Version Notes
[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'))",
Release Info
Developer | owebia |
Extension | Owebia_Shipping_2 |
Version | 2.5.22 |
Comparing to | |
See all releases |
Code changes from version 2.5.19 to 2.5.22
- README.md +36 -0
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor.php +245 -234
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor/Property/Input.php +4 -3
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Help.php +83 -83
- app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Config.php +61 -57
- app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Informations.php +10 -10
- app/code/community/Owebia/Shipping2/Controller/Abstract.php +96 -97
- app/code/community/Owebia/Shipping2/Helper/Data.php +134 -134
- app/code/community/Owebia/Shipping2/Model/Carrier/Abstract.php +187 -187
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping1.php +1 -1
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping2.php +1 -1
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping3.php +1 -1
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping4.php +0 -25
- app/code/community/Owebia/Shipping2/Model/Mysql4/Setup.php +1 -1
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Abstract.php +51 -47
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AbstractWithAttributes.php +40 -40
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Address.php +9 -10
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AddressFilter.php +83 -83
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AttributeSet.php +13 -11
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Billto.php +6 -13
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Cart.php +115 -115
- app/code/community/Owebia/Shipping2/Model/Os2/Data/CartItem.php +124 -119
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Category.php +8 -8
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Customer.php +15 -15
- app/code/community/Owebia/Shipping2/Model/Os2/Data/CustomerGroup.php +50 -50
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Customvar.php +10 -10
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Date.php +24 -23
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Info.php +0 -2
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Product.php +93 -86
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Quote.php +6 -6
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Selection.php +4 -5
- app/code/community/Owebia/Shipping2/Model/Os2/Data/StockItem.php +14 -14
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Store.php +25 -25
- app/code/community/Owebia/Shipping2/Model/System/Config/Source/LoadOnParent.php +14 -13
- app/code/community/Owebia/Shipping2/Model/System/Config/Source/ProcessChildren.php +14 -13
- app/code/community/Owebia/Shipping2/changelog +24 -13
- app/code/community/Owebia/Shipping2/controllers/Adminhtml/Os2/AjaxController.php +169 -169
- app/code/community/Owebia/Shipping2/controllers/Checkout/CartController.php +5 -5
- app/code/community/Owebia/Shipping2/doc_en_US.html +1094 -1072
- app/code/community/Owebia/Shipping2/doc_fr_FR.html +1106 -1084
- app/code/community/Owebia/Shipping2/etc/adminhtml.xml +29 -29
- app/code/community/Owebia/Shipping2/etc/config.xml +168 -183
- app/code/community/Owebia/Shipping2/etc/system.xml +461 -570
- app/code/community/Owebia/Shipping2/includes/OS2_AddressFilterParser.php +122 -122
- app/code/community/Owebia/Shipping2/includes/OwebiaShippingHelper.php +1425 -1429
- app/code/community/Owebia/Shipping2/sql/owebia_shipping2_setup/mysql4-install-2.5.13.php +0 -1
- app/etc/modules/Owebia_Shipping2.xml +7 -7
- app/locale/en_US/Owebia_Shipping2.csv +454 -454
- app/locale/fr_FR/Owebia_Shipping2.csv +467 -467
- package.xml +16 -5
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# ENGLISH
|
3 |
+
|
4 |
+
## How to manually install the extension?
|
5 |
+
|
6 |
+
- Backup your store database and web directory
|
7 |
+
- Login to Magento backend
|
8 |
+
- Go to System > Tools > Compilations, if Compiler Status is Enabled, disable the compilation
|
9 |
+
- Uncompress the archive file, then copy the directory "app" in your Magento root directory
|
10 |
+
- Go to System > Cache Management. Click button Flush Magento Cache
|
11 |
+
- Logout from Magento backend and login again
|
12 |
+
|
13 |
+
## How to completely uninstall the extension ?
|
14 |
+
After having uninstalled the extension in Magento Connect Manager, some references remain in the database.
|
15 |
+
To solve this problem, you must execute the following MySQL query:
|
16 |
+
|
17 |
+
DELETE FROM `core_config_data` WHERE `path` LIKE 'carriers/owebiashipping_/%'
|
18 |
+
|
19 |
+
--------------------------
|
20 |
+
|
21 |
+
# FRANCAIS
|
22 |
+
|
23 |
+
## Comment installer l'extension manuellement ?
|
24 |
+
|
25 |
+
- Faites une sauvegarde de votre boutique et de votre répertoire web
|
26 |
+
- Connectez-vous au panneau d'administration de Magento
|
27 |
+
- Allez dans Système > Outils > Compilation, désactiver le compilateur s'il est activé
|
28 |
+
- Décompresser l'archive, puis copier le répertoire "app" dans le répertoire racine de votre boutique Magento
|
29 |
+
- Allez dans Système > Gestion du cache. Cliquer sur le bouton Vider le cache de Magento
|
30 |
+
- Déconnectez-vous du panneau d'administration de Magento puis connectez-vous à nouveau
|
31 |
+
|
32 |
+
## Comment désinstaller complètement l’extension ?
|
33 |
+
Après avoir désinstallé l’extension depuis Magento Connect Manager, il reste encore des références dans la base de donnée.
|
34 |
+
Pour solutionner ce problème, il faut exécuter la requête MySQL suivante :
|
35 |
+
|
36 |
+
DELETE FROM `core_config_data` WHERE `path` LIKE 'carriers/owebiashipping_/%'
|
@@ -21,250 +21,261 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
239 |
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
247 |
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
270 |
}
|
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 |
+
{
|
29 |
+
$attributes = $attributes + array(
|
30 |
+
'config' => '',
|
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 __()
|
38 |
+
{
|
39 |
+
$args = func_get_args();
|
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)
|
162 |
+
{
|
163 |
+
$properties = array('*id', 'type', 'about', 'enabled');
|
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',
|
184 |
+
'enabled' => 'Enabled',
|
185 |
+
'label' => 'Label',
|
186 |
+
'description' => 'Description',
|
187 |
+
'shipto' => 'Shipping address',
|
188 |
+
'billto' => 'Billing address',
|
189 |
+
'origin' => 'Origin address',
|
190 |
+
'conditions' => 'Conditions',
|
191 |
+
'fees' => 'Fees',
|
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 |
+
}
|
218 |
|
219 |
+
protected function _getRowItem($row, $opened)
|
220 |
+
{
|
221 |
+
$type = isset($row['type']['value']) ? $row['type']['value'] : null;
|
222 |
+
switch ($type) {
|
223 |
+
case 'meta':
|
224 |
+
$label = $this->__('[meta] %s', $row['*id']);
|
225 |
+
break;
|
226 |
+
case 'data':
|
227 |
+
$label = $this->__('[data] %s', $row['*id']);
|
228 |
+
break;
|
229 |
+
default:
|
230 |
+
$label = isset($row['label']['value']) ? $row['label']['value'] : $this->__('New shipping method');
|
231 |
+
break;
|
232 |
+
}
|
233 |
+
$content = '';
|
234 |
+
if ($opened) {
|
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)
|
248 |
+
{
|
249 |
+
return htmlspecialchars($input, ENT_COMPAT, 'UTF-8');
|
250 |
+
}
|
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)
|
258 |
+
{
|
259 |
+
return $this->_getRowUI($row);
|
260 |
+
}
|
261 |
|
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 |
+
}
|
277 |
+
$output .= "</ul>";
|
278 |
+
}
|
279 |
+
return $output;
|
280 |
+
}
|
281 |
}
|
@@ -21,7 +21,8 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor_Property_Input extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
}
|
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 |
}
|
@@ -21,97 +21,97 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
jQuery.fn.scrollspy = function(){};
|
52 |
{$doc_scripts}
|
53 |
function bjson() {
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
}
|
67 |
setTimeout(function(){
|
68 |
-
|
69 |
}, 1000);
|
70 |
</script>"
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
}
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
24 |
+
public function __()
|
25 |
+
{
|
26 |
+
$args = func_get_args();
|
27 |
+
return Mage::helper('owebia_shipping2')->__($args);
|
28 |
+
}
|
29 |
|
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(){
|
56 |
+
var text = jQuery(this).text();
|
57 |
+
while (text.match(/\"__auto__\"/)) {
|
58 |
+
text = text.replace(/\"__auto__\"/, '\"id_' + ('000' + index).slice(-3) + '\"');
|
59 |
+
index++;
|
60 |
+
}
|
61 |
+
var obj = jQuery.parseJSON(text);
|
62 |
+
var beautified = jsonEncode(obj, true, true);
|
63 |
+
jQuery(this).html('<pre>' + beautified + '</pre>');
|
64 |
+
jQuery(this).addClass('code');
|
65 |
+
});
|
66 |
}
|
67 |
setTimeout(function(){
|
68 |
+
bjson();
|
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(' ', "<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 |
}
|
@@ -21,72 +21,76 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config extends Mage_Adminhtml_Block_System_Config_Form_Field
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
"
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
{$output}
|
83 |
<div style="margin-bottom:1px;">
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
</div>
|
88 |
{$element->getElementHtml()}<br/>
|
89 |
<a href="http://www.owebia.com/contributions/magento/owebia-shipping/fr/modeles-de-configuration" target="_blank">{$this->__('Download configuration templates')}</a>
|
90 |
EOD;
|
91 |
-
|
92 |
}
|
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();
|
29 |
+
return Mage::helper('owebia_shipping2')->__($args);
|
30 |
+
}
|
31 |
|
32 |
+
protected function _prepareLayout()
|
33 |
+
{
|
34 |
+
$layout = $this->getLayout();
|
35 |
+
$head = $layout->getBlock('head');
|
36 |
+
$head->addJs('owebia/shipping2/jquery-1.8.2.min.js');
|
37 |
+
$head->addJs('owebia/shipping2/jquery.noconflict.js');
|
38 |
+
$head->addJs('owebia/shipping2/jquery-ui-1.8.23.custom/js/jquery-ui-1.8.23.custom.min.js');
|
39 |
+
$head->addJs('owebia/shipping2/jquery.layout-1.3.0-rc30.6.min.js');
|
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 & 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 |
}
|
@@ -21,15 +21,15 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations extends Mage_Adminhtml_Block_System_Config_Form_Field
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
}
|
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 |
+
{
|
26 |
+
$args = func_get_args();
|
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');
|
33 |
+
return $this->__('Version: %s', $version);
|
34 |
+
}
|
35 |
}
|
@@ -21,110 +21,109 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Action
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
if (headers_sent()) {
|
62 |
-
trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
|
63 |
-
return false;
|
64 |
-
}
|
65 |
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
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 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
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 |
-
}
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
."<td class=buttons>{$buttons}</td>"
|
114 |
-
."</tr></table>"
|
115 |
-
."</div></div>"
|
116 |
-
;
|
117 |
-
}
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
public function button__($label, $onclick, $class_name='')
|
126 |
-
{
|
127 |
-
return $this->button($this->__($label),$onclick,$class_name);
|
128 |
-
}
|
129 |
}
|
130 |
-
|
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',
|
45 |
+
'.pdf' => 'application/pdf',
|
46 |
+
'.png' => 'image/png',
|
47 |
+
'.gif' => 'image/gif',
|
48 |
+
'.jpg' => 'image/jpeg',
|
49 |
+
'.jpeg' => 'image/jpeg',
|
50 |
+
'.txt' => 'text/plain',
|
51 |
+
'.htm' => 'text/html',
|
52 |
+
'.html' => 'text/html',
|
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 & 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 |
+
}
|
107 |
|
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 |
}
|
|
@@ -21,145 +21,145 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
|
23 |
{
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
}
|
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 |
+
}
|
77 |
+
return $result;
|
78 |
+
}
|
79 |
|
80 |
+
public function getMethodText($helper, $process, $row, $property)
|
81 |
+
{
|
82 |
+
if (!isset($row[$property])) return '';
|
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'),
|
133 |
+
'customer_group' => Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup'),
|
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()),
|
154 |
+
);
|
155 |
+
}
|
156 |
|
157 |
+
protected function _extract($data, $attributes)
|
158 |
+
{
|
159 |
+
$extract = array();
|
160 |
+
foreach ($attributes as $to => $from) {
|
161 |
+
$extract[$to] = isset($data[$from]) ? $data[$from] : null;
|
162 |
+
}
|
163 |
+
return $extract;
|
164 |
+
}
|
165 |
}
|
@@ -21,197 +21,197 @@
|
|
21 |
|
22 |
// if compilation
|
23 |
if (file_exists(dirname(__FILE__).'/Owebia_Shipping2_includes_OwebiaShippingHelper.php')) {
|
24 |
-
|
25 |
-
|
26 |
} else {
|
27 |
-
|
28 |
-
|
29 |
}
|
30 |
|
31 |
abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract
|
32 |
{
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
}
|
217 |
|
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
|
39 |
+
*
|
40 |
+
* @param Mage_Shipping_Model_Rate_Request $data
|
41 |
+
* @return Mage_Shipping_Model_Rate_Result
|
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 |
+
{
|
65 |
+
$this->_process($process);
|
66 |
+
return $process['result'];
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getAllowedMethods()
|
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()
|
81 |
+
{
|
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'),
|
178 |
+
'auto_correction' => (boolean)$this->__getConfigData('auto_correction'),
|
179 |
+
'stop_to_first_match' => (boolean)$this->__getConfigData('stop_to_first_match'),
|
180 |
+
),
|
181 |
+
);
|
182 |
+
return $process;
|
183 |
+
}
|
184 |
+
|
185 |
+
public function addDataModel($name, $model)
|
186 |
+
{
|
187 |
+
$this->_data_models[$name] = $model;
|
188 |
+
}
|
189 |
+
|
190 |
+
protected function __getConfigData($key)
|
191 |
+
{
|
192 |
+
return $this->getConfigData($key);
|
193 |
+
}
|
194 |
+
|
195 |
+
protected function __appendMethod(&$process, $row, $fees)
|
196 |
+
{
|
197 |
+
$helper = Mage::helper('owebia_shipping2');
|
198 |
+
$method = Mage::getModel('shipping/rate_result_method')
|
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 |
+
}
|
210 |
+
|
211 |
+
protected function __()
|
212 |
+
{
|
213 |
+
$args = func_get_args();
|
214 |
+
return Mage::helper('owebia_shipping2')->__($args);
|
215 |
+
}
|
216 |
}
|
217 |
|
@@ -21,5 +21,5 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
-
|
25 |
}
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
+
protected $_code = 'owebiashipping1';
|
25 |
}
|
@@ -21,5 +21,5 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
-
|
25 |
}
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
+
protected $_code = 'owebiashipping2';
|
25 |
}
|
@@ -21,5 +21,5 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping3 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
-
|
25 |
}
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping3 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
24 |
+
protected $_code = 'owebiashipping3';
|
25 |
}
|
@@ -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_OwebiaShipping4 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
-
{
|
24 |
-
protected $_code = 'owebiashipping4';
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -21,4 +21,4 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
|
23 |
{
|
24 |
-
}
|
21 |
|
22 |
class Owebia_Shipping2_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
|
23 |
{
|
24 |
+
}
|
@@ -21,57 +21,61 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
}
|
76 |
-
|
77 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected $additional_attributes = array();
|
25 |
+
protected $_attributes;
|
26 |
+
protected $_loaded_object = false;
|
27 |
+
protected $_data;
|
28 |
|
29 |
+
public function __construct($arguments = null)
|
30 |
+
{
|
31 |
+
$this->_data = (array)$arguments;
|
32 |
+
//echo '<pre>Owebia_Shipping2_Model_Os2_Data_Abstract::__construct<br/>';foreach ($this->_data as $n => $v){echo "\t$n => ".(is_object($v) ? get_class($v) : (is_array($v) ? 'array' : $v))."<br/>";}
|
33 |
+
}
|
34 |
|
35 |
+
protected function _loadObject()
|
36 |
+
{
|
37 |
+
return null;
|
38 |
+
}
|
39 |
|
40 |
+
protected function _getObject()
|
41 |
+
{
|
42 |
+
if ($this->_loaded_object===false) $this->_loaded_object = $this->_loadObject();
|
43 |
+
//foreach ($this->_loaded_object->getData() as $index => $value) echo "$index = $value<br/>";
|
44 |
+
return $this->_loaded_object;
|
45 |
+
}
|
46 |
|
47 |
+
protected function _load($name)
|
48 |
+
{
|
49 |
+
$object = $this->_getObject();
|
50 |
+
if (!$object) return null;
|
51 |
+
/*echo get_class($this).'.getData('.$name.')'.$object->getData($name).'<br/>';
|
52 |
+
foreach ($object->getData() as $index => $value) echo "$index = $value<br/>";*/
|
53 |
+
return $object->getData($name);
|
54 |
+
}
|
55 |
|
56 |
+
public function __sleep()
|
57 |
+
{
|
58 |
+
if (isset($this->_attributes)) return $this->_attributes;
|
59 |
+
$this->_attributes = array_unique(array_merge(array_keys($this->_data), $this->additional_attributes));
|
60 |
+
/*usort($this->_attributes, function($v1, $v2){
|
61 |
+
if ($v1=='id') return -1;
|
62 |
+
if ($v2=='id') return 1;
|
63 |
+
if ($v2=='*') return -1;
|
64 |
+
if ($v1=='*') return 1;
|
65 |
+
return $v1==$v2 ? 0 : ($v1<$v2 ? -1 : 1);
|
66 |
+
});*/
|
67 |
+
return $this->_attributes;
|
68 |
+
}
|
69 |
|
70 |
+
public function __get($name)
|
71 |
+
{
|
72 |
+
/*$name2 = str_replace('.', '_', $name);
|
73 |
+
if (isset($this->_data[$name2])) return $this->_data[$name2];*/
|
74 |
+
//if (isset($this->_data[$name])) return $this->_data[$name]; // pb if id is null
|
75 |
+
if (!is_array($this->_data)) $this->_data = array();
|
76 |
+
if (array_key_exists($name, $this->_data)) return $this->_data[$name];
|
77 |
+
//if (in_array($name, $this->additional_attributes)) $this->_data[$name] = $this->_load($name);
|
78 |
+
$this->_data[$name] = $this->_load($name);
|
79 |
+
return $this->_data[$name];
|
80 |
+
}
|
81 |
}
|
|
|
|
@@ -21,47 +21,47 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
}
|
66 |
-
|
67 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected function _load($name)
|
25 |
+
{
|
26 |
+
$elems = explode('.', $name, $limit=2);
|
27 |
+
$count = count($elems);
|
28 |
+
$last_index = $count-1;
|
29 |
+
if ($count==2) {
|
30 |
+
switch ($elems[0]) {
|
31 |
+
case 'a':
|
32 |
+
case 'attribute':
|
33 |
+
$name = $elems[1];
|
34 |
+
return $this->_getAttribute($name);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
//return parent::_load($name);
|
38 |
+
return $this->_getAttribute($name);
|
39 |
+
}
|
40 |
|
41 |
+
protected function _getAttribute($attribute_name)
|
42 |
+
{
|
43 |
+
$get_value = false;
|
44 |
+
if (substr($attribute_name, strlen($attribute_name)-6, 6)=='.value') {
|
45 |
+
$get_value = true;
|
46 |
+
$attribute_name = substr($attribute_name, 0, strlen($attribute_name)-6);
|
47 |
+
}
|
48 |
|
49 |
+
$object = $this->_getObject();
|
50 |
+
if (!$object) return null;
|
51 |
+
$attribute = $object->getResource()->getAttribute($attribute_name);
|
52 |
+
if (!$attribute) return null;
|
53 |
|
54 |
+
$attribute_frontend = $attribute->getFrontend();
|
55 |
+
$input_type = $attribute_frontend->getInputType();
|
56 |
+
switch ($input_type) {
|
57 |
+
case 'select' :
|
58 |
+
//echo 'attribute_name:'.$object->getData($attribute_name).', '.$attribute_frontend->getValue($object).';<br/>';
|
59 |
+
$value = !$get_value ? $object->getData($attribute_name) : $attribute_frontend->getValue($object);
|
60 |
+
break;
|
61 |
+
default :
|
62 |
+
$value = $object->getData($attribute_name);
|
63 |
+
break;
|
64 |
+
}
|
65 |
+
return $value;
|
66 |
+
}
|
67 |
}
|
|
|
|
@@ -21,15 +21,14 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Address extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
}
|
34 |
-
|
35 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Address extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected $additional_attributes = array('country_id', 'country_name', 'postcode');
|
25 |
|
26 |
+
protected function _load($name)
|
27 |
+
{
|
28 |
+
switch ($name) {
|
29 |
+
case 'country_name':
|
30 |
+
return Mage::getModel('directory/country')->load($this->country_id)->getName();
|
31 |
+
}
|
32 |
+
return parent::_load($name);
|
33 |
+
}
|
34 |
}
|
|
|
|
@@ -21,90 +21,90 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
108 |
}
|
109 |
-
|
110 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected static $_countries = null;
|
25 |
|
26 |
+
// source : geonames.org, 2012-09-26
|
27 |
+
protected static $_shortcuts = array(
|
28 |
+
// continents
|
29 |
+
'AF' => array(
|
30 |
+
'label' => 'Africa',
|
31 |
+
'replace' => 'AO,BF,BI,BJ,BW,CD,CF,CG,CI,CM,CV,DJ,DZ,EG,EH,ER,ET,GA,GH,GM,GN,GQ,GW,KE,KM,LR,LS,LY,MA,MG,ML,MR,MU,MW,MZ,NA,NE,NG,RE,RW,SC,SD,SS,SH,SL,SN,SO,ST,SZ,TD,TG,TN,TZ,UG,YT,ZA,ZM,ZW',
|
32 |
+
),
|
33 |
+
'AS' => array(
|
34 |
+
'label' => 'Asia',
|
35 |
+
'replace' => 'AE,AF,AM,AZ,BD,BH,BN,BT,CC,CN,CX,GE,HK,ID,IL,IN,IO,IQ,IR,JO,JP,KG,KH,KP,KR,KW,KZ,LA,LB,LK,MM,MN,MO,MV,MY,NP,OM,PH,PK,PS,QA,SA,SG,SY,TH,TJ,TM,TR,TW,UZ,VN,YE',
|
36 |
+
),
|
37 |
+
'EU' => array(
|
38 |
+
'label' => 'Europa',
|
39 |
+
'replace' => 'AD,AL,AT,AX,BA,BE,BG,BY,CH,CY,CZ,DE,DK,EE,ES,FI,FO,FR,GB,GG,GI,GR,HR,HU,IE,IM,IS,IT,JE,XK,LI,LT,LU,LV,MC,MD,ME,MK,MT,NL,NO,PL,PT,RO,RS,RU,SE,SI,SJ,SK,SM,UA,VA,CS',
|
40 |
+
),
|
41 |
+
'NA' => array(
|
42 |
+
'label' => 'North America',
|
43 |
+
'replace' => 'AG,AI,AW,BB,BL,BM,BQ,BS,BZ,CA,CR,CU,CW,DM,DO,GD,GL,GP,GT,HN,HT,JM,KN,KY,LC,MF,MQ,MS,MX,NI,PA,PM,PR,SV,SX,TC,TT,US,VC,VG,VI,AN',
|
44 |
+
),
|
45 |
+
'SA' => array(
|
46 |
+
'label' => 'South America',
|
47 |
+
'replace' => 'AR,BO,BR,CL,CO,EC,FK,GF,GY,PE,PY,SR,UY,VE',
|
48 |
+
),
|
49 |
+
'OC' => array(
|
50 |
+
'label' => 'Oceania',
|
51 |
+
'replace' => 'AS,AU,CK,FJ,FM,GU,KI,MH,MP,NC,NF,NR,NU,NZ,PF,PG,PN,PW,SB,TK,TL,TO,TV,UM,VU,WF,WS',
|
52 |
+
),
|
53 |
+
'AN' => array(
|
54 |
+
'label' => 'Antartica',
|
55 |
+
'replace' => 'AQ,BV,GS,HM,TF',
|
56 |
+
),
|
57 |
+
/*UK=>GB*/
|
58 |
+
'EU-27' => array(
|
59 |
+
'label' => 'European Union',
|
60 |
+
'replace' => 'AT,BE,BG,CY,CZ,DE,DK,EE,EL,ES,FI,FR,HU,IE,IT,LT,LU,LV,MT,NL,PL,PT,RO,SI,SK,SE,GB',
|
61 |
+
),
|
62 |
+
/* Guadeloupe, Martinique, Guyane, Réunion, Mayotte */
|
63 |
+
'DOM' => array(
|
64 |
+
'label' => "Département d'Outre-Mer",
|
65 |
+
'replace' => 'GP,MQ,GF,RE,YT',
|
66 |
+
),
|
67 |
+
/* Polynésie française, Saint-Pierre-et-Miquelon, Wallis-et-Futuna, Saint-Martin, Saint-Barthélemy */
|
68 |
+
'COM' => array(
|
69 |
+
'label' => "Collectivités d'Outre-Mer",
|
70 |
+
'replace' => 'PF,PM,WF,MF,BL',
|
71 |
+
),
|
72 |
+
);
|
73 |
|
74 |
+
public static function readable($input)
|
75 |
+
{
|
76 |
+
if (!self::$_countries) {
|
77 |
+
$collection = Mage::getModel('directory/country')->getCollection();
|
78 |
+
$countries = array();
|
79 |
+
foreach ($collection as $country) {
|
80 |
+
$countries[$country->getId()] = $country->getName();
|
81 |
+
}
|
82 |
+
self::$_countries = $countries;
|
83 |
+
}
|
84 |
+
|
85 |
+
$elems = preg_split('/\b/', $input);
|
86 |
+
$output = '';
|
87 |
+
foreach ($elems as $elem) {
|
88 |
+
if (isset(self::$_countries[$elem])) {
|
89 |
+
$output .= self::$_countries[$elem];
|
90 |
+
} else {
|
91 |
+
$output .= $elem;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
while (preg_match('/{address_filter\.([^}]+)}/', $output, $result)) {
|
95 |
+
$name = $result[1];
|
96 |
+
$replacement = isset(self::$_shortcuts[$name]) ? self::$_shortcuts[$name]['label'] : 'unknown';
|
97 |
+
$replacement = Mage::helper('owebia_shipping2')->__($replacement);
|
98 |
+
$output = str_replace($result[0], $replacement, $output);
|
99 |
+
}
|
100 |
+
return $output;
|
101 |
+
}
|
102 |
|
103 |
+
protected function _load($name)
|
104 |
+
{
|
105 |
+
if (isset(self::$_shortcuts[$name])) {
|
106 |
+
return self::$_shortcuts[$name]['replace'];
|
107 |
+
}
|
108 |
+
return parent::_load($name);
|
109 |
+
}
|
110 |
}
|
|
|
|
@@ -21,16 +21,18 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AttributeSet extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
34 |
}
|
35 |
-
|
36 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AttributeSet extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected function _loadObject()
|
25 |
+
{
|
26 |
+
return Mage::getModel('eav/entity_attribute_set')->load($this->id);
|
27 |
+
}
|
28 |
|
29 |
+
protected function _load($name)
|
30 |
+
{
|
31 |
+
switch ($name) {
|
32 |
+
case 'name':
|
33 |
+
return $this->{'attribute_set_name'};
|
34 |
+
default:
|
35 |
+
return parent::_load($name);
|
36 |
+
}
|
37 |
+
}
|
38 |
}
|
|
|
|
@@ -21,17 +21,10 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Billto extends Owebia_Shipping2_Model_Os2_Data_Address
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
protected function _loadObject() {
|
31 |
-
$quote = Mage::getModel('checkout/cart')->getQuote();
|
32 |
-
$address = $quote->getBillingAddress();
|
33 |
-
return $address;
|
34 |
-
}
|
35 |
}
|
36 |
-
|
37 |
-
?>
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Billto extends Owebia_Shipping2_Model_Os2_Data_Address
|
23 |
{
|
24 |
+
protected function _loadObject()
|
25 |
+
{
|
26 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
27 |
+
$address = $quote->getBillingAddress();
|
28 |
+
return $address;
|
29 |
+
}
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
|
|
|
@@ -21,132 +21,132 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
|
101 |
protected function _getQuote()
|
102 |
{
|
103 |
return Mage::getModel('owebia_shipping2/Os2_Data_Quote');
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
}
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
+
protected $additional_attributes = array('coupon_code', 'weight_unit', 'weight_for_charge', 'free_shipping');
|
25 |
+
protected $_free_shipping;
|
26 |
+
protected $_items;
|
27 |
+
protected $_quote;
|
28 |
+
protected $_options;
|
29 |
|
30 |
+
public function __construct($arguments)
|
31 |
+
{
|
32 |
+
parent::__construct();
|
33 |
+
$request = $arguments['request'];
|
34 |
+
$this->_options = $arguments['options'];
|
35 |
|
36 |
+
$this->_data = array(
|
37 |
+
// Do not use quote to retrieve values, totals are not available
|
38 |
+
'price-tax+discount' => null,//(double)$request->getData('package_value_with_discount'), // Bad value in backoffice orders
|
39 |
+
'price-tax-discount' => null,//(double)$request->getData('package_value'),
|
40 |
+
'price+tax+discount' => null,
|
41 |
+
'price+tax-discount' => null,
|
42 |
+
'weight' => $request->getData('package_weight'),
|
43 |
+
'qty' => $request->getData('package_qty'),
|
44 |
+
'free_shipping' => $request->getData('free_shipping'),
|
45 |
+
);
|
46 |
|
47 |
+
$cart_items = array();
|
48 |
+
$items = $request->getAllItems();
|
49 |
+
$quote_total_collected = false;
|
50 |
+
$bundle_process_children = isset($this->_options['bundle']['process_children']) && $this->_options['bundle']['process_children'];
|
51 |
+
foreach ($items as $item) {
|
52 |
+
$product = $item->getProduct();
|
53 |
+
if ($product instanceof Mage_Catalog_Model_Product) {
|
54 |
+
$key = null;
|
55 |
+
if ($item instanceof Mage_Sales_Model_Quote_Address_Item) { // Multishipping
|
56 |
+
$key = $item->getQuoteItemId();
|
57 |
+
} else if ($item instanceof Mage_Sales_Model_Quote_Item) { // Onepage checkout
|
58 |
+
$key = $item->getId();
|
59 |
+
}
|
60 |
+
$cart_items[$key] = $item;
|
61 |
+
}
|
62 |
+
}
|
63 |
|
64 |
+
// Do not use quote to retrieve values, totals are not available
|
65 |
+
$total_incl_tax_without_discount = 0;
|
66 |
+
$total_excl_tax_without_discount = 0;
|
67 |
+
$total_incl_tax_with_discount = 0;
|
68 |
+
$total_excl_tax_with_discount = 0;
|
69 |
+
$this->_items = array();
|
70 |
+
foreach ($cart_items as $item) {
|
71 |
+
$type = $item->getProduct()->getTypeId();
|
72 |
+
//echo $item->getProduct()->getTypeId().', '.$item->getQty().'<br/>';
|
73 |
+
$parent_item_id = $item->getData('parent_item_id');
|
74 |
+
$parent_item = isset($cart_items[$parent_item_id]) ? $cart_items[$parent_item_id] : null;
|
75 |
+
$parent_type = isset($parent_item) ? $parent_item->getProduct()->getTypeId() : null;
|
76 |
+
if ($type!='configurable') {
|
77 |
+
if ($type=='bundle' && $bundle_process_children) {
|
78 |
+
$this->_data['qty'] -= $item->getQty();
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
if ($parent_type=='bundle') {
|
82 |
+
if (!$bundle_process_children) continue;
|
83 |
+
else $this->_data['qty'] += $item->getQty();
|
84 |
+
}
|
85 |
+
$this->_items[] = Mage::getModel('owebia_shipping2/Os2_Data_CartItem', array('item' => $item, 'parent_item' => $parent_item, 'options' => $this->_options));
|
86 |
+
}
|
87 |
+
//foreach ($item->getData() as $index => $value) echo "$index = $value<br/>\n";
|
88 |
+
$total_excl_tax_without_discount += $item->getData('base_row_total');
|
89 |
+
$total_excl_tax_with_discount += $item->getData('base_row_total') - $item->getData('base_discount_amount');
|
90 |
+
$total_incl_tax_with_discount += $item->getData('base_row_total') - $item->getData('base_discount_amount') + $item->getData('tax_amount');
|
91 |
+
$total_incl_tax_without_discount += $item->getData('base_row_total_incl_tax');
|
92 |
+
}
|
93 |
+
$this->_data['price-tax+discount'] = $total_excl_tax_with_discount;
|
94 |
+
$this->_data['price-tax-discount'] = $total_excl_tax_without_discount;
|
95 |
+
$this->_data['price+tax+discount'] = $total_incl_tax_with_discount;
|
96 |
+
$this->_data['price+tax-discount'] = $total_incl_tax_without_discount;
|
97 |
|
98 |
+
//echo '<pre>Owebia_Shipping2_Model_Os2_Data_Abstract::__construct<br/>';foreach ($this->_data as $n => $v){echo "\t$n => ".(is_object($v) ? get_class($v) : (is_array($v) ? 'array' : $v))."<br/>";}echo '</pre>';
|
99 |
+
}
|
100 |
|
101 |
protected function _getQuote()
|
102 |
{
|
103 |
return Mage::getModel('owebia_shipping2/Os2_Data_Quote');
|
104 |
}
|
105 |
|
106 |
+
protected function _load($name)
|
107 |
+
{
|
108 |
+
switch ($name) {
|
109 |
+
case 'weight_for_charge':
|
110 |
+
$weight_for_charge = $this->weight;
|
111 |
+
foreach ($this->_items as $item) {
|
112 |
+
if ($item->free_shipping) $weight_for_charge -= $item->weight;
|
113 |
+
}
|
114 |
+
return $weight_for_charge;
|
115 |
+
case 'coupon_code':
|
116 |
+
$coupon_code = null;
|
117 |
+
$quote = $this->_getQuote();
|
118 |
+
return $quote->coupon_code;
|
119 |
+
case 'weight_unit':
|
120 |
+
return Mage::getStoreConfig('owebia_shipping2/general/weight_unit');
|
121 |
+
}
|
122 |
+
return parent::_load($name);
|
123 |
+
}
|
124 |
|
125 |
+
public function __set($name, $value)
|
126 |
+
{
|
127 |
+
switch ($name) {
|
128 |
+
case 'items':
|
129 |
+
return $this->_items = $value;
|
130 |
+
}
|
131 |
+
return parent::__set($name, $value);
|
132 |
+
}
|
133 |
|
134 |
+
public function __get($name)
|
135 |
+
{
|
136 |
+
switch ($name) {
|
137 |
+
case 'items':
|
138 |
+
return $this->_items;
|
139 |
+
case 'free_shipping':
|
140 |
+
if (isset($this->_free_shipping)) return $this->_free_shipping;
|
141 |
+
$free_shipping = parent::__get('free_shipping');
|
142 |
+
if (!$free_shipping) {
|
143 |
+
foreach ($this->_items as $item) {
|
144 |
+
$free_shipping = $item->free_shipping;
|
145 |
+
if (!$free_shipping) break;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
return $this->_free_shipping = $free_shipping;
|
149 |
+
}
|
150 |
+
return parent::__get($name);
|
151 |
+
}
|
152 |
}
|
@@ -21,133 +21,138 @@
|
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_CartItem extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|