|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
$Id$ |
|
4
|
|
|
|
|
5
|
|
|
osCommerce, Open Source E-Commerce Solutions |
|
6
|
|
|
http://www.oscommerce.com |
|
7
|
|
|
|
|
8
|
|
|
Copyright (c) 2015 osCommerce |
|
9
|
|
|
|
|
10
|
|
|
Released under the GNU General Public License |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
use OSC\OM\HTML; |
|
14
|
|
|
use OSC\OM\OSCOM; |
|
15
|
|
|
use OSC\OM\Registry; |
|
16
|
|
|
|
|
17
|
|
|
class bm_languages { |
|
18
|
|
|
var $code = 'bm_languages'; |
|
19
|
|
|
var $group = 'boxes'; |
|
20
|
|
|
var $title; |
|
21
|
|
|
var $description; |
|
22
|
|
|
var $sort_order; |
|
23
|
|
|
var $enabled = false; |
|
24
|
|
|
|
|
25
|
|
|
protected $lang; |
|
26
|
|
|
|
|
27
|
|
View Code Duplication |
function __construct() { |
|
|
|
|
|
|
28
|
|
|
$this->lang = Registry::get('Language'); |
|
29
|
|
|
|
|
30
|
|
|
$this->title = MODULE_BOXES_LANGUAGES_TITLE; |
|
31
|
|
|
$this->description = MODULE_BOXES_LANGUAGES_DESCRIPTION; |
|
32
|
|
|
|
|
33
|
|
|
if ( defined('MODULE_BOXES_LANGUAGES_STATUS') ) { |
|
34
|
|
|
$this->sort_order = MODULE_BOXES_LANGUAGES_SORT_ORDER; |
|
35
|
|
|
$this->enabled = (MODULE_BOXES_LANGUAGES_STATUS == 'True'); |
|
36
|
|
|
|
|
37
|
|
|
$this->group = ((MODULE_BOXES_LANGUAGES_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right'); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function execute() { |
|
42
|
|
|
global $PHP_SELF, $oscTemplate; |
|
43
|
|
|
|
|
44
|
|
|
if (substr(basename($PHP_SELF), 0, 8) != 'checkout') { |
|
45
|
|
|
$languages = $this->lang->getAll(); |
|
46
|
|
|
|
|
47
|
|
|
if (count($languages) > 1) { |
|
48
|
|
|
$languages_string = ''; |
|
49
|
|
|
|
|
50
|
|
|
foreach ($languages as $code => $value) { |
|
51
|
|
|
$languages_string .= ' <a href="' . OSCOM::link($PHP_SELF, tep_get_all_get_params(array('language', 'currency')) . 'language=' . $code) . '">' . HTML::image('includes/languages/' . $value['directory'] . '/images/' . $value['image'], $value['name'], NULL, NULL, NULL, false) . '</a> '; |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
ob_start(); |
|
55
|
|
|
include('includes/modules/boxes/templates/languages.php'); |
|
56
|
|
|
$data = ob_get_clean(); |
|
57
|
|
|
|
|
58
|
|
|
$oscTemplate->addBlock($data, $this->group); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
function isEnabled() { |
|
64
|
|
|
return $this->enabled; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function check() { |
|
68
|
|
|
return defined('MODULE_BOXES_LANGUAGES_STATUS'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
function install() { |
|
72
|
|
|
$OSCOM_Db = Registry::get('Db'); |
|
73
|
|
|
|
|
74
|
|
|
$OSCOM_Db->save('configuration', [ |
|
75
|
|
|
'configuration_title' => 'Enable Languages Module', |
|
76
|
|
|
'configuration_key' => 'MODULE_BOXES_LANGUAGES_STATUS', |
|
77
|
|
|
'configuration_value' => 'True', |
|
78
|
|
|
'configuration_description' => 'Do you want to add the module to your shop?', |
|
79
|
|
|
'configuration_group_id' => '6', |
|
80
|
|
|
'sort_order' => '1', |
|
81
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'True\', \'False\'), ', |
|
82
|
|
|
'date_added' => 'now()' |
|
83
|
|
|
]); |
|
84
|
|
|
|
|
85
|
|
|
$OSCOM_Db->save('configuration', [ |
|
86
|
|
|
'configuration_title' => 'Content Placement', |
|
87
|
|
|
'configuration_key' => 'MODULE_BOXES_LANGUAGES_CONTENT_PLACEMENT', |
|
88
|
|
|
'configuration_value' => 'Right Column', |
|
89
|
|
|
'configuration_description' => 'Should the module be loaded in the left or right column?', |
|
90
|
|
|
'configuration_group_id' => '6', |
|
91
|
|
|
'sort_order' => '1', |
|
92
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', |
|
93
|
|
|
'date_added' => 'now()' |
|
94
|
|
|
]); |
|
95
|
|
|
|
|
96
|
|
|
$OSCOM_Db->save('configuration', [ |
|
97
|
|
|
'configuration_title' => 'Sort Order', |
|
98
|
|
|
'configuration_key' => 'MODULE_BOXES_LANGUAGES_SORT_ORDER', |
|
99
|
|
|
'configuration_value' => '0', |
|
100
|
|
|
'configuration_description' => 'Sort order of display. Lowest is displayed first.', |
|
101
|
|
|
'configuration_group_id' => '6', |
|
102
|
|
|
'sort_order' => '0', |
|
103
|
|
|
'date_added' => 'now()' |
|
104
|
|
|
]); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
function remove() { |
|
108
|
|
|
return Registry::get('Db')->exec('delete from :table_configuration where configuration_key in ("' . implode('", "', $this->keys()) . '")'); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
function keys() { |
|
112
|
|
|
return array('MODULE_BOXES_LANGUAGES_STATUS', 'MODULE_BOXES_LANGUAGES_CONTENT_PLACEMENT', 'MODULE_BOXES_LANGUAGES_SORT_ORDER'); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.