Completed
Push — master ( 01b1a5...81f493 )
by Michael
04:03
created
class/smartobjectcontroller.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
     /**
125 125
      * @param        $smartObj
126
-     * @param        $objectid
127
-     * @param        $created_success_msg
128
-     * @param        $modified_success_msg
126
+     * @param        integer $objectid
127
+     * @param        string $created_success_msg
128
+     * @param        string $modified_success_msg
129 129
      * @param  bool  $redirect_page
130 130
      * @param  bool  $debug
131 131
      * @return mixed
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      * @param  bool   $confirm_msg
290 290
      * @param  string $op
291 291
      * @param  bool   $userSide
292
-     * @return bool
292
+     * @return boolean|null
293 293
      * @internal param string $redir_page redirect page after deleting the object
294 294
      */
295 295
     public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false)
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     }
444 444
 
445 445
     /**
446
-     * @param         $smartObj
446
+     * @param         SmartMlObject $smartObj
447 447
      * @param  bool   $onlyUrl
448 448
      * @param  bool   $withimage
449 449
      * @return string
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
     }
534 534
 
535 535
     /**
536
-     * @param $smartObj
536
+     * @param SmartObject $smartObj
537 537
      * @return string
538 538
      */
539 539
     public function getPrintAndMailLink($smartObj)
Please login to merge, or discard this patch.
Indentation   +544 added lines, -544 removed lines patch added patch discarded remove patch
@@ -31,548 +31,548 @@
 block discarded – undo
31 31
  */
32 32
 class SmartObjectController
33 33
 {
34
-    public $handler;
35
-
36
-    /**
37
-     * SmartObjectController constructor.
38
-     * @param $handler
39
-     */
40
-    public function __construct($handler)
41
-    {
42
-        $this->handler = $handler;
43
-    }
44
-
45
-    /**
46
-     * @param $smartObj
47
-     */
48
-    public function postDataToObject(&$smartObj)
49
-    {
50
-        foreach (array_keys($smartObj->vars) as $key) {
51
-            switch ($smartObj->vars[$key]['data_type']) {
52
-                case XOBJ_DTYPE_IMAGE:
53
-                    if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') {
54
-                        $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
55
-                        $smartObj->setVar($key, $_POST['url_' . $key]);
56
-                        if (file_exists($oldFile)) {
57
-                            unlink($oldFile);
58
-                        }
59
-                    }
60
-                    if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') {
61
-                        $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
62
-                        $smartObj->setVar($key, '');
63
-                        if (file_exists($oldFile)) {
64
-                            unlink($oldFile);
65
-                        }
66
-                    }
67
-                    break;
68
-
69
-                case XOBJ_DTYPE_URLLINK:
70
-                    $linkObj = $smartObj->getUrlLinkObj($key);
71
-                    $linkObj->setVar('caption', $_POST['caption_' . $key]);
72
-                    $linkObj->setVar('description', $_POST['desc_' . $key]);
73
-                    $linkObj->setVar('target', $_POST['target_' . $key]);
74
-                    $linkObj->setVar('url', $_POST['url_' . $key]);
75
-                    if ($linkObj->getVar('url') !== '') {
76
-                        $smartObj->storeUrlLinkObj($linkObj);
77
-                    }
78
-                    //todo: catch errors
79
-                    $smartObj->setVar($key, $linkObj->getVar('urllinkid'));
80
-                    break;
81
-
82
-                case XOBJ_DTYPE_FILE:
83
-                    if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') {
84
-                        $fileObj = $smartObj->getFileObj($key);
85
-                        $fileObj->setVar('caption', $_POST['caption_' . $key]);
86
-                        $fileObj->setVar('description', $_POST['desc_' . $key]);
87
-                        $fileObj->setVar('url', $_POST['url_' . $key]);
88
-                        if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' && $fileObj->getVar('url') === '')) {
89
-                            $res = $smartObj->storeFileObj($fileObj);
90
-                            if ($res) {
91
-                                $smartObj->setVar($key, $fileObj->getVar('fileid'));
92
-                            } else {
93
-                                //error setted, but no error message (to be improved)
94
-                                $smartObj->setErrors($fileObj->getErrors());
95
-                            }
96
-                        }
97
-                    }
98
-                    break;
99
-
100
-                case XOBJ_DTYPE_STIME:
101
-                case XOBJ_DTYPE_MTIME:
102
-                case XOBJ_DTYPE_LTIME:
103
-                    // check if this field's value is available in the POST array
104
-                    if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) {
105
-                        $value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
106
-                    } else {
107
-                        $value = strtotime($_POST[$key]);
108
-                        //if strtotime returns false, the value is already a time stamp
109
-                        if (!$value) {
110
-                            $value = (int)$_POST[$key];
111
-                        }
112
-                    }
113
-                    $smartObj->setVar($key, $value);
114
-
115
-                    break;
116
-
117
-                default:
118
-                    $smartObj->setVar($key, $_POST[$key]);
119
-                    break;
120
-            }
121
-        }
122
-    }
123
-
124
-    /**
125
-     * @param        $smartObj
126
-     * @param        $objectid
127
-     * @param        $created_success_msg
128
-     * @param        $modified_success_msg
129
-     * @param  bool  $redirect_page
130
-     * @param  bool  $debug
131
-     * @return mixed
132
-     */
133
-    public function doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false)
134
-    {
135
-        global $smart_previous_page;
136
-
137
-        $this->postDataToObject($smartObj);
138
-
139
-        if ($smartObj->isNew()) {
140
-            $redirect_msg = $created_success_msg;
141
-        } else {
142
-            $redirect_msg = $modified_success_msg;
143
-        }
144
-
145
-        // Check if there were uploaded files
146
-        if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) {
147
-            include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php';
148
-            $uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight);
149
-            foreach ($_FILES as $name => $file_array) {
150
-                if (isset($file_array['name']) && $file_array['name'] !== '' && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) {
151
-                    if ($uploaderObj->fetchMedia($name)) {
152
-                        $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName());
153
-                        if ($uploaderObj->upload()) {
154
-                            // Find the related field in the SmartObject
155
-                            $related_field   = str_replace('upload_', '', $name);
156
-                            $uploadedArray[] = $related_field;
157
-                            //si c'est un fichier Rich
158
-                            if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) {
159
-                                $object_fileurl = $smartObj->getUploadDir();
160
-                                $fileObj        = $smartObj->getFileObj($related_field);
161
-                                $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName());
162
-                                $fileObj->setVar('caption', $_POST['caption_' . $related_field]);
163
-                                $fileObj->setVar('description', $_POST['desc_' . $related_field]);
164
-                                $smartObj->storeFileObj($fileObj);
165
-                                //todo: catch errors
166
-                                $smartObj->setVar($related_field, $fileObj->getVar('fileid'));
167
-                            } else {
168
-                                $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field);
169
-                                unlink($old_file);
170
-                                $smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
171
-                            }
172
-                        } else {
173
-                            $smartObj->setErrors($uploaderObj->getErrors(false));
174
-                        }
175
-                    } else {
176
-                        $smartObj->setErrors($uploaderObj->getErrors(false));
177
-                    }
178
-                }
179
-            }
180
-        }
181
-
182
-        if ($debug) {
183
-            $storeResult = $this->handler->insertD($smartObj);
184
-        } else {
185
-            $storeResult = $this->handler->insert($smartObj);
186
-        }
187
-
188
-        if ($storeResult) {
189
-            if ($this->handler->getPermissions()) {
190
-                $smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
191
-                $smartPermissionsHandler->storeAllPermissionsForId($smartObj->id());
192
-            }
193
-        }
194
-
195
-        if ($redirect_page === null) {
196
-            return $smartObj;
197
-        } else {
198
-            if (!$storeResult) {
199
-                redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors());
200
-            }
201
-
202
-            $redirect_page = $redirect_page ?: smart_get_page_before_form();
203
-
204
-            redirect_header($redirect_page, 2, $redirect_msg);
205
-        }
206
-    }
207
-
208
-    /**
209
-     * Store the object in the database autmatically from a form sending POST data
210
-     *
211
-     * @param  string      $created_success_msg  message to display if new object was created
212
-     * @param  string      $modified_success_msg message to display if object was successfully edited
213
-     * @param  bool|string $redirect_page        redirect page, if not set, then we backup once
214
-     * @param  bool        $debug
215
-     * @param  bool        $x_param
216
-     * @return bool
217
-     * @internal param string $created_redir_page redirect page after creating the object
218
-     * @internal param string $modified_redir_page redirect page after editing the object
219
-     * @internal param bool $exit if set to TRUE then the script ends
220
-     */
221
-    public function storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false, $x_param = false)
222
-    {
223
-        $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0;
224
-        if ($debug) {
225
-            if ($x_param) {
226
-                $smartObj = $this->handler->getD($objectid, true, $x_param);
227
-            } else {
228
-                $smartObj = $this->handler->getD($objectid);
229
-            }
230
-        } else {
231
-            if ($x_param) {
232
-                $smartObj = $this->handler->get($objectid, true, false, false, $x_param);
233
-            } else {
234
-                $smartObj = $this->handler->get($objectid);
235
-            }
236
-        }
237
-
238
-        // if handler is the Multilanguage handler, we will need to treat this for multilanguage
239
-        if (is_subclass_of($this->handler, 'smartpersistablemlobjecthandler')) {
240
-            if ($smartObj->isNew()) {
241
-                // This is a new object. We need to store the meta data and then the language data
242
-                // First, we will get rid of the multilanguage data to only store the meta data
243
-                $smartObj->stripMultilanguageFields();
244
-                $newObject = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
245
-                /**
246
-                 * @todo we need to trap potential errors here
247
-                 */
248
-
249
-                // ok, the meta daa is stored. Let's recreate the object and then
250
-                // get rid of anything not multilanguage
251
-                unset($smartObj);
252
-                $smartObj = $this->handler->get($objectid);
253
-                $smartObj->stripNonMultilanguageFields();
254
-
255
-                $smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName));
256
-                $this->handler->changeTableNameForML();
257
-                $ret = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
258
-
259
-                return $ret;
260
-            }
261
-        } else {
262
-            return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
263
-        }
264
-    }
265
-
266
-    /**
267
-     * @return bool
268
-     */
269
-    public function storeSmartObjectD()
270
-    {
271
-        return $this->storeSmartObject(true);
272
-    }
273
-
274
-    /**
275
-     * @param  bool $debug
276
-     * @param  bool $xparam
277
-     * @return bool
278
-     */
279
-    public function storeSmartObject($debug = false, $xparam = false)
280
-    {
281
-        $ret = $this->storeFromDefaultForm('', '', null, $debug, $xparam);
282
-
283
-        return $ret;
284
-    }
285
-
286
-    /**
287
-     * Handles deletion of an object which keyid is passed as a GET param
288
-     *
289
-     * @param  bool   $confirm_msg
290
-     * @param  string $op
291
-     * @param  bool   $userSide
292
-     * @return bool
293
-     * @internal param string $redir_page redirect page after deleting the object
294
-     */
295
-    public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false)
296
-    {
297
-        global $smart_previous_page;
298
-
299
-        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
300
-        $smartObj = $this->handler->get($objectid);
301
-
302
-        if ($smartObj->isNew()) {
303
-            redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED);
304
-        }
305
-
306
-        $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
307
-        if ($confirm) {
308
-            if (!$this->handler->delete($smartObj)) {
309
-                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
310
-                exit;
311
-            }
312
-
313
-            redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS);
314
-        } else {
315
-            // no confirm: show deletion condition
316
-
317
-            xoops_cp_header();
318
-
319
-            if (!$confirm_msg) {
320
-                $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM;
321
-            }
322
-
323
-            xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'),
324
-                          sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
325
-
326
-            xoops_cp_footer();
327
-        }
328
-        exit();
329
-    }
330
-
331
-    /**
332
-     * @param bool   $confirm_msg
333
-     * @param string $op
334
-     */
335
-    public function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del')
336
-    {
337
-        global $smart_previous_page, $xoopsTpl;
338
-
339
-        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
340
-        $smartObj = $this->handler->get($objectid);
341
-
342
-        if ($smartObj->isNew()) {
343
-            redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED);
344
-        }
345
-
346
-        $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
347
-        if ($confirm) {
348
-            if (!$this->handler->delete($smartObj)) {
349
-                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
350
-                exit;
351
-            }
352
-
353
-            redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS);
354
-        } else {
355
-            // no confirm: show deletion condition
356
-            if (!$confirm_msg) {
357
-                $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM;
358
-            }
359
-
360
-            ob_start();
361
-            xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'),
362
-                          sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
363
-            $smartobjectDeleteConfirm = ob_get_clean();
364
-            $xoopsTpl->assign('smartobject_delete_confirm', $smartobjectDeleteConfirm);
365
-        }
366
-    }
367
-
368
-    /**
369
-     * Retreive the object admin side link for a {@link SmartObjectSingleView} page
370
-     *
371
-     * @param  SmartObject $smartObj  reference to the object from which we want the user side link
372
-     * @param  bool   $onlyUrl   wether or not to return a simple URL or a full <a> link
373
-     * @param  bool   $withimage
374
-     * @return string admin side link to the object
375
-     */
376
-    public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false)
377
-    {
378
-        $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
379
-        if ($onlyUrl) {
380
-            return $ret;
381
-        } elseif ($withimage) {
382
-            return "<a href='" .
383
-                   $ret .
384
-                   "'><img src='" .
385
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
386
-                   "viewmag.png' style='vertical-align: middle;' alt='" .
387
-                   _CO_SOBJECT_ADMIN_VIEW .
388
-                   "'  title='" .
389
-                   _CO_SOBJECT_ADMIN_VIEW .
390
-                   "'/></a>";
391
-        }
392
-
393
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
394
-    }
395
-
396
-    /**
397
-     * Retreive the object user side link
398
-     *
399
-     * @param  SmartObject $smartObj reference to the object from which we want the user side link
400
-     * @param  bool   $onlyUrl  wether or not to return a simple URL or a full <a> link
401
-     * @return string user side link to the object
402
-     */
403
-    public function getItemLink(SmartObject $smartObj, $onlyUrl = false)
404
-    {
405
-        $seoMode       = smart_getModuleModeSEO($this->handler->_moduleName);
406
-        $seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
407
-
408
-        /**
409
-         * $seoIncludeId feature is not finished yet, so let's put it always to true
410
-         */
411
-        //$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName);
412
-        $seoIncludeId = true;
413
-
414
-        if ($seoMode === 'rewrite') {
415
-            $ret = XOOPS_URL .
416
-                   '/' .
417
-                   $seoModuleName .
418
-                   '.' .
419
-                   $this->handler->_itemname .
420
-                   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
421
-                   '/' .
422
-                   $smartObj->getVar('short_url') .
423
-                   '.html';
424
-        } elseif ($seoMode === 'pathinfo') {
425
-            $ret = SMARTOBJECT_URL .
426
-                   'seo.php/' .
427
-                   $seoModuleName .
428
-                   '.' .
429
-                   $this->handler->_itemname .
430
-                   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
431
-                   '/' .
432
-                   $smartObj->getVar('short_url') .
433
-                   '.html';
434
-        } else {
435
-            $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
436
-        }
437
-
438
-        if (!$onlyUrl) {
439
-            $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
440
-        }
441
-
442
-        return $ret;
443
-    }
444
-
445
-    /**
446
-     * @param         $smartObj
447
-     * @param  bool   $onlyUrl
448
-     * @param  bool   $withimage
449
-     * @return string
450
-     */
451
-    public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true)
452
-    {
453
-        $ret = $this->handler->_moduleUrl .
454
-               'admin/' .
455
-               $this->handler->_page .
456
-               '?op=mod&' .
457
-               $this->handler->keyName .
458
-               '=' .
459
-               $smartObj->getVar($this->handler->keyName) .
460
-               '&language=' .
461
-               $smartObj->getVar('language');
462
-        if ($onlyUrl) {
463
-            return $ret;
464
-        } elseif ($withimage) {
465
-            return "<a href='" .
466
-                   $ret .
467
-                   "'><img src='" .
468
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
469
-                   "wizard.png' style='vertical-align: middle;' alt='" .
470
-                   _CO_SOBJECT_LANGUAGE_MODIFY .
471
-                   "'  title='" .
472
-                   _CO_SOBJECT_LANGUAGE_MODIFY .
473
-                   "'/></a>";
474
-        }
475
-
476
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
477
-    }
478
-
479
-    /**
480
-     * @param         $smartObj
481
-     * @param  bool   $onlyUrl
482
-     * @param  bool   $withimage
483
-     * @param  bool   $userSide
484
-     * @return string
485
-     */
486
-    public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
487
-    {
488
-        $admin_side = $userSide ? '' : 'admin/';
489
-        $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
490
-        if ($onlyUrl) {
491
-            return $ret;
492
-        } elseif ($withimage) {
493
-            return "<a href='" .
494
-                   $ret .
495
-                   "'><img src='" .
496
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
497
-                   "edit.png' style='vertical-align: middle;' alt='" .
498
-                   _CO_SOBJECT_MODIFY .
499
-                   "'  title='" .
500
-                   _CO_SOBJECT_MODIFY .
501
-                   "'/></a>";
502
-        }
503
-
504
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
505
-    }
506
-
507
-    /**
508
-     * @param         $smartObj
509
-     * @param  bool   $onlyUrl
510
-     * @param  bool   $withimage
511
-     * @param  bool   $userSide
512
-     * @return string
513
-     */
514
-    public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
515
-    {
516
-        $admin_side = $userSide ? '' : 'admin/';
517
-        $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
518
-        if ($onlyUrl) {
519
-            return $ret;
520
-        } elseif ($withimage) {
521
-            return "<a href='" .
522
-                   $ret .
523
-                   "'><img src='" .
524
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
525
-                   "editdelete.png' style='vertical-align: middle;' alt='" .
526
-                   _CO_SOBJECT_DELETE .
527
-                   "'  title='" .
528
-                   _CO_SOBJECT_DELETE .
529
-                   "'/></a>";
530
-        }
531
-
532
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
533
-    }
534
-
535
-    /**
536
-     * @param $smartObj
537
-     * @return string
538
-     */
539
-    public function getPrintAndMailLink($smartObj)
540
-    {
541
-        global $xoopsConfig;
542
-
543
-        $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
544
-        $js        = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);";
545
-        $printlink = '<a href="' . $js . '"><img  src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"/></a>';
546
-
547
-        $smartModule = smart_getModuleInfo($smartObj->handler->_moduleName);
548
-        $link        = smart_getCurrentPage();
549
-        $mid         = $smartModule->getVar('mid');
550
-        $friendlink  = "<a href=\"javascript:openWithSelfMain('" .
551
-                       SMARTOBJECT_URL .
552
-                       'sendlink.php?link=' .
553
-                       $link .
554
-                       '&amp;mid=' .
555
-                       $mid .
556
-                       "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" .
557
-                       SMARTOBJECT_IMAGES_ACTIONS_URL .
558
-                       "mail_send.png\"  alt=\"" .
559
-                       _CO_SOBJECT_EMAIL .
560
-                       "\" title=\"" .
561
-                       _CO_SOBJECT_EMAIL .
562
-                       "\" style=\"vertical-align: middle;\"/></a>";
563
-
564
-        $ret = '<span id="smartobject_print_button">' . $printlink . '&nbsp;</span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>';
565
-
566
-        return $ret;
567
-    }
568
-
569
-    /**
570
-     * @return string
571
-     */
572
-    public function getModuleItemString()
573
-    {
574
-        $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname;
575
-
576
-        return $ret;
577
-    }
34
+	public $handler;
35
+
36
+	/**
37
+	 * SmartObjectController constructor.
38
+	 * @param $handler
39
+	 */
40
+	public function __construct($handler)
41
+	{
42
+		$this->handler = $handler;
43
+	}
44
+
45
+	/**
46
+	 * @param $smartObj
47
+	 */
48
+	public function postDataToObject(&$smartObj)
49
+	{
50
+		foreach (array_keys($smartObj->vars) as $key) {
51
+			switch ($smartObj->vars[$key]['data_type']) {
52
+				case XOBJ_DTYPE_IMAGE:
53
+					if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') {
54
+						$oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
55
+						$smartObj->setVar($key, $_POST['url_' . $key]);
56
+						if (file_exists($oldFile)) {
57
+							unlink($oldFile);
58
+						}
59
+					}
60
+					if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') {
61
+						$oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
62
+						$smartObj->setVar($key, '');
63
+						if (file_exists($oldFile)) {
64
+							unlink($oldFile);
65
+						}
66
+					}
67
+					break;
68
+
69
+				case XOBJ_DTYPE_URLLINK:
70
+					$linkObj = $smartObj->getUrlLinkObj($key);
71
+					$linkObj->setVar('caption', $_POST['caption_' . $key]);
72
+					$linkObj->setVar('description', $_POST['desc_' . $key]);
73
+					$linkObj->setVar('target', $_POST['target_' . $key]);
74
+					$linkObj->setVar('url', $_POST['url_' . $key]);
75
+					if ($linkObj->getVar('url') !== '') {
76
+						$smartObj->storeUrlLinkObj($linkObj);
77
+					}
78
+					//todo: catch errors
79
+					$smartObj->setVar($key, $linkObj->getVar('urllinkid'));
80
+					break;
81
+
82
+				case XOBJ_DTYPE_FILE:
83
+					if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') {
84
+						$fileObj = $smartObj->getFileObj($key);
85
+						$fileObj->setVar('caption', $_POST['caption_' . $key]);
86
+						$fileObj->setVar('description', $_POST['desc_' . $key]);
87
+						$fileObj->setVar('url', $_POST['url_' . $key]);
88
+						if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' && $fileObj->getVar('url') === '')) {
89
+							$res = $smartObj->storeFileObj($fileObj);
90
+							if ($res) {
91
+								$smartObj->setVar($key, $fileObj->getVar('fileid'));
92
+							} else {
93
+								//error setted, but no error message (to be improved)
94
+								$smartObj->setErrors($fileObj->getErrors());
95
+							}
96
+						}
97
+					}
98
+					break;
99
+
100
+				case XOBJ_DTYPE_STIME:
101
+				case XOBJ_DTYPE_MTIME:
102
+				case XOBJ_DTYPE_LTIME:
103
+					// check if this field's value is available in the POST array
104
+					if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) {
105
+						$value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
106
+					} else {
107
+						$value = strtotime($_POST[$key]);
108
+						//if strtotime returns false, the value is already a time stamp
109
+						if (!$value) {
110
+							$value = (int)$_POST[$key];
111
+						}
112
+					}
113
+					$smartObj->setVar($key, $value);
114
+
115
+					break;
116
+
117
+				default:
118
+					$smartObj->setVar($key, $_POST[$key]);
119
+					break;
120
+			}
121
+		}
122
+	}
123
+
124
+	/**
125
+	 * @param        $smartObj
126
+	 * @param        $objectid
127
+	 * @param        $created_success_msg
128
+	 * @param        $modified_success_msg
129
+	 * @param  bool  $redirect_page
130
+	 * @param  bool  $debug
131
+	 * @return mixed
132
+	 */
133
+	public function doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false)
134
+	{
135
+		global $smart_previous_page;
136
+
137
+		$this->postDataToObject($smartObj);
138
+
139
+		if ($smartObj->isNew()) {
140
+			$redirect_msg = $created_success_msg;
141
+		} else {
142
+			$redirect_msg = $modified_success_msg;
143
+		}
144
+
145
+		// Check if there were uploaded files
146
+		if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) {
147
+			include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php';
148
+			$uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight);
149
+			foreach ($_FILES as $name => $file_array) {
150
+				if (isset($file_array['name']) && $file_array['name'] !== '' && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) {
151
+					if ($uploaderObj->fetchMedia($name)) {
152
+						$uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName());
153
+						if ($uploaderObj->upload()) {
154
+							// Find the related field in the SmartObject
155
+							$related_field   = str_replace('upload_', '', $name);
156
+							$uploadedArray[] = $related_field;
157
+							//si c'est un fichier Rich
158
+							if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) {
159
+								$object_fileurl = $smartObj->getUploadDir();
160
+								$fileObj        = $smartObj->getFileObj($related_field);
161
+								$fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName());
162
+								$fileObj->setVar('caption', $_POST['caption_' . $related_field]);
163
+								$fileObj->setVar('description', $_POST['desc_' . $related_field]);
164
+								$smartObj->storeFileObj($fileObj);
165
+								//todo: catch errors
166
+								$smartObj->setVar($related_field, $fileObj->getVar('fileid'));
167
+							} else {
168
+								$old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field);
169
+								unlink($old_file);
170
+								$smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
171
+							}
172
+						} else {
173
+							$smartObj->setErrors($uploaderObj->getErrors(false));
174
+						}
175
+					} else {
176
+						$smartObj->setErrors($uploaderObj->getErrors(false));
177
+					}
178
+				}
179
+			}
180
+		}
181
+
182
+		if ($debug) {
183
+			$storeResult = $this->handler->insertD($smartObj);
184
+		} else {
185
+			$storeResult = $this->handler->insert($smartObj);
186
+		}
187
+
188
+		if ($storeResult) {
189
+			if ($this->handler->getPermissions()) {
190
+				$smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
191
+				$smartPermissionsHandler->storeAllPermissionsForId($smartObj->id());
192
+			}
193
+		}
194
+
195
+		if ($redirect_page === null) {
196
+			return $smartObj;
197
+		} else {
198
+			if (!$storeResult) {
199
+				redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors());
200
+			}
201
+
202
+			$redirect_page = $redirect_page ?: smart_get_page_before_form();
203
+
204
+			redirect_header($redirect_page, 2, $redirect_msg);
205
+		}
206
+	}
207
+
208
+	/**
209
+	 * Store the object in the database autmatically from a form sending POST data
210
+	 *
211
+	 * @param  string      $created_success_msg  message to display if new object was created
212
+	 * @param  string      $modified_success_msg message to display if object was successfully edited
213
+	 * @param  bool|string $redirect_page        redirect page, if not set, then we backup once
214
+	 * @param  bool        $debug
215
+	 * @param  bool        $x_param
216
+	 * @return bool
217
+	 * @internal param string $created_redir_page redirect page after creating the object
218
+	 * @internal param string $modified_redir_page redirect page after editing the object
219
+	 * @internal param bool $exit if set to TRUE then the script ends
220
+	 */
221
+	public function storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false, $x_param = false)
222
+	{
223
+		$objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0;
224
+		if ($debug) {
225
+			if ($x_param) {
226
+				$smartObj = $this->handler->getD($objectid, true, $x_param);
227
+			} else {
228
+				$smartObj = $this->handler->getD($objectid);
229
+			}
230
+		} else {
231
+			if ($x_param) {
232
+				$smartObj = $this->handler->get($objectid, true, false, false, $x_param);
233
+			} else {
234
+				$smartObj = $this->handler->get($objectid);
235
+			}
236
+		}
237
+
238
+		// if handler is the Multilanguage handler, we will need to treat this for multilanguage
239
+		if (is_subclass_of($this->handler, 'smartpersistablemlobjecthandler')) {
240
+			if ($smartObj->isNew()) {
241
+				// This is a new object. We need to store the meta data and then the language data
242
+				// First, we will get rid of the multilanguage data to only store the meta data
243
+				$smartObj->stripMultilanguageFields();
244
+				$newObject = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
245
+				/**
246
+				 * @todo we need to trap potential errors here
247
+				 */
248
+
249
+				// ok, the meta daa is stored. Let's recreate the object and then
250
+				// get rid of anything not multilanguage
251
+				unset($smartObj);
252
+				$smartObj = $this->handler->get($objectid);
253
+				$smartObj->stripNonMultilanguageFields();
254
+
255
+				$smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName));
256
+				$this->handler->changeTableNameForML();
257
+				$ret = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
258
+
259
+				return $ret;
260
+			}
261
+		} else {
262
+			return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
263
+		}
264
+	}
265
+
266
+	/**
267
+	 * @return bool
268
+	 */
269
+	public function storeSmartObjectD()
270
+	{
271
+		return $this->storeSmartObject(true);
272
+	}
273
+
274
+	/**
275
+	 * @param  bool $debug
276
+	 * @param  bool $xparam
277
+	 * @return bool
278
+	 */
279
+	public function storeSmartObject($debug = false, $xparam = false)
280
+	{
281
+		$ret = $this->storeFromDefaultForm('', '', null, $debug, $xparam);
282
+
283
+		return $ret;
284
+	}
285
+
286
+	/**
287
+	 * Handles deletion of an object which keyid is passed as a GET param
288
+	 *
289
+	 * @param  bool   $confirm_msg
290
+	 * @param  string $op
291
+	 * @param  bool   $userSide
292
+	 * @return bool
293
+	 * @internal param string $redir_page redirect page after deleting the object
294
+	 */
295
+	public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false)
296
+	{
297
+		global $smart_previous_page;
298
+
299
+		$objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
300
+		$smartObj = $this->handler->get($objectid);
301
+
302
+		if ($smartObj->isNew()) {
303
+			redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED);
304
+		}
305
+
306
+		$confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
307
+		if ($confirm) {
308
+			if (!$this->handler->delete($smartObj)) {
309
+				redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
310
+				exit;
311
+			}
312
+
313
+			redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS);
314
+		} else {
315
+			// no confirm: show deletion condition
316
+
317
+			xoops_cp_header();
318
+
319
+			if (!$confirm_msg) {
320
+				$confirm_msg = _CO_SOBJECT_DELETE_CONFIRM;
321
+			}
322
+
323
+			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'),
324
+						  sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
325
+
326
+			xoops_cp_footer();
327
+		}
328
+		exit();
329
+	}
330
+
331
+	/**
332
+	 * @param bool   $confirm_msg
333
+	 * @param string $op
334
+	 */
335
+	public function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del')
336
+	{
337
+		global $smart_previous_page, $xoopsTpl;
338
+
339
+		$objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
340
+		$smartObj = $this->handler->get($objectid);
341
+
342
+		if ($smartObj->isNew()) {
343
+			redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED);
344
+		}
345
+
346
+		$confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
347
+		if ($confirm) {
348
+			if (!$this->handler->delete($smartObj)) {
349
+				redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
350
+				exit;
351
+			}
352
+
353
+			redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS);
354
+		} else {
355
+			// no confirm: show deletion condition
356
+			if (!$confirm_msg) {
357
+				$confirm_msg = _CO_SOBJECT_DELETE_CONFIRM;
358
+			}
359
+
360
+			ob_start();
361
+			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'),
362
+						  sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
363
+			$smartobjectDeleteConfirm = ob_get_clean();
364
+			$xoopsTpl->assign('smartobject_delete_confirm', $smartobjectDeleteConfirm);
365
+		}
366
+	}
367
+
368
+	/**
369
+	 * Retreive the object admin side link for a {@link SmartObjectSingleView} page
370
+	 *
371
+	 * @param  SmartObject $smartObj  reference to the object from which we want the user side link
372
+	 * @param  bool   $onlyUrl   wether or not to return a simple URL or a full <a> link
373
+	 * @param  bool   $withimage
374
+	 * @return string admin side link to the object
375
+	 */
376
+	public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false)
377
+	{
378
+		$ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
379
+		if ($onlyUrl) {
380
+			return $ret;
381
+		} elseif ($withimage) {
382
+			return "<a href='" .
383
+				   $ret .
384
+				   "'><img src='" .
385
+				   SMARTOBJECT_IMAGES_ACTIONS_URL .
386
+				   "viewmag.png' style='vertical-align: middle;' alt='" .
387
+				   _CO_SOBJECT_ADMIN_VIEW .
388
+				   "'  title='" .
389
+				   _CO_SOBJECT_ADMIN_VIEW .
390
+				   "'/></a>";
391
+		}
392
+
393
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
394
+	}
395
+
396
+	/**
397
+	 * Retreive the object user side link
398
+	 *
399
+	 * @param  SmartObject $smartObj reference to the object from which we want the user side link
400
+	 * @param  bool   $onlyUrl  wether or not to return a simple URL or a full <a> link
401
+	 * @return string user side link to the object
402
+	 */
403
+	public function getItemLink(SmartObject $smartObj, $onlyUrl = false)
404
+	{
405
+		$seoMode       = smart_getModuleModeSEO($this->handler->_moduleName);
406
+		$seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
407
+
408
+		/**
409
+		 * $seoIncludeId feature is not finished yet, so let's put it always to true
410
+		 */
411
+		//$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName);
412
+		$seoIncludeId = true;
413
+
414
+		if ($seoMode === 'rewrite') {
415
+			$ret = XOOPS_URL .
416
+				   '/' .
417
+				   $seoModuleName .
418
+				   '.' .
419
+				   $this->handler->_itemname .
420
+				   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
421
+				   '/' .
422
+				   $smartObj->getVar('short_url') .
423
+				   '.html';
424
+		} elseif ($seoMode === 'pathinfo') {
425
+			$ret = SMARTOBJECT_URL .
426
+				   'seo.php/' .
427
+				   $seoModuleName .
428
+				   '.' .
429
+				   $this->handler->_itemname .
430
+				   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
431
+				   '/' .
432
+				   $smartObj->getVar('short_url') .
433
+				   '.html';
434
+		} else {
435
+			$ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
436
+		}
437
+
438
+		if (!$onlyUrl) {
439
+			$ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
440
+		}
441
+
442
+		return $ret;
443
+	}
444
+
445
+	/**
446
+	 * @param         $smartObj
447
+	 * @param  bool   $onlyUrl
448
+	 * @param  bool   $withimage
449
+	 * @return string
450
+	 */
451
+	public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true)
452
+	{
453
+		$ret = $this->handler->_moduleUrl .
454
+			   'admin/' .
455
+			   $this->handler->_page .
456
+			   '?op=mod&' .
457
+			   $this->handler->keyName .
458
+			   '=' .
459
+			   $smartObj->getVar($this->handler->keyName) .
460
+			   '&language=' .
461
+			   $smartObj->getVar('language');
462
+		if ($onlyUrl) {
463
+			return $ret;
464
+		} elseif ($withimage) {
465
+			return "<a href='" .
466
+				   $ret .
467
+				   "'><img src='" .
468
+				   SMARTOBJECT_IMAGES_ACTIONS_URL .
469
+				   "wizard.png' style='vertical-align: middle;' alt='" .
470
+				   _CO_SOBJECT_LANGUAGE_MODIFY .
471
+				   "'  title='" .
472
+				   _CO_SOBJECT_LANGUAGE_MODIFY .
473
+				   "'/></a>";
474
+		}
475
+
476
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
477
+	}
478
+
479
+	/**
480
+	 * @param         $smartObj
481
+	 * @param  bool   $onlyUrl
482
+	 * @param  bool   $withimage
483
+	 * @param  bool   $userSide
484
+	 * @return string
485
+	 */
486
+	public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
487
+	{
488
+		$admin_side = $userSide ? '' : 'admin/';
489
+		$ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
490
+		if ($onlyUrl) {
491
+			return $ret;
492
+		} elseif ($withimage) {
493
+			return "<a href='" .
494
+				   $ret .
495
+				   "'><img src='" .
496
+				   SMARTOBJECT_IMAGES_ACTIONS_URL .
497
+				   "edit.png' style='vertical-align: middle;' alt='" .
498
+				   _CO_SOBJECT_MODIFY .
499
+				   "'  title='" .
500
+				   _CO_SOBJECT_MODIFY .
501
+				   "'/></a>";
502
+		}
503
+
504
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
505
+	}
506
+
507
+	/**
508
+	 * @param         $smartObj
509
+	 * @param  bool   $onlyUrl
510
+	 * @param  bool   $withimage
511
+	 * @param  bool   $userSide
512
+	 * @return string
513
+	 */
514
+	public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
515
+	{
516
+		$admin_side = $userSide ? '' : 'admin/';
517
+		$ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
518
+		if ($onlyUrl) {
519
+			return $ret;
520
+		} elseif ($withimage) {
521
+			return "<a href='" .
522
+				   $ret .
523
+				   "'><img src='" .
524
+				   SMARTOBJECT_IMAGES_ACTIONS_URL .
525
+				   "editdelete.png' style='vertical-align: middle;' alt='" .
526
+				   _CO_SOBJECT_DELETE .
527
+				   "'  title='" .
528
+				   _CO_SOBJECT_DELETE .
529
+				   "'/></a>";
530
+		}
531
+
532
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
533
+	}
534
+
535
+	/**
536
+	 * @param $smartObj
537
+	 * @return string
538
+	 */
539
+	public function getPrintAndMailLink($smartObj)
540
+	{
541
+		global $xoopsConfig;
542
+
543
+		$printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
544
+		$js        = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);";
545
+		$printlink = '<a href="' . $js . '"><img  src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"/></a>';
546
+
547
+		$smartModule = smart_getModuleInfo($smartObj->handler->_moduleName);
548
+		$link        = smart_getCurrentPage();
549
+		$mid         = $smartModule->getVar('mid');
550
+		$friendlink  = "<a href=\"javascript:openWithSelfMain('" .
551
+					   SMARTOBJECT_URL .
552
+					   'sendlink.php?link=' .
553
+					   $link .
554
+					   '&amp;mid=' .
555
+					   $mid .
556
+					   "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" .
557
+					   SMARTOBJECT_IMAGES_ACTIONS_URL .
558
+					   "mail_send.png\"  alt=\"" .
559
+					   _CO_SOBJECT_EMAIL .
560
+					   "\" title=\"" .
561
+					   _CO_SOBJECT_EMAIL .
562
+					   "\" style=\"vertical-align: middle;\"/></a>";
563
+
564
+		$ret = '<span id="smartobject_print_button">' . $printlink . '&nbsp;</span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>';
565
+
566
+		return $ret;
567
+	}
568
+
569
+	/**
570
+	 * @return string
571
+	 */
572
+	public function getModuleItemString()
573
+	{
574
+		$ret = $this->handler->_moduleName . '_' . $this->handler->_itemname;
575
+
576
+		return $ret;
577
+	}
578 578
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  * @credit  Jan Keller Pedersen <[email protected]> - IDG Danmark A/S <www.idg.dk>
24 24
  * @link    http://smartfactory.ca The SmartFactory
