Ncsvginterface.php 5 KB
<?php
/**
 * @package  anc_text 
 * @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_Text_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
	 */
		private $editTextNoodeParentId='';
	public function editTextSVG(DOMNode $domel, $p_parentitemId, $MagentoID) {
		/**
		 * anc_text .... 
		 */
		if (true) {
			$ChildrenItemIds = Mage::helper('anc_printconfigproduct/cart')->getChildrenItemIds($p_parentitemId, $MagentoID);
			$nctext_id = Mage::helper('anc_lib/quoteitem')->getItemProductOptionByOptionSku($ChildrenItemIds[0], Mage::helper('anc_text/ncconstant')->AncSPTextOptionSku);
			$nctext = Mage::helper('anc_text/ncmodel')->getNcText($nctext_id);
			$domtags = $domel->getElementsByTagName(Mage::helper('anc_printconfigproduct/constant')->get('ancpcpSVGEditTagText'));
			foreach ($domtags as $domtag) {
			if ($nctext['content']) {
					$p_where = array("option_id" => $nctext_id);
					$varoptionser = Mage::helper('anc_lib/sql')->selectFetchOne("type", "catalog_product_option", $p_where);
						if ($domtag->nodeName == Mage::helper('anc_printconfigproduct/constant')->get('ancpcpSVGEditTagText')&& $domtag->parentNode->getAttribute('MagentoID')==$MagentoID) {

							$value_tmp = Mage::helper('anc_printconfigproduct/xml')->replaceinCalnamedates($nctext['content']);
							
							$value_tmp = Mage::helper('anc_printconfigproduct/xmlfrontend')->replaceHtmlforInkscape($value_tmp);
							$value= Mage::helper('anc_printconfigproduct/placeholder')->replaceStringWithArrayValues($value_tmp);						
							$domtag->nodeValue = '';							
							$parentNode= $domtag->parentNode;
							$parentId=$parentNode->getAttribute('id');;
							$parentName=$parentNode->nodeName;
							if($parentId === $this->editTextNoodeParentId){
								
							}else{
								Mage::helper('anc_printconfigproduct/xmlfrontend')->appendHTML($domtag, $value);
							}
							$this->editTextNoodeParentId=$parentId;
						}
			}	
				
				
				
				
				
				
				
				
				
			}
		}
		/**
		 * version wenns eine magento datei ist und nicht das neue anc_text gennutzt wird
		 */ else {
//			$ary_backdata = Mage::helper('anc_printconfigproduct/cart')->doGetChildItemOptionInfoBuyRequest($p_parentitemId, $MagentoID);
//
//			$file = $this->getTextfromOptions($ary_backdata[0]['options']);
//			if ($file) {
//				$domel->setAttribute('xlink:href', 'file://' . $file);
//			}
		}
		return $domel;
	}
	
	
	
	
	
		public function editTextSVG2(DOMNode $domel, $p_parentitemId, $MagentoID) {
		$ary_backdata = Mage::helper('anc_printconfigproduct/cart')->doGetChildItemOptionInfoBuyRequest($p_parentitemId, $MagentoID);
		$domtags = $domel->getElementsByTagName(Mage::helper('anc_printconfigproduct/constant')->get('ancpcpSVGEditTagText'));
		foreach ($domtags as $domtag) {
			if (is_array($ary_backdata[0])) {
				foreach ($ary_backdata[0]['options'] as $key => $value) {
					$p_where = array("option_id" => $key);
					$varoptionser = Mage::helper('anc_lib/sql')->selectFetchOne("type", "catalog_product_option", $p_where);
					if ($varoptionser == 'area') {
						if ($domtag->nodeName == Mage::helper('anc_printconfigproduct/constant')->get('ancpcpSVGEditTagText')&& $domtag->parentNode->getAttribute('MagentoID')==$MagentoID) {
							$num_br = count($positions_html_array[0]);
							$value = Mage::helper('anc_printconfigproduct/xml')->replaceinCalnamedates($value);
							$value = Mage::helper('anc_printconfigproduct/xmlfrontend')->replaceHtmlforInkscape($value);
							$domtag->nodeValue = '';
							Mage::helper('anc_printconfigproduct/xmlfrontend')->appendHTML($domtag, $value);
						}
					}
				}
			}
		}
		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 getTextfromOptions(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;
	}	
}