|
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 sb_google_plus_one { |
|
18
|
|
|
var $code = 'sb_google_plus_one'; |
|
19
|
|
|
var $title; |
|
20
|
|
|
var $description; |
|
21
|
|
|
var $sort_order; |
|
22
|
|
|
var $icon; |
|
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_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_TITLE; |
|
31
|
|
|
$this->public_title = MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_PUBLIC_TITLE; |
|
|
|
|
|
|
32
|
|
|
$this->description = MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_DESCRIPTION; |
|
33
|
|
|
|
|
34
|
|
|
if ( defined('MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_STATUS') ) { |
|
35
|
|
|
$this->sort_order = MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SORT_ORDER; |
|
36
|
|
|
$this->enabled = (MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_STATUS == 'True'); |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function getOutput() { |
|
41
|
|
|
$output = '<div class="g-plusone" data-href="' . OSCOM::link('product_info.php', 'products_id=' . $_GET['products_id'], false) . '" data-size="' . strtolower(MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SIZE) . '" data-annotation="' . strtolower(MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ANNOTATION) . '"'; |
|
42
|
|
|
|
|
43
|
|
|
if (MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ANNOTATION == 'Inline') { |
|
44
|
|
|
$output.= ' data-width="' . (int)MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_WIDTH . '" data-align="' . strtolower(MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ALIGN) . '"'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$output .= '></div>'; |
|
48
|
|
|
|
|
49
|
|
|
$output .= '<script> |
|
50
|
|
|
if ( typeof window.___gcfg == "undefined" ) { |
|
51
|
|
|
window.___gcfg = { }; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ( typeof window.___gcfg.lang == "undefined" ) { |
|
55
|
|
|
window.___gcfg.lang = "' . HTML::outputProtected($this->lang->get('code')) . '"; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
(function() { |
|
59
|
|
|
var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true; |
|
60
|
|
|
po.src = \'https://apis.google.com/js/plusone.js\'; |
|
61
|
|
|
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s); |
|
62
|
|
|
})(); |
|
63
|
|
|
</script>'; |
|
64
|
|
|
|
|
65
|
|
|
return $output; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
function isEnabled() { |
|
69
|
|
|
return $this->enabled; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
function getIcon() { |
|
73
|
|
|
return $this->icon; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
function getPublicTitle() { |
|
77
|
|
|
return $this->public_title; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
function check() { |
|
81
|
|
|
return defined('MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_STATUS'); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
View Code Duplication |
function install() { |
|
|
|
|
|
|
85
|
|
|
$OSCOM_Db = Registry::get('Db'); |
|
86
|
|
|
|
|
87
|
|
|
$OSCOM_Db->save('configuration', [ |
|
88
|
|
|
'configuration_title' => 'Enable Google+ +1 Button Module', |
|
89
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_STATUS', |
|
90
|
|
|
'configuration_value' => 'True', |
|
91
|
|
|
'configuration_description' => 'Do you want to allow products to be recommended through Google+ +1 Button?', |
|
92
|
|
|
'configuration_group_id' => '6', |
|
93
|
|
|
'sort_order' => '1', |
|
94
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'True\', \'False\'), ', |
|
95
|
|
|
'date_added' => 'now()' |
|
96
|
|
|
]); |
|
97
|
|
|
|
|
98
|
|
|
$OSCOM_Db->save('configuration', [ |
|
99
|
|
|
'configuration_title' => 'Button Size', |
|
100
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SIZE', |
|
101
|
|
|
'configuration_value' => 'Small', |
|
102
|
|
|
'configuration_description' => 'Sets the size of the button.', |
|
103
|
|
|
'configuration_group_id' => '6', |
|
104
|
|
|
'sort_order' => '1', |
|
105
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'Small\', \'Medium\', \'Standard\', \'Tall\'), ', |
|
106
|
|
|
'date_added' => 'now()' |
|
107
|
|
|
]); |
|
108
|
|
|
|
|
109
|
|
|
$OSCOM_Db->save('configuration', [ |
|
110
|
|
|
'configuration_title' => 'Annotation', |
|
111
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ANNOTATION', |
|
112
|
|
|
'configuration_value' => 'None', |
|
113
|
|
|
'configuration_description' => 'The annotation to display next to the button.', |
|
114
|
|
|
'configuration_group_id' => '6', |
|
115
|
|
|
'sort_order' => '1', |
|
116
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'None\', \'Bubble\', \'Inline\'), ', |
|
117
|
|
|
'date_added' => 'now()' |
|
118
|
|
|
]); |
|
119
|
|
|
|
|
120
|
|
|
$OSCOM_Db->save('configuration', [ |
|
121
|
|
|
'configuration_title' => 'Inline Width', |
|
122
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_WIDTH', |
|
123
|
|
|
'configuration_value' => '120', |
|
124
|
|
|
'configuration_description' => 'The width of the inline annotation in pixels (minimum 120).', |
|
125
|
|
|
'configuration_group_id' => '6', |
|
126
|
|
|
'sort_order' => '1', |
|
127
|
|
|
'date_added' => 'now()' |
|
128
|
|
|
]); |
|
129
|
|
|
|
|
130
|
|
|
$OSCOM_Db->save('configuration', [ |
|
131
|
|
|
'configuration_title' => 'Inline Alignment', |
|
132
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ALIGN', |
|
133
|
|
|
'configuration_value' => 'Left', |
|
134
|
|
|
'configuration_description' => 'The alignment of the inline annotation.', |
|
135
|
|
|
'configuration_group_id' => '6', |
|
136
|
|
|
'sort_order' => '1', |
|
137
|
|
|
'set_function' => 'tep_cfg_select_option(array(\'Left\', \'Right\'), ', |
|
138
|
|
|
'date_added' => 'now()' |
|
139
|
|
|
]); |
|
140
|
|
|
|
|
141
|
|
|
$OSCOM_Db->save('configuration', [ |
|
142
|
|
|
'configuration_title' => 'Sort Order', |
|
143
|
|
|
'configuration_key' => 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SORT_ORDER', |
|
144
|
|
|
'configuration_value' => '0', |
|
145
|
|
|
'configuration_description' => 'Sort order of display. Lowest is displayed first.', |
|
146
|
|
|
'configuration_group_id' => '6', |
|
147
|
|
|
'sort_order' => '0', |
|
148
|
|
|
'date_added' => 'now()' |
|
149
|
|
|
]); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
function remove() { |
|
153
|
|
|
return Registry::get('Db')->exec('delete from :table_configuration where configuration_key in ("' . implode('", "', $this->keys()) . '")'); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
function keys() { |
|
157
|
|
|
return array('MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_STATUS', 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SIZE', 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ANNOTATION', 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_WIDTH', 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_ALIGN', 'MODULE_SOCIAL_BOOKMARKS_GOOGLE_PLUS_ONE_SORT_ORDER'); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
?> |
|
|
|
|
|
|
161
|
|
|
|
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.