25 25
  */
26
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
27
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecthandler.php';
26
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php';
27
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjecthandler.php';
28 28
 
29 29
 /**
30 30
  * Class SmartObjectController
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
         foreach (array_keys($smartObj->vars) as $key) {
51 51
             switch ($smartObj->vars[$key]['data_type']) {
52 52
                 case XOBJ_DTYPE_IMAGE:
53
-                    if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') {
54
-                        $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
55
-                        $smartObj->setVar($key, $_POST['url_' . $key]);
53
+                    if (isset($_POST['url_'.$key]) && $_POST['url_'.$key] !== '') {
54
+                        $oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
55
+                        $smartObj->setVar($key, $_POST['url_'.$key]);
56 56
                         if (file_exists($oldFile)) {
57 57
                             unlink($oldFile);
58 58
                         }
59 59
                     }
60
-                    if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') {
61
-                        $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
60
+                    if (isset($_POST['delete_'.$key]) && $_POST['delete_'.$key] == '1') {
61
+                        $oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
62 62
                         $smartObj->setVar($key, '');
63 63
                         if (file_exists($oldFile)) {
64 64
                             unlink($oldFile);
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 
69 69
                 case XOBJ_DTYPE_URLLINK:
70 70
                     $linkObj = $smartObj->getUrlLinkObj($key);
71
-                    $linkObj->setVar('caption', $_POST['caption_' . $key]);
72
-                    $linkObj->setVar('description', $_POST['desc_' . $key]);
73
-                    $linkObj->setVar('target', $_POST['target_' . $key]);
74
-                    $linkObj->setVar('url', $_POST['url_' . $key]);
71
+                    $linkObj->setVar('caption', $_POST['caption_'.$key]);
72
+                    $linkObj->setVar('description', $_POST['desc_'.$key]);
73
+                    $linkObj->setVar('target', $_POST['target_'.$key]);
74
+                    $linkObj->setVar('url', $_POST['url_'.$key]);
75 75
                     if ($linkObj->getVar('url') !== '') {
76 76
                         $smartObj->storeUrlLinkObj($linkObj);
77 77
                     }
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
                     break;
81 81
 
82 82
                 case XOBJ_DTYPE_FILE:
83
-                    if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') {
83
+                    if (!isset($_FILES['upload_'.$key]['name']) || $_FILES['upload_'.$key]['name'] === '') {
84 84
                         $fileObj = $smartObj->getFileObj($key);
85
-                        $fileObj->setVar('caption', $_POST['caption_' . $key]);
86
-                        $fileObj->setVar('description', $_POST['desc_' . $key]);
87
-                        $fileObj->setVar('url', $_POST['url_' . $key]);
85
+                        $fileObj->setVar('caption', $_POST['caption_'.$key]);
86
+                        $fileObj->setVar('description', $_POST['desc_'.$key]);
87
+                        $fileObj->setVar('url', $_POST['url_'.$key]);
88 88
                         if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' && $fileObj->getVar('url') === '')) {
89 89
                             $res = $smartObj->storeFileObj($fileObj);
90 90
                             if ($res) {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                         $value = strtotime($_POST[$key]);
108 108
                         //if strtotime returns false, the value is already a time stamp
109 109
                         if (!$value) {
110
-                            $value = (int)$_POST[$key];
110
+                            $value = (int) $_POST[$key];
111 111
                         }
112 112
                     }
113 113
                     $smartObj->setVar($key, $value);
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
 
145 145
         // Check if there were uploaded files
146 146
         if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) {
147
-            include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php';
147
+            include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartuploader.php';
148 148
             $uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight);
149 149
             foreach ($_FILES as $name => $file_array) {
150 150
                 if (isset($file_array['name']) && $file_array['name'] !== '' && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) {
151 151
                     if ($uploaderObj->fetchMedia($name)) {
152
-                        $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName());
152
+                        $uploaderObj->setTargetFileName(time().'_'.$uploaderObj->getMediaName());
153 153
                         if ($uploaderObj->upload()) {
154 154
                             // Find the related field in the SmartObject
155 155
                             $related_field   = str_replace('upload_', '', $name);
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
                             if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) {
159 159
                                 $object_fileurl = $smartObj->getUploadDir();
160 160
                                 $fileObj        = $smartObj->getFileObj($related_field);
161
-                                $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName());
162
-                                $fileObj->setVar('caption', $_POST['caption_' . $related_field]);
163
-                                $fileObj->setVar('description', $_POST['desc_' . $related_field]);
161
+                                $fileObj->setVar('url', $object_fileurl.$uploaderObj->getSavedFileName());
162
+                                $fileObj->setVar('caption', $_POST['caption_'.$related_field]);
163
+                                $fileObj->setVar('description', $_POST['desc_'.$related_field]);
164 164
                                 $smartObj->storeFileObj($fileObj);
165 165
                                 //todo: catch errors
166 166
                                 $smartObj->setVar($related_field, $fileObj->getVar('fileid'));
167 167
                             } else {
168
-                                $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field);
168
+                                $old_file = $smartObj->getUploadDir(true).$smartObj->getVar($related_field);
169 169
                                 unlink($old_file);
170 170
                                 $smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
171 171
                             }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             return $smartObj;
197 197
         } else {
198 198
             if (!$storeResult) {
199
-                redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors());
199
+                redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR.$smartObj->getHtmlErrors());
200 200
             }
201 201
 
202 202
             $redirect_page = $redirect_page ?: smart_get_page_before_form();
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false, $x_param = false)
222 222
     {
223
-        $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0;
223
+        $objectid = isset($_POST[$this->handler->keyName]) ? (int) $_POST[$this->handler->keyName] : 0;
224 224
         if ($debug) {
225 225
             if ($x_param) {
226 226
                 $smartObj = $this->handler->getD($objectid, true, $x_param);
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     {
297 297
         global $smart_previous_page;
298 298
 
299
-        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
299
+        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int) $_REQUEST[$this->handler->keyName] : 0;
300 300
         $smartObj = $this->handler->get($objectid);
301 301
 
302 302
         if ($smartObj->isNew()) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
307 307
         if ($confirm) {
308 308
             if (!$this->handler->delete($smartObj)) {
309
-                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
309
+                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR.$smartObj->getHtmlErrors());
310 310
                 exit;
311 311
             }
312 312
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     {
337 337
         global $smart_previous_page, $xoopsTpl;
338 338
 
339
-        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0;
339
+        $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int) $_REQUEST[$this->handler->keyName] : 0;
340 340
         $smartObj = $this->handler->get($objectid);
341 341
 
342 342
         if ($smartObj->isNew()) {
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
347 347
         if ($confirm) {
348 348
             if (!$this->handler->delete($smartObj)) {
349
-                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
349
+                redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR.$smartObj->getHtmlErrors());
350 350
                 exit;
351 351
             }
352 352
 
@@ -375,22 +375,22 @@  discard block
 block discarded – undo
375 375
      */
376 376
     public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false)
377 377
     {
378
-        $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
378
+        $ret = $this->handler->_moduleUrl.'admin/'.$this->handler->_page.'?op=view&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName);
379 379
         if ($onlyUrl) {
380 380
             return $ret;
381 381
         } elseif ($withimage) {
382
-            return "<a href='" .
383
-                   $ret .
384
-                   "'><img src='" .
385
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
386
-                   "viewmag.png' style='vertical-align: middle;' alt='" .
387
-                   _CO_SOBJECT_ADMIN_VIEW .
388
-                   "'  title='" .
389
-                   _CO_SOBJECT_ADMIN_VIEW .
382
+            return "<a href='".
383
+                   $ret.
384
+                   "'><img src='".
385
+                   SMARTOBJECT_IMAGES_ACTIONS_URL.
386
+                   "viewmag.png' style='vertical-align: middle;' alt='".
387
+                   _CO_SOBJECT_ADMIN_VIEW.
388
+                   "'  title='".
389
+                   _CO_SOBJECT_ADMIN_VIEW.
390 390
                    "'/></a>";
391 391
         }
392 392
 
393
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
393
+        return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>';
394 394
     }
395 395
 
396 396
     /**
@@ -412,31 +412,31 @@  discard block
 block discarded – undo
412 412
         $seoIncludeId = true;
413 413
 
414 414
         if ($seoMode === 'rewrite') {
415
-            $ret = XOOPS_URL .
416
-                   '/' .
417
-                   $seoModuleName .
418
-                   '.' .
419
-                   $this->handler->_itemname .
420
-                   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
421
-                   '/' .
422
-                   $smartObj->getVar('short_url') .
415
+            $ret = XOOPS_URL.
416
+                   '/'.
417
+                   $seoModuleName.
418
+                   '.'.
419
+                   $this->handler->_itemname.
420
+                   ($seoIncludeId ? '.'.$smartObj->getVar($this->handler->keyName) : '').
421
+                   '/'.
422
+                   $smartObj->getVar('short_url').
423 423
                    '.html';
424 424
         } elseif ($seoMode === 'pathinfo') {
425
-            $ret = SMARTOBJECT_URL .
426
-                   'seo.php/' .
427
-                   $seoModuleName .
428
-                   '.' .
429
-                   $this->handler->_itemname .
430
-                   ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') .
431
-                   '/' .
432
-                   $smartObj->getVar('short_url') .
425
+            $ret = SMARTOBJECT_URL.
426
+                   'seo.php/'.
427
+                   $seoModuleName.
428
+                   '.'.
429
+                   $this->handler->_itemname.
430
+                   ($seoIncludeId ? '.'.$smartObj->getVar($this->handler->keyName) : '').
431
+                   '/'.
432
+                   $smartObj->getVar('short_url').
433 433
                    '.html';
434 434
         } else {
435
-            $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
435
+            $ret = $this->handler->_moduleUrl.$this->handler->_page.'?'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName);
436 436
         }
437 437
 
438 438
         if (!$onlyUrl) {
439
-            $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
439
+            $ret = "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>';
440 440
         }
441 441
 
442 442
         return $ret;
@@ -450,30 +450,30 @@  discard block
 block discarded – undo
450 450
      */
451 451
     public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true)
452 452
     {
453
-        $ret = $this->handler->_moduleUrl .
454
-               'admin/' .
455
-               $this->handler->_page .
456
-               '?op=mod&' .
457
-               $this->handler->keyName .
458
-               '=' .
459
-               $smartObj->getVar($this->handler->keyName) .
460
-               '&language=' .
453
+        $ret = $this->handler->_moduleUrl.
454
+               'admin/'.
455
+               $this->handler->_page.
456
+               '?op=mod&'.
457
+               $this->handler->keyName.
458
+               '='.
459
+               $smartObj->getVar($this->handler->keyName).
460
+               '&language='.
461 461
                $smartObj->getVar('language');
462 462
         if ($onlyUrl) {
463 463
             return $ret;
464 464
         } elseif ($withimage) {
465
-            return "<a href='" .
466
-                   $ret .
467
-                   "'><img src='" .
468
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
469
-                   "wizard.png' style='vertical-align: middle;' alt='" .
470
-                   _CO_SOBJECT_LANGUAGE_MODIFY .
471
-                   "'  title='" .
472
-                   _CO_SOBJECT_LANGUAGE_MODIFY .
465
+            return "<a href='".
466
+                   $ret.
467
+                   "'><img src='".
468
+                   SMARTOBJECT_IMAGES_ACTIONS_URL.
469
+                   "wizard.png' style='vertical-align: middle;' alt='".
470
+                   _CO_SOBJECT_LANGUAGE_MODIFY.
471
+                   "'  title='".
472
+                   _CO_SOBJECT_LANGUAGE_MODIFY.
473 473
                    "'/></a>";
474 474
         }
475 475
 
476
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
476
+        return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>';
477 477
     }
478 478
 
479 479
     /**
@@ -486,22 +486,22 @@  discard block
 block discarded – undo
486 486
     public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
487 487
     {
488 488
         $admin_side = $userSide ? '' : 'admin/';
489
-        $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
489
+        $ret        = $this->handler->_moduleUrl.$admin_side.$this->handler->_page.'?op=mod&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName);
490 490
         if ($onlyUrl) {
491 491
             return $ret;
492 492
         } elseif ($withimage) {
493
-            return "<a href='" .
494
-                   $ret .
495
-                   "'><img src='" .
496
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
497
-                   "edit.png' style='vertical-align: middle;' alt='" .
498
-                   _CO_SOBJECT_MODIFY .
499
-                   "'  title='" .
500
-                   _CO_SOBJECT_MODIFY .
493
+            return "<a href='".
494
+                   $ret.
495
+                   "'><img src='".
496
+                   SMARTOBJECT_IMAGES_ACTIONS_URL.
497
+                   "edit.png' style='vertical-align: middle;' alt='".
498
+                   _CO_SOBJECT_MODIFY.
499
+                   "'  title='".
500
+                   _CO_SOBJECT_MODIFY.
501 501
                    "'/></a>";
502 502
         }
503 503
 
504
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
504
+        return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>';
505 505
     }
506 506
 
507 507
     /**
@@ -514,22 +514,22 @@  discard block
 block discarded – undo
514 514
     public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
515 515
     {
516 516
         $admin_side = $userSide ? '' : 'admin/';
517
-        $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
517
+        $ret        = $this->handler->_moduleUrl.$admin_side.$this->handler->_page.'?op=del&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName);
518 518
         if ($onlyUrl) {
519 519
             return $ret;
520 520
         } elseif ($withimage) {
521
-            return "<a href='" .
522
-                   $ret .
523
-                   "'><img src='" .
524
-                   SMARTOBJECT_IMAGES_ACTIONS_URL .
525
-                   "editdelete.png' style='vertical-align: middle;' alt='" .
526
-                   _CO_SOBJECT_DELETE .
527
-                   "'  title='" .
528
-                   _CO_SOBJECT_DELETE .
521
+            return "<a href='".
522
+                   $ret.
523
+                   "'><img src='".
524
+                   SMARTOBJECT_IMAGES_ACTIONS_URL.
525
+                   "editdelete.png' style='vertical-align: middle;' alt='".
526
+                   _CO_SOBJECT_DELETE.
527
+                   "'  title='".
528
+                   _CO_SOBJECT_DELETE.
529 529
                    "'/></a>";
530 530
         }
531 531
 
532
-        return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>';
532
+        return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>';
533 533
     }
534 534
 
535 535
     /**
@@ -540,28 +540,28 @@  discard block
 block discarded – undo
540 540
     {
541 541
         global $xoopsConfig;
542 542
 
543
-        $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName);
544
-        $js        = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);";
545
-        $printlink = '<a href="' . $js . '"><img  src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"/></a>';
543
+        $printlink = $this->handler->_moduleUrl.'print.php?'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName);
544
+        $js        = "javascript:openWithSelfMain('".$printlink."', 'smartpopup', 700, 519);";
545
+        $printlink = '<a href="'.$js.'"><img  src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'fileprint.png" alt="" style="vertical-align: middle;"/></a>';
546 546
 
547 547
         $smartModule = smart_getModuleInfo($smartObj->handler->_moduleName);
548 548
         $link        = smart_getCurrentPage();
549 549
         $mid         = $smartModule->getVar('mid');
550
-        $friendlink  = "<a href=\"javascript:openWithSelfMain('" .
551
-                       SMARTOBJECT_URL .
552
-                       'sendlink.php?link=' .
553
-                       $link .
554
-                       '&amp;mid=' .
555
-                       $mid .
556
-                       "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" .
557
-                       SMARTOBJECT_IMAGES_ACTIONS_URL .
558
-                       "mail_send.png\"  alt=\"" .
559
-                       _CO_SOBJECT_EMAIL .
560
-                       "\" title=\"" .
561
-                       _CO_SOBJECT_EMAIL .
550
+        $friendlink  = "<a href=\"javascript:openWithSelfMain('".
551
+                       SMARTOBJECT_URL.
552
+                       'sendlink.php?link='.
553
+                       $link.
554
+                       '&amp;mid='.
555
+                       $mid.
556
+                       "', ',',',',',','sendmessage', 674, 500);\"><img src=\"".
557
+                       SMARTOBJECT_IMAGES_ACTIONS_URL.
558
+                       "mail_send.png\"  alt=\"".
559
+                       _CO_SOBJECT_EMAIL.
560
+                       "\" title=\"".
561
+                       _CO_SOBJECT_EMAIL.
562 562
                        "\" style=\"vertical-align: middle;\"/></a>";
563 563
 
564
-        $ret = '<span id="smartobject_print_button">' . $printlink . '&nbsp;</span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>';
564
+        $ret = '<span id="smartobject_print_button">'.$printlink.'&nbsp;</span>'.'<span id="smartobject_mail_button">'.$friendlink.'</span>';
565 565
 
566 566
         return $ret;
567 567
     }
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
      */
572 572
     public function getModuleItemString()
573 573
     {
574
-        $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname;
574
+        $ret = $this->handler->_moduleName.'_'.$this->handler->_itemname;
575 575
 
576 576
         return $ret;
577 577
     }
Please login to merge, or discard this patch.
class/smartobjecthandler.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @param XoopsDatabase $db           {@link XoopsDatabase}
134 134
      *                                           object
135
-     * @param                      $itemname
135
+     * @param                      string $itemname
136 136
      * @param string               $keyname      Name of the table key that uniquely identify each {@link SmartObject}
137 137
      * @param string               $idenfierName Name of the field which properly identify the {@link SmartObject}
138
-     * @param                      $summaryName
138
+     * @param                      string $summaryName
139 139
      * @param                      $modulename
140 140
      * @internal param string $tablename Name of the table use to store this <a href='psi_element://SmartObject'>SmartObject</a>
141 141
      * @internal param Name $string of the class derived from <a href='psi_element://SmartObject'>SmartObject</a> and which this handler is handling and which this handler is handling
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
     /**
193 193
      * @param $criteria
194
-     * @param $perm_name
194
+     * @param boolean $perm_name
195 195
      * @return bool
196 196
      */
197 197
     public function setGrantedObjectsCriteria(&$criteria, $perm_name)
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     /**
378
-     * @param        $sql
378
+     * @param        string $sql
379 379
      * @param        $criteria
380 380
      * @param  bool  $force
381 381
      * @param  bool  $debug
Please login to merge, or discard this patch.
Indentation   +966 added lines, -966 removed lines patch added patch discarded remove patch
@@ -25,970 +25,970 @@
 block discarded – undo
25 25
  */
26 26
 class SmartPersistableObjectHandler extends XoopsObjectHandler
