ancimage.phtml 5.53 KB
<?php 
	/** 
	 * 
	 * @var $this anc_image/catalog_product_view_options_type_ancimage
	 * 
	 * @package	anc_image 
	 * @anc_image_eingabetyp -- Formular bzw ansicht im Frontend im Warenkorb beim Produkt konfigurieren
	 * @copy Grundlage: Magento18/app/design/frontend/base/default/template/catalog/product/view/options/type/text.phtml 
	 * @since	20140416 
	 * @author	netz.coop eG* 
	 */ 
?>
<?php 

/**
 * @cache problem
 */
Mage::app()->cleanCache();


?>
<?php $DropzoneIndex = Mage::helper('anc_lib/data')->getElementIndexForId(); ?>
<?php $dropzone_id = 'ancimage-dropzone-id'.$DropzoneIndex; ?> 
<?php $ancnote_id = 'ancnote-id'; ?>
<?php $_option = $this->getOption(); ?>
<?php $input_id = 'options_'.$_option->getId().'_text'; ?> 
<div class="ancimage-ancimage anc-productview">
	<script type="text/javascript">
		function loadNcImageIntoProductGalleryThumbnailButton() {
			jQuery('.anc_image_choose').unbind("click").click(function(e){
				e.preventDefault(); 			
				Anc_Image_Type.loadImageInto(
					jQuery(this).data('anc_image_id'), 
					jQuery('#<?php echo $input_id; ?>'),
					jQuery(this).data('anc_image_url'), 
					jQuery('#<?php echo $dropzone_id; ?>')
				);
			});				
		}
	</script>

	<div class="ancimage_type anc-productview-type" id="<?php echo $_option->getSku(); ?>">
		<div class="ancimage_type-fakewrapper anc-productview-type-fakewrapper">
			<div id="<?php echo $ancnote_id; ?>"></div>
			<input type="hidden" onchange="opConfig.reloadPrice()" id="<?php echo $input_id ?>" class="input-text<?php echo $_option->getIsRequire() ? ' required-entry' : '' ?> <?php echo $_option->getMaxCharacters() ? ' validate-length maximum-length-'.$_option->getMaxCharacters() : '' ?> product-custom-option" name="options[<?php echo $_option->getId() ?>]" value="<?php echo $this->escapeHtml($this->getDefaultValue()) ?>" />
			<div class="ancimage-info">
				<div class="editor"></div>
				<div class="image"></div>					
			</div>
			<div class="<?php echo $_option->getSku(); ?>" id="ancimage-imageeditorarea-id">

				<div id="<?php echo $dropzone_id; ?>"  
					 class="dropzone ancimage-dropzone" 
					 title="" 
					 data-pxwidth="<?php echo $_option->getImageSizeX() ?>"
					 data-pxheight="<?php echo $_option->getImageSizeY() ?>"
					 data-maxfilesizemb="<?php echo $_option->getMaxCharacters() ?>"
				>
					<?php $path = Mage::helper('anc_image/ncimage')->getNcImagePath($this->getDefaultValue(), 'relative', 'original'); ?>
					<?php // $Currentpageinfos = Mage::helper('anc_lib/data')->getCurrentcheckoutcartinfos(); ?>
					<?php $ItemInfos=  Mage::helper('anc_lib/data')->getCheckoutCartItemInfos(); ?>
					<?php $Cropdata = Mage::helper('anc_image/ncimage')->getCropdata($ItemInfos['item_id']); ?>
					<div class="preview-database-image"
						 data-imagesrc="<?php echo DS.$path; ?>"
						 <?php if(is_array($Cropdata)): ?>
							data-cropH="<?php echo $Cropdata['cropH']; ?>"
							data-cropW="<?php echo $Cropdata['cropW']; ?>"
							data-imgH="<?php echo $Cropdata['imgH']; ?>"
							data-imgW="<?php echo $Cropdata['imgW']; ?>"
							data-imgInitH="<?php echo $Cropdata['imgInitH']; ?>"
							data-imgInitW="<?php echo $Cropdata['imgInitW']; ?>"
							data-imgX1="<?php echo $Cropdata['imgX1']; ?>"
							data-imgY1="<?php echo $Cropdata['imgY1']; ?>"
						 <?php endif; ?>
					 >
						<?php // if($path):?>
							<!--<img src="<?php // echo $path; ?>" />-->
						<?php // endif; ?>
					</div>
				</div>
			</div>			
		</div>
	</div>

<!-- Gallerien zum auswählen -->
	<?php $gallerie_dropzone_id = 'ancimage-dropzone-id'.Mage::helper('anc_lib/data')->getElementIndexForId(); ?> 
	<div class="ancimage_type-possibility anc-productview-possibility">
		<?php echo $this->getLayout()
						->getBlockSingleton('anc_image/galleriesmanager')
						->setTemplate('anc/image/customer_galleries.phtml')
						->setIfGalleryCategory(true)
						->setSelectorIdDropzoneOwn($gallerie_dropzone_id)
						->toHtml(); ?>
		<script type="text/javascript">
			jQuery(document).ready(function($) {
				// damit initialen laden der Gallerie auch die Thumbnail-Bilder-Button funktionieren
					loadNcImageIntoProductGalleryThumbnailButton();		
			}); 
		</script>
	</div>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			var dropzone_params = {
				url: "<?php echo $this->getUrl('ancimage/customer/uploadImage', array()) ?>",
				dictDefaultMessage: 'Bild hochladen',
				success: function() {	this.removeAllFiles();	}
			}
			
			var gallery_ajaxData = {
				url: "<?php echo $this->getUrl('ancimage/customer/gallerysimple', array()) ?>  ul.gallery",
				context: jQuery(".ancimage-customer_galleriesown > .ancimage-gallerie-content > .ancimage-gallerie-content-view"),
				success: function(reponse) { 
					// damit das hochgeladene Bild auch in der dropbopx angezeigt wird
						Anc_Image_Type.loadImageInto(
							reponse.id, 
//							jQuery('#<?php // echo $_option->getSku(); ?> > dd > .input-box > input'), 
							jQuery('#<?php echo $input_id; ?>'),
							'<?php echo DS; ?>'+reponse.path, 
							jQuery('#<?php echo $dropzone_id; ?>')
						);			
				
					// damit nach hochladen eines bildes und darauf folgende reloaden der gallerie,
					// die (anderen) galleriebilder wieder in die dropbox geladen werden können				
						loadNcImageIntoProductGalleryThumbnailButton();
						
				},
			};			
			
			Anc_Image_Type.droppableFile(
				jQuery(" #<?php echo $gallerie_dropzone_id; ?>"), 
				dropzone_params,
				jQuery(" #<?php echo $input_id; ?>"), 
				jQuery(" #<?php echo $ancnote_id; ?>"), 
				gallery_ajaxData,
				false
			);					

		}); 
	</script>		
</div>