-
Notifications
You must be signed in to change notification settings - Fork 5
/
ET_CurrencyManager-1.2.5.tar
2508 lines (2297 loc) · 149 KB
/
ET_CurrencyManager-1.2.5.tar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
app/ 000777 0000312 0000312 00000000000 12524575137 0010607 5 ustar nginx nginx app/code/ 000777 0000312 0000312 00000000000 12524575137 0011521 5 ustar nginx nginx app/code/community/ 000777 0000312 0000312 00000000000 12524575137 0013545 5 ustar nginx nginx app/code/community/ET/ 000777 0000312 0000312 00000000000 12524575137 0014055 5 ustar nginx nginx app/code/community/ET/CurrencyManager/ 000777 0000312 0000312 00000000000 12524575137 0017142 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/ 000777 0000312 0000312 00000000000 12524575137 0020174 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/ 000777 0000312 0000312 00000000000 12524575137 0022111 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/ 000777 0000312 0000312 00000000000 12524575137 0023463 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/Product/ 000777 0000312 0000312 00000000000 12524575137 0025103 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/Product/Edit/ 000777 0000312 0000312 00000000000 12524575137 0025770 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/Product/Edit/Tab/ 000777 0000312 0000312 00000000000 12524575137 0026476 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/Product/Edit/Tab/Options/ 000777 0000312 0000312 00000000000 12524575137 0030131 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/Catalog/Product/Edit/Tab/Options/Option.php 000666 0000312 0000312 00000002555 12524575137 0032121 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option
extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
{
/**
* Rewrite to use custom precision (http://support.etwebsolutions.com/issues/466)
*
* @param $value
* @param $type
* @return string
*/
public function getPriceValue($value, $type)
{
$options = Mage::helper('currencymanager')->getOptions(array());
if (isset($options["input_admin"]) && isset($options['precision'])) {
if ($type == 'percent') {
return number_format($value, $options['precision'], null, '');
} elseif ($type == 'fixed') {
return number_format($value, $options['precision'], null, '');
}
}
return parent::getPriceValue($value, $type);
}
} app/code/community/ET/CurrencyManager/Block/Adminhtml/Formprice.php 000666 0000312 0000312 00000002117 12524575137 0024551 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Adminhtml_Formprice extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price
{
public function getEscapedValue($index=null)
{
$options = Mage::helper('currencymanager')->getOptions(array());
$value = $this->getValue();
if (!is_numeric($value)) {
return null;
}
if (isset($options["input_admin"]) && isset($options['precision'])) {
return number_format($value, $options['precision'], null, '');
}
return parent::getEscapedValue($index);
}
} app/code/community/ET/CurrencyManager/Block/Adminhtml/Heading.php 000666 0000312 0000312 00000002520 12524575137 0024160 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
//if (!class_exists('Mage_Adminhtml_Block_System_Config_Form_Field_Heading')) {
// https://bugs.php.net/bug.php?id=52339
if (version_compare(Mage::getVersion(), '1.4.1', '<')) {
class ET_CurrencyManager_Block_Adminhtml_Heading
extends Mage_Adminhtml_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
{
public function render(Varien_Data_Form_Element_Abstract $element)
{
return sprintf(
'<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>',
$element->getHtmlId(), $element->getHtmlId(), $element->getLabel()
);
}
}
} else {
class ET_CurrencyManager_Block_Adminhtml_Heading extends Mage_Adminhtml_Block_System_Config_Form_Field_Heading
{
}
} app/code/community/ET/CurrencyManager/Block/Adminhtml/Support.php 000666 0000312 0000312 00000016767 12524575137 0024317 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Adminhtml_Support
extends Mage_Adminhtml_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
{
/**
* Support tab
* version 2.0.0
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$helper = Mage::helper('currencymanager');
$moduleNameId = 'ET_CurrencyManager';
$moduleVersion = $this->_getConfigValue($moduleNameId, 'version');
$moduleName = $this->_getConfigValue($moduleNameId, 'name');
$moduleShortDescription = $this->_getConfigValue($moduleNameId, 'descr');
$moduleLicense = $this->_getConfigValue($moduleNameId, 'license');
$linkParameters = '';
$moduleLicenseLink = $this->_getConfigValue($moduleNameId, 'licenselink') . $linkParameters;
$moduleSupportLink = $this->_getConfigValue($moduleNameId, 'redminelink') . $linkParameters;
$moduleLink = $this->_getConfigValue($moduleNameId, 'permanentlink') . $linkParameters;
$servicesLink = $this->_getConfigValue($moduleNameId, 'ourserviceslink') . $linkParameters;
$magentoVersion = Mage::getVersion();
$magentoPlatform = $this->_getPlatform();
$logoLink = 'https://shop.etwebsolutions.com/logotypes/' .
$magentoPlatform . '/' .
$magentoVersion . '/' .
$moduleNameId . '/' .
$moduleVersion . '/' .
'logo.png';
$html =
'<style>
.line {border-top: 1px solid #c6c6c6; padding-top: 10px;}
.developer-label {color: #000000; font-weight:bold; width: 150px;}
.developer-text { padding-bottom: 15px;}
.developer {width: 600px; }
</style>';
$html .= '
<table cellspacing="0" cellpading="0" class="developer">
<tr>
<td class="developer-label">' . $helper->__('Extension:') . '</td>
<td class="developer-text">' . $helper->__(
'<strong>%s</strong> (version %s)',
$moduleName,
$moduleVersion
) . '</td>
</tr>
<tr>
<td class="developer-label">' . $helper->__('License:') . '</td>
<td class="developer-text">' . $helper->__(
'<a href="%s" target="_blank">%s</a>',
$moduleLicenseLink,
$moduleLicense
) . '</td>
</tr>
<tr>
<td class="developer-label">' . $helper->__('Short Description:') . '</td>
<td class="developer-text">' . $moduleShortDescription . '</td>
</tr>
<tr>
<td class="developer-label">' . $helper->__('Documentation:') . '</td>
<td class="developer-text">' . $helper->__(
'You can see description of extension features and answers to the ' .
'frequently asked questions on <a href="%s" target="_blank">our website</a>.',
$moduleLink) . '</td>
</tr>
<tr>
<td class="developer-label line">' . $helper->__('Support:') . '</td>
<td class="developer-text line">' . $helper->__(
'Extension support is available through <a href="%s" target="_blank">issue tracking system' .
'</a>.<br>You can see information freely, but you will have to sign up to open a ticket.<br>' .
'<br>Please, report all bugs and feature requests that are related to this extension.<br>' .
'<br>If by some reason you can not submit a question, bug report or feature request to our ' .
'ticket system, you can write us an email - support@etwebsolutions.com.',
$moduleSupportLink) . '</td>
</tr>
<tr>
<td class="developer-label line"><img src="' . $logoLink . '" width="100px" height="34px"> </td>
<td class="developer-text line">' . $helper->__(
'You can hire our team to customize the extension. E-mail us on sales@etwebsolutions.com.<br>' .
'<br>You can see a list of provided services on <a href="%s" target="_blank">our website</a>.',
$servicesLink) . '</td>
</tr>
</table>';
return $html;
}
protected function _getConfigValue($module, $config)
{
$locale = Mage::app()->getLocale()->getLocaleCode();
$defaultLocale = 'en_US';
$mainConfig = Mage::getConfig();
$moduleConfig = $mainConfig->getNode('modules/' . $module . '/' . $config);
if ((string)$moduleConfig) {
return $moduleConfig;
}
if ($moduleConfig->$locale) {
return $moduleConfig->$locale;
} else {
return $moduleConfig->$defaultLocale;
}
}
const PLATFORM_CE = 'ce';
const PLATFORM_PE = 'pe';
const PLATFORM_EE = 'ee';
const PLATFORM_GO = 'go';
const PLATFORM_UNKNOWN = 'unknown';
protected static $_platformCode = self::PLATFORM_UNKNOWN;
/**
* Get edition code
* @return string
*/
protected function _getPlatform()
{
if (self::$_platformCode == self::PLATFORM_UNKNOWN) {
// from Magento CE version 1.7. we can get platform from Mage class
if (property_exists('Mage', '_currentEdition')) {
switch (Mage::getEdition()) {
case Mage::EDITION_COMMUNITY:
self::$_platformCode = self::PLATFORM_CE;
break;
case Mage::EDITION_PROFESSIONAL:
self::$_platformCode = self::PLATFORM_PE;
break;
case Mage::EDITION_ENTERPRISE:
self::$_platformCode = self::PLATFORM_EE;
break;
case Mage::EDITION_ENTERPRISE:
self::$_platformCode = self::PLATFORM_EE;
break;
default:
self::$_platformCode = self::PLATFORM_UNKNOWN;
}
}
// if platform still unknown
if (self::$_platformCode == self::PLATFORM_UNKNOWN) {
$modulesArray = (array)Mage::getConfig()->getNode('modules')->children();
$isEnterprise = array_key_exists('Enterprise_Enterprise', $modulesArray);
$isProfessional = false; // TODO: how determine?
$isGo = false; // TODO: how?
if ($isEnterprise) {
self::$_platformCode = self::PLATFORM_EE;
} elseif ($isProfessional) {
self::$_platformCode = self::PLATFORM_PE;
} elseif ($isGo) {
self::$_platformCode = self::PLATFORM_GO;
} else {
self::$_platformCode = self::PLATFORM_CE;
}
}
}
return self::$_platformCode;
}
} app/code/community/ET/CurrencyManager/Block/Adminhtml/Symbolreplace.php 000666 0000312 0000312 00000024142 12524575137 0025426 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Adminhtml_Symbolreplace extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected $_addRowButtonHtml = array();
protected $_removeRowButtonHtml = array();
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);
$html = '<div id="symbolreplace_template" style="display:none">';
$html .= $this->_getRowTemplateHtml();
$html .= '</div>';
$html .= '<ul id="symbolreplace_container">';
if ($this->_getValue('currency')) {
foreach (array_keys($this->_getValue('currency')) as $row) {
if ($row) {
$html .= $this->_getRowTemplateHtml($row);
}
}
}
$html .= '</ul>';
$html .= $this->_getAddRowButtonHtml(
'symbolreplace_container',
'symbolreplace_template', $this->__('Add currency specific options')
);
return $html;
}
protected function _getRowTemplateHtml($row = 0)
{
$html = '<li><fieldset>';
$html .= $this->_getCurrencySelectHtml($row);
$html .= $this->_getPrecisionHtml($row);
$html .= $this->_getMinDecimalCountHtml($row);
$html .= $this->_getCutZeroHtml($row);
$html .= $this->_getSuffixHtml($row);
$html .= $this->_getSymbolPositionHtml($row);
$html .= $this->_getSymbolUseHtml($row);
$html .= $this->_getSymbolReplaceHtml($row);
$html .= $this->_getZeroPriceReplaceHtml($row);
$html .= '<br /> <br />';
$html .= $this->_getRemoveRowButtonHtml();
$html .= '</fieldset></li>';
return $html;
}
protected function _getZeroPriceReplaceHtml($row)
{
$html = '<label>' . $this->__('Replace Zero Price to:') . ' </label> ';
$html .= '<input class="input-text" name="' . $this->getElement()->getName() . '[zerotext][]" value="'
. $this->_getValue('zerotext/' . $row) . '" ' . $this->_getDisabled() . '/> ';
$html .= '<p class="nm"><small>' . $this->__('Leave empty for global value use') . '</small></p>';
return $html;
}
protected function _getSymbolReplaceHtml($row)
{
$html = '<label>' . $this->__('Replace symbol to:') . ' </label> ';
$html .= '<input class="input-text" name="' . $this->getElement()->getName() . '[symbol][]" value="'
. $this->_getValue('symbol/' . $row) . '" ' . $this->_getDisabled() . '/> ';
$html .= '<p class="nm"><small>' . $this->__('Leave empty for disable replace') . '</small></p>';
return $html;
}
protected function _getSymbolUseHtml($row)
{
$html = '<label>' . $this->__('Currency symbol use:') . ' </label> ';
$html .= '<select class="input-text" name="' . $this->getElement()->getName() . '[display][]">';
foreach (Mage::getModel("currencymanager/typesymboluse")->toOptionArray() as $labelValue) {
$html .= '<option value="' . $labelValue["value"] . '" '
. ($this->_getValue('display/' . $row) == $labelValue["value"] ? 'selected="selected"' : '') . '>'
. $labelValue["label"] . "</option>";
}
$html .= '</select>';
return $html;
}
protected function _getSymbolPositionHtml($row)
{
$html = '<label>' . $this->__('Symbol position:') . ' </label> ';
$html .= '<select class="input-text" name="' . $this->getElement()->getName() . '[position][]">';
foreach (Mage::getModel("currencymanager/typeposition")->toOptionArray() as $labelValue) {
$html .= '<option value="' . $labelValue["value"] . '" '
. ($this->_getValue('position/' . $row) == $labelValue["value"] ? 'selected="selected"' : '') . '>'
. $labelValue["label"] . "</option>";
}
$html .= '</select>';
return $html;
}
protected function _getSuffixHtml($row)
{
$html = '<label>' . $this->__('Suffix:') . ' </label> ';
$html .= '<input class="input-text" name="' . $this->getElement()->getName()
. '[cutzerodecimal_suffix][]" value="' . $this->_getValue('cutzerodecimal_suffix/' . $row)
. '" ' . $this->_getDisabled() . '/> ';
$html .= '<p class="nm"><small>' . $this->__('Leave empty for global value use') . '</small></p>';
return $html;
}
protected function _getMinDecimalCountHtml($row)
{
$html = '<label>' . $this->__('Minimum number of digits after the decimal point:') . ' </label> ';
$html .= '<input class="input-text" name="' . $this->getElement()->getName()
. '[min_decimal_count][]" value="' . $this->_getValue('min_decimal_count/' . $row)
. '" ' . $this->_getDisabled() . '/> ';
$html .= '<p class="nm"><small>' . $this->__('Leave empty for global value use') . '</small></p>';
return $html;
}
protected function _getCutZeroHtml($row)
{
$html = '<label>' . $this->__('Cut Zero Decimals:') . ' </label> ';
$html .= '<select class="input-text" name="' . $this->getElement()->getName() . '[cutzerodecimal][]">';
foreach (Mage::getModel("adminhtml/system_config_source_yesno")->toOptionArray() as $labelValue) {
$html .= '<option value="' . $labelValue["value"] . '" '
. ($this->_getValue('cutzerodecimal/' . $row) == $labelValue["value"] ? 'selected="selected"' : '')
. '>' . $labelValue["label"] . "</option>";
}
$html .= '</select>';
return $html;
}
protected function _getPrecisionHtml($row)
{
$html = '<label>' . $this->__('Display precision:') . ' </label> ';
$html .= '<input class="input-text" name="' . $this->getElement()->getName() . '[precision][]" value="'
. $this->_getValue('precision/' . $row) . '" ' . $this->_getDisabled() . '/> ';
$html .= '<p class="nm"><small>' . $this->__('Leave empty for global value use') . '</small></p>';
return $html;
}
protected function _getCurrencySelectHtml($row)
{
$html = '<label>' . $this->__('Select currency:') . ' </label> ';
$html .= '<select name="' . $this->getElement()->getName() . '[currency][]" ' . $this->_getDisabled() . '>';
$html .= '<option value="">' . $this->__('* Select currency') . '</option>';
foreach ($this->getAllowedCurrencies() as $currencyCode => $currency) {
$html .= '<option value="' . $currencyCode . '" ' . $this->_getSelected('currency/' . $row, $currencyCode)
. ' style="background:white;">' . $currency . " - " . $currencyCode . '</option>';
}
$html .= '</select>';
return $html;
}
protected function getAllowedCurrencies()
{
if (!$this->hasData('allowed_currencies')) {
$currencies = Mage::app()->getLocale()->getOptionCurrencies();
$allowedCurrencyCodes = Mage::getSingleton('directory/currency')->getConfigAllowCurrencies();
$formattedCurrencies = array();
foreach ($currencies as $currency) {
$formattedCurrencies[$currency['value']]['label'] = $currency['label'];
}
$allowedCurrencies = array();
foreach ($allowedCurrencyCodes as $currencyCode) {
$allowedCurrencies[$currencyCode] = $formattedCurrencies[$currencyCode]['label'];
}
$this->setData('allowed_currencies', $allowedCurrencies);
}
return $this->getData('allowed_currencies');
}
protected function _getDisabled()
{
return $this->getElement()->getDisabled() ? ' disabled' : '';
}
protected function _getValue($key)
{
$value = $this->getElement()->getData('value/' . $key);
if (is_null($value) && $key != 'currency') {
$key = explode("/", $key);
$key = array_shift($key);
//$value = Mage::app()->getConfig()->getNode('default/currencymanager/general/symbolreplace/'.$key);
$value = Mage::app()->getConfig()->getNode('default/currencymanager/general/'.$key);
return (string)$value;
}
return $value;
}
protected function _getSelected($key, $value)
{
return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
}
protected function _getAddRowButtonHtml($container, $template, $title = 'Add')
{
if (!isset($this->_addRowButtonHtml[$container])) {
$this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setClass('add ' . $this->_getDisabled())
->setLabel($this->__($title))
//$this->__('Add')
->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
->setDisabled($this->_getDisabled())
->toHtml();
}
return $this->_addRowButtonHtml[$container];
}
protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Remove')
{
if (!$this->_removeRowButtonHtml) {
$this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setClass('delete v-middle ' . $this->_getDisabled())
->setLabel($this->__($title))
//$this->__('Remove')
->setOnClick("Element.remove($(this).up('" . $selector . "'))")
->setDisabled($this->_getDisabled())
->toHtml();
}
return $this->_removeRowButtonHtml;
}
} app/code/community/ET/CurrencyManager/Block/Adminhtml/System/ 000777 0000312 0000312 00000000000 12524575137 0023375 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/System/Config/ 000777 0000312 0000312 00000000000 12524575137 0024602 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/System/Config/Form/ 000777 0000312 0000312 00000000000 12524575137 0025505 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/System/Config/Form/Field/ 000777 0000312 0000312 00000000000 12524575137 0026530 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Block/Adminhtml/System/Config/Form/Field/Linktooptions.php 000666 0000312 0000312 00000001771 12524575137 0032123 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Adminhtml_System_Config_Form_Field_Linktooptions
extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
return '<a href="' . $this->getUrl('*/system_config/edit', array('section' => 'currencymanager')) . '">' .
Mage::helper('currencymanager')->__('Click here to configure currency additional display options') .
'</a>';
}
} app/code/community/ET/CurrencyManager/Block/Js.php 000666 0000312 0000312 00000002371 12524575137 0021264 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Block_Js extends Mage_Core_Block_Template
{
public function getJsonConfig()
{
if (method_exists(Mage::helper('core'), 'jsonEncode')) {
return Mage::helper('core')->jsonEncode(
Mage::helper('currencymanager')->getOptions(
array(),
false,
Mage::app()->getStore()->getCurrentCurrencyCode()
)
);
} else {
return Zend_Json::encode(
Mage::helper('currencymanager')->getOptions(
array(),
false,
Mage::app()->getStore()->getCurrentCurrencyCode()
)
);
}
}
} app/code/community/ET/CurrencyManager/Helper/ 000777 0000312 0000312 00000000000 12524575137 0020361 5 ustar nginx nginx app/code/community/ET/CurrencyManager/Helper/Data.php 000666 0000312 0000312 00000024222 12524575137 0021745 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* ZEND constants avalable in /lib/Zend/Currency.php
*
* NOTICE
*
* Magento ver 1.3.x - display - USE_SHORTNAME(3) by default
* Magento ver 1.4.x - display - USE_SYMBOL(2) by default
*
* position: 8 - standart; 16 - right; 32 - left
*
*/
protected $_options = array();
protected $_optionsadvanced = array();
public function getOptions($options = array(), $old = false, $currency = "default") //$old for support Magento 1.3.x
{
$storeId = Mage::app()->getStore()->getStoreId();
if ((!isset($this->_options[$storeId][$currency])) || (!isset($this->_optionsadvanced[$storeId][$currency]))) {
$this->setOptions($currency);
}
$newOptions = $this->_options[$storeId][$currency];
$newOptionsAdvanced = $this->_optionsadvanced[$storeId][$currency];
if (!$old) {
$newOptions = $newOptions + $newOptionsAdvanced;
}
// For JavaScript prices: Strange Symbol extracting in function getOutputFormat
// in file app/code/core/Mage/Directory/Model/Currency.php
// For Configurable, Bundle and Simple with custom options
// This causes problem if any currency has by default NO_SYMBOL
// with this module can't change display value in this case
if (isset($options["display"])) {
if ($options["display"] == Zend_Currency::NO_SYMBOL) {
unset($newOptions["display"]);
}
}
if (count($options) > 0) {
return $newOptions + $options;
} else {
return $newOptions;
}
}
public function clearOptions($options)
{
$oldOptions = array("position", "format", "display", "precision", "script", "name", "currency", "symbol");
foreach (array_keys($options) as $optionKey) {
if (!in_array($optionKey, $oldOptions)) {
unset($options[$optionKey]);
}
}
return $options;
}
public function isEnabled()
{
$config = Mage::getStoreConfig('currencymanager/general');
$storeId = Mage::app()->getStore()->getStoreId();
return ((($config['enabled']) && ($storeId > 0)) || (($config['enabledadm']) && ($storeId == 0)));
}
public function setOptions($currency = "default")
{
$config = Mage::getStoreConfig('currencymanager/general');
$options = array();
$optionsAdvanced = array();
$storeId = Mage::app()->getStore()->getStoreId();
if ($this->isEnabled()) {
$notCheckout = !($config['excludecheckout'] & $this->isInOrder());
$this->_getGeneralOptions($config, $options, $optionsAdvanced, $notCheckout);
// formatting symbols from admin, preparing to use. Maybe can do better :)
// если в админке будут внесены
// несколько значений для одной валюты,
// то использоваться будет только одна
if (isset($config['symbolreplace'])) {
$this->_collectCurrencyOptions($config, $currency, $notCheckout, $options, $optionsAdvanced);
}
} // end NOT ENABLED
$this->_options[$storeId][$currency] = $options;
$this->_optionsadvanced[$storeId][$currency] = $optionsAdvanced;
if (!isset($this->_options[$storeId]["default"])) {
$this->_options[$storeId]["default"] = $options;
$this->_optionsadvanced[$storeId]["default"] = $optionsAdvanced;
}
return $this;
}
protected function _getGeneralOptions($config, &$options, &$optionsAdvanced, $notCheckout)
{
if ($notCheckout) {
if (isset($config['precision'])) { // precision must be in range -1 .. 30
$options['precision'] = min(30, max(-1, (int)$config['precision']));
}
if (isset($config['zerotext'])) {
$optionsAdvanced['zerotext'] = $config['zerotext'];
}
}
if (isset($config['position'])) {
$options['position'] = (int)$config['position'];
}
if (isset($config['display'])) {
$options['display'] = (int)$config['display'];
}
if (isset($config['input_admin'])) {
if ($config['input_admin'] > 0) {
$optionsAdvanced['input_admin'] = (int)$config['input_admin'];
}
}
$optionsAdvanced['excludecheckout'] = $config['excludecheckout'];
$optionsAdvanced['cutzerodecimal'] = $config['cutzerodecimal'];
$optionsAdvanced['cutzerodecimal_suffix'] = isset($config['cutzerodecimal_suffix']) ?
$config['cutzerodecimal_suffix'] : "";
$optionsAdvanced['min_decimal_count'] = isset($config['min_decimal_count']) ?
$config['min_decimal_count'] : "2";
}
protected function _collectCurrencyOptions($config, $currency, $notCheckout, &$options, &$optionsAdvanced)
{
$symbolReplace = $this->_unsetSymbolReplace($config);
if (count($symbolReplace['currency']) > 0) {
$tmpOptions = array();
$tmpOptionsAdvanced = array();
$tmpOptionsAdvanced['cutzerodecimal'] = $this->_getCurrencyOption(
$currency, $symbolReplace, 'cutzerodecimal', true
);
if (isset($symbolReplace['cutzerodecimal_suffix'])) {
$tmpOptionsAdvanced["cutzerodecimal_suffix"] = $this->_getCurrencyOption(
$currency, $symbolReplace, 'cutzerodecimal_suffix'
);
}
if (isset($symbolReplace['min_decimal_count'])) {
$tmpOptionsAdvanced["min_decimal_count"] = $this->_getCurrencyOption(
$currency, $symbolReplace, 'min_decimal_count'
);
}
$tmpOptions['position'] = $this->_getCurrencyOption($currency, $symbolReplace, 'position', true);
$tmpOptions['display'] = $this->_getCurrencyOption($currency, $symbolReplace, 'display', true);
$tmpOptions['symbol'] = $this->_getCurrencyOption($currency, $symbolReplace, 'symbol');
if ($notCheckout) {
$tmpOptionsAdvanced['zerotext'] = $this->_getCurrencyOption($currency, $symbolReplace, 'zerotext');
$precision = $this->_getCurrencyOption($currency, $symbolReplace, 'precision', true);
if ($precision !== false) {
$tmpOptions['precision'] = min(30, max(-1, $precision));
}
}
foreach ($tmpOptions as $option => $value) {
if ($value !== false) {
$options[$option] = $value;
}
}
foreach ($tmpOptionsAdvanced as $option => $value) {
if ($value !== false) {
$optionsAdvanced[$option] = $value;
}
}
}
}
/**
* To check where price is used
* in some cases default values for precision and zerotext should be used
* for sales/checkout in frontend
* for admin AND sales_order*
*
* @return bool
*/
public function isInOrder()
{
$moduleName = Mage::app()->getRequest()->getModuleName();
$controllerName = Mage::app()->getRequest()->getControllerName();
$orderModules = array('sales', 'checkout', 'paypal');
$modifiedOrderModules = array(
'order_modules' => new Varien_Object(array('module_names'=>$orderModules)),
);
Mage::dispatchEvent('et_currencymanager_checking_is_in_order_before', $modifiedOrderModules);
$orderModules = $modifiedOrderModules['order_modules']->getData('module_names');
return ((in_array($moduleName, $orderModules))
|| (
($moduleName == 'admin') && (strpos($controllerName, 'sales_order') !== false)
));
}
protected function _unsetSymbolReplace($config)
{
if (!is_array($config['symbolreplace'])) {
$symbolReplace = unserialize($config['symbolreplace']);
foreach (array_keys($symbolReplace['currency']) as $symbolReplaceKey) {
if (strlen(trim($symbolReplace['currency'][$symbolReplaceKey])) == 0) {
unset($symbolReplace['currency'][$symbolReplaceKey]);
unset($symbolReplace['precision'][$symbolReplaceKey]);
unset($symbolReplace['min_decimal_count'][$symbolReplaceKey]);
unset($symbolReplace['cutzerodecimal'][$symbolReplaceKey]);
unset($symbolReplace['cutzerodecimal_suffix'][$symbolReplaceKey]);
unset($symbolReplace['position'][$symbolReplaceKey]);
unset($symbolReplace['display'][$symbolReplaceKey]);
unset($symbolReplace['symbol'][$symbolReplaceKey]);
unset($symbolReplace['zerotext'][$symbolReplaceKey]);
}
}
return $symbolReplace;
}
return false;
}
public function resetOptions()
{
$this->_options = array();
$this->_optionsadvanced = array();
}
protected function _getCurrencyOption($currency, $symbolReplace, $option, $int = false)
{
$configSubData = array_combine($symbolReplace['currency'], $symbolReplace[$option]);
if (array_key_exists($currency, $configSubData)) {
$value = $configSubData[$currency];
if ($value === "") {
return false;
}
return ($int) ? (int)$value : $value;
}
return false;
}
} app/code/community/ET/CurrencyManager/Helper/Tax.php 000666 0000312 0000312 00000003477 12524575137 0021641 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Helper_Tax extends Mage_Tax_Helper_Data
{
/**
* Get product price with all tax settings processing CM wrapper
*
* @param Mage_Catalog_Model_Product $product
* @param float $price inputed product price
* @param bool $includingTax return price include tax flag
* @param null|Mage_Customer_Model_Address $shippingAddress
* @param null|Mage_Customer_Model_Address $billingAddress
* @param null|int $ctc customer tax class
* @param mixed $store
* @param bool $priceIncludesTax flag what price parameter contain tax
* @return float
*/
public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
$ctc = null, $store = null, $priceIncludesTax = null
) {
if (!$price) {
return $price;
}
$store = Mage::app()->getStore($store);
if (!$this->needPriceConversion($store)) {
return $price;
}
Mage::app()->getStore($store)->setDoNotRoundET(true);
$result = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc,
$store, $priceIncludesTax);
Mage::app()->getStore($store)->setDoNotRoundET(false);
return $result;
}
} app/code/community/ET/CurrencyManager/Helper/Tax1810.php 000666 0000312 0000312 00000003556 12524575137 0022151 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @category ET
* @package ET_CurrencyManager
* @copyright Copyright (c) 2012 ET Web Solutions (http://etwebsolutions.com)
* @contacts support@etwebsolutions.com
* @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
*/
class ET_CurrencyManager_Helper_Tax1810 extends Mage_Tax_Helper_Data
{
/**
* Get product price with all tax settings processing
*
* @param Mage_Catalog_Model_Product $product
* @param float $price inputed product price
* @param bool $includingTax return price include tax flag
* @param null|Mage_Customer_Model_Address $shippingAddress
* @param null|Mage_Customer_Model_Address $billingAddress
* @param null|int $ctc customer tax class
* @param null|Mage_Core_Model_Store $store
* @param bool $priceIncludesTax flag what price parameter contain tax
* @return float
*/
public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
$ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true
) {
if (!$price) {
return $price;
}
$store = Mage::app()->getStore($store);
if (!$this->needPriceConversion($store)) {
return $price;
}
Mage::app()->getStore($store)->setDoNotRoundET(true);
$result = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc,
$store, $priceIncludesTax, $roundPrice);
Mage::app()->getStore($store)->setDoNotRoundET(false);
return $result;
}
} app/code/community/ET/CurrencyManager/Helper/Url.php 000666 0000312 0000312 00000002452 12524575137 0021637 0 ustar nginx nginx <?php
/**
* NOTICE OF LICENSE
*
* You may not sell, sub-license, rent or lease
* any portion of the Software or Documentation to anyone.
*