27 27
 {
28
-    public $_itemname;
29
-
30
-    /**
31
-     * Name of the table use to store this {@link SmartObject}
32
-     *
33
-     * Note that the name of the table needs to be free of the database prefix.
34
-     * For example "smartsection_categories"
35
-     * @var string
36
-     */
37
-    public $table;
38
-
39
-    /**
40
-     * Name of the table key that uniquely identify each {@link SmartObject}
41
-     *
42
-     * For example: "categoryid"
43
-     * @var string
44
-     */
45
-    public $keyName;
46
-
47
-    /**
48
-     * Name of the class derived from {@link SmartObject} and which this handler is handling
49
-     *
50
-     * Note that this string needs to be lowercase
51
-     *
52
-     * For example: "smartsectioncategory"
53
-     * @var string
54
-     */
55
-    public $className;
56
-
57
-    /**
58
-     * Name of the field which properly identify the {@link SmartObject}
59
-     *
60
-     * For example: "name" (this will be the category's name)
61
-     * @var string
62
-     */
63
-    public $identifierName;
64
-
65
-    /**
66
-     * Name of the field which will be use as a summary for the object
67
-     *
68
-     * For example: "summary"
69
-     * @var string
70
-     */
71
-    public $summaryName;
72
-
73
-    /**
74
-     * Page name use to basically manage and display the {@link SmartObject}
75
-     *
76
-     * This page needs to be the same in user side and admin side
77
-     *
78
-     * For example category.php - we will deduct smartsection/category.php as well as smartsection/admin/category.php
79
-     * @todo this could probably be automatically deducted from the class name - for example, the class SmartsectionCategory will have "category.php" as it's managing page
80
-     * @var string
81
-     */
82
-    public $_page;
83
-
84
-    /**
85
-     * Full path of the module using this {@link SmartObject}
86
-     *
87
-     * <code>XOOPS_URL . "/modules/smartsection/"</code>
88
-     * @todo this could probably be automatically deducted from the class name as it is always prefixed with the module name
89
-     * @var string
90
-     */
91
-    public $_modulePath;
92
-
93
-    public $_moduleUrl;
94
-
95
-    public $_moduleName;
96
-
97
-    public $_uploadUrl;
98
-
99
-    public $_uploadPath;
100
-
101
-    public $_allowedMimeTypes = 0;
102
-
103
-    public $_maxFileSize = 1000000;
104
-
105
-    public $_maxWidth = 500;
106
-
107
-    public $_maxHeight = 500;
108
-
109
-    public $highlightFields = array();
110
-
111
-    /**
112
-     * Array containing the events name and functions
113
-     *
114
-     * @var array
115
-     */
116
-    public $eventArray = array();
117
-
118
-    /**
119
-     * Array containing the permissions that this handler will manage on the objects
120
-     *
121
-     * @var array
122
-     */
123
-    public $permissionsArray = false;
124
-
125
-    public $generalSQL = false;
126
-
127
-    public $_eventHooks     = array();
128
-    public $_disabledEvents = array();
129
-
130
-    /**
131
-     * Constructor - called from child classes
132
-     *
133
-     * @param XoopsDatabase $db           {@link XoopsDatabase}
134
-     *                                           object
135
-     * @param                      $itemname
136
-     * @param string               $keyname      Name of the table key that uniquely identify each {@link SmartObject}
137
-     * @param string               $idenfierName Name of the field which properly identify the {@link SmartObject}
138
-     * @param                      $summaryName
139
-     * @param                      $modulename
140
-     * @internal param string $tablename Name of the table use to store this <a href='psi_element://SmartObject'>SmartObject</a>
141
-     * @internal param Name $string of the class derived from <a href='psi_element://SmartObject'>SmartObject</a> and which this handler is handling and which this handler is handling
142
-     * @internal param string $page Page name use to basically manage and display the <a href='psi_element://SmartObject'>SmartObject</a>
143
-     * @internal param string $moduleName name of the module
144
-     */
145
-    public function __construct(XoopsDatabase $db, $itemname, $keyname, $idenfierName, $summaryName, $modulename)
146
-    {
147
-        parent::__construct($db);
148
-
149
-        $this->_itemname      = $itemname;
150
-        $this->_moduleName    = $modulename;
151
-        $this->table          = $db->prefix($modulename . '_' . $itemname);
152
-        $this->keyName        = $keyname;
153
-        $this->className      = ucfirst($modulename) . ucfirst($itemname);
154
-        $this->identifierName = $idenfierName;
155
-        $this->summaryName    = $summaryName;
156
-        $this->_page          = $itemname . '.php';
157
-        $this->_modulePath    = XOOPS_ROOT_PATH . '/modules/' . $this->_moduleName . '/';
158
-        $this->_moduleUrl     = XOOPS_URL . '/modules/' . $this->_moduleName . '/';
159
-        $this->_uploadPath    = XOOPS_UPLOAD_PATH . '/' . $this->_moduleName . '/';
160
-        $this->_uploadUrl     = XOOPS_UPLOAD_URL . '/' . $this->_moduleName . '/';
161
-    }
162
-
163
-    /**
164
-     * @param $event
165
-     * @param $method
166
-     */
167
-    public function addEventHook($event, $method)
168
-    {
169
-        $this->_eventHooks[$event] = $method;
170
-    }
171
-
172
-    /**
173
-     * Add a permission that this handler will manage for its objects
174
-     *
175
-     * Example: $this->addPermission('view', _AM_SSHOP_CAT_PERM_READ, _AM_SSHOP_CAT_PERM_READ_DSC);
176
-     *
177
-     * @param string      $perm_name   name of the permission
178
-     * @param string      $caption     caption of the control that will be displayed in the form
179
-     * @param bool|string $description description of the control that will be displayed in the form
180
-     */
181
-    public function addPermission($perm_name, $caption, $description = false)
182
-    {
183
-        include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
184
-
185
-        $this->permissionsArray[] = array(
186
-            'perm_name'   => $perm_name,
187
-            'caption'     => $caption,
188
-            'description' => $description
189
-        );
190
-    }
191
-
192
-    /**
193
-     * @param $criteria
194
-     * @param $perm_name
195
-     * @return bool
196
-     */
197
-    public function setGrantedObjectsCriteria(&$criteria, $perm_name)
198
-    {
199
-        $smartPermissionsHandler = new SmartobjectPermissionHandler($this);
200
-        $grantedItems            = $smartPermissionsHandler->getGrantedItems($perm_name);
201
-        if (count($grantedItems) > 0) {
202
-            $criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
203
-
204
-            return true;
205
-        } else {
206
-            return false;
207
-        }
208
-    }
209
-
210
-    /**
211
-     * @param bool $_uploadPath
212
-     * @param bool $_allowedMimeTypes
213
-     * @param bool $_maxFileSize
214
-     * @param bool $_maxWidth
215
-     * @param bool $_maxHeight
216
-     */
217
-    public function setUploaderConfig($_uploadPath = false, $_allowedMimeTypes = false, $_maxFileSize = false, $_maxWidth = false, $_maxHeight = false)
218
-    {
219
-        $this->_uploadPath       = $_uploadPath ?: $this->_uploadPath;
220
-        $this->_allowedMimeTypes = $_allowedMimeTypes ?: $this->_allowedMimeTypes;
221
-        $this->_maxFileSize      = $_maxFileSize ?: $this->_maxFileSize;
222
-        $this->_maxWidth         = $_maxWidth ?: $this->_maxWidth;
223
-        $this->_maxHeight        = $_maxHeight ?: $this->_maxHeight;
224
-    }
225
-
226
-    /**
227
-     * create a new {@link SmartObject}
228
-     *
229
-     * @param bool $isNew Flag the new objects as "new"?
230
-     *
231
-     * @return SmartObject {@link SmartObject}
232
-     */
233
-    public function create($isNew = true)
234
-    {
235
-        $obj = new $this->className($this);
236
-        $obj->setImageDir($this->getImageUrl(), $this->getImagePath());
237
-        if (!$obj->handler) {
238
-            $obj->handler =& $this;
239
-        }
240
-
241
-        if ($isNew === true) {
242
-            $obj->setNew();
243
-        }
244
-
245
-        return $obj;
246
-    }
247
-
248
-    /**
249
-     * @return string
250
-     */
251
-    public function getImageUrl()
252
-    {
253
-        return $this->_uploadUrl . $this->_itemname . '/';
254
-    }
255
-
256
-    /**
257
-     * @return string
258
-     */
259
-    public function getImagePath()
260
-    {
261
-        $dir = $this->_uploadPath . $this->_itemname;
262
-        if (!file_exists($dir)) {
263
-            smart_admin_mkdir($dir);
264
-        }
265
-
266
-        return $dir . '/';
267
-    }
268
-
269
-    /**
270
-     * retrieve a {@link SmartObject}
271
-     *
272
-     * @param  mixed $id        ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
273
-     * @param  bool  $as_object whether to return an object or an array
274
-     * @param  bool  $debug
275
-     * @param  bool  $criteria
276
-     * @return mixed reference to the <a href='psi_element://SmartObject'>SmartObject</a>, FALSE if failed
277
-     *                         FALSE if failed
278
-     */
279
-    public function get($id, $as_object = true, $debug = false, $criteria = false)
280
-    {
281
-        if (!$criteria) {
282
-            $criteria = new CriteriaCompo();
283
-        }
284
-        if (is_array($this->keyName)) {
285
-            for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
286
-                /**
287
-                 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
288
-                 * Is the fact that we removed the (int)() represents a security risk ?
289
-                 */
290
-                //$criteria->add(new Criteria($this->keyName[$i], ($id[$i]), '=', $this->_itemname));
291
-                $criteria->add(new Criteria($this->keyName[$i], $id[$i], '=', $this->_itemname));
292
-            }
293
-        } else {
294
-            //$criteria = new Criteria($this->keyName, (int)($id), '=', $this->_itemname);
295
-            /**
296
-             * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
297
-             * Is the fact that we removed the (int)() represents a security risk ?
298
-             */
299
-            $criteria->add(new Criteria($this->keyName, $id, '=', $this->_itemname));
300
-        }
301
-        $criteria->setLimit(1);
302
-        if ($debug) {
303
-            $obj_array = $this->getObjectsD($criteria, false, $as_object);
304
-        } else {
305
-            $obj_array = $this->getObjects($criteria, false, $as_object);
306
-            //patch: weird bug of indexing by id even if id_as_key = false;
307
-            if (!isset($obj_array[0]) && is_object($obj_array[$id])) {
308
-                $obj_array[0] = $obj_array[$id];
309
-                unset($obj_array[$id]);
310
-                $obj_array[0]->unsetNew();
311
-            }
312
-        }
313
-
314
-        if (count($obj_array) != 1) {
315
-            $obj = $this->create();
316
-
317
-            return $obj;
318
-        }
319
-
320
-        return $obj_array[0];
321
-    }
322
-
323
-    /**
324
-     * retrieve a {@link SmartObject}
325
-     *
326
-     * @param  mixed $id        ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
327
-     * @param  bool  $as_object whether to return an object or an array
328
-     * @return mixed reference to the {@link SmartObject}, FALSE if failed
329
-     */
330
-    public function &getD($id, $as_object = true)
331
-    {
332
-        return $this->get($id, $as_object, true);
333
-    }
334
-
335
-    /**
336
-     * retrieve objects from the database
337
-     *
338
-     * @param CriteriaElement $criteria  {@link CriteriaElement} conditions to be met
339
-     * @param bool   $id_as_key use the ID as key for the array?
340
-     * @param bool   $as_object return an array of objects?
341
-     *
342
-     * @param  bool  $sql
343
-     * @param  bool  $debug
344
-     * @return array
345
-     */
346
-    public function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true, $sql = false, $debug = false)
347
-    {
348
-        $ret   = array();
349
-        $limit = $start = 0;
350
-
351
-        if ($this->generalSQL) {
352
-            $sql = $this->generalSQL;
353
-        } elseif (!$sql) {
354
-            $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname;
355
-        }
356
-
357
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
358
-            $sql .= ' ' . $criteria->renderWhere();
359
-            if ($criteria->getSort() !== '') {
360
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
361
-            }
362
-            $limit = $criteria->getLimit();
363
-            $start = $criteria->getStart();
364
-        }
365
-        if ($debug) {
366
-            xoops_debug($sql);
367
-        }
368
-
369
-        $result = $this->db->query($sql, $limit, $start);
370
-        if (!$result) {
371
-            return $ret;
372
-        }
373
-
374
-        return $this->convertResultSet($result, $id_as_key, $as_object);
375
-    }
376
-
377
-    /**
378
-     * @param        $sql
379
-     * @param        $criteria
380
-     * @param  bool  $force
381
-     * @param  bool  $debug
382
-     * @return array
383
-     */
384
-    public function query($sql, $criteria, $force = false, $debug = false)
385
-    {
386
-        $ret = array();
387
-
388
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
389
-            $sql .= ' ' . $criteria->renderWhere();
390
-            if ($criteria->groupby) {
391
-                $sql .= $criteria->getGroupby();
392
-            }
393
-            if ($criteria->getSort() !== '') {
394
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
395
-            }
396
-        }
397
-        if ($debug) {
398
-            xoops_debug($sql);
399
-        }
400
-
401
-        if ($force) {
402
-            $result = $this->db->queryF($sql);
403
-        } else {
404
-            $result = $this->db->query($sql);
405
-        }
406
-
407
-        if (!$result) {
408
-            return $ret;
409
-        }
410
-
411
-        while (false !== ($myrow = $this->db->fetchArray($result))) {
412
-            $ret[] = $myrow;
413
-        }
414
-
415
-        return $ret;
416
-    }
417
-
418
-    /**
419
-     * retrieve objects with debug mode - so will show the query
420
-     *
421
-     * @param CriteriaElement $criteria  {@link CriteriaElement} conditions to be met
422
-     * @param bool   $id_as_key use the ID as key for the array?
423
-     * @param bool   $as_object return an array of objects?
424
-     *
425
-     * @param  bool  $sql
426
-     * @return array
427
-     */
428
-    public function getObjectsD(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true, $sql = false)
429
-    {
430
-        return $this->getObjects($criteria, $id_as_key, $as_object, $sql, true);
431
-    }
432
-
433
-    /**
434
-     * @param $arrayObjects
435
-     * @return array|bool
436
-     */
437
-    public function getObjectsAsArray($arrayObjects)
438
-    {
439
-        $ret = array();
440
-        foreach ($arrayObjects as $key => $object) {
441
-            $ret[$key] = $object->toArray();
442
-        }
443
-        if (count($ret > 0)) {
444
-            return $ret;
445
-        } else {
446
-            return false;
447
-        }
448
-    }
449
-
450
-    /**
451
-     * Convert a database resultset to a returnable array
452
-     *
453
-     * @param object $result    database resultset
454
-     * @param bool   $id_as_key - should NOT be used with joint keys
455
-     * @param bool   $as_object
456
-     *
457
-     * @return array
458
-     */
459
-    public function convertResultSet($result, $id_as_key = false, $as_object = true)
460
-    {
461
-        $ret = array();
462
-        while (false !== ($myrow = $this->db->fetchArray($result))) {
463
-            $obj = $this->create(false);
464
-            $obj->assignVars($myrow);
465
-            if (!$id_as_key) {
466
-                if ($as_object) {
467
-                    $ret[] =& $obj;
468
-                } else {
469
-                    $ret[] = $obj->toArray();
470
-                }
471
-            } else {
472
-                if ($as_object) {
473
-                    $value =& $obj;
474
-                } else {
475
-                    $value = $obj->toArray();
476
-                }
477
-                if ($id_as_key === 'parentid') {
478
-                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
479
-                } else {
480
-                    $ret[$obj->getVar($this->keyName)] = $value;
481
-                }
482
-            }
483
-            unset($obj);
484
-        }
485
-
486
-        return $ret;
487
-    }
488
-
489
-    /**
490
-     * @param  null  $criteria
491
-     * @param  int   $limit
492
-     * @param  int   $start
493
-     * @return array
494
-     */
495
-    public function getListD($criteria = null, $limit = 0, $start = 0)
496
-    {
497
-        return $this->getList($criteria, $limit, $start, true);
498
-    }
499
-
500
-    /**
501
-     * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
502
-     *
503
-     * @param CriteriaElement $criteria {@link CriteriaElement} conditions to be met
504
-     * @param int    $limit    Max number of objects to fetch
505
-     * @param int    $start    Which record to start at
506
-     *
507
-     * @param  bool  $debug
508
-     * @return array
509
-     */
510
-    public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0, $debug = false)
511
-    {
512
-        $ret = array();
513
-        if ($criteria === null) {
514
-            $criteria = new CriteriaCompo();
515
-        }
516
-
517
-        if ($criteria->getSort() === '') {
518
-            $criteria->setSort($this->getIdentifierName());
519
-        }
520
-
521
-        $sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
522
-        if (!empty($this->identifierName)) {
523
-            $sql .= ', ' . $this->getIdentifierName();
524
-        }
525
-        $sql .= ' FROM ' . $this->table . ' AS ' . $this->_itemname;
526
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
527
-            $sql .= ' ' . $criteria->renderWhere();
528
-            if ($criteria->getSort() !== '') {
529
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
530
-            }
531
-            $limit = $criteria->getLimit();
532
-            $start = $criteria->getStart();
533
-        }
534
-
535
-        if ($debug) {
536
-            xoops_debug($sql);
537
-        }
538
-
539
-        $result = $this->db->query($sql, $limit, $start);
540
-        if (!$result) {
541
-            return $ret;
542
-        }
543
-
544
-        $myts = MyTextSanitizer::getInstance();
545
-        while (false !== ($myrow = $this->db->fetchArray($result))) {
546
-            //identifiers should be textboxes, so sanitize them like that
547
-            $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->displayTarea($myrow[$this->identifierName]);
548
-        }
549
-
550
-        return $ret;
551
-    }
552
-
553
-    /**
554
-     * count objects matching a condition
555
-     *
556
-     * @param  CriteriaElement $criteria {@link CriteriaElement} to match
557
-     * @return int    count of objects
558
-     */
559
-    public function getCount(CriteriaElement $criteria = null)
560
-    {
561
-        $field   = '';
562
-        $groupby = false;
563
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
564
-            if ($criteria->groupby !== '') {
565
-                $groupby = true;
566
-                $field   = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
567
-            }
568
-        }
569
-        /**
570
-         * if we have a generalSQL, lets used this one.
571
-         * This needs to be improved...
572
-         */
573
-        if ($this->generalSQL) {
574
-            $sql = $this->generalSQL;
575
-            $sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
576
-        } else {
577
-            $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table . ' AS ' . $this->_itemname;
578
-        }
579
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
580
-            $sql .= ' ' . $criteria->renderWhere();
581
-            if ($criteria->groupby !== '') {
582
-                $sql .= $criteria->getGroupby();
583
-            }
584
-        }
585
-
586
-        $result = $this->db->query($sql);
587
-        if (!$result) {
588
-            return 0;
589
-        }
590
-        if ($groupby === false) {
591
-            list($count) = $this->db->fetchRow($result);
592
-
593
-            return $count;
594
-        } else {
595
-            $ret = array();
596
-            while (false !== (list($id, $count) = $this->db->fetchRow($result))) {
597
-                $ret[$id] = $count;
598
-            }
599
-
600
-            return $ret;
601
-        }
602
-    }
603
-
604
-    /**
605
-     * delete an object from the database
606
-     *
607
-     * @param  XoopsObject $obj   reference to the object to delete
608
-     * @param  bool        $force
609
-     * @return bool        FALSE if failed.
610
-     */
611
-    public function delete(XoopsObject $obj, $force = false)
612
-    {
613
-        $eventResult = $this->executeEvent('beforeDelete', $obj);
614
-        if (!$eventResult) {
615
-            $obj->setErrors('An error occured during the BeforeDelete event');
616
-
617
-            return false;
618
-        }
619
-
620
-        if (is_array($this->keyName)) {
621
-            $clause = array();
622
-            for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
623
-                $clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
624
-            }
625
-            $whereclause = implode(' AND ', $clause);
626
-        } else {
627
-            $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
628
-        }
629
-        $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause;
630
-        if (false !== $force) {
631
-            $result = $this->db->queryF($sql);
632
-        } else {
633
-            $result = $this->db->query($sql);
634
-        }
635
-        if (!$result) {
636
-            return false;
637
-        }
638
-
639
-        $eventResult = $this->executeEvent('afterDelete', $obj);
640
-        if (!$eventResult) {
641
-            $obj->setErrors('An error occured during the AfterDelete event');
642
-
643
-            return false;
644
-        }
645
-
646
-        return true;
647
-    }
648
-
649
-    /**
650
-     * @param $event
651
-     */
652
-    public function disableEvent($event)
653
-    {
654
-        if (is_array($event)) {
655
-            foreach ($event as $v) {
656
-                $this->_disabledEvents[] = $v;
657
-            }
658
-        } else {
659
-            $this->_disabledEvents[] = $event;
660
-        }
661
-    }
662
-
663
-    /**
664
-     * @return array
665
-     */
666
-    public function getPermissions()
667
-    {
668
-        return $this->permissionsArray;
669
-    }
670
-
671
-    /**
672
-     * insert a new object in the database
673
-     *
674
-     * @param  XoopsObject $obj         reference to the object
675
-     * @param  bool        $force       whether to force the query execution despite security settings
676
-     * @param  bool        $checkObject check if the object is dirty and clean the attributes
677
-     * @param  bool        $debug
678
-     * @return bool        FALSE if failed, TRUE if already present and unchanged or successful
679
-     */
680
-    public function insert(XoopsObject $obj, $force = false, $checkObject = true, $debug = false)
681
-    {
682
-        if ($checkObject !== false) {
683
-            if (!is_object($obj)) {
684
-                return false;
685
-            }
686
-            /**
687
-             * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
688
-             */
689
-            if (!is_a($obj, $this->className)) {
690
-                $obj->setError(get_class($obj) . ' Differs from ' . $this->className);
691
-
692
-                return false;
693
-            }
694
-            if (!$obj->isDirty()) {
695
-                $obj->setErrors('Not dirty'); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith
696
-
697
-                return true;
698
-            }
699
-        }
700
-
701
-        if ($obj->seoEnabled) {
702
-            // Auto create meta tags if empty
703
-            $smartobjectMetagen = new SmartMetagen($obj->title(), $obj->getVar('meta_keywords'), $obj->summary());
704
-
705
-            if (!$obj->getVar('meta_keywords') || !$obj->getVar('meta_description')) {
706
-                if (!$obj->meta_keywords()) {
707
-                    $obj->setVar('meta_keywords', $smartobjectMetagen->_keywords);
708
-                }
709
-
710
-                if (!$obj->meta_description()) {
711
-                    $obj->setVar('meta_description', $smartobjectMetagen->_meta_description);
712
-                }
713
-            }
714
-
715
-            // Auto create short_url if empty
716
-            if (!$obj->short_url()) {
717
-                $obj->setVar('short_url', $smartobjectMetagen->generateSeoTitle($obj->title('n'), false));
718
-            }
719
-        }
720
-
721
-        $eventResult = $this->executeEvent('beforeSave', $obj);
722
-        if (!$eventResult) {
723
-            $obj->setErrors('An error occured during the BeforeSave event');
724
-
725
-            return false;
726
-        }
727
-
728
-        if ($obj->isNew()) {
729
-            $eventResult = $this->executeEvent('beforeInsert', $obj);
730
-            if (!$eventResult) {
731
-                $obj->setErrors('An error occured during the BeforeInsert event');
732
-
733
-                return false;
734
-            }
735
-        } else {
736
-            $eventResult = $this->executeEvent('beforeUpdate', $obj);
737
-            if (!$eventResult) {
738
-                $obj->setErrors('An error occured during the BeforeUpdate event');
739
-
740
-                return false;
741
-            }
742
-        }
743
-        if (!$obj->cleanVars()) {
744
-            $obj->setErrors('Variables were not cleaned properly.');
745
-
746
-            return false;
747
-        }
748
-        $fieldsToStoreInDB = array();
749
-        foreach ($obj->cleanVars as $k => $v) {
750
-            if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
751
-                $cleanvars[$k] = (int)$v;
752
-            } elseif (is_array($v)) {
753
-                $cleanvars[$k] = $this->db->quoteString(implode(',', $v));
754
-            } else {
755
-                $cleanvars[$k] = $this->db->quoteString($v);
756
-            }
757
-            if ($obj->vars[$k]['persistent']) {
758
-                $fieldsToStoreInDB[$k] = $cleanvars[$k];
759
-            }
760
-        }
761
-        if ($obj->isNew()) {
762
-            if (!is_array($this->keyName)) {
763
-                if ($cleanvars[$this->keyName] < 1) {
764
-                    $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq');
765
-                }
766
-            }
767
-
768
-            $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($fieldsToStoreInDB)) . ') VALUES (' . implode(',', array_values($fieldsToStoreInDB)) . ')';
769
-        } else {
770
-            $sql = 'UPDATE ' . $this->table . ' SET';
771
-            foreach ($fieldsToStoreInDB as $key => $value) {
772
-                if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
773
-                    continue;
774
-                }
775
-                if (isset($notfirst)) {
776
-                    $sql .= ',';
777
-                }
778
-                $sql .= ' ' . $key . ' = ' . $value;
779
-                $notfirst = true;
780
-            }
781
-            if (is_array($this->keyName)) {
782
-                $whereclause = '';
783
-                for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
784
-                    if ($i > 0) {
785
-                        $whereclause .= ' AND ';
786
-                    }
787
-                    $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
788
-                }
789
-            } else {
790
-                $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
791
-            }
792
-            $sql .= ' WHERE ' . $whereclause;
793
-        }
794
-
795
-        if ($debug) {
796
-            xoops_debug($sql);
797
-        }
798
-
799
-        if (false != $force) {
800
-            $result = $this->db->queryF($sql);
801
-        } else {
802
-            $result = $this->db->query($sql);
803
-        }
804
-
805
-        if (!$result) {
806
-            $obj->setErrors($this->db->error());
807
-
808
-            return false;
809
-        }
810
-
811
-        if ($obj->isNew() && !is_array($this->keyName)) {
812
-            $obj->assignVar($this->keyName, $this->db->getInsertId());
813
-        }
814
-        $eventResult = $this->executeEvent('afterSave', $obj);
815
-        if (!$eventResult) {
816
-            $obj->setErrors('An error occured during the AfterSave event');
817
-
818
-            return false;
819
-        }
820
-
821
-        if ($obj->isNew()) {
822
-            $obj->unsetNew();
823
-            $eventResult = $this->executeEvent('afterInsert', $obj);
824
-            if (!$eventResult) {
825
-                $obj->setErrors('An error occured during the AfterInsert event');
826
-
827
-                return false;
828
-            }
829
-        } else {
830
-            $eventResult = $this->executeEvent('afterUpdate', $obj);
831
-            if (!$eventResult) {
832
-                $obj->setErrors('An error occured during the AfterUpdate event');
833
-
834
-                return false;
835
-            }
836
-        }
837
-
838
-        return true;
839
-    }
840
-
841
-    /**
842
-     * @param       $obj
843
-     * @param  bool $force
844
-     * @param  bool $checkObject
845
-     * @param  bool $debug
846
-     * @return bool
847
-     */
848
-    public function insertD($obj, $force = false, $checkObject = true, $debug = false)
849
-    {
850
-        return $this->insert($obj, $force, $checkObject, true);
851
-    }
852
-
853
-    /**
854
-     * Change a value for objects with a certain criteria
855
-     *
856
-     * @param string $fieldname  Name of the field
857
-     * @param string $fieldvalue Value to write
858
-     * @param CriteriaElement $criteria   {@link CriteriaElement}
859
-     *
860
-     * @param  bool $force
861
-     * @return bool
862
-     */
863
-    public function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false)
864
-    {
865
-        $set_clause = $fieldname . ' = ';
866
-        if (is_numeric($fieldvalue)) {
867
-            $set_clause .= $fieldvalue;
868
-        } elseif (is_array($fieldvalue)) {
869
-            $set_clause .= $this->db->quoteString(implode(',', $fieldvalue));
870
-        } else {
871
-            $set_clause .= $this->db->quoteString($fieldvalue);
872
-        }
873
-        $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause;
874
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
875
-            $sql .= ' ' . $criteria->renderWhere();
876
-        }
877
-        if (false != $force) {
878
-            $result = $this->db->queryF($sql);
879
-        } else {
880
-            $result = $this->db->query($sql);
881
-        }
882
-        if (!$result) {
883
-            return false;
884
-        }
885
-
886
-        return true;
887
-    }
888
-
889
-    /**
890
-     * delete all objects meeting the conditions
891
-     *
892
-     * @param  CriteriaElement $criteria {@link CriteriaElement} with conditions to meet
893
-     * @return bool
894
-     */
895
-
896
-    public function deleteAll(CriteriaElement $criteria = null)
897
-    {
898
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
899
-            $sql = 'DELETE FROM ' . $this->table;
900
-            $sql .= ' ' . $criteria->renderWhere();
901
-            if (!$this->db->query($sql)) {
902
-                return false;
903
-            }
904
-            $rows = $this->db->getAffectedRows();
905
-
906
-            return $rows > 0 ? $rows : true;
907
-        }
908
-
909
-        return false;
910
-    }
911
-
912
-    /**
913
-     * @return mixed
914
-     */
915
-    public function getModuleInfo()
916
-    {
917
-        return smart_getModuleInfo($this->_moduleName);
918
-    }
919
-
920
-    /**
921
-     * @return bool
922
-     */
923
-    public function getModuleConfig()
924
-    {
925
-        return smart_getModuleConfig($this->_moduleName);
926
-    }
927
-
928
-    /**
929
-     * @return string
930
-     */
931
-    public function getModuleItemString()
932
-    {
933
-        $ret = $this->_moduleName . '_' . $this->_itemname;
934
-
935
-        return $ret;
936
-    }
937
-
938
-    /**
939
-     * @param $object
940
-     */
941
-    public function updateCounter($object)
942
-    {
943
-        if (isset($object->vars['counter'])) {
944
-            $new_counter = $object->getVar('counter') + 1;
945
-            $sql         = 'UPDATE ' . $this->table . ' SET counter=' . $new_counter . ' WHERE ' . $this->keyName . '=' . $object->id();
946
-            $this->query($sql, null, true);
947
-        }
948
-    }
949
-
950
-    /**
951
-     * Execute the function associated with an event
952
-     * This method will check if the function is available
953
-     *
954
-     * @param  string $event           name of the event
955
-     * @param         $executeEventObj
956
-     * @return mixed  result of the execution of the function or FALSE if the function was not executed
957
-     * @internal param object $obj $object on which is performed the event
958
-     */
959
-    public function executeEvent($event, &$executeEventObj)
960
-    {
961
-        if (!in_array($event, $this->_disabledEvents)) {
962
-            if (method_exists($this, $event)) {
963
-                $ret = $this->$event($executeEventObj);
964
-            } else {
965
-                // check to see if there is a hook for this event
966
-                if (isset($this->_eventHooks[$event])) {
967
-                    $method = $this->_eventHooks[$event];
968
-                    // check to see if the method specified by this hook exists
969
-                    if (method_exists($this, $method)) {
970
-                        $ret = $this->$method($executeEventObj);
971
-                    }
972
-                }
973
-                $ret = true;
974
-            }
975
-
976
-            return $ret;
977
-        }
978
-
979
-        return true;
980
-    }
981
-
982
-    /**
983
-     * @param  bool   $withprefix
984
-     * @return string
985
-     */
986
-    public function getIdentifierName($withprefix = true)
987
-    {
988
-        if ($withprefix) {
989
-            return $this->_itemname . '.' . $this->identifierName;
990
-        } else {
991
-            return $this->identifierName;
992
-        }
993
-    }
28
+	public $_itemname;
29
+
30
+	/**
31
+	 * Name of the table use to store this {@link SmartObject}
32
+	 *
33
+	 * Note that the name of the table needs to be free of the database prefix.
34
+	 * For example "smartsection_categories"
35
+	 * @var string
36
+	 */
37
+	public $table;
38
+
39
+	/**
40
+	 * Name of the table key that uniquely identify each {@link SmartObject}
41
+	 *
42
+	 * For example: "categoryid"
43
+	 * @var string
44
+	 */
45
+	public $keyName;
46
+
47
+	/**
48
+	 * Name of the class derived from {@link SmartObject} and which this handler is handling
49
+	 *
50
+	 * Note that this string needs to be lowercase
51
+	 *
52
+	 * For example: "smartsectioncategory"
53
+	 * @var string
54
+	 */
55
+	public $className;
56
+
57
+	/**
58
+	 * Name of the field which properly identify the {@link SmartObject}
59
+	 *
60
+	 * For example: "name" (this will be the category's name)
61
+	 * @var string
62
+	 */
63
+	public $identifierName;
64
+
65
+	/**
66
+	 * Name of the field which will be use as a summary for the object
67
+	 *
68
+	 * For example: "summary"
69
+	 * @var string
70
+	 */
71
+	public $summaryName;
72
+
73
+	/**
74
+	 * Page name use to basically manage and display the {@link SmartObject}
75
+	 *
76
+	 * This page needs to be the same in user side and admin side
77
+	 *
78
+	 * For example category.php - we will deduct smartsection/category.php as well as smartsection/admin/category.php
79
+	 * @todo this could probably be automatically deducted from the class name - for example, the class SmartsectionCategory will have "category.php" as it's managing page
80
+	 * @var string
81
+	 */
82
+	public $_page;
83
+
84
+	/**
85
+	 * Full path of the module using this {@link SmartObject}
86
+	 *
87
+	 * <code>XOOPS_URL . "/modules/smartsection/"</code>
88
+	 * @todo this could probably be automatically deducted from the class name as it is always prefixed with the module name
89
+	 * @var string
90
+	 */
91
+	public $_modulePath;
92
+
93
+	public $_moduleUrl;
94
+
95
+	public $_moduleName;
96
+
97
+	public $_uploadUrl;
98
+
99
+	public $_uploadPath;
100
+
101
+	public $_allowedMimeTypes = 0;
102
+
103
+	public $_maxFileSize = 1000000;
104
+
105
+	public $_maxWidth = 500;
106
+
107
+	public $_maxHeight = 500;
108
+
109
+	public $highlightFields = array();
110
+
111
+	/**
112
+	 * Array containing the events name and functions
113
+	 *
114
+	 * @var array
115
+	 */
116
+	public $eventArray = array();
117
+
118
+	/**
119
+	 * Array containing the permissions that this handler will manage on the objects
120
+	 *
121
+	 * @var array
122
+	 */
123
+	public $permissionsArray = false;
124
+
125
+	public $generalSQL = false;
126
+
127
+	public $_eventHooks     = array();
128
+	public $_disabledEvents = array();
129
+
130
+	/**
131
+	 * Constructor - called from child classes
132
+	 *
133
+	 * @param XoopsDatabase $db           {@link XoopsDatabase}
134
+	 *                                           object
135
+	 * @param                      $itemname
136
+	 * @param string               $keyname      Name of the table key that uniquely identify each {@link SmartObject}
137
+	 * @param string               $idenfierName Name of the field which properly identify the {@link SmartObject}
138
+	 * @param                      $summaryName
139
+	 * @param                      $modulename
140
+	 * @internal param string $tablename Name of the table use to store this <a href='psi_element://SmartObject'>SmartObject</a>
141
+	 * @internal param Name $string of the class derived from <a href='psi_element://SmartObject'>SmartObject</a> and which this handler is handling and which this handler is handling
142
+	 * @internal param string $page Page name use to basically manage and display the <a href='psi_element://SmartObject'>SmartObject</a>
143
+	 * @internal param string $moduleName name of the module
144
+	 */
145
+	public function __construct(XoopsDatabase $db, $itemname, $keyname, $idenfierName, $summaryName, $modulename)
146
+	{
147
+		parent::__construct($db);
148
+
149
+		$this->_itemname      = $itemname;
150
+		$this->_moduleName    = $modulename;
151
+		$this->table          = $db->prefix($modulename . '_' . $itemname);
152
+		$this->keyName        = $keyname;
153
+		$this->className      = ucfirst($modulename) . ucfirst($itemname);
154
+		$this->identifierName = $idenfierName;
155
+		$this->summaryName    = $summaryName;
156
+		$this->_page          = $itemname . '.php';
157
+		$this->_modulePath    = XOOPS_ROOT_PATH . '/modules/' . $this->_moduleName . '/';
158
+		$this->_moduleUrl     = XOOPS_URL . '/modules/' . $this->_moduleName . '/';
159
+		$this->_uploadPath    = XOOPS_UPLOAD_PATH . '/' . $this->_moduleName . '/';
160
+		$this->_uploadUrl     = XOOPS_UPLOAD_URL . '/' . $this->_moduleName . '/';
161
+	}
162
+
163
+	/**
164
+	 * @param $event
165
+	 * @param $method
166
+	 */
167
+	public function addEventHook($event, $method)
168
+	{
169
+		$this->_eventHooks[$event] = $method;
170
+	}
171
+
172
+	/**
173
+	 * Add a permission that this handler will manage for its objects
174
+	 *
175
+	 * Example: $this->addPermission('view', _AM_SSHOP_CAT_PERM_READ, _AM_SSHOP_CAT_PERM_READ_DSC);
176
+	 *
177
+	 * @param string      $perm_name   name of the permission
178
+	 * @param string      $caption     caption of the control that will be displayed in the form
179
+	 * @param bool|string $description description of the control that will be displayed in the form
180
+	 */
181
+	public function addPermission($perm_name, $caption, $description = false)
182
+	{
183
+		include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
184
+
185
+		$this->permissionsArray[] = array(
186
+			'perm_name'   => $perm_name,
187
+			'caption'     => $caption,
188
+			'description' => $description
189
+		);
190
+	}
191
+
192
+	/**
193
+	 * @param $criteria
194
+	 * @param $perm_name
195
+	 * @return bool
196
+	 */
197
+	public function setGrantedObjectsCriteria(&$criteria, $perm_name)
198
+	{
199
+		$smartPermissionsHandler = new SmartobjectPermissionHandler($this);
200
+		$grantedItems            = $smartPermissionsHandler->getGrantedItems($perm_name);
201
+		if (count($grantedItems) > 0) {
202
+			$criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
203
+
204
+			return true;
205
+		} else {
206
+			return false;
207
+		}
208
+	}
209
+
210
+	/**
211
+	 * @param bool $_uploadPath
212
+	 * @param bool $_allowedMimeTypes
213
+	 * @param bool $_maxFileSize
214
+	 * @param bool $_maxWidth
215
+	 * @param bool $_maxHeight
216
+	 */
217
+	public function setUploaderConfig($_uploadPath = false, $_allowedMimeTypes = false, $_maxFileSize = false, $_maxWidth = false, $_maxHeight = false)
218
+	{
219
+		$this->_uploadPath       = $_uploadPath ?: $this->_uploadPath;
220
+		$this->_allowedMimeTypes = $_allowedMimeTypes ?: $this->_allowedMimeTypes;
221
+		$this->_maxFileSize      = $_maxFileSize ?: $this->_maxFileSize;
222
+		$this->_maxWidth         = $_maxWidth ?: $this->_maxWidth;
223
+		$this->_maxHeight        = $_maxHeight ?: $this->_maxHeight;
224
+	}
225
+
226
+	/**
227
+	 * create a new {@link SmartObject}
228
+	 *
229
+	 * @param bool $isNew Flag the new objects as "new"?
230
+	 *
231
+	 * @return SmartObject {@link SmartObject}
232
+	 */
233
+	public function create($isNew = true)
234
+	{
235
+		$obj = new $this->className($this);
236
+		$obj->setImageDir($this->getImageUrl(), $this->getImagePath());
237
+		if (!$obj->handler) {
238
+			$obj->handler =& $this;
239
+		}
240
+
241
+		if ($isNew === true) {
242
+			$obj->setNew();
243
+		}
244
+
245
+		return $obj;
246
+	}
247
+
248
+	/**
249
+	 * @return string
250
+	 */
251
+	public function getImageUrl()
252
+	{
253
+		return $this->_uploadUrl . $this->_itemname . '/';
254
+	}
255
+
256
+	/**
257
+	 * @return string
258
+	 */
259
+	public function getImagePath()
260
+	{
261
+		$dir = $this->_uploadPath . $this->_itemname;
262
+		if (!file_exists($dir)) {
263
+			smart_admin_mkdir($dir);
264
+		}
265
+
266
+		return $dir . '/';
267
+	}
268
+
269
+	/**
270
+	 * retrieve a {@link SmartObject}
271
+	 *
272
+	 * @param  mixed $id        ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
273
+	 * @param  bool  $as_object whether to return an object or an array
274
+	 * @param  bool  $debug
275
+	 * @param  bool  $criteria
276
+	 * @return mixed reference to the <a href='psi_element://SmartObject'>SmartObject</a>, FALSE if failed
277
+	 *                         FALSE if failed
278
+	 */
279
+	public function get($id, $as_object = true, $debug = false, $criteria = false)
280
+	{
281
+		if (!$criteria) {
282
+			$criteria = new CriteriaCompo();
283
+		}
284
+		if (is_array($this->keyName)) {
285
+			for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
286
+				/**
287
+				 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
288
+				 * Is the fact that we removed the (int)() represents a security risk ?
289
+				 */
290
+				//$criteria->add(new Criteria($this->keyName[$i], ($id[$i]), '=', $this->_itemname));
291
+				$criteria->add(new Criteria($this->keyName[$i], $id[$i], '=', $this->_itemname));
292
+			}
293
+		} else {
294
+			//$criteria = new Criteria($this->keyName, (int)($id), '=', $this->_itemname);
295
+			/**
296
+			 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
297
+			 * Is the fact that we removed the (int)() represents a security risk ?
298
+			 */
299
+			$criteria->add(new Criteria($this->keyName, $id, '=', $this->_itemname));
300
+		}
301
+		$criteria->setLimit(1);
302
+		if ($debug) {
303
+			$obj_array = $this->getObjectsD($criteria, false, $as_object);
304
+		} else {
305
+			$obj_array = $this->getObjects($criteria, false, $as_object);
306
+			//patch: weird bug of indexing by id even if id_as_key = false;
307
+			if (!isset($obj_array[0]) && is_object($obj_array[$id])) {
308
+				$obj_array[0] = $obj_array[$id];
309
+				unset($obj_array[$id]);
310
+				$obj_array[0]->unsetNew();
311
+			}
312
+		}
313
+
314
+		if (count($obj_array) != 1) {
315
+			$obj = $this->create();
316
+
317
+			return $obj;
318
+		}
319
+
320
+		return $obj_array[0];
321
+	}
322
+
323
+	/**
324
+	 * retrieve a {@link SmartObject}
325
+	 *
326
+	 * @param  mixed $id        ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
327
+	 * @param  bool  $as_object whether to return an object or an array
328
+	 * @return mixed reference to the {@link SmartObject}, FALSE if failed
329
+	 */
330
+	public function &getD($id, $as_object = true)
331
+	{
332
+		return $this->get($id, $as_object, true);
333
+	}
334
+
335
+	/**
336
+	 * retrieve objects from the database
337
+	 *
338
+	 * @param CriteriaElement $criteria  {@link CriteriaElement} conditions to be met
339
+	 * @param bool   $id_as_key use the ID as key for the array?
340
+	 * @param bool   $as_object return an array of objects?
341
+	 *
342
+	 * @param  bool  $sql
343
+	 * @param  bool  $debug
344
+	 * @return array
345
+	 */
346
+	public function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true, $sql = false, $debug = false)
347
+	{
348
+		$ret   = array();
349
+		$limit = $start = 0;
350
+
351
+		if ($this->generalSQL) {
352
+			$sql = $this->generalSQL;
353
+		} elseif (!$sql) {
354
+			$sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname;
355
+		}
356
+
357
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
358
+			$sql .= ' ' . $criteria->renderWhere();
359
+			if ($criteria->getSort() !== '') {
360
+				$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
361
+			}
362
+			$limit = $criteria->getLimit();
363
+			$start = $criteria->getStart();
364
+		}
365
+		if ($debug) {
366
+			xoops_debug($sql);
367
+		}
368
+
369
+		$result = $this->db->query($sql, $limit, $start);
370
+		if (!$result) {
371
+			return $ret;
372
+		}
373
+
374
+		return $this->convertResultSet($result, $id_as_key, $as_object);
375
+	}
376
+
377
+	/**
378
+	 * @param        $sql
379
+	 * @param        $criteria
380
+	 * @param  bool  $force
381
+	 * @param  bool  $debug
382
+	 * @return array
383
+	 */
384
+	public function query($sql, $criteria, $force = false, $debug = false)
385
+	{
386
+		$ret = array();
387
+
388
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
389
+			$sql .= ' ' . $criteria->renderWhere();
390
+			if ($criteria->groupby) {
391
+				$sql .= $criteria->getGroupby();
392
+			}
393
+			if ($criteria->getSort() !== '') {
394
+				$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
395
+			}
396
+		}
397
+		if ($debug) {
398
+			xoops_debug($sql);
399
+		}
400
+
401
+		if ($force) {
402
+			$result = $this->db->queryF($sql);
403
+		} else {
404
+			$result = $this->db->query($sql);
405
+		}
406
+
407
+		if (!$result) {
408
+			return $ret;
409
+		}
410
+
411
+		while (false !== ($myrow = $this->db->fetchArray($result))) {
412
+			$ret[] = $myrow;
413
+		}
414
+
415
+		return $ret;
416
+	}
417
+
418
+	/**
419
+	 * retrieve objects with debug mode - so will show the query
420
+	 *
421
+	 * @param CriteriaElement $criteria  {@link CriteriaElement} conditions to be met
422
+	 * @param bool   $id_as_key use the ID as key for the array?
423
+	 * @param bool   $as_object return an array of objects?
424
+	 *
425
+	 * @param  bool  $sql
426
+	 * @return array
427
+	 */
428
+	public function getObjectsD(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true, $sql = false)
429
+	{
430
+		return $this->getObjects($criteria, $id_as_key, $as_object, $sql, true);
431
+	}
432
+
433
+	/**
434
+	 * @param $arrayObjects
435
+	 * @return array|bool
436
+	 */
437
+	public function getObjectsAsArray($arrayObjects)
438
+	{
439
+		$ret = array();
440
+		foreach ($arrayObjects as $key => $object) {
441
+			$ret[$key] = $object->toArray();
442
+		}
443
+		if (count($ret > 0)) {
444
+			return $ret;
445
+		} else {
446
+			return false;
447
+		}
448
+	}
449
+
450
+	/**
451
+	 * Convert a database resultset to a returnable array
452
+	 *
453
+	 * @param object $result    database resultset
454
+	 * @param bool   $id_as_key - should NOT be used with joint keys
455
+	 * @param bool   $as_object
456
+	 *
457
+	 * @return array
458
+	 */
459
+	public function convertResultSet($result, $id_as_key = false, $as_object = true)
460
+	{
461
+		$ret = array();
462
+		while (false !== ($myrow = $this->db->fetchArray($result))) {
463
+			$obj = $this->create(false);
464
+			$obj->assignVars($myrow);
465
+			if (!$id_as_key) {
466
+				if ($as_object) {
467
+					$ret[] =& $obj;
468
+				} else {
469
+					$ret[] = $obj->toArray();
470
+				}
471
+			} else {
472
+				if ($as_object) {
473
+					$value =& $obj;
474
+				} else {
475
+					$value = $obj->toArray();
476
+				}
477
+				if ($id_as_key === 'parentid') {
478
+					$ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
479
+				} else {
480
+					$ret[$obj->getVar($this->keyName)] = $value;
481
+				}
482
+			}
483
+			unset($obj);
484
+		}
485
+
486
+		return $ret;
487
+	}
488
+
489
+	/**
490
+	 * @param  null  $criteria
491
+	 * @param  int   $limit
492
+	 * @param  int   $start
493
+	 * @return array
494
+	 */
495
+	public function getListD($criteria = null, $limit = 0, $start = 0)
496
+	{
497
+		return $this->getList($criteria, $limit, $start, true);
498
+	}
499
+
500
+	/**
501
+	 * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
502
+	 *
503
+	 * @param CriteriaElement $criteria {@link CriteriaElement} conditions to be met
504
+	 * @param int    $limit    Max number of objects to fetch
505
+	 * @param int    $start    Which record to start at
506
+	 *
507
+	 * @param  bool  $debug
508
+	 * @return array
509
+	 */
510
+	public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0, $debug = false)
511
+	{
512
+		$ret = array();
513
+		if ($criteria === null) {
514
+			$criteria = new CriteriaCompo();
515
+		}
516
+
517
+		if ($criteria->getSort() === '') {
518
+			$criteria->setSort($this->getIdentifierName());
519
+		}
520
+
521
+		$sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
522
+		if (!empty($this->identifierName)) {
523
+			$sql .= ', ' . $this->getIdentifierName();
524
+		}
525
+		$sql .= ' FROM ' . $this->table . ' AS ' . $this->_itemname;
526
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
527
+			$sql .= ' ' . $criteria->renderWhere();
528
+			if ($criteria->getSort() !== '') {
529
+				$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
530
+			}
531
+			$limit = $criteria->getLimit();
532
+			$start = $criteria->getStart();
533
+		}
534
+
535
+		if ($debug) {
536
+			xoops_debug($sql);
537
+		}
538
+
539
+		$result = $this->db->query($sql, $limit, $start);
540
+		if (!$result) {
541
+			return $ret;
542
+		}
543
+
544
+		$myts = MyTextSanitizer::getInstance();
545
+		while (false !== ($myrow = $this->db->fetchArray($result))) {
546
+			//identifiers should be textboxes, so sanitize them like that
547
+			$ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->displayTarea($myrow[$this->identifierName]);
548
+		}
549
+
550
+		return $ret;
551
+	}
552
+
553
+	/**
554
+	 * count objects matching a condition
555
+	 *
556
+	 * @param  CriteriaElement $criteria {@link CriteriaElement} to match
557
+	 * @return int    count of objects
558
+	 */
559
+	public function getCount(CriteriaElement $criteria = null)
560
+	{
561
+		$field   = '';
562
+		$groupby = false;
563
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
564
+			if ($criteria->groupby !== '') {
565
+				$groupby = true;
566
+				$field   = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
567
+			}
568
+		}
569
+		/**
570
+		 * if we have a generalSQL, lets used this one.
571
+		 * This needs to be improved...
572
+		 */
573
+		if ($this->generalSQL) {
574
+			$sql = $this->generalSQL;
575
+			$sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
576
+		} else {
577
+			$sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table . ' AS ' . $this->_itemname;
578
+		}
579
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
580
+			$sql .= ' ' . $criteria->renderWhere();
581
+			if ($criteria->groupby !== '') {
582
+				$sql .= $criteria->getGroupby();
583
+			}
584
+		}
585
+
586
+		$result = $this->db->query($sql);
587
+		if (!$result) {
588
+			return 0;
589
+		}
590
+		if ($groupby === false) {
591
+			list($count) = $this->db->fetchRow($result);
592
+
593
+			return $count;
594
+		} else {
595
+			$ret = array();
596
+			while (false !== (list($id, $count) = $this->db->fetchRow($result))) {
597
+				$ret[$id] = $count;
598
+			}
599
+
600
+			return $ret;
601
+		}
602
+	}
603
+
604
+	/**
605
+	 * delete an object from the database
606
+	 *
607
+	 * @param  XoopsObject $obj   reference to the object to delete
608
+	 * @param  bool        $force
609
+	 * @return bool        FALSE if failed.
610
+	 */
611
+	public function delete(XoopsObject $obj, $force = false)
612
+	{
613
+		$eventResult = $this->executeEvent('beforeDelete', $obj);
614
+		if (!$eventResult) {
615
+			$obj->setErrors('An error occured during the BeforeDelete event');
616
+
617
+			return false;
618
+		}
619
+
620
+		if (is_array($this->keyName)) {
621
+			$clause = array();
622
+			for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
623
+				$clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
624
+			}
625
+			$whereclause = implode(' AND ', $clause);
626
+		} else {
627
+			$whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
628
+		}
629
+		$sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause;
630
+		if (false !== $force) {
631
+			$result = $this->db->queryF($sql);
632
+		} else {
633
+			$result = $this->db->query($sql);
634
+		}
635
+		if (!$result) {
636
+			return false;
637
+		}
638
+
639
+		$eventResult = $this->executeEvent('afterDelete', $obj);
640
+		if (!$eventResult) {
641
+			$obj->setErrors('An error occured during the AfterDelete event');
642
+
643
+			return false;
644
+		}
645
+
646
+		return true;
647
+	}
648
+
649
+	/**
650
+	 * @param $event
651
+	 */
652
+	public function disableEvent($event)
653
+	{
654
+		if (is_array($event)) {
655
+			foreach ($event as $v) {
656
+				$this->_disabledEvents[] = $v;
657
+			}
658
+		} else {
659
+			$this->_disabledEvents[] = $event;
660
+		}
661
+	}
662
+
663
+	/**
664
+	 * @return array
665
+	 */
666
+	public function getPermissions()
667
+	{
668
+		return $this->permissionsArray;
669
+	}
670
+
671
+	/**
672
+	 * insert a new object in the database
673
+	 *
674
+	 * @param  XoopsObject $obj         reference to the object
675
+	 * @param  bool        $force       whether to force the query execution despite security settings
676
+	 * @param  bool        $checkObject check if the object is dirty and clean the attributes
677
+	 * @param  bool        $debug
678
+	 * @return bool        FALSE if failed, TRUE if already present and unchanged or successful
679
+	 */
680
+	public function insert(XoopsObject $obj, $force = false, $checkObject = true, $debug = false)
681
+	{
682
+		if ($checkObject !== false) {
683
+			if (!is_object($obj)) {
684
+				return false;
685
+			}
686
+			/**
687
+			 * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
688
+			 */
689
+			if (!is_a($obj, $this->className)) {
690
+				$obj->setError(get_class($obj) . ' Differs from ' . $this->className);
691
+
692
+				return false;
693
+			}
694
+			if (!$obj->isDirty()) {
695
+				$obj->setErrors('Not dirty'); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith
696
+
697
+				return true;
698
+			}
699
+		}
700
+
701
+		if ($obj->seoEnabled) {
702
+			// Auto create meta tags if empty
703
+			$smartobjectMetagen = new SmartMetagen($obj->title(), $obj->getVar('meta_keywords'), $obj->summary());
704
+
705
+			if (!$obj->getVar('meta_keywords') || !$obj->getVar('meta_description')) {
706
+				if (!$obj->meta_keywords()) {
707
+					$obj->setVar('meta_keywords', $smartobjectMetagen->_keywords);
708
+				}
709
+
710
+				if (!$obj->meta_description()) {
711
+					$obj->setVar('meta_description', $smartobjectMetagen->_meta_description);
712
+				}
713
+			}
714
+
715
+			// Auto create short_url if empty
716
+			if (!$obj->short_url()) {
717
+				$obj->setVar('short_url', $smartobjectMetagen->generateSeoTitle($obj->title('n'), false));
718
+			}
719
+		}
720
+
721
+		$eventResult = $this->executeEvent('beforeSave', $obj);
722
+		if (!$eventResult) {
723
+			$obj->setErrors('An error occured during the BeforeSave event');
724
+
725
+			return false;
726
+		}
727
+
728
+		if ($obj->isNew()) {
729
+			$eventResult = $this->executeEvent('beforeInsert', $obj);
730
+			if (!$eventResult) {
731
+				$obj->setErrors('An error occured during the BeforeInsert event');
732
+
733
+				return false;
734
+			}
735
+		} else {
736
+			$eventResult = $this->executeEvent('beforeUpdate', $obj);
737
+			if (!$eventResult) {
738
+				$obj->setErrors('An error occured during the BeforeUpdate event');
739
+
740
+				return false;
741
+			}
742
+		}
743
+		if (!$obj->cleanVars()) {
744
+			$obj->setErrors('Variables were not cleaned properly.');
745
+
746
+			return false;
747
+		}
748
+		$fieldsToStoreInDB = array();
749
+		foreach ($obj->cleanVars as $k => $v) {
750
+			if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
751
+				$cleanvars[$k] = (int)$v;
752
+			} elseif (is_array($v)) {
753
+				$cleanvars[$k] = $this->db->quoteString(implode(',', $v));
754
+			} else {
755
+				$cleanvars[$k] = $this->db->quoteString($v);
756
+			}
757
+			if ($obj->vars[$k]['persistent']) {
758
+				$fieldsToStoreInDB[$k] = $cleanvars[$k];
759
+			}
760
+		}
761
+		if ($obj->isNew()) {
762
+			if (!is_array($this->keyName)) {
763
+				if ($cleanvars[$this->keyName] < 1) {
764
+					$cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq');
765
+				}
766
+			}
767
+
768
+			$sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($fieldsToStoreInDB)) . ') VALUES (' . implode(',', array_values($fieldsToStoreInDB)) . ')';
769
+		} else {
770
+			$sql = 'UPDATE ' . $this->table . ' SET';
771
+			foreach ($fieldsToStoreInDB as $key => $value) {
772
+				if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
773
+					continue;
774
+				}
775
+				if (isset($notfirst)) {
776
+					$sql .= ',';
777
+				}
778
+				$sql .= ' ' . $key . ' = ' . $value;
779
+				$notfirst = true;
780
+			}
781
+			if (is_array($this->keyName)) {
782
+				$whereclause = '';
783
+				for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
784
+					if ($i > 0) {
785
+						$whereclause .= ' AND ';
786
+					}
787
+					$whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
788
+				}
789
+			} else {
790
+				$whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
791
+			}
792
+			$sql .= ' WHERE ' . $whereclause;
793
+		}
794
+
795
+		if ($debug) {
796
+			xoops_debug($sql);
797
+		}
798
+
799
+		if (false != $force) {
800
+			$result = $this->db->queryF($sql);
801
+		} else {
802
+			$result = $this->db->query($sql);
803
+		}
804
+
805
+		if (!$result) {
806
+			$obj->setErrors($this->db->error());
807
+
808
+			return false;
809
+		}
810
+
811
+		if ($obj->isNew() && !is_array($this->keyName)) {
812
+			$obj->assignVar($this->keyName, $this->db->getInsertId());
813
+		}
814
+		$eventResult = $this->executeEvent('afterSave', $obj);
815
+		if (!$eventResult) {
816
+			$obj->setErrors('An error occured during the AfterSave event');
817
+
818
+			return false;
819
+		}
820
+
821
+		if ($obj->isNew()) {
822
+			$obj->unsetNew();
823
+			$eventResult = $this->executeEvent('afterInsert', $obj);
824
+			if (!$eventResult) {
825
+				$obj->setErrors('An error occured during the AfterInsert event');
826
+
827
+				return false;
828
+			}
829
+		} else {
830
+			$eventResult = $this->executeEvent('afterUpdate', $obj);
831
+			if (!$eventResult) {
832
+				$obj->setErrors('An error occured during the AfterUpdate event');
833
+
834
+				return false;
835
+			}
836
+		}
837
+
838
+		return true;
839
+	}
840
+
841
+	/**
842
+	 * @param       $obj
843
+	 * @param  bool $force
844
+	 * @param  bool $checkObject
845
+	 * @param  bool $debug
846
+	 * @return bool
847
+	 */
848
+	public function insertD($obj, $force = false, $checkObject = true, $debug = false)
849
+	{
850
+		return $this->insert($obj, $force, $checkObject, true);
851
+	}
852
+
853
+	/**
854
+	 * Change a value for objects with a certain criteria
855
+	 *
856
+	 * @param string $fieldname  Name of the field
857
+	 * @param string $fieldvalue Value to write
858
+	 * @param CriteriaElement $criteria   {@link CriteriaElement}
859
+	 *
860
+	 * @param  bool $force
861
+	 * @return bool
862
+	 */
863
+	public function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false)
864
+	{
865
+		$set_clause = $fieldname . ' = ';
866
+		if (is_numeric($fieldvalue)) {
867
+			$set_clause .= $fieldvalue;
868
+		} elseif (is_array($fieldvalue)) {
869
+			$set_clause .= $this->db->quoteString(implode(',', $fieldvalue));
870
+		} else {
871
+			$set_clause .= $this->db->quoteString($fieldvalue);
872
+		}
873
+		$sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause;
874
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
875
+			$sql .= ' ' . $criteria->renderWhere();
876
+		}
877
+		if (false != $force) {
878
+			$result = $this->db->queryF($sql);
879
+		} else {
880
+			$result = $this->db->query($sql);
881
+		}
882
+		if (!$result) {
883
+			return false;
884
+		}
885
+
886
+		return true;
887
+	}
888
+
889
+	/**
890
+	 * delete all objects meeting the conditions
891
+	 *
892
+	 * @param  CriteriaElement $criteria {@link CriteriaElement} with conditions to meet
893
+	 * @return bool
894
+	 */
895
+
896
+	public function deleteAll(CriteriaElement $criteria = null)
897
+	{
898
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
899
+			$sql = 'DELETE FROM ' . $this->table;
900
+			$sql .= ' ' . $criteria->renderWhere();
901
+			if (!$this->db->query($sql)) {
902
+				return false;
903
+			}
904
+			$rows = $this->db->getAffectedRows();
905
+
906
+			return $rows > 0 ? $rows : true;
907
+		}
908
+
909
+		return false;
910
+	}
911
+
912
+	/**
913
+	 * @return mixed
914
+	 */
915
+	public function getModuleInfo()
916
+	{
917
+		return smart_getModuleInfo($this->_moduleName);
918
+	}
919
+
920
+	/**
921
+	 * @return bool
922
+	 */
923
+	public function getModuleConfig()
924
+	{
925
+		return smart_getModuleConfig($this->_moduleName);
926
+	}
927
+
928
+	/**
929
+	 * @return string
930
+	 */
931
+	public function getModuleItemString()
932
+	{
933
+		$ret = $this->_moduleName . '_' . $this->_itemname;
934
+
935
+		return $ret;
936
+	}
937
+
938
+	/**
939
+	 * @param $object
940
+	 */
941
+	public function updateCounter($object)
942
+	{
943
+		if (isset($object->vars['counter'])) {
944
+			$new_counter = $object->getVar('counter') + 1;
945
+			$sql         = 'UPDATE ' . $this->table . ' SET counter=' . $new_counter . ' WHERE ' . $this->keyName . '=' . $object->id();
946
+			$this->query($sql, null, true);
947
+		}
948
+	}
949
+
950
+	/**
951
+	 * Execute the function associated with an event
952
+	 * This method will check if the function is available
953
+	 *
954
+	 * @param  string $event           name of the event
955
+	 * @param         $executeEventObj
956
+	 * @return mixed  result of the execution of the function or FALSE if the function was not executed
957
+	 * @internal param object $obj $object on which is performed the event
958
+	 */
959
+	public function executeEvent($event, &$executeEventObj)
960
+	{
961
+		if (!in_array($event, $this->_disabledEvents)) {
962
+			if (method_exists($this, $event)) {
963
+				$ret = $this->$event($executeEventObj);
964
+			} else {
965
+				// check to see if there is a hook for this event
966
+				if (isset($this->_eventHooks[$event])) {
967
+					$method = $this->_eventHooks[$event];
968
+					// check to see if the method specified by this hook exists
969
+					if (method_exists($this, $method)) {
970
+						$ret = $this->$method($executeEventObj);
971
+					}
972
+				}
973
+				$ret = true;
974
+			}
975
+
976
+			return $ret;
977
+		}
978
+
979
+		return true;
980
+	}
981
+
982
+	/**
983
+	 * @param  bool   $withprefix
984
+	 * @return string
985
+	 */
986
+	public function getIdentifierName($withprefix = true)
987
+	{
988
+		if ($withprefix) {
989
+			return $this->_itemname . '.' . $this->identifierName;
990
+		} else {
991
+			return $this->identifierName;
992
+		}
993
+	}
994 994
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 
149 149
         $this->_itemname      = $itemname;
