Completed
Push — master ( 88111b...b3fce7 )
by Michael
05:58
created
class/PersistableMlObjectHandler.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -21,60 +21,60 @@
 block discarded – undo
21 21
  */
22 22
 class PersistableMlObjectHandler extends Smartobject\PersistableObjectHandler
23 23
 {
24
-    /**
25
-     * @param  null|\CriteriaElement  $criteria
26
-     * @param  bool $id_as_key
27
-     * @param  bool $as_object
28
-     * @param  bool $debug
29
-     * @param  bool $language
30
-     * @return array
31
-     */
32
-    public function getObjects(
33
-        \CriteriaElement $criteria = null,
34
-        $id_as_key = false,
35
-        $as_object = true,
36
-        $debug = false,
37
-        $language = false
38
-    ) {
39
-        // Create the first part of the SQL query to join the "_text" table
40
-        $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName;
24
+	/**
25
+	 * @param  null|\CriteriaElement  $criteria
26
+	 * @param  bool $id_as_key
27
+	 * @param  bool $as_object
28
+	 * @param  bool $debug
29
+	 * @param  bool $language
30
+	 * @return array
31
+	 */
32
+	public function getObjects(
33
+		\CriteriaElement $criteria = null,
34
+		$id_as_key = false,
35
+		$as_object = true,
36
+		$debug = false,
37
+		$language = false
38
+	) {
39
+		// Create the first part of the SQL query to join the "_text" table
40
+		$sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName;
41 41
 
42
-        if ($language) {
43
-            // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language
42
+		if ($language) {
43
+			// If a language was specified, then let's create a WHERE clause to only return the objects associated with this language
44 44
 
45
-            // if no criteria was previously created, let's create it
46
-            if (!$criteria) {
47
-                $criteria = new \CriteriaCompo();
48
-            }
49
-            $criteria->add(new \Criteria('language', $language));
45
+			// if no criteria was previously created, let's create it
46
+			if (!$criteria) {
47
+				$criteria = new \CriteriaCompo();
48
+			}
49
+			$criteria->add(new \Criteria('language', $language));
50 50
 
51
-            return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
52
-        }
51
+			return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
52
+		}
53 53
 
54
-        return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
55
-    }
54
+		return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
55
+	}
56 56
 
57
-    /**
58
-     * @param  mixed $id
59
-     * @param  bool  $language
60
-     * @param  bool  $as_object
61
-     * @param  bool  $debug
62
-     * @return mixed
63
-     */
64
-    public function &get($id, $language = false, $as_object = true, $debug = false)
65
-    {
66
-        if (!$language) {
67
-            return parent::get($id, $as_object, $debug);
68
-        } else {
69
-            $criteria = new \CriteriaCompo();
70
-            $criteria->add(new \Criteria('language', $language));
57
+	/**
58
+	 * @param  mixed $id
59
+	 * @param  bool  $language
60
+	 * @param  bool  $as_object
61
+	 * @param  bool  $debug
62
+	 * @return mixed
63
+	 */
64
+	public function &get($id, $language = false, $as_object = true, $debug = false)
65
+	{
66
+		if (!$language) {
67
+			return parent::get($id, $as_object, $debug);
68
+		} else {
69
+			$criteria = new \CriteriaCompo();
70
+			$criteria->add(new \Criteria('language', $language));
71 71
 
72
-            return parent::get($id, $as_object, $debug, $criteria);
73
-        }
74
-    }
72
+			return parent::get($id, $as_object, $debug, $criteria);
73
+		}
74
+	}
75 75
 
76
-    public function changeTableNameForML()
77
-    {
78
-        $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text');
79
-    }
76
+	public function changeTableNameForML()
77
+	{
78
+		$this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text');
79
+	}
80 80
 }
Please login to merge, or discard this patch.
blocks/addto.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function smartobject_addto_show($options)
10 10
 {
11
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
11
+	require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
12 12
 //    require_once SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php';
13
-    $smartaddto = new XoopsModules\Smartobject\AddTo($options[0]);
14
-    $block      = $smartaddto->renderForBlock();
13
+	$smartaddto = new XoopsModules\Smartobject\AddTo($options[0]);
14
+	$block      = $smartaddto->renderForBlock();
15 15
 
16
-    return $block;
16
+	return $block;
17 17
 }
18 18
 
19 19
 /**
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function smartobject_addto_edit($options)
24 24
 {
25
-    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
25
+	require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
26 26
 
27
-    $form = '';
27
+	$form = '';
28 28
 
29
-    $layout_select = new \XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]);
30
-    $layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0);
31
-    $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1);
32
-    $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2);
33
-    $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3);
34
-    $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br>';
29
+	$layout_select = new \XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]);
30
+	$layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0);
31
+	$layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1);
32
+	$layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2);
33
+	$layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3);
34
+	$form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br>';
35 35
 
36
-    return $form;
36
+	return $form;
37 37
 }
Please login to merge, or discard this patch.
include/update.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -28,26 +28,26 @@  discard block
 block discarded – undo
28 28
  */
29 29
 function xoops_module_update_smartobject(\XoopsModule $module)
