Version Notes
- Added XML helper into postoffice package
Download this release
Release Info
Developer | Magento Core Team |
Extension | Eabi_DpdEE |
Version | 0.1.30 |
Comparing to | |
See all releases |
Code changes from version 0.1.29 to 0.1.30
- app/code/community/Eabi/DpdEE/CHANGELOG.txt +3 -0
- app/code/community/Eabi/DpdEE/etc/config.xml +1 -1
- app/code/community/Eabi/Postoffice/Helper/Xml.php +781 -0
- app/code/community/Eabi/Postoffice/etc/config.xml +1 -1
- app/etc/modules/Eabi_DpdEE.xml +1 -1
- app/etc/modules/Eabi_Postoffice.xml +1 -1
- package.xml +5 -6
app/code/community/Eabi/DpdEE/CHANGELOG.txt
CHANGED
@@ -95,3 +95,6 @@
|
|
95 |
0.1.29
|
96 |
- Pickup point extra info is stored correctly
|
97 |
- Mixed content warning removed from admin configuration panel
|
|
|
|
|
|
95 |
0.1.29
|
96 |
- Pickup point extra info is stored correctly
|
97 |
- Mixed content warning removed from admin configuration panel
|
98 |
+
|
99 |
+
0.1.30
|
100 |
+
- Added XML helper into postoffice package
|
app/code/community/Eabi/DpdEE/etc/config.xml
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
<config>
|
37 |
<modules>
|
38 |
<Eabi_DpdEE>
|
39 |
-
<version>0.1.
|
40 |
</Eabi_DpdEE>
|
41 |
</modules>
|
42 |
|
36 |
<config>
|
37 |
<modules>
|
38 |
<Eabi_DpdEE>
|
39 |
+
<version>0.1.30</version>
|
40 |
</Eabi_DpdEE>
|
41 |
</modules>
|
42 |
|
app/code/community/Eabi/Postoffice/Helper/Xml.php
ADDED
@@ -0,0 +1,781 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://opensource.org/licenses/osl-3.0.php
|
13 |
+
* or
|
14 |
+
* http://www.gnu.org/licenses/gpl-3.0.txt
|
15 |
+
* If you did not receive a copy of the license and are unable to
|
16 |
+
* obtain it through the world-wide-web, please send an email
|
17 |
+
* to info@e-abi.ee so we can send you a copy immediately.
|
18 |
+
*
|
19 |
+
* DISCLAIMER
|
20 |
+
*
|
21 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
22 |
+
* versions in the future.
|
23 |
+
*
|
24 |
+
* @category Eabi
|
25 |
+
* @package Eabi_Dpd
|
26 |
+
* @copyright Copyright (c) 2016 Aktsiamaailm LLC (http://en.e-abi.ee/)
|
27 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
28 |
+
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
|
29 |
+
* @author Matis Halmann
|
30 |
+
*
|
31 |
+
|
32 |
+
*/
|
33 |
+
|
34 |
+
/**
|
35 |
+
* <p>Converts PHP assoc array to SoapVar</p>
|
36 |
+
*
|
37 |
+
* @author Matis
|
38 |
+
*/
|
39 |
+
class Eabi_Postoffice_Helper_Xml extends Mage_Core_Helper_Abstract {
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* <p>holds xpath compatible queries</p>
|
44 |
+
* <p>Format:</p>
|
45 |
+
* <pre>
|
46 |
+
$this->_queryDetails[xpath_selector] = array(
|
47 |
+
'query' => xpath_selector,
|
48 |
+
'exec' => indexed or assoc array of operations,
|
49 |
+
);
|
50 |
+
*</pre>
|
51 |
+
* <p>indexed operations will change XML attributes based on the order of XML tags appearing</p>
|
52 |
+
* <p>assoc array operation will change XML attributes on all matching XML tags</p>
|
53 |
+
* @var array
|
54 |
+
*/
|
55 |
+
protected $_queryDetails = array();
|
56 |
+
|
57 |
+
/**
|
58 |
+
* <p>Converts assoc array to SoapVar and fills up XML attributes, if they are contained in <code>$variable</code></p>
|
59 |
+
* <p>Sample input:</p>
|
60 |
+
* <pre>
|
61 |
+
*
|
62 |
+
*
|
63 |
+
*$variable = array(
|
64 |
+
'pick_up_time' => array(
|
65 |
+
'@attributes' => array(
|
66 |
+
'start' => '2011-08-10T12:15:00',
|
67 |
+
'finish' => '2011-08-10T14:30:00',
|
68 |
+
),
|
69 |
+
'worker' => 'Töötaja nimi',
|
70 |
+
'extra' => array(
|
71 |
+
0 => array(
|
72 |
+
'@attributes' => array(
|
73 |
+
'extra_var' => '3',
|
74 |
+
),
|
75 |
+
),
|
76 |
+
1 => array(
|
77 |
+
'@attributes' => array(
|
78 |
+
'extra_var' => '',
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
);
|
84 |
+
* </pre>
|
85 |
+
* <p>Results in following XML:</p>
|
86 |
+
* <pre>
|
87 |
+
<pick_up_time start="2011-08-10T12:15:00" finish="2011-08-10T14:30:00">
|
88 |
+
<worker>Töötaja nimi</worker>
|
89 |
+
<extra extra_var="3" />
|
90 |
+
<extra extra_var="" />
|
91 |
+
</pick_up_time>
|
92 |
+
* </pre>
|
93 |
+
* @param array $variable
|
94 |
+
* @param array $attributes SoapVar does not support XML attributes, you need to overwrite SoapClient class and apply attributes as xpath queries
|
95 |
+
* @param string $namespace
|
96 |
+
* @return \SoapVar
|
97 |
+
*/
|
98 |
+
public function toXmlVar($variable, array &$attributes = array(), $namespace = null) {
|
99 |
+
$this->_queryDetails = array();
|
100 |
+
$result = '';
|
101 |
+
if (is_array($variable)) {
|
102 |
+
$this->_toXmlVar($result, $variable, $namespace, -1, '');
|
103 |
+
$attributes = $this->_queryDetails;
|
104 |
+
|
105 |
+
|
106 |
+
return $result;
|
107 |
+
} else {
|
108 |
+
return $variable;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* <p>Recursive function to convert <code>$variable</code> into SoapVar equivalent.</p>
|
115 |
+
* @param SoapVar $result result will be stored here
|
116 |
+
* @param array $variable assoc array which would be converted to <code>SoapVar</code>
|
117 |
+
* @param type $namespace SoapVar xml namespace
|
118 |
+
* @param int $level depth level
|
119 |
+
* @param string $parentKey parent XML node name
|
120 |
+
* @param array $parents first element is root XML node name, last element is direct parents XML node name
|
121 |
+
*/
|
122 |
+
private function _toXmlVar(&$str, $variable, $namespace, $level, $parentKey, $parents = array(), $aattributesString = '') {
|
123 |
+
$tmpResult = array();
|
124 |
+
$char = ""; //"\t";
|
125 |
+
$line = ""; //"\r\n";
|
126 |
+
|
127 |
+
|
128 |
+
$attributesSymbol = '@attributes';
|
129 |
+
//such a case is only case when attributes can be contained
|
130 |
+
$attributes = isset($variable[$attributesSymbol]) ? $variable[$attributesSymbol] : array();
|
131 |
+
if (isset($variable[$attributesSymbol])) {
|
132 |
+
unset($variable[$attributesSymbol]);
|
133 |
+
}
|
134 |
+
$attributesString = '';
|
135 |
+
if (count($attributes)) {
|
136 |
+
//add xpath compatible query details in order to be able to fill up XML attributes afterwards
|
137 |
+
$this->_addQuery('//' . implode('/', $parents), $attributes);
|
138 |
+
$attributesArray = array();
|
139 |
+
foreach ($attributes as $ak => $av) {
|
140 |
+
$attributesArray[] = htmlspecialchars($ak) . '="' . htmlspecialchars($av) . '"';
|
141 |
+
}
|
142 |
+
$attributesString .= ' ' . implode(' ', $attributesArray);
|
143 |
+
}
|
144 |
+
|
145 |
+
//handle case, where 'nodename' => 'nodevalue'
|
146 |
+
if (is_array($variable) && $this->_isAssoc($variable)) {
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
if ($parentKey != '') {
|
152 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($parentKey) . $attributesString . ">$line";
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
foreach ($variable as $key => $value) {
|
158 |
+
if (is_array($value) && $this->_isAssoc($value)) {
|
159 |
+
//regular assoc array recursion, where $key is corresponding parent
|
160 |
+
|
161 |
+
$tmpParents = $parents;
|
162 |
+
$tmpParents[] = $key;
|
163 |
+
$this->_toXmlVar($str, $value, $namespace, $level + 1, $key, $tmpParents);
|
164 |
+
} else if (is_array($value) && !$this->_isAssoc($value)) {
|
165 |
+
//indexed array recursion, where each subvalue shares same $key parent
|
166 |
+
$tmpVar = array();
|
167 |
+
$tmpParents = $parents;
|
168 |
+
$tmpParents[] = $key;
|
169 |
+
|
170 |
+
$iattributes = isset($value[$attributesSymbol]) ? $value[$attributesSymbol] : array();
|
171 |
+
|
172 |
+
if (isset($value[$attributesSymbol])) {
|
173 |
+
unset($value[$attributesSymbol]);
|
174 |
+
}
|
175 |
+
$iattributesString = '';
|
176 |
+
if (count($iattributes)) {
|
177 |
+
//add xpath compatible query details in order to be able to fill up XML attributes afterwards
|
178 |
+
$this->_addQuery('//' . implode('/', $parents), $iattributes);
|
179 |
+
$iattributesArray = array();
|
180 |
+
foreach ($iattributes as $ak => $av) {
|
181 |
+
$iattributesArray[] = htmlspecialchars($ak) . '="' . htmlspecialchars($av) . '"';
|
182 |
+
}
|
183 |
+
$iattributesString .= ' ' . implode(' ', $iattributesArray);
|
184 |
+
}
|
185 |
+
// $str .= str_repeat($char, $level) . "<" . htmlspecialchars($key) . $attributesString . ">$line";
|
186 |
+
// $str .= htmlspecialchars($subValue);
|
187 |
+
// $this->_toXmlVar($str, $subValue, $namespace, $level + 1, $key, $tmpParents);
|
188 |
+
// $str .= str_repeat($char, $level) . "</" . htmlspecialchars($key) . ">$line";
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
foreach ($value as $skey => $subValue) {
|
193 |
+
$this->_toXmlVar($str, $subValue, $namespace, $level + 1, $key, $tmpParents, $iattributesString);
|
194 |
+
}
|
195 |
+
} else {
|
196 |
+
//no recursion, create XML string SoapVar element
|
197 |
+
if ($value !== null) {
|
198 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($key) . ">$line";
|
199 |
+
$str .= htmlspecialchars($value);
|
200 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($key) . ">$line";
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
if ($parentKey != '')
|
205 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($parentKey) . ">$line";
|
206 |
+
} else if (is_array($variable) && !$this->_isAssoc($variable)) {
|
207 |
+
//handle indexed array recursion, where $parentKey is shared among the children
|
208 |
+
|
209 |
+
|
210 |
+
if ($parentKey != '')
|
211 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($parentKey) . $attributesString . ">$line";
|
212 |
+
|
213 |
+
foreach ($variable as $value) {
|
214 |
+
if (is_array($value)) {
|
215 |
+
$tmpParents = $parents;
|
216 |
+
$tmpParents[] = $parentKey;
|
217 |
+
|
218 |
+
$this->_toXmlVar($str, $value, $namespace, $level + 0, $parentKey, $tmpParents);
|
219 |
+
} else {
|
220 |
+
//no recursion, create XML string SoapVar element
|
221 |
+
if ($value !== null) {
|
222 |
+
$str .= htmlspecialchars($value);
|
223 |
+
|
224 |
+
|
225 |
+
// $str .= htmlspecialchars($value);
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
if ($parentKey != '')
|
230 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($parentKey) . ">$line";
|
231 |
+
} else if (is_string($variable)) {
|
232 |
+
|
233 |
+
if ($parentKey != '')
|
234 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($parentKey) . $aattributesString . ">$line";
|
235 |
+
$str .= htmlspecialchars($variable);
|
236 |
+
if ($parentKey != '')
|
237 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($parentKey) . ">$line";
|
238 |
+
}
|
239 |
+
//once iterated, put together SoaVar object from the collected $result
|
240 |
+
// $result = $str;
|
241 |
+
// return $result;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* <p>Returns true, if <code>$arr</code> is associative array false otherwise</p>
|
246 |
+
* @param array $arr
|
247 |
+
* @return bool
|
248 |
+
*/
|
249 |
+
private function _isAssoc($arr) {
|
250 |
+
$cp = $arr;
|
251 |
+
if (isset($cp['@attributes'])) {
|
252 |
+
unset($cp['@attributes']);
|
253 |
+
}
|
254 |
+
return array_keys($cp) !== range(0, count($cp) - 1);
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* <p>Converts assoc array to SoapVar and fills up XML attributes, if they are contained in <code>$variable</code></p>
|
259 |
+
* <p>Sample input:</p>
|
260 |
+
* <pre>
|
261 |
+
*
|
262 |
+
*
|
263 |
+
* $variable = array(
|
264 |
+
'pick_up_time' => array(
|
265 |
+
'@attributes' => array(
|
266 |
+
'start' => '2011-08-10T12:15:00',
|
267 |
+
'finish' => '2011-08-10T14:30:00',
|
268 |
+
),
|
269 |
+
'worker' => 'Töötaja nimi',
|
270 |
+
'extra' => array(
|
271 |
+
0 => array(
|
272 |
+
'@attributes' => array(
|
273 |
+
'extra_var' => '3',
|
274 |
+
),
|
275 |
+
),
|
276 |
+
1 => array(
|
277 |
+
'@attributes' => array(
|
278 |
+
'extra_var' => '',
|
279 |
+
),
|
280 |
+
),
|
281 |
+
),
|
282 |
+
),
|
283 |
+
);
|
284 |
+
* </pre>
|
285 |
+
* <p>Results in following XML:</p>
|
286 |
+
* <pre>
|
287 |
+
<pick_up_time start="2011-08-10T12:15:00" finish="2011-08-10T14:30:00">
|
288 |
+
<worker>Töötaja nimi</worker>
|
289 |
+
<extra extra_var="3" />
|
290 |
+
<extra extra_var="" />
|
291 |
+
</pick_up_time>
|
292 |
+
* </pre>
|
293 |
+
* @param array $variable
|
294 |
+
* @param array $attributes SoapVar does not support XML attributes, you need to overwrite SoapClient class and apply attributes as xpath queries
|
295 |
+
* @param string $namespace
|
296 |
+
* @return \SoapVar
|
297 |
+
*/
|
298 |
+
public function toSoapVar($variable, array &$attributes = array(), $namespace = null) {
|
299 |
+
$this->_queryDetails = array();
|
300 |
+
$result = array();
|
301 |
+
if (is_array($variable)) {
|
302 |
+
$this->_toSoapVar($result, $variable, $namespace, -1, '');
|
303 |
+
$attributes = $this->_queryDetails;
|
304 |
+
|
305 |
+
|
306 |
+
return $result;
|
307 |
+
} else {
|
308 |
+
return new SoapVar($variable, XSD_STRING, null, $namespace, '');
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
|
313 |
+
/**
|
314 |
+
* <p>Recursive function to convert <code>$variable</code> into SoapVar equivalent.</p>
|
315 |
+
* @param SoapVar $result result will be stored here
|
316 |
+
* @param array $variable assoc array which would be converted to <code>SoapVar</code>
|
317 |
+
* @param type $namespace SoapVar xml namespace
|
318 |
+
* @param int $level depth level
|
319 |
+
* @param string $parentKey parent XML node name
|
320 |
+
* @param array $parents first element is root XML node name, last element is direct parents XML node name
|
321 |
+
*/
|
322 |
+
private function _toSoapVar(&$result, $variable, $namespace, $level, $parentKey, $parents = array()) {
|
323 |
+
$tmpResult = array();
|
324 |
+
|
325 |
+
$attributesSymbol = '@attributes';
|
326 |
+
|
327 |
+
//handle case, where 'nodename' => 'nodevalue'
|
328 |
+
if (is_array($variable) && $this->_isAssoc($variable)) {
|
329 |
+
//such a case is only case when attributes can be contained
|
330 |
+
$attributes = isset($variable[$attributesSymbol])?$variable[$attributesSymbol]:array();
|
331 |
+
if (isset($variable[$attributesSymbol])) {
|
332 |
+
unset($variable[$attributesSymbol]);
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
if (count($attributes)) {
|
337 |
+
//add xpath compatible query details in order to be able to fill up XML attributes afterwards
|
338 |
+
$this->_addQuery('//' . implode('/', $parents), $attributes);
|
339 |
+
}
|
340 |
+
|
341 |
+
foreach ($variable as $key => $value) {
|
342 |
+
if (is_array($value) && $this->_isAssoc($value)) {
|
343 |
+
//regular assoc array recursion, where $key is corresponding parent
|
344 |
+
|
345 |
+
$tmpParents = $parents;
|
346 |
+
$tmpParents[] = $key;
|
347 |
+
$this->_toSoapVar($tmpResult[], $value, $namespace, $level + 1, $key, $tmpParents);
|
348 |
+
} else if (is_array($value) && !$this->_isAssoc($value)) {
|
349 |
+
//indexed array recursion, where each subvalue shares same $key parent
|
350 |
+
$tmpVar = array();
|
351 |
+
$tmpParents = $parents;
|
352 |
+
$tmpParents[] = $key;
|
353 |
+
foreach ($value as $subValue) {
|
354 |
+
$this->_toSoapVar($tmpResult[], $subValue, $namespace, $level + 1, $key, $tmpParents);
|
355 |
+
}
|
356 |
+
} else {
|
357 |
+
//no recursion, create XML string SoapVar element
|
358 |
+
if ($value !== null) {
|
359 |
+
$tmpResult[] = new SoapVar($value, XSD_STRING, null, $namespace, $key);
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
} else if (is_array($variable) && !$this->_isAssoc($variable)) {
|
364 |
+
//handle indexed array recursion, where $parentKey is shared among the children
|
365 |
+
|
366 |
+
foreach ($variable as $value) {
|
367 |
+
if (is_array($value)) {
|
368 |
+
$tmpParents = $parents;
|
369 |
+
$tmpParents[] = $parentKey;
|
370 |
+
|
371 |
+
|
372 |
+
$this->_toSoapVar($tmpResult[], $value, $namespace, $level + 0, $parentKey, $tmpParents);
|
373 |
+
} else {
|
374 |
+
//no recursion, create XML string SoapVar element
|
375 |
+
if ($value !== null) {
|
376 |
+
$tmpResult[] = new SoapVar($value, XSD_STRING, null, $namespace, $parentKey);
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
} else if (is_string($variable)){
|
381 |
+
$tmpResult[] = new SoapVar($variable, XSD_STRING, null, $namespace, $parentKey);
|
382 |
+
}
|
383 |
+
//once iterated, put together SoaVar object from the collected $result
|
384 |
+
$result = new SoapVar((object) $tmpResult, SOAP_ENC_OBJECT, null, $namespace, $parentKey);
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
/**
|
389 |
+
* <p>Returns true, if <code>$arr</code> is associative array false otherwise</p>
|
390 |
+
* @param array $arr
|
391 |
+
* @return bool
|
392 |
+
*/
|
393 |
+
private function _isAssoc_old($arr) {
|
394 |
+
return array_keys($arr) !== range(0, count($arr) - 1);
|
395 |
+
}
|
396 |
+
|
397 |
+
|
398 |
+
/**
|
399 |
+
* <p>Adds xpath compatible queryes based on <code>$query</code> xpath and array of <code>$operations</code></p>
|
400 |
+
* @param string $query
|
401 |
+
* @param array $operations
|
402 |
+
*/
|
403 |
+
protected function _addQuery($query, $operations) {
|
404 |
+
if (isset($this->_queryDetails[$query])) {
|
405 |
+
$item = $this->_queryDetails[$query];
|
406 |
+
|
407 |
+
//create multi item result so each sequential node would get it's own result
|
408 |
+
if (!isset($item['exec'][0])) {
|
409 |
+
$item['exec'] = array($item['exec']);
|
410 |
+
}
|
411 |
+
$item['exec'][] = $operations;
|
412 |
+
} else {
|
413 |
+
$item = array(
|
414 |
+
'query' => $query,
|
415 |
+
'exec' => $operations,
|
416 |
+
);
|
417 |
+
}
|
418 |
+
$this->_queryDetails[$query] = $item;
|
419 |
+
}
|
420 |
+
|
421 |
+
|
422 |
+
/**
|
423 |
+
* To check the allowed nesting depth of the XML tree during xml2json conversion.
|
424 |
+
*
|
425 |
+
* @var int
|
426 |
+
*/
|
427 |
+
public static $maxRecursionDepthAllowed = 25;
|
428 |
+
|
429 |
+
/**
|
430 |
+
* fromXml - Converts XML to JSON
|
431 |
+
*
|
432 |
+
* Converts a XML formatted string into a JSON formatted string.
|
433 |
+
* The value returned will be a string in JSON format.
|
434 |
+
*
|
435 |
+
* The caller of this function needs to provide only the first parameter,
|
436 |
+
* which is an XML formatted String. The second parameter is optional, which
|
437 |
+
* lets the user to select if the XML attributes in the input XML string
|
438 |
+
* should be included or ignored in xml2json conversion.
|
439 |
+
*
|
440 |
+
* This function converts the XML formatted string into a PHP array by
|
441 |
+
* calling a recursive (protected static) function in this class. Then, it
|
442 |
+
* converts that PHP array into JSON by calling the "encode" static funcion.
|
443 |
+
*
|
444 |
+
* Throws a Zend_Json_Exception if the input not a XML formatted string.
|
445 |
+
* NOTE: Encoding native javascript expressions via Zend_Json_Expr is not possible.
|
446 |
+
*
|
447 |
+
* @access public
|
448 |
+
* @param string $xmlStringContents XML String to be converted
|
449 |
+
* @param boolean $ignoreXmlAttributes Include or exclude XML attributes in
|
450 |
+
* the xml2json conversion process.
|
451 |
+
* @return mixed - JSON formatted string on success
|
452 |
+
* @throws Zend_Json_Exception
|
453 |
+
*/
|
454 |
+
public function fromXml($xmlStringContents, $ignoreXmlAttributes = true, $useNew = false) {
|
455 |
+
// Load the XML formatted string into a Simple XML Element object.
|
456 |
+
$simpleXmlElementObject = simplexml_load_string($xmlStringContents);
|
457 |
+
|
458 |
+
// If it is not a valid XML content, throw an exception.
|
459 |
+
if ($simpleXmlElementObject == null) {
|
460 |
+
//require_once 'Zend/Json/Exception.php';
|
461 |
+
throw new Zend_Json_Exception('Function fromXml was called with an invalid XML formatted string.');
|
462 |
+
} // End of if ($simpleXmlElementObject == null)
|
463 |
+
|
464 |
+
$resultArray = null;
|
465 |
+
|
466 |
+
// Call the recursive function to convert the XML into a PHP array.
|
467 |
+
if ($useNew) {
|
468 |
+
$resultArray = self::_processXml2($simpleXmlElementObject, $ignoreXmlAttributes);
|
469 |
+
} else {
|
470 |
+
$resultArray = self::_processXml($simpleXmlElementObject, $ignoreXmlAttributes);
|
471 |
+
}
|
472 |
+
|
473 |
+
// Convert the PHP array to JSON using Zend_Json encode method.
|
474 |
+
// It is just that simple.
|
475 |
+
return $resultArray;
|
476 |
+
}
|
477 |
+
|
478 |
+
// End of function fromXml.
|
479 |
+
|
480 |
+
/**
|
481 |
+
* _processXml - Contains the logic for xml2json
|
482 |
+
*
|
483 |
+
* The logic in this function is a recursive one.
|
484 |
+
*
|
485 |
+
* The main caller of this function (i.e. fromXml) needs to provide
|
486 |
+
* only the first two parameters i.e. the SimpleXMLElement object and
|
487 |
+
* the flag for ignoring or not ignoring XML attributes. The third parameter
|
488 |
+
* will be used internally within this function during the recursive calls.
|
489 |
+
*
|
490 |
+
* This function converts the SimpleXMLElement object into a PHP array by
|
491 |
+
* calling a recursive (protected static) function in this class. Once all
|
492 |
+
* the XML elements are stored in the PHP array, it is returned to the caller.
|
493 |
+
*
|
494 |
+
* Throws a Zend_Json_Exception if the XML tree is deeper than the allowed limit.
|
495 |
+
*
|
496 |
+
* @static
|
497 |
+
* @access protected
|
498 |
+
* @param SimpleXMLElement $simpleXmlElementObject XML element to be converted
|
499 |
+
* @param boolean $ignoreXmlAttributes Include or exclude XML attributes in
|
500 |
+
* the xml2json conversion process.
|
501 |
+
* @param int $recursionDepth Current recursion depth of this function
|
502 |
+
* @return mixed - On success, a PHP associative array of traversed XML elements
|
503 |
+
* @throws Zend_Json_Exception
|
504 |
+
*/
|
505 |
+
protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0) {
|
506 |
+
// Keep an eye on how deeply we are involved in recursion.
|
507 |
+
if ($recursionDepth > self::$maxRecursionDepthAllowed) {
|
508 |
+
// XML tree is too deep. Exit now by throwing an exception.
|
509 |
+
//require_once 'Zend/Json/Exception.php';
|
510 |
+
throw new Zend_Json_Exception(
|
511 |
+
"Function _processXml exceeded the allowed recursion depth of " .
|
512 |
+
self::$maxRecursionDepthAllowed);
|
513 |
+
} // End of if ($recursionDepth > self::$maxRecursionDepthAllowed)
|
514 |
+
|
515 |
+
if ($recursionDepth == 0) {
|
516 |
+
// Store the original SimpleXmlElementObject sent by the caller.
|
517 |
+
// We will need it at the very end when we return from here for good.
|
518 |
+
$callerProvidedSimpleXmlElementObject = $simpleXmlElementObject;
|
519 |
+
} // End of if ($recursionDepth == 0)
|
520 |
+
|
521 |
+
if ($simpleXmlElementObject instanceof SimpleXMLElement) {
|
522 |
+
// Get a copy of the simpleXmlElementObject
|
523 |
+
$copyOfSimpleXmlElementObject = $simpleXmlElementObject;
|
524 |
+
// Get the object variables in the SimpleXmlElement object for us to iterate.
|
525 |
+
$simpleXmlElementObject = get_object_vars($simpleXmlElementObject);
|
526 |
+
} // End of if (get_class($simpleXmlElementObject) == "SimpleXMLElement")
|
527 |
+
// It needs to be an array of object variables.
|
528 |
+
if (is_array($simpleXmlElementObject)) {
|
529 |
+
// Initialize a result array.
|
530 |
+
$resultArray = array();
|
531 |
+
// Is the input array size 0? Then, we reached the rare CDATA text if any.
|
532 |
+
if (count($simpleXmlElementObject) <= 0) {
|
533 |
+
// Let us return the lonely CDATA. It could even be
|
534 |
+
// an empty element or just filled with whitespaces.
|
535 |
+
return (trim(strval($copyOfSimpleXmlElementObject)));
|
536 |
+
} // End of if (count($simpleXmlElementObject) <= 0)
|
537 |
+
// Let us walk through the child elements now.
|
538 |
+
foreach ($simpleXmlElementObject as $key => $value) {
|
539 |
+
// Check if we need to ignore the XML attributes.
|
540 |
+
// If yes, you can skip processing the XML attributes.
|
541 |
+
// Otherwise, add the XML attributes to the result array.
|
542 |
+
if (($ignoreXmlAttributes == true) && (is_string($key)) && ($key == "@attributes")) {
|
543 |
+
continue;
|
544 |
+
} // End of if(($ignoreXmlAttributes == true) && ($key == "@attributes"))
|
545 |
+
// Let us recursively process the current XML element we just visited.
|
546 |
+
// Increase the recursion depth by one.
|
547 |
+
$recursionDepth++;
|
548 |
+
$resultArray[$key] = self::_processXml($value, $ignoreXmlAttributes, $recursionDepth);
|
549 |
+
|
550 |
+
// Decrease the recursion depth by one.
|
551 |
+
$recursionDepth--;
|
552 |
+
} // End of foreach($simpleXmlElementObject as $key=>$value) {
|
553 |
+
|
554 |
+
if ($recursionDepth == 0) {
|
555 |
+
// That is it. We are heading to the exit now.
|
556 |
+
// Set the XML root element name as the root [top-level] key of
|
557 |
+
// the associative array that we are going to return to the original
|
558 |
+
// caller of this recursive function.
|
559 |
+
$tempArray = $resultArray;
|
560 |
+
$resultArray = array();
|
561 |
+
$resultArray[$callerProvidedSimpleXmlElementObject->getName()] = $tempArray;
|
562 |
+
} // End of if ($recursionDepth == 0)
|
563 |
+
|
564 |
+
return($resultArray);
|
565 |
+
} else {
|
566 |
+
// We are now looking at either the XML attribute text or
|
567 |
+
// the text between the XML tags.
|
568 |
+
// In order to allow Zend_Json_Expr from xml, we check if the node
|
569 |
+
// matchs the pattern that try to detect if it is a new Zend_Json_Expr
|
570 |
+
// if it matches, we return a new Zend_Json_Expr instead of a text node
|
571 |
+
$pattern = '/^[\s]*new Zend_Json_Expr[\s]*\([\s]*[\"\']{1}(.*)[\"\']{1}[\s]*\)[\s]*$/';
|
572 |
+
$matchings = array();
|
573 |
+
$match = preg_match($pattern, $simpleXmlElementObject, $matchings);
|
574 |
+
if ($match) {
|
575 |
+
return new Zend_Json_Expr($matchings[1]);
|
576 |
+
} else {
|
577 |
+
return (trim(strval($simpleXmlElementObject)));
|
578 |
+
}
|
579 |
+
} // End of if (is_array($simpleXmlElementObject))
|
580 |
+
}
|
581 |
+
|
582 |
+
// End of function _processXml.
|
583 |
+
|
584 |
+
/**
|
585 |
+
* _processXml - Contains the logic for xml2json
|
586 |
+
*
|
587 |
+
* The logic in this function is a recursive one.
|
588 |
+
*
|
589 |
+
* The main caller of this function (i.e. fromXml) needs to provide
|
590 |
+
* only the first two parameters i.e. the SimpleXMLElement object and
|
591 |
+
* the flag for ignoring or not ignoring XML attributes. The third parameter
|
592 |
+
* will be used internally within this function during the recursive calls.
|
593 |
+
*
|
594 |
+
* This function converts the SimpleXMLElement object into a PHP array by
|
595 |
+
* calling a recursive (protected static) function in this class. Once all
|
596 |
+
* the XML elements are stored in the PHP array, it is returned to the caller.
|
597 |
+
*
|
598 |
+
* Throws a Zend_Json_Exception if the XML tree is deeper than the allowed limit.
|
599 |
+
*
|
600 |
+
* @param SimpleXMLElement $simpleXmlElementObject
|
601 |
+
* @param boolean $ignoreXmlAttributes
|
602 |
+
* @param integer $recursionDepth
|
603 |
+
* @return array
|
604 |
+
*/
|
605 |
+
protected static function _processXml2($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0) {
|
606 |
+
// Keep an eye on how deeply we are involved in recursion.
|
607 |
+
if ($recursionDepth > self::$maxRecursionDepthAllowed) {
|
608 |
+
// XML tree is too deep. Exit now by throwing an exception.
|
609 |
+
// require_once 'Zend/Json/Exception.php';
|
610 |
+
throw new Zend_Json_Exception(
|
611 |
+
"Function _processXml exceeded the allowed recursion depth of " .
|
612 |
+
self::$maxRecursionDepthAllowed);
|
613 |
+
} // End of if ($recursionDepth > self::$maxRecursionDepthAllowed)
|
614 |
+
|
615 |
+
$children = $simpleXmlElementObject->children();
|
616 |
+
$name = $simpleXmlElementObject->getName();
|
617 |
+
$value = self::_getXmlValue($simpleXmlElementObject);
|
618 |
+
$attributes = (array) $simpleXmlElementObject->attributes();
|
619 |
+
|
620 |
+
if (count($children) == 0) {
|
621 |
+
if (!empty($attributes) && !$ignoreXmlAttributes) {
|
622 |
+
foreach ($attributes['@attributes'] as $k => $v) {
|
623 |
+
$attributes['@attributes'][$k] = self::_getXmlValue($v);
|
624 |
+
}
|
625 |
+
if (!empty($value)) {
|
626 |
+
$attributes['@text'] = $value;
|
627 |
+
}
|
628 |
+
return array($name => $attributes);
|
629 |
+
} else {
|
630 |
+
return array($name => $value);
|
631 |
+
}
|
632 |
+
} else {
|
633 |
+
$childArray = array();
|
634 |
+
foreach ($children as $child) {
|
635 |
+
$childname = $child->getName();
|
636 |
+
$element = self::_processXml2($child, $ignoreXmlAttributes, $recursionDepth + 1);
|
637 |
+
if (array_key_exists($childname, $childArray)) {
|
638 |
+
if (empty($subChild[$childname])) {
|
639 |
+
$childArray[$childname] = array($childArray[$childname]);
|
640 |
+
$subChild[$childname] = true;
|
641 |
+
}
|
642 |
+
$childArray[$childname][] = $element[$childname];
|
643 |
+
} else {
|
644 |
+
$childArray[$childname] = $element[$childname];
|
645 |
+
}
|
646 |
+
}
|
647 |
+
if (!empty($attributes) && !$ignoreXmlAttributes) {
|
648 |
+
foreach ($attributes['@attributes'] as $k => $v) {
|
649 |
+
$attributes['@attributes'][$k] = self::_getXmlValue($v);
|
650 |
+
}
|
651 |
+
$childArray['@attributes'] = $attributes['@attributes'];
|
652 |
+
}
|
653 |
+
if (!empty($value)) {
|
654 |
+
$childArray['@text'] = $value;
|
655 |
+
}
|
656 |
+
return array($name => $childArray);
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Return the value of an XML attribute text or the text between
|
662 |
+
* the XML tags
|
663 |
+
*
|
664 |
+
* In order to allow Zend_Json_Expr from xml, we check if the node
|
665 |
+
* matchs the pattern that try to detect if it is a new Zend_Json_Expr
|
666 |
+
* if it matches, we return a new Zend_Json_Expr instead of a text node
|
667 |
+
*
|
668 |
+
* @param SimpleXMLElement $simpleXmlElementObject
|
669 |
+
* @return Zend_Json_Expr|string
|
670 |
+
*/
|
671 |
+
protected static function _getXmlValue($simpleXmlElementObject) {
|
672 |
+
$pattern = '/^[\s]*new Zend_Json_Expr[\s]*\([\s]*[\"\']{1}(.*)[\"\']{1}[\s]*\)[\s]*$/';
|
673 |
+
$matchings = array();
|
674 |
+
$match = preg_match($pattern, $simpleXmlElementObject, $matchings);
|
675 |
+
if ($match) {
|
676 |
+
return new Zend_Json_Expr($matchings[1]);
|
677 |
+
} else {
|
678 |
+
return (trim(strval($simpleXmlElementObject)));
|
679 |
+
}
|
680 |
+
}
|
681 |
+
|
682 |
+
public function toXml($variable, array &$attributes = array()) {
|
683 |
+
return $this->_toXml_old($variable, $attributes);
|
684 |
+
// $rawBuiltAttributes = array();
|
685 |
+
// $soapVar = $this->toSoapVar($variable, $rawBuiltAttributes);
|
686 |
+
// echo '<pre>'.htmlspecialchars(print_r($soapVar, true), ENT_COMPAT | ENT_HTML401 | ENT_IGNORE).'</pre>';
|
687 |
+
|
688 |
+
|
689 |
+
|
690 |
+
// $r = $this->toXmlVar($variable, $rawBuiltAttributes);
|
691 |
+
// return $r;
|
692 |
+
}
|
693 |
+
protected function _toXml_old($variable, array $attributes = array()) {
|
694 |
+
$line = ""; //\r\n";
|
695 |
+
|
696 |
+
$str = '<?xml version="1.0" encoding="utf-8"?>' . $line;
|
697 |
+
if (is_array($variable)) {
|
698 |
+
$this->toXmlArray($str, '', $variable, -1);
|
699 |
+
} else {
|
700 |
+
throw new Exception('invalid input, cannot convert to xml');
|
701 |
+
}
|
702 |
+
if (count($attributes)) {
|
703 |
+
$xmlRequest = new DOMDocument('1.0');
|
704 |
+
$xmlRequest->loadXML($str);
|
705 |
+
$xpath = new DOMXPath($xmlRequest);
|
706 |
+
|
707 |
+
foreach ($attributes as $attribute) {
|
708 |
+
$query = $attribute['query'];
|
709 |
+
$nodeset = $xpath->query($query, $xmlRequest);
|
710 |
+
|
711 |
+
$exec = $attribute['exec'];
|
712 |
+
if (!isset($exec[0])) {
|
713 |
+
//same pattern will be applied to every result
|
714 |
+
foreach ($nodeset as $node) {
|
715 |
+
foreach ($exec as $k => $v) {
|
716 |
+
$node->setAttribute($k, $v);
|
717 |
+
}
|
718 |
+
}
|
719 |
+
} else {
|
720 |
+
//each result will get it's own result
|
721 |
+
foreach ($nodeset as $i => $node) {
|
722 |
+
foreach ($exec[$i] as $k => $v) {
|
723 |
+
$node->setAttribute($k, $v);
|
724 |
+
}
|
725 |
+
}
|
726 |
+
}
|
727 |
+
}
|
728 |
+
$str = $xmlRequest->saveXML();
|
729 |
+
}
|
730 |
+
|
731 |
+
|
732 |
+
return $str;
|
733 |
+
}
|
734 |
+
|
735 |
+
private function toXmlArray(&$str, $key, array $array, $level) {
|
736 |
+
//packages
|
737 |
+
$char = ""; //"\t";
|
738 |
+
$line = ""; //"\r\n";
|
739 |
+
|
740 |
+
if ($this->isAssoc($array)) {
|
741 |
+
if ($key != '')
|
742 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($key) . ">$line";
|
743 |
+
//package
|
744 |
+
foreach ($array as $xkey => $value) {
|
745 |
+
if (is_string($value)) {
|
746 |
+
$str .= str_repeat($char, $level + 1) . "<" . htmlspecialchars($xkey) . ">";
|
747 |
+
$str .= htmlspecialchars($value);
|
748 |
+
$str .= "</" . htmlspecialchars($xkey) . ">$line";
|
749 |
+
} else if (is_array($value)) {
|
750 |
+
//array of packages, key is package
|
751 |
+
$this->toXmlArray($str, $xkey, $value, $level + 1);
|
752 |
+
}
|
753 |
+
}
|
754 |
+
if ($key != '')
|
755 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($key) . ">$line";
|
756 |
+
} else {
|
757 |
+
//not assoc
|
758 |
+
foreach ($array as $value) {
|
759 |
+
if (is_string($value)) {
|
760 |
+
$str .= str_repeat($char, $level + 0) . "<" . htmlspecialchars($key) . ">";
|
761 |
+
$str .= htmlspecialchars($value);
|
762 |
+
$str .= "</" . htmlspecialchars($key) . ">$line";
|
763 |
+
} else if (is_array($value)) {
|
764 |
+
//single package
|
765 |
+
if ($key != '')
|
766 |
+
$str .= str_repeat($char, $level) . "<" . htmlspecialchars($key) . ">$line";
|
767 |
+
$this->toXmlArray($str, '', $value, $level + 0);
|
768 |
+
if ($key != '')
|
769 |
+
$str .= str_repeat($char, $level) . "</" . htmlspecialchars($key) . ">$line";
|
770 |
+
}
|
771 |
+
}
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
private function isAssoc($arr) {
|
776 |
+
return array_keys($arr) !== range(0, count($arr) - 1);
|
777 |
+
}
|
778 |
+
|
779 |
+
|
780 |
+
|
781 |
+
}
|
app/code/community/Eabi/Postoffice/etc/config.xml
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
<config>
|
37 |
<modules>
|
38 |
<Eabi_Postoffice>
|
39 |
-
<version>0.1.
|
40 |
</Eabi_Postoffice>
|
41 |
</modules>
|
42 |
|
36 |
<config>
|
37 |
<modules>
|
38 |
<Eabi_Postoffice>
|
39 |
+
<version>0.1.16</version>
|
40 |
</Eabi_Postoffice>
|
41 |
</modules>
|
42 |
|
app/etc/modules/Eabi_DpdEE.xml
CHANGED
@@ -39,7 +39,7 @@
|
|
39 |
<depends>
|
40 |
<Eabi_Postoffice />
|
41 |
</depends>
|
42 |
-
<version>0.1.
|
43 |
</Eabi_DpdEE>
|
44 |
</modules>
|
45 |
</config>
|
39 |
<depends>
|
40 |
<Eabi_Postoffice />
|
41 |
</depends>
|
42 |
+
<version>0.1.30</version>
|
43 |
</Eabi_DpdEE>
|
44 |
</modules>
|
45 |
</config>
|
app/etc/modules/Eabi_Postoffice.xml
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
<Mage_Shipping />
|
43 |
<Eabi_Livehandler />
|
44 |
</depends>
|
45 |
-
<version>0.1.
|
46 |
</Eabi_Postoffice>
|
47 |
</modules>
|
48 |
</config>
|
42 |
<Mage_Shipping />
|
43 |
<Eabi_Livehandler />
|
44 |
</depends>
|
45 |
+
<version>0.1.16</version>
|
46 |
</Eabi_Postoffice>
|
47 |
</modules>
|
48 |
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eabi_DpdEE</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl-3.0.txt">GNU Public License V3.0</license>
|
7 |
<channel>community</channel>
|
@@ -17,12 +17,11 @@
|
|
17 |
<p>Allows to call the courier from Magento admin</p>
|
18 |
<p>Allows cash on delivery payment and allows to set an extra fee per country which will be appended to shipping fee</p>
|
19 |
<p>Intended to use for Estonian merchant who sends parcels to all Baltic states</p></description>
|
20 |
-
<notes>-
|
21 |
-
- Mixed content warning removed from admin configuration panel</notes>
|
22 |
<authors><author><name>Matis Matis</name><user>auto-converted</user><email>info@e-abi.ee</email></author></authors>
|
23 |
-
<date>2016-
|
24 |
-
<time>23:
|
25 |
-
<contents><target name="magecommunity"><dir name="Eabi"><dir name="DpdEE"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Country.php" hash="3a0ce3bedf19b868d81f4117740778ce"/></dir></dir></dir></dir><dir name="Info"><file name="Payment.php" hash="5c362a3835374edcd3f06c03bf1807d9"/></dir><dir name="Order"><file name="Courier.php" hash="897aa2fb30241802e04db8e997cc5eb8"/></dir><file name="Invoice.php" hash="3b6991a3f7a08763c16ccc73ceab2111"/></dir><dir name="Helper"><file name="Data.php" hash="5599ef7d77c5769653d3b655b7f18d72"/></dir><dir name="Model"><dir name="Action"><dir name="Carrier"><dir name="Order"><file name="Courier.php" hash="bfec69ca2b190b71cc5d649d00b685f9"/></dir></dir></dir><dir name="Button"><file name="Courier.php" hash="b60b161082d23d9596473fc4f942484a"/></dir><dir name="Payment"><file name="Processor.php" hash="18f56c72f9b897f40e97bae83e440d1f"/></dir><dir name="Source"><dir name="Label"><file name="Position.php" hash="d3c89fbc76ab10ab8daa86800fe19083"/></dir><file name="Service.php" hash="504b474a715c21d943b61b7eaddac974"/></dir><file name="Api.php" hash="5fb56e2ba77e5275c9479ad56cfaa1be"/><file name="Config.php" hash="27f77c56c64cefa4b7ccfb3df1b877b5"/><file name="Flat.php" hash="1bafdae148495a356031343f83bed390"/><file name="Observer.php" hash="8a1eeac07c99ee53c1fb0a27f14a0984"/><file name="Post.php" hash="95028daf7aa8cdbf20d046c3e3e9db8f"/></dir><dir name="etc"><file name="config.xml" hash="
|
26 |
<compatible/>
|
27 |
<dependencies><required><package><name>Eabi_Livehandler</name><channel>community</channel><min>0.1.15</min><max>1.0.0</max></package></required></dependencies>
|
28 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eabi_DpdEE</name>
|
4 |
+
<version>0.1.30</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl-3.0.txt">GNU Public License V3.0</license>
|
7 |
<channel>community</channel>
|
17 |
<p>Allows to call the courier from Magento admin</p>
|
18 |
<p>Allows cash on delivery payment and allows to set an extra fee per country which will be appended to shipping fee</p>
|
19 |
<p>Intended to use for Estonian merchant who sends parcels to all Baltic states</p></description>
|
20 |
+
<notes>- Added XML helper into postoffice package</notes>
|
|
|
21 |
<authors><author><name>Matis Matis</name><user>auto-converted</user><email>info@e-abi.ee</email></author></authors>
|
22 |
+
<date>2016-02-05</date>
|
23 |
+
<time>23:48:12</time>
|
24 |
+
<contents><target name="magecommunity"><dir name="Eabi"><dir name="DpdEE"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Country.php" hash="3a0ce3bedf19b868d81f4117740778ce"/></dir></dir></dir></dir><dir name="Info"><file name="Payment.php" hash="5c362a3835374edcd3f06c03bf1807d9"/></dir><dir name="Order"><file name="Courier.php" hash="897aa2fb30241802e04db8e997cc5eb8"/></dir><file name="Invoice.php" hash="3b6991a3f7a08763c16ccc73ceab2111"/></dir><dir name="Helper"><file name="Data.php" hash="5599ef7d77c5769653d3b655b7f18d72"/></dir><dir name="Model"><dir name="Action"><dir name="Carrier"><dir name="Order"><file name="Courier.php" hash="bfec69ca2b190b71cc5d649d00b685f9"/></dir></dir></dir><dir name="Button"><file name="Courier.php" hash="b60b161082d23d9596473fc4f942484a"/></dir><dir name="Payment"><file name="Processor.php" hash="18f56c72f9b897f40e97bae83e440d1f"/></dir><dir name="Source"><dir name="Label"><file name="Position.php" hash="d3c89fbc76ab10ab8daa86800fe19083"/></dir><file name="Service.php" hash="504b474a715c21d943b61b7eaddac974"/></dir><file name="Api.php" hash="5fb56e2ba77e5275c9479ad56cfaa1be"/><file name="Config.php" hash="27f77c56c64cefa4b7ccfb3df1b877b5"/><file name="Flat.php" hash="1bafdae148495a356031343f83bed390"/><file name="Observer.php" hash="8a1eeac07c99ee53c1fb0a27f14a0984"/><file name="Post.php" hash="95028daf7aa8cdbf20d046c3e3e9db8f"/></dir><dir name="etc"><file name="config.xml" hash="23aa150db9c9fad5024e2e6135ac2fdb"/><file name="system.xml" hash="f159733074600175fe21a3245fa06328"/></dir><dir name="sql"><dir name="eabi_dpdee_setup"><file name="mysql4-install-0.1.0.php" hash="d87dbd3080d98c183956319f20110433"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="56765009037b3699a7c871f14704a00c"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="411745561f0ddec025db8a48cb2abd26"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="6ad16e795c12646cd77242434c43cab0"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="dfbd21903d6e85592c994ec5dee5e374"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="a852db2e91ae253593d499a230e08013"/><file name="mysql4-upgrade-0.1.9-0.1.10.php" hash="456f749bc3e49363561153b3e0e57d96"/></dir></dir><file name="CHANGELOG.txt" hash="fc52c8136fae9f5313a7c3a057cfa4fe"/><file name="LICENCE.txt" hash="0191312e121c0b3e1165619b96efcf9f"/></dir><dir name="Postoffice"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="License.php" hash="2f5750200eb5e1ba7fd5ba10f82b8a18"/><file name="Remove.php" hash="f94c1e6fb2ca0d054fb5c87dc98b289c"/></dir></dir></dir></dir><dir name="Config"><file name="Rebuildbutton.php" hash="b9139075530956f874b72d1592c95890"/></dir></dir><dir name="Helper"><file name="Countrycode.php" hash="45879a8fbb193c3fc98fa6c4947a964c"/><file name="Data.php" hash="76aa3727765746553c4e5c3d77e09b43"/><file name="Xml.php" hash="3d477c8bad1c6c4cb2183664efee7673"/></dir><dir name="Model"><dir name="Carrier"><file name="Abstract.php" hash="18d9ab0cad39900aa60a8e74a7a6b6cb"/><file name="Result.php" hash="77e183bf5f9b31b9ae9c4c12182b0f43"/></dir><dir name="Email"><dir name="Template"><file name="Mailer.php" hash="ad050d051f143033273328c6c6d365cb"/></dir></dir><dir name="Licenceable"><dir name="Autosend"><file name="Method.php" hash="f06c99a1a4311de474cd63afed947220"/></dir><dir name="Payment"><file name="Method.php" hash="18fe727f3ac4db9ccfa93486115432ba"/></dir><dir name="Shipping"><file name="Method.php" hash="b34ba5c1bee4c3c818514c125f9ee882"/></dir><file name="Method.php" hash="f054356db17488890b3275cc9608ef39"/></dir><dir name="Mysql4"><dir name="Carriermodule"><file name="Collection.php" hash="7079738f5fe7591b98aa93a8d9f02dab"/></dir><dir name="Office"><file name="Collection.php" hash="7941e291c5fa7e613d3ecdf785e1d98f"/></dir><file name="Carriermodule.php" hash="e7074af5aa20080065cf5ee44a4e8708"/><file name="Office.php" hash="55ac0e86fe5b89cfaeca3250872d977a"/></dir><dir name="Source"><file name="Sendevent.php" hash="a62dda6f3551e1ae961fc3bb4a91fa11"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="cd46d97cad9d45a0eaf86a193ebe142c"/></dir></dir></dir><file name="Carriermodule.php" hash="4d4a5b6b72d102e26136b49eafb07d9d"/><file name="Observer.php" hash="13140483e2d7dcfd3a808ef1441bdf9e"/><file name="Office.php" hash="13926ff31c40ca796a15d1e2369559d7"/><file name="Orderview.php" hash="2f67fd0efa38f508fb7a438c98ec4517"/><file name="Updater.php" hash="075fd8691affe5fc79f16c7291b0a13e"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Eabi"><dir name="Postoffice"><file name="PostofficeController.php" hash="a51d4f075e8d9a606871946dc5cb53ed"/></dir></dir><file name="PostofficeController.php" hash="72a194bbe8bc3bc0685be1f8101f4d13"/></dir><file name="IndexController.php" hash="674711f386853981403317113f6fe128"/></dir><dir name="etc"><file name="config.xml" hash="08f3804b8d199af909a8fa573fca7d86"/></dir><dir name="sql"><dir name="eabi_postoffice_setup"><file name="mysql4-install-0.1.0.php" hash="6c25a503d5bc3bef7fdecf12123f7b57"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="00be7881382e9e904cb2bc2cedc89818"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="a9cf1ab713568971161e0caeb0ad19dc"/><file name="mysql4-upgrade-0.1.11-0.1.12.php" hash="40014409962d19234b62913c63b2252f"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="2330590d882eda1bb14dfa0982af096c"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="08580cbaa3ead11e28388998acbec5d8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="eabi_dpdee.xml" hash="85311cb850eb13eadaed47cdc9c44fb3"/><file name="eabi_postoffice.xml" hash="3248575e76fe484b1e13ee20b11d7b49"/></dir><dir name="template"><dir name="eabi_dpdee"><dir name="order"><file name="courier.phtml" hash="0310f24e96ca3873e78e0e2a0ab26743"/></dir><file name="payment_info.phtml" hash="3f8a01e4bcd2efab555d729bee8335da"/></dir><dir name="eabi_postoffice"><file name="shipping_method_form.phtml" hash="2b74940d708277d75ac29917f52055a4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eabi_dpdee.xml" hash="27179eee219a0a8c85b87b8d670ae9e1"/><file name="eabi_postoffice.xml" hash="1b5b7e81226f5a8fdefc19ef618f38f5"/></dir><dir name="template"><dir name="eabi_dpdee"><file name="payment_info.phtml" hash="3f8a01e4bcd2efab555d729bee8335da"/></dir><dir name="eabi_postoffice"><dir name="tracking"><file name="popup.phtml" hash="bdfccfd7127864575a27587a95e3930c"/></dir><file name="available.phtml" hash="c24db2206654d096e898cc034370676b"/><file name="multishipping.phtml" hash="b18864cf6636826fd9b9ef11cd35657f"/><file name="shipping.phtml" hash="b0edc38cd43bdcfede1f4cf5348c9dd6"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eabi_Postoffice.xml" hash="65c6a950c9670c44711f1a1beb981e1f"/><file name="Eabi_DpdEE.xml" hash="4739e823ea42f8561d01a083419aba45"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Eabi_DpdEE.csv" hash="d53a6b36efac9db3dfad081f31712b40"/><file name="Eabi_Postoffice.csv" hash="651b14b0e55dbeeb55de579a1a993eab"/></dir><dir name="et_EE"><file name="Eabi_DpdEE.csv" hash="0a64d6699de9f680874acbc9869d4837"/><file name="Eabi_Postoffice.csv" hash="ea423904bbab2d44e6b68a537576c567"/></dir><dir name="ru_RU"><file name="Eabi_DpdEE.csv" hash="a208ad8515648b555ca13c9209c4f833"/><file name="Eabi_Postoffice.csv" hash="651b14b0e55dbeeb55de579a1a993eab"/></dir><dir name="hu_HU"><file name="Eabi_Postoffice.csv" hash="651b14b0e55dbeeb55de579a1a993eab"/></dir><dir name="fi_FI"><file name="Eabi_Postoffice.csv" hash="651b14b0e55dbeeb55de579a1a993eab"/></dir><dir name="lt_LT"><file name="Eabi_Postoffice.csv" hash="651b14b0e55dbeeb55de579a1a993eab"/></dir><dir name="sv_SE"><file name="Eabi_Postoffice.csv" hash="bbad7cd0c48e9482913265b2f0f0cef9"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="eabi_dpdee.css" hash="dcffac29e30c23248afd296ba6eba357"/><file name="eabi_postoffice.css" hash="1baea3a2164029da5adcb67df9ae42da"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="eabi_postoffice.css" hash="df0bc2bfd582fc01eb23ffe23fe56e90"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="css"><file name="eabi_postoffice.css" hash="df0bc2bfd582fc01eb23ffe23fe56e90"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="eabi_js"><file name="eabi_dpdee.js" hash="bced7e30c8c108c77b773e8c921b7d12"/></dir></dir></target></contents>
|
25 |
<compatible/>
|
26 |
<dependencies><required><package><name>Eabi_Livehandler</name><channel>community</channel><min>0.1.15</min><max>1.0.0</max></package></required></dependencies>
|
27 |
</package>
|