150 150
         $this->_moduleName    = $modulename;
151
-        $this->table          = $db->prefix($modulename . '_' . $itemname);
151
+        $this->table          = $db->prefix($modulename.'_'.$itemname);
152 152
         $this->keyName        = $keyname;
153
-        $this->className      = ucfirst($modulename) . ucfirst($itemname);
153
+        $this->className      = ucfirst($modulename).ucfirst($itemname);
154 154
         $this->identifierName = $idenfierName;
155 155
         $this->summaryName    = $summaryName;
156
-        $this->_page          = $itemname . '.php';
157
-        $this->_modulePath    = XOOPS_ROOT_PATH . '/modules/' . $this->_moduleName . '/';
158
-        $this->_moduleUrl     = XOOPS_URL . '/modules/' . $this->_moduleName . '/';
159
-        $this->_uploadPath    = XOOPS_UPLOAD_PATH . '/' . $this->_moduleName . '/';
160
-        $this->_uploadUrl     = XOOPS_UPLOAD_URL . '/' . $this->_moduleName . '/';
156
+        $this->_page          = $itemname.'.php';
157
+        $this->_modulePath    = XOOPS_ROOT_PATH.'/modules/'.$this->_moduleName.'/';
158
+        $this->_moduleUrl     = XOOPS_URL.'/modules/'.$this->_moduleName.'/';
159
+        $this->_uploadPath    = XOOPS_UPLOAD_PATH.'/'.$this->_moduleName.'/';
160
+        $this->_uploadUrl     = XOOPS_UPLOAD_URL.'/'.$this->_moduleName.'/';
161 161
     }
162 162
 