30 30
 {
31
-    ob_start();
31
+	ob_start();
32 32
 
33
-    $dbVersion = Smartobject\Utility::getMeta('version', 'smartobject');
34
-    if (!$dbVersion) {
35
-        $dbVersion = 0;
36
-    }
33
+	$dbVersion = Smartobject\Utility::getMeta('version', 'smartobject');
34
+	if (!$dbVersion) {
35
+		$dbVersion = 0;
36
+	}
37 37
 
38
-    $dbupdater = new XoopsModules\Smartobject\Dbupdater();
38
+	$dbupdater = new XoopsModules\Smartobject\Dbupdater();
39 39
 
40
-    echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br>';
40
+	echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br>';
41 41
 
42
-    // db migrate version = 1
43
-    $newDbVersion = 1;
44
-    if ($dbVersion < $newDbVersion) {
45
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
42
+	// db migrate version = 1
43
+	$newDbVersion = 1;
44
+	if ($dbVersion < $newDbVersion) {
45
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
46 46
 
47
-        // Create table smartobject_link
48
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_link');
49
-        if (!$table->exists()) {
50
-            $table->setStructure("CREATE TABLE `%s` (
47
+		// Create table smartobject_link
48
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_link');
49
+		if (!$table->exists()) {
50
+			$table->setStructure("CREATE TABLE `%s` (
51 51
               `linkid` int(11) NOT NULL auto_increment,
52 52
               `from_uid` int(11) NOT NULL default '0',
53 53
               `from_email` varchar(255) NOT NULL default '',
@@ -64,63 +64,63 @@  discard block
 block discarded – undo
64 64
               PRIMARY KEY  (`linkid`)
65 65
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
66 66
 
67
-            if (!$dbupdater->updateTable($table)) {
68
-                /**
69
-                 * @todo trap the errors
70
-                 */
71
-            }
72
-        }
73
-        unset($table);
74
-        // Create table smartobject_link
75
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_link');
76
-        if (!$table->fieldExists('date')) {
77
-            $table->addNewField('date', "int(11) NOT NULL default '0'");
78
-            if (!$dbupdater->updateTable($table)) {
79
-                /**
80
-                 * @todo trap the errors
81
-                 */
82
-            }
83
-        }
84
-        unset($table);
85
-
86
-        // Create table smartobject_tag
87
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_tag');
88
-        if (!$table->exists()) {
89
-            $table->setStructure("CREATE TABLE %s (
67
+			if (!$dbupdater->updateTable($table)) {
68
+				/**
69
+				 * @todo trap the errors
70
+				 */
71
+			}
72
+		}
73
+		unset($table);
74
+		// Create table smartobject_link
75
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_link');
76
+		if (!$table->fieldExists('date')) {
77
+			$table->addNewField('date', "int(11) NOT NULL default '0'");
78
+			if (!$dbupdater->updateTable($table)) {
79
+				/**
80
+				 * @todo trap the errors
81
+				 */
82
+			}
83
+		}
84
+		unset($table);
85
+
86
+		// Create table smartobject_tag
87
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_tag');
88
+		if (!$table->exists()) {
89
+			$table->setStructure("CREATE TABLE %s (
90 90
               `tagid` int(11) NOT NULL auto_increment,
91 91
               `name` varchar(255) NOT NULL default '',
92 92
               `description` TEXT NOT NULL,
93 93
               PRIMARY KEY  (`id`)
94 94
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
95 95
 
96
-            if (!$dbupdater->updateTable($table)) {
97
-                /**
98
-                 * @todo trap the errors
99
-                 */
100
-            }
101
-        }
102
-
103
-        // Create table smartobject_tag_text
104
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_tag_text');
105
-        if (!$table->exists()) {
106
-            $table->setStructure("CREATE TABLE %s (
96
+			if (!$dbupdater->updateTable($table)) {
97
+				/**
98
+				 * @todo trap the errors
99
+				 */
100
+			}
101
+		}
102
+
103
+		// Create table smartobject_tag_text
104
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_tag_text');
105
+		if (!$table->exists()) {
106
+			$table->setStructure("CREATE TABLE %s (
107 107
               `tagid` int(11) NOT NULL default 0,
108 108
               `language` varchar(255) NOT NULL default '',
109 109
               `value` TEXT NOT NULL,
110 110
               PRIMARY KEY  (`id`, `language`)
111 111
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
112 112
 
113
-            if (!$dbupdater->updateTable($table)) {
114
-                /**
115
-                 * @todo trap the errors
116
-                 */
117
-            }
118
-        }
119
-
120
-        // Create table smartobject_adsense
121
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_adsense');
122
-        if (!$table->exists()) {
123
-            $table->setStructure("
113
+			if (!$dbupdater->updateTable($table)) {
114
+				/**
115
+				 * @todo trap the errors
116
+				 */
117
+			}
118
+		}
119
+
120
+		// Create table smartobject_adsense
121
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_adsense');
122
+		if (!$table->exists()) {
123
+			$table->setStructure("
124 124
   `adsenseid` int(11) NOT NULL auto_increment,
125 125
   `format` VARCHAR(100) NOT NULL,
126 126
   `description` TEXT NOT NULL,
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
   `tag` varchar(50) NOT NULL default '',
135 135
   PRIMARY KEY  (`adsenseid`)
136 136
             ");
137
-        }
138
-
139
-        if (!$dbupdater->updateTable($table)) {
140
-            /**
141
-             * @todo trap the errors
142
-             */
143
-        }
144
-    }
145
-    // db migrate version = 2
146
-    $newDbVersion = 2;
147
-    if ($dbVersion < $newDbVersion) {
148
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
149
-
150
-        // Create table smartobject_rating
151
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_rating');
152
-        if (!$table->exists()) {
153
-            $table->setStructure('
137
+		}
138
+
139
+		if (!$dbupdater->updateTable($table)) {
140
+			/**
141
+			 * @todo trap the errors
142
+			 */
143
+		}
144
+	}
145
+	// db migrate version = 2
146
+	$newDbVersion = 2;
147
+	if ($dbVersion < $newDbVersion) {
148
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
149
+
150
+		// Create table smartobject_rating
151
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_rating');
152
+		if (!$table->exists()) {
153
+			$table->setStructure('
154 154
   `ratingid` int(11) NOT NULL auto_increment,
155 155
   `dirname` VARCHAR(255) NOT NULL,
156 156
   `item` VARCHAR(255) NOT NULL,
@@ -161,36 +161,36 @@  discard block
 block discarded – undo
161 161
   PRIMARY KEY  (`ratingid`),
162 162
   UNIQUE (`dirname`, `item`, `itemid`, `uid`)
163 163
             ');
164
-        }
165
-
166
-        if (!$dbupdater->updateTable($table)) {
167
-            /**
168
-             * @todo trap the errors
169
-             */
170
-        }
171
-
172
-        // Create table smartobject_currency
173
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_currency');
174
-        $table->setData("2, 'EUR', 'Euro', '�', 0.65, 0");
175
-        $table->setData("3, 'USD', 'American dollar', '$', 0.9, 0");
176
-        $table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1");
177
-
178
-        if (!$dbupdater->updateTable($table)) {
179
-            /**
180
-             * @todo trap the errors
181
-             */
182
-        }
183
-    }
184
-
185
-    // db migrate version = 3
186
-    $newDbVersion = 3;
187
-    if ($dbVersion < $newDbVersion) {
188
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
189
-
190
-        // Create table smartobject_customtag
191
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_customtag');
192
-        if (!$table->exists()) {
193
-            $table->setStructure('
164
+		}
165
+
166
+		if (!$dbupdater->updateTable($table)) {
167
+			/**
168
+			 * @todo trap the errors
169
+			 */
170
+		}
171
+
172
+		// Create table smartobject_currency
173
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_currency');
174
+		$table->setData("2, 'EUR', 'Euro', '�', 0.65, 0");
175
+		$table->setData("3, 'USD', 'American dollar', '$', 0.9, 0");
176
+		$table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1");
177
+
178
+		if (!$dbupdater->updateTable($table)) {
179
+			/**
180
+			 * @todo trap the errors
181
+			 */
182
+		}
183
+	}
184
+
185
+	// db migrate version = 3
186
+	$newDbVersion = 3;
187
+	if ($dbVersion < $newDbVersion) {
188
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
189
+
190
+		// Create table smartobject_customtag
191
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_customtag');
192
+		if (!$table->exists()) {
193
+			$table->setStructure('
194 194
               `customtagid` int(11) NOT NULL auto_increment,
195 195
               `name` VARCHAR(255) NOT NULL,
196 196
               `description` TEXT NOT NULL,
@@ -198,24 +198,24 @@  discard block
 block discarded – undo
198 198
               `language` TEXT NOT NULL,
199 199
               PRIMARY KEY  (`customtagid`)
200 200
             ');
201
-        }
202
-
203
-        if (!$dbupdater->updateTable($table)) {
204
-            /**
205
-             * @todo trap the errors
206
-             */
207
-        }
208
-    }
209
-
210
-    // db migrate version = 4
211
-    $newDbVersion = 4;
212
-    if ($dbVersion < $newDbVersion) {
213
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
214
-
215
-        // Create table smartobject_currency
216
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_currency');
217
-        if (!$table->exists()) {
218
-            $table->setStructure('
201
+		}
202
+
203
+		if (!$dbupdater->updateTable($table)) {
204
+			/**
205
+			 * @todo trap the errors
206
+			 */
207
+		}
208
+	}
209
+
210
+	// db migrate version = 4
211
+	$newDbVersion = 4;
212
+	if ($dbVersion < $newDbVersion) {
213
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
214
+
215
+		// Create table smartobject_currency
216
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_currency');
217
+		if (!$table->exists()) {
218
+			$table->setStructure('
219 219
               `currencyid` int(11) NOT NULL auto_increment,
220 220
               `iso4217` VARCHAR(5) NOT NULL,
221 221
               `name` VARCHAR(255) NOT NULL,
@@ -224,46 +224,46 @@  discard block
 block discarded – undo
224 224
               `default_currency` int(1) NOT NULL,
225 225
               PRIMARY KEY  (`currencyid`)
226 226
             ');
227
-        }
228
-
229
-        if (!$dbupdater->updateTable($table)) {
230
-            /**
231
-             * @todo trap the errors
232
-             */
233
-        }
234
-    }
235
-
236
-    // db migrate version = 6
237
-    $newDbVersion = 6;
238
-    if ($dbVersion < $newDbVersion) {
239
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
240
-    }
241
-
242
-    $newDbVersion = 7;
243
-    if ($dbVersion < $newDbVersion) {
244
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
245
-
246
-        // Create table smartobject_file
247
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_file');
248
-        if (!$table->exists()) {
249
-            $table->setStructure('
227
+		}
228
+
229
+		if (!$dbupdater->updateTable($table)) {
230
+			/**
231
+			 * @todo trap the errors
232
+			 */
233
+		}
234
+	}
235
+
236
+	// db migrate version = 6
237
+	$newDbVersion = 6;
238
+	if ($dbVersion < $newDbVersion) {
239
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
240
+	}
241
+
242
+	$newDbVersion = 7;
243
+	if ($dbVersion < $newDbVersion) {
244
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
245
+
246
+		// Create table smartobject_file
247
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_file');
248
+		if (!$table->exists()) {
249
+			$table->setStructure('
250 250
               `fileid` int(11) NOT NULL auto_increment,
251 251
               `caption` varchar(255) collate latin1_general_ci NOT NULL,
252 252
               `url` varchar(255) collate latin1_general_ci NOT NULL,
253 253
               `description` text collate latin1_general_ci NOT NULL,
254 254
                PRIMARY KEY  (`fileid`)
255 255
             ');
256
-            if (!$dbupdater->updateTable($table)) {
257
-                /**
258
-                 * @todo trap the errors
259
-                 */
260
-            }
261
-        }
262
-        unset($table);
263
-        // Create table smartobject_urllink
264
-        $table = new XoopsModules\Smartobject\DbTable('smartobject_urllink');
265
-        if (!$table->exists()) {
266
-            $table->setStructure('
256
+			if (!$dbupdater->updateTable($table)) {
257
+				/**
258
+				 * @todo trap the errors
259
+				 */
260
+			}
261
+		}
262
+		unset($table);
263
+		// Create table smartobject_urllink
264
+		$table = new XoopsModules\Smartobject\DbTable('smartobject_urllink');
265
+		if (!$table->exists()) {
266
+			$table->setStructure('
267 267
               `urllinkid` int(11) NOT NULL auto_increment,
268 268
               `caption` varchar(255) collate latin1_general_ci NOT NULL,
269 269
               `url` varchar(255) collate latin1_general_ci NOT NULL,
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
               `target` varchar(10) collate latin1_general_ci NOT NULL,
272 272
                 PRIMARY KEY  (`urllinkid`)
273 273
             ');
274
-            if (!$dbupdater->updateTable($table)) {
275
-                /**
276
-                 * @todo trap the errors
277
-                 */
278
-            }
279
-        }
280
-        unset($table);
281
-    }
282
-    echo '</code>';
283
-
284
-    $feedback = ob_get_clean();
285
-    if (method_exists($module, 'setMessage')) {
286
-        $module->setMessage($feedback);
287
-    } else {
288
-        echo $feedback;
289
-    }
290
-    Smartobject\Utility::setMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current
291
-
292
-    return true;
274
+			if (!$dbupdater->updateTable($table)) {
275
+				/**
276
+				 * @todo trap the errors
277
+				 */
278
+			}
279
+		}
280
+		unset($table);
281
+	}
282
+	echo '</code>';
283
+
284
+	$feedback = ob_get_clean();
285
+	if (method_exists($module, 'setMessage')) {
286
+		$module->setMessage($feedback);
287
+	} else {
288
+		echo $feedback;
289
+	}
290
+	Smartobject\Utility::setMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current
291
+
292
+	return true;
293 293
 }
294 294
 
295 295
 /**
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
  */
299 299
 function xoops_module_install_smartobject(\XoopsModule $module)
300 300
 {
301
-    ob_start();
301
+	ob_start();
302 302
 
303
-    echo 'Using the ImpressCMS onInstall event';
304
-    $feedback = ob_get_clean();
303
+	echo 'Using the ImpressCMS onInstall event';
304
+	$feedback = ob_get_clean();
305 305
 
306
-    return $feedback;
306
+	return $feedback;
307 307
 }
Please login to merge, or discard this patch.
include/adsense.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 
14 14
 function smart_adsense_initiate_smartytags()
15 15
 {
16
-    global $xoopsTpl, $smartobjectAdsenseHandler;
17
-    if (is_object($xoopsTpl)) {
18
-        foreach ($smartobjectAdsenseHandler->objects as $k => $v) {
19
-            $xoopsTpl->assign('adsense_' . $k, $v->render());
20
-        }
21
-    }
16
+	global $xoopsTpl, $smartobjectAdsenseHandler;
17
+	if (is_object($xoopsTpl)) {
18
+		foreach ($smartobjectAdsenseHandler->objects as $k => $v) {
19
+			$xoopsTpl->assign('adsense_' . $k, $v->render());
20
+		}
21
+	}
22 22
 }
23 23
 
24 24
 if (!defined('SMARTOBJECT_URL')) {
25
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
25
+	require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
26 26
 }
27 27
 
28 28
 //require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/functions.php';
Please login to merge, or discard this patch.
include/rating.rate.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use XoopsModules\Smartobject\PluginHandler;
13 13
 
14 14
 if (!defined('SMARTOBJECT_URL')) {
15
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
15
+	require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
16 16
 }
17 17
 //require_once SMARTOBJECT_ROOT_PATH . 'class/rating.php';
18 18
 //require_once SMARTOBJECT_ROOT_PATH . 'include/functions.php';
@@ -26,52 +26,52 @@  discard block
 block discarded – undo
26 26
 $smartobjectPluginHandler = new XoopsModules\Smartobject\PluginHandler();
27 27
 $pluginObj                = $smartobjectPluginHandler->getPlugin($module_dirname);
28 28
 if ($pluginObj) {
29
-    $rating_item = $pluginObj->getItem();
30
-    if ($rating_item) {
31
-        $rating_itemid = $pluginObj->getItemIdForItem($rating_item);
32
-        $stats         = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item);
33
-        $xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']);
34
-        $xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']);
35
-        $xoopsTpl->assign('smartobject_rating_item', $rating_item);
36
-        if (is_object($xoopsUser)) {
37
-            $ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid'));
38
-            $xoopsTpl->assign('smartobject_user_can_rate', true);
39
-        }
40
-        if (isset($ratingObj) && is_object($ratingObj)) {
41
-            $xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate'));
42
-            $xoopsTpl->assign('smartobject_rated', true);
43
-        } else {
44
-            $xoopsTpl->assign('smartobject_rating_dirname', $module_dirname);
45
-            $xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid);
46
-            $urls = Smartobject\Utility::getCurrentUrls();
47
-            $xoopsTpl->assign('smartobject_rating_current_page', $urls['full']);
48
-            if (isset($xoTheme) && is_object($xoTheme)) {
49
-                $xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css');
50
-            } else {
51
-                //probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme
52
-                //$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css'>");
53
-            }
54
-        }
55
-    }
29
+	$rating_item = $pluginObj->getItem();
30
+	if ($rating_item) {
31
+		$rating_itemid = $pluginObj->getItemIdForItem($rating_item);
32
+		$stats         = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item);
33
+		$xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']);
34
+		$xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']);
35
+		$xoopsTpl->assign('smartobject_rating_item', $rating_item);
36
+		if (is_object($xoopsUser)) {
37
+			$ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid'));
38
+			$xoopsTpl->assign('smartobject_user_can_rate', true);
39
+		}
40
+		if (isset($ratingObj) && is_object($ratingObj)) {
41
+			$xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate'));
42
+			$xoopsTpl->assign('smartobject_rated', true);
43
+		} else {
44
+			$xoopsTpl->assign('smartobject_rating_dirname', $module_dirname);
45
+			$xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid);
46
+			$urls = Smartobject\Utility::getCurrentUrls();
47
+			$xoopsTpl->assign('smartobject_rating_current_page', $urls['full']);
48
+			if (isset($xoTheme) && is_object($xoTheme)) {
49
+				$xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css');
50
+			} else {
51
+				//probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme
52
+				//$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css'>");
53
+			}
54
+		}
55
+	}
56 56
 }
57 57
 
58 58
 if (isset($_POST['smartobject_rating_submit'])) {
59
-    // The rating form has just been posted. Let's save the info
60
-    $ratingObj = $smartobjectRatingHandler->create();
61
-    $ratingObj->setVar('dirname', $module_dirname);
62
-    $ratingObj->setVar('item', $rating_item);
63
-    $ratingObj->setVar('itemid', $rating_itemid);
64
-    $ratingObj->setVar('uid', $xoopsUser->getVar('uid'));
65
-    $ratingObj->setVar('date', time());
66
-    $ratingObj->setVar('rate', $_POST['smartobject_rating_value']);
67
-    if (!$smartobjectRatingHandler->insert($ratingObj)) {
68
-        if (1062 == $xoopsDB->errno()) {
69
-            $message = _SOBJECT_RATING_DUPLICATE_ENTRY;
70
-        } else {
71
-            $message = _SOBJECT_RATING_ERROR;
72
-        }
73
-    } else {
74
-        $message = _SOBJECT_RATING_SUCCESS;
75
-    }
76
-    redirect_header('', 3, $message);
59
+	// The rating form has just been posted. Let's save the info
60
+	$ratingObj = $smartobjectRatingHandler->create();
61
+	$ratingObj->setVar('dirname', $module_dirname);
62
+	$ratingObj->setVar('item', $rating_item);
63
+	$ratingObj->setVar('itemid', $rating_itemid);
64
+	$ratingObj->setVar('uid', $xoopsUser->getVar('uid'));
65
+	$ratingObj->setVar('date', time());
66
+	$ratingObj->setVar('rate', $_POST['smartobject_rating_value']);
67
+	if (!$smartobjectRatingHandler->insert($ratingObj)) {
68
+		if (1062 == $xoopsDB->errno()) {
69
+			$message = _SOBJECT_RATING_DUPLICATE_ENTRY;
70
+		} else {
71
+			$message = _SOBJECT_RATING_ERROR;
72
+		}
73
+	} else {
74
+		$message = _SOBJECT_RATING_SUCCESS;
75
+	}
76
+	redirect_header('', 3, $message);
77 77
 }
Please login to merge, or discard this patch.
include/captcha/scripts/img.php 1 patch
Indentation   +412 added lines, -412 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $xoopsLogger->activated = false;
11 11
 
12 12
 if (empty(Request::getString('HTTP_REFERER', '', 'SERVER')) || !preg_match('/^' . preg_quote(XOOPS_URL, '/') . '/', Request::getString('HTTP_REFERER', '', 'SERVER'))) {
13
-    exit();
13
+	exit();
14 14
 }
15 15
 
16 16
 /**
@@ -18,192 +18,192 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class XoopsCaptchaImageHandler
20 20
 {
21
-    public $config = [];
22
-    //var $mode = "gd"; // GD or bmp
23
-    public $code;
24
-    public $invalid = false;
25
-
26
-    public $font;
27
-    public $spacing;
28
-    public $width;
29
-    public $height;
30
-
31
-    /**
32
-     * XoopsCaptchaImageHandler constructor.
33
-     */
34
-    public function __construct()
35
-    {
36
-        if (empty($_SESSION['XoopsCaptcha_name'])) {
37
-            $this->invalid = true;
38
-        }
39
-
40
-        if (!extension_loaded('gd')) {
41
-            $this->mode = 'bmp';
42
-        } else {
43
-            $required_functions = [
44
-                'imagecreatetruecolor',
45
-                'imagecolorallocate',
46
-                'imagefilledrectangle',
47
-                'imagejpeg',
48
-                'imagedestroy',
49
-                'imageftbbox'
50
-            ];
51
-            foreach ($required_functions as $func) {
52
-                if (!function_exists($func)) {
53
-                    $this->mode = 'bmp';
54
-                    break;
55
-                }
56
-            }
57
-        }
58
-    }
59
-
60
-    /**
61
-     * Loading configs from CAPTCHA class
62
-     * @param array $config
63
-     */
64
-    public function setConfig($config = [])
65
-    {
66
-        // Loading default preferences
67
-        $this->config = $config;
68
-    }
69
-
70
-    public function loadImage()
71
-    {
72
-        $this->createCode();
73
-        $this->setCode();
74
-        $this->createImage();
75
-    }
76
-
77
-    /**
78
-     * Create Code
79
-     */
80
-    public function createCode()
81
-    {
82
-        if ($this->invalid) {
83
-            return;
84
-        }
85
-
86
-        if ('bmp' === $this->mode) {
87
-            $this->config['num_chars'] = 4;
88
-            $this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
89
-        } else {
90
-            $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
91
-            if (!$this->config['casesensitive']) {
92
-                $this->code = strtoupper($this->code);
93
-            }
94
-        }
95
-    }
96
-
97
-    public function setCode()
98
-    {
99
-        if ($this->invalid) {
100
-            return;
101
-        }
102
-
103
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
104
-        $maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
105
-
106
-        // Increase the attempt records on refresh
107
-        if (!empty($maxAttempts)) {
108
-            $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
109
-            if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
110
-                $this->invalid = true;
111
-            }
112
-        }
113
-    }
114
-
115
-    /**
116
-     * @param  string $file
117
-     * @return string|void
118
-     */
119
-    public function createImage($file = '')
120
-    {
121
-        if ($this->invalid) {
122
-            header('Content-type: image/gif');
123
-            readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
124
-
125
-            return;
126
-        }
127
-
128
-        if ('bmp' === $this->mode) {
129
-            return $this->createImageBmp();
130
-        } else {
131
-            return $this->createImageGd();
132
-        }
133
-    }
134
-
135
-    /**
136
-     *  Create CAPTCHA iamge with GD
137
-     *  Originated from DuGris' SecurityImage
138
-     * @param string $file
139
-     */
140
-    //  --------------------------------------------------------------------------- //
141
-    // Class: SecurityImage 1.5                                                    //
142
-    // Author: DuGris aka L. Jen <http://www.dugris.info>                           //
143
-    // Email: [email protected]                                                    //
144
-    // Licence: GNU                                                                 //
145
-    // Project: XOOPS Project                                                   //
146
-    //  --------------------------------------------------------------------------- //
147
-    public function createImageGd($file = '')
148
-    {
149
-        $this->loadFont();
150
-        $this->setImageSize();
151
-
152
-        $this->oImage = imagecreatetruecolor($this->width, $this->height);
153
-        $background   = imagecolorallocate($this->oImage, 255, 255, 255);
154
-        imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
155
-
156
-        switch ($this->config['background_type']) {
157
-            default:
158
-            case 0:
159
-                $this->drawBars();
160
-                break;
161
-
162
-            case 1:
163
-                $this->drawCircles();
164
-                break;
165
-
166
-            case 2:
167
-                $this->drawLines();
168
-                break;
169
-
170
-            case 3:
171
-                $this->drawRectangles();
172
-                break;
173
-
174
-            case 4:
175
-                $this->drawEllipses();
176
-                break;
177
-
178
-            case 5:
179
-                $this->drawPolygons();
180
-                break;
181
-
182
-            case 100:
183
-                $this->createFromFile();
184
-                break;
185
-        }
186
-        $this->drawBorder();
187
-        $this->drawCode();
188
-
189
-        if (empty($file)) {
190
-            header('Content-type: image/jpeg');
191
-            imagejpeg($this->oImage);
192
-        } else {
193
-            imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
194
-        }
195
-        imagedestroy($this->oImage);
196
-    }
197
-
198
-    /**
199
-     * @param         $name
200
-     * @param  string $extension
201
-     * @return array
202
-     */
203
-    public function _getList($name, $extension = '')
204
-    {
205
-        $items = [];
206
-        /*
21
+	public $config = [];
22
+	//var $mode = "gd"; // GD or bmp
23
+	public $code;
24
+	public $invalid = false;
25
+
26
+	public $font;
27
+	public $spacing;
28
+	public $width;
29
+	public $height;
30
+
31
+	/**
32
+	 * XoopsCaptchaImageHandler constructor.
33
+	 */
34
+	public function __construct()
35
+	{
36
+		if (empty($_SESSION['XoopsCaptcha_name'])) {
37
+			$this->invalid = true;
38
+		}
39
+
40
+		if (!extension_loaded('gd')) {
41
+			$this->mode = 'bmp';
42
+		} else {
43
+			$required_functions = [
44
+				'imagecreatetruecolor',
45
+				'imagecolorallocate',
46
+				'imagefilledrectangle',
47
+				'imagejpeg',
48
+				'imagedestroy',
49
+				'imageftbbox'
50
+			];
51
+			foreach ($required_functions as $func) {
52
+				if (!function_exists($func)) {
53
+					$this->mode = 'bmp';
54
+					break;
55
+				}
56
+			}
57
+		}
58
+	}
59
+
60
+	/**
61
+	 * Loading configs from CAPTCHA class
62
+	 * @param array $config
63
+	 */
64
+	public function setConfig($config = [])
65
+	{
66
+		// Loading default preferences
67
+		$this->config = $config;
68
+	}
69
+
70
+	public function loadImage()
71
+	{
72
+		$this->createCode();
73
+		$this->setCode();
74
+		$this->createImage();
75
+	}
76
+
77
+	/**
78
+	 * Create Code
79
+	 */
80
+	public function createCode()
81
+	{
82
+		if ($this->invalid) {
83
+			return;
84
+		}
85
+
86
+		if ('bmp' === $this->mode) {
87
+			$this->config['num_chars'] = 4;
88
+			$this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
89
+		} else {
90
+			$this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
91
+			if (!$this->config['casesensitive']) {
92
+				$this->code = strtoupper($this->code);
93
+			}
94
+		}
95
+	}
96
+
97
+	public function setCode()
98
+	{
99
+		if ($this->invalid) {
100
+			return;
101
+		}
102
+
103
+		$_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
104
+		$maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
105
+
106
+		// Increase the attempt records on refresh
107
+		if (!empty($maxAttempts)) {
108
+			$_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
109
+			if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
110
+				$this->invalid = true;
111
+			}
112
+		}
113
+	}
114
+
115
+	/**
116
+	 * @param  string $file
117
+	 * @return string|void
118
+	 */
119
+	public function createImage($file = '')
120
+	{
121
+		if ($this->invalid) {
122
+			header('Content-type: image/gif');
123
+			readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
124
+
125
+			return;
126
+		}
127
+
128
+		if ('bmp' === $this->mode) {
129
+			return $this->createImageBmp();
130
+		} else {
131
+			return $this->createImageGd();
132
+		}
133
+	}
134
+
135
+	/**
136
+	 *  Create CAPTCHA iamge with GD
137
+	 *  Originated from DuGris' SecurityImage
138
+	 * @param string $file
139
+	 */
140
+	//  --------------------------------------------------------------------------- //
141
+	// Class: SecurityImage 1.5                                                    //
142
+	// Author: DuGris aka L. Jen <http://www.dugris.info>                           //
143
+	// Email: [email protected]                                                    //
144
+	// Licence: GNU                                                                 //
145
+	// Project: XOOPS Project                                                   //
146
+	//  --------------------------------------------------------------------------- //
147
+	public function createImageGd($file = '')
148
+	{
149
+		$this->loadFont();
150
+		$this->setImageSize();
151
+
152
+		$this->oImage = imagecreatetruecolor($this->width, $this->height);
153
+		$background   = imagecolorallocate($this->oImage, 255, 255, 255);
154
+		imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
155
+
156
+		switch ($this->config['background_type']) {
157
+			default:
158
+			case 0:
159
+				$this->drawBars();
160
+				break;
161
+
162
+			case 1:
163
+				$this->drawCircles();
164
+				break;
165
+
166
+			case 2:
167
+				$this->drawLines();
168
+				break;
169
+
170
+			case 3:
171
+				$this->drawRectangles();
172
+				break;
173
+
174
+			case 4:
175
+				$this->drawEllipses();
176
+				break;
177
+
178
+			case 5:
179
+				$this->drawPolygons();
180
+				break;
181
+
182
+			case 100:
183
+				$this->createFromFile();
184
+				break;
185
+		}
186
+		$this->drawBorder();
187
+		$this->drawCode();
188
+
189
+		if (empty($file)) {
190
+			header('Content-type: image/jpeg');
191
+			imagejpeg($this->oImage);
192
+		} else {
193
+			imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
194
+		}
195
+		imagedestroy($this->oImage);
196
+	}
197
+
198
+	/**
199
+	 * @param         $name
200
+	 * @param  string $extension
201
+	 * @return array
202
+	 */
203
+	public function _getList($name, $extension = '')
204
+	{
205
+		$items = [];
206
+		/*
207 207
          if (@ require_once XOOPS_ROOT_PATH."/Frameworks/art/functions.ini.php") {
208 208
          load_functions("cache");
209 209
          if ($items = mod_loadCacheFile("captcha_{$name}", "captcha")) {
@@ -211,231 +211,231 @@  discard block
 block discarded – undo
211 211
          }
212 212
          }
213 213
          */
214
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
215
-        $file_path = $this->config['rootpath'] . "/{$name}";
216
-        $files     = XoopsLists::getFileListAsArray($file_path);
217
-        foreach ($files as $item) {
218
-            if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
219
-                $items[] = $item;
220
-            }
221
-        }
222
-        if (function_exists('mod_createCacheFile')) {
223
-            mod_createCacheFile($items, "captcha_{$name}", 'captcha');
224
-        }
225
-
226
-        return $items;
227
-    }
228
-
229
-    public function loadFont()
230
-    {
231
-        $fonts      = $this->_getList('fonts', 'ttf');
232
-        $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
233
-    }
234
-
235
-    public function setImageSize()
236
-    {
237
-        $MaxCharWidth  = 0;
238
-        $MaxCharHeight = 0;
239
-        $oImage        = imagecreatetruecolor(100, 100);
240
-        $text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
241
-        $FontSize      = $this->config['fontsize_max'];
242
-        for ($Angle = -30; $Angle <= 30; ++$Angle) {
243
-            for ($i = 65; $i <= 90; ++$i) {
244
-                $CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), []);
245
-                $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
246
-                if ($_MaxCharWidth > $MaxCharWidth) {
247
-                    $MaxCharWidth = $_MaxCharWidth;
248
-                }
249
-                $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
250
-                if ($_MaxCharHeight > $MaxCharHeight) {
251
-                    $MaxCharHeight = $_MaxCharHeight;
252
-                }
253
-            }
254
-        }
255
-        imagedestroy($oImage);
256
-
257
-        $this->height  = $MaxCharHeight + 2;
258
-        $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
259
-        $this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
260
-    }
261
-
262
-    /**
263
-     * Return random background
264
-     *
265
-     * @return null|string
266
-     */
267
-    public function loadBackground()
268
-    {
269
-        $RandBackground = null;
270
-        if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
271
-            $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
272
-        }
273
-
274
-        return $RandBackground;
275
-    }
276
-
277
-    /**
278
-     * Draw Image background
279
-     */
280
-    public function createFromFile()
281
-    {
282
-        if ($RandImage = $this->loadBackground()) {
283
-            $ImageType = @getimagesize($RandImage);
284
-            switch (@$ImageType[2]) {
285
-                case 1:
286
-                    $BackgroundImage = imagecreatefromgif($RandImage);
287
-                    break;
288
-
289
-                case 2:
290
-                    $BackgroundImage = imagecreatefromjpeg($RandImage);
291
-                    break;
292
-
293
-                case 3:
294
-                    $BackgroundImage = imagecreatefrompng($RandImage);
295
-                    break;
296
-            }
297
-        }
298
-        if (!empty($BackgroundImage)) {
299
-            imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
300
-            imagedestroy($BackgroundImage);
301
-        } else {
302
-            $this->drawBars();
303
-        }
304
-    }
305
-
306
-    /**
307
-     * Draw Code
308
-     */
309
-    public function drawCode()
310
-    {
311
-        for ($i = 0; $i < $this->config['num_chars']; ++$i) {
312
-            // select random greyscale colour
313
-            $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
314
-
315
-            // write text to image
316
-            $Angle = mt_rand(10, 30);
317
-            if ($i % 2) {
318
-                $Angle = mt_rand(-10, -30);
319
-            }
320
-
321
-            // select random font size
322
-            $FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
323
-
324
-            $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], []);
325
-            $CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
326
-
327
-            // calculate character starting coordinates
328
-            $posX = ($this->spacing / 2) + ($i * $this->spacing);
329
-            $posY = 2 + ($this->height / 2) + ($CharHeight / 4);
330
-
331
-            imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], []);
332
-        }
333
-    }
334
-
335
-    /**
336
-     * Draw Border
337
-     */
338
-    public function drawBorder()
339
-    {
340
-        $rgb          = mt_rand(50, 150);
341
-        $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
342
-        imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
343
-    }
344
-
345
-    /**
346
-     * Draw Circles background
347
-     */
348
-    public function drawCircles()
349
-    {
350
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
351
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
352
-            imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
353
-        }
354
-    }
355
-
356
-    /**
357
-     * Draw Lines background
358
-     */
359
-    public function drawLines()
360
-    {
361
-        for ($i = 0; $i < $this->config['background_num']; ++$i) {
362
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
363
-            imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
364
-        }
365
-    }
366
-
367
-    /**
368
-     * Draw Rectangles background
369
-     */
370
-    public function drawRectangles()
371
-    {
372
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
373
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
374
-            imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
375
-        }
376
-    }
377
-
378
-    /**
379
-     * Draw Bars background
380
-     */
381
-    public function drawBars()
382
-    {
383
-        for ($i = 0; $i <= $this->height;) {
384
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
385
-            imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
386
-            $i += 2.5;
387
-        }
388
-        for ($i = 0; $i <= $this->width;) {
389
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
390
-            imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
391
-            $i += 2.5;
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Draw Ellipses background
397
-     */
398
-    public function drawEllipses()
399
-    {
400
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
401
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
402
-            imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
403
-        }
404
-    }
405
-
406
-    /**
407
-     * Draw polygons background
408
-     */
409
-    public function drawPolygons()
410
-    {
411
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
412
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
413
-            $coords      = [];
414
-            for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
415
-                $coords[] = mt_rand(0, $this->width);
416
-                $coords[] = mt_rand(0, $this->height);
417
-            }
418
-            imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
419
-        }
420
-    }
421
-
422
-    /**
423
-     *  Create CAPTCHA iamge with BMP
424
-     *  TODO
425
-     * @param  string $file
426
-     * @return string
427
-     */
428
-    public function createImageBmp($file = '')
429
-    {
430
-        $image = '';
431
-
432
-        if (empty($file)) {
433
-            header('Content-type: image/bmp');
434
-            echo $image;
435
-        } else {
436
-            return $image;
437
-        }
438
-    }
214
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
215
+		$file_path = $this->config['rootpath'] . "/{$name}";
216
+		$files     = XoopsLists::getFileListAsArray($file_path);
217
+		foreach ($files as $item) {
218
+			if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
219
+				$items[] = $item;
220
+			}
221
+		}
222
+		if (function_exists('mod_createCacheFile')) {
223
+			mod_createCacheFile($items, "captcha_{$name}", 'captcha');
224
+		}
225
+
226
+		return $items;
227
+	}
228
+
229
+	public function loadFont()
230
+	{
231
+		$fonts      = $this->_getList('fonts', 'ttf');
232
+		$this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
233
+	}
234
+
235
+	public function setImageSize()
236
+	{
237
+		$MaxCharWidth  = 0;
238
+		$MaxCharHeight = 0;
239
+		$oImage        = imagecreatetruecolor(100, 100);
240
+		$text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
241
+		$FontSize      = $this->config['fontsize_max'];
242
+		for ($Angle = -30; $Angle <= 30; ++$Angle) {
243
+			for ($i = 65; $i <= 90; ++$i) {
244
+				$CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), []);
245
+				$_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
246
+				if ($_MaxCharWidth > $MaxCharWidth) {
247
+					$MaxCharWidth = $_MaxCharWidth;
248
+				}
249
+				$_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
250
+				if ($_MaxCharHeight > $MaxCharHeight) {
251
+					$MaxCharHeight = $_MaxCharHeight;
252
+				}
253
+			}
254
+		}
255
+		imagedestroy($oImage);
256
+
257
+		$this->height  = $MaxCharHeight + 2;
258
+		$this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
259
+		$this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
260
+	}
261
+
262
+	/**
263
+	 * Return random background
264
+	 *
265
+	 * @return null|string
266
+	 */
267
+	public function loadBackground()
268
+	{
269
+		$RandBackground = null;
270
+		if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
271
+			$RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
272
+		}
273
+
274
+		return $RandBackground;
275
+	}
276
+
277
+	/**
278
+	 * Draw Image background
279
+	 */
280
+	public function createFromFile()
281
+	{
282
+		if ($RandImage = $this->loadBackground()) {
283
+			$ImageType = @getimagesize($RandImage);
284
+			switch (@$ImageType[2]) {
285
+				case 1:
286
+					$BackgroundImage = imagecreatefromgif($RandImage);
287
+					break;
288
+
289
+				case 2:
290
+					$BackgroundImage = imagecreatefromjpeg($RandImage);
291
+					break;
292
+
293
+				case 3:
294
+					$BackgroundImage = imagecreatefrompng($RandImage);
295
+					break;
296
+			}
297
+		}
298
+		if (!empty($BackgroundImage)) {
299
+			imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
300
+			imagedestroy($BackgroundImage);
301
+		} else {
302
+			$this->drawBars();
303
+		}
304
+	}
305
+
306
+	/**
307
+	 * Draw Code
308
+	 */
309
+	public function drawCode()
310
+	{
311
+		for ($i = 0; $i < $this->config['num_chars']; ++$i) {
312
+			// select random greyscale colour
313
+			$text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
314
+
315
+			// write text to image
316
+			$Angle = mt_rand(10, 30);
317
+			if ($i % 2) {
318
+				$Angle = mt_rand(-10, -30);
319
+			}
320
+
321
+			// select random font size
322
+			$FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
323
+
324
+			$CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], []);
325
+			$CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
326
+
327
+			// calculate character starting coordinates
328
+			$posX = ($this->spacing / 2) + ($i * $this->spacing);
329
+			$posY = 2 + ($this->height / 2) + ($CharHeight / 4);
330
+
331
+			imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], []);
332
+		}
333
+	}
334
+
335
+	/**
336
+	 * Draw Border
337
+	 */
338
+	public function drawBorder()
339
+	{
340
+		$rgb          = mt_rand(50, 150);
341
+		$border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
342
+		imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
343
+	}
344
+
345
+	/**
346
+	 * Draw Circles background
347
+	 */
348
+	public function drawCircles()
349
+	{
350
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
351
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
352
+			imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
353
+		}
354
+	}
355
+
356
+	/**
357
+	 * Draw Lines background
358
+	 */
359
+	public function drawLines()
360
+	{
361
+		for ($i = 0; $i < $this->config['background_num']; ++$i) {
362
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
363
+			imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
364
+		}
365
+	}
366
+
367
+	/**
368
+	 * Draw Rectangles background
369
+	 */
370
+	public function drawRectangles()
371
+	{
372
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
373
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
374
+			imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
375
+		}
376
+	}
377
+
378
+	/**
379
+	 * Draw Bars background
380
+	 */
381
+	public function drawBars()
382
+	{
383
+		for ($i = 0; $i <= $this->height;) {
384
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
385
+			imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
386
+			$i += 2.5;
387
+		}
388
+		for ($i = 0; $i <= $this->width;) {
389
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
390
+			imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
391
+			$i += 2.5;
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Draw Ellipses background
397
+	 */
398
+	public function drawEllipses()
399
+	{
400
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
401
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
402
+			imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
403
+		}
404
+	}
405
+
406
+	/**
407
+	 * Draw polygons background
408
+	 */
409
+	public function drawPolygons()
410
+	{
411
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
412
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
413
+			$coords      = [];
414
+			for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
415
+				$coords[] = mt_rand(0, $this->width);
416
+				$coords[] = mt_rand(0, $this->height);
417
+			}
418
+			imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
419
+		}
420
+	}
421
+
422
+	/**
423
+	 *  Create CAPTCHA iamge with BMP
424
+	 *  TODO
425
+	 * @param  string $file
426
+	 * @return string
427
+	 */
428
+	public function createImageBmp($file = '')
429
+	{
430
+		$image = '';
431
+
432
+		if (empty($file)) {
433
+			header('Content-type: image/bmp');
434
+			echo $image;
435
+		} else {
436
+			return $image;
437
+		}
438
+	}
439 439
 }
