Ncsvginterface.php 3.65 KB
<?php
/**
 * @package  anc_image
 * @category magento
 * @mailto	code [at] netz.coop
 * @author	netz.coop eG* 
 * @copyright (c) 2014, netz.coop eG
 * 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */ 
class Anc_Image_Helper_Ncsvginterface extends Mage_Core_Helper_Abstract {
	/**
	 *  Bearbeiten eines BildElementes in einer SVG (erstellt mit Inkscape Erweiterung)
	 * @param type $domel
	 * @param type $p_parentitemId
	 * @param type $MagentoID
	 * @return type
	 */
	public function editImageSVG(DOMNode $domel, $p_parentitemId, $MagentoID) {
		/**
		 * anc_image .... 
		 */
		if (true) {
			$ChildrenItemIds = Mage::helper('anc_printconfigproduct/cart')->getChildrenItemIds($p_parentitemId, $MagentoID);
			$CropfilePath = Mage::helper('anc_image/ncimage')->getCropfilePath($ChildrenItemIds[0], 'absolute');
			
			if($CropfilePath) {
				$domel->setAttribute('xlink:href', 'file://' . $CropfilePath);
			} else {
				$ItemProductOptionByOptionSku = Mage::helper('anc_lib/quoteitem')->getItemProductOptionByOptionSku($ChildrenItemIds[0], Mage::helper('anc_image/ncconstant')->ancSPAncImage);
				if ($ItemProductOptionByOptionSku) {
					$NcImageRelativePath = Mage::helper('anc_image/ncimage')->getNcImagePath($ItemProductOptionByOptionSku, 'absolute', 'original');
					if ($NcImageRelativePath) {
						$domel->setAttribute('xlink:href', 'file://' . $NcImageRelativePath);
					}
				} else {
	//				D::ulli("editImageSVG($domel, $p_parentitemId, $MagentoID)".$ChildrenItemIds[0].": es wurde kein Bild zum ersetzen angegeben, also gibts das svg bild");
				}				
			}
		}
		/**
		 * version wenns eine magento datei ist und nicht das neue anc_image gennutzt wird
		 */ else {
			$ary_backdata = Mage::helper('anc_printconfigproduct/cart')->doGetChildItemOptionInfoBuyRequest($p_parentitemId, $MagentoID);

			$file = $this->getImagefromOptions($ary_backdata[0]['options']);
			if ($file) {
				$domel->setAttribute('xlink:href', 'file://' . $file);
			}
		}
		return $domel;
	}
	
	/**
	 * Gibt ein Bildpfad aus dem Optionen Array der Media Gallery zurück 
	 * bei mehr Bildern eine Ausgabe in der mc_log 
	 * @param array $p_options
	 * @param type $parmam_what
	 * @return array
	 */
	private function getImagefromOptions(array $p_options, $parmam_what = "fullpath") {
		$filename = null;
		foreach ($p_options as $key => $valarray) {
			if (!$filename) {
				$filename = $p_options[$key]['fullpath'];
			} else {
				$filename2 = $p_options[$key]['fullpath'];
			}
		}
		return $filename;
	}	
	
	
	public function replaceSignature($customerid=null,$param_char='A'){
		
		$fontname = Mage::helper('anc_image/ncimage')->getFontName($customerid,$param_char);
		if($fontname){
			$string = '<flowSpan id="flowSpanUnterschrift" style="font-size:1em;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:\''.$fontname.' Font\';-inkscape-font-specification:\''.$fontname.' Font\'">A</flowSpan>';
		}else{
			$string= 'Unterschrift ist nicht im System';
		}
//		D::ulli('$string'.$string,1,1);
		return $string;
//		
//		$fontname = 
//		
//		return $replacestring;
	}
	
	
}