163 163
     /**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function addPermission($perm_name, $caption, $description = false)
182 182
     {
183
-        include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
183
+        include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjectpermission.php');
184 184
 
185 185
         $this->permissionsArray[] = array(
186 186
             'perm_name'   => $perm_name,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $smartPermissionsHandler = new SmartobjectPermissionHandler($this);
200 200
         $grantedItems            = $smartPermissionsHandler->getGrantedItems($perm_name);
201 201
         if (count($grantedItems) > 0) {
202
-            $criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
202
+            $criteria->add(new Criteria($this->keyName, '('.implode(', ', $grantedItems).')', 'IN'));
203 203
 
204 204
             return true;
205 205
         } else {
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $obj = new $this->className($this);
236 236
         $obj->setImageDir($this->getImageUrl(), $this->getImagePath());
237 237
         if (!$obj->handler) {
238
-            $obj->handler =& $this;
238
+            $obj->handler = & $this;
239 239
         }
240 240
 
241 241
         if ($isNew === true) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     public function getImageUrl()
252 252
     {
253
-        return $this->_uploadUrl . $this->_itemname . '/';
253
+        return $this->_uploadUrl.$this->_itemname.'/';
254 254
     }
255 255
 
256 256
     /**
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function getImagePath()
260 260
     {
261
-        $dir = $this->_uploadPath . $this->_itemname;
261
+        $dir = $this->_uploadPath.$this->_itemname;
262 262
         if (!file_exists($dir)) {
263 263
             smart_admin_mkdir($dir);
264 264
         }
265 265
 
266
-        return $dir . '/';
266
+        return $dir.'/';
267 267
     }
268 268
 
269 269
     /**
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
         if ($this->generalSQL) {
352 352
             $sql = $this->generalSQL;
353 353
         } elseif (!$sql) {
354
-            $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname;
354
+            $sql = 'SELECT * FROM '.$this->table.' AS '.$this->_itemname;
355 355
         }
356 356
 
357 357
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
358
-            $sql .= ' ' . $criteria->renderWhere();
358
+            $sql .= ' '.$criteria->renderWhere();
359 359
             if ($criteria->getSort() !== '') {
360
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
360
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
361 361
             }
362 362
             $limit = $criteria->getLimit();
363 363
             $start = $criteria->getStart();
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
         $ret = array();
387 387
 
388 388
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
389
-            $sql .= ' ' . $criteria->renderWhere();
389
+            $sql .= ' '.$criteria->renderWhere();
390 390
             if ($criteria->groupby) {
391 391
                 $sql .= $criteria->getGroupby();
392 392
             }
393 393
             if ($criteria->getSort() !== '') {
394
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
394
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
395 395
             }
396 396
         }
397 397
         if ($debug) {
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
             $obj->assignVars($myrow);
465 465
             if (!$id_as_key) {
466 466
                 if ($as_object) {
467
-                    $ret[] =& $obj;
467
+                    $ret[] = & $obj;
468 468
                 } else {
469 469
                     $ret[] = $obj->toArray();
470 470
                 }
471 471
             } else {
472 472
                 if ($as_object) {
473
-                    $value =& $obj;
473
+                    $value = & $obj;
474 474
                 } else {
475 475
                     $value = $obj->toArray();
476 476
                 }
477 477
                 if ($id_as_key === 'parentid') {
478
-                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
478
+                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] = & $value;
479 479
                 } else {
480 480
                     $ret[$obj->getVar($this->keyName)] = $value;
481 481
                 }
@@ -518,15 +518,15 @@  discard block
 block discarded – undo
518 518
             $criteria->setSort($this->getIdentifierName());
519 519
         }
520 520
 
521
-        $sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
521
+        $sql = 'SELECT '.(is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
522 522
         if (!empty($this->identifierName)) {
523
-            $sql .= ', ' . $this->getIdentifierName();
523
+            $sql .= ', '.$this->getIdentifierName();
524 524
         }
525
-        $sql .= ' FROM ' . $this->table . ' AS ' . $this->_itemname;
525
+        $sql .= ' FROM '.$this->table.' AS '.$this->_itemname;
526 526
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
527
-            $sql .= ' ' . $criteria->renderWhere();
527
+            $sql .= ' '.$criteria->renderWhere();
528 528
             if ($criteria->getSort() !== '') {
529
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
529
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
530 530
             }
531 531
             $limit = $criteria->getLimit();
532 532
             $start = $criteria->getStart();
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
564 564
             if ($criteria->groupby !== '') {
565 565
                 $groupby = true;
566
-                $field   = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
566
+                $field   = $criteria->groupby.', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
567 567
             }
568 568
         }
569 569
         /**
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
             $sql = $this->generalSQL;
575 575
             $sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
576 576
         } else {
577
-            $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table . ' AS ' . $this->_itemname;
577
+            $sql = 'SELECT '.$field.'COUNT(*) FROM '.$this->table.' AS '.$this->_itemname;
578 578
         }
579 579
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
580
-            $sql .= ' ' . $criteria->renderWhere();
580
+            $sql .= ' '.$criteria->renderWhere();
581 581
             if ($criteria->groupby !== '') {
582 582
                 $sql .= $criteria->getGroupby();
583 583
             }
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
         if (is_array($this->keyName)) {
621 621
             $clause = array();
622 622
             for ($i = 0, $iMax = count($this->keyName); $i < $iMax; ++$i) {
623
-                $clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
623
+                $clause[] = $this->keyName[$i].' = '.$obj->getVar($this->keyName[$i]);
624 624
             }
625 625
             $whereclause = implode(' AND ', $clause);
626 626
         } else {
627
-            $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
627
+            $whereclause = $this->keyName.' = '.$obj->getVar($this->keyName);
628 628
         }
629
-        $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause;
629
+        $sql = 'DELETE FROM '.$this->table.' WHERE '.$whereclause;
630 630
         if (false !== $force) {
631 631
             $result = $this->db->queryF($sql);
632 632
         } else {
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
              * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
688 688
              */
689 689
             if (!is_a($obj, $this->className)) {
690
-                $obj->setError(get_class($obj) . ' Differs from ' . $this->className);
690
+                $obj->setError(get_class($obj).' Differs from '.$this->className);
691 691
 
692 692
                 return false;
693 693
             }
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
         $fieldsToStoreInDB = array();
749 749
         foreach ($obj->cleanVars as $k => $v) {
750 750
             if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
751
-                $cleanvars[$k] = (int)$v;
751
+                $cleanvars[$k] = (int) $v;
752 752
             } elseif (is_array($v)) {
753 753
                 $cleanvars[$k] = $this->db->quoteString(implode(',', $v));
754 754
             } else {
@@ -761,13 +761,13 @@  discard block
 block discarded – undo
761 761
         if ($obj->isNew()) {
762 762
             if (!is_array($this->keyName)) {
763 763
                 if ($cleanvars[$this->keyName] < 1) {
764
-                    $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq');
764
+                    $cleanvars[$this->keyName] = $this->db->genId($this->table.'_'.$this->keyName.'_seq');
765 765
                 }
766 766
             }
767 767
 
768
-            $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($fieldsToStoreInDB)) . ') VALUES (' . implode(',', array_values($fieldsToStoreInDB)) . ')';
768
+            $sql = 'INSERT INTO '.$this->table.' ('.implode(',', array_keys($fieldsToStoreInDB)).') VALUES ('.implode(',', array_values($fieldsToStoreInDB)).')';
769 769
         } else {
770
-            $sql = 'UPDATE ' . $this->table . ' SET';
770
+            $sql = 'UPDATE '.$this->table.' SET';
771 771
             foreach ($fieldsToStoreInDB as $key => $value) {
772 772
                 if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
773 773
                     continue;
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
                 if (isset($notfirst)) {
776 776
                     $sql .= ',';
777 777
                 }
778
-                $sql .= ' ' . $key . ' = ' . $value;
778
+                $sql .= ' '.$key.' = '.$value;
779 779
                 $notfirst = true;
780 780
             }
781 781
             if (is_array($this->keyName)) {
@@ -784,12 +784,12 @@  discard block
 block discarded – undo
784 784
                     if ($i > 0) {
785 785
                         $whereclause .= ' AND ';
786 786
                     }
787
-                    $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]);
787
+                    $whereclause .= $this->keyName[$i].' = '.$obj->getVar($this->keyName[$i]);
788 788
                 }
789 789
             } else {
790
-                $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName);
790
+                $whereclause = $this->keyName.' = '.$obj->getVar($this->keyName);
791 791
             }
792
-            $sql .= ' WHERE ' . $whereclause;
792
+            $sql .= ' WHERE '.$whereclause;
793 793
         }
794 794
 
795 795
         if ($debug) {
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
      */
863 863
     public function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false)
864 864
     {
865
-        $set_clause = $fieldname . ' = ';
865
+        $set_clause = $fieldname.' = ';
866 866
         if (is_numeric($fieldvalue)) {
867 867
             $set_clause .= $fieldvalue;
868 868
         } elseif (is_array($fieldvalue)) {
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
         } else {
871 871
             $set_clause .= $this->db->quoteString($fieldvalue);
872 872
         }
873
-        $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause;
873
+        $sql = 'UPDATE '.$this->table.' SET '.$set_clause;
874 874
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
875
-            $sql .= ' ' . $criteria->renderWhere();
875
+            $sql .= ' '.$criteria->renderWhere();
876 876
         }
877 877
         if (false != $force) {
878 878
             $result = $this->db->queryF($sql);
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
     public function deleteAll(CriteriaElement $criteria = null)
897 897
     {
898 898
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
899
-            $sql = 'DELETE FROM ' . $this->table;
900
-            $sql .= ' ' . $criteria->renderWhere();
899
+            $sql = 'DELETE FROM '.$this->table;
900
+            $sql .= ' '.$criteria->renderWhere();
901 901
             if (!$this->db->query($sql)) {
902 902
                 return false;
903 903
             }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
      */
931 931
     public function getModuleItemString()
932 932
     {
933
-        $ret = $this->_moduleName . '_' . $this->_itemname;
933
+        $ret = $this->_moduleName.'_'.$this->_itemname;
934 934
 
935 935
         return $ret;
936 936
     }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
     {
943 943
         if (isset($object->vars['counter'])) {
944 944
             $new_counter = $object->getVar('counter') + 1;
945
-            $sql         = 'UPDATE ' . $this->table . ' SET counter=' . $new_counter . ' WHERE ' . $this->keyName . '=' . $object->id();
945
+            $sql         = 'UPDATE '.$this->table.' SET counter='.$new_counter.' WHERE '.$this->keyName.'='.$object->id();
946 946
             $this->query($sql, null, true);
947 947
         }
948 948
     }
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
     public function getIdentifierName($withprefix = true)
987 987
     {
988 988
         if ($withprefix) {
989
-            return $this->_itemname . '.' . $this->identifierName;
989
+            return $this->_itemname.'.'.$this->identifierName;
990 990
         } else {
991 991
             return $this->identifierName;
992 992
         }
Please login to merge, or discard this patch.
class/smartobjectsregistry.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     /**
19 19
      * Access the only instance of this class
20 20
      *
21
-     * @return XoopsObject
21
+     * @return SmartObjectsRegistry
22 22
      *
23 23
      * @static
24 24
      * @staticvar   object
Please login to merge, or discard this patch.
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -13,169 +13,169 @@
 block discarded – undo
13 13
  */
14 14
 class SmartObjectsRegistry
15 15
 {
16
-    public $_registryArray;
16
+	public $_registryArray;
17 17
 
18
-    /**
19
-     * Access the only instance of this class
20
-     *
21
-     * @return XoopsObject
22
-     *
23
-     * @static
24
-     * @staticvar   object
25
-     */
26
-    public static function getInstance()
27
-    {
28
-        static $instance;
29
-        if (null === $instance) {
30
-            $instance = new static();
31
-        }
18
+	/**
19
+	 * Access the only instance of this class
20
+	 *
21
+	 * @return XoopsObject
22
+	 *
23
+	 * @static
24
+	 * @staticvar   object
25
+	 */
26
+	public static function getInstance()
27
+	{
28
+		static $instance;
29
+		if (null === $instance) {
30
+			$instance = new static();
31
+		}
32 32
 
33
-        return $instance;
34
-    }
33
+		return $instance;
34
+	}
35 35
 
36
-    /**
37
-     * Adding objects to the registry
38
-     *
39
-     * @param  SmartPersistableObjectHandler $handler  of the objects to add
40
-     * @param  bool|CriteriaCompo            $criteria to pass to the getObjects method of the handler (with id_as_key)
41
-     * @return FALSE                         if an error occured
42
-     */
43
-    public function addObjectsFromHandler(&$handler, $criteria = false)
44
-    {
45
-        if (method_exists($handler, 'getObjects')) {
46
-            $objects                                                                     = $handler->getObjects($criteria, true);
47
-            $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects;
36
+	/**
37
+	 * Adding objects to the registry
38
+	 *
39
+	 * @param  SmartPersistableObjectHandler $handler  of the objects to add
40
+	 * @param  bool|CriteriaCompo            $criteria to pass to the getObjects method of the handler (with id_as_key)
41
+	 * @return FALSE                         if an error occured
42
+	 */
43
+	public function addObjectsFromHandler(&$handler, $criteria = false)
44
+	{
45
+		if (method_exists($handler, 'getObjects')) {
46
+			$objects                                                                     = $handler->getObjects($criteria, true);
47
+			$this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects;
48 48
 
49
-            return $objects;
50
-        } else {
51
-            return false;
52
-        }
53
-    }
49
+			return $objects;
50
+		} else {
51
+			return false;
52
+		}
53
+	}
54 54
 
55
-    /**
56
-     * Adding objects to the registry from an item name
57
-     * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
-     *
59
-     * @param  string             $item       name of the item
60
-     * @param  bool|string        $modulename name of the module
61
-     * @param  bool|CriteriaCompo $criteria   to pass to the getObjects method of the handler (with id_as_key)
62
-     * @return FALSE              if an error occured
63
-     */
64
-    public function addObjectsFromItemName($item, $modulename = false, $criteria = false)
65
-    {
66
-        if (!$modulename) {
67
-            global $xoopsModule;
68
-            if (!is_object($xoopsModule)) {
69
-                return false;
70
-            } else {
71
-                $modulename = $xoopsModule->dirname();
72
-            }
73
-        }
74
-        $objectHandler = xoops_getModuleHandler($item, $modulename);
55
+	/**
56
+	 * Adding objects to the registry from an item name
57
+	 * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
+	 *
59
+	 * @param  string             $item       name of the item
60
+	 * @param  bool|string        $modulename name of the module
61
+	 * @param  bool|CriteriaCompo $criteria   to pass to the getObjects method of the handler (with id_as_key)
62
+	 * @return FALSE              if an error occured
63
+	 */
64
+	public function addObjectsFromItemName($item, $modulename = false, $criteria = false)
65
+	{
66
+		if (!$modulename) {
67
+			global $xoopsModule;
68
+			if (!is_object($xoopsModule)) {
69
+				return false;
70
+			} else {
71
+				$modulename = $xoopsModule->dirname();
72
+			}
73
+		}
74
+		$objectHandler = xoops_getModuleHandler($item, $modulename);
75 75
 
76
-        if (method_exists($objectHandler, 'getObjects')) {
77
-            $objects                                                                                 = $objectHandler->getObjects($criteria, true);
78
-            $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects;
76
+		if (method_exists($objectHandler, 'getObjects')) {
77
+			$objects                                                                                 = $objectHandler->getObjects($criteria, true);
78
+			$this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects;
79 79
 
80
-            return $objects;
81
-        } else {
82
-            return false;
83
-        }
84
-    }
80
+			return $objects;
81
+		} else {
82
+			return false;
83
+		}
84
+	}
85 85
 
86
-    /**
87
-     * Fetching objects from the registry
88
-     *
89
-     * @param string $itemname
90
-     * @param string $modulename
91
-     *
92
-     * @return the requested objects or FALSE if they don't exists in the registry
93
-     */
94
-    public function getObjects($itemname, $modulename)
95
-    {
96
-        if (!$modulename) {
97
-            global $xoopsModule;
98
-            if (!is_object($xoopsModule)) {
99
-                return false;
100
-            } else {
101
-                $modulename = $xoopsModule->dirname();
102
-            }
103
-        }
104
-        if (isset($this->_registryArray['objects'][$modulename][$itemname])) {
105
-            return $this->_registryArray['objects'][$modulename][$itemname];
106
-        } else {
107
-            // if they were not in registry, let's fetch them and add them to the reigistry
108
-            $moduleHandler = xoops_getModuleHandler($itemname, $modulename);
109
-            if (method_exists($moduleHandler, 'getObjects')) {
110
-                $objects = $moduleHandler->getObjects();
111
-            }
112
-            $this->_registryArray['objects'][$modulename][$itemname] = $objects;
86
+	/**
87
+	 * Fetching objects from the registry
88
+	 *
89
+	 * @param string $itemname
90
+	 * @param string $modulename
91
+	 *
92
+	 * @return the requested objects or FALSE if they don't exists in the registry
93
+	 */
94
+	public function getObjects($itemname, $modulename)
95
+	{
96
+		if (!$modulename) {
97
+			global $xoopsModule;
98
+			if (!is_object($xoopsModule)) {
99
+				return false;
100
+			} else {
101
+				$modulename = $xoopsModule->dirname();
102
+			}
103
+		}
104
+		if (isset($this->_registryArray['objects'][$modulename][$itemname])) {
105
+			return $this->_registryArray['objects'][$modulename][$itemname];
106
+		} else {
107
+			// if they were not in registry, let's fetch them and add them to the reigistry
108
+			$moduleHandler = xoops_getModuleHandler($itemname, $modulename);
109
+			if (method_exists($moduleHandler, 'getObjects')) {
110
+				$objects = $moduleHandler->getObjects();
111
+			}
112
+			$this->_registryArray['objects'][$modulename][$itemname] = $objects;
113 113
 
114
-            return $objects;
115
-        }
116
-    }
114
+			return $objects;
115
+		}
116
+	}
117 117
 
118
-    /**
119
-     * Fetching objects from the registry, as a list: objectid => identifier
120
-     *
121
-     * @param string $itemname
122
-     * @param string $modulename
123
-     *
124
-     * @return the requested objects or FALSE if they don't exists in the registry
125
-     */
126
-    public function getList($itemname, $modulename)
127
-    {
128
-        if (!$modulename) {
129
-            global $xoopsModule;
130
-            if (!is_object($xoopsModule)) {
131
-                return false;
132
-            } else {
133
-                $modulename = $xoopsModule->dirname();
134
-            }
135
-        }
136
-        if (isset($this->_registryArray['list'][$modulename][$itemname])) {
137
-            return $this->_registryArray['list'][$modulename][$itemname];
138
-        } else {
139
-            // if they were not in registry, let's fetch them and add them to the reigistry
140
-            $moduleHandler = xoops_getModuleHandler($itemname, $modulename);
141
-            if (method_exists($moduleHandler, 'getList')) {
142
-                $objects = $moduleHandler->getList();
143
-            }
144
-            $this->_registryArray['list'][$modulename][$itemname] = $objects;
118
+	/**
119
+	 * Fetching objects from the registry, as a list: objectid => identifier
120
+	 *
121
+	 * @param string $itemname
122
+	 * @param string $modulename
123
+	 *
124
+	 * @return the requested objects or FALSE if they don't exists in the registry
125
+	 */
126
+	public function getList($itemname, $modulename)
127
+	{
128
+		if (!$modulename) {
129
+			global $xoopsModule;
130
+			if (!is_object($xoopsModule)) {
131
+				return false;
132
+			} else {
133
+				$modulename = $xoopsModule->dirname();
134
+			}
135
+		}
136
+		if (isset($this->_registryArray['list'][$modulename][$itemname])) {
137
+			return $this->_registryArray['list'][$modulename][$itemname];
138
+		} else {
139
+			// if they were not in registry, let's fetch them and add them to the reigistry
140
+			$moduleHandler = xoops_getModuleHandler($itemname, $modulename);
141
+			if (method_exists($moduleHandler, 'getList')) {
142
+				$objects = $moduleHandler->getList();
143
+			}
144
+			$this->_registryArray['list'][$modulename][$itemname] = $objects;
145 145
 
146
-            return $objects;
147
-        }
148
-    }
146
+			return $objects;
147
+		}
148
+	}
149 149
 
150
-    /**
151
-     * Retreive a single object
152
-     *
153
-     * @param string $itemname
154
-     * @param string $key
155
-     *
156
-     * @param  bool $modulename
157
-     * @return the  requestd object or FALSE if they don't exists in the registry
158
-     */
159
-    public function getSingleObject($itemname, $key, $modulename = false)
160
-    {
161
-        if (!$modulename) {
162
-            global $xoopsModule;
163
-            if (!is_object($xoopsModule)) {
164
-                return false;
165
-            } else {
166
-                $modulename = $xoopsModule->dirname();
167
-            }
168
-        }
169
-        if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) {
170
-            return $this->_registryArray['objects'][$modulename][$itemname][$key];
171
-        } else {
172
-            $objectHandler = xoops_getModuleHandler($itemname, $modulename);
173
-            $object        = $objectHandler->get($key);
174
-            if (!$object->isNew()) {
175
-                return $object;
176
-            } else {
177
-                return false;
178
-            }
179
-        }
180
-    }
150
+	/**
151
+	 * Retreive a single object
152
+	 *
153
+	 * @param string $itemname
154
+	 * @param string $key
155
+	 *
156
+	 * @param  bool $modulename
157
+	 * @return the  requestd object or FALSE if they don't exists in the registry
158
+	 */
159
+	public function getSingleObject($itemname, $key, $modulename = false)
160
+	{
161
+		if (!$modulename) {
162
+			global $xoopsModule;
163
+			if (!is_object($xoopsModule)) {
164
+				return false;
165
+			} else {
166
+				$modulename = $xoopsModule->dirname();
167
+			}
168
+		}
169
+		if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) {
170
+			return $this->_registryArray['objects'][$modulename][$itemname][$key];
171
+		} else {
172
+			$objectHandler = xoops_getModuleHandler($itemname, $modulename);
173
+			$object        = $objectHandler->get($key);
174
+			if (!$object->isNew()) {
175
+				return $object;
176
+			} else {
177
+				return false;
178
+			}
179
+		}
180
+	}
181 181
 }
Please login to merge, or discard this patch.
include/functions.php 3 patches
Doc Comments   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 }
326 326
 
327 327
 /**
328
- * @param              $key
328
+ * @param              string $key
329 329
  * @param  bool        $moduleName
330 330
  * @param  string      $default
331 331
  * @return null|string
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 
388 388
 /**
389 389
  * Thanks to the NewBB2 Development Team
390
- * @param $target
390
+ * @param string $target
391 391
  * @return bool
392 392
  */
393 393
 function smart_admin_mkdir($target)
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 
541 541
 /**
542 542
  * @param $dirname
543
- * @return bool
543
+ * @return boolean|null
544 544
  */
545 545
 function smart_deleteFile($dirname)
546 546
 {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 }
756 756
 
757 757
 /**
758
- * @param $name
758
+ * @param string $name
759 759
  */
760 760
 function smart_close_collapsable($name)
761 761
 {
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 }
766 766
 
767 767
 /**
768
- * @param     $name
768
+ * @param     string $name
769 769
  * @param     $value
770 770
  * @param int $time
771 771
  */
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 }
780 780
 
781 781
 /**
782
- * @param         $name
782
+ * @param         string $name
783 783
  * @param  string $default
784 784
  * @return string
785 785
  */
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 }
939 939
 
940 940
 /**
941
- * @param $src
941
+ * @param string $src
942 942
  */
943 943
 function smart_addScript($src)
944 944
 {
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 }
1116 1116
 
1117 1117
 /**
1118
- * @param $module
1119
- * @param $file
1118
+ * @param string $module
1119
+ * @param string $file
1120 1120
  */
1121 1121
 function smart_loadLanguageFile($module, $file)
1122 1122
 {
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
  * This function should be able to cover almost all floats that appear in an european environment.
1233 1233
  * @param            $str
1234 1234
  * @param  bool      $set
1235
- * @return float|int
1235
+ * @return double
1236 1236
  */
1237 1237
 function smart_getfloat($str, $set = false)
1238 1238
 {
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 /**
1268 1268
  * @param                         $var
1269 1269
  * @param  bool                   $currencyObj
1270
- * @return float|int|mixed|string
1270
+ * @return string
1271 1271
  */
1272 1272
 function smart_currency($var, $currencyObj = false)
1273 1273
 {
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 
1296 1296
 /**
1297 1297
  * @param $var
1298
- * @return float|int|mixed|string
1298
+ * @return string
1299 1299
  */
1300 1300
 function smart_float($var)
1301 1301
 {
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 /**
1344 1344
  * @param $moduleName
1345 1345
  * @param $items
1346
- * @return array
1346
+ * @return string[]
1347 1347
  */
1348 1348
 function smart_getTablesArray($moduleName, $items)
1349 1349
 {
Please login to merge, or discard this patch.
Indentation   +733 added lines, -733 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
 function smart_get_css_link($cssfile)
13 13
 {
14
-    $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />';
14
+	$ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />';
15 15
 
16
-    return $ret;
16
+	return $ret;
17 17
 }
18 18
 
19 19
 /**
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function smart_get_page_before_form()
23 23
 {
24
-    global $smart_previous_page;
24
+	global $smart_previous_page;
25 25
 
26
-    return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page;
26
+	return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page;
27 27
 }
28 28
 
29 29
 /**
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function smart_userIsAdmin($module = false)
36 36
 {
37
-    global $xoopsUser;
38
-    static $smart_isAdmin;
39
-    if (!$module) {
40
-        global $xoopsModule;
41
-        $module = $xoopsModule->getVar('dirname');
42
-    }
43
-    if (isset($smart_isAdmin[$module])) {
44
-        return $smart_isAdmin[$module];
45
-    }
46
-    if (!$xoopsUser) {
47
-        $smart_isAdmin[$module] = false;
48
-
49
-        return $smart_isAdmin[$module];
50
-    }
51
-    $smart_isAdmin[$module] = false;
52
-    $smartModule            = smart_getModuleInfo($module);
53
-    if (!is_object($smartModule)) {
54
-        return false;
55
-    }
56
-    $module_id              = $smartModule->getVar('mid');
57
-    $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id);
58
-
59
-    return $smart_isAdmin[$module];
37
+	global $xoopsUser;
38
+	static $smart_isAdmin;
39
+	if (!$module) {
40
+		global $xoopsModule;
41
+		$module = $xoopsModule->getVar('dirname');
42
+	}
43
+	if (isset($smart_isAdmin[$module])) {
44
+		return $smart_isAdmin[$module];
45
+	}
46
+	if (!$xoopsUser) {
47
+		$smart_isAdmin[$module] = false;
48
+
49
+		return $smart_isAdmin[$module];
50
+	}
51
+	$smart_isAdmin[$module] = false;
52
+	$smartModule            = smart_getModuleInfo($module);
53
+	if (!is_object($smartModule)) {
54
+		return false;
55
+	}
56
+	$module_id              = $smartModule->getVar('mid');
57
+	$smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id);
58
+
59
+	return $smart_isAdmin[$module];
60 60
 }
61 61
 
62 62
 /**
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
  */
65 65
 function smart_isXoops22()
66 66
 {
67
-    $xoops22 = false;
68
-    $xv      = str_replace('XOOPS ', '', XOOPS_VERSION);
69
-    if (substr($xv, 2, 1) == '2') {
70
-        $xoops22 = true;
71
-    }
67
+	$xoops22 = false;
68
+	$xv      = str_replace('XOOPS ', '', XOOPS_VERSION);
69
+	if (substr($xv, 2, 1) == '2') {
70
+		$xoops22 = true;
71
+	}
72 72
 
73
-    return $xoops22;
73
+	return $xoops22;
74 74
 }
75 75
 
76 76
 /**
@@ -81,34 +81,34 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false)
83 83
 {
84
-    if (!$moduleName) {
85
-        global $xoopsModule;
86
-        $moduleName = $xoopsModule->getVar('dirname');
87
-    }
88
-    $smartModule       = smart_getModuleInfo($moduleName);
89
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
90
-    if (!isset($smartModule)) {
91
-        return '';
92
-    }
93
-
94
-    if ($forBreadCrumb && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) {
95
-        return '';
96
-    }
97
-    if (!$withLink) {
98
-        return $smartModule->getVar('name');
99
-    } else {
100
-        $seoMode = smart_getModuleModeSEO($moduleName);
101
-        if ($seoMode === 'rewrite') {
102
-            $seoModuleName = smart_getModuleNameForSEO($moduleName);
103
-            $ret           = XOOPS_URL . '/' . $seoModuleName . '/';
104
-        } elseif ($seoMode === 'pathinfo') {
105
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/';
106
-        } else {
107
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/';
108
-        }
109
-
110
-        return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>';
111
-    }
84
+	if (!$moduleName) {
85
+		global $xoopsModule;
86
+		$moduleName = $xoopsModule->getVar('dirname');
87
+	}
88
+	$smartModule       = smart_getModuleInfo($moduleName);
89
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
90
+	if (!isset($smartModule)) {
91
+		return '';
92
+	}
93
+
94
+	if ($forBreadCrumb && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) {
95
+		return '';
96
+	}
97
+	if (!$withLink) {
98
+		return $smartModule->getVar('name');
99
+	} else {
100
+		$seoMode = smart_getModuleModeSEO($moduleName);
101
+		if ($seoMode === 'rewrite') {
102
+			$seoModuleName = smart_getModuleNameForSEO($moduleName);
103
+			$ret           = XOOPS_URL . '/' . $seoModuleName . '/';
104
+		} elseif ($seoMode === 'pathinfo') {
105
+			$ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/';
106
+		} else {
107
+			$ret = XOOPS_URL . '/modules/' . $moduleName . '/';
108
+		}
109
+
110
+		return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>';
111
+	}
112 112
 }
113 113
 
114 114
 /**
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function smart_getModuleNameForSEO($moduleName = false)
119 119
 {
120
-    $smartModule       = smart_getModuleInfo($moduleName);
121
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
122
-    if (isset($smartModuleConfig['seo_module_name'])) {
123
-        return $smartModuleConfig['seo_module_name'];
124
-    }
125
-    $ret = smart_getModuleName(false, false, $moduleName);
126
-
127
-    return strtolower($ret);
120
+	$smartModule       = smart_getModuleInfo($moduleName);
121
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
122
+	if (isset($smartModuleConfig['seo_module_name'])) {
123
+		return $smartModuleConfig['seo_module_name'];
124
+	}
125
+	$ret = smart_getModuleName(false, false, $moduleName);
126
+
127
+	return strtolower($ret);
128 128
 }
129 129
 
130 130
 /**
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
  */
134 134
 function smart_getModuleModeSEO($moduleName = false)
135 135
 {
136
-    $smartModule       = smart_getModuleInfo($moduleName);
137
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
136
+	$smartModule       = smart_getModuleInfo($moduleName);
137
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
138 138
 
139
-    return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false;
139
+	return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false;
140 140
 }
141 141
 
142 142
 /**
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function smart_getModuleIncludeIdSEO($moduleName = false)
147 147
 {
148
-    $smartModule       = smart_getModuleInfo($moduleName);
149
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
148
+	$smartModule       = smart_getModuleInfo($moduleName);
149
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
150 150
 
151
-    return !empty($smartModuleConfig['seo_inc_id']);
151
+	return !empty($smartModuleConfig['seo_inc_id']);
152 152
 }
153 153
 
154 154
 /**
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function smart_getenv($key)
159 159
 {
160
-    $ret = '';
161
-    $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : '');
160
+	$ret = '';
161
+	$ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : '');
162 162
 
163
-    return $ret;
163
+	return $ret;
164 164
 }
165 165
 
166 166
 function smart_xoops_cp_header()
167 167
 {
168
-    xoops_cp_header();
169
-    global $xoopsModule, $xoopsConfig;
170
-    /**
171
-     * include SmartObject admin language file
172
-     */
173
-    $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
174
-    if (file_exists($fileName)) {
175
-        include_once $fileName;
176
-    } else {
177
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
178
-    }
179
-    ?>
168
+	xoops_cp_header();
169
+	global $xoopsModule, $xoopsConfig;
170
+	/**
171
+	 * include SmartObject admin language file
172
+	 */
173
+	$fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
174
+	if (file_exists($fileName)) {
175
+		include_once $fileName;
176
+	} else {
177
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
178
+	}
179
+	?>
180 180
     <script type='text/javascript'>
181 181
         <!--
182 182
         var smart_url = '<?php echo SMARTOBJECT_URL ?>';
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
         src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script>
190 190
     <?php
191 191
 
192
-    /**
193
-     * Include the admin language constants for the SmartObject Framework
194
-     */
195
-    $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php';
196
-    if (!file_exists($admin_file)) {
197
-        $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php';
198
-    }
199
-    include_once($admin_file);
192
+	/**
193
+	 * Include the admin language constants for the SmartObject Framework
194
+	 */
195
+	$admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php';
196
+	if (!file_exists($admin_file)) {
197
+		$admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php';
198
+	}
199
+	include_once($admin_file);
200 200
 }
201 201
 
202 202
 /**
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function smart_TableExists($table)
212 212
 {
213
-    $bRetVal = false;
214
-    //Verifies that a MySQL table exists
215
-    $xoopsDB  = XoopsDatabaseFactory::getDatabaseConnection();
216
-    $realname = $xoopsDB->prefix($table);
217
-    $sql      = 'SHOW TABLES FROM ' . XOOPS_DB_NAME;
218
-    $ret      = $xoopsDB->queryF($sql);
219
-    while (list($m_table) = $xoopsDB->fetchRow($ret)) {
220
-        if ($m_table == $realname) {
221
-            $bRetVal = true;
222
-            break;
223
-        }
224
-    }
225
-    $xoopsDB->freeRecordSet($ret);
226
-
227
-    return $bRetVal;
213
+	$bRetVal = false;
214
+	//Verifies that a MySQL table exists
215
+	$xoopsDB  = XoopsDatabaseFactory::getDatabaseConnection();
216
+	$realname = $xoopsDB->prefix($table);
217
+	$sql      = 'SHOW TABLES FROM ' . XOOPS_DB_NAME;
218
+	$ret      = $xoopsDB->queryF($sql);
219
+	while (list($m_table) = $xoopsDB->fetchRow($ret)) {
220
+		if ($m_table == $realname) {
221
+			$bRetVal = true;
222
+			break;
223
+		}
224
+	}
225
+	$xoopsDB->freeRecordSet($ret);
226
+
227
+	return $bRetVal;
228 228
 }
229 229
 
230 230
 /**
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
  */
240 240
 function smart_GetMeta($key, $moduleName = false)
241 241
 {
242
-    if (!$moduleName) {
243
-        $moduleName = smart_getCurrentModuleName();
244
-    }
245
-    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
246
-    $sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key));
247
-    $ret     = $xoopsDB->query($sql);
248
-    if (!$ret) {
249
-        $value = false;
250
-    } else {
251
-        list($value) = $xoopsDB->fetchRow($ret);
252
-    }
253
-
254
-    return $value;
242
+	if (!$moduleName) {
243
+		$moduleName = smart_getCurrentModuleName();
244
+	}
245
+	$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
246
+	$sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key));
247
+	$ret     = $xoopsDB->query($sql);
248
+	if (!$ret) {
249
+		$value = false;
250
+	} else {
251
+		list($value) = $xoopsDB->fetchRow($ret);
252
+	}
253
+
254
+	return $value;
255 255
 }
