Owebia_Shipping_2 - Version 2.6.0

Version Notes

[2.6.0 - October 24, 2016]
Refactor code to comply to Magento coding standards
Remove compress functionality
Only one carrier available for new installations

[2.5.24 - September 07, 2016]
Update documentation

[2.5.23 - August 18, 2016]
Fix special functions call issue: missing opening parenthesis

[2.5.22 - July 18, 2016]
Add composer.json and modman files

[2.5.21 - May 9, 2016]
Fix replacement of special functions, thanks to Sébastien L.

[2.5.20 - 25 avril 2016]
Fix code indentation
Fix version number
Add readme file in package

[2.5.19 - 09 novembre 2015]
Note: the extension is not affected by the patch SUPEE-6788 since it uses the new admin url routing syntax for 3 years (version 2.4.8.0)
Fix bug: deactivation of auto-escaping by default since it can cause some bugs (ex: impossible to use {address_filter.EU-27} in shipto)
Fix bug: fix auto-escaping of properties like {{shipto.country_name}}
Fix bug: variable replacements in labels (variables {cart.price-tax-discount}, {cart.price-tax+discount}, {cart.price+tax-discount} and {cart.price+tax+discount})
Fix bug: use items and not quote to retrieve values {cart.price-tax-discount}, {cart.price-tax+discount}, {cart.price+tax-discount} and {cart.price+tax+discount} (quote totals are not available at this time, calculating them causes duplications of addresses and a false grand_total value)
Fix bug: retrieve customer in backoffice order
Fix unicode accented chars in json_encode for PHP < 5.4
Fix bug: usage of regular expressions inside {count ...}, {sum ...}, {min ...} and {max ...}
Allow usage of php functions date and strtotime (ex: "label": "'Your package will be delivered between ' . date('d/m', strtotime('+5 days')) . ' and ' . date('d/m Y', strtotime('+7 days'))",

Download this release

Release Info

Developer owebia
Extension Owebia_Shipping_2
Version 2.6.0
Comparing to
See all releases


Code changes from version 2.5.24 to 2.6.0

Files changed (53) hide show
  1. app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor.php +138 -130
  2. app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor/Property/Input.php +7 -19
  3. app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Help.php +20 -72
  4. app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Config.php +35 -50
  5. app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Informations.php +8 -19
  6. app/code/community/Owebia/Shipping2/Controller/Abstract.php +72 -64
  7. app/code/community/Owebia/Shipping2/Helper/Data.php +101 -106
  8. app/code/community/Owebia/Shipping2/Model/AddressFilterParser.php +188 -0
  9. app/code/community/Owebia/Shipping2/Model/Carrier/Abstract.php +66 -93
  10. app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping1.php +3 -18
  11. app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping2.php +3 -18
  12. app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping3.php +0 -25
  13. app/code/community/Owebia/Shipping2/Model/ConfigParser.php +1940 -0
  14. app/code/community/Owebia/Shipping2/Model/Mysql4/Setup.php +0 -24
  15. app/code/community/Owebia/Shipping2/Model/Os2/Data.php +41 -0
  16. app/code/community/Owebia/Shipping2/Model/Os2/Data/Abstract.php +14 -39
  17. app/code/community/Owebia/Shipping2/Model/Os2/Data/AbstractWithAttributes.php +16 -34
  18. app/code/community/Owebia/Shipping2/Model/Os2/Data/Address.php +5 -20
  19. app/code/community/Owebia/Shipping2/Model/Os2/Data/AddressFilter.php +42 -30
  20. app/code/community/Owebia/Shipping2/Model/Os2/Data/AttributeSet.php +5 -20
  21. app/code/community/Owebia/Shipping2/Model/Os2/Data/Billto.php +3 -18
  22. app/code/community/Owebia/Shipping2/Model/Os2/Data/Cart.php +51 -64
  23. app/code/community/Owebia/Shipping2/Model/Os2/Data/CartItem.php +34 -73
  24. app/code/community/Owebia/Shipping2/Model/Os2/Data/Category.php +5 -20
  25. app/code/community/Owebia/Shipping2/Model/Os2/Data/Customer.php +12 -25
  26. app/code/community/Owebia/Shipping2/Model/Os2/Data/CustomerGroup.php +31 -40
  27. app/code/community/Owebia/Shipping2/Model/Os2/Data/Customvar.php +3 -18
  28. app/code/community/Owebia/Shipping2/Model/Os2/Data/Date.php +26 -27
  29. app/code/community/Owebia/Shipping2/Model/Os2/Data/Info.php +4 -18
  30. app/code/community/Owebia/Shipping2/Model/Os2/Data/Product.php +54 -63
  31. app/code/community/Owebia/Shipping2/Model/Os2/Data/Quote.php +10 -23
  32. app/code/community/Owebia/Shipping2/Model/Os2/Data/Selection.php +3 -18
  33. app/code/community/Owebia/Shipping2/Model/Os2/Data/StockItem.php +9 -22
  34. app/code/community/Owebia/Shipping2/Model/Os2/Data/Store.php +5 -20
  35. app/code/community/Owebia/Shipping2/Model/Os2/Message.php +35 -0
  36. app/code/community/Owebia/Shipping2/Model/Os2/Result.php +35 -0
  37. app/code/community/Owebia/Shipping2/Model/System/Config/Source/LoadOnParent.php +8 -19
  38. app/code/community/Owebia/Shipping2/Model/System/Config/Source/ProcessChildren.php +8 -19
  39. app/code/community/Owebia/Shipping2/changelog +5 -0
  40. app/code/community/Owebia/Shipping2/controllers/Adminhtml/Os2/AjaxController.php +232 -172
  41. app/code/community/Owebia/Shipping2/controllers/Checkout/CartController.php +8 -21
  42. app/code/community/Owebia/Shipping2/doc_en_US.html +7 -2
  43. app/code/community/Owebia/Shipping2/doc_fr_FR.html +7 -2
  44. app/code/community/Owebia/Shipping2/etc/adminhtml.xml +3 -17
  45. app/code/community/Owebia/Shipping2/etc/config.xml +14 -49
  46. app/code/community/Owebia/Shipping2/etc/system.xml +7 -150
  47. app/code/community/Owebia/Shipping2/includes/OS2_AddressFilterParser.php +0 -148
  48. app/code/community/Owebia/Shipping2/includes/OwebiaShippingHelper.php +0 -1467
  49. app/code/community/Owebia/Shipping2/sql/owebia_shipping2_setup/mysql4-install-2.5.13.php +15 -6
  50. app/etc/modules/Owebia_Shipping2.xml +2 -17
  51. app/locale/en_US/Owebia_Shipping2.csv +1 -727
  52. app/locale/fr_FR/Owebia_Shipping2.csv +1 -747
  53. package.xml +10 -5
app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor.php CHANGED
@@ -1,28 +1,13 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_Abstract
23
{
24
protected $_config;
25
- protected $_opened_row_ids;
26
27
public function __construct($attributes)
28
{
@@ -31,7 +16,7 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
31
'opened_row_ids' => array(),
32
);
33
$this->_config = $attributes['config'];
34
- $this->_opened_row_ids = $attributes['opened_row_ids'];
35
}
36
37
public function __()
@@ -40,122 +25,134 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
40
return Mage::helper('owebia_shipping2')->__($args);
41
}
42
43
- private function _getPropertyInput($property_name, $property)
44
{
45
if (is_array($property)) { // Compatibility PHP 5.2
46
- $value = isset($property['original_value']) ? $property['original_value'] : (isset($property['value']) ? $property['value'] : (isset($property) ? $property : ''));
47
} else {
48
$value = $property;
49
}
50
51
- $toolbar = "<span class=\"os2-field-btn os2-field-help\" data-property=\"{$property_name}\"></span>";
52
- switch ($property_name) {
53
case 'enabled':
54
- $enabled = $value!==false;
55
- $input = "<select class=field name=\"{$property_name}\">"
56
- ."<option value=\"1\"".($enabled ? ' selected="selected"' : '').">".$this->__('Enabled (default)')."</option>"
57
- ."<option value=\"0\"".($enabled ? '' : ' selected="selected"').">".$this->__('Disabled')."</option>"
58
- ."</select>";
59
break;
60
case 'type':
61
- $input = "<select class=field name=\"{$property_name}\">"
62
- ."<option value=method".($value=='method' || !$value ? '' : ' selected="selected"').">".$this->__('Shipping Method (default)')."</option>"
63
- ."<option value=data".($value=='data' ? ' selected="selected"' : '').">".$this->__('Data')."</option>"
64
- ."<option value=meta".($value=='meta' ? ' selected="selected"' : '').">".$this->__('Meta')."</option>"
65
- ."</select>";
66
break;
67
case 'shipto':
68
case 'billto':
69
case 'origin':
70
- $toolbar = "<span class=\"os2-field-btn os2-field-edit\"></span>".$toolbar;
71
default:
72
- $input = "<input class=field name=\"{$property_name}\" value=\"".htmlspecialchars($value, ENT_COMPAT, 'UTF-8')."\"/>";
73
break;
74
}
75
return $input;
76
}
77
-
78
- public function getPropertyTools($controller, $property_name)
79
{
80
$after = '';
81
- switch ($property_name) {
82
- case 'label':
83
- case 'description':
84
- $after = "<fieldset class=buttons-set><legend>".$this->__('Insert')."</legend>"
85
- ."<p>"
86
- .$controller->button__('Shipping country',"os2editor.insertAtCaret(this,'{shipto.country_name}');",'os2-insert')
87
- .$controller->button__('Cart weight',"os2editor.insertAtCaret(this,'{cart.weight}');",'os2-insert')
88
- .$controller->button__('Products quantity',"os2editor.insertAtCaret(this,'{cart.qty}');",'os2-insert')
89
- .$controller->button__('Price incl. tax',"os2editor.insertAtCaret(this,'{cart.price+tax+discount}');",'os2-insert')
90
- .$controller->button__('Price excl. tax',"os2editor.insertAtCaret(this,'{cart.price-tax+discount}');",'os2-insert')
91
- ."</p>"
92
- ."</fieldset>";
93
- break;
94
- case 'fees':
95
- $after = "<fieldset class=buttons-set><legend>".$this->__('Insert')."</legend>"
96
- ."<p>"
97
- .$controller->button__('Weight',"os2editor.insertAtCaret(this,'{cart.weight}');",'os2-insert')
98
- .$controller->button__('Products quantity',"os2editor.insertAtCaret(this,'{cart.qty}');",'os2-insert')
99
- .$controller->button__('Price incl. tax',"os2editor.insertAtCaret(this,'{cart.price+tax+discount}');",'os2-insert')
100
- .$controller->button__('Price excl. tax',"os2editor.insertAtCaret(this,'{cart.price-tax+discount}');",'os2-insert')
101
- ."</p>"
102
- ."</fieldset>";
103
- break;
104
- case 'conditions':
105
- $after = "<fieldset class=buttons-set><legend>".$this->__('Insert')."</legend>"
106
- ."<p>"
107
- .$controller->button__('Weight',"os2editor.insertAtCaret(this,'{cart.weight}');",'os2-insert')
108
- .$controller->button__('Products quantity',"os2editor.insertAtCaret(this,'{cart.qty}');",'os2-insert')
109
- .$controller->button__('Price incl. tax',"os2editor.insertAtCaret(this,'{cart.price+tax+discount}');",'os2-insert')
110
- .$controller->button__('Price excl. tax',"os2editor.insertAtCaret(this,'{cart.price-tax+discount}');",'os2-insert')
111
- ."</p>"
112
- ."</fieldset>";
113
- break;
114
- case 'customer_groups':
115
- $model = Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup');
116
- $groups = (array)$model->getCollection();
117
- $output = '';
118
- foreach ($groups as $id => $name) {
119
- $output .= $controller->button($this->esc($name.' ('.$id.')'),"os2editor.insertAtCaret(this,'".$this->jsEscape($id)."');",'os2-insert');
120
- }
121
- $after = "<fieldset class=buttons-set><legend>".$this->__('Tools')."</legend>"
122
- ."<p>"
123
- .$controller->button__('Human readable version',"os2editor.getReadableSelection(this);")
124
- ."</p><div id=os2-output></div>"
125
- ."</fieldset>"
126
- ."<fieldset class=buttons-set><legend>".$this->__('Insert')."</legend>"
127
- ."<p>{$output}</p>"
128
- ."</fieldset>"
129
- ;
130
- break;
131
- case 'tracking_url':
132
- $after = "<fieldset class=buttons-set><legend>".$this->__('Insert')."</legend>"
133
- ."<p>"
134
- .$controller->button__('Tracking number',"os2editor.insertAtCaret(this,'{tracking_number}');",'os2-insert')
135
- ."</p>"
136
- ."</fieldset>";
137
- break;
138
- case 'shipto':
139
- case 'billto':
140
- case 'origin':
141
- $after = "<fieldset class=buttons-set><legend>".$this->__('Tools')."</legend>"
142
- ."<p>"
143
- .$controller->button__('Human readable version',"os2editor.getReadableSelection(this);")
144
- ."</p><div id=os2-output></div>"
145
- ."</fieldset>"
146
- ;
147
- break;
148
- case 'about':
149
- break;
150
}
151
return $after;
152
}
153
154
- public function sortProperties($k1, $k2)
155
{
156
- $i1 = isset($this->properties_sort[$k1]) ? $this->properties_sort[$k1] : 1000;
157
- $i2 = isset($this->properties_sort[$k2]) ? $this->properties_sort[$k2] : 1000;
158
- return $i1==$i2 ? strcmp($k1, $k2) : $i1-$i2;
159
}
160
161
protected function _getRowUI(&$row)
@@ -164,20 +161,26 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
164
$type = isset($row['type']['value']) ? $row['type']['value'] : null;
165
switch ($type) {
166
case 'meta':
167
- $row_label = $this->__('[meta] %s', $row['*id']);
168
break;
169
case 'data':
170
- $row_label = $this->__('[data] %s', $row['*id']);
171
break;
172
default:
173
if (!isset($row['label'])) {
174
$row['label']['value'] = $this->__('New shipping method');
175
}
176
- $row_label = $row['label']['value'];
177
- $properties = array_merge($properties, array('label', 'description', 'shipto', 'billto', 'origin', 'conditions', 'fees', 'customer_groups', 'tracking_url'));
178
}
179
180
- $properties_label = array(
181
'*id' => 'ID',
182
'type' => 'Type',
183
'about' => 'About',
@@ -192,26 +195,29 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
192
'customer_groups' => 'Customer groups',
193
'tracking_url' => 'Tracking url',
194
);
195
- foreach ($properties as $property_name) {
196
- if (!isset($row[$property_name])) $row[$property_name] = null;
197
}
198
- $this->properties_sort = array_flip($properties);
199
uksort($row, array($this, 'sortProperties'));
200
$list = '';
201
$content = '';
202
$j = 0;
203
- foreach ($row as $property_name => $property) {
204
- $property_label = isset($properties_label[$property_name]) ? $properties_label[$property_name] : $property_name;
205
$error = array();
206
if (isset($property['messages'])) {
207
foreach ($property['messages'] as $message) {
208
$error[] = $this->__($message);
209
}
210
}
211
- $content .= "<tr class=\"os2-p-container".($error ? ' os2-error' : '')."\"".($error ? ' title="'.$this->esc(implode(', ', $error)).'"' : '')."><th>".$this->__($property_label)."</th><td>".$this->_getPropertyInput($property_name, $property, $big = false)."</td></tr>";
212
$j++;
213
}
214
- //$output = "<ul class=\"properties-list ui-layout-west\">{$list}</ul><div class=\"properties-container ui-layout-center\">{$content}</div>";
215
$output = "<table class=properties-container>{$content}</table>";
216
return $output;
217
}
@@ -235,13 +241,15 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
235
$content = $this->_getRowUI($row);
236
}
237
$error = false;
238
- foreach ($row as $property_name => $property) {
239
if (is_array($property) /*Compatibility*/ && isset($property['messages'])) {
240
$error = true;
241
break;
242
}
243
}
244
- return "<li data-id=\"{$row['*id']}\"".($error ? ' class=os2-error' : '')."><h5><button class=\"os2-remove-row-btn\" title=\"{$this->__('Remove')}\"></button>".$label."</h5><div class=\"row-ui".($opened ? ' opened' : '')."\">{$content}</div></li>";
245
}
246
247
protected function esc($input)
@@ -251,7 +259,7 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
251
252
protected function jsEscape($input)
253
{
254
- return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$input);
255
}
256
257
public function getRowUI(&$row)
@@ -262,15 +270,15 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
262
public function getHtml()
263
{
264
$config = $this->getData('config');
265
- $opened_row_ids = $this->getData('opened_row_ids');
266
- $output = /*"<pre>".print_r($config, true)."</pre>".*/"";
267
$i = 0;
268
if (!$config) {
269
$output .= "<p style=\"padding:10px;\">Configuration vide</p>";
270
} else {
271
$output .= "<ul id=os2-editor-elems-container>";
272
- foreach ($config as $row_id => &$row) {
273
- $opened = in_array($row_id, $opened_row_ids) || !$opened_row_ids && $i==0;
274
$output .= $this->_getRowItem($row, $opened);
275
$i++;
276
}
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_Abstract
8
{
9
protected $_config;
10
+ protected $_openedRowIds;
11
12
public function __construct($attributes)
13
{
16
'opened_row_ids' => array(),
17
);
18
$this->_config = $attributes['config'];
19
+ $this->_openedRowIds = $attributes['opened_row_ids'];
20
}
21
22
public function __()
25
return Mage::helper('owebia_shipping2')->__($args);
26
}
27
28
+ protected function _getPropertyInput($propertyName, $property)
29
{
30
if (is_array($property)) { // Compatibility PHP 5.2
31
+ $value = isset($property['original_value'])
32
+ ? $property['original_value']
33
+ : (isset($property['value']) ? $property['value'] : (isset($property) ? $property : ''));
34
} else {
35
$value = $property;
36
}
37
38
+ $toolbar = "<span class=\"os2-field-btn os2-field-help\" data-property=\"{$propertyName}\"></span>";
39
+ switch ($propertyName) {
40
case 'enabled':
41
+ $enabled = $value !== false;
42
+ $input = "<select class=field name=\"{$propertyName}\">"
43
+ . "<option value=\"1\"" . ($enabled ? ' selected="selected"' : '') . ">"
44
+ . $this->__('Enabled (default)') . "</option>"
45
+ . "<option value=\"0\"" . ($enabled ? '' : ' selected="selected"') . ">"
46
+ . $this->__('Disabled') . "</option>"
47
+ . "</select>";
48
break;
49
case 'type':
50
+ $input = "<select class=field name=\"{$propertyName}\">"
51
+ . "<option value=method" . ($value=='method' || !$value ? '' : ' selected="selected"') . ">"
52
+ . $this->__('Shipping Method (default)') . "</option>"
53
+ . "<option value=data" . ($value=='data' ? ' selected="selected"' : '') . ">"
54
+ . $this->__('Data') . "</option>"
55
+ . "<option value=meta" . ($value=='meta' ? ' selected="selected"' : '') . ">"
56
+ . $this->__('Meta') . "</option>"
57
+ . "</select>";
58
break;
59
case 'shipto':
60
case 'billto':
61
case 'origin':
62
+ $toolbar = "<span class=\"os2-field-btn os2-field-edit\"></span>" . $toolbar;
63
default:
64
+ $input = "<input class=field name=\"{$propertyName}\""
65
+ . " value=\"" . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . "\"/>";
66
break;
67
}
68
return $input;
69
}
70
+
71
+ public function insertBtn($controller, $title, $variable)
72
+ {
73
+ return $controller->button__(
74
+ $title,
75
+ "os2editor.insertAtCaret(this,'$variable');",
76
+ 'os2-insert'
77
+ );
78
+ }
79
+
80
+ public function getPropertyTools($controller, $propertyName)
81
{
82
$after = '';
83
+ if ($propertyName == 'label' || $propertyName == 'description') {
84
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
85
+ . "<p>"
86
+ . $this->insertBtn($controller, 'Shipping country', '{shipto.country_name}')
87
+ . $this->insertBtn($controller, 'Cart weight', '{cart.weight}')
88
+ . $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
89
+ . $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
90
+ . $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
91
+ . "</p>"
92
+ . "</fieldset>";
93
+ } elseif ($propertyName == 'fees') {
94
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
95
+ . "<p>"
96
+ . $this->insertBtn($controller, 'Weight', '{cart.weight}')
97
+ . $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
98
+ . $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
99
+ . $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
100
+ . "</p>"
101
+ . "</fieldset>";
102
+ } elseif ($propertyName == 'conditions') {
103
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
104
+ . "<p>"
105
+ . $this->insertBtn($controller, 'Weight', '{cart.weight}')
106
+ . $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
107
+ . $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
108
+ . $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
109
+ . "</p>"
110
+ . "</fieldset>";
111
+ } elseif ($propertyName == 'customer_groups') {
112
+ $model = Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup');
113
+ $groups = (array)$model->getCollection();
114
+ $output = '';
115
+ foreach ($groups as $id => $name) {
116
+ $output .= $this->insertBtn(
117
+ $controller,
118
+ $this->esc($name . ' (' . $id . ')'),
119
+ $this->jsEscape($id)
120
+ );
121
+ }
122
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Tools') . "</legend>"
123
+ . "<p>"
124
+ . $controller->button__('Human readable version', "os2editor.getReadableSelection(this);")
125
+ . "</p><div id=os2-output></div>"
126
+ . "</fieldset>"
127
+ . "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
128
+ . "<p>{$output}</p>"
129
+ . "</fieldset>"
130
+ ;
131
+ } elseif ($propertyName == 'tracking_url') {
132
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
133
+ . "<p>"
134
+ . $this->insertBtn($controller, 'Tracking number', '{tracking_number}')
135
+ . "</p>"
136
+ . "</fieldset>";
137
+ } elseif ($propertyName == 'shipto' ||$propertyName == 'billto' || $propertyName == 'origin') {
138
+ $after = "<fieldset class=buttons-set><legend>" . $this->__('Tools') . "</legend>"
139
+ . "<p>"
140
+ . $controller->button__('Human readable version', "os2editor.getReadableSelection(this);")
141
+ . "</p><div id=os2-output></div>"
142
+ . "</fieldset>"
143
+ ;
144
+ } elseif ($propertyName == 'about') {
145
+ $after = '';
146
}
147
return $after;
148
}
149
150
+ public function sortProperties($firstKey, $secondKey)
151
{
152
+ $firstKeyPosition = isset($this->propertiesSort[$firstKey]) ? $this->propertiesSort[$firstKey] : 1000;
153
+ $secondKeyPosition = isset($this->propertiesSort[$secondKey]) ? $this->propertiesSort[$secondKey] : 1000;
154
+ return $firstKeyPosition == $secondKeyPosition
155
+ ? strcmp($firstKey, $secondKey) : $firstKeyPosition - $secondKeyPosition;
156
}
157
158
protected function _getRowUI(&$row)
161
$type = isset($row['type']['value']) ? $row['type']['value'] : null;
162
switch ($type) {
163
case 'meta':
164
+ $rowLabel = $this->__('[meta] %s', $row['*id']);
165
break;
166
case 'data':
167
+ $rowLabel = $this->__('[data] %s', $row['*id']);
168
break;
169
default:
170
if (!isset($row['label'])) {
171
$row['label']['value'] = $this->__('New shipping method');
172
}
173
+ $rowLabel = $row['label']['value'];
174
+ $properties = array_merge(
175
+ $properties,
176
+ array(
177
+ 'label', 'description', 'shipto', 'billto', 'origin',
178
+ 'conditions', 'fees', 'customer_groups', 'tracking_url',
179
+ )
180
+ );
181
}
182
183
+ $propertiesLabel = array(
184
'*id' => 'ID',
185
'type' => 'Type',
186
'about' => 'About',
195
'customer_groups' => 'Customer groups',
196
'tracking_url' => 'Tracking url',
197
);
198
+ foreach ($properties as $propertyName) {
199
+ if (!isset($row[$propertyName])) $row[$propertyName] = null;
200
}
201
+ $this->propertiesSort = array_flip($properties);
202
uksort($row, array($this, 'sortProperties'));
203
$list = '';
204
$content = '';
205
$j = 0;
206
+ foreach ($row as $propertyName => $property) {
207
+ $propertyLabel = isset($propertiesLabel[$propertyName]) ? $propertiesLabel[$propertyName] : $propertyName;
208
$error = array();
209
if (isset($property['messages'])) {
210
foreach ($property['messages'] as $message) {
211
$error[] = $this->__($message);
212
}
213
}
214
+ $content .= "<tr class=\"os2-p-container" . ($error ? ' os2-error' : ''). "\""
215
+ . ($error ? ' title="' . $this->esc(implode(', ', $error)) . '"' : '')
216
+ . "><th>" . $this->__($propertyLabel) . "</th>"
217
+ . "<td>" . $this->_getPropertyInput($propertyName, $property, $big = false) . "</td>"
218
+ . "</tr>";
219
$j++;
220
}
221
$output = "<table class=properties-container>{$content}</table>";
222
return $output;
223
}
241
$content = $this->_getRowUI($row);
242
}
243
$error = false;
244
+ foreach ($row as $propertyName => $property) {
245
if (is_array($property) /*Compatibility*/ && isset($property['messages'])) {
246
$error = true;
247
break;
248
}
249
}
250
+ return "<li data-id=\"{$row['*id']}\"" . ($error ? ' class=os2-error' : '') . ">"
251
+ . "<h5><button class=\"os2-remove-row-btn\" title=\"{$this->__('Remove')}\"></button>" . $label . "</h5>"
252
+ . "<div class=\"row-ui" . ($opened ? ' opened' : '') . "\">{$content}</div></li>";
253
}
254
255
protected function esc($input)
259
260
protected function jsEscape($input)
261
{
262
+ return str_replace(array("\r\n", "\r", "\n", "'"), array("\\n", "\\n", "\\n", "\\'"), $input);
263
}
264
265
public function getRowUI(&$row)
270
public function getHtml()
271
{
272
$config = $this->getData('config');
273
+ $openedRowIds = $this->getData('opened_row_ids');
274
+ $output = '';
275
$i = 0;
276
if (!$config) {
277
$output .= "<p style=\"padding:10px;\">Configuration vide</p>";
278
} else {
279
$output .= "<ul id=os2-editor-elems-container>";
280
+ foreach ($config as $rowId => &$row) {
281
+ $opened = in_array($rowId, $openedRowIds) || !$openedRowIds && $i==0;
282
$output .= $this->_getRowItem($row, $opened);
283
$i++;
284
}
app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor/Property/Input.php CHANGED
@@ -1,28 +1,16 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor_Property_Input extends Mage_Adminhtml_Block_Abstract
23
{
24
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
25
{
26
-
27
}
28
}
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor_Property_Input extends Mage_Adminhtml_Block_Abstract
8
{
9
+ /**
10
+ * {@inheritdoc}
11
+ */
12
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
{
14
+ return '';
15
}
16
}
app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Help.php CHANGED
@@ -1,23 +1,8 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
23
{
@@ -30,26 +15,28 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abs
30
public function getHtml()
31
{
32
$controller = $this->getData('controller');
33
- $help_id = $this->getData('help_id');
34
$content = $this->getData('content');
35
$helper = $this->getData('helper');
36
37
- $locale_code = Mage::app()->getLocale()->getLocaleCode();
38
- $help_file = Mage::getBaseDir('app') . '/code/community/Owebia/Shipping2/doc_' . $locale_code . '.html';
39
- if (!file_exists($help_file)) {
40
- $help_file = Mage::getBaseDir('app') . '/code/community/Owebia/Shipping2/doc_en_US.html';
41
}
42
- $content = file_get_contents($help_file);
43
- $doc_sidebar = preg_replace('#^.*<!-- doc sidebar start -->(.*)<!-- doc sidebar end -->.*$#s', '\1', $content);
44
- $doc_content = preg_replace('#^.*<!-- doc content start -->(.*)<!-- doc content end -->.*$#s', '\1', $content);
45
- $doc_scripts = preg_replace('#^.*<!-- doc scripts start -->(.*)<!-- doc scripts end -->.*$#s', '\1', $content);
46
- $doc_scripts = str_replace('$(', "jQuery(", $doc_scripts);
47
- $doc_scripts = str_replace('$.', "jQuery.", $doc_scripts);
48
- $content = $doc_sidebar . $doc_content
49
- //. "<script>jQuery.fn.scrollspy = function(){};" . $doc_scripts . "</script>"
50
. "<script>
51
jQuery.fn.scrollspy = function(){};
52
- {$doc_scripts}
53
function bjson() {
54
var index = 0;
55
jQuery('div.json').each(function(){
@@ -69,49 +56,10 @@ setTimeout(function(){
69
}, 1000);
70
</script>"
71
;
72
- //$nav = "<div id=os2-help-nav><a href=\"#\" onclick=\"os2editor.refreshHelp();\">".$this->__('Refresh')."</a> | <a href=\"#\" onclick=\"os2editor.previousHelp();\">".$this->__('Previous page')."</a>".($help_id!='summary' ? " | <a href=\"#summary\">".$this->__('Summary')."</a>" : '')."</div>";
73
$nav = '';
74
$title = '';
75
$header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
76
- $content = ($header ? "{$header}" : '')."<div id=os2-help class=ui-layout-center>{$content}</div>";
77
- return $content;
78
-
79
- $controller = $this->getData('controller');
80
- $help_id = $this->getData('help_id');
81
- $content = $this->getData('content');
82
- $helper = $this->getData('helper');
83
- $content = str_replace(
84
- array("\\t", "<c>", "<c class=new>", "</c>", "<string>", "</string>", "<property>", "</property>"),
85
- array('&nbsp;&nbsp;&nbsp;', "<span class=code>", "<span class=\"code new\">", "</span>", "<span class=code><span class=string>", "</span></span>", "<span class=property>", "</span>"),
86
- $content);
87
- $header = null;
88
- $footer = null;
89
- $title = null;
90
- if ($help_id=='changelog') {
91
- $changelog = @file_get_contents($controller->getModulePath('changelog'));
92
- if (!$changelog) $changelog = "Empty changelog";
93
- $changelog = mb_convert_encoding($changelog, 'UTF-8', 'ISO-8859-1');
94
- if (!$changelog) $changelog = "Encoding error";
95
- $changelog = htmlspecialchars($changelog, ENT_QUOTES, 'UTF-8');
96
- $changelog = str_replace("\n", "<br/>", $changelog);
97
- $content = str_replace('{changelog}', $changelog, $content);
98
- }
99
- while (preg_match('#{code=json}(.*?){/code}#s', $content, $result)) {
100
- $json = str_replace("\r\n", '', $result[1]);
101
- try {
102
- $json = Zend_Json::decode($json);
103
- } catch (Exception $e) {}
104
- $content = str_replace($result[0], "<div class=code>".$helper::jsonEncode($json, $beautify = true, $html = true)."</div>", $content);
105
- }
106
- if (preg_match('#<h4>(.*)</h4>#', $content, $result)) {
107
- $title = $result[1];
108
- $content = str_replace($result[0], '', $content);
109
- }
110
- $nav = "<div id=os2-help-nav><a href=\"#\" onclick=\"os2editor.refreshHelp();\">".$this->__('Refresh')."</a> | <a href=\"#\" onclick=\"os2editor.previousHelp();\">".$this->__('Previous page')."</a>".($help_id!='summary' ? " | <a href=\"#summary\">".$this->__('Summary')."</a>" : '')."</div>";
111
- $header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
112
- $content = ($header ? "{$header}" : '')."<div id=os2-help class=ui-layout-center>{$content}</div>";
113
- $content = preg_replace('/ href="#([a-z0-9_\-\.]+)"/', ' href="#" onclick="os2editor.help(\'\1\');"', $content);
114
return $content;
115
-
116
}
117
}
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
8
{
15
public function getHtml()
16
{
17
$controller = $this->getData('controller');
18
+ $helpId = $this->getData('help_id');
19
$content = $this->getData('content');
20
$helper = $this->getData('helper');
21
22
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
23
+ $helpFileDir = Mage::getBaseDir('app') . '/code/community/Owebia/Shipping2';
24
+ $helpFileBasename = 'doc_' . $localeCode . '.html';
25
+ $ioFile = new Varien_Io_File();
26
+ $ioFile->cd($helpFileDir);
27
+ if ($ioFile->fileExists($helpFileBasename)) {
28
+ $helpFileBasename = 'doc_en_US.html';
29
}
30
+ $content = $ioFile->read($helpFileBasename);
31
+ $docSidebar = preg_replace('#^.*<!-- doc sidebar start -->(.*)<!-- doc sidebar end -->.*$#s', '\1', $content);
32
+ $docContent = preg_replace('#^.*<!-- doc content start -->(.*)<!-- doc content end -->.*$#s', '\1', $content);
33
+ $docScript = preg_replace('#^.*<!-- doc scripts start -->(.*)<!-- doc scripts end -->.*$#s', '\1', $content);
34
+ $docScript = str_replace('$(', "jQuery(", $docScript);
35
+ $docScript = str_replace('$.', "jQuery.", $docScript);
36
+ $content = $docSidebar . $docContent
37
. "<script>
38
jQuery.fn.scrollspy = function(){};
39
+ {$docScript}
40
function bjson() {
41
var index = 0;
42
jQuery('div.json').each(function(){
56
}, 1000);
57
</script>"
58
;
59
$nav = '';
60
$title = '';
61
$header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
62
+ $content = ($header ? "{$header}" : '') . "<div id=os2-help class=ui-layout-center>{$content}</div>";
63
return $content;
64
}
65
}
app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Config.php CHANGED
@@ -1,28 +1,14 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
- class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config extends Mage_Adminhtml_Block_System_Config_Form_Field
23
{
24
- private static $JS_INCLUDED = false;
25
-
26
public function __()
27
{
28
$args = func_get_args();
@@ -40,57 +26,56 @@ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config extends M
40
$head->addJs('owebia/shipping2/colorbox/jquery.colorbox-min.js');
41
$head->addJs('owebia/shipping2/jquery.caret.1.02.min.js');
42
$head->addJs('owebia/shipping2/os2editor.js');
43
- //$head->addItem('js_css', 'owebia/shipping2/jquery-ui-1.8.23.custom/css/ui-lightness/jquery-ui-1.8.23.custom.css');
44
$head->addItem('js_css', 'owebia/shipping2/colorbox/colorbox.css', 'media="all"');
45
$head->addItem('js_css', 'owebia/shipping2/os2editor.css', 'media="all"');
46
- //$head->addItem('other', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js');
47
- //$head->append($block);
48
-
49
parent::_prepareLayout();
50
}
51
52
- private function label__($input)
53
{
54
- return str_replace(array("\r\n","\r","\n","'"), array("\\n","\\n","\\n","\\'"), $this->__($input));
55
}
56
57
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
58
{
59
$output = '';
60
- if (!self::$JS_INCLUDED) {
61
$output = "<script type=\"text/javascript\">\n"
62
- ."//<![CDATA[\n"
63
- ."jQuery.noConflict();\n"
64
- ."var os2editor = new OS2Editor({\n"
65
- ."ajax_url: '".$this->getUrl('adminhtml/os2_ajax/index')."?isAjax=true',\n"
66
- ."form_key: FORM_KEY,\n"
67
- ."apply_btn_label: '".$this->label__('Apply')."',\n"
68
- ."cancel_btn_label: '".$this->label__('Cancel')."',\n"
69
- ."menu_item_dissociate_label: '".$this->label__('Dissociate')."',\n"
70
- ."menu_item_remove_label: '".$this->label__('Remove')."',\n"
71
- ."menu_item_edit_label: '".$this->label__('Edit')."',\n"
72
- ."prompt_new_value_label: '".$this->label__('Enter the new value:')."',\n"
73
- ."default_row_label: '".$this->label__('[No label]')."',\n"
74
- ."loading_label: '".$this->label__('Loading...')."'\n"
75
- ."});\n"
76
- ."
77
"
78
- ."//]]>\n"
79
- ."</script>\n"
80
;
81
- self::$JS_INCLUDED = true;
82
}
83
84
- $shipping_code = preg_replace('/^groups\[([^\]]*)\].*#x2F;','\1',$element->getName());
85
return <<<EOD
86
{$output}
87
<div style="margin-bottom:1px;">
88
- <button type="button" class="scalable" onclick="os2editor.init(this, '{$shipping_code}').page('source');"><span>{$this->__('Source &amp; Correction')}</span></button>
89
- <button type="button" class="scalable" onclick="os2editor.init(this, '{$shipping_code}').help('summary');"><span>{$this->__('Help')}</span></button>
90
<!--<a href="{$this->getUrl('adminhtml/os2_ajax/doc')}">doc</a>-->
91
</div>
92
{$element->getElementHtml()}<br/>
93
- <a href="http://www.owebia.com/contributions/magento/owebia-shipping/fr/modeles-de-configuration" target="_blank">{$this->__('Download configuration templates')}</a>
94
EOD;
95
}
96
}
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
+ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
{
10
+ protected static $_isJsIncluded = false;
11
+
12
public function __()
13
{
14
$args = func_get_args();
26
$head->addJs('owebia/shipping2/colorbox/jquery.colorbox-min.js');
27
$head->addJs('owebia/shipping2/jquery.caret.1.02.min.js');
28
$head->addJs('owebia/shipping2/os2editor.js');
29
$head->addItem('js_css', 'owebia/shipping2/colorbox/colorbox.css', 'media="all"');
30
$head->addItem('js_css', 'owebia/shipping2/os2editor.css', 'media="all"');
31
parent::_prepareLayout();
32
}
33
34
+ protected function label__($input)
35
{
36
+ return str_replace(array("\r\n", "\r", "\n", "'"), array("\\n", "\\n", "\\n", "\\'"), $this->__($input));
37
}
38
39
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
40
{
41
$output = '';
42
+ if (!self::$_isJsIncluded) {
43
$output = "<script type=\"text/javascript\">\n"
44
+ . "//<![CDATA[\n"
45
+ . "jQuery.noConflict();\n"
46
+ . "var os2editor = new OS2Editor({\n"
47
+ . "ajax_url: '" . $this->getUrl('adminhtml/os2_ajax/index') . "?isAjax=true',\n"
48
+ . "form_key: FORM_KEY,\n"
49
+ . "apply_btn_label: '" . $this->label__('Apply') . "',\n"
50
+ . "cancel_btn_label: '" . $this->label__('Cancel') . "',\n"
51
+ . "menu_item_dissociate_label: '" . $this->label__('Dissociate') . "',\n"
52
+ . "menu_item_remove_label: '" . $this->label__('Remove') . "',\n"
53
+ . "menu_item_edit_label: '" . $this->label__('Edit') . "',\n"
54
+ . "prompt_new_value_label: '" . $this->label__('Enter the new value:') . "',\n"
55
+ . "default_row_label: '" . $this->label__('[No label]') . "',\n"
56
+ . "loading_label: '" . $this->label__('Loading...') . "'\n"
57
+ . "});\n"
58
+ . "
59
"
60
+ . "//]]>\n"
61
+ . "</script>\n"
62
;
63
+ self::$_isJsIncluded = true;
64
}
65
66
+ $shippingCode = preg_replace('/^groups\[([^\]]*)\].*#x2F;', '\1', $element->getName());
67
return <<<EOD
68
{$output}
69
<div style="margin-bottom:1px;">
70
+ <button type="button" class="scalable" onclick="os2editor.init(this, '{$shippingCode}').page('source');"
71
+ ><span>{$this->__('Source &amp; Correction')}</span></button>
72
+ <button type="button" class="scalable" onclick="os2editor.init(this, '{$shippingCode}').help('summary');"
73
+ ><span>{$this->__('Help')}</span></button>
74
<!--<a href="{$this->getUrl('adminhtml/os2_ajax/doc')}">doc</a>-->
75
</div>
76
{$element->getElementHtml()}<br/>
77
+ <a href="http://www.owebia.com/contributions/magento/owebia-shipping/fr/modeles-de-configuration" target="_blank"
78
+ >{$this->__('Download configuration templates')}</a>
79
EOD;
80
}
81
}
app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Informations.php CHANGED
@@ -1,25 +1,11 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
- class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations extends Mage_Adminhtml_Block_System_Config_Form_Field
23
{
24
public function __()
25
{
@@ -27,6 +13,9 @@ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations ext
27
return Mage::helper('owebia_shipping2')->__($args);
28
}
29
30
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
31
{
32
$version = Mage::getConfig()->getNode('modules/Owebia_Shipping2/version');
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
+ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
{
10
public function __()
11
{
13
return Mage::helper('owebia_shipping2')->__($args);
14
}
15
16
+ /**
17
+ * {@inheritDoc}
18
+ */
19
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
20
{
21
$version = Mage::getConfig()->getNode('modules/Owebia_Shipping2/version');
app/code/community/Owebia/Shipping2/Controller/Abstract.php CHANGED
@@ -1,44 +1,39 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Action
23
{
24
public function __()
25
{
26
$args = func_get_args();
27
return Mage::helper('owebia_shipping2')->__($args);
28
}
29
30
- public function getModulePath($path)
31
{
32
- if (file_exists(dirname(__FILE__) . '/Owebia_Shipping2_' . str_replace('/', '_', $path))) {
33
- return 'Owebia_Shipping2_'.str_replace('/', '_', $path);
34
- } else {
35
- return Mage::getBaseDir('code') . '/community/Owebia/Shipping2/' . $path;
36
- }
37
}
38
39
protected function getMimeType($extension)
40
{
41
- $mime_type_array = array(
42
'.gz' => 'application/x-gzip',
43
'.tgz' => 'application/x-gzip',
44
'.zip' => 'application/zip',
@@ -53,54 +48,66 @@ class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Act
53
'.mpg' => 'video/mpeg',
54
'.avi' => 'video/x-msvideo',
55
);
56
- return isset($mime_type_array[$extension]) ? $mime_type_array[$extension] : 'application/octet-stream';
57
}
58
-
59
protected function forceDownload($filename, $content)
60
{
61
if (headers_sent()) {
62
- trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
63
return false;
64
}
65
66
- $extension = strrchr($filename,'.');
67
- $mime_type = $this->getMimeType($extension);
68
69
- header('Content-disposition: attachment; filename="'.$filename.'"');
70
- header('Content-Type: application/force-download');
71
- header('Content-Transfer-Encoding: '.$mime_type."\n"); // Surtout ne pas enlever le \n
72
- //header('Content-Length: '.filesize($filename));
73
- header('Pragma: no-cache');
74
- header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
75
- header('Expires: 0');
76
- echo $content;
77
- return true;
78
}
79
80
protected function cleanKey($key)
81
{
82
- return preg_replace('/[^a-z0-9\-_]/i','_',$key);
83
}
84
85
- protected function page($page, $layout_content = array(), $with_dialog = true)
86
{
87
- if (!is_array($layout_content)) $layout_content = array('center' => $layout_content);
88
- return ($with_dialog ? "<div id=os2-dialog>"
89
- . $this->pageHeader($this->__('Owebia Shipping 2 Editor'),
90
- $this->button__('Source &amp; Correction', "os2editor.page('source');", 'source')
91
- . $this->button__('Help', "os2editor.help('summary');", 'help')
92
- //. $this->button__('Donate', "os2editor.page('donate');", 'donate')
93
- . $this->button__('Close', "os2editor.close();", 'cancel')
94
)
95
. "<div id=os2-page-container class=ui-layout-center>" : '')
96
. "<div id=os2-page-{$page} class=os2-page>"
97
- . (!isset($layout_content['north']) ? '' : "<div class=\"ui-layout-north inner-layout\">".$layout_content['north']."</div>")
98
- . "<div class=\"ui-layout-center inner-layout\">".$layout_content['center']."</div>"
99
- . (!isset($layout_content['south']) ? '' : "<div class=\"ui-layout-south inner-layout\">".$layout_content['south']."</div>")
100
- . (!isset($layout_content['west']) ? '' : "<div class=\"ui-layout-west inner-layout\">".$layout_content['west']."</div>")
101
- . (!isset($layout_content['east']) ? '' : "<div class=\"ui-layout-east inner-layout\">".$layout_content['east']."</div>")
102
. "</div>"
103
- . ($with_dialog ? "</div>"
104
. "</div>" : '')
105
;
106
}
@@ -108,22 +115,23 @@ class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Act
108
protected function pageHeader($title, $buttons)
109
{
110
return "<div class=ui-layout-north><div id=os2-page-header>"
111
- ."<table cellspacing=0><tr>"
112
- ."<td><h3>{$title}</h3></td>"
113
- ."<td class=buttons>{$buttons}</td>"
114
- ."</tr></table>"
115
- ."</div></div>"
116
;
117
}
118
119
- public function button($label, $onclick, $class_name='')
120
{
121
- $class_name = 'scalable'.($class_name!='' ? ' '.$class_name : '');
122
- return "<button type=\"button\" class=\"".$class_name."\" onclick=\"".$onclick."\"><span>".$label."</span></button>";
123
}
124
125
- public function button__($label, $onclick, $class_name='')
126
{
127
- return $this->button($this->__($label),$onclick,$class_name);
128
}
129
}
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Action
8
{
9
+ protected function _isAllowed()
10
+ {
11
+ return Mage::getSingleton('admin/session')->isAllowed('admin');
12
+ }
13
+
14
public function __()
15
{
16
$args = func_get_args();
17
return Mage::helper('owebia_shipping2')->__($args);
18
}
19
20
+ protected function outputContent($content)
21
{
22
+ return $this->getResponse()
23
+ ->setBody($content);
24
+ }
25
+
26
+ protected function json($data)
27
+ {
28
+ return $this->outputContent(
29
+ Mage::helper('core')
30
+ ->jsonEncode($data)
31
+ );
32
}
33
34
protected function getMimeType($extension)
35
{
36
+ $mimeTypeArray = array(
37
'.gz' => 'application/x-gzip',
38
'.tgz' => 'application/x-gzip',
39
'.zip' => 'application/zip',
48
'.mpg' => 'video/mpeg',
49
'.avi' => 'video/x-msvideo',
50
);
51
+ return isset($mimeTypeArray[$extension]) ? $mimeTypeArray[$extension] : 'application/octet-stream';
52
}
53
+
54
protected function forceDownload($filename, $content)
55
{
56
if (headers_sent()) {
57
+ trigger_error('forceDownload($filename) - Headers have already been sent', E_USER_ERROR);
58
return false;
59
}
60
61
+ $extension = strrchr($filename, '.');
62
+ $mimeType = $this->getMimeType($extension);
63
64
+ $this->getResponse()
65
+ ->clearHeaders()
66
+ ->setHeader('Content-disposition', 'attachment; filename="' . $filename . '"')
67
+ ->setHeader('Content-Type', 'application/force-download')
68
+ ->setHeader('Content-Transfer-Encoding', $mimeType . "\n") // Surtout ne pas enlever le \n
69
+ ->setHeader('Pragma', 'no-cache')
70
+ ->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
71
+ ->setHeader('Expires', '0');
72
+ return $this->outputContent($content);
73
}
74
75
protected function cleanKey($key)
76
{
77
+ return preg_replace('/[^a-z0-9\-_]/i', '_', $key);
78
}
79
80
+ protected function page($page, $layoutContent = array(), $withDialog = true)
81
{
82
+ if (!is_array($layoutContent)) $layoutContent = array('center' => $layoutContent);
83
+ return ($withDialog ? "<div id=os2-dialog>"
84
+ . $this->pageHeader(
85
+ $this->__('Owebia Shipping 2 Editor'),
86
+ $this->button__('Source &amp; Correction', "os2editor.page('source');", 'source')
87
+ . $this->button__('Help', "os2editor.help('summary');", 'help')
88
+ . $this->button__('Close', "os2editor.close();", 'cancel')
89
)
90
. "<div id=os2-page-container class=ui-layout-center>" : '')
91
. "<div id=os2-page-{$page} class=os2-page>"
92
+ . (!isset($layoutContent['north'])
93
+ ? ''
94
+ : "<div class=\"ui-layout-north inner-layout\">" . $layoutContent['north'] . "</div>"
95
+ )
96
+ . "<div class=\"ui-layout-center inner-layout\">" . $layoutContent['center'] . "</div>"
97
+ . (!isset($layoutContent['south'])
98
+ ? ''
99
+ : "<div class=\"ui-layout-south inner-layout\">" . $layoutContent['south'] . "</div>"
100
+ )
101
+ . (!isset($layoutContent['west'])
102
+ ? ''
103
+ : "<div class=\"ui-layout-west inner-layout\">" . $layoutContent['west'] . "</div>"
104
+ )
105
+ . (!isset($layoutContent['east'])
106
+ ? ''
107
+ : "<div class=\"ui-layout-east inner-layout\">" . $layoutContent['east'] . "</div>"
108
+ )
109
. "</div>"
110
+ . ($withDialog ? "</div>"
111
. "</div>" : '')
112
;
113
}
115
protected function pageHeader($title, $buttons)
116
{
117
return "<div class=ui-layout-north><div id=os2-page-header>"
118
+ . "<table cellspacing=0><tr>"
119
+ . "<td><h3>{$title}</h3></td>"
120
+ . "<td class=buttons>{$buttons}</td>"
121
+ . "</tr></table>"
122
+ . "</div></div>"
123
;
124
}
125
126
+ public function button($label, $onclick, $className = '')
127
{
128
+ $className = 'scalable' . ($className != '' ? ' ' . $className : '');
129
+ return "<button type=\"button\" class=\"" . $className . "\" onclick=\"" . $onclick . "\">"
130
+ . "<span>" . $label . "</span></button>";
131
}
132
133
+ public function button__($label, $onclick, $className = '')
134
{
135
+ return $this->button($this->__($label), $onclick, $className);
136
}
137
}
app/code/community/Owebia/Shipping2/Helper/Data.php CHANGED
@@ -1,76 +1,39 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
23
{
24
- protected $_translate_inline;
25
26
public function __()
27
{
28
$args = func_get_args();
29
- if (isset($args[0]) && is_array($args[0]) && count($args)==1) {
30
$args = $args[0];
31
}
32
$message = array_shift($args);
33
- if ($message instanceof OS_Message) {
34
$args = $message->args;
35
$message = $message->message;
36
}
37
-
38
- $output = parent::__($message);
39
-
40
- /*if (true) {
41
- $translations = @file_get_contents('translations.os2');
42
- $translations = eval('return '.$translations.';');
43
- if (!is_array($translations)) $translations = array();
44
-
45
- $file = 'NC';
46
- $line = 'NC';
47
- $backtrace = debug_backtrace();
48
- foreach ($backtrace as $trace) {
49
- if (!isset($trace['function'])) continue;
50
- if (substr($trace['function'], strlen($trace['function'])-2, strlen($trace['function']))=='__') {
51
- $file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/');
52
- $line = $trace['line'];
53
- continue;
54
- }
55
- //$file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/');
56
- //echo $file.', '.$trace['function'].'(), '.$line.', '.$message.'<br/>';
57
- break;
58
- }
59
60
- $translations[Mage::app()->getLocale()->getLocaleCode()][$file][$message] = $output;
61
- ksort($translations[Mage::app()->getLocale()->getLocaleCode()]);
62
- file_put_contents('translations.os2', var_export($translations, true));
63
- }*/
64
65
- if (count($args)==0) {
66
$result = $output;
67
} else {
68
- if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
69
- if ($this->_translate_inline) {
70
$parts = explode('}}{{', $output);
71
$parts[0] = vsprintf($parts[0], $args);
72
$result = implode('}}{{', $parts);
73
- } else {
74
$result = vsprintf($output, $args);
75
}
76
}
@@ -83,50 +46,70 @@ class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
83
84
$output = '';
85
$cart = $process['data']['cart'];
86
- return $helper->evalInput($process, $row, $property, str_replace(
87
- array(
88
- '{cart.weight}',
89
- '{cart.price-tax+discount}',
90
- '{cart.price-tax-discount}',
91
- '{cart.price+tax+discount}',
92
- '{cart.price+tax-discount}',
93
- ),
94
- array(
95
- $cart->weight . $cart->weight_unit,
96
- $this->currency($cart->{'price-tax+discount'}),
97
- $this->currency($cart->{'price-tax-discount'}),
98
- $this->currency($cart->{'price+tax+discount'}),
99
- $this->currency($cart->{'price+tax-discount'}),
100
- ),
101
- $helper->getRowProperty($row, $property)
102
- ));
103
}
104
-
105
- public function getDataModelMap($helper, $carrier_code, $request)
106
{
107
- $mage_config = Mage::getConfig();
108
return array(
109
- 'info' => Mage::getModel('owebia_shipping2/Os2_Data_Info', array_merge($helper->getInfos(), array(
110
- 'magento_version' => Mage::getVersion(),
111
- 'module_version' => (string)$mage_config->getNode('modules/Owebia_Shipping2/version'),
112
- 'carrier_code' => $carrier_code,
113
- ))),
114
- 'cart' => Mage::getModel('owebia_shipping2/Os2_Data_Cart', array(
115
- 'request' => $request,
116
- 'options' => array(
117
- 'bundle' => array(
118
- 'process_children' => (boolean)Mage::getStoreConfig('owebia_shipping2/bundle_product/process_children'),
119
- 'load_item_options_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/bundle_product/load_item_options_on_parent'),
120
- 'load_item_data_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/bundle_product/load_item_data_on_parent'),
121
- 'load_product_data_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/bundle_product/load_product_data_on_parent'),
122
- ),
123
- 'configurable' => array(
124
- 'load_item_options_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/configurable_product/load_item_options_on_parent'),
125
- 'load_item_data_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/configurable_product/load_item_data_on_parent'),
126
- 'load_product_data_on_parent' => (boolean)Mage::getStoreConfig('owebia_shipping2/configurable_product/load_product_data_on_parent'),
127
- ),
128
- ),
129
- )),
130
'quote' => Mage::getModel('owebia_shipping2/Os2_Data_Quote'),
131
'selection' => Mage::getModel('owebia_shipping2/Os2_Data_Selection'),
132
'customer' => Mage::getModel('owebia_shipping2/Os2_Data_Customer'),
@@ -134,20 +117,32 @@ class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
134
'customvar' => Mage::getModel('owebia_shipping2/Os2_Data_Customvar'),
135
'date' => Mage::getModel('owebia_shipping2/Os2_Data_Date'),
136
'address_filter' => Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter'),
137
- 'origin' => Mage::getModel('owebia_shipping2/Os2_Data_Address', $this->_extract($request->getData(), array(
138
- 'country_id' => 'country_id',
139
- 'region_id' => 'region_id',
140
- 'postcode' => 'postcode',
141
- 'city' => 'city',
142
- ))),
143
- 'shipto' => Mage::getModel('owebia_shipping2/Os2_Data_Address', $this->_extract($request->getData(), array(
144
- 'country_id' => 'dest_country_id',
145
- 'region_id' => 'dest_region_id',
146
- 'region_code' => 'dest_region_code',
147
- 'street' => 'dest_street',
148
- 'city' => 'dest_city',
149
- 'postcode' => 'dest_postcode',
150
- ))),
151
'billto' => Mage::getModel('owebia_shipping2/Os2_Data_Billto'),
152
'store' => Mage::getModel('owebia_shipping2/Os2_Data_Store', array('id' => $request->getData('store_id'))),
153
'request' => Mage::getModel('owebia_shipping2/Os2_Data_Abstract', $request->getData()),
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
8
{
9
+ protected $_isTranslateInlineEnabled;
10
11
public function __()
12
{
13
$args = func_get_args();
14
+ if (isset($args[0]) && is_array($args[0]) && count($args) == 1) {
15
$args = $args[0];
16
}
17
$message = array_shift($args);
18
+ if ($message instanceof Owebia_Shipping2_Model_Os2_Message) {
19
$args = $message->args;
20
$message = $message->message;
21
}
22
23
+ $output = parent::__($message);
24
25
+ if (count($args) == 0) {
26
$result = $output;
27
} else {
28
+ if (!isset($this->_isTranslateInlineEnabled)) {
29
+ $this->_isTranslateInlineEnabled = Mage::getSingleton('core/translate')
30
+ ->getTranslateInline();
31
+ }
32
+ if ($this->_isTranslateInlineEnabled) {
33
$parts = explode('}}{{', $output);
34
$parts[0] = vsprintf($parts[0], $args);
35
$result = implode('}}{{', $parts);
36
+ } else {
37
$result = vsprintf($output, $args);
38
}
39
}
46
47
$output = '';
48
$cart = $process['data']['cart'];
49
+ return $helper->evalInput(
50
+ $process,
51
+ $row,
52
+ $property,
53
+ str_replace(
54
+ array(
55
+ '{cart.weight}',
56
+ '{cart.price-tax+discount}',
57
+ '{cart.price-tax-discount}',
58
+ '{cart.price+tax+discount}',
59
+ '{cart.price+tax-discount}',
60
+ ),
61
+ array(
62
+ $cart->getData('weight') . $cart->getData('weight_unit'),
63
+ $this->currency($cart->getData('price-tax+discount')),
64
+ $this->currency($cart->getData('price-tax-discount')),
65
+ $this->currency($cart->getData('price+tax+discount')),
66
+ $this->currency($cart->getData('price+tax-discount')),
67
+ ),
68
+ $helper->getRowProperty($row, $property)
69
+ )
70
+ );
71
}
72
+
73
+ protected function getBoolean($path)
74
{
75
+ return (boolean) Mage::getStoreConfig('owebia_shipping2/' . $path);
76
+ }
77
+
78
+ public function getDataModelMap($helper, $carrierCode, $request)
79
+ {
80
+ $mageConfig = Mage::getConfig();
81
+ $cartOptions = array(
82
+ 'bundle' => array(
83
+ 'process_children' => $this->getBoolean('bundle_product/process_children'),
84
+ 'load_item_options_on_parent' => $this->getBoolean('bundle_product/load_item_options_on_parent'),
85
+ 'load_item_data_on_parent' => $this->getBoolean('bundle_product/load_item_data_on_parent'),
86
+ 'load_product_data_on_parent' => $this->getBoolean('bundle_product/load_product_data_on_parent'),
87
+ ),
88
+ 'configurable' => array(
89
+ 'load_item_options_on_parent' => $this->getBoolean('configurable_product/load_item_options_on_parent'),
90
+ 'load_item_data_on_parent' => $this->getBoolean('configurable_product/load_item_data_on_parent'),
91
+ 'load_product_data_on_parent' => $this->getBoolean('configurable_product/load_product_data_on_parent'),
92
+ ),
93
+ );
94
return array(
95
+ 'info' => Mage::getModel(
96
+ 'owebia_shipping2/Os2_Data_Info',
97
+ array_merge(
98
+ $helper->getInfos(),
99
+ array(
100
+ 'magento_version' => Mage::getVersion(),
101
+ 'module_version' => (string)$mageConfig->getNode('modules/Owebia_Shipping2/version'),
102
+ 'carrier_code' => $carrierCode,
103
+ )
104
+ )
105
+ ),
106
+ 'cart' => Mage::getModel(
107
+ 'owebia_shipping2/Os2_Data_Cart',
108
+ array(
109
+ 'request' => $request,
110
+ 'options' => $cartOptions,
111
+ )
112
+ ),
113
'quote' => Mage::getModel('owebia_shipping2/Os2_Data_Quote'),
114
'selection' => Mage::getModel('owebia_shipping2/Os2_Data_Selection'),
115
'customer' => Mage::getModel('owebia_shipping2/Os2_Data_Customer'),
117
'customvar' => Mage::getModel('owebia_shipping2/Os2_Data_Customvar'),
118
'date' => Mage::getModel('owebia_shipping2/Os2_Data_Date'),
119
'address_filter' => Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter'),
120
+ 'origin' => Mage::getModel(
121
+ 'owebia_shipping2/Os2_Data_Address',
122
+ $this->_extract(
123
+ $request->getData(),
124
+ array(
125
+ 'country_id' => 'country_id',
126
+ 'region_id' => 'region_id',
127
+ 'postcode' => 'postcode',
128
+ 'city' => 'city',
129
+ )
130
+ )
131
+ ),
132
+ 'shipto' => Mage::getModel(
133
+ 'owebia_shipping2/Os2_Data_Address',
134
+ $this->_extract(
135
+ $request->getData(),
136
+ array(
137
+ 'country_id' => 'dest_country_id',
138
+ 'region_id' => 'dest_region_id',
139
+ 'region_code' => 'dest_region_code',
140
+ 'street' => 'dest_street',
141
+ 'city' => 'dest_city',
142
+ 'postcode' => 'dest_postcode',
143
+ )
144
+ )
145
+ ),
146
'billto' => Mage::getModel('owebia_shipping2/Os2_Data_Billto'),
147
'store' => Mage::getModel('owebia_shipping2/Os2_Data_Store', array('id' => $request->getData('store_id'))),
148
'request' => Mage::getModel('owebia_shipping2/Os2_Data_Abstract', $request->getData()),
app/code/community/Owebia/Shipping2/Model/AddressFilterParser.php ADDED
@@ -0,0 +1,188 @@
1
+ <?php
2
+ /**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ class Owebia_Shipping2_Model_AddressFilterParser
8
+ {
9
+ protected $_configParser;
10
+ protected $_input = null;
11
+ protected $_position = null;
12
+ protected $_bufferStart = null;
13
+ protected $_char = null;
14
+ protected $_join = null;
15
+
16
+ protected $_output = '';
17
+ protected $_level = null;
18
+ protected $_parentLevel = null;
19
+ protected $_regexp = false;
20
+ protected $_litteral = false;
21
+ protected $_litteralQuote = null;
22
+ protected $_callbackMap = array(
23
+ '(' => 'openingParenthesisCallback',
24
+ ')' => 'closingParenthesisCallback',
25
+ '"' => 'quoteCallback',
26
+ "'" => 'quoteCallback',
27
+ ' ' => 'spaceCallback',
28
+ '-' => 'hyphenCallback',
29
+ ',' => 'commaCallback',
30
+ '/' => 'slashCallback',
31
+ );
32
+
33
+ public function __construct($configParser)
34
+ {
35
+ $this->_configParser = $configParser;
36
+ }
37
+
38
+ public function parse($input)
39
+ {
40
+ $this->current = array();
41
+
42
+ $this->_input = $input;
43
+ $this->length = strlen($this->_input);
44
+ // look at each character
45
+ $this->_join = ' && ';
46
+ for ($this->_position = 0; $this->_position < $this->length; $this->_position++) {
47
+ $this->_char = $this->_input[$this->_position];
48
+ if (isset($this->_callbackMap[$this->_char])) {
49
+ $this->{$this->_callbackMap[$this->_char]}();
50
+ } else {
51
+ $this->defaultCallback();
52
+ }
53
+ }
54
+ $this->push($this->buffer());
55
+ return $this->_output;
56
+ }
57
+
58
+ protected function closingParenthesisCallback()
59
+ {
60
+ if ($this->_regexp || $this->_litteral) {
61
+ return;
62
+ }
63
+ $this->push($this->buffer() . ')');
64
+ $this->_parentLevel = null;
65
+ }
66
+
67
+ protected function openingParenthesisCallback()
68
+ {
69
+ if ($this->_regexp || $this->_litteral) {
70
+ return;
71
+ }
72
+ $this->push($this->buffer());
73
+ $this->push($this->_join, $onlyIfNotEmpty = true);
74
+ $this->push('(');
75
+ $this->_parentLevel = $this->_level;
76
+ $this->_join = ' && ';
77
+ }
78
+
79
+ protected function quoteCallback()
80
+ {
81
+ if (!$this->_litteral || $this->_litteralQuote == $this->_char) {
82
+ $this->_litteral = !$this->_litteral;
83
+ $this->_litteralQuote = $this->_char;
84
+ }
85
+ if ($this->_bufferStart === null) {
86
+ $this->_bufferStart = $this->_position;
87
+ }
88
+ }
89
+
90
+ protected function spaceCallback()
91
+ {
92
+ if ($this->_regexp || $this->_litteral) {
93
+ return;
94
+ }
95
+ $this->push($this->buffer());
96
+ }
97
+
98
+ protected function hyphenCallback()
99
+ {
100
+ if ($this->_regexp || $this->_litteral) {
101
+ return;
102
+ }
103
+ $this->push($this->buffer());
104
+ $this->_join = ' && !';
105
+ }
106
+
107
+ protected function commaCallback()
108
+ {
109
+ if ($this->_regexp || $this->_litteral) {
110
+ return;
111
+ }
112
+ $this->push($this->buffer());
113
+ $this->push(' || ');
114
+ }
115
+
116
+ protected function slashCallback()
117
+ {
118
+ $this->_regexp = !$this->_regexp;
119
+ $this->defaultCallback();
120
+ }
121
+
122
+ protected function defaultCallback()
123
+ {
124
+ if ($this->_bufferStart === null) {
125
+ $this->_bufferStart = $this->_position;
126
+ }
127
+ }
128
+
129
+ protected function escapeString($input)
130
+ {
131
+ return $this->_configParser->escapeString($input);
132
+ }
133
+
134
+ protected function buffer()
135
+ {
136
+ if ($this->_bufferStart !== null) {
137
+ // extract string from buffer start to current position
138
+ $buffer = substr($this->_input, $this->_bufferStart, $this->_position - $this->_bufferStart);
139
+ // clean buffer
140
+ $this->_bufferStart = null;
141
+ // throw token into current scope
142
+ if ($buffer == '*') {
143
+ $buffer = 1;
144
+ } else if ($this->_parentLevel == 'country') {
145
+ if (preg_match('/^[A-Z]{2}#x2F;', $buffer)) {
146
+ $buffer = "{{c}}==={$this->escapeString($buffer)}";
147
+ $this->_level = 'country';
148
+ } else if (substr($buffer, 0, 1) == '/'
149
+ && (substr($buffer, strlen($buffer) - 1, 1) == '/'
150
+ || substr($buffer, strlen($buffer) - 2, 2) == '/i'
151
+ )
152
+ ) {
153
+ $buffer = "preg_match('" . str_replace("'", "\\'", $buffer) . "', (string)({{p}}))";
154
+ } else if (strpos($buffer, '*') !== false) {
155
+ $buffer = "preg_match('/^"
156
+ . str_replace(
157
+ array("'", '*'),
158
+ array("\\'", '(?:.*)'),
159
+ $buffer
160
+ )
161
+ . "#x2F;', (string)({{p}}))";
162
+ } else if (preg_match('/^"[^"]+"#x2F;', $buffer)) {
163
+ $buffer = trim($buffer, '"');
164
+ $buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
165
+ } else if (preg_match('/^\'[^\']+\'#x2F;', $buffer)) {
166
+ $buffer = trim($buffer, "'");
167
+ $buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
168
+ } else {
169
+ $buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
170
+ }
171
+ } else if (preg_match('/^[A-Z]{2}#x2F;', $buffer)) {
172
+ $buffer = "{{c}}==={$this->escapeString($buffer)}";
173
+ $this->_level = 'country';
174
+ }
175
+ return $buffer;
176
+ }
177
+ return null;
178
+ }
179
+
180
+ protected function push($text, $onlyIfNotEmpty = false)
181
+ {
182
+ if (isset($text)) {
183
+ if (!$onlyIfNotEmpty || $this->_output) {
184
+ $this->_output .= $text;
185
+ }
186
+ }
187
+ }
188
+ }
app/code/community/Owebia/Shipping2/Model/Carrier/Abstract.php CHANGED
@@ -1,38 +1,14 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
-
22
- // if compilation
23
- if (file_exists(dirname(__FILE__).'/Owebia_Shipping2_includes_OwebiaShippingHelper.php')) {
24
- include_once 'Owebia_Shipping2_includes_OS2_AddressFilterParser.php';
25
- include_once 'Owebia_Shipping2_includes_OwebiaShippingHelper.php';
26
- } else {
27
- include_once Mage::getBaseDir('code').'/community/Owebia/Shipping2/includes/OS2_AddressFilterParser.php';
28
- include_once Mage::getBaseDir('code').'/community/Owebia/Shipping2/includes/OwebiaShippingHelper.php';
29
- }
30
31
abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract
32
{
33
protected $_config;
34
- protected $_helper;
35
- protected $_data_models = array();
36
37
/**
38
* Collect rates for this shipping method based on information in $request
@@ -42,23 +18,10 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
42
*/
43
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
44
{
45
- //setlocale(LC_NUMERIC, 'fr_FR');
46
if (!$this->__getConfigData('active')) return false; // skip if not enabled
47
- //$this->display($request->_data);
48
$process = $this->__getProcess($request);
49
return $this->getRates($process);
50
}
51
-
52
- public function display($var)
53
- {
54
- $i = 0;
55
- foreach ($var as $name => $value) {
56
- //if ($i>20)
57
- echo "{$name} => {$value}<br/>";
58
- //$this->_helper->debug($name.' => '.$value.'<br/>');
59
- $i++;
60
- }
61
- }
62
63
public function getRates($process)
64
{
@@ -70,11 +33,13 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
70
{
71
$process = array();
72
$config = $this->_getConfig();
73
- $allowed_methods = array();
74
if (count($config)>0) {
75
- foreach ($config as $row) $allowed_methods[$row['*id']] = isset($row['label']) ? $row['label']['value'] : 'No label';
76
}
77
- return $allowed_methods;
78
}
79
80
public function isTrackingAvailable()
@@ -82,96 +47,106 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
82
return true;
83
}
84
85
- public function getTrackingInfo($tracking_number)
86
{
87
- $original_tracking_number = $tracking_number;
88
- $global_tracking_url = $this->__getConfigData('tracking_view_url');
89
- $tracking_url = $global_tracking_url;
90
- $parts = explode(':', $tracking_number);
91
- if (count($parts)>=2) {
92
- $tracking_number = $parts[1];
93
94
$process = array();
95
$config = $this->_getConfig();
96
-
97
if (isset($config[$parts[0]]['tracking_url'])) {
98
$row = $config[$parts[0]];
99
- $tmp_tracking_url = $this->_helper->getRowProperty($row, 'tracking_url');
100
- if (isset($tmp_tracking_url)) $tracking_url = $tmp_tracking_url;
101
}
102
}
103
104
- $tracking_status = Mage::getModel('shipping/tracking_result_status')
105
->setCarrier($this->_code)
106
->setCarrierTitle($this->__getConfigData('title'))
107
- ->setTracking($tracking_number)
108
->addData(
109
array(
110
- 'status'=> $tracking_url ? '<a target="_blank" href="' . str_replace('{tracking_number}', $tracking_number, $tracking_url) . '">' . $this->__('track the package') . '</a>' : "suivi non disponible pour le colis {$tracking_number} (original_tracking_number='{$original_tracking_number}', global_tracking_url='{$global_tracking_url}'" . (isset($row) ? ", tmp_tracking_url='{$tmp_tracking_url}'" : '') . ")"
111
)
112
- )
113
- ;
114
- $tracking_result = Mage::getModel('shipping/tracking_result')
115
- ->append($tracking_status)
116
- ;
117
118
- if ($trackings = $tracking_result->getAllTrackings()) return $trackings[0];
119
return false;
120
}
121
-
122
- /***************************************************************************************************************************/
123
124
protected function _process(&$process)
125
{
126
- $debug = (bool)(isset($_GET['debug']) ? $_GET['debug'] : $this->__getConfigData('debug'));
127
- if ($debug) $this->_helper->initDebug($this->_code, $process);
128
129
- $value_found = false;
130
foreach ($process['config'] as $row) {
131
- $result = $this->_helper->processRow($process, $row);
132
if ($result->success) {
133
- $value_found = true;
134
$this->__appendMethod($process, $row, $result->result);
135
if ($process['options']->stop_to_first_match) break;
136
}
137
}
138
-
139
- $http_request = Mage::app()->getFrontController()->getRequest();
140
- if ($debug && $this->__checkRequest($http_request, 'checkout/cart/index')) {
141
Mage::getSingleton('core/session')
142
- ->addNotice('DEBUG'.$this->_helper->getDebug());
143
}
144
}
145
146
protected function _getConfig()
147
{
148
if (!isset($this->_config)) {
149
- $this->_helper = new OwebiaShippingHelper(
150
- $this->__getConfigData('config'),
151
- (boolean)$this->__getConfigData('auto_correction')
152
- );
153
- $this->_config = $this->_helper->getConfig();
154
}
155
return $this->_config;
156
}
157
158
- /***************************************************************************************************************************/
159
160
- protected function __checkRequest($http_request, $path)
161
{
162
list($router, $controller, $action) = explode('/', $path);
163
- return $http_request->getRouteName()==$router && $http_request->getControllerName()==$controller && $http_request->getActionName()==$action;
164
}
165
166
protected function __getProcess($request)
167
{
168
- $mage_config = Mage::getConfig();
169
- $os2_config = $this->_getConfig();
170
- $data = Mage::helper('owebia_shipping2')->getDataModelMap($this->_helper, $this->_code, $request);
171
$process = array(
172
'data' => $data,
173
'cart.items' => array(),
174
- 'config' => $os2_config,
175
'result' => Mage::getModel('shipping/rate_result'),
176
'options' => (object)array(
177
'auto_escaping' => (boolean)$this->__getConfigData('auto_escaping'),
@@ -184,7 +159,7 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
184
185
public function addDataModel($name, $model)
186
{
187
- $this->_data_models[$name] = $model;
188
}
189
190
protected function __getConfigData($key)
@@ -199,11 +174,10 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
199
->setCarrier($this->_code)
200
->setCarrierTitle($this->__getConfigData('title'))
201
->setMethod($row['*id'])
202
- ->setMethodTitle($helper->getMethodText($this->_helper, $process, $row, 'label'))
203
- ->setMethodDescription($helper->getMethodText($this->_helper, $process, $row, 'description'))
204
->setPrice($fees)
205
- ->setCost($fees)
206
- ;
207
208
$process['result']->append($method);
209
}
@@ -214,4 +188,3 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
214
return Mage::helper('owebia_shipping2')->__($args);
215
}
216
}
217
-
1
<?php
2
/**
3
+ * Copyright © 2008-2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract
8
{
9
protected $_config;
10
+ protected $_parser;
11
+ protected $_dataModels = array();
12
13
/**
14
* Collect rates for this shipping method based on information in $request
18
*/
19
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
20
{
21
if (!$this->__getConfigData('active')) return false; // skip if not enabled
22
$process = $this->__getProcess($request);
23
return $this->getRates($process);
24
}
25
26
public function getRates($process)
27
{
33
{
34
$process = array();
35
$config = $this->_getConfig();
36
+ $allowedMethods = array();
37
if (count($config)>0) {
38
+ foreach ($config as $row) {
39
+ $allowedMethods[$row['*id']] = isset($row['label']) ? $row['label']['value'] : 'No label';
40
+ }
41
}
42
+ return $allowedMethods;
43
}
44
45
public function isTrackingAvailable()
47
return true;
48
}
49
50
+ public function getTrackingInfo($trackingNumber)
51
{
52
+ $originalTrackingNumber = $trackingNumber;
53
+ $globalTrackingUrl = $this->__getConfigData('tracking_view_url');
54
+ $trackingUrl = $globalTrackingUrl;
55
+ $parts = explode(':', $trackingNumber);
56
+ if (count($parts) >= 2) {
57
+ $trackingNumber = $parts[1];
58
59
$process = array();
60
$config = $this->_getConfig();
61
+
62
if (isset($config[$parts[0]]['tracking_url'])) {
63
$row = $config[$parts[0]];
64
+ $tmpTrackingUrl = $this->getParser()->getRowProperty($row, 'tracking_url');
65
+ if (isset($tmpTrackingUrl)) $trackingUrl = $tmpTrackingUrl;
66
}
67
}
68
69
+ $trackingStatus = Mage::getModel('shipping/tracking_result_status')
70
->setCarrier($this->_code)
71
->setCarrierTitle($this->__getConfigData('title'))
72
+ ->setTracking($trackingNumber)
73
->addData(
74
array(
75
+ 'status'=> $trackingUrl
76
+ ? '<a target="_blank" href="' . str_replace('{tracking_number}', $trackingNumber, $trackingUrl)
77
+ . '">' . $this->__('track the package') . '</a>'
78
+ : "suivi non disponible pour le colis {$trackingNumber}"
79
+ . " (originalTrackingNumber='{$originalTrackingNumber}',"
80
+ . " globalTrackingUrl='{$globalTrackingUrl}'"
81
+ . (isset($row) ? ", tmpTrackingUrl='{$tmpTrackingUrl}'" : '')
82
+ . ")"
83
)
84
+ );
85
+ $trackingResult = Mage::getModel('shipping/tracking_result')
86
+ ->append($trackingStatus);
87
88
+ if ($trackings = $trackingResult->getAllTrackings()) return $trackings[0];
89
return false;
90
}
91
92
protected function _process(&$process)
93
{
94
+ $debug = (bool)$this->__getConfigData('debug');
95
+ if ($debug) $this->getParser()->initDebug($this->_code, $process);
96
97
+ $valueFound = false;
98
foreach ($process['config'] as $row) {
99
+ $result = $this->getParser()->processRow($process, $row);
100
if ($result->success) {
101
+ $valueFound = true;
102
$this->__appendMethod($process, $row, $result->result);
103
if ($process['options']->stop_to_first_match) break;
104
}
105
}
106
+
107
+ $httpRequest = Mage::app()->getFrontController()->getRequest();
108
+ if ($debug && $this->__checkRequest($httpRequest, 'checkout/cart/index')) {
109
Mage::getSingleton('core/session')
110
+ ->addNotice('DEBUG' . $this->getParser()->getDebug());
111
}
112
}
113
114
protected function _getConfig()
115
{
116
if (!isset($this->_config)) {
117
+ $this->_config = $this->getParser()
118
+ ->getConfig();
119
}
120
return $this->_config;
121
}
122
123
+ protected function getParser()
124
+ {
125
+ if (!isset($this->_parser)) {
126
+ $this->_parser = Mage::getModel('owebia_shipping2/ConfigParser')
127
+ ->init(
128
+ $this->__getConfigData('config'),
129
+ (boolean)$this->__getConfigData('auto_correction')
130
+ );
131
+ }
132
+ return $this->_parser;
133
+ }
134
135
+ protected function __checkRequest($httpRequest, $path)
136
{
137
list($router, $controller, $action) = explode('/', $path);
138
+ return $httpRequest->getRouteName() == $router
139
+ && $httpRequest->getControllerName() == $controller
140
+ && $httpRequest->getActionName() == $action;
141
}
142
143
protected function __getProcess($request)
144
{
145
+ $data = Mage::helper('owebia_shipping2')->getDataModelMap($this->getParser(), $this->_code, $request);
146
$process = array(
147
'data' => $data,
148
'cart.items' => array(),
149
+ 'config' => $this->_getConfig(),
150
'result' => Mage::getModel('shipping/rate_result'),
151
'options' => (object)array(
152
'auto_escaping' => (boolean)$this->__getConfigData('auto_escaping'),
159
160
public function addDataModel($name, $model)
161
{
162
+ $this->_dataModels[$name] = $model;
163
}
164
165
protected function __getConfigData($key)
174
->setCarrier($this->_code)
175
->setCarrierTitle($this->__getConfigData('title'))
176
->setMethod($row['*id'])
177
+ ->setMethodTitle($helper->getMethodText($this->getParser(), $process, $row, 'label'))
178
+ ->setMethodDescription($helper->getMethodText($this->getParser(), $process, $row, 'description'))
179
->setPrice($fees)
180
+ ->setCost($fees);
181
182
$process['result']->append($method);
183
}
188
return Mage::helper('owebia_shipping2')->__($args);
189
}
190
}
app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping1.php CHANGED
@@ -1,23 +1,8 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
23
{
1
<?php
2
/**
3
+ * Copyright © 2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
8
{
app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping2.php CHANGED
@@ -1,23 +1,8 @@
1
<?php
2
-
3
/**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
22
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
23
{
1
<?php
2
/**
3
+ * Copyright © 2016 Owebia. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
7
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
8
{
app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping3.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Copyright (c) 2008-14 Owebia
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
- * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14
- * IN THE SOFTWARE.
15
- *
16
- * @website http://www.owebia.com/
17
- * @project Magento Owebia Shipping 2 module
18
- * @author Antoine Lemoine
19
- * @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
20
- **/
21
-
22
- class Owebia_Shipping2_Model_Carrier_OwebiaShipping3 extends Owebia_Shipping2_Model_Carrier_Abstract
23
- {
24
- protected $_code = 'owebiashipping3';
25
- }
app/code/community/Owebia/Shipping2/Model/ConfigParser.php ADDED
@@ -0,0 +1,1940 @@