440 440
 
441 441
 $config       = @include __DIR__ . '/../config.php';
Please login to merge, or discard this patch.
include/projax/classes/Prototype.php 1 patch
Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -15,452 +15,452 @@
 block discarded – undo
15 15
  */
16 16
 class Prototype extends JavaScript
17 17
 {
18
-    public $CALLBACKS = [
19
-        'uninitialized',
20
-        'loading',
21
-        'loaded',
22
-        'interactive',
23
-        'complete',
24
-        'failure',
25
-        'success'
26
-    ];
27
-
28
-    public $AJAX_OPTIONS = [
29
-        'before',
30
-        'after',
31
-        'condition',
32
-        'url',
33
-        'asynchronous',
34
-        'method',
35
-        'insertion',
36
-        'position',
37
-        'form',
38
-        'with',
39
-        'update',
40
-        'script',
41
-        'uninitialized',
42
-        'loading',
43
-        'loaded',
44
-        'interactive',
45
-        'complete',
46
-        'failure',
47
-        'success'
48
-    ];
49
-
50
-    /**
51
-     * @return string
52
-     */
53
-    public function evaluate_remote_response()
54
-    {
55
-        return 'eval(request.responseText)';
56
-    }
57
-
58
-    /**
59
-     * @param $options
60
-     * @return string
61
-     */
62
-    public function form_remote_tag($options)
63
-    {
64
-        $options['form'] = true;
65
-
66
-        return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '"  >';
67
-    }
68
-
69
-    /**
70
-     * @param         $name
71
-     * @param  null   $options
72
-     * @param  null   $html_options
73
-     * @return string
74
-     */
75
-    public function link_to_remote($name, $options = null, $html_options = null)
76
-    {
77
-        return $this->link_to_function($name, $this->remote_function($options), $html_options);
78
-    }
79
-
80
-    /**
81
-     * @param         $field_id
82
-     * @param  null   $options
83
-     * @return string
84
-     */
85
-    public function observe_field($field_id, $options = null)
86
-    {
87
-        if (isset($options['frequency']) && $options['frequency'] > 0) {
88
-            return $this->_build_observer('Form.Element.Observer', $field_id, $options);
89
-        } else {
90
-            return $this->_build_observer('Form.Element.EventObserver', $field_id, $options);
91
-        }
92
-    }
93
-
94
-    /**
95
-     * @param         $form_id
96
-     * @param  null   $options
97
-     * @return string
98
-     */
99
-    public function observe_form($form_id, $options = null)
100
-    {
101
-        if (isset($options['frequency'])) {
102
-            return $this->_build_observer('Form.Observer', $form_id, $options);
103
-        } else {
104
-            return $this->_build_observer('Form.EventObserver', $form_id, $options);
105
-        }
106
-    }
107
-
108
-    /**
109
-     * @param  null $options
110
-     * @return string
111
-     */
112
-    public function periodically_call_remote($options = null)
113
-    {
114
-        $frequency = isset($options['frequency']) ? $options['frequency'] : 10;
115
-        $code      = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')';
116
-
117
-        return $code;
118
-    }
119
-
120
-    /**
121
-     * @param $options
122
-     * @return string
123
-     */
124
-    public function remote_function($options)
125
-    {
126
-        $javascript_options = $this->_options_for_ajax($options);
127
-
128
-        $update = '';
129
-
130
-        if (isset($options['update']) && is_array($options['update'])) {
131
-            $update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : '';
132
-            $update .= empty($update) ? '' : ',';
133
-            $update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : '';
134
-        } else {
135
-            $update .= isset($options['update']) ? $options['update'] : '';
136
-        }
137
-
138
-        $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\',';
139
-
140
-        $ajax_function .= "'" . $options['url'] . "'";
141
-        $ajax_function .= ',' . $javascript_options . ')';
142
-
143
-        $ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function;
144
-        $ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function;
145
-        $ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function;
146
-        $ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function;
147
-
148
-        return $ajax_function;
149
-    }
150
-
151
-    /**
152
-     * @param $name
153
-     * @param $value
154
-     * @param $options
155
-     * @return string
156
-     */
157
-    public function submit_to_remote($name, $value, $options)
158
-    {
159
-        if (isset($options['with'])) {
160
-            $options['with'] = 'Form.serialize(this.form)';
161
-        }
162
-
163
-        return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '">';
164
-    }
165
-
166
-    /**
167
-     * @param      $element_id
168
-     * @param null $options
169
-     * @param      $block
170
-     */
171
-    public function update_element_function($element_id, $options = null, $block)
172
-    {
173
-        $content = isset($options['content']) ? $options['content'] : '';
174
-        $content = $this->escape($content);
175
-    }
176
-
177
-    /**
178
-     * @param $block
179
-     */
180
-    public function update_page($block)
181
-    {
182
-    }
183
-
184
-    /**
185
-     * @param $block
186
-     * @return string
187
-     */
188
-    public function update_page_tag(& $block)
189
-    {
190
-        return $this->tag($block);
191
-    }
192
-
193
-    /////////////////////////////////////////////////////////////////////////////////////
194
-    //                             Private functions
195
-    /////////////////////////////////////////////////////////////////////////////////////
196
-
197
-    /**
198
-     * @param $options
199
-     * @return array
200
-     */
201
-    public function _build_callbacks($options)
202
-    {
203
-        $callbacks = [];
204
-        foreach ($options as $callback => $code) {
205
-            if (in_array($callback, $this->CALLBACKS)) {
206
-                $name             = 'on' . ucfirst($callback);
207
-                $callbacks[$name] = 'function(request){' . $code . '}';
208
-            }
209
-        }
210
-
211
-        return $callbacks;
212
-    }
213
-
214
-    /**
215
-     * @param         $klass
216
-     * @param         $name
217
-     * @param  null   $options
218
-     * @return string
219
-     */
220
-    public function _build_observer($klass, $name, $options = null)
221
-    {
222
-        if (isset($options['with']) && false === strpos($options['with'], '=')) {
223
-            $options['with'] = '\'' . $options['with'] . '=\' + value';
224
-        } elseif (isset($options['with']) && isset($options['update'])) {
225
-            $options['with'] = 'value';
226
-        }
227
-
228
-        $callback = $options['function'] ?: $this->remote_function($options);
229
-
230
-        $javascript = "new $klass('$name', ";
231
-        $javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : '';
232
-        $javascript .= 'function (element,value) { ';
233
-        $javascript .= $callback;
234
-        $javascript .= isset($options['on']) ? ', ' . $options['on'] : '';
235
-        $javascript .= '})';
236
-
237
-        return $javascript;
238
-    }
239
-
240
-    /**
241
-     * @param $method
242
-     * @return string
243
-     */
244
-    public function _method_option_to_s($method)
245
-    {
246
-        return false !== strpos($method, "'") ? $method : "'$method'";
247
-    }
248
-
249
-    /**
250
-     * @param $options
251
-     * @return string
252
-     */
253
-    public function _options_for_ajax($options)
254
-    {
255
-        $js_options = is_array($options) ? $this->_build_callbacks($options) : [];
256
-
257
-        if (isset($options['type']) && 'synchronous' === $option['type']) {
258
-            $js_options['asynchronous'] = 'false';
259
-        }
260
-
261
-        if (isset($options['method'])) {
262
-            $js_options['method'] = $this->_method_option_to_s($options['method']);
263
-        }
264
-
265
-        if (isset($options['position'])) {
266
-            $js_options['insertion'] = 'Insertion.' . ucfirst($options['position']);
267
-        }
268
-
269
-        $js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true';
270
-
271
-        if (isset($options['form'])) {
272
-            $js_options['parameters'] = 'Form.serialize(this)';
273
-        } elseif (isset($options['parameters'])) {
274
-            $js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')';
275
-        } elseif (isset($options['with'])) {
276
-            $js_options['parameters'] = $options['with'];
277
-        }
278
-
279
-        return $this->_options_for_javascript($js_options);
280
-    }
281
-
282
-    /////////////////////////////////////////////////////////////////////////////////////
283
-    //                            Mergerd Javascript Generator helpers
284
-    /////////////////////////////////////////////////////////////////////////////////////
285
-
286
-    /**
287
-     * @param $javascript
288
-     */
289
-    public function dump($javascript)
290
-    {
291
-        echo $javascript;
292
-    }
293
-
294
-    /**
295
-     * @param         $id
296
-     * @param  null   $extend
297
-     * @return string
298
-     */
299
-    public function ID($id, $extend = null)
300
-    {
301
-        return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : '';
302
-    }
303
-
304
-    /**
305
-     * @param $message
306
-     * @return string
307
-     */
308
-    public function alert($message)
309
-    {
310
-        return $this->call('alert', $message);
311
-    }
312
-
313
-    /**
314
-     * @param $variable
315
-     * @param $value
316
-     * @return string
317
-     */
318
-    public function assign($variable, $value)
319
-    {
320
-        return "$variable = $value;";
321
-    }
322
-
323
-    /**
324
-     * @param         $function
325
-     * @param  null   $args
326
-     * @return string
327
-     */
328
-    public function call($function, $args = null)
329
-    {
330
-        $arg_str = '';
331
-        if (is_array($args)) {
332
-            foreach ($args as $arg) {
333
-                if (!empty($arg_str)) {
334
-                    $arg_str .= ', ';
335
-                }
336
-                if (is_string($arg)) {
337
-                    $arg_str .= "'$arg'";
338
-                } else {
339
-                    $arg_str .= $arg;
340
-                }
341
-            }
342
-        } else {
343
-            if (is_string($args)) {
344
-                $arg_str .= "'$args'";
345
-            } else {
346
-                $arg_str .= $args;
347
-            }
348
-        }
349
-
350
-        return "$function($arg_str)";
351
-    }
352
-
353
-    /**
354
-     * @param  int    $seconds
355
-     * @param  string $script
356
-     * @return string
357
-     */
358
-    public function delay($seconds = 1, $script = '')
359
-    {
360
-        return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )';
361
-    }
362
-
363
-    /**
364
-     * @param $id
365
-     * @return string
366
-     */
367
-    public function hide($id)
368
-    {
369
-        return $this->call('Element.hide', $id);
370
-    }
371
-
372
-    /**
373
-     * @param         $position
374
-     * @param         $id
375
-     * @param  null   $options_for_render
376
-     * @return string
377
-     */
378
-    public function insert_html($position, $id, $options_for_render = null)
379
-    {
380
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
381
-
382
-        return $this->call('new Insertion.' . ucfirst($position), $args);
383
-    }
384
-
385
-    /**
386
-     * @param $location
387
-     * @return string
388
-     */
389
-    public function redirect_to($location)
390
-    {
391
-        return $this->assign('window.location.href', $location);
392
-    }
393
-
394
-    /**
395
-     * @param $id
396
-     * @return string
397
-     */
398
-    public function remove($id)
399
-    {
400
-        if (is_array($id)) {
401
-            $arr_str = '';
402
-            foreach ($id as $obj) {
403
-                if (!empty($arg_str)) {
404
-                    $arg_str .= ', ';
405
-                }
406
-                $arg_str .= "'$arg'";
407
-            }
408
-
409
-            return "$A[$arg_str].each(Element.remove)";
410
-        } else {
411
-            return "Element.remove('$id')";
412
-        }
413
-    }
414
-
415
-    /**
416
-     * @param $id
417
-     * @param $options_for_render
418
-     * @return string
419
-     */
420
-    public function replace($id, $options_for_render)
421
-    {
422
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
423
-
424
-        return $this->call('Element.replace', $args);
425
-    }
426
-
427
-    /**
428
-     * @param $id
429
-     * @param $options_for_render
430
-     * @return string
431
-     */
432
-    public function replace_html($id, $options_for_render)
433
-    {
434
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
435
-
436
-        return $this->call('Element.update', $args);
437
-    }
438
-
439
-    /**
440
-     * @param         $pattern
441
-     * @param  null   $extend
442
-     * @return string
443
-     */
444
-    public function select($pattern, $extend = null)
445
-    {
446
-        return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : '';
447
-    }
448
-
449
-    /**
450
-     * @param $id
451
-     * @return string
452
-     */
453
-    public function show($id)
454
-    {
455
-        return $this->call('Element.show', $id);
456
-    }
457
-
458
-    /**
459
-     * @param $id
460
-     * @return string
461
-     */
462
-    public function toggle($id)
463
-    {
464
-        return $this->call('Element.toggle', $id);
465
-    }
18
+	public $CALLBACKS = [
19
+		'uninitialized',
20
+		'loading',
21
+		'loaded',
22
+		'interactive',
23
+		'complete',
24
+		'failure',
25
+		'success'
26
+	];
27
+
28
+	public $AJAX_OPTIONS = [
29
+		'before',
30
+		'after',
31
+		'condition',
32
+		'url',
33
+		'asynchronous',
34
+		'method',
35
+		'insertion',
36
+		'position',
37
+		'form',
38
+		'with',
39
+		'update',
40
+		'script',
41
+		'uninitialized',
42
+		'loading',
43
+		'loaded',
44
+		'interactive',
45
+		'complete',
46
+		'failure',
47
+		'success'
48
+	];
49
+
50
+	/**
51
+	 * @return string
52
+	 */
53
+	public function evaluate_remote_response()
54
+	{
55
+		return 'eval(request.responseText)';
56
+	}
57
+
58
+	/**
59
+	 * @param $options
60
+	 * @return string
61
+	 */
62
+	public function form_remote_tag($options)
63
+	{
64
+		$options['form'] = true;
65
+
66
+		return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '"  >';
67
+	}
68
+
69
+	/**
70
+	 * @param         $name
71
+	 * @param  null   $options
72
+	 * @param  null   $html_options
73
+	 * @return string
74
+	 */
75
+	public function link_to_remote($name, $options = null, $html_options = null)
76
+	{
77
+		return $this->link_to_function($name, $this->remote_function($options), $html_options);
78
+	}
79
+
80
+	/**
81
+	 * @param         $field_id
82
+	 * @param  null   $options
83
+	 * @return string
84
+	 */
85
+	public function observe_field($field_id, $options = null)
86
+	{
87
+		if (isset($options['frequency']) && $options['frequency'] > 0) {
88
+			return $this->_build_observer('Form.Element.Observer', $field_id, $options);
89
+		} else {
90
+			return $this->_build_observer('Form.Element.EventObserver', $field_id, $options);
91
+		}
92
+	}
93
+
94
+	/**
95
+	 * @param         $form_id
96
+	 * @param  null   $options
97
+	 * @return string
98
+	 */
99
+	public function observe_form($form_id, $options = null)
100
+	{
101
+		if (isset($options['frequency'])) {
102
+			return $this->_build_observer('Form.Observer', $form_id, $options);
103
+		} else {
104
+			return $this->_build_observer('Form.EventObserver', $form_id, $options);
105
+		}
106
+	}
107
+
108
+	/**
109
+	 * @param  null $options
110
+	 * @return string
111
+	 */
112
+	public function periodically_call_remote($options = null)
113
+	{
114
+		$frequency = isset($options['frequency']) ? $options['frequency'] : 10;
115
+		$code      = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')';
116
+
117
+		return $code;
118
+	}
119
+
120
+	/**
121
+	 * @param $options
122
+	 * @return string
123
+	 */
124
+	public function remote_function($options)
125
+	{
126
+		$javascript_options = $this->_options_for_ajax($options);
127
+
128
+		$update = '';
129
+
130
+		if (isset($options['update']) && is_array($options['update'])) {
131
+			$update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : '';
132
+			$update .= empty($update) ? '' : ',';
133
+			$update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : '';
134
+		} else {
135
+			$update .= isset($options['update']) ? $options['update'] : '';
136
+		}
137
+
138
+		$ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\',';
139
+
140
+		$ajax_function .= "'" . $options['url'] . "'";
141
+		$ajax_function .= ',' . $javascript_options . ')';
142
+
143
+		$ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function;
144
+		$ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function;
145
+		$ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function;
146
+		$ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function;
147
+
148
+		return $ajax_function;
149
+	}
150
+
151
+	/**
152
+	 * @param $name
153
+	 * @param $value
154
+	 * @param $options
155
+	 * @return string
156
+	 */
157
+	public function submit_to_remote($name, $value, $options)
158
+	{
159
+		if (isset($options['with'])) {
160
+			$options['with'] = 'Form.serialize(this.form)';
161
+		}
162
+
163
+		return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '">';
164
+	}
165
+
166
+	/**
167
+	 * @param      $element_id
168
+	 * @param null $options
169
+	 * @param      $block
170
+	 */
171
+	public function update_element_function($element_id, $options = null, $block)
172
+	{
173
+		$content = isset($options['content']) ? $options['content'] : '';
174
+		$content = $this->escape($content);
175
+	}
176
+
177
+	/**
178
+	 * @param $block
179
+	 */
180
+	public function update_page($block)
181
+	{
182
+	}
183
+
184
+	/**
185
+	 * @param $block
186
+	 * @return string
187
+	 */
188
+	public function update_page_tag(& $block)
189
+	{
190
+		return $this->tag($block);
191
+	}
192
+
193
+	/////////////////////////////////////////////////////////////////////////////////////
194
+	//                             Private functions
195
+	/////////////////////////////////////////////////////////////////////////////////////
196
+
197
+	/**
198
+	 * @param $options
199
+	 * @return array
200
+	 */
201
+	public function _build_callbacks($options)
202
+	{
203
+		$callbacks = [];
204
+		foreach ($options as $callback => $code) {
205
+			if (in_array($callback, $this->CALLBACKS)) {
206
+				$name             = 'on' . ucfirst($callback);
207
+				$callbacks[$name] = 'function(request){' . $code . '}';
208
+			}
209
+		}
210
+
211
+		return $callbacks;
212
+	}
213
+
214
+	/**
215
+	 * @param         $klass
216
+	 * @param         $name
217
+	 * @param  null   $options
218
+	 * @return string
219
+	 */
220
+	public function _build_observer($klass, $name, $options = null)
221
+	{
222
+		if (isset($options['with']) && false === strpos($options['with'], '=')) {
223
+			$options['with'] = '\'' . $options['with'] . '=\' + value';
224
+		} elseif (isset($options['with']) && isset($options['update'])) {
225
+			$options['with'] = 'value';
226
+		}
227
+
228
+		$callback = $options['function'] ?: $this->remote_function($options);
229
+
230
+		$javascript = "new $klass('$name', ";
231
+		$javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : '';
232
+		$javascript .= 'function (element,value) { ';
233
+		$javascript .= $callback;
234
+		$javascript .= isset($options['on']) ? ', ' . $options['on'] : '';
235
+		$javascript .= '})';
236
+
237
+		return $javascript;
238
+	}
239
+
240
+	/**
241
+	 * @param $method
242
+	 * @return string
243
+	 */
244
+	public function _method_option_to_s($method)
245
+	{
246
+		return false !== strpos($method, "'") ? $method : "'$method'";
247
+	}
248
+
249
+	/**
250
+	 * @param $options
251
+	 * @return string
252
+	 */
253
+	public function _options_for_ajax($options)
254
+	{
255
+		$js_options = is_array($options) ? $this->_build_callbacks($options) : [];
256
+
257
+		if (isset($options['type']) && 'synchronous' === $option['type']) {
258
+			$js_options['asynchronous'] = 'false';
259
+		}
260
+
261
+		if (isset($options['method'])) {
262
+			$js_options['method'] = $this->_method_option_to_s($options['method']);
263
+		}
264
+
265
+		if (isset($options['position'])) {
266
+			$js_options['insertion'] = 'Insertion.' . ucfirst($options['position']);
267
+		}
268
+
269
+		$js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true';
270
+
271
+		if (isset($options['form'])) {
272
+			$js_options['parameters'] = 'Form.serialize(this)';
273
+		} elseif (isset($options['parameters'])) {
274
+			$js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')';
275
+		} elseif (isset($options['with'])) {
276
+			$js_options['parameters'] = $options['with'];
277
+		}
278
+
279
+		return $this->_options_for_javascript($js_options);
280
+	}
281
+
282
+	/////////////////////////////////////////////////////////////////////////////////////
283
+	//                            Mergerd Javascript Generator helpers
284
+	/////////////////////////////////////////////////////////////////////////////////////
285
+
286
+	/**
287
+	 * @param $javascript
288
+	 */
289
+	public function dump($javascript)
290
+	{
291
+		echo $javascript;
292
+	}
293
+
294
+	/**
295
+	 * @param         $id
296
+	 * @param  null   $extend
297
+	 * @return string
298
+	 */
299
+	public function ID($id, $extend = null)
300
+	{
301
+		return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : '';
302
+	}
303
+
304
+	/**
305
+	 * @param $message
306
+	 * @return string
307
+	 */
308
+	public function alert($message)
309
+	{
310
+		return $this->call('alert', $message);
311
+	}
312
+
313
+	/**
314
+	 * @param $variable
315
+	 * @param $value
316
+	 * @return string
317
+	 */
318
+	public function assign($variable, $value)
319
+	{
320
+		return "$variable = $value;";
321
+	}
322
+
323
+	/**
324
+	 * @param         $function
325
+	 * @param  null   $args
326
+	 * @return string
327
+	 */
328
+	public function call($function, $args = null)
329
+	{
330
+		$arg_str = '';
331
+		if (is_array($args)) {
332
+			foreach ($args as $arg) {
333
+				if (!empty($arg_str)) {
334
+					$arg_str .= ', ';
335
+				}
336
+				if (is_string($arg)) {
337
+					$arg_str .= "'$arg'";
338
+				} else {
339
+					$arg_str .= $arg;
340
+				}
341
+			}
342
+		} else {
343
+			if (is_string($args)) {
344
+				$arg_str .= "'$args'";
345
+			} else {
346
+				$arg_str .= $args;
347
+			}
348
+		}
349
+
350
+		return "$function($arg_str)";
351
+	}
352
+
353
+	/**
354
+	 * @param  int    $seconds
355
+	 * @param  string $script
356
+	 * @return string
357
+	 */
358
+	public function delay($seconds = 1, $script = '')
359
+	{
360
+		return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )';
361
+	}
362
+
363
+	/**
364
+	 * @param $id
365
+	 * @return string
366
+	 */
367
+	public function hide($id)
368
+	{
369
+		return $this->call('Element.hide', $id);
370
+	}
371
+
372
+	/**
373
+	 * @param         $position
374
+	 * @param         $id
375
+	 * @param  null   $options_for_render
376
+	 * @return string
377
+	 */
378
+	public function insert_html($position, $id, $options_for_render = null)
379
+	{
380
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
381
+
382
+		return $this->call('new Insertion.' . ucfirst($position), $args);
383
+	}
384
+
385
+	/**
386
+	 * @param $location
387
+	 * @return string
388
+	 */
389
+	public function redirect_to($location)
390
+	{
391
+		return $this->assign('window.location.href', $location);
392
+	}
393
+
394
+	/**
395
+	 * @param $id
396
+	 * @return string
397
+	 */
398
+	public function remove($id)
399
+	{
400
+		if (is_array($id)) {
401
+			$arr_str = '';
402
+			foreach ($id as $obj) {
403
+				if (!empty($arg_str)) {
404
+					$arg_str .= ', ';
405
+				}
406
+				$arg_str .= "'$arg'";
407
+			}
408
+
409
+			return "$A[$arg_str].each(Element.remove)";
410
+		} else {
411
+			return "Element.remove('$id')";
412
+		}
413
+	}
414
+
415
+	/**
416
+	 * @param $id
417
+	 * @param $options_for_render
418
+	 * @return string
419
+	 */
420
+	public function replace($id, $options_for_render)
421
+	{
422
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
423
+
424
+		return $this->call('Element.replace', $args);
425
+	}
426
+
427
+	/**
428
+	 * @param $id
429
+	 * @param $options_for_render
430
+	 * @return string
431
+	 */
432
+	public function replace_html($id, $options_for_render)
433
+	{
434
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
435
+
436
+		return $this->call('Element.update', $args);
437
+	}
438
+
439
+	/**
440
+	 * @param         $pattern
441
+	 * @param  null   $extend
442
+	 * @return string
443
+	 */
444
+	public function select($pattern, $extend = null)
445
+	{
446
+		return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : '';
447
+	}
448
+
449
+	/**
450
+	 * @param $id
451
+	 * @return string
452
+	 */
453
+	public function show($id)
454
+	{
455
+		return $this->call('Element.show', $id);
456
+	}
457
+
458
+	/**
459
+	 * @param $id
460
+	 * @return string
461
+	 */
462
+	public function toggle($id)
463
+	{
464
+		return $this->call('Element.toggle', $id);
465
+	}
466 466
 }