256 256
 
257 257
 /**
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function smart_getCurrentModuleName()
261 261
 {
262
-    global $xoopsModule;
263
-    if (is_object($xoopsModule)) {
264
-        return $xoopsModule->getVar('dirname');
265
-    } else {
266
-        return false;
267
-    }
262
+	global $xoopsModule;
263
+	if (is_object($xoopsModule)) {
264
+		return $xoopsModule->getVar('dirname');
265
+	} else {
266
+		return false;
267
+	}
268 268
 }
269 269
 
270 270
 /**
@@ -280,22 +280,22 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function smart_SetMeta($key, $value, $moduleName = false)
282 282
 {
283
-    if (!$moduleName) {
284
-        $moduleName = smart_getCurrentModuleName();
285
-    }
286
-    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
287
-    $ret     = smart_GetMeta($key, $moduleName);
288
-    if ($ret === '0' || $ret > 0) {
289
-        $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
290
-    } else {
291
-        $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
292
-    }
293
-    $ret = $xoopsDB->queryF($sql);
294
-    if (!$ret) {
295
-        return false;
296
-    }
297
-
298
-    return true;
283
+	if (!$moduleName) {
284
+		$moduleName = smart_getCurrentModuleName();
285
+	}
286
+	$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
287
+	$ret     = smart_GetMeta($key, $moduleName);
288
+	if ($ret === '0' || $ret > 0) {
289
+		$sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
290
+	} else {
291
+		$sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
292
+	}
293
+	$ret = $xoopsDB->queryF($sql);
294
+	if (!$ret) {
295
+		return false;
296
+	}
297
+
298
+	return true;
299 299
 }
300 300
 
301 301
 // Thanks to Mithrandir:-)
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
  */
309 309
 function smart_substr($str, $start, $length, $trimmarker = '...')
310 310
 {
311
-    // if the string is empty, let's get out ;-)
312
-    if ($str === '') {
313
-        return $str;
314
-    }
315
-    // reverse a string that is shortened with '' as trimmarker
316
-    $reversed_string = strrev(xoops_substr($str, $start, $length, ''));
317
-    // find first space in reversed string
318
-    $position_of_space = strpos($reversed_string, ' ', 0);
319
-    // truncate the original string to a length of $length
320
-    // minus the position of the last space
321
-    // plus the length of the $trimmarker
322
-    $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
323
-
324
-    return $truncated_string;
311
+	// if the string is empty, let's get out ;-)
312
+	if ($str === '') {
313
+		return $str;
314
+	}
315
+	// reverse a string that is shortened with '' as trimmarker
316
+	$reversed_string = strrev(xoops_substr($str, $start, $length, ''));
317
+	// find first space in reversed string
318
+	$position_of_space = strpos($reversed_string, ' ', 0);
319
+	// truncate the original string to a length of $length
320
+	// minus the position of the last space
321
+	// plus the length of the $trimmarker
322
+	$truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
323
+
324
+	return $truncated_string;
325 325
 }
326 326
 
327 327
 /**
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
  */
333 333
 function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined')
334 334
 {
335
-    if (!$moduleName) {
336
-        $moduleName = smart_getCurrentModuleName();
337
-    }
338
-    $configs = smart_getModuleConfig($moduleName);
339
-    if (isset($configs[$key])) {
340
-        return $configs[$key];
341
-    } else {
342
-        if ($default === 'default_is_undefined') {
343
-            return null;
344
-        } else {
345
-            return $default;
346
-        }
347
-    }
335
+	if (!$moduleName) {
336
+		$moduleName = smart_getCurrentModuleName();
337
+	}
338
+	$configs = smart_getModuleConfig($moduleName);
339
+	if (isset($configs[$key])) {
340
+		return $configs[$key];
341
+	} else {
342
+		if ($default === 'default_is_undefined') {
343
+			return null;
344
+		} else {
345
+			return $default;
346
+		}
347
+	}
348 348
 }
349 349
 
350 350
 /**
@@ -357,32 +357,32 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function smart_copyr($source, $dest)
359 359
 {
360
-    // Simple copy for a file
361
-    if (is_file($source)) {
362
-        return copy($source, $dest);
363
-    }
364
-    // Make destination directory
365
-    if (!is_dir($dest)) {
366
-        mkdir($dest);
367
-    }
368
-    // Loop through the folder
369
-    $dir = dir($source);
370
-    while (false !== $entry = $dir->read()) {
371
-        // Skip pointers
372
-        if ($entry === '.' || $entry === '..') {
373
-            continue;
374
-        }
375
-        // Deep copy directories
376
-        if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) {
377
-            copyr("$source/$entry", "$dest/$entry");
378
-        } else {
379
-            copy("$source/$entry", "$dest/$entry");
380
-        }
381
-    }
382
-    // Clean up
383
-    $dir->close();
384
-
385
-    return true;
360
+	// Simple copy for a file
361
+	if (is_file($source)) {
362
+		return copy($source, $dest);
363
+	}
364
+	// Make destination directory
365
+	if (!is_dir($dest)) {
366
+		mkdir($dest);
367
+	}
368
+	// Loop through the folder
369
+	$dir = dir($source);
370
+	while (false !== $entry = $dir->read()) {
371
+		// Skip pointers
372
+		if ($entry === '.' || $entry === '..') {
373
+			continue;
374
+		}
375
+		// Deep copy directories
376
+		if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) {
377
+			copyr("$source/$entry", "$dest/$entry");
378
+		} else {
379
+			copy("$source/$entry", "$dest/$entry");
380
+		}
381
+	}
382
+	// Clean up
383
+	$dir->close();
384
+
385
+	return true;
386 386
 }
387 387
 
388 388
 /**
@@ -392,26 +392,26 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function smart_admin_mkdir($target)
394 394
 {
395
-    // http://www.php.net/manual/en/function.mkdir.php
396
-    // saint at corenova.com
397
-    // bart at cdasites dot com
398
-    if (is_dir($target) || empty($target)) {
399
-        return true; // best case check first
400
-    }
401
-    if (file_exists($target) && !is_dir($target)) {
402
-        return false;
403
-    }
404
-    if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) {
405
-        if (!file_exists($target)) {
406
-            $res = mkdir($target, 0777); // crawl back up & create dir tree
407
-            smart_admin_chmod($target);
408
-
409
-            return $res;
410
-        }
411
-    }
412
-    $res = is_dir($target);
413
-
414
-    return $res;
395
+	// http://www.php.net/manual/en/function.mkdir.php
396
+	// saint at corenova.com
397
+	// bart at cdasites dot com
398
+	if (is_dir($target) || empty($target)) {
399
+		return true; // best case check first
400
+	}
401
+	if (file_exists($target) && !is_dir($target)) {
402
+		return false;
403
+	}
404
+	if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) {
405
+		if (!file_exists($target)) {
406
+			$res = mkdir($target, 0777); // crawl back up & create dir tree
407
+			smart_admin_chmod($target);
408
+
409
+			return $res;
410
+		}
411
+	}
412
+	$res = is_dir($target);
413
+
414
+	return $res;
415 415
 }
416 416
 
417 417
 /**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  */
423 423
 function smart_admin_chmod($target, $mode = 0777)
424 424
 {
425
-    return @ chmod($target, $mode);
425
+	return @ chmod($target, $mode);
426 426
 }
427 427
 
428 428
 /**
@@ -433,31 +433,31 @@  discard block
 block discarded – undo
433 433
  */
434 434
 function smart_imageResize($src, $maxWidth, $maxHeight)
435 435
 {
436
-    $width  = '';
437
-    $height = '';
438
-    $type   = '';
439
-    $attr   = '';
440
-    if (file_exists($src)) {
441
-        list($width, $height, $type, $attr) = getimagesize($src);
442
-        if ($width > $maxWidth) {
443
-            $originalWidth = $width;
444
-            $width         = $maxWidth;
445
-            $height        = $width * $height / $originalWidth;
446
-        }
447
-        if ($height > $maxHeight) {
448
-            $originalHeight = $height;
449
-            $height         = $maxHeight;
450
-            $width          = $height * $width / $originalHeight;
451
-        }
452
-        $attr = " width='$width' height='$height'";
453
-    }
454
-
455
-    return array(
456
-        $width,
457
-        $height,
458
-        $type,
459
-        $attr
460
-    );
436
+	$width  = '';
437
+	$height = '';
438
+	$type   = '';
439
+	$attr   = '';
440
+	if (file_exists($src)) {
441
+		list($width, $height, $type, $attr) = getimagesize($src);
442
+		if ($width > $maxWidth) {
443
+			$originalWidth = $width;
444
+			$width         = $maxWidth;
445
+			$height        = $width * $height / $originalWidth;
446
+		}
447
+		if ($height > $maxHeight) {
448
+			$originalHeight = $height;
449
+			$height         = $maxHeight;
450
+			$width          = $height * $width / $originalHeight;
451
+		}
452
+		$attr = " width='$width' height='$height'";
453
+	}
454
+
455
+	return array(
456
+		$width,
457
+		$height,
458
+		$type,
459
+		$attr
460
+	);
461 461
 }
462 462
 
463 463
 /**
@@ -466,34 +466,34 @@  discard block
 block discarded – undo
466 466
  */
467 467
 function smart_getModuleInfo($moduleName = false)
468 468
 {
469
-    static $smartModules;
470
-    if (isset($smartModules[$moduleName])) {
471
-        $ret =& $smartModules[$moduleName];
472
-
473
-        return $ret;
474
-    }
475
-    global $xoopsModule;
476
-    if (!$moduleName) {
477
-        if (isset($xoopsModule) && is_object($xoopsModule)) {
478
-            $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule;
479
-
480
-            return $smartModules[$xoopsModule->getVar('dirname')];
481
-        }
482
-    }
483
-    if (!isset($smartModules[$moduleName])) {
484
-        if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
485
-            $smartModules[$moduleName] = $xoopsModule;
486
-        } else {
487
-            $hModule = xoops_getHandler('module');
488
-            if ($moduleName !== 'xoops') {
489
-                $smartModules[$moduleName] = $hModule->getByDirname($moduleName);
490
-            } else {
491
-                $smartModules[$moduleName] = $hModule->getByDirname('system');
492
-            }
493
-        }
494
-    }
495
-
496
-    return $smartModules[$moduleName];
469
+	static $smartModules;
470
+	if (isset($smartModules[$moduleName])) {
471
+		$ret =& $smartModules[$moduleName];
472
+
473
+		return $ret;
474
+	}
475
+	global $xoopsModule;
476
+	if (!$moduleName) {
477
+		if (isset($xoopsModule) && is_object($xoopsModule)) {
478
+			$smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule;
479
+
480
+			return $smartModules[$xoopsModule->getVar('dirname')];
481
+		}
482
+	}
483
+	if (!isset($smartModules[$moduleName])) {
484
+		if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
485
+			$smartModules[$moduleName] = $xoopsModule;
486
+		} else {
487
+			$hModule = xoops_getHandler('module');
488
+			if ($moduleName !== 'xoops') {
489
+				$smartModules[$moduleName] = $hModule->getByDirname($moduleName);
490
+			} else {
491
+				$smartModules[$moduleName] = $hModule->getByDirname('system');
492
+			}
493
+		}
494
+	}
495
+
496
+	return $smartModules[$moduleName];
497 497
 }
498 498
 
499 499
 /**
@@ -502,40 +502,40 @@  discard block
 block discarded – undo
502 502
  */
503 503
 function smart_getModuleConfig($moduleName = false)
504 504
 {
505
-    static $smartConfigs;
506
-    if (isset($smartConfigs[$moduleName])) {
507
-        $ret =& $smartConfigs[$moduleName];
508
-
509
-        return $ret;
510
-    }
511
-    global $xoopsModule, $xoopsModuleConfig;
512
-    if (!$moduleName) {
513
-        if (isset($xoopsModule) && is_object($xoopsModule)) {
514
-            $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig;
515
-
516
-            return $smartConfigs[$xoopsModule->getVar('dirname')];
517
-        }
518
-    }
519
-    // if we still did not found the xoopsModule, this is because there is none
520
-    if (!$moduleName) {
521
-        $ret = false;
522
-
523
-        return $ret;
524
-    }
525
-    if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
526
-        $smartConfigs[$moduleName] = $xoopsModuleConfig;
527
-    } else {
528
-        $module = smart_getModuleInfo($moduleName);
529
-        if (!is_object($module)) {
530
-            $ret = false;
531
-
532
-            return $ret;
533
-        }
534
-        $hModConfig                = xoops_getHandler('config');
535
-        $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
536
-    }
537
-
538
-    return $smartConfigs[$moduleName];
505
+	static $smartConfigs;
506
+	if (isset($smartConfigs[$moduleName])) {
507
+		$ret =& $smartConfigs[$moduleName];
508
+
509
+		return $ret;
510
+	}
511
+	global $xoopsModule, $xoopsModuleConfig;
512
+	if (!$moduleName) {
513
+		if (isset($xoopsModule) && is_object($xoopsModule)) {
514
+			$smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig;
515
+
516
+			return $smartConfigs[$xoopsModule->getVar('dirname')];
517
+		}
518
+	}
519
+	// if we still did not found the xoopsModule, this is because there is none
520
+	if (!$moduleName) {
521
+		$ret = false;
522
+
523
+		return $ret;
524
+	}
525
+	if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
526
+		$smartConfigs[$moduleName] = $xoopsModuleConfig;
527
+	} else {
528
+		$module = smart_getModuleInfo($moduleName);
529
+		if (!is_object($module)) {
530
+			$ret = false;
531
+
532
+			return $ret;
533
+		}
534
+		$hModConfig                = xoops_getHandler('config');
535
+		$smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
536
+	}
537
+
538
+	return $smartConfigs[$moduleName];
539 539
 }
540 540
 
541 541
 /**
@@ -544,10 +544,10 @@  discard block
 block discarded – undo
544 544
  */
545 545
 function smart_deleteFile($dirname)
546 546
 {
547
-    // Simple delete for a file
548
-    if (is_file($dirname)) {
549
-        return unlink($dirname);
550
-    }
547
+	// Simple delete for a file
548
+	if (is_file($dirname)) {
549
+		return unlink($dirname);
550
+	}
551 551
 }
552 552
 
553 553
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  */
557 557
 function smart_formatErrors($errors = array())
558 558
 {
559
-    $ret = '';
560
-    foreach ($errors as $key => $value) {
561
-        $ret .= '<br> - ' . $value;
562
-    }
559
+	$ret = '';
560
+	foreach ($errors as $key => $value) {
561
+		$ret .= '<br> - ' . $value;
562
+	}
563 563
 
564
-    return $ret;
564
+	return $ret;
565 565
 }
566 566
 
567 567
 /**
@@ -575,64 +575,64 @@  discard block
 block discarded – undo
575 575
  */
576 576
 function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false)
577 577
 {
578
-    if (!is_numeric($userid)) {
579
-        return $userid;
580
-    }
581
-    $userid = (int)$userid;
582
-    if ($userid > 0) {
583
-        if ($users == array()) {
584
-            //fetching users
585
-            $memberHandler = xoops_getHandler('member');
586
-            $user          =& $memberHandler->getUser($userid);
587
-        } else {
588
-            if (!isset($users[$userid])) {
589
-                return $GLOBALS['xoopsConfig']['anonymous'];
590
-            }
591
-            $user =& $users[$userid];
592
-        }
593
-        if (is_object($user)) {
594
-            $ts        = MyTextSanitizer:: getInstance();
595
-            $username  = $user->getVar('uname');
596
-            $fullname  = '';
597
-            $fullname2 = $user->getVar('name');
598
-            if ($name && !empty($fullname2)) {
599
-                $fullname = $user->getVar('name');
600
-            }
601
-            if (!empty($fullname)) {
602
-                $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
603
-            } else {
604
-                $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
605
-            }
606
-            // add contact info: email + PM
607
-            if ($withContact) {
608
-                $linkeduser .= ' <a href="mailto:' .
609
-                               $user->getVar('email') .
610
-                               '"><img style="vertical-align: middle;" src="' .
611
-                               XOOPS_URL .
612
-                               '/images/icons/email.gif' .
613
-                               '" alt="' .
614
-                               _CO_SOBJECT_SEND_EMAIL .
615
-                               '" title="' .
616
-                               _CO_SOBJECT_SEND_EMAIL .
617
-                               '"/></a>';
618
-                $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
619
-                $linkeduser .= ' <a href="' .
620
-                               $js .
621
-                               '"><img style="vertical-align: middle;" src="' .
622
-                               XOOPS_URL .
623
-                               '/images/icons/pm.gif' .
624
-                               '" alt="' .
625
-                               _CO_SOBJECT_SEND_PM .
626
-                               '" title="' .
627
-                               _CO_SOBJECT_SEND_PM .
628
-                               '"/></a>';
629
-            }
630
-
631
-            return $linkeduser;
632
-        }
633
-    }
634
-
635
-    return $GLOBALS['xoopsConfig']['anonymous'];
578
+	if (!is_numeric($userid)) {
579
+		return $userid;
580
+	}
581
+	$userid = (int)$userid;
582
+	if ($userid > 0) {
583
+		if ($users == array()) {
584
+			//fetching users
585
+			$memberHandler = xoops_getHandler('member');
586
+			$user          =& $memberHandler->getUser($userid);
587
+		} else {
588
+			if (!isset($users[$userid])) {
589
+				return $GLOBALS['xoopsConfig']['anonymous'];
590
+			}
591
+			$user =& $users[$userid];
592
+		}
593
+		if (is_object($user)) {
594
+			$ts        = MyTextSanitizer:: getInstance();
595
+			$username  = $user->getVar('uname');
596
+			$fullname  = '';
597
+			$fullname2 = $user->getVar('name');
598
+			if ($name && !empty($fullname2)) {
599
+				$fullname = $user->getVar('name');
600
+			}
601
+			if (!empty($fullname)) {
602
+				$linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
603
+			} else {
604
+				$linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
605
+			}
606
+			// add contact info: email + PM
607
+			if ($withContact) {
608
+				$linkeduser .= ' <a href="mailto:' .
609
+							   $user->getVar('email') .
610
+							   '"><img style="vertical-align: middle;" src="' .
611
+							   XOOPS_URL .
612
+							   '/images/icons/email.gif' .
613
+							   '" alt="' .
614
+							   _CO_SOBJECT_SEND_EMAIL .
615
+							   '" title="' .
616
+							   _CO_SOBJECT_SEND_EMAIL .
617
+							   '"/></a>';
618
+				$js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
619
+				$linkeduser .= ' <a href="' .
620
+							   $js .
621
+							   '"><img style="vertical-align: middle;" src="' .
622
+							   XOOPS_URL .
623
+							   '/images/icons/pm.gif' .
624
+							   '" alt="' .
625
+							   _CO_SOBJECT_SEND_PM .
626
+							   '" title="' .
627
+							   _CO_SOBJECT_SEND_PM .
628
+							   '"/></a>';
629
+			}
630
+
631
+			return $linkeduser;
632
+		}
633
+	}
634
+
635
+	return $GLOBALS['xoopsConfig']['anonymous'];
636 636
 }
637 637
 
638 638
 /**
@@ -643,33 +643,33 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1)
645 645
 {
646
-    global $xoopsModule, $xoopsConfig;
647
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
648
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
649
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
650
-    } else {
651
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
652
-    }
653
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
654
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
655
-    } else {
656
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
657
-    }
658
-    $headermenu = array();
659
-    $adminmenu  = array();
660
-    include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
661
-    $tpl = new XoopsTpl();
662
-    $tpl->assign(array(
663
-                     'headermenu'      => $headermenu,
664
-                     'adminmenu'       => $adminmenu,
665
-                     'current'         => $currentoption,
666
-                     'breadcrumb'      => $breadcrumb,
667
-                     'headermenucount' => count($headermenu),
668
-                     'submenus'        => $submenus,
669
-                     'currentsub'      => $currentsub,
670
-                     'submenuscount'   => count($submenus)
671
-                 ));
672
-    $tpl->display('db:smartobject_admin_menu.tpl');
646
+	global $xoopsModule, $xoopsConfig;
647
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
648
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
649
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
650
+	} else {
651
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
652
+	}
653
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
654
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
655
+	} else {
656
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
657
+	}
658
+	$headermenu = array();
659
+	$adminmenu  = array();
660
+	include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
661
+	$tpl = new XoopsTpl();
662
+	$tpl->assign(array(
663
+					 'headermenu'      => $headermenu,
664
+					 'adminmenu'       => $adminmenu,
665
+					 'current'         => $currentoption,
666
+					 'breadcrumb'      => $breadcrumb,
667
+					 'headermenucount' => count($headermenu),
668
+					 'submenus'        => $submenus,
669
+					 'currentsub'      => $currentsub,
670
+					 'submenuscount'   => count($submenus)
671
+				 ));
672
+	$tpl->display('db:smartobject_admin_menu.tpl');
673 673
 }
674 674
 
675 675
 /**
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function smart_collapsableBar($id = '', $title = '', $dsc = '')
681 681
 {
682
-    global $xoopsModule;
683
-    echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>";
684
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
685
-    echo "<div id='" . $id . "'>";
686
-    if ($dsc !== '') {
687
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
688
-    }
682
+	global $xoopsModule;
683
+	echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>";
684
+	echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
685
+	echo "<div id='" . $id . "'>";
686
+	if ($dsc !== '') {
687
+		echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
688
+	}
689 689
 }
690 690
 
691 691
 /**
@@ -695,15 +695,15 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '')
697 697
 {
698
-    global $xoopsModule;
699
-    $onClick = "ajaxtogglecollapse('$id')";
700
-    //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
701
-    echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
702
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
703
-    echo "<div id='" . $id . "'>";
704
-    if ($dsc !== '') {
705
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
706
-    }
698
+	global $xoopsModule;
699
+	$onClick = "ajaxtogglecollapse('$id')";
700
+	//$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
701
+	echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
702
+	echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
703
+	echo "<div id='" . $id . "'>";
704
+	if ($dsc !== '') {
705
+		echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
706
+	}
707 707
 }
708 708
 
709 709
 /**
@@ -730,20 +730,20 @@  discard block
 block discarded – undo
730 730
  */
731 731
 function smart_openclose_collapsable($name)
732 732
 {
733
-    $urls        = smart_getCurrentUrls();
734
-    $path        = $urls['phpself'];
735
-    $cookie_name = $path . '_smart_collaps_' . $name;
736
-    $cookie_name = str_replace('.', '_', $cookie_name);
737
-    $cookie      = smart_getCookieVar($cookie_name, '');
738
-    if ($cookie === 'none') {
739
-        echo '
733
+	$urls        = smart_getCurrentUrls();
734
+	$path        = $urls['phpself'];
735
+	$cookie_name = $path . '_smart_collaps_' . $name;
736
+	$cookie_name = str_replace('.', '_', $cookie_name);
737
+	$cookie      = smart_getCookieVar($cookie_name, '');
738
+	if ($cookie === 'none') {
739
+		echo '
740 740
                 <script type="text/javascript"><!--
741 741
                 togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon");
742 742
                     //-->
743 743
                 </script>
744 744
                 ';
745
-    }
746
-    /*  if ($cookie == 'none') {
745
+	}
746
+	/*  if ($cookie == 'none') {
747 747
      echo '
748 748
      <script type="text/javascript"><!--
749 749
      hideElement("' . $name . '");
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
  */
760 760
 function smart_close_collapsable($name)
761 761
 {
762
-    echo '</div>';
763
-    smart_openclose_collapsable($name);
764
-    echo '<br>';
762
+	echo '</div>';
763
+	smart_openclose_collapsable($name);
764
+	echo '<br>';
765 765
 }
766 766
 
767 767
 /**
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
  */
772 772
 function smart_setCookieVar($name, $value, $time = 0)
773 773
 {
774
-    if ($time == 0) {
775
-        $time = time() + 3600 * 24 * 365;
776
-        //$time = '';
777
-    }
778
-    setcookie($name, $value, $time, '/');
774
+	if ($time == 0) {
775
+		$time = time() + 3600 * 24 * 365;
776
+		//$time = '';
777
+	}
778
+	setcookie($name, $value, $time, '/');
779 779
 }
780 780
 
781 781
 /**
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
  */
786 786
 function smart_getCookieVar($name, $default = '')
787 787
 {
788
-    $name = str_replace('.', '_', $name);
789
-    if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
790
-        return $_COOKIE[$name];
791
-    } else {
792
-        return $default;
793
-    }
788
+	$name = str_replace('.', '_', $name);
789
+	if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
790
+		return $_COOKIE[$name];
791
+	} else {
792
+		return $default;
793
+	}
794 794
 }
795 795
 
796 796
 /**
@@ -798,25 +798,25 @@  discard block
 block discarded – undo
798 798
  */
799 799
 function smart_getCurrentUrls()
800 800
 {
801
-    $urls        = array();
802
-    $http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
803
-    $phpself     = $_SERVER['PHP_SELF'];
804
-    $httphost    = $_SERVER['HTTP_HOST'];
805
-    $querystring = $_SERVER['QUERY_STRING'];
806
-    if ($querystring !== '') {
807
-        $querystring = '?' . $querystring;
808
-    }
809
-    $currenturl           = $http . $httphost . $phpself . $querystring;
810
-    $urls                 = array();
811
-    $urls['http']         = $http;
812
-    $urls['httphost']     = $httphost;
813
-    $urls['phpself']      = $phpself;
814
-    $urls['querystring']  = $querystring;
815
-    $urls['full_phpself'] = $http . $httphost . $phpself;
816
-    $urls['full']         = $currenturl;
817
-    $urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
818
-
819
-    return $urls;
801
+	$urls        = array();
802
+	$http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
803
+	$phpself     = $_SERVER['PHP_SELF'];
804
+	$httphost    = $_SERVER['HTTP_HOST'];
805
+	$querystring = $_SERVER['QUERY_STRING'];
806
+	if ($querystring !== '') {
807
+		$querystring = '?' . $querystring;
808
+	}
809
+	$currenturl           = $http . $httphost . $phpself . $querystring;
810
+	$urls                 = array();
811
+	$urls['http']         = $http;
812
+	$urls['httphost']     = $httphost;
813
+	$urls['phpself']      = $phpself;
814
+	$urls['querystring']  = $querystring;
815
+	$urls['full_phpself'] = $http . $httphost . $phpself;
816
+	$urls['full']         = $currenturl;
817
+	$urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
818
+
819
+	return $urls;
820 820
 }
821 821
 
822 822
 /**
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
  */
825 825
 function smart_getCurrentPage()
826 826
 {
827
-    $urls = smart_getCurrentUrls();
827
+	$urls = smart_getCurrentUrls();
828 828
 
829
-    return $urls['full'];
829
+	return $urls['full'];
830 830
 }
831 831
 
832 832
 /**
@@ -889,39 +889,39 @@  discard block
 block discarded – undo
889 889
  */
890 890
 function smart_modFooter()
891 891
 {
892
-    global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
893
-
894
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
895
-    $tpl = new XoopsTpl();
896
-
897
-    $hModule      = xoops_getHandler('module');
898
-    $versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
899
-    $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
900
-    $modfooter    = "<a href='" .
901
-                    $versioninfo->getInfo('support_site_url') .
902
-                    "' target='_blank'><img src='" .
903
-                    XOOPS_URL .
904
-                    '/modules/' .
905
-                    $xoopsModule->getVar('dirname') .
906
-                    "/assets/images/cssbutton.gif' title='" .
907
-                    $modfootertxt .
908
-                    "' alt='" .
909
-                    $modfootertxt .
910
-                    "'/></a>";
911
-    $tpl->assign('modfooter', $modfooter);
912
-
913
-    if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
914
-        define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?');
915
-    }
916
-    $smartobjectConfig = smart_getModuleConfig('smartobject');
917
-    $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
918
-    $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
892
+	global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
893
+
894
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
895
+	$tpl = new XoopsTpl();
896
+
897
+	$hModule      = xoops_getHandler('module');
898
+	$versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
899
+	$modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
900
+	$modfooter    = "<a href='" .
901
+					$versioninfo->getInfo('support_site_url') .
902
+					"' target='_blank'><img src='" .
903
+					XOOPS_URL .
904
+					'/modules/' .
905
+					$xoopsModule->getVar('dirname') .
906
+					"/assets/images/cssbutton.gif' title='" .
907
+					$modfootertxt .
908
+					"' alt='" .
909
+					$modfootertxt .
910
+					"'/></a>";
911
+	$tpl->assign('modfooter', $modfooter);
912
+
913
+	if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
914
+		define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?');
915
+	}
916
+	$smartobjectConfig = smart_getModuleConfig('smartobject');
917
+	$tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
918
+	$tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
919 919
 }
920 920
 
921 921
 function smart_xoops_cp_footer()
922 922
 {
923
-    smart_modFooter();
924
-    xoops_cp_footer();
923
+	smart_modFooter();
924
+	xoops_cp_footer();
925 925
 }
926 926
 
927 927
 /**
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
  */
931 931
 function smart_sanitizeForCommonTags($text)
