Ncsvginterface.php
5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?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;
}
}