Please login to merge, or discard this patch.
include/currency.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 $smartobjectCurrencyHandler = Smartobject\Helper::getInstance()->getHandler('Currency');
21 21
 
22 22
 if (!$smartobjectCurrenciesObj) {
23
-    $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies();
23
+	$smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies();
24 24
 }
25 25
 if (!$smartobjectCurrenciesArray) {
26
-    foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) {
27
-        if ($currencyObj->getVar('default_currency', 'e')) {
28
-            $smartobjectDefaultCurrency = $currencyObj;
29
-        }
30
-        $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode();
31
-    }
26
+	foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) {
27
+		if ($currencyObj->getVar('default_currency', 'e')) {
28
+			$smartobjectDefaultCurrency = $currencyObj;
29
+		}
30
+		$smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode();
31
+	}
32 32
 }
Please login to merge, or discard this patch.
include/customtag.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 
14 14
 function smart_customtag_initiate()
15 15
 {
16
-    global $xoopsTpl, $smartobjectCustomtagHandler;
17
-    if (is_object($xoopsTpl)) {
18
-        foreach ($smartobjectCustomtagHandler->objects as $k => $v) {
19
-            $xoopsTpl->assign($k, $v->render());
20
-        }
21
-    }
16
+	global $xoopsTpl, $smartobjectCustomtagHandler;
17
+	if (is_object($xoopsTpl)) {
18
+		foreach ($smartobjectCustomtagHandler->objects as $k => $v) {
19
+			$xoopsTpl->assign($k, $v->render());
20
+		}
21
+	}
22 22
 }
23 23
 
24 24
 if (!defined('SMARTOBJECT_URL')) {
25
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
25
+	require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
26 26
 }
27 27
 
28 28
 Smartobject\Utility::loadLanguageFile('smartobject', 'customtag');
Please login to merge, or discard this patch.