932 932
 {
933
-    global $xoopsConfig;
934
-    $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
935
-    $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
933
+	global $xoopsConfig;
934
+	$text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
935
+	$text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
936 936
 
937
-    return $text;
937
+	return $text;
938 938
 }
939 939
 
940 940
 /**
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
  */
943 943
 function smart_addScript($src)
944 944
 {
945
-    echo '<script src="' . $src . '" type="text/javascript"></script>';
945
+	echo '<script src="' . $src . '" type="text/javascript"></script>';
946 946
 }
947 947
 
948 948
 /**
@@ -950,17 +950,17 @@  discard block
 block discarded – undo
950 950
  */
951 951
 function smart_addStyle($src)
952 952
 {
953
-    if ($src === 'smartobject') {
954
-        $src = SMARTOBJECT_URL . 'assets/css/module.css';
955
-    }
956
-    echo smart_get_css_link($src);
953
+	if ($src === 'smartobject') {
954
+		$src = SMARTOBJECT_URL . 'assets/css/module.css';
955
+	}
956
+	echo smart_get_css_link($src);
957 957
 }
958 958
 
959 959
 function smart_addAdminAjaxSupport()
960 960
 {
961
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
962
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
963
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
961
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
962
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
963
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
964 964
 }
965 965
 
966 966
 /**
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
  */
970 970
 function smart_sanitizeForSmartpopupLink($text)
971 971
 {
972
-    $patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
973
-    $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
974
-    $ret            = preg_replace($patterns, $replacements, $text);
972
+	$patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
973
+	$replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
974
+	$ret            = preg_replace($patterns, $replacements, $text);
975 975
 
976
-    return $ret;
976
+	return $ret;
977 977
 }
978 978
 
979 979
 /**
@@ -988,25 +988,25 @@  discard block
 block discarded – undo
988 988
  */
989 989
 function smart_getImageSize($url, & $width, & $height)
990 990
 {
991
-    if (empty($width) || empty($height)) {
992
-        if (!$dimension = @ getimagesize($url)) {
993
-            return false;
994
-        }
995
-        if (!empty($width)) {
996
-            $height = $dimension[1] * $width / $dimension[0];
997
-        } elseif (!empty($height)) {
998
-            $width = $dimension[0] * $height / $dimension[1];
999
-        } else {
1000
-            list($width, $height) = array(
1001
-                $dimension[0],
1002
-                $dimension[1]
1003
-            );
1004
-        }
1005
-
1006
-        return true;
1007
-    } else {
1008
-        return true;
1009
-    }
991
+	if (empty($width) || empty($height)) {
992
+		if (!$dimension = @ getimagesize($url)) {
993
+			return false;
994
+		}
995
+		if (!empty($width)) {
996
+			$height = $dimension[1] * $width / $dimension[0];
997
+		} elseif (!empty($height)) {
998
+			$width = $dimension[0] * $height / $dimension[1];
999
+		} else {
1000
+			list($width, $height) = array(
1001
+				$dimension[0],
1002
+				$dimension[1]
1003
+			);
1004
+		}
1005
+
1006
+		return true;
1007
+	} else {
1008
+		return true;
1009
+	}
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
  */
1020 1020
 function smart_htmlnumericentities($str)
1021 1021
 {
1022
-    //    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
1023
-    return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
1022
+	//    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
1023
+	return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
1024 1024
 }
1025 1025
 
1026 1026
 /**
@@ -1030,24 +1030,24 @@  discard block
 block discarded – undo
1030 1030
  */
1031 1031
 function smart_getcorehandler($name, $optional = false)
1032 1032
 {
1033
-    static $handlers;
1034
-    $name = strtolower(trim($name));
1035
-    if (!isset($handlers[$name])) {
1036
-        if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
1037
-            require_once $hnd_file;
1038
-        }
1039
-        $class = 'Xoops' . ucfirst($name) . 'Handler';
1040
-        if (class_exists($class)) {
1041
-            $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
1042
-        }
1043
-    }
1044
-    if (!isset($handlers[$name]) && !$optional) {
1045
-        trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
1046
-    }
1047
-    if (isset($handlers[$name])) {
1048
-        return $handlers[$name];
1049
-    }
1050
-    $inst = false;
1033
+	static $handlers;
1034
+	$name = strtolower(trim($name));
1035
+	if (!isset($handlers[$name])) {
1036
+		if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
1037
+			require_once $hnd_file;
1038
+		}
1039
+		$class = 'Xoops' . ucfirst($name) . 'Handler';
1040
+		if (class_exists($class)) {
1041
+			$handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
1042
+		}
1043
+	}
1044
+	if (!isset($handlers[$name]) && !$optional) {
1045
+		trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
1046
+	}
1047
+	if (isset($handlers[$name])) {
1048
+		return $handlers[$name];
1049
+	}
1050
+	$inst = false;
1051 1051
 }
1052 1052
 
1053 1053
 /**
@@ -1056,15 +1056,15 @@  discard block
 block discarded – undo
1056 1056
  */
1057 1057
 function smart_sanitizeAdsenses_callback($matches)
1058 1058
 {
1059
-    global $smartobjectAdsenseHandler;
1060
-    if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1061
-        $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1062
-        $ret        = $adsenseObj->render();
1063
-
1064
-        return $ret;
1065
-    } else {
1066
-        return '';
1067
-    }
1059
+	global $smartobjectAdsenseHandler;
1060
+	if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1061
+		$adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1062
+		$ret        = $adsenseObj->render();
1063
+
1064
+		return $ret;
1065
+	} else {
1066
+		return '';
1067
+	}
1068 1068
 }
1069 1069
 
1070 1070
 /**
@@ -1073,13 +1073,13 @@  discard block
 block discarded – undo
1073 1073
  */
1074 1074
 function smart_sanitizeAdsenses($text)
1075 1075
 {
1076
-    $patterns     = array();
1077
-    $replacements = array();
1076
+	$patterns     = array();
1077
+	$replacements = array();
1078 1078
 
1079
-    $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1080
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1079
+	$patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1080
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1081 1081
 
1082
-    return $text;
1082
+	return $text;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1088,15 +1088,15 @@  discard block
 block discarded – undo
1088 1088
  */
1089 1089
 function smart_sanitizeCustomtags_callback($matches)
1090 1090
 {
1091
-    global $smartobjectCustomtagHandler;
1092
-    if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1093
-        $customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1094
-        $ret       = $customObj->renderWithPhp();
1095
-
1096
-        return $ret;
1097
-    } else {
1098
-        return '';
1099
-    }
1091
+	global $smartobjectCustomtagHandler;
1092
+	if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1093
+		$customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1094
+		$ret       = $customObj->renderWithPhp();
1095
+
1096
+		return $ret;
1097
+	} else {
1098
+		return '';
1099
+	}
1100 1100
 }
1101 1101
 
1102 1102
 /**
@@ -1105,13 +1105,13 @@  discard block
 block discarded – undo
1105 1105
  */
1106 1106
 function smart_sanitizeCustomtags($text)
1107 1107
 {
1108
-    $patterns     = array();
1109
-    $replacements = array();
1108
+	$patterns     = array();
1109
+	$replacements = array();
1110 1110
 
1111
-    $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1112
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1111
+	$patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1112
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1113 1113
 
1114
-    return $text;
1114
+	return $text;
1115 1115
 }
1116 1116
 
1117 1117
 /**
@@ -1120,20 +1120,20 @@  discard block
 block discarded – undo
1120 1120
  */
1121 1121
 function smart_loadLanguageFile($module, $file)
1122 1122
 {
1123
-    global $xoopsConfig;
1124
-
1125
-    $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1126
-    if (!file_exists($filename)) {
1127
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1128
-    }
1129
-    if (file_exists($filename)) {
1130
-        include_once($filename);
1131
-    }
1123
+	global $xoopsConfig;
1124
+
1125
+	$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1126
+	if (!file_exists($filename)) {
1127
+		$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1128
+	}
1129
+	if (file_exists($filename)) {
1130
+		include_once($filename);
1131
+	}
1132 1132
 }
1133 1133
 
1134 1134
 function smart_loadCommonLanguageFile()
1135 1135
 {
1136
-    smart_loadLanguageFile('smartobject', 'common');
1136
+	smart_loadLanguageFile('smartobject', 'common');
1137 1137
 }
1138 1138
 
1139 1139
 /**
@@ -1143,35 +1143,35 @@  discard block
 block discarded – undo
1143 1143
  */
1144 1144
 function smart_purifyText($text, $keyword = false)
1145 1145
 {
1146
-    global $myts;
1147
-    $text = str_replace('&nbsp;', ' ', $text);
1148
-    $text = str_replace('<br>', ' ', $text);
1149
-    $text = str_replace('<br>', ' ', $text);
1150
-    $text = str_replace('<br', ' ', $text);
1151
-    $text = strip_tags($text);
1152
-    $text = html_entity_decode($text);
1153
-    $text = $myts->undoHtmlSpecialChars($text);
1154
-    $text = str_replace(')', ' ', $text);
1155
-    $text = str_replace('(', ' ', $text);
1156
-    $text = str_replace(':', ' ', $text);
1157
-    $text = str_replace('&euro', ' euro ', $text);
1158
-    $text = str_replace('&hellip', '...', $text);
1159
-    $text = str_replace('&rsquo', ' ', $text);
1160
-    $text = str_replace('!', ' ', $text);
1161
-    $text = str_replace('?', ' ', $text);
1162
-    $text = str_replace('"', ' ', $text);
1163
-    $text = str_replace('-', ' ', $text);
1164
-    $text = str_replace('\n', ' ', $text);
1165
-    $text = str_replace('&#8213;', ' ', $text);
1166
-
1167
-    if ($keyword) {
1168
-        $text = str_replace('.', ' ', $text);
1169
-        $text = str_replace(',', ' ', $text);
1170
-        $text = str_replace('\'', ' ', $text);
1171
-    }
1172
-    $text = str_replace(';', ' ', $text);
1173
-
1174
-    return $text;
1146
+	global $myts;
1147
+	$text = str_replace('&nbsp;', ' ', $text);
1148
+	$text = str_replace('<br>', ' ', $text);
1149
+	$text = str_replace('<br>', ' ', $text);
1150
+	$text = str_replace('<br', ' ', $text);
1151
+	$text = strip_tags($text);
1152
+	$text = html_entity_decode($text);
1153
+	$text = $myts->undoHtmlSpecialChars($text);
1154
+	$text = str_replace(')', ' ', $text);
1155
+	$text = str_replace('(', ' ', $text);
1156
+	$text = str_replace(':', ' ', $text);
1157
+	$text = str_replace('&euro', ' euro ', $text);
1158
+	$text = str_replace('&hellip', '...', $text);
1159
+	$text = str_replace('&rsquo', ' ', $text);
1160
+	$text = str_replace('!', ' ', $text);
1161
+	$text = str_replace('?', ' ', $text);
1162
+	$text = str_replace('"', ' ', $text);
1163
+	$text = str_replace('-', ' ', $text);
1164
+	$text = str_replace('\n', ' ', $text);
1165
+	$text = str_replace('&#8213;', ' ', $text);
1166
+
1167
+	if ($keyword) {
1168
+		$text = str_replace('.', ' ', $text);
1169
+		$text = str_replace(',', ' ', $text);
1170
+		$text = str_replace('\'', ' ', $text);
1171
+	}
1172
+	$text = str_replace(';', ' ', $text);
1173
+
1174
+	return $text;
1175 1175
 }
1176 1176
 
1177 1177
 /**
@@ -1180,49 +1180,49 @@  discard block
 block discarded – undo
1180 1180
  */
1181 1181
 function smart_html2text($document)
1182 1182
 {
1183
-    // PHP Manual:: function preg_replace
1184
-    // $document should contain an HTML document.
1185
-    // This will remove HTML tags, javascript sections
1186
-    // and white space. It will also convert some
1187
-    // common HTML entities to their text equivalent.
1188
-    // Credits: newbb2
1189
-    $search = array(
1190
-        "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1191
-        "'<img.*?/>'si",       // Strip out img tags
1192
-        "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1193
-        "'([\r\n])[\s]+'",                // Strip out white space
1194
-        "'&(quot|#34);'i",                // Replace HTML entities
1195
-        "'&(amp|#38);'i",
1196
-        "'&(lt|#60);'i",
1197
-        "'&(gt|#62);'i",
1198
-        "'&(nbsp|#160);'i",
1199
-        "'&(iexcl|#161);'i",
1200
-        "'&(cent|#162);'i",
1201
-        "'&(pound|#163);'i",
1202
-        "'&(copy|#169);'i",
1203
-        "'&#(\d+);'e"
1204
-    );                    // evaluate as php
1205
-
1206
-    $replace = array(
1207
-        '',
1208
-        '',
1209
-        '',
1210
-        "\\1",
1211
-        "\"",
1212
-        '&',
1213
-        '<',
1214
-        '>',
1215
-        ' ',
1216
-        chr(161),
1217
-        chr(162),
1218
-        chr(163),
1219
-        chr(169),
1220
-        "chr(\\1)"
1221
-    );
1222
-
1223
-    $text = preg_replace($search, $replace, $document);
1224
-
1225
-    return $text;
1183
+	// PHP Manual:: function preg_replace
1184
+	// $document should contain an HTML document.
1185
+	// This will remove HTML tags, javascript sections
1186
+	// and white space. It will also convert some
1187
+	// common HTML entities to their text equivalent.
1188
+	// Credits: newbb2
1189
+	$search = array(
1190
+		"'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1191
+		"'<img.*?/>'si",       // Strip out img tags
1192
+		"'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1193
+		"'([\r\n])[\s]+'",                // Strip out white space
1194
+		"'&(quot|#34);'i",                // Replace HTML entities
1195
+		"'&(amp|#38);'i",
1196
+		"'&(lt|#60);'i",
1197
+		"'&(gt|#62);'i",
1198
+		"'&(nbsp|#160);'i",
1199
+		"'&(iexcl|#161);'i",
1200
+		"'&(cent|#162);'i",
1201
+		"'&(pound|#163);'i",
1202
+		"'&(copy|#169);'i",
1203
+		"'&#(\d+);'e"
1204
+	);                    // evaluate as php
1205
+
1206
+	$replace = array(
1207
+		'',
1208
+		'',
1209
+		'',
1210
+		"\\1",
1211
+		"\"",
1212
+		'&',
1213
+		'<',
1214
+		'>',
1215
+		' ',
1216
+		chr(161),
1217
+		chr(162),
1218
+		chr(163),
1219
+		chr(169),
1220
+		"chr(\\1)"
1221
+	);
1222
+
1223
+	$text = preg_replace($search, $replace, $document);
1224
+
1225
+	return $text;
1226 1226
 }
1227 1227
 
1228 1228
 /**
@@ -1236,32 +1236,32 @@  discard block
 block discarded – undo
1236 1236
  */
1237 1237
 function smart_getfloat($str, $set = false)
1238 1238
 {
1239
-    if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1240
-        // Found number in $str, so set $str that number
1241
-        $str = $match[0];
1242
-        if (false !== strpos($str, ',')) {
1243
-            // A comma exists, that makes it easy, cos we assume it separates the decimal part.
1244
-            $str = str_replace('.', '', $str);    // Erase thousand seps
1245
-            $str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1246
-
1247
-            return (float)$str;
1248
-        } else {
1249
-            // No comma exists, so we have to decide, how a single dot shall be treated
1250
-            if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1251
-                // Treat single dot as decimal separator
1252
-                return (float)$str;
1253
-            } else {
1254
-                //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> ";
1255
-                // Else, treat all dots as thousand seps
1256
-                $str = str_replace('.', '', $str);    // Erase thousand seps
1257
-
1258
-                return (float)$str;
1259
-            }
1260
-        }
1261
-    } else {
1262
-        // No number found, return zero
1263
-        return 0;
1264
-    }
1239
+	if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1240
+		// Found number in $str, so set $str that number
1241
+		$str = $match[0];
1242
+		if (false !== strpos($str, ',')) {
1243
+			// A comma exists, that makes it easy, cos we assume it separates the decimal part.
1244
+			$str = str_replace('.', '', $str);    // Erase thousand seps
1245
+			$str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1246
+
1247
+			return (float)$str;
1248
+		} else {
1249
+			// No comma exists, so we have to decide, how a single dot shall be treated
1250
+			if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1251
+				// Treat single dot as decimal separator
1252
+				return (float)$str;
1253
+			} else {
1254
+				//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> ";
1255
+				// Else, treat all dots as thousand seps
1256
+				$str = str_replace('.', '', $str);    // Erase thousand seps
1257
+
1258
+				return (float)$str;
1259
+			}
1260
+		}
1261
+	} else {
1262
+		// No number found, return zero
1263
+		return 0;
1264
+	}
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1271,26 +1271,26 @@  discard block
 block discarded – undo
1271 1271
  */
1272 1272
 function smart_currency($var, $currencyObj = false)
1273 1273
 {
1274
-    $ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1275
-    $ret = round($ret, 2);
1276
-    // make sur we have at least .00 in the $var
1277
-    $decimal_section_original = strstr($ret, '.');
1278
-    $decimal_section          = $decimal_section_original;
1279
-    if ($decimal_section) {
1280
-        if (strlen($decimal_section) == 1) {
1281
-            $decimal_section = '.00';
1282
-        } elseif (strlen($decimal_section) == 2) {
1283
-            $decimal_section .= '0';
1284
-        }
1285
-        $ret = str_replace($decimal_section_original, $decimal_section, $ret);
1286
-    } else {
1287
-        $ret .= '.00';
1288
-    }
1289
-    if ($currencyObj) {
1290
-        $ret = $ret . ' ' . $currencyObj->getCode();
1291
-    }
1292
-
1293
-    return $ret;
1274
+	$ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1275
+	$ret = round($ret, 2);
1276
+	// make sur we have at least .00 in the $var
1277
+	$decimal_section_original = strstr($ret, '.');
1278
+	$decimal_section          = $decimal_section_original;
1279
+	if ($decimal_section) {
1280
+		if (strlen($decimal_section) == 1) {
1281
+			$decimal_section = '.00';
1282
+		} elseif (strlen($decimal_section) == 2) {
1283
+			$decimal_section .= '0';
1284
+		}
1285
+		$ret = str_replace($decimal_section_original, $decimal_section, $ret);
1286
+	} else {
1287
+		$ret .= '.00';
1288
+	}
1289
+	if ($currencyObj) {
1290
+		$ret = $ret . ' ' . $currencyObj->getCode();
1291
+	}
1292
+
1293
+	return $ret;
1294 1294
 }
1295 1295
 
1296 1296
 /**
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
  */
1300 1300
 function smart_float($var)
1301 1301
 {
1302
-    return smart_currency($var);
1302
+	return smart_currency($var);
1303 1303
 }
1304 1304
 
1305 1305
 /**
@@ -1308,16 +1308,16 @@  discard block
 block discarded – undo
1308 1308
  */
1309 1309
 function smart_getModuleAdminLink($moduleName = false)
1310 1310
 {
1311
-    global $xoopsModule;
1312
-    if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1313
-        $moduleName = $xoopsModule->getVar('dirname');
1314
-    }
1315
-    $ret = '';
1316
-    if ($moduleName) {
1317
-        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1318
-    }
1319
-
1320
-    return $ret;
1311
+	global $xoopsModule;
1312
+	if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1313
+		$moduleName = $xoopsModule->getVar('dirname');
1314
+	}
1315
+	$ret = '';
1316
+	if ($moduleName) {
1317
+		$ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1318
+	}
1319
+
1320
+	return $ret;
1321 1321
 }
1322 1322
 
1323 1323
 /**
@@ -1325,19 +1325,19 @@  discard block
 block discarded – undo
1325 1325
  */
1326 1326
 function smart_getEditors()
1327 1327
 {
1328
-    $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1329
-    if (!file_exists($filename)) {
1330
-        return false;
1331
-    }
1332
-    include_once $filename;
1333
-    $xoopseditorHandler = XoopsEditorHandler::getInstance();
1334
-    $aList              = $xoopseditorHandler->getList();
1335
-    $ret                = array();
1336
-    foreach ($aList as $k => $v) {
1337
-        $ret[$v] = $k;
1338
-    }
1339
-
1340
-    return $ret;
1328
+	$filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1329
+	if (!file_exists($filename)) {
1330
+		return false;
1331
+	}
1332
+	include_once $filename;
1333
+	$xoopseditorHandler = XoopsEditorHandler::getInstance();
1334
+	$aList              = $xoopseditorHandler->getList();
1335
+	$ret                = array();
1336
+	foreach ($aList as $k => $v) {
1337
+		$ret[$v] = $k;
1338
+	}
1339
+
1340
+	return $ret;
1341 1341
 }
1342 1342
 
1343 1343
 /**
@@ -1347,11 +1347,11 @@  discard block
 block discarded – undo
1347 1347
  */
1348 1348
 function smart_getTablesArray($moduleName, $items)
1349 1349
 {
1350
-    $ret = array();
1351
-    foreach ($items as $item) {
1352
-        $ret[] = $moduleName . '_' . $item;
1353
-    }
1354
-    $ret[] = $moduleName . '_meta';
1350
+	$ret = array();
1351
+	foreach ($items as $item) {
1352
+		$ret[] = $moduleName . '_' . $item;
1353
+	}
1354
+	$ret[] = $moduleName . '_meta';
1355 1355
 
1356
-    return $ret;
1356
+	return $ret;
1357 1357
 }
Please login to merge, or discard this patch.
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 function smart_get_css_link($cssfile)
13 13
 {
14
-    $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />';
14
+    $ret = '<link rel="stylesheet" type="text/css" href="'.$cssfile.'" />';
15 15
 
16 16
     return $ret;
17 17
 }
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
         $seoMode = smart_getModuleModeSEO($moduleName);
101 101
         if ($seoMode === 'rewrite') {
102 102
             $seoModuleName = smart_getModuleNameForSEO($moduleName);
103
-            $ret           = XOOPS_URL . '/' . $seoModuleName . '/';
103
+            $ret           = XOOPS_URL.'/'.$seoModuleName.'/';
104 104
         } elseif ($seoMode === 'pathinfo') {
105
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/';
105
+            $ret = XOOPS_URL.'/modules/'.$moduleName.'/seo.php/'.$seoModuleName.'/';
106 106
         } else {
107
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/';
107
+            $ret = XOOPS_URL.'/modules/'.$moduleName.'/';
108 108
         }
109 109
 
110
-        return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>';
110
+        return '<a href="'.$ret.'">'.$smartModule->getVar('name').'</a>';
111 111
     }
112 112
 }
113 113
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
     /**
171 171
      * include SmartObject admin language file
172 172
      */
173
-    $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
173
+    $fileName = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php';
174 174
     if (file_exists($fileName)) {
175 175
         include_once $fileName;
176 176
     } else {
177
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
177
+        include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php';
178 178
     }
179 179
     ?>
180 180
     <script type='text/javascript'>
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
     /**
193 193
      * Include the admin language constants for the SmartObject Framework
194 194
      */
195
-    $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php';
195
+    $admin_file = SMARTOBJECT_ROOT_PATH.'language/'.$xoopsConfig['language'].'/admin.php';
196 196
     if (!file_exists($admin_file)) {
197
-        $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php';
197
+        $admin_file = SMARTOBJECT_ROOT_PATH.'language/english/admin.php';
198 198
     }
199 199
     include_once($admin_file);
200 200
 }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     //Verifies that a MySQL table exists
215 215
     $xoopsDB  = XoopsDatabaseFactory::getDatabaseConnection();
216 216
     $realname = $xoopsDB->prefix($table);
217
-    $sql      = 'SHOW TABLES FROM ' . XOOPS_DB_NAME;
217
+    $sql      = 'SHOW TABLES FROM '.XOOPS_DB_NAME;
218 218
     $ret      = $xoopsDB->queryF($sql);
219 219
     while (list($m_table) = $xoopsDB->fetchRow($ret)) {
220 220
         if ($m_table == $realname) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         $moduleName = smart_getCurrentModuleName();
244 244
     }
245 245
     $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
246
-    $sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key));
246
+    $sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key));
247 247
     $ret     = $xoopsDB->query($sql);
