This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
xls_admin.php
4708 lines (2992 loc) · 145 KB
/
xls_admin.php
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
<?php
/*
LightSpeed Web Store
NOTICE OF LICENSE
This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@lightspeedretail.com <mailto:support@lightspeedretail.com>
* so we can send you a copy immediately.
DISCLAIMER
* Do not edit or add to this file if you wish to upgrade Web Store to newer
* versions in the future. If you wish to customize Web Store for your
* needs please refer to http://www.lightspeedretail.com for more information.
* @copyright Copyright (c) 2011 Xsilva Systems, Inc. http://www.lightspeedretail.com
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/** THIS IS THE SCRIPT THAT LOADS THE WEB STORE ADMIN PANEL FROM LIGHTSPEED, ALTER AT YOUR OWN RISK **/
// FORCE URL based session
ini_set('session.use_cookies' , 'off');
ini_set('session.use_trans_sid' , 'on');
ob_start(); // These includes may spit content which we need to ignore
require_once('includes/prepend.inc.php');
_xls_lang_init(_xls_get_conf('LANGUAGE_DEFAULT' , 'en'));
ob_end_clean();
if(isset($_GET[session_name()]))
session_id($_GET[session_name()]);
function adminTemplate($name)
{
return 'templates/admin/'.$name;
}
function admin_sid(){
//return '';
return "&" . session_name() . "=" . session_id();
}
QApplication::$EncodingType = "UTF-8";
define('XLSWS_ADMIN_MODULE' , true);
if(!isset($_SESSION['admin_auth'])
){
$uname = md5(gmdate('d'));
$conf = Configuration::LoadByKey('LSKEY');
//LightSpeed may send password in one of two scenarios
$password = md5(gmdate('d') . $conf->Value);
$password2 = md5(date('d') . $conf->Value);
if(isset($_POST['user']) && isset($_POST['password']) &&
($_POST['password'] == $password || $_POST['password'] == $password2))
{
$_SESSION['admin_auth'] = true;
session_commit();
// if session id is not set and add it in request uri
_rd(QApplication::$RequestUri . "?" . admin_sid());
}else{
$msg = "<h1>Cannot Connect</h1>Unauthorized admin access or session timed out from " . _xls_get_ip() . " at " . gmdate("Y-m-d H:i:s") . " GMT.<br>Please re-open the Admin Panel\n\n " ; //
_xls_log($msg . "Session vars: " . print_r($_SESSION , true) . " \n\nServer vars: " . print_r($_SERVER , true) . " . \n\n Post Vars: " . print_r($_POST , true));
die("<pre>$msg</pre>");
}
}
// Check IP address
$ips = _xls_get_conf('LSAUTH_IPS');
if ((trim($ips) != '')){
$found = false;
foreach (explode(',', $ips) as $ip)
if ($_SERVER['REMOTE_ADDR'] == trim($ip))
$found = true;
if($found == false){
$msg = " Unauthorised WebKit Access from " . $_SERVER['REMOTE_ADDR'] . " - IP address is not in authorized list.";
_xls_log($msg);
die($msg);
}
}
if(!isset($XLSWS_VARS['page']))
$XLSWS_VARS['page'] = 'config';
//add custom includes as well..
require_once(CUSTOM_INCLUDES . 'prepend.inc.php');
/* class XLS_OnOff
* class to create iTouch like on/off toggles in the Admin Panel
* extended from a Qcheckbox, see api.qcodo.com under Qforms and Qcontrols
* under QCheckBox for methd and parameter descriptions
*/
class XLS_OnOff extends QCheckBox {
public function GetJavaScriptAction() {
return "onclick";
}
public function ParsePostData() {
if (array_key_exists($this->strControlId, $_POST)) {
if ($_POST[$this->strControlId])
$this->blnChecked = true;
else
$this->blnChecked = false;
} else {
$this->blnChecked = false;
}
}
protected function GetControlHtml() {
if (!$this->blnEnabled)
$strDisabled = 'disabled="disabled" ';
else
$strDisabled = "";
if ($this->intTabIndex)
$strTabIndex = sprintf('tabindex="%s" ', $this->intTabIndex);
else
$strTabIndex = "";
if ($this->strToolTip)
$strToolTip = sprintf('title="%s" ', $this->strToolTip);
else
$strToolTip = "";
if ($this->strAccessKey)
$strAccessKey = sprintf('accesskey="%s" ', $this->strAccessKey);
else
$strAccessKey = "";
if ($this->blnChecked)
$strChecked = " class=\"on_inline" . (($this->strCssClass)?sprintf(' %s ', $this->strCssClass):"") . "\" ";
else
$strChecked = " class=\"off_inline" . (($this->strCssClass)?sprintf(' %s ', $this->strCssClass):"") . "\" ";
$strStyle = $this->GetStyleAttributes();
if (strlen($strStyle) > 0)
$strStyle = sprintf('style="%s" ', $strStyle);
else
$strStyle = 'style="float: left;" ';
$strCustomAttributes = $this->GetCustomAttributes();
$strActions = $this->GetActionAttributes();
if(trim($strActions) == ''){
$strActions = " onclick=\"var elm=document.getElementById('$this->strControlId'); var aelm=document.getElementById('$this->strControlId' + '_a'); if(elm.value=='1'){ elm.value='0'; aelm.className='off_inline'; }else{ elm.value='1'; aelm.className='on_inline'; } return false;\" ";
}
$this->blnIsBlockElement = false;
$strToReturn = sprintf('<input type="hidden" name="%s" id="%s" value="%s"/><a id="%s_a" href="javascript:{}" %s%s%s%s%s%s%s%s></a>',
$this->strControlId,
$this->strControlId,
$this->blnChecked?"1":"0",
$this->strControlId,
$strDisabled,
$strChecked,
$strActions,
$strAccessKey,
$strToolTip,
$strTabIndex,
$strCustomAttributes,
$strStyle);
return $strToReturn;
}
}
//THE VARIOUS ITEMS IN THE ADMIN DROPDOWN PANEL - CONFIGURATION, SHIPPING, PAYMENT, STATS AND SYSTEM
$arrShipTabs = array('shipping' => _sp('Shipping') , 'methods' => _sp('Methods') , 'destinations' =>_sp('Destinations') ,'tier' =>_sp('Shipping Tiers') , 'countries' =>_sp('Countries') , 'states' =>_sp('States/Regions') );
$arrConfigTabs = array('store' => _sp('Store') , 'appear' => _sp('Appearance') , 'sidebars' =>_sp('Sidebars'));
$arrPaymentTabs = array('methods' => _sp('Methods') , 'cc' => _sp('Credit Card Types'), 'promo' => _sp('Promo Codes'));
$arrStatTabs = array('chart' => _sp('Charts') , 'vlog' => _sp('Visitor Log'));
$arrSystemTabs = array('config' => _sp('Configuration') , 'task' => _sp('Tasks') , 'slog' => _sp('System Log'));
/* class xlsws_admin
* class to create a general form that can be used throughout the admin panel
* extended from a Qcheckbox, see api.qcodo.com under Qforms and Qcontrols
*/
class xlsws_admin extends QForm{
public $admin_pages = array();
protected $pxyTabClick;
protected $pxyPanelClick;
protected $arrTabs;
protected $arrPanels;
protected $currentTab;
protected $url;
protected $configPnls = array();
protected function Form_Create(){
$this->url = $_SERVER['REQUEST_URI'];
$this->admin_pages = array(
'config' => _sp('Configuration')
, 'paym' => _sp('Payment Methods')
, 'ship' => _sp('Shipping')
, 'cpage' => _sp('Pages')
, 'stats' => _sp('Stats')
, 'system' => _sp('System')
);
// is there custom admin folder?
if(is_dir(CUSTOM_INCLUDES . 'admin')){
$this->admin_pages['custom'] = _sp('Custom');
}
$this->pxyTabClick = new QControlProxy($this);
$this->pxyTabClick->AddAction(new QClickEvent() , new QServerAction('ChangeTab'));
$this->pxyTabClick->AddAction(new QClickEvent() , new QTerminateAction());
$this->pxyPanelClick = new QControlProxy($this);
$this->pxyPanelClick->AddAction(new QClickEvent() , new QServerAction('ChangePanel'));
$this->pxyPanelClick->AddAction(new QClickEvent() , new QTerminateAction());
}
public function get_uri($subpage){
global $_SERVER , $XLSWS_VARS;
return $_SERVER["SCRIPT_NAME"] . '?' . (isset($XLSWS_VARS['page'])?"page=$XLSWS_VARS[page]":'') . "&subpage=$subpage" . admin_sid();
}
public function ChangeTab($strFormId, $strControlId, $strParameter){
$this->currentTab = $strParameter;
}
public function configDone(){
}
//public function Form_PreRender(){
//QApplication::ExecuteJavaScript("$('.rounded').corners();");
//QApplication::ExecuteJavaScript("tooltip();");
//}
}
/* class xlsws_config_types
* class to lookup numeric listing definations for each admin panel choice
*/
class xlsws_config_types extends QBaseClass {
const System = 1;
const Store = 2;
const CustomerRegistration = 3;
const Cart = 4;
const Email = 5;
const SRO = 6;
const GiftRegistry = 7;
const ProductListing = 8;
const Shipping = 9;
const Payment = 10;
const Inventory = 11;
const Appearance = 12;
const Product = 13;
const SEO = 14;
const Localisation = 15;
const Security = 16;
const Images = 17;
}
/* class xlsws_admin_config_panel
* class to create the main configuration section panel
* see api.qcodo.com under Qpanel for methods and parameters
*/
class xlsws_admin_config_panel extends QPanel{
protected $strMethodCallBack; //the callback function to call
protected $configType; //the type of configuration in this section
public $fields; //list of fields
public $helpers = array(); //related helpers
protected $objParentObject; //the parent object the configuration option belongs to
protected $configs; //list of different configurations for a field
public $btnSave; //the save button
public $btnEdit; //the edit button
public $btnCancel; //the cancel button
public $Info = ""; //the tooltip info text
public $special_css_class = ""; //any special CSS class you wish to use for this section
// Customize Look/Feel
//protected $strPadding = '10px';
//protected $strBackColor = '#fefece';
protected $strFileLocation;
public $EditMode = false;
public function __construct($objParentControl, $objParentObject, $configType , $strMethodCallBack, $strControlId = null) {
$evaledOptionControl = false;
// First, let's call the Parent's __constructor
try {
parent::__construct($objParentControl, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
// Next, we set the local module object
$this->objParentObject = $objParentObject;
$this->configType = $configType;
// Let's record the reference to the form's MethodCallBack
$this->strMethodCallBack = $strMethodCallBack;
$this->fields = array();
if(is_string($this->configType))
$this->configs = Configuration::QueryArray(QQ::Equal( QQN::Configuration()->Key , $this->configType) , QQ::Clause(QQ::OrderBy(QQN::Configuration()->SortOrder , QQN::Configuration()->Title)));
elseif(is_array($this->configType))
$this->configs = Configuration::QueryArray(QQ::In( QQN::Configuration()->Key , $this->configType) , QQ::Clause(QQ::OrderBy(QQN::Configuration()->SortOrder , QQN::Configuration()->Title)));
else
$this->configs = Configuration::LoadArrayByConfigurationTypeId($this->configType , QQ::Clause(QQ::OrderBy(QQN::Configuration()->SortOrder , QQN::Configuration()->Title)));
foreach($this->configs as $config){
if($config->Options != ''){
$evaledOptionControl = $this->evalOption($config->Options);
}
$optType = trim(strtoupper($config->Options));
if($optType == 'BOOL'){
$this->fields[$config->Key] = new XLS_OnOff($this);
$this->fields[$config->Key]->Enabled = true;
$this->fields[$config->Key]->Checked = intval($config->Value)?true:false;
}elseif($evaledOptionControl instanceof QControl){
$this->fields[$config->Key] = $evaledOptionControl;
}elseif($optType == 'PINT'){
$this->fields[$config->Key] = new XLSIntegerBox($this);
$this->fields[$config->Key]->Required = true;
$this->fields[$config->Key]->Minimum = 0;
$this->fields[$config->Key]->Required = true;
}elseif(is_array($evaledOptionControl) && $optType != ""){
$this->fields[$config->Key] = new XLSListBox($this);
$this->fields[$config->Key]->RemoveAllItems();
foreach($evaledOptionControl as $k=>$v)
$this->fields[$config->Key]->AddItem(_sp($v) , $k);
$this->fields[$config->Key]->SelectedValue = $config->Value;
}elseif($optType == 'HEADERIMAGE'){
// for some very mysterious reason, having this code (the
// creation of the XLSTextBox()) in evalOption causes failure
// (the box doesn't appear)... sticking it here as a
// quickfix for release
$this->fields[$config->Key] = new XLSTextBox($this);
$this->fields[$config->Key]->Text = $config->Value;
$this->fields[$config->Key]->Required = true;
}else{
$this->fields[$config->Key] = new XLSTextBox($this);
$this->fields[$config->Key]->Text = $config->Value;
if($config->Key=="EMAIL_SMTP_PASSWORD") $this->fields[$config->Key]->TextMode = QTextMode::Password;
//$this->fields[$config->Key]->Required = true;
}
$this->fields[$config->Key]->Name = _sp($config->Title);
// $this->fields[$config->Key]->CssClass .= " admin_config_field";
$this->helpers[$config->Key] = $config->HelperText;
}
$this->btnSave = new QButton($this);
$this->btnSave->Text = _sp('Save');
$this->btnSave->CssClass = 'button admin_save';
$this->btnSave->Visible = false;
$this->btnSave->AddAction(new QClickEvent() , new QServerControlAction($this , 'btnSave_click'));
$this->btnSave->CausesValidation = true;
$this->btnCancel = new QButton($this);
$this->btnCancel->Text = _sp('Cancel');
$this->btnCancel->Visible = false;
$this->btnCancel->CssClass = 'button admin_cancel';
$this->btnCancel->AddAction(new QClickEvent() , new QAjaxControlAction($this , 'btnCancel_click'));
$this->btnEdit = new QButton($this);
$this->btnEdit->Text = _sp('Edit');
$this->btnEdit->CssClass = 'button admin_edit';
$this->btnEdit->AddAction(new QClickEvent() , new QAjaxControlAction($this , 'btnEdit_click'));
$this->strTemplate = adminTemplate('config_panel.tpl.php');
}
public function btnEdit_click(){
$this->btnEdit->Visible = false;
$this->btnSave->Visible = true;
$this->btnCancel->Visible = true;
$this->EditMode = true;
$this->Refresh();
foreach($this->fields as $key=>$field){
$config = Configuration::LoadByKey($key);
if(!$config)
continue;
if($this->fields[$key] instanceof XLS_OnOff ){
$this->fields[$config->Key]->Checked = intval($config->Value)?true:false;
}elseif(($this->fields[$key] instanceof QFileAsset) ){
if(file_exists($config->Value))
$this->fields[$config->Key]->File = $config->Value;
$this->special_css_class = " extra_height";
}elseif($this->fields[$key] instanceof QListControl ){
$this->fields[$config->Key]->SelectedValue = $config->Value;
}else{
$this->fields[$config->Key]->Text = $config->Value;
}
}
QApplication::ExecuteJavaScript("doRefresh();");
}
public function evalOption($str){
$str = trim($str);
if($str == '')
return '';
switch($str){
case 'BOOL':
return array(0=>'No' , 1=>'Yes');
case 'TEMPLATE':
$arr = array();
$d = dir("templates/");
while (false!== ($filename = $d->read())) {
if (is_dir("templates/$filename") && file_exists("templates/$filename/index.tpl.php")) { // whatever your includes extensions are
$arr[$filename] = $filename;
}
}
$d->close();
return $arr;
case 'COUNTRY':
$arr = array();
$objCountries= Country::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Country()->SortOrder , QQN::Country()->Country)));
if ($objCountries) foreach ($objCountries as $objCountry) {
$arr[$objCountry->Code] = ($objCountry->Country);
}
return $arr;
case 'STATE':
$states = State::LoadAll(QQ::Clause(QQ::OrderBy(QQN::State()->State)));
$arr = array();
foreach($states as $state) {
$arr[$state->Code] = ( $state->Country->Country . '-' . $state->State);
}
return $arr;
case 'WEIGHT':
return array('lb'=>'Pound' , 'kg'=>'Kilogram');
case 'DIMENSION':
return array('in'=>'Inch' , 'cm'=>'Centimeter');
case 'ENCODING':
return array('ISO-8859-1'=>'ISO-8859-1','ISO-8859-15'=>'ISO-8859-15','UTF-8'=>'UTF-8'
,'cp1251'=>'cp1251','cp1252'=>'cp1252','KOI8-R'=>'KOI8-R'
,'BIG5'=>'BIG5','GB2312'=>'GB2312','BIG5-HKSCS'=>'BIG5-HKSCS'
,'Shift_JIS'=>'Shift_JIS','EUC-JP'=>'EUC-JP');
case 'TIMEZONE':
$arr = _xls_timezones();
$arr = _xls_values_as_keys($arr);
return $arr;
case 'PRODUCT_SORT':
return array("Name" => _sp("Product Name") , "Code" => _sp("Product Code") , "SellWeb" => _sp("Price") , "InventoryTotal" => _sp("Inventory"));
case 'EMAIL_SMTP_SECURITY_MODE':
return array(0 => _sp("Autodetect") , 1 => _sp("Force No Security") , 2 => _sp("Force SSL") , 3 => _sp("Force TLS"));
case 'INVENTORY_DISPLAY_LEVEL':
return array('1' => _sp("With Messages Defined Below") , '' => _sp("Showing Actual Numbers Remaining"));
case 'STORE_IMAGE_LOCATION':
return array('DB'=>'Database' , 'FS' => 'File System');
default:
if(stristr($str , "return"))
return @eval($str);
}
return '';
}
public function GetHelperText($fieldKey){
if(!isset($this->helpers[$fieldKey]))
return '';
return htmlspecialchars($this->helpers[$fieldKey]) . '<br /> <br />' . _sp('Key') . ' : ' . $fieldKey;
}
public function btnSave_click($strFormId, $strControlId, $strParameter){
$values = array();
// $error = $this->objModule->check_config_fields($this->fields);
//
// if(!$error)
// return;
foreach($this->fields as $key=>$field){
$config = Configuration::LoadByKey($key);
if(!$config)
continue;
if($field instanceOf QTextBox){
$config->Value = $field->Text;
}elseif($field instanceof QListBox){
if($field->SelectionMode == QSelectionMode::Multiple)
$config->Value= implode("\n" , $field->SelectedValues);
else
$config->Value= $field->SelectedValue;
}elseif($field instanceof XLS_OnOff ){
$config->Value= $field->Checked;
}elseif($field instanceof QRadioButtonList ){
$config->Value = $field->SelectedValue;
}elseif($field instanceof QFileAsset )
$config->Value = $field->File;
$config->Save();
}
$this->btnCancel_click($strFormId, $strControlId, $strParameter);
}
public function btnCancel_click($strFormId, $strControlId, $strParameter){
$this->btnEdit->Visible = true;
$this->btnSave->Visible = false;
$this->btnCancel->Visible = false;
$this->EditMode = false;
$this->Refresh();
}
}
/* class xlsws_admin_store_config
* class to create the main configuration tab within the configuration section
* see xlsws_admin for more details
*/
class xlsws_admin_store_config extends xlsws_admin{
protected function Form_Create(){
parent::Form_Create();
$this->arrTabs = $GLOBALS['arrConfigTabs'];
$this->currentTab = 'store';
$this->configPnls['store'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Store , "configDone");
$this->configPnls['store']->Name = _sp('Store Information');
$this->configPnls['store']->Info = _sp('Store information (e.g. Contact details)');
$this->configPnls['local'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Localisation , "configDone");
$this->configPnls['local']->Name = _sp('Localization');
$this->configPnls['local']->Info = _sp('Geographical configuration for your store');
$this->configPnls['custreg'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::CustomerRegistration , "configDone");
$this->configPnls['custreg']->Name = _sp('Customer Registration');
$this->configPnls['custreg']->Info = _sp('Information required for customer registration');
}
}
/* class xlsws_admin_appear_config
* class to create the main appearance tab within the configuration section
* see xlsws_admin for more details
*/
class xlsws_admin_appear_config extends xlsws_admin{
protected function Form_Create(){
parent::Form_Create();
$this->arrTabs = $GLOBALS['arrConfigTabs'];
$this->currentTab = 'appear';
$this->configPnls['stemp'] = new xlsws_admin_config_panel($this , $this , 'DEFAULT_TEMPLATE' , "configDone");
$this->configPnls['stemp']->Name = _sp('Store Template');
$this->configPnls['stemp']->Info = _sp('Choose which template you would use for your store.');
$this->configPnls['himage'] = new xlsws_admin_config_panel($this , $this , 'HEADER_IMAGE' , "configDone");
$this->configPnls['himage']->Name = _sp('Header Image');
$this->configPnls['himage']->Info = _sp('Header image displayed in your webstore. Upload your logo or logo for webstore here.');
$this->configPnls['prods'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::ProductListing , "configDone");
$this->configPnls['prods']->Name = _sp('Products');
$this->configPnls['prods']->Info = _sp('Product Listing options');
$this->configPnls['stock'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Inventory , "configDone");
$this->configPnls['stock']->Name = _sp('Inventory');
$this->configPnls['stock']->Info = _sp('Inventory related options for your webstore');
$this->configPnls['image'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Images , "configDone");
$this->configPnls['image']->Name = _sp('Images');
$this->configPnls['image']->Info = _sp('Image dimentions and other image related options');
$this->configPnls['cart'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Cart , "configDone");
$this->configPnls['cart']->Name = _sp('Carts');
$this->configPnls['cart']->Info = _sp('Cart related options');
$this->configPnls['gr'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::GiftRegistry , "configDone");
$this->configPnls['gr']->Name = _sp('Wish List');
$this->configPnls['gr']->Info = _sp('Wish List related options');
}
}
/* class xlsws_admin_appear_config
* class to create the main system configuration section
* see xlsws_admin for more details
*/
class xlsws_admin_system_config extends xlsws_admin{
protected function Form_Create(){
parent::Form_Create();
$this->arrTabs = $GLOBALS['arrSystemTabs'];
$this->currentTab = 'config';
$this->configPnls['system'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::System , "configDone");
$this->configPnls['system']->Name = _sp('System Configuration');
$this->configPnls['system']->Info = _sp('System configurations for your web store.');
$this->configPnls['email'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Email , "configDone");
$this->configPnls['email']->Name = _sp('Email');
$this->configPnls['email']->Info = _sp('Email options for your webstore.');
$this->configPnls['security'] = new xlsws_admin_config_panel($this , $this , xlsws_config_types::Security , "configDone");
$this->configPnls['security']->Name = _sp('Security');
$this->configPnls['security']->Info = _sp('Secure your store.');
}
}
/* class xlsws_admin_appear_config
* class to create the main shipping configuration section
* see xlsws_admin for more details
*/
class xlsws_admin_ship_config extends xlsws_admin{
protected function Form_Create(){
parent::Form_Create();
$this->arrTabs = $GLOBALS['arrShipTabs'];
$this->currentTab = 'shipping';
$this->configPnls['defship'] = new xlsws_admin_config_panel($this , $this , 'SHIP_RESTRICT_DESTINATION' , "configDone");
$this->configPnls['defship']->Name = _sp('Restricted shipping');
$this->configPnls['defship']->Info = _sp('Only ship to restricted destinations?');
$this->configPnls['wunit'] = new xlsws_admin_config_panel($this , $this , 'WEIGHT_UNIT' , "configDone");
$this->configPnls['wunit']->Name = _sp('Weight Unit');
$this->configPnls['wunit']->Info = _sp('This is weight unit you are using for your products in LightSpeed. This unit will be used in shipping calculation.');
$this->configPnls['dunit'] = new xlsws_admin_config_panel($this , $this , 'DIMENSION_UNIT' , "configDone");
$this->configPnls['dunit']->Name = _sp('Dimension Unit');
$this->configPnls['dunit']->Info = _sp('This is dimension unit you are using for your products in LightSpeed. This unit will be used in shipping calculation.');
$shipTaxconfig = Configuration::LoadByKey('SHIPPING_TAXABLE');
if (! $shipTaxconfig)
{
_xls_insert_conf('SHIPPING_TAXABLE', _sp('Taxable shipping'), '0', _sp('This is used to enable tax calculations on shipping charges.'), 9, 'BOOL');
}
$this->configPnls['taxship'] = new xlsws_admin_config_panel($this , $this , 'SHIPPING_TAXABLE' , "configDone");
$this->configPnls['taxship']->Name = _sp('Taxable shipping');
$this->configPnls['taxship']->Info = _sp('This is used to enable tax calculations on shipping charges.');
}
}
/* xlsws_admin_load_module - loads a particular module you pass for the admin panel
* @param string - the source path of the module relative to your Web Store document root
* @param folder - the folder within the path the module lies in
* @return none
*/
function xlsws_admin_load_module( $source , $folder){
$rD = dir($source . $folder);
while (false!== ($filename = $rD->read())) {
if (substr($filename, -4) == '.php') { // whatever your includes extensions are
require_once $source . "$folder" . "$filename";
}
}
$rD->close();
}
xlsws_admin_load_module(XLSWS_INCLUDES , "sidebar/");
xlsws_admin_load_module(XLSWS_INCLUDES , "payment/");
xlsws_admin_load_module(XLSWS_INCLUDES , "shipping/");
xlsws_admin_load_module(CUSTOM_INCLUDES , "sidebar/");
xlsws_admin_load_module(CUSTOM_INCLUDES , "payment/");
xlsws_admin_load_module(CUSTOM_INCLUDES , "shipping/");
/* class xlsws_admin_modules_config
* class to create the main shipping and payment section
* see api.qcodo.com under Qpanel for configuration options
*/
class xlsws_admin_modules_config extends QPanel{
protected $objModule; //the loaded module as an object
protected $moduleRec; //the record used within the module itself
protected $strMethodCallBack; //the callback method used
public $fields;
protected $objParentObject;
public $EditMode = false;
public $ModId;
public $btnSave;
public $btnCancel;
public $btnConfig;
public $btnUp;
public $btnDown;
public $btnOnOff;
// Customize Look/Feel
//protected $strPadding = '10px';
//protected $strBackColor = '#fefece';
public $strFileLocation;
public function __construct($objParentControl, $modId, $moduleRec, $strFileLocation , $strMethodCallBack, $strControlId = null) {
// First, let's call the Parent's __constructor
try {
parent::__construct($objParentControl, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
// Next, we set the local module object
$this->objParentObject = $objParentControl;
$this->ModId = $modId;
// Let's record the reference to the form's MethodCallBack
$this->strMethodCallBack = $strMethodCallBack;
$this->strFileLocation = $strFileLocation;
$this->moduleRec = $moduleRec;
$this->load_module_obj();
$this->fields = $this->objModule->config_fields($this);
$this->btnSave = new QButton($this);
$this->btnSave->Text = _sp('Save');
$this->btnSave->AddAction(new QClickEvent() , new QServerControlAction($this , 'btnSave_click'));
$this->btnSave->CausesValidation = true;
$this->btnSave->Visible = false;
$this->btnCancel = new QButton($this);
$this->btnCancel->Text = _sp('Cancel');
$this->btnCancel->AddAction(new QClickEvent() , new QServerControlAction($this , 'btnCancel_click'));
$this->btnCancel->Visible = false;
$this->btnConfig = new QImageButton($this);
$this->btnConfig->ImageUrl = adminTemplate('css/images/btn_settings.png');
$this->btnConfig->CssClass = 'settings';
$this->btnConfig->AddAction(new QClickEvent(), new QServerControlAction($this , 'btnConfig_click'));
$this->btnConfig->CausesValidation = false;
$this->btnConfig->Visible = true;
$this->btnUp = new QImageButton($this);
$this->btnUp->ActionParameter = $this->ModId;
$this->btnUp->CausesValidation = false;
$this->btnDown = new QImageButton($this);
$this->btnDown->ActionParameter = $this->ModId;
$this->btnDown->CausesValidation = false;
// we only enable sorting when the module is enabled because, rather than having a
// sensible 'enabled' flag, the code just *removes* modules from the db when they
// are disabled! In that case, our up/down actions cause horrible white page of death.
if ($this->objParentObject->modules[$this->ModId]['enabled'])
{
$this->btnUp->ImageUrl = adminTemplate('css/images/btn_up.png');
$this->btnUp->AddAction(new QClickEvent(), new QServerAction('butMoveUpModule_Click'));