248 248
     if (!$ret) {
249 249
         $value = false;
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
     $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
287 287
     $ret     = smart_GetMeta($key, $moduleName);
288 288
     if ($ret === '0' || $ret > 0) {
289
-        $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
289
+        $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
290 290
     } else {
291
-        $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
291
+        $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
292 292
     }
293 293
     $ret = $xoopsDB->queryF($sql);
294 294
     if (!$ret) {
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 {
469 469
     static $smartModules;
470 470
     if (isset($smartModules[$moduleName])) {
471
-        $ret =& $smartModules[$moduleName];
471
+        $ret = & $smartModules[$moduleName];
472 472
 
473 473
         return $ret;
474 474
     }
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 {
505 505
     static $smartConfigs;
506 506
     if (isset($smartConfigs[$moduleName])) {
507
-        $ret =& $smartConfigs[$moduleName];
507
+        $ret = & $smartConfigs[$moduleName];
508 508
 
509 509
         return $ret;
510 510
     }
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             return $ret;
533 533
         }
534 534
         $hModConfig                = xoops_getHandler('config');
535
-        $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
535
+        $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
536 536
     }
537 537
 
538 538
     return $smartConfigs[$moduleName];
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 {
559 559
     $ret = '';
560 560
     foreach ($errors as $key => $value) {
561
-        $ret .= '<br> - ' . $value;
561
+        $ret .= '<br> - '.$value;
562 562
     }
563 563
 
564 564
     return $ret;
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
     if (!is_numeric($userid)) {
579 579
         return $userid;
580 580
     }
581
-    $userid = (int)$userid;
581
+    $userid = (int) $userid;
582 582
     if ($userid > 0) {
583 583
         if ($users == array()) {
584 584
             //fetching users
585 585
             $memberHandler = xoops_getHandler('member');
586
-            $user          =& $memberHandler->getUser($userid);
586
+            $user          = & $memberHandler->getUser($userid);
587 587
         } else {
588 588
             if (!isset($users[$userid])) {
589 589
                 return $GLOBALS['xoopsConfig']['anonymous'];
590 590
             }
591
-            $user =& $users[$userid];
591
+            $user = & $users[$userid];
592 592
         }
593 593
         if (is_object($user)) {
594 594
             $ts        = MyTextSanitizer:: getInstance();
@@ -599,32 +599,32 @@  discard block
 block discarded – undo
599 599
                 $fullname = $user->getVar('name');
600 600
             }
601 601
             if (!empty($fullname)) {
602
-                $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
602
+                $linkeduser = "$fullname [<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".$ts->htmlSpecialChars($username).'</a>]';
603 603
             } else {
604
-                $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
604
+                $linkeduser = "<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".ucwords($ts->htmlSpecialChars($username)).'</a>';
605 605
             }
606 606
             // add contact info: email + PM
607 607
             if ($withContact) {
608
-                $linkeduser .= ' <a href="mailto:' .
609
-                               $user->getVar('email') .
610
-                               '"><img style="vertical-align: middle;" src="' .
611
-                               XOOPS_URL .
612
-                               '/images/icons/email.gif' .
613
-                               '" alt="' .
614
-                               _CO_SOBJECT_SEND_EMAIL .
615
-                               '" title="' .
616
-                               _CO_SOBJECT_SEND_EMAIL .
608
+                $linkeduser .= ' <a href="mailto:'.
609
+                               $user->getVar('email').
610
+                               '"><img style="vertical-align: middle;" src="'.
611
+                               XOOPS_URL.
612
+                               '/images/icons/email.gif'.
613
+                               '" alt="'.
614
+                               _CO_SOBJECT_SEND_EMAIL.
615
+                               '" title="'.
616
+                               _CO_SOBJECT_SEND_EMAIL.
617 617
                                '"/></a>';
618
-                $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
619
-                $linkeduser .= ' <a href="' .
620
-                               $js .
621
-                               '"><img style="vertical-align: middle;" src="' .
622
-                               XOOPS_URL .
623
-                               '/images/icons/pm.gif' .
624
-                               '" alt="' .
625
-                               _CO_SOBJECT_SEND_PM .
626
-                               '" title="' .
627
-                               _CO_SOBJECT_SEND_PM .
618
+                $js = "javascript:openWithSelfMain('".XOOPS_URL.'/pmlite.php?send2=1&to_userid='.$userid."', 'pmlite',450,370);";
619
+                $linkeduser .= ' <a href="'.
620
+                               $js.
621
+                               '"><img style="vertical-align: middle;" src="'.
622
+                               XOOPS_URL.
623
+                               '/images/icons/pm.gif'.
624
+                               '" alt="'.
625
+                               _CO_SOBJECT_SEND_PM.
626
+                               '" title="'.
627
+                               _CO_SOBJECT_SEND_PM.
628 628
                                '"/></a>';
629 629
             }
630 630
 
@@ -644,20 +644,20 @@  discard block
 block discarded – undo
644 644
 function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1)
645 645
 {
646 646
     global $xoopsModule, $xoopsConfig;
647
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
648
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
649
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
647
+    include_once XOOPS_ROOT_PATH.'/class/template.php';
648
+    if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) {
649
+        include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php';
650 650
     } else {
651
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
651
+        include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/modinfo.php';
652 652
     }
653
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
654
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
653
+    if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php')) {
654
+        include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php';
655 655
     } else {
656
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
656
+        include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php';
657 657
     }
658 658
     $headermenu = array();
659 659
     $adminmenu  = array();
660
-    include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
660
+    include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/admin/menu.php';
661 661
     $tpl = new XoopsTpl();
662 662
     $tpl->assign(array(
663 663
                      'headermenu'      => $headermenu,
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
 function smart_collapsableBar($id = '', $title = '', $dsc = '')
681 681
 {
682 682
     global $xoopsModule;
683
-    echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>";
684
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
685
-    echo "<div id='" . $id . "'>";
683
+    echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('".$id."'); toggleIcon('".$id."_icon')\";>";
684
+    echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt='' /></a>&nbsp;".$title.'</h3>';
685
+    echo "<div id='".$id."'>";
686 686
     if ($dsc !== '') {
687
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
687
+        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>';
688 688
     }
689 689
 }
690 690
 
@@ -698,11 +698,11 @@  discard block
 block discarded – undo
698 698
     global $xoopsModule;
699 699
     $onClick = "ajaxtogglecollapse('$id')";
700 700
     //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
701
-    echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
702
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
703
-    echo "<div id='" . $id . "'>";
701
+    echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="'.$onClick.'">';
702
+    echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt='' /></a>&nbsp;".$title.'</h3>';
703
+    echo "<div id='".$id."'>";
704 704
     if ($dsc !== '') {
705
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
705
+        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>';
706 706
     }
707 707
 }
708 708
 
@@ -732,13 +732,13 @@  discard block
 block discarded – undo
732 732
 {
733 733
     $urls        = smart_getCurrentUrls();
734 734
     $path        = $urls['phpself'];
735
-    $cookie_name = $path . '_smart_collaps_' . $name;
735
+    $cookie_name = $path.'_smart_collaps_'.$name;
736 736
     $cookie_name = str_replace('.', '_', $cookie_name);
737 737
     $cookie      = smart_getCookieVar($cookie_name, '');
738 738
     if ($cookie === 'none') {
739 739
         echo '
740 740
                 <script type="text/javascript"><!--
741
-                togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon");
741
+                togglecollapse("' . $name.'"); toggleIcon("'.$name.'_icon");
742 742
                     //-->
743 743
                 </script>
744 744
                 ';
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
     $httphost    = $_SERVER['HTTP_HOST'];
805 805
     $querystring = $_SERVER['QUERY_STRING'];
806 806
     if ($querystring !== '') {
807
-        $querystring = '?' . $querystring;
807
+        $querystring = '?'.$querystring;
808 808
     }
809
-    $currenturl           = $http . $httphost . $phpself . $querystring;
809
+    $currenturl           = $http.$httphost.$phpself.$querystring;
810 810
     $urls                 = array();
811 811
     $urls['http']         = $http;
812 812
     $urls['httphost']     = $httphost;
813 813
     $urls['phpself']      = $phpself;
814 814
     $urls['querystring']  = $querystring;
815
-    $urls['full_phpself'] = $http . $httphost . $phpself;
815
+    $urls['full_phpself'] = $http.$httphost.$phpself;
816 816
     $urls['full']         = $currenturl;
817
-    $urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
817
+    $urls['isHomePage']   = (XOOPS_URL.'/index.php') == ($http.$httphost.$phpself);
818 818
 
819 819
     return $urls;
820 820
 }
@@ -891,22 +891,22 @@  discard block
 block discarded – undo
891 891
 {
892 892
     global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
893 893
 
894
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
894
+    include_once XOOPS_ROOT_PATH.'/class/template.php';
895 895
     $tpl = new XoopsTpl();
896 896
 
897 897
     $hModule      = xoops_getHandler('module');
898
-    $versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
899
-    $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
900
-    $modfooter    = "<a href='" .
901
-                    $versioninfo->getInfo('support_site_url') .
902
-                    "' target='_blank'><img src='" .
903
-                    XOOPS_URL .
904
-                    '/modules/' .
905
-                    $xoopsModule->getVar('dirname') .
906
-                    "/assets/images/cssbutton.gif' title='" .
907
-                    $modfootertxt .
908
-                    "' alt='" .
909
-                    $modfootertxt .
898
+    $versioninfo  = & $hModule->get($xoopsModule->getVar('mid'));
899
+    $modfootertxt = 'Module '.$versioninfo->getInfo('name').' - Version '.$versioninfo->getInfo('version').'';
900
+    $modfooter    = "<a href='".
901
+                    $versioninfo->getInfo('support_site_url').
902
+                    "' target='_blank'><img src='".
903
+                    XOOPS_URL.
904
+                    '/modules/'.
905
+                    $xoopsModule->getVar('dirname').
906
+                    "/assets/images/cssbutton.gif' title='".
907
+                    $modfootertxt.
908
+                    "' alt='".
909
+                    $modfootertxt.
910 910
                     "'/></a>";
911 911
     $tpl->assign('modfooter', $modfooter);
912 912
 
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
     }
916 916
     $smartobjectConfig = smart_getModuleConfig('smartobject');
917 917
     $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
918
-    $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
918
+    $tpl->display(SMARTOBJECT_ROOT_PATH.'templates/smartobject_admin_footer.html');
919 919
 }
920 920
 
921 921
 function smart_xoops_cp_footer()
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
  */
943 943
 function smart_addScript($src)
944 944
 {
945
-    echo '<script src="' . $src . '" type="text/javascript"></script>';
945
+    echo '<script src="'.$src.'" type="text/javascript"></script>';
946 946
 }
947 947
 
948 948
 /**
@@ -951,16 +951,16 @@  discard block
 block discarded – undo
951 951
 function smart_addStyle($src)
952 952
 {
953 953
     if ($src === 'smartobject') {
954
-        $src = SMARTOBJECT_URL . 'assets/css/module.css';
954
+        $src = SMARTOBJECT_URL.'assets/css/module.css';
955 955
     }
956 956
     echo smart_get_css_link($src);
957 957
 }
958 958
 
959 959
 function smart_addAdminAjaxSupport()
960 960
 {
961
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
962
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
963
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
961
+    smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/lib/prototype.js');
962
+    smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/scriptaculous.js');
963
+    smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/smart.js');
964 964
 }
965 965
 
966 966
 /**
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 function smart_htmlnumericentities($str)
1021 1021
 {
1022 1022
     //    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
1023
-    return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
1023
+    return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function($m) { return '&#'.ord($m[0]).chr(59); }, $str);
1024 1024
 }
1025 1025
 
1026 1026
 /**
@@ -1033,16 +1033,16 @@  discard block
 block discarded – undo
1033 1033
     static $handlers;
1034 1034
     $name = strtolower(trim($name));
1035 1035
     if (!isset($handlers[$name])) {
1036
-        if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
1036
+        if (file_exists($hnd_file = XOOPS_ROOT_PATH.'/kernel/'.$name.'.php')) {
1037 1037
             require_once $hnd_file;
1038 1038
         }
1039
-        $class = 'Xoops' . ucfirst($name) . 'Handler';
1039
+        $class = 'Xoops'.ucfirst($name).'Handler';
1040 1040
         if (class_exists($class)) {
1041
-            $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
1041
+            $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops');
1042 1042
         }
1043 1043
     }
1044 1044
     if (!isset($handlers[$name]) && !$optional) {
1045
-        trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
1045
+        trigger_error('Class <b>'.$class.'</b> does not exist<br>Handler Name: '.$name, E_USER_ERROR);
1046 1046
     }
1047 1047
     if (isset($handlers[$name])) {
1048 1048
         return $handlers[$name];
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
 {
1123 1123
     global $xoopsConfig;
1124 1124
 
1125
-    $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1125
+    $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/'.$xoopsConfig['language'].'/'.$file.'.php';
1126 1126
     if (!file_exists($filename)) {
1127
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1127
+        $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/english/'.$file.'.php';
1128 1128
     }
1129 1129
     if (file_exists($filename)) {
1130 1130
         include_once($filename);
@@ -1187,11 +1187,11 @@  discard block
 block discarded – undo
1187 1187
     // common HTML entities to their text equivalent.
1188 1188
     // Credits: newbb2
1189 1189
     $search = array(
1190
-        "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1191
-        "'<img.*?/>'si",       // Strip out img tags
1192
-        "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1193
-        "'([\r\n])[\s]+'",                // Strip out white space
1194
-        "'&(quot|#34);'i",                // Replace HTML entities
1190
+        "'<script[^>]*?>.*?</script>'si", // Strip out javascript
1191
+        "'<img.*?/>'si", // Strip out img tags
1192
+        "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
1193
+        "'([\r\n])[\s]+'", // Strip out white space
1194
+        "'&(quot|#34);'i", // Replace HTML entities
1195 1195
         "'&(amp|#38);'i",
1196 1196
         "'&(lt|#60);'i",
1197 1197
         "'&(gt|#62);'i",
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
         "'&(pound|#163);'i",
1202 1202
         "'&(copy|#169);'i",
1203 1203
         "'&#(\d+);'e"
1204
-    );                    // evaluate as php
1204
+    ); // evaluate as php
1205 1205
 
1206 1206
     $replace = array(
1207 1207
         '',
@@ -1241,21 +1241,21 @@  discard block
 block discarded – undo
1241 1241
         $str = $match[0];
1242 1242
         if (false !== strpos($str, ',')) {
1243 1243
             // A comma exists, that makes it easy, cos we assume it separates the decimal part.
1244
-            $str = str_replace('.', '', $str);    // Erase thousand seps
1245
-            $str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1244
+            $str = str_replace('.', '', $str); // Erase thousand seps
1245
+            $str = str_replace(',', '.', $str); // Convert , to . for floatval command
1246 1246
 
1247
-            return (float)$str;
1247
+            return (float) $str;
1248 1248
         } else {
1249 1249
             // No comma exists, so we have to decide, how a single dot shall be treated
1250 1250
             if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1251 1251
                 // Treat single dot as decimal separator
1252
-                return (float)$str;
1252
+                return (float) $str;
1253 1253
             } else {
1254 1254
                 //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> ";
1255 1255
                 // Else, treat all dots as thousand seps
1256
-                $str = str_replace('.', '', $str);    // Erase thousand seps
1256
+                $str = str_replace('.', '', $str); // Erase thousand seps
1257 1257
 
1258
-                return (float)$str;
1258
+                return (float) $str;
1259 1259
             }
1260 1260
         }
1261 1261
     } else {
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
         $ret .= '.00';
1288 1288
     }
1289 1289
     if ($currencyObj) {
1290
-        $ret = $ret . ' ' . $currencyObj->getCode();
1290
+        $ret = $ret.' '.$currencyObj->getCode();
1291 1291
     }
1292 1292
 
1293 1293
     return $ret;
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
     }
1315 1315
     $ret = '';
1316 1316
     if ($moduleName) {
1317
-        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1317
+        $ret = "<a href='".XOOPS_URL."/modules/$moduleName/admin/index.php'>"._CO_SOBJECT_ADMIN_PAGE.'</a>';
1318 1318
     }
1319 1319
 
1320 1320
     return $ret;
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
  */
1326 1326
 function smart_getEditors()
1327 1327
 {
1328
-    $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1328
+    $filename = XOOPS_ROOT_PATH.'/class/xoopseditor/xoopseditor.php';
1329 1329
     if (!file_exists($filename)) {
1330 1330
         return false;
1331 1331
     }
@@ -1349,9 +1349,9 @@  discard block
 block discarded – undo
1349 1349
 {
1350 1350
     $ret = array();
1351 1351
     foreach ($items as $item) {
1352
-        $ret[] = $moduleName . '_' . $item;
1352
+        $ret[] = $moduleName.'_'.$item;
1353 1353
     }
1354
-    $ret[] = $moduleName . '_meta';
1354
+    $ret[] = $moduleName.'_meta';
1355 1355
 
1356 1356
     return $ret;
1357 1357
 }
Please login to merge, or discard this patch.
header.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * Licence: GNU
7 7
  */
8 8
 
9
-include dirname(dirname(__DIR__)) . '/mainfile.php';
10
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
9
+include dirname(dirname(__DIR__)).'/mainfile.php';
10
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php';
11 11
 
12 12
 smart_loadCommonLanguageFile();
Please login to merge, or discard this patch.
class/smartmlobject.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -24,82 +24,82 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class SmartMlObject extends SmartObject
26 26
 {
27
-    /**
28
-     * SmartMlObject constructor.
29
-     */
30
-    public function __construct()
31
-    {
32
-        $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true);
33
-        $this->setControl('language', 'language');
34
-    }
35
-
36
-    /**
37
-     * If object is not new, change the control of the not-multilanguage fields
38
-     *
39
-     * We need to intercept this function from SmartObject because if the object is not new...
40
-     */
41
-    // function getForm() {
42
-
43
-    //}
44
-
45
-    /**
46
-     * Strip Multilanguage Fields
47
-     *
48
-     * Get rid of all the multilanguage fields to have an object with only global fields.
49
-     * This will be usefull when creating the ML object for the first time. Then we will be able
50
-     * to create translations.
51
-     */
52
-    public function stripMultilanguageFields()
53
-    {
54
-        $objectVars    =& $this->getVars();
55
-        $newObjectVars = array();
56
-        foreach ($objectVars as $key => $var) {
57
-            if (!$var['multilingual']) {
58
-                $newObjectVars[$key] = $var;
59
-            }
60
-        }
61
-        $this->vars = $newObjectVars;
62
-    }
63
-
64
-    public function stripNonMultilanguageFields()
65
-    {
66
-        $objectVars    =& $this->getVars();
67
-        $newObjectVars = array();
68
-        foreach ($objectVars as $key => $var) {
69
-            if ($var['multilingual'] || $key == $this->handler->keyName) {
70
-                $newObjectVars[$key] = $var;
71
-            }
72
-        }
73
-        $this->vars = $newObjectVars;
74
-    }
75
-
76
-    /**
77
-     * Make non multilanguage fields read only
78
-     *
79
-     * This is used when we are creating/editing a translation.
80
-     * We only want to edit the multilanguag fields, not the global one.
81
-     */
82
-    public function makeNonMLFieldReadOnly()
83
-    {
84
-        foreach ($this->getVars() as $key => $var) {
85
-            //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) {
86
-            if (!$var['multilingual'] && $key != $this->handler->keyName) {
87
-                $this->setControl($key, 'label');
88
-            }
89
-        }
90
-    }
91
-
92
-    /**
93
-     * @param  bool   $onlyUrl
94
-     * @param  bool   $withimage
95
-     * @return string
96
-     */
97
-    public function getEditLanguageLink($onlyUrl = false, $withimage = true)
98
-    {
99
-        $controller = new SmartObjectController($this->handler);
100
-
101
-        return $controller->getEditLanguageLink($this, $onlyUrl, $withimage);
102
-    }
27
+	/**
28
+	 * SmartMlObject constructor.
29
+	 */
30
+	public function __construct()
31
+	{
32
+		$this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true);
33
+		$this->setControl('language', 'language');
34
+	}
35
+
36
+	/**
37
+	 * If object is not new, change the control of the not-multilanguage fields
38
+	 *
39
+	 * We need to intercept this function from SmartObject because if the object is not new...
40
+	 */
41
+	// function getForm() {
42
+
43
+	//}
44
+
45
+	/**
46
+	 * Strip Multilanguage Fields
47
+	 *
48
+	 * Get rid of all the multilanguage fields to have an object with only global fields.
49
+	 * This will be usefull when creating the ML object for the first time. Then we will be able
50
+	 * to create translations.
51
+	 */
52
+	public function stripMultilanguageFields()
53
+	{
54
+		$objectVars    =& $this->getVars();
55
+		$newObjectVars = array();
56
+		foreach ($objectVars as $key => $var) {
57
+			if (!$var['multilingual']) {
58
+				$newObjectVars[$key] = $var;
59
+			}
60
+		}
61
+		$this->vars = $newObjectVars;
62
+	}
63
+
64
+	public function stripNonMultilanguageFields()
65
+	{
66
+		$objectVars    =& $this->getVars();
67
+		$newObjectVars = array();
68
+		foreach ($objectVars as $key => $var) {
69
+			if ($var['multilingual'] || $key == $this->handler->keyName) {
70
+				$newObjectVars[$key] = $var;
71
+			}
72
+		}
73
+		$this->vars = $newObjectVars;
74
+	}
75
+
76
+	/**
77
+	 * Make non multilanguage fields read only
78
+	 *
79
+	 * This is used when we are creating/editing a translation.
80
+	 * We only want to edit the multilanguag fields, not the global one.
81
+	 */
82
+	public function makeNonMLFieldReadOnly()
83
+	{
84
+		foreach ($this->getVars() as $key => $var) {
85
+			//if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) {
86
+			if (!$var['multilingual'] && $key != $this->handler->keyName) {
87
+				$this->setControl($key, 'label');
88
+			}
89
+		}
90
+	}
91
+
92
+	/**
93
+	 * @param  bool   $onlyUrl
94
+	 * @param  bool   $withimage
95
+	 * @return string
96
+	 */
97
+	public function getEditLanguageLink($onlyUrl = false, $withimage = true)
98
+	{
99
+		$controller = new SmartObjectController($this->handler);
100
+
101
+		return $controller->getEditLanguageLink($this, $onlyUrl, $withimage);
102
+	}
103 103
 }
104 104
 
105 105
 /**
@@ -107,70 +107,70 @@  discard block
 block discarded – undo
107 107
  */
108 108
 class SmartPersistableMlObjectHandler extends SmartPersistableObjectHandler
109 109
 {
110
-    /**
111
-     * @param  null  $criteria
112
-     * @param  bool  $id_as_key
113
-     * @param  bool  $as_object
114
-     * @param  bool  $debug
115
-     * @param  bool  $language
116
-     * @return array
117
-     */
118
-    public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false)
119
-    {
120
-        // Create the first part of the SQL query to join the "_text" table
121
-        $sql = 'SELECT * FROM ' .
122
-               $this->table .
123
-               ' AS ' .
124
-               $this->_itemname .
125
-               ' INNER JOIN ' .
126
-               $this->table .
127
-               '_text AS ' .
128
-               $this->_itemname .
129
-               '_text ON ' .
130
-               $this->_itemname .
131
-               '.' .
132
-               $this->keyName .
133
-               '=' .
134
-               $this->_itemname .
135
-               '_text.' .
136
-               $this->keyName;
137
-
138
-        if ($language) {
139
-            // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language
140
-
141
-            // if no criteria was previously created, let's create it
142
-            if (!$criteria) {
143
-                $criteria = new CriteriaCompo();
144
-            }
145
-            $criteria->add(new Criteria('language', $language));
146
-
147
-            return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
148
-        }
149
-
150
-        return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
151
-    }
152
-
153
-    /**
154
-     * @param  mixed $id
155
-     * @param  bool  $language
156
-     * @param  bool  $as_object
157
-     * @param  bool  $debug
158
-     * @return mixed
159
-     */
160
-    public function &get($id, $language = false, $as_object = true, $debug = false)
161
-    {
162
-        if (!$language) {
163
-            return parent::get($id, $as_object, $debug);
164
-        } else {
165
-            $criteria = new CriteriaCompo();
166
-            $criteria->add(new Criteria('language', $language));
167
-
168
-            return parent::get($id, $as_object, $debug, $criteria);
169
-        }
170
-    }
171
-
172
-    public function changeTableNameForML()
173
-    {
174
-        $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text');
175
-    }
110
+	/**
111
+	 * @param  null  $criteria
112
+	 * @param  bool  $id_as_key
113
+	 * @param  bool  $as_object
114
+	 * @param  bool  $debug
115
+	 * @param  bool  $language
116
+	 * @return array
117
+	 */
118
+	public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false)
119
+	{
120
+		// Create the first part of the SQL query to join the "_text" table
121
+		$sql = 'SELECT * FROM ' .
122
+			   $this->table .
123
+			   ' AS ' .
124
+			   $this->_itemname .
125
+			   ' INNER JOIN ' .
126
+			   $this->table .
127
+			   '_text AS ' .
128
+			   $this->_itemname .
129
+			   '_text ON ' .
130
+			   $this->_itemname .
131
+			   '.' .
132
+			   $this->keyName .
133
+			   '=' .
134
+			   $this->_itemname .
135
+			   '_text.' .
136
+			   $this->keyName;
137
+
138
+		if ($language) {
139
+			// If a language was specified, then let's create a WHERE clause to only return the objects associated with this language
140
+
141
+			// if no criteria was previously created, let's create it
142
+			if (!$criteria) {
143
+				$criteria = new CriteriaCompo();
144
+			}
145
+			$criteria->add(new Criteria('language', $language));
146
+
147
+			return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
148
+		}
149
+
150
+		return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql);
151
+	}
152
+
153
+	/**
154
+	 * @param  mixed $id
155
+	 * @param  bool  $language
156
+	 * @param  bool  $as_object
157
+	 * @param  bool  $debug
158
+	 * @return mixed
159
+	 */
160
+	public function &get($id, $language = false, $as_object = true, $debug = false)
161
+	{
162
+		if (!$language) {
163
+			return parent::get($id, $as_object, $debug);
164
+		} else {
165
+			$criteria = new CriteriaCompo();
166
+			$criteria->add(new Criteria('language', $language));
167
+
168
+			return parent::get($id, $as_object, $debug, $criteria);
169
+		}
170
+	}
171
+
172
+	public function changeTableNameForML()
173
+	{
174
+		$this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text');
175
+	}
176 176
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
14
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
14
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php';
15 15
 
16 16
 /**
17 17
  * SmartObject base Multilanguage-enabled class
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function stripMultilanguageFields()
53 53
     {
54
-        $objectVars    =& $this->getVars();
54
+        $objectVars    = & $this->getVars();
55 55
         $newObjectVars = array();
56 56
         foreach ($objectVars as $key => $var) {
57 57
             if (!$var['multilingual']) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
     public function stripNonMultilanguageFields()
65 65
     {
66
-        $objectVars    =& $this->getVars();
66
+        $objectVars    = & $this->getVars();
67 67
         $newObjectVars = array();
68 68
         foreach ($objectVars as $key => $var) {
69 69
             if ($var['multilingual'] || $key == $this->handler->keyName) {
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
     public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false)
119 119
     {
120 120
         // Create the first part of the SQL query to join the "_text" table
121
-        $sql = 'SELECT * FROM ' .
122
-               $this->table .
123
-               ' AS ' .
124
-               $this->_itemname .
125
-               ' INNER JOIN ' .
126
-               $this->table .
127
-               '_text AS ' .
128
-               $this->_itemname .
129
-               '_text ON ' .
130
-               $this->_itemname .
131
-               '.' .
132
-               $this->keyName .
133
-               '=' .
134
-               $this->_itemname .
135
-               '_text.' .
121
+        $sql = 'SELECT * FROM '.
122
+               $this->table.
123
+               ' AS '.
124
+               $this->_itemname.
125
+               ' INNER JOIN '.
126
+               $this->table.
127
+               '_text AS '.
128
+               $this->_itemname.
129
+               '_text ON '.
130
+               $this->_itemname.
131
+               '.'.
132
+               $this->keyName.
133
+               '='.
134
+               $this->_itemname.
135
+               '_text.'.
136 136
                $this->keyName;
137 137
 
138 138
         if ($language) {
@@ -171,6 +171,6 @@  discard block
 block discarded – undo
171 171
 
172 172
     public function changeTableNameForML()
173 173
     {
174
-        $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text');
174
+        $this->table = $this->db->prefix($this->_moduleName.'_'.$this->_itemname.'_text');
175 175
     }
176 176
 }
Please login to merge, or discard this patch.
class/file.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class SmartobjectFile extends SmartobjectBasedUrl
10 10
 {
11
-    /**
12
-     * SmartobjectFile constructor.
13
-     */
14
-    public function __construct()
15
-    {
16
-        parent::__construct();
17
-        $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME);
18
-    }
11
+	/**
12
+	 * SmartobjectFile constructor.
13
+	 */
14
+	public function __construct()
15
+	{
16
+		parent::__construct();
17
+		$this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME);
18
+	}
19 19
 }
20 20
 
21 21
 /**
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class SmartobjectFileHandler extends SmartPersistableObjectHandler
25 25
 {
26
-    /**
27
-     * SmartobjectFileHandler constructor.
28
-     * @param XoopsDatabase $db
29
-     */
30
-    public function __construct(XoopsDatabase $db)
31
-    {
32
-        parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject');
33
-    }
26
+	/**
27
+	 * SmartobjectFileHandler constructor.
28
+	 * @param XoopsDatabase $db
29
+	 */
30
+	public function __construct(XoopsDatabase $db)
31
+	{
32
+		parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject');
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
3 3
 
4
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/basedurl.php';
4
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/basedurl.php';
5 5
 
6 6
 /**
7 7
  * Class SmartobjectFile
Please login to merge, or discard this patch.
class/currency.php 2 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -37,115 +37,115 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class SmartobjectCurrency extends SmartObject
39 39
 {
40
-    public $_modulePlugin = false;
41
-
42
-    /**
43
-     * SmartobjectCurrency constructor.
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
-        $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
-        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
-        $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
-        $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
-        $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
-
54
-        $this->setControl('symbol', array(
55
-            'name'      => 'text',
56
-            'size'      => '15',
57
-            'maxlength' => '15'
58
-        ));
59
-
60
-        $this->setControl('iso4217', array(
61
-            'name'      => 'text',
62
-            'size'      => '5',
63
-            'maxlength' => '5'
64
-        ));
65
-
66
-        $this->setControl('rate', array(
67
-            'name'      => 'text',
68
-            'size'      => '5',
69
-            'maxlength' => '5'
70
-        ));
71
-
72
-        $this->setControl('rate', array(
73
-            'name'      => 'text',
74
-            'size'      => '5',
75
-            'maxlength' => '5'
76
-        ));
77
-
78
-        $this->hideFieldFromForm('default_currency');
79
-    }
80
-
81
-    /**
82
-     * @param  string $key
83
-     * @param  string $format
84
-     * @return mixed
85
-     */
86
-    public function getVar($key, $format = 's')
87
-    {
88
-        if ($format === 's' && in_array($key, array('rate', 'default_currency'))) {
89
-            //            return call_user_func(array($this, $key));
90
-            return $this->{$key}();
91
-        }
92
-
93
-        return parent::getVar($key, $format);
94
-    }
95
-
96
-    /**
97
-     * @return mixed
98
-     */
99
-    public function getCurrencyLink()
100
-    {
101
-        $ret = $this->getVar('name', 'e');
102
-
103
-        return $ret;
104
-    }
105
-
106
-    /**
107
-     * @return mixed
108
-     */
109
-    public function getCode()
110
-    {
111
-        $ret = $this->getVar('iso4217', 'e');
112
-
113
-        return $ret;
114
-    }
115
-
116
-    /**
117
-     * @return float|int|mixed|string
118
-     */
119
-    public function rate()
120
-    {
121
-        return smart_currency($this->getVar('rate', 'e'));
122
-    }
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function defaultCurrency()
128
-    {
129
-        if ($this->getVar('default_currency', 'e') === true) {
130
-            return _YES;
131
-        } else {
132
-            return _NO;
133
-        }
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getDefaultCurrencyControl()
140
-    {
141
-        $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
-        if ($this->getVar('default_currency', 'e')) {
143
-            $radio_box .= 'checked="checked"';
144
-        }
145
-        $radio_box .= '>';
146
-
147
-        return $radio_box;
148
-    }
40
+	public $_modulePlugin = false;
41
+
42
+	/**
43
+	 * SmartobjectCurrency constructor.
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
+		$this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
+		$this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
+		$this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
+		$this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
+		$this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
+
54
+		$this->setControl('symbol', array(
55
+			'name'      => 'text',
56
+			'size'      => '15',
57
+			'maxlength' => '15'
58
+		));
59
+
60
+		$this->setControl('iso4217', array(
61
+			'name'      => 'text',
62
+			'size'      => '5',
63
+			'maxlength' => '5'
64
+		));
65
+
66
+		$this->setControl('rate', array(
67
+			'name'      => 'text',
68
+			'size'      => '5',
69
+			'maxlength' => '5'
70
+		));
71
+
72
+		$this->setControl('rate', array(
73
+			'name'      => 'text',
74
+			'size'      => '5',
75
+			'maxlength' => '5'
76
+		));
77
+
78
+		$this->hideFieldFromForm('default_currency');
79
+	}
80
+
81
+	/**
82
+	 * @param  string $key
83
+	 * @param  string $format
84
+	 * @return mixed
85
+	 */
86
+	public function getVar($key, $format = 's')
87
+	{
88
+		if ($format === 's' && in_array($key, array('rate', 'default_currency'))) {
89
+			//            return call_user_func(array($this, $key));
90
+			return $this->{$key}();
91
+		}
92
+
93
+		return parent::getVar($key, $format);
94
+	}
95
+
96
+	/**
97
+	 * @return mixed
98
+	 */
99
+	public function getCurrencyLink()
100
+	{
101
+		$ret = $this->getVar('name', 'e');
102
+
103
+		return $ret;
104
+	}
105
+
106
+	/**
107
+	 * @return mixed
108
+	 */
109
+	public function getCode()
110
+	{
111
+		$ret = $this->getVar('iso4217', 'e');
112
+
113
+		return $ret;
114
+	}
115
+
116
+	/**
117
+	 * @return float|int|mixed|string
118
+	 */
119
+	public function rate()
120
+	{
121
+		return smart_currency($this->getVar('rate', 'e'));
122
+	}
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function defaultCurrency()
128
+	{
129
+		if ($this->getVar('default_currency', 'e') === true) {
130
+			return _YES;
131
+		} else {
132
+			return _NO;
133
+		}
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getDefaultCurrencyControl()
140
+	{
141
+		$radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
+		if ($this->getVar('default_currency', 'e')) {
143
+			$radio_box .= 'checked="checked"';
144
+		}
145
+		$radio_box .= '>';
146
+
147
+		return $radio_box;
148
+	}
149 149
 }
150 150
 
151 151
 /**
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
  */
154 154
 class SmartObjectCurrencyHandler extends SmartPersistableObjectHandler
155 155
 {
156
-    /**
157
-     * SmartObjectCurrencyHandler constructor.
158
-     * @param XoopsDatabase $db
159
-     */
160
-    public function __construct(XoopsDatabase $db)
161
-    {
162
-        parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
-    }
164
-
165
-    /**
166
-     * @return array
167
-     */
168
-    public function getCurrencies()
169
-    {
170
-        $currenciesObj = $this->getObjects(null, true);
171
-
172
-        return $currenciesObj;
173
-    }
156
+	/**
157
+	 * SmartObjectCurrencyHandler constructor.
158
+	 * @param XoopsDatabase $db
159
+	 */
160
+	public function __construct(XoopsDatabase $db)
161
+	{
162
+		parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
+	}
164
+
165
+	/**
166
+	 * @return array
167
+	 */
168
+	public function getCurrencies()
169
+	{
170
+		$currenciesObj = $this->getObjects(null, true);
171
+
172
+		return $currenciesObj;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 
30 30
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
31 31
 
32
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
33
-include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
32
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php';
33
+include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
34 34
 
35 35
 /**
36 36
  * Class SmartobjectCurrency
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function getDefaultCurrencyControl()
140 140
     {
141
-        $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
141
+        $radio_box = '<input name="default_currency" value="'.$this->getVar('currencyid').'" type="radio"';
142 142
         if ($this->getVar('default_currency', 'e')) {
143 143
             $radio_box .= 'checked="checked"';
144 144
         }
Please login to merge, or discard this patch.
class/smartloader.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,6 @@
 block discarded – undo
30 30
 $smarthookHandler = SmartHookHandler::getInstance();
31 31
 
32 32
 if (!class_exists('smartmetagen')) {
33
-    include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php');
33
+	include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php');
34 34
 }
35 35
 //$smartobjectConfig = smart_getModuleConfig('smartobject');
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
 
14 14
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
15 15
 
16
-include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php');
16
+include_once(XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php');
17 17
 
18 18
 /**
19 19
  * Include other classes used by the SmartObject
20 20
  */
21
-include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjecthandler.php');
22
-include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobject.php');
23
-include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectsregistry.php');
21
+include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjecthandler.php');
22
+include_once(SMARTOBJECT_ROOT_PATH.'class/smartobject.php');
23
+include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjectsregistry.php');
24 24
 
25 25
 /**
26 26
  * Including SmartHook feature
27 27
  */
28 28
 
29
-include_once(SMARTOBJECT_ROOT_PATH . 'class/smarthookhandler.php');
29
+include_once(SMARTOBJECT_ROOT_PATH.'class/smarthookhandler.php');
30 30
 $smarthookHandler = SmartHookHandler::getInstance();
31 31
 
32 32
 if (!class_exists('smartmetagen')) {
33
-    include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php');
33
+    include_once(SMARTOBJECT_ROOT_PATH.'class/smartmetagen.php');
34 34
 }
35 35
 //$smartobjectConfig = smart_getModuleConfig('smartobject');
Please login to merge, or discard this patch.