Completed
Push — master ( 01b1a5...81f493 )
by Michael
04:03
created
class/smartobjecttable.php 2 patches
Indentation   +886 added lines, -886 removed lines patch added patch discarded remove patch
@@ -21,77 +21,77 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class SmartObjectColumn
23 23
 {
24
-    public $_keyname;
25
-    public $_align;
26
-    public $_width;
27
-    public $_customMethodForValue;
28
-    public $_extraParams;
29
-    public $_sortable;
30
-    public $_customCaption;
31
-
32
-    /**
33
-     * SmartObjectColumn constructor.
34
-     * @param        $keyname
35
-     * @param string $align
36
-     * @param bool   $width
37
-     * @param bool   $customMethodForValue
38
-     * @param bool   $param
39
-     * @param bool   $customCaption
40
-     * @param bool   $sortable
41
-     */
42
-    public function __construct($keyname, $align = 'left', $width = false, $customMethodForValue = false, $param = false, $customCaption = false, $sortable = true)
43
-    {
44
-        $this->_keyname              = $keyname;
45
-        $this->_align                = $align;
46
-        $this->_width                = $width;
47
-        $this->_customMethodForValue = $customMethodForValue;
48
-        $this->_sortable             = $sortable;
49
-        $this->_param                = $param;
50
-        $this->_customCaption        = $customCaption;
51
-    }
52
-
53
-    public function getKeyName()
54
-    {
55
-        return $this->_keyname;
56
-    }
57
-
58
-    /**
59
-     * @return string
60
-     */
61
-    public function getAlign()
62
-    {
63
-        return $this->_align;
64
-    }
65
-
66
-    /**
67
-     * @return bool
68
-     */
69
-    public function isSortable()
70
-    {
71
-        return $this->_sortable;
72
-    }
73
-
74
-    /**
75
-     * @return bool|string
76
-     */
77
-    public function getWidth()
78
-    {
79
-        if ($this->_width) {
80
-            $ret = $this->_width;
81
-        } else {
82
-            $ret = '';
83
-        }
84
-
85
-        return $ret;
86
-    }
87
-
88
-    /**
89
-     * @return bool
90
-     */
91
-    public function getCustomCaption()
92
-    {
93
-        return $this->_customCaption;
94
-    }
24
+	public $_keyname;
25
+	public $_align;
26
+	public $_width;
27
+	public $_customMethodForValue;
28
+	public $_extraParams;
29
+	public $_sortable;
30
+	public $_customCaption;
31
+
32
+	/**
33
+	 * SmartObjectColumn constructor.
34
+	 * @param        $keyname
35
+	 * @param string $align
36
+	 * @param bool   $width
37
+	 * @param bool   $customMethodForValue
38
+	 * @param bool   $param
39
+	 * @param bool   $customCaption
40
+	 * @param bool   $sortable
41
+	 */
42
+	public function __construct($keyname, $align = 'left', $width = false, $customMethodForValue = false, $param = false, $customCaption = false, $sortable = true)
43
+	{
44
+		$this->_keyname              = $keyname;
45
+		$this->_align                = $align;
46
+		$this->_width                = $width;
47
+		$this->_customMethodForValue = $customMethodForValue;
48
+		$this->_sortable             = $sortable;
49
+		$this->_param                = $param;
50
+		$this->_customCaption        = $customCaption;
51
+	}
52
+
53
+	public function getKeyName()
54
+	{
55
+		return $this->_keyname;
56
+	}
57
+
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function getAlign()
62
+	{
63
+		return $this->_align;
64
+	}
65
+
66
+	/**
67
+	 * @return bool
68
+	 */
69
+	public function isSortable()
70
+	{
71
+		return $this->_sortable;
72
+	}
73
+
74
+	/**
75
+	 * @return bool|string
76
+	 */
77
+	public function getWidth()
78
+	{
79
+		if ($this->_width) {
80
+			$ret = $this->_width;
81
+		} else {
82
+			$ret = '';
83
+		}
84
+
85
+		return $ret;
86
+	}
87
+
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	public function getCustomCaption()
92
+	{
93
+		return $this->_customCaption;
94
+	}
95 95
 }
96 96
 
97 97
 /**
@@ -105,819 +105,819 @@  discard block
 block discarded – undo
105 105
  */
106 106
 class SmartObjectTable
107 107
 {
108
-    public $_id;
109
-    public $_objectHandler;
110
-    public $_columns;
111
-    public $_criteria;
112
-    public $_actions;
113
-    public $_objects = false;
114
-    public $_aObjects;
115
-    public $_custom_actions;
116
-    public $_sortsel;
117
-    public $_ordersel;
118
-    public $_limitsel;
119
-    public $_filtersel;
120
-    public $_filterseloptions;
121
-    public $_filtersel2;
122
-    public $_filtersel2options;
123
-    public $_filtersel2optionsDefault;
124
-
125
-    public $_tempObject;
126
-    public $_tpl;
127
-    public $_introButtons;
128
-    public $_quickSearch            = false;
129
-    public $_actionButtons          = false;
130
-    public $_head_css_class         = 'bg3';
131
-    public $_hasActions             = false;
132
-    public $_userSide               = false;
133
-    public $_printerFriendlyPage    = false;
134
-    public $_tableHeader            = false;
135
-    public $_tableFooter            = false;
136
-    public $_showActionsColumnTitle = true;
137
-    public $_isTree                 = false;
138
-    public $_showFilterAndLimit     = true;
139
-    public $_enableColumnsSorting   = true;
140
-    public $_customTemplate         = false;
141
-    public $_withSelectedActions    = array();
142
-
143
-    /**
144
-     * Constructor
145
-     *
146
-     * @param SmartPersistableObjectHandler $objectHandler {@link SmartPersistableObjectHandler}
147
-     * @param CriteriaElement          $criteria
148
-     * @param array                         $actions       array representing the actions to offer
149
-     *
150
-     * @param bool                          $userSide
151
-     * @internal param array $columns array representing the columns to display in the table
152
-     */
153
-    public function __construct(SmartPersistableObjectHandler $objectHandler, CriteriaElement $criteria = null, $actions = array('edit', 'delete'), $userSide = false)
154
-    {
155
-        $this->_id            = $objectHandler->className;
156
-        $this->_objectHandler = $objectHandler;
157
-
158
-        if (!$criteria) {
159
-            $criteria = new CriteriaCompo();
160
-        }
161
-        $this->_criteria       = $criteria;
162
-        $this->_actions        = $actions;
163
-        $this->_custom_actions = array();
164
-        $this->_userSide       = $userSide;
165
-        if ($userSide) {
166
-            $this->_head_css_class = 'head';
167
-        }
168
-    }
169
-
170
-    /**
171
-     * @param      $op
172
-     * @param bool $caption
173
-     * @param bool $text
174
-     */
175
-    public function addActionButton($op, $caption = false, $text = false)
176
-    {
177
-        $action                 = array(
178
-            'op'      => $op,
179
-            'caption' => $caption,
180
-            'text'    => $text
181
-        );
182
-        $this->_actionButtons[] = $action;
183
-    }
184
-
185
-    /**
186
-     * @param $columnObj
187
-     */
188
-    public function addColumn($columnObj)
189
-    {
190
-        $this->_columns[] = $columnObj;
191
-    }
192
-
193
-    /**
194
-     * @param $name
195
-     * @param $location
196
-     * @param $value
197
-     */
198
-    public function addIntroButton($name, $location, $value)
199
-    {
200
-        $introButton             = array();
201
-        $introButton['name']     = $name;
202
-        $introButton['location'] = $location;
203
-        $introButton['value']    = $value;
204
-        $this->_introButtons[]   = $introButton;
205
-        unset($introButton);
206
-    }
207
-
208
-    public function addPrinterFriendlyLink()
209
-    {
210
-        $current_urls               = smart_getCurrentUrls();
211
-        $current_url                = $current_urls['full'];
212
-        $this->_printerFriendlyPage = $current_url . '&print';
213
-    }
214
-
215
-    /**
216
-     * @param        $fields
217
-     * @param string $caption
218
-     */
219
-    public function addQuickSearch($fields, $caption = _CO_SOBJECT_QUICK_SEARCH)
220
-    {
221
-        $this->_quickSearch = array('fields' => $fields, 'caption' => $caption);
222
-    }
223
-
224
-    /**
225
-     * @param $content
226
-     */
227
-    public function addHeader($content)
228
-    {
229
-        $this->_tableHeader = $content;
230
-    }
231
-
232
-    /**
233
-     * @param $content
234
-     */
235
-    public function addFooter($content)
236
-    {
237
-        $this->_tableFooter = $content;
238
-    }
239
-
240
-    /**
241
-     * @param $caption
242
-     */
243
-    public function addDefaultIntroButton($caption)
244
-    {
245
-        $this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page . '?op=mod', $caption);
246
-    }
247
-
248
-    /**
249
-     * @param $method
250
-     */
251
-    public function addCustomAction($method)
252
-    {
253
-        $this->_custom_actions[] = $method;
254
-    }
255
-
256
-    /**
257
-     * @param $default_sort
258
-     */
259
-    public function setDefaultSort($default_sort)
260
-    {
261
-        $this->_sortsel = $default_sort;
262
-    }
263
-
264
-    /**
265
-     * @return string
266
-     */
267
-    public function getDefaultSort()
268
-    {
269
-        if ($this->_sortsel) {
270
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
271
-        } else {
272
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_objectHandler->identifierName);
273
-        }
274
-    }
275
-
276
-    /**
277
-     * @param $default_order
278
-     */
279
-    public function setDefaultOrder($default_order)
280
-    {
281
-        $this->_ordersel = $default_order;
282
-    }
283
-
284
-    /**
285
-     * @return string
286
-     */
287
-    public function getDefaultOrder()
288
-    {
289
-        if ($this->_ordersel) {
290
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
291
-        } else {
292
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', 'ASC');
293
-        }
294
-    }
295
-
296
-    /**
297
-     * @param array $actions
298
-     */
299
-    public function addWithSelectedActions($actions = array())
300
-    {
301
-        $this->addColumn(new SmartObjectColumn('checked', 'center', 20, false, false, ' '));
302
-        $this->_withSelectedActions = $actions;
303
-    }
304
-
305
-    /**
306
-     * Adding a filter in the table
307
-     *
308
-     * @param string $key    key to the field that will be used for sorting
309
-     * @param string $method method of the handler that will be called to populate the options when this filter is selected
310
-     * @param bool   $default
311
-     */
312
-    public function addFilter($key, $method, $default = false)
313
-    {
314
-        $this->_filterseloptions[$key]   = $method;
315
-        $this->_filtersel2optionsDefault = $default;
316
-    }
317
-
318
-    /**
319
-     * @param $default_filter
320
-     */
321
-    public function setDefaultFilter($default_filter)
322
-    {
323
-        $this->_filtersel = $default_filter;
324
-    }
325
-
326
-    public function isForUserSide()
327
-    {
328
-        $this->_userSide = true;
329
-    }
330
-
331
-    /**
332
-     * @param $template
333
-     */
334
-    public function setCustomTemplate($template)
335
-    {
336
-        $this->_customTemplate = $template;
337
-    }
338
-
339
-    public function setSortOrder()
340
-    {
341
-        $this->_sortsel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] : $this->getDefaultSort();
342
-        //$this->_sortsel = isset($_POST['sortsel']) ? $_POST['sortsel']: $this->_sortsel;
343
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
344
-        $fieldsForSorting = $this->_tempObject->getFieldsForSorting($this->_sortsel);
345
-
346
-        if (isset($this->_tempObject->vars[$this->_sortsel]['itemName']) && $this->_tempObject->vars[$this->_sortsel]['itemName']) {
347
-            $this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'] . '.' . $this->_sortsel);
348
-        } else {
349
-            $this->_criteria->setSort($this->_objectHandler->_itemname . '.' . $this->_sortsel);
350
-        }
351
-
352
-        $this->_ordersel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : $this->getDefaultOrder();
353
-        //$this->_ordersel = isset($_POST['ordersel']) ? $_POST['ordersel']:$this->_ordersel;
354
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
355
-        $ordersArray = $this->getOrdersArray();
356
-        $this->_criteria->setOrder($this->_ordersel);
357
-    }
358
-
359
-    /**
360
-     * @param $id
361
-     */
362
-    public function setTableId($id)
363
-    {
364
-        $this->_id = $id;
365
-    }
366
-
367
-    /**
368
-     * @param $objects
369
-     */
370
-    public function setObjects($objects)
371
-    {
372
-        $this->_objects = $objects;
373
-    }
374
-
375
-    public function createTableRows()
376
-    {
377
-        $this->_aObjects = array();
378
-
379
-        $doWeHaveActions = false;
380
-
381
-        $objectclass = 'odd';
382
-        if (count($this->_objects) > 0) {
383
-            foreach ($this->_objects as $object) {
384
-                $aObject = array();
385
-
386
-                $i = 0;
387
-
388
-                $aColumns = array();
389
-
390
-                foreach ($this->_columns as $column) {
391
-                    $aColumn = array();
392
-
393
-                    if ($i == 0) {
394
-                        $class = 'head';
395
-                    } elseif ($i % 2 == 0) {
396
-                        $class = 'even';
397
-                    } else {
398
-                        $class = 'odd';
399
-                    }
400
-                    if (method_exists($object, 'initiateCustomFields')) {
401
-                        //$object->initiateCustomFields();
402
-                    }
403
-                    if ($column->_keyname === 'checked') {
404
-                        $value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
405
-                    } elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
406
-                        $method = $column->_customMethodForValue;
407
-                        if ($column->_param) {
408
-                            $value = $object->$method($column->_param);
409
-                        } else {
410
-                            $value = $object->$method();
411
-                        }
412
-                    } else {
413
-                        /**
414
-                         * If the column is the identifier, then put a link on it
415
-                         */
416
-                        if ($column->getKeyName() == $this->_objectHandler->identifierName) {
417
-                            $value = $object->getItemLink();
418
-                        } else {
419
-                            $value = $object->getVar($column->getKeyName());
420
-                        }
421
-                    }
422
-
423
-                    $aColumn['value'] = $value;
424
-                    $aColumn['class'] = $class;
425
-                    $aColumn['width'] = $column->getWidth();
426
-                    $aColumn['align'] = $column->getAlign();
427
-
428
-                    $aColumns[] = $aColumn;
429
-                    ++$i;
430
-                }
431
-
432
-                $aObject['columns'] = $aColumns;
433
-                $aObject['id']      = $object->id();
434
-
435
-                $objectclass = ($objectclass === 'even') ? 'odd' : 'even';
436
-
437
-                $aObject['class'] = $objectclass;
438
-
439
-                $actions = array();
440
-
441
-                // Adding the custom actions if any
442
-                foreach ($this->_custom_actions as $action) {
443
-                    if (method_exists($object, $action)) {
444
-                        $actions[] = $object->$action();
445
-                    }
446
-                }
447
-
448
-                include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
449
-                $controller = new SmartObjectController($this->_objectHandler);
450
-
451
-                if ((!is_array($this->_actions)) || in_array('edit', $this->_actions)) {
452
-                    $actions[] = $controller->getEditItemLink($object, false, true, $this->_userSide);
453
-                }
454
-                if ((!is_array($this->_actions)) || in_array('delete', $this->_actions)) {
455
-                    $actions[] = $controller->getDeleteItemLink($object, false, true, $this->_userSide);
456
-                }
457
-                $aObject['actions'] = $actions;
458
-
459
-                $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
460
-
461
-                $doWeHaveActions = $doWeHaveActions ? true : count($actions) > 0;
462
-
463
-                $this->_aObjects[] = $aObject;
464
-            }
465
-            $this->_tpl->assign('smartobject_objects', $this->_aObjects);
466
-        } else {
467
-            $colspan = count($this->_columns) + 1;
468
-            $this->_tpl->assign('smartobject_colspan', $colspan);
469
-        }
470
-        $this->_hasActions = $doWeHaveActions;
471
-    }
472
-
473
-    /**
474
-     * @param  bool $debug
475
-     * @return mixed
476
-     */
477
-    public function fetchObjects($debug = false)
478
-    {
479
-        return $this->_objectHandler->getObjects($this->_criteria, true, true, false, $debug);
480
-    }
481
-
482
-    /**
483
-     * @return string
484
-     */
485
-    public function getDefaultFilter()
486
-    {
487
-        if ($this->_filtersel) {
488
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
489
-        } else {
490
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', 'default');
491
-        }
492
-    }
493
-
494
-    /**
495
-     * @return array|bool
496
-     */
497
-    public function getFiltersArray()
498
-    {
499
-        $ret               = array();
500
-        $field             = array();
501
-        $field['caption']  = _CO_OBJ_NONE;
502
-        $field['selected'] = '';
503
-        $ret['default']    = $field;
504
-        unset($field);
505
-
506
-        if ($this->_filterseloptions) {
507
-            foreach ($this->_filterseloptions as $key => $value) {
508
-                $field = array();
509
-                if (is_array($value)) {
510
-                    $field['caption']  = $key;
511
-                    $field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
512
-                } else {
513
-                    $field['caption']  = $this->_tempObject->vars[$key]['form_caption'];
514
-                    $field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
515
-                }
516
-                $ret[$key] = $field;
517
-                unset($field);
518
-            }
519
-        } else {
520
-            $ret = false;
521
-        }
522
-
523
-        return $ret;
524
-    }
525
-
526
-    /**
527
-     * @param $default_filter2
528
-     */
529
-    public function setDefaultFilter2($default_filter2)
530
-    {
531
-        $this->_filtersel2 = $default_filter2;
532
-    }
533
-
534
-    /**
535
-     * @return string
536
-     */
537
-    public function getDefaultFilter2()
538
-    {
539
-        if ($this->_filtersel2) {
540
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
541
-        } else {
542
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', 'default');
543
-        }
544
-    }
545
-
546
-    /**
547
-     * @return array
548
-     */
549
-    public function getFilters2Array()
550
-    {
551
-        $ret = array();
552
-
553
-        foreach ($this->_filtersel2options as $key => $value) {
554
-            $field             = array();
555
-            $field['caption']  = $value;
556
-            $field['selected'] = $this->_filtersel2 == $key ? "selected='selected'" : '';
557
-            $ret[$key]         = $field;
558
-            unset($field);
559
-        }
560
-
561
-        return $ret;
562
-    }
563
-
564
-    /**
565
-     * @param $limitsArray
566
-     * @param $params_of_the_options_sel
567
-     */
568
-    public function renderOptionSelection($limitsArray, $params_of_the_options_sel)
569
-    {
570
-        // Rendering the form to select options on the table
571
-        $current_urls = smart_getCurrentUrls();
572
-        $current_url  = $current_urls['full'];
573
-
574
-        /**
575
-         * What was $params_of_the_options_sel doing again ?
576
-         */
577
-        //$this->_tpl->assign('smartobject_optionssel_action', $_SERVER['PHP_SELF'] . "?" . implode('&', $params_of_the_options_sel));
578
-        $this->_tpl->assign('smartobject_optionssel_action', $current_url);
579
-        $this->_tpl->assign('smartobject_optionssel_limitsArray', $limitsArray);
580
-    }
581
-
582
-    /**
583
-     * @return array
584
-     */
585
-    public function getLimitsArray()
586
-    {
587
-        $ret                    = array();
588
-        $ret['all']['caption']  = _CO_SOBJECT_LIMIT_ALL;
589
-        $ret['all']['selected'] = ('all' === $this->_limitsel) ? "selected='selected'" : '';
590
-
591
-        $ret['5']['caption']  = '5';
592
-        $ret['5']['selected'] = ('5' == $this->_limitsel) ? "selected='selected'" : '';
593
-
594
-        $ret['10']['caption']  = '10';
595
-        $ret['10']['selected'] = ('10' == $this->_limitsel) ? "selected='selected'" : '';
596
-
597
-        $ret['15']['caption']  = '15';
598
-        $ret['15']['selected'] = ('15' == $this->_limitsel) ? "selected='selected'" : '';
599
-
600
-        $ret['20']['caption']  = '20';
601
-        $ret['20']['selected'] = ('20' == $this->_limitsel) ? "selected='selected'" : '';
602
-
603
-        $ret['25']['caption']  = '25';
604
-        $ret['25']['selected'] = ('25' == $this->_limitsel) ? "selected='selected'" : '';
605
-
606
-        $ret['30']['caption']  = '30';
607
-        $ret['30']['selected'] = ('30' == $this->_limitsel) ? "selected='selected'" : '';
608
-
609
-        $ret['35']['caption']  = '35';
610
-        $ret['35']['selected'] = ('35' == $this->_limitsel) ? "selected='selected'" : '';
611
-
612
-        $ret['40']['caption']  = '40';
613
-        $ret['40']['selected'] = ('40' == $this->_limitsel) ? "selected='selected'" : '';
614
-
615
-        return $ret;
616
-    }
617
-
618
-    /**
619
-     * @return bool
620
-     */
621
-    public function getObjects()
622
-    {
623
-        return $this->_objects;
624
-    }
625
-
626
-    public function hideActionColumnTitle()
627
-    {
628
-        $this->_showActionsColumnTitle = false;
629
-    }
630
-
631
-    public function hideFilterAndLimit()
632
-    {
633
-        $this->_showFilterAndLimit = false;
634
-    }
635
-
636
-    /**
637
-     * @return array
638
-     */
639
-    public function getOrdersArray()
640
-    {
641
-        $ret                    = array();
642
-        $ret['ASC']['caption']  = _CO_SOBJECT_SORT_ASC;
643
-        $ret['ASC']['selected'] = ('ASC' === $this->_ordersel) ? "selected='selected'" : '';
644
-
645
-        $ret['DESC']['caption']  = _CO_SOBJECT_SORT_DESC;
646
-        $ret['DESC']['selected'] = ('DESC' === $this->_ordersel) ? "selected='selected'" : '';
647
-
648
-        return $ret;
649
-    }
650
-
651
-    /**
652
-     * @return mixed|string|void
653
-     */
654
-    public function renderD()
655
-    {
656
-        return $this->render(false, true);
657
-    }
658
-
659
-    public function renderForPrint()
660
-    {
661
-    }
662
-
663
-    /**
664
-     * @param  bool $fetchOnly
665
-     * @param  bool $debug
666
-     * @return mixed|string|void
667
-     */
668
-    public function render($fetchOnly = false, $debug = false)
669
-    {
670
-        include_once XOOPS_ROOT_PATH . '/class/template.php';
671
-
672
-        $this->_tpl = new XoopsTpl();
673
-
674
-        /**
675
-         * We need access to the vars of the SmartObject for a few things in the table creation.
676
-         * Since we may not have a SmartObject to look into now, let's create one for this purpose
677
-         * and we will free it after
678
-         */
679
-        $this->_tempObject = $this->_objectHandler->create();
680
-
681
-        $this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int)$_GET['start' . $this->_objectHandler->keyName] : 0);
682
-
683
-        $this->setSortOrder();
684
-
685
-        if (!$this->_isTree) {
686
-            $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15');
687
-        } else {
688
-            $this->_limitsel = 'all';
689
-        }
690
-
691
-        $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
692
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel);
693
-        $limitsArray = $this->getLimitsArray();
694
-        $this->_criteria->setLimit($this->_limitsel);
695
-
696
-        $this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter();
697
-        $this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel;
698
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
699
-        $filtersArray = $this->getFiltersArray();
700
-
701
-        if ($filtersArray) {
702
-            $this->_tpl->assign('smartobject_optionssel_filtersArray', $filtersArray);
703
-        }
704
-
705
-        // Check if the selected filter is defined and if so, create the selfilter2
706
-        if (isset($this->_filterseloptions[$this->_filtersel])) {
707
-            // check if method associate with this filter exists in the handler
708
-            if (is_array($this->_filterseloptions[$this->_filtersel])) {
709
-                $filter = $this->_filterseloptions[$this->_filtersel];
710
-                $this->_criteria->add($filter['criteria']);
711
-            } else {
712
-                if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) {
713
-
714
-                    // then we will create the selfilter2 options by calling this method
715
-                    $method                   = $this->_filterseloptions[$this->_filtersel];
716
-                    $this->_filtersel2options = $this->_objectHandler->$method();
717
-
718
-                    $this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2();
719
-                    $this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2;
720
-
721
-                    $filters2Array = $this->getFilters2Array();
722
-                    $this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array);
723
-
724
-                    smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
725
-                    if ($this->_filtersel2 !== 'default') {
726
-                        $this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2));
727
-                    }
728
-                }
729
-            }
730
-        }
731
-        // Check if we have a quicksearch
732
-
733
-        if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
734
-            $quicksearch_criteria = new CriteriaCompo();
735
-            if (is_array($this->_quickSearch['fields'])) {
736
-                foreach ($this->_quickSearch['fields'] as $v) {
737
-                    $quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
738
-                }
739
-            } else {
740
-                $quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
741
-            }
742
-            $this->_criteria->add($quicksearch_criteria);
743
-        }
744
-
745
-        $this->_objects = $this->fetchObjects($debug);
746
-
747
-        include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
748
-        if ($this->_criteria->getLimit() > 0) {
749
-
750
-            /**
751
-             * Geeting rid of the old params
752
-             * $new_get_array is an array containing the new GET parameters
753
-             */
754
-            $new_get_array = array();
755
-
756
-            /**
757
-             * $params_of_the_options_sel is an array with all the parameters of the page
758
-             * but without the pagenave parameters. This array will be used in the
759
-             * OptionsSelection
760
-             */
761
-            $params_of_the_options_sel = array();
762
-
763
-            $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName);
764
-            foreach ($_GET as $k => $v) {
765
-                if (!in_array($k, $not_needed_params)) {
766
-                    $new_get_array[]             = "$k=$v";
767
-                    $params_of_the_options_sel[] = "$k=$v";
768
-                }
769
-            }
770
-
771
-            /**
772
-             * Adding the new params of the pagenav
773
-             */
774
-            $new_get_array[] = 'sortsel=' . $this->_sortsel;
775
-            $new_get_array[] = 'ordersel=' . $this->_ordersel;
776
-            $new_get_array[] = 'limitsel=' . $this->_limitsel;
777
-            $otherParams     = implode('&', $new_get_array);
778
-
779
-            $pagenav =
780
-                new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
781
-            $this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav());
782
-        }
783
-        $this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
784
-
785
-        // retreive the current url and the query string
786
-        $current_urls = smart_getCurrentUrls();
787
-        $current_url  = $current_urls['full_phpself'];
788
-        $query_string = $current_urls['querystring'];
789
-        if ($query_string) {
790
-            $query_string = str_replace('?', '', $query_string);
791
-        }
792
-        $query_stringArray     = explode('&', $query_string);
793
-        $new_query_stringArray = array();
794
-        foreach ($query_stringArray as $query_string) {
795
-            if (strpos($query_string, 'sortsel') == false && strpos($query_string, 'ordersel') == false) {
796
-                $new_query_stringArray[] = $query_string;
797
-            }
798
-        }
799
-        $new_query_string = implode('&', $new_query_stringArray);
800
-
801
-        $orderArray                     = array();
802
-        $orderArray['ASC']['image']     = 'desc.png';
803
-        $orderArray['ASC']['neworder']  = 'DESC';
804
-        $orderArray['DESC']['image']    = 'asc.png';
805
-        $orderArray['DESC']['neworder'] = 'ASC';
806
-
807
-        $aColumns = array();
808
-
809
-        foreach ($this->_columns as $column) {
810
-            $qs_param         = '';
811
-            $aColumn          = array();
812
-            $aColumn['width'] = $column->getWidth();
813
-            $aColumn['align'] = $column->getAlign();
814
-            $aColumn['key']   = $column->getKeyName();
815
-            if ($column->_keyname === 'checked') {
816
-                $aColumn['caption'] = '<input type ="checkbox" id="checkall_smartobjects" name="checkall_smartobjects"'
817
-                                      . ' value="checkall_smartobjects" onclick="smartobject_checkall(window.document.form_'
818
-                                      . $this->_id
819
-                                      . ', \'selected_smartobjects\');" />';
820
-            } elseif ($column->getCustomCaption()) {
821
-                $aColumn['caption'] = $column->getCustomCaption();
822
-            } else {
823
-                $aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName();
824
-            }
825
-            // Are we doing a GET sort on this column ?
826
-            $getSort = (isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName())
827
-                       || ($this->_sortsel == $column->getKeyName());
828
-            $order   = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC';
829
-
830
-            if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') {
831
-                $qs_param = '&quicksearch_' . $this->_id . '=' . $_REQUEST['quicksearch_' . $this->_id];
832
-            }
833
-            if (!$this->_enableColumnsSorting || $column->_keyname === 'checked' || !$column->isSortable()) {
834
-                $aColumn['caption'] = $aColumn['caption'];
835
-            } elseif ($getSort) {
836
-                $aColumn['caption'] = '<a href="'
837
-                                      . $current_url
838
-                                      . '?'
839
-                                      . $this->_objectHandler->_itemname
840
-                                      . '_'
841
-                                      . 'sortsel='
842
-                                      . $column->getKeyName()
843
-                                      . '&'
844
-                                      . $this->_objectHandler->_itemname
845
-                                      . '_'
846
-                                      . 'ordersel='
847
-                                      . $orderArray[$order]['neworder']
848
-                                      . $qs_param
849
-                                      . '&'
850
-                                      . $new_query_string
851
-                                      . '">'
852
-                                      . $aColumn['caption']
853
-                                      . ' <img src="'
854
-                                      . SMARTOBJECT_IMAGES_ACTIONS_URL
855
-                                      . $orderArray[$order]['image']
856
-                                      . '" alt="ASC" /></a>';
857
-            } else {
858
-                $aColumn['caption'] = '<a href="'
859
-                                      . $current_url
860
-                                      . '?'
861
-                                      . $this->_objectHandler->_itemname
862
-                                      . '_'
863
-                                      . 'sortsel='
864
-                                      . $column->getKeyName()
865
-                                      . '&'
866
-                                      . $this->_objectHandler->_itemname
867
-                                      . '_'
868
-                                      . 'ordersel=ASC'
869
-                                      . $qs_param
870
-                                      . '&'
871
-                                      . $new_query_string
872
-                                      . '">'
873
-                                      . $aColumn['caption']
874
-                                      . '</a>';
875
-            }
876
-            $aColumns[] = $aColumn;
877
-        }
878
-        $this->_tpl->assign('smartobject_columns', $aColumns);
879
-
880
-        if ($this->_quickSearch) {
881
-            $this->_tpl->assign('smartobject_quicksearch', $this->_quickSearch['caption']);
882
-        }
883
-
884
-        $this->createTableRows();
885
-
886
-        $this->_tpl->assign('smartobject_showFilterAndLimit', $this->_showFilterAndLimit);
887
-        $this->_tpl->assign('smartobject_isTree', $this->_isTree);
888
-        $this->_tpl->assign('smartobject_show_action_column_title', $this->_showActionsColumnTitle);
889
-        $this->_tpl->assign('smartobject_table_header', $this->_tableHeader);
890
-        $this->_tpl->assign('smartobject_table_footer', $this->_tableFooter);
891
-        $this->_tpl->assign('smartobject_printer_friendly_page', $this->_printerFriendlyPage);
892
-        $this->_tpl->assign('smartobject_user_side', $this->_userSide);
893
-        $this->_tpl->assign('smartobject_has_actions', $this->_hasActions);
894
-        $this->_tpl->assign('smartobject_head_css_class', $this->_head_css_class);
895
-        $this->_tpl->assign('smartobject_actionButtons', $this->_actionButtons);
896
-        $this->_tpl->assign('smartobject_introButtons', $this->_introButtons);
897
-        $this->_tpl->assign('smartobject_id', $this->_id);
898
-        if (!empty($this->_withSelectedActions)) {
899
-            $this->_tpl->assign('smartobject_withSelectedActions', $this->_withSelectedActions);
900
-        }
901
-
902
-        $smartobjectTable_template = $this->_customTemplate ?: 'smartobject_smarttable_display.tpl';
903
-        if ($fetchOnly) {
904
-            return $this->_tpl->fetch('db:' . $smartobjectTable_template);
905
-        } else {
906
-            $this->_tpl->display('db:' . $smartobjectTable_template);
907
-        }
908
-    }
909
-
910
-    public function disableColumnsSorting()
911
-    {
912
-        $this->_enableColumnsSorting = false;
913
-    }
914
-
915
-    /**
916
-     * @param  bool $debug
917
-     * @return mixed|string|void
918
-     */
919
-    public function fetch($debug = false)
920
-    {
921
-        return $this->render(true, $debug);
922
-    }
108
+	public $_id;
109
+	public $_objectHandler;
110
+	public $_columns;
111
+	public $_criteria;
112
+	public $_actions;
113
+	public $_objects = false;
114
+	public $_aObjects;
115
+	public $_custom_actions;
116
+	public $_sortsel;
117
+	public $_ordersel;
118
+	public $_limitsel;
119
+	public $_filtersel;
120
+	public $_filterseloptions;
121
+	public $_filtersel2;
122
+	public $_filtersel2options;
123
+	public $_filtersel2optionsDefault;
124
+
125
+	public $_tempObject;
126
+	public $_tpl;
127
+	public $_introButtons;
128
+	public $_quickSearch            = false;
129
+	public $_actionButtons          = false;
130
+	public $_head_css_class         = 'bg3';
131
+	public $_hasActions             = false;
132
+	public $_userSide               = false;
133
+	public $_printerFriendlyPage    = false;
134
+	public $_tableHeader            = false;
135
+	public $_tableFooter            = false;
136
+	public $_showActionsColumnTitle = true;
137
+	public $_isTree                 = false;
138
+	public $_showFilterAndLimit     = true;
139
+	public $_enableColumnsSorting   = true;
140
+	public $_customTemplate         = false;
141
+	public $_withSelectedActions    = array();
142
+
143
+	/**
144
+	 * Constructor
145
+	 *
146
+	 * @param SmartPersistableObjectHandler $objectHandler {@link SmartPersistableObjectHandler}
147
+	 * @param CriteriaElement          $criteria
148
+	 * @param array                         $actions       array representing the actions to offer
149
+	 *
150
+	 * @param bool                          $userSide
151
+	 * @internal param array $columns array representing the columns to display in the table
152
+	 */
153
+	public function __construct(SmartPersistableObjectHandler $objectHandler, CriteriaElement $criteria = null, $actions = array('edit', 'delete'), $userSide = false)
154
+	{
155
+		$this->_id            = $objectHandler->className;
156
+		$this->_objectHandler = $objectHandler;
157
+
158
+		if (!$criteria) {
159
+			$criteria = new CriteriaCompo();
160
+		}
161
+		$this->_criteria       = $criteria;
162
+		$this->_actions        = $actions;
163
+		$this->_custom_actions = array();
164
+		$this->_userSide       = $userSide;
165
+		if ($userSide) {
166
+			$this->_head_css_class = 'head';
167
+		}
168
+	}
169
+
170
+	/**
171
+	 * @param      $op
172
+	 * @param bool $caption
173
+	 * @param bool $text
174
+	 */
175
+	public function addActionButton($op, $caption = false, $text = false)
176
+	{
177
+		$action                 = array(
178
+			'op'      => $op,
179
+			'caption' => $caption,
180
+			'text'    => $text
181
+		);
182
+		$this->_actionButtons[] = $action;
183
+	}
184
+
185
+	/**
186
+	 * @param $columnObj
187
+	 */
188
+	public function addColumn($columnObj)
189
+	{
190
+		$this->_columns[] = $columnObj;
191
+	}
192
+
193
+	/**
194
+	 * @param $name
195
+	 * @param $location
196
+	 * @param $value
197
+	 */
198
+	public function addIntroButton($name, $location, $value)
199
+	{
200
+		$introButton             = array();
201
+		$introButton['name']     = $name;
202
+		$introButton['location'] = $location;
203
+		$introButton['value']    = $value;
204
+		$this->_introButtons[]   = $introButton;
205
+		unset($introButton);
206
+	}
207
+
208
+	public function addPrinterFriendlyLink()
209
+	{
210
+		$current_urls               = smart_getCurrentUrls();
211
+		$current_url                = $current_urls['full'];
212
+		$this->_printerFriendlyPage = $current_url . '&print';
213
+	}
214
+
215
+	/**
216
+	 * @param        $fields
217
+	 * @param string $caption
218
+	 */
219
+	public function addQuickSearch($fields, $caption = _CO_SOBJECT_QUICK_SEARCH)
220
+	{
221
+		$this->_quickSearch = array('fields' => $fields, 'caption' => $caption);
222
+	}
223
+
224
+	/**
225
+	 * @param $content
226
+	 */
227
+	public function addHeader($content)
228
+	{
229
+		$this->_tableHeader = $content;
230
+	}
231
+
232
+	/**
233
+	 * @param $content
234
+	 */
235
+	public function addFooter($content)
236
+	{
237
+		$this->_tableFooter = $content;
238
+	}
239
+
240
+	/**
241
+	 * @param $caption
242
+	 */
243
+	public function addDefaultIntroButton($caption)
244
+	{
245
+		$this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page . '?op=mod', $caption);
246
+	}
247
+
248
+	/**
249
+	 * @param $method
250
+	 */
251
+	public function addCustomAction($method)
252
+	{
253
+		$this->_custom_actions[] = $method;
254
+	}
255
+
256
+	/**
257
+	 * @param $default_sort
258
+	 */
259
+	public function setDefaultSort($default_sort)
260
+	{
261
+		$this->_sortsel = $default_sort;
262
+	}
263
+
264
+	/**
265
+	 * @return string
266
+	 */
267
+	public function getDefaultSort()
268
+	{
269
+		if ($this->_sortsel) {
270
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
271
+		} else {
272
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_objectHandler->identifierName);
273
+		}
274
+	}
275
+
276
+	/**
277
+	 * @param $default_order
278
+	 */
279
+	public function setDefaultOrder($default_order)
280
+	{
281
+		$this->_ordersel = $default_order;
282
+	}
283
+
284
+	/**
285
+	 * @return string
286
+	 */
287
+	public function getDefaultOrder()
288
+	{
289
+		if ($this->_ordersel) {
290
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
291
+		} else {
292
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', 'ASC');
293
+		}
294
+	}
295
+
296
+	/**
297
+	 * @param array $actions
298
+	 */
299
+	public function addWithSelectedActions($actions = array())
300
+	{
301
+		$this->addColumn(new SmartObjectColumn('checked', 'center', 20, false, false, '&nbsp;'));
302
+		$this->_withSelectedActions = $actions;
303
+	}
304
+
305
+	/**
306
+	 * Adding a filter in the table
307
+	 *
308
+	 * @param string $key    key to the field that will be used for sorting
309
+	 * @param string $method method of the handler that will be called to populate the options when this filter is selected
310
+	 * @param bool   $default
311
+	 */
312
+	public function addFilter($key, $method, $default = false)
313
+	{
314
+		$this->_filterseloptions[$key]   = $method;
315
+		$this->_filtersel2optionsDefault = $default;
316
+	}
317
+
318
+	/**
319
+	 * @param $default_filter
320
+	 */
321
+	public function setDefaultFilter($default_filter)
322
+	{
323
+		$this->_filtersel = $default_filter;
324
+	}
325
+
326
+	public function isForUserSide()
327
+	{
328
+		$this->_userSide = true;
329
+	}
330
+
331
+	/**
332
+	 * @param $template
333
+	 */
334
+	public function setCustomTemplate($template)
335
+	{
336
+		$this->_customTemplate = $template;
337
+	}
338
+
339
+	public function setSortOrder()
340
+	{
341
+		$this->_sortsel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] : $this->getDefaultSort();
342
+		//$this->_sortsel = isset($_POST['sortsel']) ? $_POST['sortsel']: $this->_sortsel;
343
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
344
+		$fieldsForSorting = $this->_tempObject->getFieldsForSorting($this->_sortsel);
345
+
346
+		if (isset($this->_tempObject->vars[$this->_sortsel]['itemName']) && $this->_tempObject->vars[$this->_sortsel]['itemName']) {
347
+			$this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'] . '.' . $this->_sortsel);
348
+		} else {
349
+			$this->_criteria->setSort($this->_objectHandler->_itemname . '.' . $this->_sortsel);
350
+		}
351
+
352
+		$this->_ordersel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : $this->getDefaultOrder();
353
+		//$this->_ordersel = isset($_POST['ordersel']) ? $_POST['ordersel']:$this->_ordersel;
354
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
355
+		$ordersArray = $this->getOrdersArray();
356
+		$this->_criteria->setOrder($this->_ordersel);
357
+	}
358
+
359
+	/**
360
+	 * @param $id
361
+	 */
362
+	public function setTableId($id)
363
+	{
364
+		$this->_id = $id;
365
+	}
366
+
367
+	/**
368
+	 * @param $objects
369
+	 */
370
+	public function setObjects($objects)
371
+	{
372
+		$this->_objects = $objects;
373
+	}
374
+
375
+	public function createTableRows()
376
+	{
377
+		$this->_aObjects = array();
378
+
379
+		$doWeHaveActions = false;
380
+
381
+		$objectclass = 'odd';
382
+		if (count($this->_objects) > 0) {
383
+			foreach ($this->_objects as $object) {
384
+				$aObject = array();
385
+
386
+				$i = 0;
387
+
388
+				$aColumns = array();
389
+
390
+				foreach ($this->_columns as $column) {
391
+					$aColumn = array();
392
+
393
+					if ($i == 0) {
394
+						$class = 'head';
395
+					} elseif ($i % 2 == 0) {
396
+						$class = 'even';
397
+					} else {
398
+						$class = 'odd';
399
+					}
400
+					if (method_exists($object, 'initiateCustomFields')) {
401
+						//$object->initiateCustomFields();
402
+					}
403
+					if ($column->_keyname === 'checked') {
404
+						$value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
405
+					} elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
406
+						$method = $column->_customMethodForValue;
407
+						if ($column->_param) {
408
+							$value = $object->$method($column->_param);
409
+						} else {
410
+							$value = $object->$method();
411
+						}
412
+					} else {
413
+						/**
414
+						 * If the column is the identifier, then put a link on it
415
+						 */
416
+						if ($column->getKeyName() == $this->_objectHandler->identifierName) {
417
+							$value = $object->getItemLink();
418
+						} else {
419
+							$value = $object->getVar($column->getKeyName());
420
+						}
421
+					}
422
+
423
+					$aColumn['value'] = $value;
424
+					$aColumn['class'] = $class;
425
+					$aColumn['width'] = $column->getWidth();
426
+					$aColumn['align'] = $column->getAlign();
427
+
428
+					$aColumns[] = $aColumn;
429
+					++$i;
430
+				}
431
+
432
+				$aObject['columns'] = $aColumns;
433
+				$aObject['id']      = $object->id();
434
+
435
+				$objectclass = ($objectclass === 'even') ? 'odd' : 'even';
436
+
437
+				$aObject['class'] = $objectclass;
438
+
439
+				$actions = array();
440
+
441
+				// Adding the custom actions if any
442
+				foreach ($this->_custom_actions as $action) {
443
+					if (method_exists($object, $action)) {
444
+						$actions[] = $object->$action();
445
+					}
446
+				}
447
+
448
+				include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
449
+				$controller = new SmartObjectController($this->_objectHandler);
450
+
451
+				if ((!is_array($this->_actions)) || in_array('edit', $this->_actions)) {
452
+					$actions[] = $controller->getEditItemLink($object, false, true, $this->_userSide);
453
+				}
454
+				if ((!is_array($this->_actions)) || in_array('delete', $this->_actions)) {
455
+					$actions[] = $controller->getDeleteItemLink($object, false, true, $this->_userSide);
456
+				}
457
+				$aObject['actions'] = $actions;
458
+
459
+				$this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
460
+
461
+				$doWeHaveActions = $doWeHaveActions ? true : count($actions) > 0;
462
+
463
+				$this->_aObjects[] = $aObject;
464
+			}
465
+			$this->_tpl->assign('smartobject_objects', $this->_aObjects);
466
+		} else {
467
+			$colspan = count($this->_columns) + 1;
468
+			$this->_tpl->assign('smartobject_colspan', $colspan);
469
+		}
470
+		$this->_hasActions = $doWeHaveActions;
471
+	}
472
+
473
+	/**
474
+	 * @param  bool $debug
475
+	 * @return mixed
476
+	 */
477
+	public function fetchObjects($debug = false)
478
+	{
479
+		return $this->_objectHandler->getObjects($this->_criteria, true, true, false, $debug);
480
+	}
481
+
482
+	/**
483
+	 * @return string
484
+	 */
485
+	public function getDefaultFilter()
486
+	{
487
+		if ($this->_filtersel) {
488
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
489
+		} else {
490
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', 'default');
491
+		}
492
+	}
493
+
494
+	/**
495
+	 * @return array|bool
496
+	 */
497
+	public function getFiltersArray()
498
+	{
499
+		$ret               = array();
500
+		$field             = array();
501
+		$field['caption']  = _CO_OBJ_NONE;
502
+		$field['selected'] = '';
503
+		$ret['default']    = $field;
504
+		unset($field);
505
+
506
+		if ($this->_filterseloptions) {
507
+			foreach ($this->_filterseloptions as $key => $value) {
508
+				$field = array();
509
+				if (is_array($value)) {
510
+					$field['caption']  = $key;
511
+					$field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
512
+				} else {
513
+					$field['caption']  = $this->_tempObject->vars[$key]['form_caption'];
514
+					$field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
515
+				}
516
+				$ret[$key] = $field;
517
+				unset($field);
518
+			}
519
+		} else {
520
+			$ret = false;
521
+		}
522
+
523
+		return $ret;
524
+	}
525
+
526
+	/**
527
+	 * @param $default_filter2
528
+	 */
529
+	public function setDefaultFilter2($default_filter2)
530
+	{
531
+		$this->_filtersel2 = $default_filter2;
532
+	}
533
+
534
+	/**
535
+	 * @return string
536
+	 */
537
+	public function getDefaultFilter2()
538
+	{
539
+		if ($this->_filtersel2) {
540
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
541
+		} else {
542
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', 'default');
543
+		}
544
+	}
545
+
546
+	/**
547
+	 * @return array
548
+	 */
549
+	public function getFilters2Array()
550
+	{
551
+		$ret = array();
552
+
553
+		foreach ($this->_filtersel2options as $key => $value) {
554
+			$field             = array();
555
+			$field['caption']  = $value;
556
+			$field['selected'] = $this->_filtersel2 == $key ? "selected='selected'" : '';
557
+			$ret[$key]         = $field;
558
+			unset($field);
559
+		}
560
+
561
+		return $ret;
562
+	}
563
+
564
+	/**
565
+	 * @param $limitsArray
566
+	 * @param $params_of_the_options_sel
567
+	 */
568
+	public function renderOptionSelection($limitsArray, $params_of_the_options_sel)
569
+	{
570
+		// Rendering the form to select options on the table
571
+		$current_urls = smart_getCurrentUrls();
572
+		$current_url  = $current_urls['full'];
573
+
574
+		/**
575
+		 * What was $params_of_the_options_sel doing again ?
576
+		 */
577
+		//$this->_tpl->assign('smartobject_optionssel_action', $_SERVER['PHP_SELF'] . "?" . implode('&', $params_of_the_options_sel));
578
+		$this->_tpl->assign('smartobject_optionssel_action', $current_url);
579
+		$this->_tpl->assign('smartobject_optionssel_limitsArray', $limitsArray);
580
+	}
581
+
582
+	/**
583
+	 * @return array
584
+	 */
585
+	public function getLimitsArray()
586
+	{
587
+		$ret                    = array();
588
+		$ret['all']['caption']  = _CO_SOBJECT_LIMIT_ALL;
589
+		$ret['all']['selected'] = ('all' === $this->_limitsel) ? "selected='selected'" : '';
590
+
591
+		$ret['5']['caption']  = '5';
592
+		$ret['5']['selected'] = ('5' == $this->_limitsel) ? "selected='selected'" : '';
593
+
594
+		$ret['10']['caption']  = '10';
595
+		$ret['10']['selected'] = ('10' == $this->_limitsel) ? "selected='selected'" : '';
596
+
597
+		$ret['15']['caption']  = '15';
598
+		$ret['15']['selected'] = ('15' == $this->_limitsel) ? "selected='selected'" : '';
599
+
600
+		$ret['20']['caption']  = '20';
601
+		$ret['20']['selected'] = ('20' == $this->_limitsel) ? "selected='selected'" : '';
602
+
603
+		$ret['25']['caption']  = '25';
604
+		$ret['25']['selected'] = ('25' == $this->_limitsel) ? "selected='selected'" : '';
605
+
606
+		$ret['30']['caption']  = '30';
607
+		$ret['30']['selected'] = ('30' == $this->_limitsel) ? "selected='selected'" : '';
608
+
609
+		$ret['35']['caption']  = '35';
610
+		$ret['35']['selected'] = ('35' == $this->_limitsel) ? "selected='selected'" : '';
611
+
612
+		$ret['40']['caption']  = '40';
613
+		$ret['40']['selected'] = ('40' == $this->_limitsel) ? "selected='selected'" : '';
614
+
615
+		return $ret;
616
+	}
617
+
618
+	/**
619
+	 * @return bool
620
+	 */
621
+	public function getObjects()
622
+	{
623
+		return $this->_objects;
624
+	}
625
+
626
+	public function hideActionColumnTitle()
627
+	{
628
+		$this->_showActionsColumnTitle = false;
629
+	}
630
+
631
+	public function hideFilterAndLimit()
632
+	{
633
+		$this->_showFilterAndLimit = false;
634
+	}
635
+
636
+	/**
637
+	 * @return array
638
+	 */
639
+	public function getOrdersArray()
640
+	{
641
+		$ret                    = array();
642
+		$ret['ASC']['caption']  = _CO_SOBJECT_SORT_ASC;
643
+		$ret['ASC']['selected'] = ('ASC' === $this->_ordersel) ? "selected='selected'" : '';
644
+
645
+		$ret['DESC']['caption']  = _CO_SOBJECT_SORT_DESC;
646
+		$ret['DESC']['selected'] = ('DESC' === $this->_ordersel) ? "selected='selected'" : '';
647
+
648
+		return $ret;
649
+	}
650
+
651
+	/**
652
+	 * @return mixed|string|void
653
+	 */
654
+	public function renderD()
655
+	{
656
+		return $this->render(false, true);
657
+	}
658
+
659
+	public function renderForPrint()
660
+	{
661
+	}
662
+
663
+	/**
664
+	 * @param  bool $fetchOnly
665
+	 * @param  bool $debug
666
+	 * @return mixed|string|void
667
+	 */
668
+	public function render($fetchOnly = false, $debug = false)
669
+	{
670
+		include_once XOOPS_ROOT_PATH . '/class/template.php';
671
+
672
+		$this->_tpl = new XoopsTpl();
673
+
674
+		/**
675
+		 * We need access to the vars of the SmartObject for a few things in the table creation.
676
+		 * Since we may not have a SmartObject to look into now, let's create one for this purpose
677
+		 * and we will free it after
678
+		 */
679
+		$this->_tempObject = $this->_objectHandler->create();
680
+
681
+		$this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int)$_GET['start' . $this->_objectHandler->keyName] : 0);
682
+
683
+		$this->setSortOrder();
684
+
685
+		if (!$this->_isTree) {
686
+			$this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15');
687
+		} else {
688
+			$this->_limitsel = 'all';
689
+		}
690
+
691
+		$this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
692
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel);
693
+		$limitsArray = $this->getLimitsArray();
694
+		$this->_criteria->setLimit($this->_limitsel);
695
+
696
+		$this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter();
697
+		$this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel;
698
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
699
+		$filtersArray = $this->getFiltersArray();
700
+
701
+		if ($filtersArray) {
702
+			$this->_tpl->assign('smartobject_optionssel_filtersArray', $filtersArray);
703
+		}
704
+
705
+		// Check if the selected filter is defined and if so, create the selfilter2
706
+		if (isset($this->_filterseloptions[$this->_filtersel])) {
707
+			// check if method associate with this filter exists in the handler
708
+			if (is_array($this->_filterseloptions[$this->_filtersel])) {
709
+				$filter = $this->_filterseloptions[$this->_filtersel];
710
+				$this->_criteria->add($filter['criteria']);
711
+			} else {
712
+				if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) {
713
+
714
+					// then we will create the selfilter2 options by calling this method
715
+					$method                   = $this->_filterseloptions[$this->_filtersel];
716
+					$this->_filtersel2options = $this->_objectHandler->$method();
717
+
718
+					$this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2();
719
+					$this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2;
720
+
721
+					$filters2Array = $this->getFilters2Array();
722
+					$this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array);
723
+
724
+					smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
725
+					if ($this->_filtersel2 !== 'default') {
726
+						$this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2));
727
+					}
728
+				}
729
+			}
730
+		}
731
+		// Check if we have a quicksearch
732
+
733
+		if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
734
+			$quicksearch_criteria = new CriteriaCompo();
735
+			if (is_array($this->_quickSearch['fields'])) {
736
+				foreach ($this->_quickSearch['fields'] as $v) {
737
+					$quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
738
+				}
739
+			} else {
740
+				$quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
741
+			}
742
+			$this->_criteria->add($quicksearch_criteria);
743
+		}
744
+
745
+		$this->_objects = $this->fetchObjects($debug);
746
+
747
+		include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
748
+		if ($this->_criteria->getLimit() > 0) {
749
+
750
+			/**
751
+			 * Geeting rid of the old params
752
+			 * $new_get_array is an array containing the new GET parameters
753
+			 */
754
+			$new_get_array = array();
755
+
756
+			/**
757
+			 * $params_of_the_options_sel is an array with all the parameters of the page
758
+			 * but without the pagenave parameters. This array will be used in the
759
+			 * OptionsSelection
760
+			 */
761
+			$params_of_the_options_sel = array();
762
+
763
+			$not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName);
764
+			foreach ($_GET as $k => $v) {
765
+				if (!in_array($k, $not_needed_params)) {
766
+					$new_get_array[]             = "$k=$v";
767
+					$params_of_the_options_sel[] = "$k=$v";
768
+				}
769
+			}
770
+
771
+			/**
772
+			 * Adding the new params of the pagenav
773
+			 */
774
+			$new_get_array[] = 'sortsel=' . $this->_sortsel;
775
+			$new_get_array[] = 'ordersel=' . $this->_ordersel;
776
+			$new_get_array[] = 'limitsel=' . $this->_limitsel;
777
+			$otherParams     = implode('&', $new_get_array);
778
+
779
+			$pagenav =
780
+				new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
781
+			$this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav());
782
+		}
783
+		$this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
784
+
785
+		// retreive the current url and the query string
786
+		$current_urls = smart_getCurrentUrls();
787
+		$current_url  = $current_urls['full_phpself'];
788
+		$query_string = $current_urls['querystring'];
789
+		if ($query_string) {
790
+			$query_string = str_replace('?', '', $query_string);
791
+		}
792
+		$query_stringArray     = explode('&', $query_string);
793
+		$new_query_stringArray = array();
794
+		foreach ($query_stringArray as $query_string) {
795
+			if (strpos($query_string, 'sortsel') == false && strpos($query_string, 'ordersel') == false) {
796
+				$new_query_stringArray[] = $query_string;
797
+			}
798
+		}
799
+		$new_query_string = implode('&', $new_query_stringArray);
800
+
801
+		$orderArray                     = array();
802
+		$orderArray['ASC']['image']     = 'desc.png';
803
+		$orderArray['ASC']['neworder']  = 'DESC';
804
+		$orderArray['DESC']['image']    = 'asc.png';
805
+		$orderArray['DESC']['neworder'] = 'ASC';
806
+
807
+		$aColumns = array();
808
+
809
+		foreach ($this->_columns as $column) {
810
+			$qs_param         = '';
811
+			$aColumn          = array();
812
+			$aColumn['width'] = $column->getWidth();
813
+			$aColumn['align'] = $column->getAlign();
814
+			$aColumn['key']   = $column->getKeyName();
815
+			if ($column->_keyname === 'checked') {
816
+				$aColumn['caption'] = '<input type ="checkbox" id="checkall_smartobjects" name="checkall_smartobjects"'
817
+									  . ' value="checkall_smartobjects" onclick="smartobject_checkall(window.document.form_'
818
+									  . $this->_id
819
+									  . ', \'selected_smartobjects\');" />';
820
+			} elseif ($column->getCustomCaption()) {
821
+				$aColumn['caption'] = $column->getCustomCaption();
822
+			} else {
823
+				$aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName();
824
+			}
825
+			// Are we doing a GET sort on this column ?
826
+			$getSort = (isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName())
827
+					   || ($this->_sortsel == $column->getKeyName());
828
+			$order   = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC';
829
+
830
+			if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') {
831
+				$qs_param = '&quicksearch_' . $this->_id . '=' . $_REQUEST['quicksearch_' . $this->_id];
832
+			}
833
+			if (!$this->_enableColumnsSorting || $column->_keyname === 'checked' || !$column->isSortable()) {
834
+				$aColumn['caption'] = $aColumn['caption'];
835
+			} elseif ($getSort) {
836
+				$aColumn['caption'] = '<a href="'
837
+									  . $current_url
838
+									  . '?'
839
+									  . $this->_objectHandler->_itemname
840
+									  . '_'
841
+									  . 'sortsel='
842
+									  . $column->getKeyName()
843
+									  . '&'
844
+									  . $this->_objectHandler->_itemname
845
+									  . '_'
846
+									  . 'ordersel='
847
+									  . $orderArray[$order]['neworder']
848
+									  . $qs_param
849
+									  . '&'
850
+									  . $new_query_string
851
+									  . '">'
852
+									  . $aColumn['caption']
853
+									  . ' <img src="'
854
+									  . SMARTOBJECT_IMAGES_ACTIONS_URL
855
+									  . $orderArray[$order]['image']
856
+									  . '" alt="ASC" /></a>';
857
+			} else {
858
+				$aColumn['caption'] = '<a href="'
859
+									  . $current_url
860
+									  . '?'
861
+									  . $this->_objectHandler->_itemname
862
+									  . '_'
863
+									  . 'sortsel='
864
+									  . $column->getKeyName()
865
+									  . '&'
866
+									  . $this->_objectHandler->_itemname
867
+									  . '_'
868
+									  . 'ordersel=ASC'
869
+									  . $qs_param
870
+									  . '&'
871
+									  . $new_query_string
872
+									  . '">'
873
+									  . $aColumn['caption']
874
+									  . '</a>';
875
+			}
876
+			$aColumns[] = $aColumn;
877
+		}
878
+		$this->_tpl->assign('smartobject_columns', $aColumns);
879
+
880
+		if ($this->_quickSearch) {
881
+			$this->_tpl->assign('smartobject_quicksearch', $this->_quickSearch['caption']);
882
+		}
883
+
884
+		$this->createTableRows();
885
+
886
+		$this->_tpl->assign('smartobject_showFilterAndLimit', $this->_showFilterAndLimit);
887
+		$this->_tpl->assign('smartobject_isTree', $this->_isTree);
888
+		$this->_tpl->assign('smartobject_show_action_column_title', $this->_showActionsColumnTitle);
889
+		$this->_tpl->assign('smartobject_table_header', $this->_tableHeader);
890
+		$this->_tpl->assign('smartobject_table_footer', $this->_tableFooter);
891
+		$this->_tpl->assign('smartobject_printer_friendly_page', $this->_printerFriendlyPage);
892
+		$this->_tpl->assign('smartobject_user_side', $this->_userSide);
893
+		$this->_tpl->assign('smartobject_has_actions', $this->_hasActions);
894
+		$this->_tpl->assign('smartobject_head_css_class', $this->_head_css_class);
895
+		$this->_tpl->assign('smartobject_actionButtons', $this->_actionButtons);
896
+		$this->_tpl->assign('smartobject_introButtons', $this->_introButtons);
897
+		$this->_tpl->assign('smartobject_id', $this->_id);
898
+		if (!empty($this->_withSelectedActions)) {
899
+			$this->_tpl->assign('smartobject_withSelectedActions', $this->_withSelectedActions);
900
+		}
901
+
902
+		$smartobjectTable_template = $this->_customTemplate ?: 'smartobject_smarttable_display.tpl';
903
+		if ($fetchOnly) {
904
+			return $this->_tpl->fetch('db:' . $smartobjectTable_template);
905
+		} else {
906
+			$this->_tpl->display('db:' . $smartobjectTable_template);
907
+		}
908
+	}
909
+
910
+	public function disableColumnsSorting()
911
+	{
912
+		$this->_enableColumnsSorting = false;
913
+	}
914
+
915
+	/**
916
+	 * @param  bool $debug
917
+	 * @return mixed|string|void
918
+	 */
919
+	public function fetch($debug = false)
920
+	{
921
+		return $this->render(true, $debug);
922
+	}
923 923
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function addActionButton($op, $caption = false, $text = false)
176 176
     {
177
-        $action                 = array(
177
+        $action = array(
178 178
             'op'      => $op,
179 179
             'caption' => $caption,
180 180
             'text'    => $text
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $current_urls               = smart_getCurrentUrls();
211 211
         $current_url                = $current_urls['full'];
212
-        $this->_printerFriendlyPage = $current_url . '&print';
212
+        $this->_printerFriendlyPage = $current_url.'&print';
213 213
     }
214 214
 
215 215
     /**
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function addDefaultIntroButton($caption)
244 244
     {
245
-        $this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page . '?op=mod', $caption);
245
+        $this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page.'?op=mod', $caption);
246 246
     }
247 247
 
248 248
     /**
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
     public function getDefaultSort()
268 268
     {
269 269
         if ($this->_sortsel) {
270
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
270
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_sortsel', $this->_sortsel);
271 271
         } else {
272
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_objectHandler->identifierName);
272
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_sortsel', $this->_objectHandler->identifierName);
273 273
         }
274 274
     }
275 275
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
     public function getDefaultOrder()
288 288
     {
289 289
         if ($this->_ordersel) {
290
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
290
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_ordersel', $this->_ordersel);
291 291
         } else {
292
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', 'ASC');
292
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_ordersel', 'ASC');
293 293
         }
294 294
     }
295 295
 
@@ -338,20 +338,20 @@  discard block
 block discarded – undo
338 338
 
339 339
     public function setSortOrder()
340 340
     {
341
-        $this->_sortsel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] : $this->getDefaultSort();
341
+        $this->_sortsel = isset($_GET[$this->_objectHandler->_itemname.'_'.'sortsel']) ? $_GET[$this->_objectHandler->_itemname.'_'.'sortsel'] : $this->getDefaultSort();
342 342
         //$this->_sortsel = isset($_POST['sortsel']) ? $_POST['sortsel']: $this->_sortsel;
343
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
343
+        smart_setCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_sortsel', $this->_sortsel);
344 344
         $fieldsForSorting = $this->_tempObject->getFieldsForSorting($this->_sortsel);
345 345
 
346 346
         if (isset($this->_tempObject->vars[$this->_sortsel]['itemName']) && $this->_tempObject->vars[$this->_sortsel]['itemName']) {
347
-            $this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'] . '.' . $this->_sortsel);
347
+            $this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'].'.'.$this->_sortsel);
348 348
         } else {
349
-            $this->_criteria->setSort($this->_objectHandler->_itemname . '.' . $this->_sortsel);
349
+            $this->_criteria->setSort($this->_objectHandler->_itemname.'.'.$this->_sortsel);
350 350
         }
351 351
 
352
-        $this->_ordersel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : $this->getDefaultOrder();
352
+        $this->_ordersel = isset($_GET[$this->_objectHandler->_itemname.'_'.'ordersel']) ? $_GET[$this->_objectHandler->_itemname.'_'.'ordersel'] : $this->getDefaultOrder();
353 353
         //$this->_ordersel = isset($_POST['ordersel']) ? $_POST['ordersel']:$this->_ordersel;
354
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
354
+        smart_setCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_ordersel', $this->_ordersel);
355 355
         $ordersArray = $this->getOrdersArray();
356 356
         $this->_criteria->setOrder($this->_ordersel);
357 357
     }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
                         //$object->initiateCustomFields();
402 402
                     }
403 403
                     if ($column->_keyname === 'checked') {
404
-                        $value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
404
+                        $value = '<input type ="checkbox" name="selected_smartobjects[]" value="'.$object->id().'" />';
405 405
                     } elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
406 406
                         $method = $column->_customMethodForValue;
407 407
                         if ($column->_param) {
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                     }
446 446
                 }
447 447
 
448
-                include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
448
+                include_once SMARTOBJECT_ROOT_PATH.'class/smartobjectcontroller.php';
449 449
                 $controller = new SmartObjectController($this->_objectHandler);
450 450
 
451 451
                 if ((!is_array($this->_actions)) || in_array('edit', $this->_actions)) {
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
     public function getDefaultFilter()
486 486
     {
487 487
         if ($this->_filtersel) {
488
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
488
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_filtersel', $this->_filtersel);
489 489
         } else {
490
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', 'default');
490
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_filtersel', 'default');
491 491
         }
492 492
     }
493 493
 
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
     public function getDefaultFilter2()
538 538
     {
539 539
         if ($this->_filtersel2) {
540
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
540
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_filtersel2', $this->_filtersel2);
541 541
         } else {
542
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', 'default');
542
+            return smart_getCookieVar($_SERVER['PHP_SELF'].'_filtersel2', 'default');
543 543
         }
544 544
     }
545 545
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
      */
668 668
     public function render($fetchOnly = false, $debug = false)
669 669
     {
670
-        include_once XOOPS_ROOT_PATH . '/class/template.php';
670
+        include_once XOOPS_ROOT_PATH.'/class/template.php';
671 671
 
672 672
         $this->_tpl = new XoopsTpl();
673 673
 
@@ -678,24 +678,24 @@  discard block
 block discarded – undo
678 678
          */
679 679
         $this->_tempObject = $this->_objectHandler->create();
680 680
 
681
-        $this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int)$_GET['start' . $this->_objectHandler->keyName] : 0);
681
+        $this->_criteria->setStart(isset($_GET['start'.$this->_objectHandler->keyName]) ? (int) $_GET['start'.$this->_objectHandler->keyName] : 0);
682 682
 
683 683
         $this->setSortOrder();
684 684
 
685 685
         if (!$this->_isTree) {
686
-            $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15');
686
+            $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'].'_limitsel', '15');
687 687
         } else {
688 688
             $this->_limitsel = 'all';
689 689
         }
690 690
 
691 691
         $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
692
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel);
692
+        smart_setCookieVar($_SERVER['PHP_SELF'].'_limitsel', $this->_limitsel);
693 693
         $limitsArray = $this->getLimitsArray();
694 694
         $this->_criteria->setLimit($this->_limitsel);
695 695
 
696 696
         $this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter();
697 697
         $this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel;
698
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
698
+        smart_setCookieVar($_SERVER['PHP_SELF'].'_'.$this->_id.'_filtersel', $this->_filtersel);
699 699
         $filtersArray = $this->getFiltersArray();
700 700
 
701 701
         if ($filtersArray) {
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
                     $filters2Array = $this->getFilters2Array();
722 722
                     $this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array);
723 723
 
724
-                    smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
724
+                    smart_setCookieVar($_SERVER['PHP_SELF'].'_filtersel2', $this->_filtersel2);
725 725
                     if ($this->_filtersel2 !== 'default') {
726 726
                         $this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2));
727 727
                     }
@@ -730,21 +730,21 @@  discard block
 block discarded – undo
730 730
         }
731 731
         // Check if we have a quicksearch
732 732
 
733
-        if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
733
+        if (isset($_POST['quicksearch_'.$this->_id]) && $_POST['quicksearch_'.$this->_id] != '') {
734 734
             $quicksearch_criteria = new CriteriaCompo();
735 735
             if (is_array($this->_quickSearch['fields'])) {
736 736
                 foreach ($this->_quickSearch['fields'] as $v) {
737
-                    $quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
737
+                    $quicksearch_criteria->add(new Criteria($v, '%'.$_POST['quicksearch_'.$this->_id].'%', 'LIKE'), 'OR');
738 738
                 }
739 739
             } else {
740
-                $quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
740
+                $quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%'.$_POST['quicksearch_'.$this->_id].'%', 'LIKE'));
741 741
             }
742 742
             $this->_criteria->add($quicksearch_criteria);
743 743
         }
744 744
 
745 745
         $this->_objects = $this->fetchObjects($debug);
746 746
 
747
-        include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
747
+        include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
748 748
         if ($this->_criteria->getLimit() > 0) {
749 749
 
750 750
             /**
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
              */
761 761
             $params_of_the_options_sel = array();
762 762
 
763
-            $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName);
763
+            $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start'.$this->_objectHandler->keyName);
764 764
             foreach ($_GET as $k => $v) {
765 765
                 if (!in_array($k, $not_needed_params)) {
766 766
                     $new_get_array[]             = "$k=$v";
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
             /**
772 772
              * Adding the new params of the pagenav
773 773
              */
774
-            $new_get_array[] = 'sortsel=' . $this->_sortsel;
775
-            $new_get_array[] = 'ordersel=' . $this->_ordersel;
776
-            $new_get_array[] = 'limitsel=' . $this->_limitsel;
774
+            $new_get_array[] = 'sortsel='.$this->_sortsel;
775
+            $new_get_array[] = 'ordersel='.$this->_ordersel;
776
+            $new_get_array[] = 'limitsel='.$this->_limitsel;
777 777
             $otherParams     = implode('&', $new_get_array);
778 778
 
779 779
             $pagenav =
780
-                new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
780
+                new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start'.$this->_objectHandler->keyName, $otherParams);
781 781
             $this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav());
782 782
         }
783 783
         $this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
@@ -823,12 +823,12 @@  discard block
 block discarded – undo
823 823
                 $aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName();
824 824
             }
825 825
             // Are we doing a GET sort on this column ?
826
-            $getSort = (isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName())
826
+            $getSort = (isset($_GET[$this->_objectHandler->_itemname.'_'.'sortsel']) && $_GET[$this->_objectHandler->_itemname.'_'.'sortsel'] == $column->getKeyName())
827 827
                        || ($this->_sortsel == $column->getKeyName());
828
-            $order   = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC';
828
+            $order   = isset($_GET[$this->_objectHandler->_itemname.'_'.'ordersel']) ? $_GET[$this->_objectHandler->_itemname.'_'.'ordersel'] : 'DESC';
829 829
 
830
-            if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') {
831
-                $qs_param = '&quicksearch_' . $this->_id . '=' . $_REQUEST['quicksearch_' . $this->_id];
830
+            if (isset($_REQUEST['quicksearch_'.$this->_id]) && $_REQUEST['quicksearch_'.$this->_id] != '') {
831
+                $qs_param = '&quicksearch_'.$this->_id.'='.$_REQUEST['quicksearch_'.$this->_id];
832 832
             }
833 833
             if (!$this->_enableColumnsSorting || $column->_keyname === 'checked' || !$column->isSortable()) {
834 834
                 $aColumn['caption'] = $aColumn['caption'];
@@ -901,9 +901,9 @@  discard block
 block discarded – undo
901 901
 
902 902
         $smartobjectTable_template = $this->_customTemplate ?: 'smartobject_smarttable_display.tpl';
903 903
         if ($fetchOnly) {
904
-            return $this->_tpl->fetch('db:' . $smartobjectTable_template);
904
+            return $this->_tpl->fetch('db:'.$smartobjectTable_template);
905 905
         } else {
906
-            $this->_tpl->display('db:' . $smartobjectTable_template);
906
+            $this->_tpl->display('db:'.$smartobjectTable_template);
907 907
         }
908 908
     }
909 909
 
Please login to merge, or discard this patch.
class/smarthookhandler.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
6 6
  */
7 7
 class SmartHookHandler
8 8
 {
9
-    /**
10
-     * SmartHookHandler constructor.
11
-     */
12
-    public function __construct()
13
-    {
14
-    }
9
+	/**
10
+	 * SmartHookHandler constructor.
11
+	 */
12
+	public function __construct()
13
+	{
14
+	}
15 15
 
16
-    /**
17
-     * Access the only instance of this class
18
-     *
19
-     * @return XoopsObject
20
-     *
21
-     * @static
22
-     * @staticvar   object
23
-     */
24
-    public static function getInstance()
25
-    {
26
-        static $instance;
27
-        if (null === $instance) {
28
-            $instance = new static();
29
-        }
16
+	/**
17
+	 * Access the only instance of this class
18
+	 *
19
+	 * @return XoopsObject
20
+	 *
21
+	 * @static
22
+	 * @staticvar   object
23
+	 */
24
+	public static function getInstance()
25
+	{
26
+		static $instance;
27
+		if (null === $instance) {
28
+			$instance = new static();
29
+		}
30 30
 
31
-        return $instance;
32
-    }
31
+		return $instance;
32
+	}
33 33
 
34
-    /**
35
-     * @param $hook_name
36
-     */
37
-    public function executeHook($hook_name)
38
-    {
39
-        $lower_hook_name = strtolower($hook_name);
40
-        $filename        = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
41
-        if (file_exists($filename)) {
42
-            include_once($filename);
43
-            $function = 'smarthook_' . $lower_hook_name;
44
-            if (function_exists($function)) {
45
-                $function();
46
-            }
47
-        }
48
-    }
34
+	/**
35
+	 * @param $hook_name
36
+	 */
37
+	public function executeHook($hook_name)
38
+	{
39
+		$lower_hook_name = strtolower($hook_name);
40
+		$filename        = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
41
+		if (file_exists($filename)) {
42
+			include_once($filename);
43
+			$function = 'smarthook_' . $lower_hook_name;
44
+			if (function_exists($function)) {
45
+				$function();
46
+			}
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@
 block discarded – undo
37 37
     public function executeHook($hook_name)
38 38
     {
39 39
         $lower_hook_name = strtolower($hook_name);
40
-        $filename        = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
40
+        $filename        = SMARTOBJECT_ROOT_PATH.'include/custom_code/'.$lower_hook_name.'.php';
41 41
         if (file_exists($filename)) {
42 42
             include_once($filename);
43
-            $function = 'smarthook_' . $lower_hook_name;
43
+            $function = 'smarthook_'.$lower_hook_name;
44 44
             if (function_exists($function)) {
45 45
                 $function();
46 46
             }
Please login to merge, or discard this patch.
class/smartexport.php 2 patches
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -19,110 +19,110 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class SmartObjectExport
21 21
 {
22
-    public $handler;
23
-    public $criteria;
24
-    public $fields;
25
-    public $format;
26
-    public $filename;
27
-    public $filepath;
28
-    public $options;
29
-    public $outputMethods = false;
30
-    public $notDisplayFields;
22
+	public $handler;
23
+	public $criteria;
24
+	public $fields;
25
+	public $format;
26
+	public $filename;
27
+	public $filepath;
28
+	public $options;
29
+	public $outputMethods = false;
30
+	public $notDisplayFields;
31 31
 
32
-    /**
33
-     * Constructor
34
-     *
35
-     * @param SmartPersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export
36
-     * @param CriteriaElement      $criteria      containing the criteria of the query fetching the objects to be exported
37
-     * @param array|bool  $fields        fields to be exported. If FALSE then all fields will be exported
38
-     * @param bool|string $filename      name of the file to be created
39
-     * @param bool|string $filepath      path where the file will be saved
40
-     * @param string      $format        format of the ouputed export. Currently only supports CSV
41
-     * @param array|bool  $options       options of the format to be exported in
42
-     */
43
-    public function __construct(SmartPersistableObjectHandler $objectHandler, CriteriaElement $criteria = null, $fields = false, $filename = false, $filepath = false, $format = 'csv', $options = false)
44
-    {
45
-        $this->handler          = $objectHandler;
46
-        $this->criteria         = $criteria;
47
-        $this->fields           = $fields;
48
-        $this->filename         = $filename;
49
-        $this->format           = $format;
50
-        $this->options          = $options;
51
-        $this->notDisplayFields = false;
52
-    }
32
+	/**
33
+	 * Constructor
34
+	 *
35
+	 * @param SmartPersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export
36
+	 * @param CriteriaElement      $criteria      containing the criteria of the query fetching the objects to be exported
37
+	 * @param array|bool  $fields        fields to be exported. If FALSE then all fields will be exported
38
+	 * @param bool|string $filename      name of the file to be created
39
+	 * @param bool|string $filepath      path where the file will be saved
40
+	 * @param string      $format        format of the ouputed export. Currently only supports CSV
41
+	 * @param array|bool  $options       options of the format to be exported in
42
+	 */
43
+	public function __construct(SmartPersistableObjectHandler $objectHandler, CriteriaElement $criteria = null, $fields = false, $filename = false, $filepath = false, $format = 'csv', $options = false)
44
+	{
45
+		$this->handler          = $objectHandler;
46
+		$this->criteria         = $criteria;
47
+		$this->fields           = $fields;
48
+		$this->filename         = $filename;
49
+		$this->format           = $format;
50
+		$this->options          = $options;
51
+		$this->notDisplayFields = false;
52
+	}
53 53
 
54
-    /**
55
-     * Renders the export
56
-     * @param $filename
57
-     */
58
-    public function render($filename)
59
-    {
60
-        $this->filename = $filename;
54
+	/**
55
+	 * Renders the export
56
+	 * @param $filename
57
+	 */
58
+	public function render($filename)
59
+	{
60
+		$this->filename = $filename;
61 61
 
62
-        $objects        = $this->handler->getObjects($this->criteria);
63
-        $rows           = array();
64
-        $columnsHeaders = array();
65
-        $firstObject    = true;
66
-        foreach ($objects as $object) {
67
-            $row = array();
68
-            foreach ($object->vars as $key => $var) {
69
-                if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
70
-                    if ($this->outputMethods && isset($this->outputMethods[$key]) && method_exists($object, $this->outputMethods[$key])) {
71
-                        $method    = $this->outputMethods[$key];
72
-                        $row[$key] = $object->$method();
73
-                    } else {
74
-                        $row[$key] = $object->getVar($key);
75
-                    }
76
-                    if ($firstObject) {
77
-                        // then set the columnsHeaders array as well
78
-                        $columnsHeaders[$key] = $var['form_caption'];
79
-                    }
80
-                }
81
-            }
82
-            $firstObject = false;
83
-            $rows[]      = $row;
84
-            unset($row);
85
-        }
86
-        $data                   = array();
87
-        $data['rows']           = $rows;
88
-        $data['columnsHeaders'] = $columnsHeaders;
89
-        $smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
90
-        $smartExportRenderer->execute();
91
-    }
62
+		$objects        = $this->handler->getObjects($this->criteria);
63
+		$rows           = array();
64
+		$columnsHeaders = array();
65
+		$firstObject    = true;
66
+		foreach ($objects as $object) {
67
+			$row = array();
68
+			foreach ($object->vars as $key => $var) {
69
+				if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
70
+					if ($this->outputMethods && isset($this->outputMethods[$key]) && method_exists($object, $this->outputMethods[$key])) {
71
+						$method    = $this->outputMethods[$key];
72
+						$row[$key] = $object->$method();
73
+					} else {
74
+						$row[$key] = $object->getVar($key);
75
+					}
76
+					if ($firstObject) {
77
+						// then set the columnsHeaders array as well
78
+						$columnsHeaders[$key] = $var['form_caption'];
79
+					}
80
+				}
81
+			}
82
+			$firstObject = false;
83
+			$rows[]      = $row;
84
+			unset($row);
85
+		}
86
+		$data                   = array();
87
+		$data['rows']           = $rows;
88
+		$data['columnsHeaders'] = $columnsHeaders;
89
+		$smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
90
+		$smartExportRenderer->execute();
91
+	}
92 92
 
93
-    /**
94
-     * Set an array contaning the alternate methods to use instead of the default getVar()
95
-     *
96
-     * $outputMethods array example: 'uid' => 'getUserName'...
97
-     * @param $outputMethods
98
-     */
99
-    public function setOuptutMethods($outputMethods)
100
-    {
101
-        $this->outputMethods = $outputMethods;
102
-    }
93
+	/**
94
+	 * Set an array contaning the alternate methods to use instead of the default getVar()
95
+	 *
96
+	 * $outputMethods array example: 'uid' => 'getUserName'...
97
+	 * @param $outputMethods
98
+	 */
99
+	public function setOuptutMethods($outputMethods)
100
+	{
101
+		$this->outputMethods = $outputMethods;
102
+	}
103 103
 
104
-    /*
104
+	/*
105 105
      * Set an array of fields that we don't want in export
106 106
      */
107
-    /**
108
-     * @param $fields
109
-     */
110
-    public function setNotDisplayFields($fields)
111
-    {
112
-        if (!$this->notDisplayFields) {
113
-            if (is_array($fields)) {
114
-                $this->notDisplayFields = $fields;
115
-            } else {
116
-                $this->notDisplayFields = array($fields);
117
-            }
118
-        } else {
119
-            if (is_array($fields)) {
120
-                $this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
121
-            } else {
122
-                $this->notDisplayFields[] = $fields;
123
-            }
124
-        }
125
-    }
107
+	/**
108
+	 * @param $fields
109
+	 */
110
+	public function setNotDisplayFields($fields)
111
+	{
112
+		if (!$this->notDisplayFields) {
113
+			if (is_array($fields)) {
114
+				$this->notDisplayFields = $fields;
115
+			} else {
116
+				$this->notDisplayFields = array($fields);
117
+			}
118
+		} else {
119
+			if (is_array($fields)) {
120
+				$this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
121
+			} else {
122
+				$this->notDisplayFields[] = $fields;
123
+			}
124
+		}
125
+	}
126 126
 }
127 127
 
128 128
 /**
@@ -136,181 +136,181 @@  discard block
 block discarded – undo
136 136
  */
137 137
 class SmartExportRenderer
138 138
 {
139
-    public $data;
140
-    public $format;
141
-    public $filename;
142
-    public $filepath;
143
-    public $options;
139
+	public $data;
140
+	public $format;
141
+	public $filename;
142
+	public $filepath;
143
+	public $options;
144 144
 
145
-    /**
146
-     * Constructor
147
-     *
148
-     * @param array       $data     contains the data to be exported
149
-     * @param bool|string $filename name of the file in which the exported data will be saved
150
-     * @param bool|string $filepath path where the file will be saved
151
-     * @param string      $format   format of the ouputed export. Currently only supports CSV
152
-     * @param array       $options  options of the format to be exported in
153
-     */
154
-    public function __construct($data, $filename = false, $filepath = false, $format = 'csv', $options = array('separator' => ';'))
155
-    {
156
-        $this->data     = $data;
157
-        $this->format   = $format;
158
-        $this->filename = $filename;
159
-        $this->filepath = $filepath;
160
-        $this->options  = $options;
161
-    }
145
+	/**
146
+	 * Constructor
147
+	 *
148
+	 * @param array       $data     contains the data to be exported
149
+	 * @param bool|string $filename name of the file in which the exported data will be saved
150
+	 * @param bool|string $filepath path where the file will be saved
151
+	 * @param string      $format   format of the ouputed export. Currently only supports CSV
152
+	 * @param array       $options  options of the format to be exported in
153
+	 */
154
+	public function __construct($data, $filename = false, $filepath = false, $format = 'csv', $options = array('separator' => ';'))
155
+	{
156
+		$this->data     = $data;
157
+		$this->format   = $format;
158
+		$this->filename = $filename;
159
+		$this->filepath = $filepath;
160
+		$this->options  = $options;
161
+	}
162 162
 
163
-    /**
164
-     * @param         $dataArray
165
-     * @param         $separator
166
-     * @param  string $trim
167
-     * @param  bool   $removeEmptyLines
168
-     * @return string
169
-     */
170
-    public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
171
-    {
172
-        if (!is_array($dataArray) || empty($dataArray)) {
173
-            return '';
174
-        }
175
-        switch ($trim) {
176
-            case 'none':
177
-                $trimFunction = false;
178
-                break;
179
-            case 'left':
180
-                $trimFunction = 'ltrim';
181
-                break;
182
-            case 'right':
183
-                $trimFunction = 'rtrim';
184
-                break;
185
-            default: //'both':
186
-                $trimFunction = 'trim';
187
-                break;
188
-        }
189
-        $ret = array();
190
-        foreach ($dataArray as $key => $field) {
191
-            $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
192
-        }
163
+	/**
164
+	 * @param         $dataArray
165
+	 * @param         $separator
166
+	 * @param  string $trim
167
+	 * @param  bool   $removeEmptyLines
168
+	 * @return string
169
+	 */
170
+	public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
171
+	{
172
+		if (!is_array($dataArray) || empty($dataArray)) {
173
+			return '';
174
+		}
175
+		switch ($trim) {
176
+			case 'none':
177
+				$trimFunction = false;
178
+				break;
179
+			case 'left':
180
+				$trimFunction = 'ltrim';
181
+				break;
182
+			case 'right':
183
+				$trimFunction = 'rtrim';
184
+				break;
185
+			default: //'both':
186
+				$trimFunction = 'trim';
187
+				break;
188
+		}
189
+		$ret = array();
190
+		foreach ($dataArray as $key => $field) {
191
+			$ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
192
+		}
193 193
 
194
-        return implode($separator, $ret);
195
-    }
194
+		return implode($separator, $ret);
195
+	}
196 196
 
197
-    /**
198
-     * @param $val
199
-     * @param $separator
200
-     * @param $trimFunction
201
-     * @return mixed|string
202
-     */
203
-    public function valToCsvHelper($val, $separator, $trimFunction)
204
-    {
205
-        if ($trimFunction) {
206
-            $val = $trimFunction ($val);
207
-        }
208
-        //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
209
-        $needQuote = false;
210
-        do {
211
-            if (strpos($val, '"') !== false) {
212
-                $val       = str_replace('"', '""', $val);
213
-                $needQuote = true;
214
-                break;
215
-            }
216
-            if (strpos($val, $separator) !== false) {
217
-                $needQuote = true;
218
-                break;
219
-            }
220
-            if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac
221
-                $needQuote = true;
222
-                break;
223
-            }
224
-        } while (false);
225
-        if ($needQuote) {
226
-            $val = '"' . $val . '"';
227
-        }
197
+	/**
198
+	 * @param $val
199
+	 * @param $separator
200
+	 * @param $trimFunction
201
+	 * @return mixed|string
202
+	 */
203
+	public function valToCsvHelper($val, $separator, $trimFunction)
204
+	{
205
+		if ($trimFunction) {
206
+			$val = $trimFunction ($val);
207
+		}
208
+		//If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
209
+		$needQuote = false;
210
+		do {
211
+			if (strpos($val, '"') !== false) {
212
+				$val       = str_replace('"', '""', $val);
213
+				$needQuote = true;
214
+				break;
215
+			}
216
+			if (strpos($val, $separator) !== false) {
217
+				$needQuote = true;
218
+				break;
219
+			}
220
+			if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac
221
+				$needQuote = true;
222
+				break;
223
+			}
224
+		} while (false);
225
+		if ($needQuote) {
226
+			$val = '"' . $val . '"';
227
+		}
228 228
 
229
-        return $val;
230
-    }
229
+		return $val;
230
+	}
231 231
 
232
-    public function execute()
233
-    {
234
-        $exportFileData = '';
232
+	public function execute()
233
+	{
234
+		$exportFileData = '';
235 235
 
236
-        switch ($this->format) {
237
-            case 'csv':
238
-                $separator = isset($this->options['separator']) ? $this->options['separator'] : ';';
239
-                $firstRow  = implode($separator, $this->data['columnsHeaders']);
240
-                $exportFileData .= $firstRow . "\r\n";
236
+		switch ($this->format) {
237
+			case 'csv':
238
+				$separator = isset($this->options['separator']) ? $this->options['separator'] : ';';
239
+				$firstRow  = implode($separator, $this->data['columnsHeaders']);
240
+				$exportFileData .= $firstRow . "\r\n";
241 241
 
242
-                foreach ($this->data['rows'] as $cols) {
243
-                    $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
244
-                }
245
-                break;
246
-        }
247
-        $this->saveExportFile($exportFileData);
248
-    }
242
+				foreach ($this->data['rows'] as $cols) {
243
+					$exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
244
+				}
245
+				break;
246
+		}
247
+		$this->saveExportFile($exportFileData);
248
+	}
249 249
 
250
-    /**
251
-     * @param $content
252
-     */
253
-    public function saveExportFile($content)
254
-    {
255
-        switch ($this->format) {
256
-            case 'csv':
257
-                $this->saveCsv($content);
258
-                break;
259
-        }
260
-    }
250
+	/**
251
+	 * @param $content
252
+	 */
253
+	public function saveExportFile($content)
254
+	{
255
+		switch ($this->format) {
256
+			case 'csv':
257
+				$this->saveCsv($content);
258
+				break;
259
+		}
260
+	}
261 261
 
262
-    /**
263
-     * @param $content
264
-     */
265
-    public function saveCsv($content)
266
-    {
267
-        if (!$this->filepath) {
268
-            $this->filepath = XOOPS_UPLOAD_PATH . '/';
269
-        }
270
-        if (!$this->filename) {
271
-            $this->filename .= time();
272
-            $this->filename .= '.csv';
273
-        }
262
+	/**
263
+	 * @param $content
264
+	 */
265
+	public function saveCsv($content)
266
+	{
267
+		if (!$this->filepath) {
268
+			$this->filepath = XOOPS_UPLOAD_PATH . '/';
269
+		}
270
+		if (!$this->filename) {
271
+			$this->filename .= time();
272
+			$this->filename .= '.csv';
273
+		}
274 274
 
275
-        $fullFileName = $this->filepath . $this->filename;
275
+		$fullFileName = $this->filepath . $this->filename;
276 276
 
277
-        if (!$handle = fopen($fullFileName, 'a+')) {
278
-            trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
279
-        } elseif (fwrite($handle, $content) === false) {
280
-            trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
281
-        } else {
282
-            $mimeType  = 'text/csv';
283
-            $file      = strrev($this->filename);
284
-            $temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
285
-            if ($temp_name === '') {
286
-                $file_name = $this->filename;
287
-            } else {
288
-                $file_name = $temp_name;
289
-            }
290
-            $fullFileName = $this->filepath . stripslashes(trim($this->filename));
277
+		if (!$handle = fopen($fullFileName, 'a+')) {
278
+			trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
279
+		} elseif (fwrite($handle, $content) === false) {
280
+			trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
281
+		} else {
282
+			$mimeType  = 'text/csv';
283
+			$file      = strrev($this->filename);
284
+			$temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
285
+			if ($temp_name === '') {
286
+				$file_name = $this->filename;
287
+			} else {
288
+				$file_name = $temp_name;
289
+			}
290
+			$fullFileName = $this->filepath . stripslashes(trim($this->filename));
291 291
 
292
-            if (ini_get('zlib.output_compression')) {
293
-                ini_set('zlib.output_compression', 'Off');
294
-            }
292
+			if (ini_get('zlib.output_compression')) {
293
+				ini_set('zlib.output_compression', 'Off');
294
+			}
295 295
 
296
-            header('Pragma: public');
297
-            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
298
-            header('Cache-Control: private', false);
299
-            header('Content-Transfer-Encoding: binary');
300
-            if (isset($mimeType)) {
301
-                header('Content-Type: ' . $mimeType);
302
-            }
296
+			header('Pragma: public');
297
+			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
298
+			header('Cache-Control: private', false);
299
+			header('Content-Transfer-Encoding: binary');
300
+			if (isset($mimeType)) {
301
+				header('Content-Type: ' . $mimeType);
302
+			}
303 303
 
304
-            header('Content-Disposition: attachment; filename=' . $file_name);
304
+			header('Content-Disposition: attachment; filename=' . $file_name);
305 305
 
306
-            if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
307
-                $fp = fopen($fullFileName, 'r');
308
-            } else {
309
-                $fp = fopen($fullFileName, 'rb');
310
-            }
311
-            fpassthru($fp);
312
-            exit();
313
-        }
314
-        fclose($handle);
315
-    }
306
+			if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
307
+				$fp = fopen($fullFileName, 'r');
308
+			} else {
309
+				$fp = fopen($fullFileName, 'rb');
310
+			}
311
+			fpassthru($fp);
312
+			exit();
313
+		}
314
+		fclose($handle);
315
+	}
316 316
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     public function valToCsvHelper($val, $separator, $trimFunction)
204 204
     {
205 205
         if ($trimFunction) {
206
-            $val = $trimFunction ($val);
206
+            $val = $trimFunction($val);
207 207
         }
208 208
         //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
209 209
         $needQuote = false;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             }
224 224
         } while (false);
225 225
         if ($needQuote) {
226
-            $val = '"' . $val . '"';
226
+            $val = '"'.$val.'"';
227 227
         }
228 228
 
229 229
         return $val;
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
             case 'csv':
238 238
                 $separator = isset($this->options['separator']) ? $this->options['separator'] : ';';
239 239
                 $firstRow  = implode($separator, $this->data['columnsHeaders']);
240
-                $exportFileData .= $firstRow . "\r\n";
240
+                $exportFileData .= $firstRow."\r\n";
241 241
 
242 242
                 foreach ($this->data['rows'] as $cols) {
243
-                    $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
243
+                    $exportFileData .= $this->arrayToCsvString($cols, $separator)."\r\n";
244 244
                 }
245 245
                 break;
246 246
         }
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
     public function saveCsv($content)
266 266
     {
267 267
         if (!$this->filepath) {
268
-            $this->filepath = XOOPS_UPLOAD_PATH . '/';
268
+            $this->filepath = XOOPS_UPLOAD_PATH.'/';
269 269
         }
270 270
         if (!$this->filename) {
271 271
             $this->filename .= time();
272 272
             $this->filename .= '.csv';
273 273
         }
274 274
 
275
-        $fullFileName = $this->filepath . $this->filename;
275
+        $fullFileName = $this->filepath.$this->filename;
276 276
 
277 277
         if (!$handle = fopen($fullFileName, 'a+')) {
278
-            trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
278
+            trigger_error('Unable to open '.$fullFileName, E_USER_WARNING);
279 279
         } elseif (fwrite($handle, $content) === false) {
280
-            trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
280
+            trigger_error('Unable to write in '.$fullFileName, E_USER_WARNING);
281 281
         } else {
282 282
             $mimeType  = 'text/csv';
283 283
             $file      = strrev($this->filename);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
             } else {
288 288
                 $file_name = $temp_name;
289 289
             }
290
-            $fullFileName = $this->filepath . stripslashes(trim($this->filename));
290
+            $fullFileName = $this->filepath.stripslashes(trim($this->filename));
291 291
 
292 292
             if (ini_get('zlib.output_compression')) {
293 293
                 ini_set('zlib.output_compression', 'Off');
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
             header('Cache-Control: private', false);
299 299
             header('Content-Transfer-Encoding: binary');
300 300
             if (isset($mimeType)) {
301
-                header('Content-Type: ' . $mimeType);
301
+                header('Content-Type: '.$mimeType);
302 302
             }
303 303
 
304
-            header('Content-Disposition: attachment; filename=' . $file_name);
304
+            header('Content-Disposition: attachment; filename='.$file_name);
305 305
 
306 306
             if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
307 307
                 $fp = fopen($fullFileName, 'r');
Please login to merge, or discard this patch.
class/smartobjecttag.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class SmartobjectTag extends SmartMlObject
37 37
 {
38
-    /**
39
-     * SmartobjectTag constructor.
40
-     */
41
-    public function __construct()
42
-    {
43
-        $this->initVar('tagid', XOBJ_DTYPE_INT, '', true);
44
-        $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true);
45
-        $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC);
46
-        $this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC);
38
+	/**
39
+	 * SmartobjectTag constructor.
40
+	 */
41
+	public function __construct()
42
+	{
43
+		$this->initVar('tagid', XOBJ_DTYPE_INT, '', true);
44
+		$this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true);
45
+		$this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC);
46
+		$this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC);
47 47
 
48
-        // call parent constructor to get Multilanguage field initiated
49
-        $this->SmartMlObject();
50
-    }
48
+		// call parent constructor to get Multilanguage field initiated
49
+		$this->SmartMlObject();
50
+	}
51 51
 }
52 52
 
53 53
 /**
@@ -55,27 +55,27 @@  discard block
 block discarded – undo
55 55
  */
56 56
 class SmartobjectTagHandler extends SmartPersistableMlObjectHandler
57 57
 {
58
-    /**
59
-     * SmartobjectTagHandler constructor.
60
-     * @param XoopsDatabase $db
61
-     */
62
-    public function __construct(XoopsDatabase $db)
63
-    {
64
-        parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject');
65
-    }
58
+	/**
59
+	 * SmartobjectTagHandler constructor.
60
+	 * @param XoopsDatabase $db
61
+	 */
62
+	public function __construct(XoopsDatabase $db)
63
+	{
64
+		parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject');
65
+	}
66 66
 
67
-    /**
68
-     * @return mixed
69
-     */
70
-    public function getLanguages()
71
-    {
72
-        include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
73
-        $aLanguages     = XoopsLists::getLangList();
74
-        $ret['default'] = _CO_SOBJECT_ALL;
75
-        foreach ($aLanguages as $lang) {
76
-            $ret[$lang] = $lang;
77
-        }
67
+	/**
68
+	 * @return mixed
69
+	 */
70
+	public function getLanguages()
71
+	{
72
+		include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
73
+		$aLanguages     = XoopsLists::getLangList();
74
+		$ret['default'] = _CO_SOBJECT_ALL;
75
+		foreach ($aLanguages as $lang) {
76
+			$ret[$lang] = $lang;
77
+		}
78 78
 
79
-        return $ret;
80
-    }
79
+		return $ret;
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // -------------------------------------------------------------------------//
29 29
 
30 30
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
31
-include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartmlobject.php';
31
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartmlobject.php';
32 32
 
33 33
 /**
34 34
  * Class SmartobjectTag
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getLanguages()
71 71
     {
72
-        include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
72
+        include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
73 73
         $aLanguages     = XoopsLists::getLangList();
74 74
         $ret['default'] = _CO_SOBJECT_ALL;
75 75
         foreach ($aLanguages as $lang) {
Please login to merge, or discard this patch.
class/smartmetagen.php 2 patches
Indentation   +348 added lines, -348 removed lines patch added patch discarded remove patch
@@ -18,320 +18,320 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class SmartMetaGen
20 20
 {
21
-    public $_myts;
22
-
23
-    public $_title;
24
-    public $_original_title;
25
-    public $_keywords;
26
-    public $_meta_description;
27
-    public $_categoryPath;
28
-    public $_description;
29
-    public $_minChar = 4;
30
-
31
-    /**
32
-     * SmartMetaGen constructor.
33
-     * @param      $title
34
-     * @param bool $keywords
35
-     * @param bool $description
36
-     * @param bool $categoryPath
37
-     */
38
-    public function __construct($title, $keywords = false, $description = false, $categoryPath = false)
39
-    {
40
-        $this->_myts = MyTextSanitizer::getInstance();
41
-        $this->setCategoryPath($categoryPath);
42
-        $this->setTitle($title);
43
-        $this->setDescription($description);
44
-
45
-        if (!$keywords) {
46
-            $keywords = $this->createMetaKeywords();
47
-        }
48
-
49
-        /*      $myts = MyTextSanitizer::getInstance();
21
+	public $_myts;
22
+
23
+	public $_title;
24
+	public $_original_title;
25
+	public $_keywords;
26
+	public $_meta_description;
27
+	public $_categoryPath;
28
+	public $_description;
29
+	public $_minChar = 4;
30
+
31
+	/**
32
+	 * SmartMetaGen constructor.
33
+	 * @param      $title
34
+	 * @param bool $keywords
35
+	 * @param bool $description
36
+	 * @param bool $categoryPath
37
+	 */
38
+	public function __construct($title, $keywords = false, $description = false, $categoryPath = false)
39
+	{
40
+		$this->_myts = MyTextSanitizer::getInstance();
41
+		$this->setCategoryPath($categoryPath);
42
+		$this->setTitle($title);
43
+		$this->setDescription($description);
44
+
45
+		if (!$keywords) {
46
+			$keywords = $this->createMetaKeywords();
47
+		}
48
+
49
+		/*      $myts = MyTextSanitizer::getInstance();
50 50
          if (method_exists($myts, 'formatForML')) {
51 51
          $keywords = $myts->formatForML($keywords);
52 52
          $description = $myts->formatForML($description);
53 53
          }
54 54
          */
55
-        $this->setKeywords($keywords);
56
-    }
57
-
58
-    /**
59
-     * Return true if the string is length > 0
60
-     *
61
-     * @credit psylove
62
-     *
63
-     * @var    string  $string Chaine de caract�re
64
-     * @return boolean
65
-     */
66
-    public function emptyString($var)
67
-    {
68
-        return (strlen($var) > 0);
69
-    }
70
-
71
-    /**
72
-     * Create a title for the short_url field of an article
73
-     *
74
-     * @credit psylove
75
-     *
76
-     * @var    string      $title title of the article
77
-     * @param  bool|string $withExt
78
-     * @return string      sort_url for the article
79
-     */
80
-    public function generateSeoTitle($title = '', $withExt = true)
81
-    {
82
-        // Transformation de la chaine en minuscule
83
-        // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus
84
-        $title = rawurlencode(strtolower($title));
85
-
86
-        // Transformation des ponctuations
87
-        $pattern = array(
88
-            '/%09/', // Tab
89
-            '/%20/', // Space
90
-            '/%21/', // !
91
-            '/%22/', // "
92
-            '/%23/', // #
93
-            '/%25/', // %
94
-            '/%26/', // &
95
-            '/%27/', // '
96
-            '/%28/', // (
97
-            '/%29/', // )
98
-            '/%2C/', // ,
99
-            '/%2F/', // /
100
-            '/%3A/', // :
101
-            '/%3B/', // ;
102
-            '/%3C/', // <
103
-            '/%3D/', // =
104
-            '/%3E/', // >
105
-            '/%3F/', // ?
106
-            '/%40/', // @
107
-            '/%5B/', // [
108
-            '/%5C/', // \
109
-            '/%5D/', // ]
110
-            '/%5E/', // ^
111
-            '/%7B/', // {
112
-            '/%7C/', // |
113
-            '/%7D/', // }
114
-            '/%7E/', // ~
115
-            "/\./" // .
116
-        );
117
-        $rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
118
-        $title   = preg_replace($pattern, $rep_pat, $title);
119
-
120
-        // Transformation des caract�res accentu�s
121
-        $pattern = array(
122
-            '/%B0/', // °
123
-            '/%E8/', // è
124
-            '/%E9/', // é
125
-            '/%EA/', // ê
126
-            '/%EB/', // ë
127
-            '/%E7/', // ç
128
-            '/%E0/', // à
129
-            '/%E2/', // â
130
-            '/%E4/', // ä
131
-            '/%EE/', // î
132
-            '/%EF/', // ï
133
-            '/%F9/', // ù
134
-            '/%FC/', // ü
135
-            '/%FB/', // û
136
-            '/%F4/', // ô
137
-            '/%F6/', // ö
138
-        );        
139
-        $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
140
-        $title   = preg_replace($pattern, $rep_pat, $title);
141
-
142
-        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
143
-        $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
144
-        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
145
-
146
-        if (count($title) > 0) {
147
-            if ($withExt) {
148
-                $title .= '.html';
149
-            }
150
-
151
-            return $title;
152
-        } else {
153
-            return '';
154
-        }
155
-    }
156
-
157
-    /**
158
-     * @param $document
159
-     * @return mixed
160
-     */
161
-    public function html2text($document)
162
-    {
163
-        return smart_html2text($document);
164
-    }
165
-
166
-    /**
167
-     * @param $title
168
-     */
169
-    public function setTitle($title)
170
-    {
171
-        global $xoopsModule, $xoopsModuleConfig;
172
-        $this->_title          = $this->html2text($title);
173
-        $this->_title          = $this->purifyText($this->_title);
174
-        $this->_original_title = $this->_title;
175
-
176
-        $moduleName = $xoopsModule->getVar('name');
177
-
178
-        $titleTag = array();
179
-
180
-        $show_mod_name_breadcrumb = isset($xoopsModuleConfig['show_mod_name_breadcrumb']) ? $xoopsModuleConfig['show_mod_name_breadcrumb'] : true;
181
-
182
-        if ($moduleName && $show_mod_name_breadcrumb) {
183
-            $titleTag['module'] = $moduleName;
184
-        }
185
-
186
-        if (isset($this->_title) && ($this->_title !== '') && (strtoupper($this->_title) != strtoupper($moduleName))) {
187
-            $titleTag['title'] = $this->_title;
188
-        }
189
-
190
-        if (isset($this->_categoryPath) && ($this->_categoryPath !== '')) {
191
-            $titleTag['category'] = $this->_categoryPath;
192
-        }
193
-
194
-        $ret = isset($titleTag['title']) ? $titleTag['title'] : '';
195
-
196
-        if (isset($titleTag['category']) && $titleTag['category'] !== '') {
197
-            if ($ret !== '') {
198
-                $ret .= ' - ';
199
-            }
200
-            $ret .= $titleTag['category'];
201
-        }
202
-        if (isset($titleTag['module']) && $titleTag['module'] !== '') {
203
-            if ($ret !== '') {
204
-                $ret .= ' - ';
205
-            }
206
-            $ret .= $titleTag['module'];
207
-        }
208
-        $this->_title = $ret;
209
-    }
210
-
211
-    /**
212
-     * @param $keywords
213
-     */
214
-    public function setKeywords($keywords)
215
-    {
216
-        $this->_keywords = $keywords;
217
-    }
218
-
219
-    /**
220
-     * @param $categoryPath
221
-     */
222
-    public function setCategoryPath($categoryPath)
223
-    {
224
-        $categoryPath        = $this->html2text($categoryPath);
225
-        $this->_categoryPath = $categoryPath;
226
-    }
227
-
228
-    /**
229
-     * @param $description
230
-     */
231
-    public function setDescription($description)
232
-    {
233
-        if (!$description) {
234
-            global $xoopsModuleConfig;
235
-            if (isset($xoopsModuleConfig['module_meta_description'])) {
236
-                $description = $xoopsModuleConfig['module_meta_description'];
237
-            }
238
-        }
239
-
240
-        $description = $this->html2text($description);
241
-        $description = $this->purifyText($description);
242
-
243
-        $description = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $description);
244
-        $description = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $description);
245
-        $description = preg_replace('/[ ]* [ ]*/', ' ', $description);
246
-        $description = stripslashes($description);
247
-
248
-        $this->_description      = $description;
249
-        $this->_meta_description = $this->createMetaDescription();
250
-    }
251
-
252
-    public function createTitleTag()
253
-    {
254
-    }
255
-
256
-    /**
257
-     * @param               $text
258
-     * @param  bool         $keyword
259
-     * @return mixed|string
260
-     */
261
-    public function purifyText($text, $keyword = false)
262
-    {
263
-        return smart_purifyText($text, $keyword);
264
-    }
265
-
266
-    /**
267
-     * @param  int    $maxWords
268
-     * @return string
269
-     */
270
-    public function createMetaDescription($maxWords = 100)
271
-    {
272
-        $words = array();
273
-        $words = explode(' ', $this->_description);
274
-
275
-        // Only keep $maxWords words
276
-        $newWords = array();
277
-        $i        = 0;
278
-
279
-        while ($i < $maxWords - 1 && $i < count($words)) {
280
-            $newWords[] = $words[$i];
281
-            ++$i;
282
-        }
283
-        $ret = implode(' ', $newWords);
284
-
285
-        return $ret;
286
-    }
287
-
288
-    /**
289
-     * @param $text
290
-     * @param $minChar
291
-     * @return array
292
-     */
293
-    public function findMetaKeywords($text, $minChar)
294
-    {
295
-        $keywords = array();
296
-
297
-        $text = $this->purifyText($text);
298
-        $text = $this->html2text($text);
299
-
300
-        $text = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $text);
301
-        $text = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $text);
302
-        $text = preg_replace('/[ ]* [ ]*/', ' ', $text);
303
-        $text = stripslashes($text);
304
-        $text =
305
-
306
-        $originalKeywords = preg_split('/[^a-zA-Z\'"-]+/', $text, -1, PREG_SPLIT_NO_EMPTY);
307
-
308
-        foreach ($originalKeywords as $originalKeyword) {
309
-            $secondRoundKeywords = explode("'", $originalKeyword);
310
-            foreach ($secondRoundKeywords as $secondRoundKeyword) {
311
-                if (strlen($secondRoundKeyword) >= $minChar) {
312
-                    if (!in_array($secondRoundKeyword, $keywords)) {
313
-                        $keywords[] = trim($secondRoundKeyword);
314
-                    }
315
-                }
316
-            }
317
-        }
318
-
319
-        return $keywords;
320
-    }
321
-
322
-    /**
323
-     * @return string
324
-     */
325
-    public function createMetaKeywords()
326
-    {
327
-        global $xoopsModuleConfig;
328
-        $keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar);
329
-        if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) && $xoopsModuleConfig['moduleMetaKeywords'] !== '') {
330
-            $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']);
331
-            $keywords       = array_merge($keywords, $moduleKeywords);
332
-        }
333
-
334
-        /* Commenting this out as it may cause problem on XOOPS ML websites
55
+		$this->setKeywords($keywords);
56
+	}
57
+
58
+	/**
59
+	 * Return true if the string is length > 0
60
+	 *
61
+	 * @credit psylove
62
+	 *
63
+	 * @var    string  $string Chaine de caract�re
64
+	 * @return boolean
65
+	 */
66
+	public function emptyString($var)
67
+	{
68
+		return (strlen($var) > 0);
69
+	}
70
+
71
+	/**
72
+	 * Create a title for the short_url field of an article
73
+	 *
74
+	 * @credit psylove
75
+	 *
76
+	 * @var    string      $title title of the article
77
+	 * @param  bool|string $withExt
78
+	 * @return string      sort_url for the article
79
+	 */
80
+	public function generateSeoTitle($title = '', $withExt = true)
81
+	{
82
+		// Transformation de la chaine en minuscule
83
+		// Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus
84
+		$title = rawurlencode(strtolower($title));
85
+
86
+		// Transformation des ponctuations
87
+		$pattern = array(
88
+			'/%09/', // Tab
89
+			'/%20/', // Space
90
+			'/%21/', // !
91
+			'/%22/', // "
92
+			'/%23/', // #
93
+			'/%25/', // %
94
+			'/%26/', // &
95
+			'/%27/', // '
96
+			'/%28/', // (
97
+			'/%29/', // )
98
+			'/%2C/', // ,
99
+			'/%2F/', // /
100
+			'/%3A/', // :
101
+			'/%3B/', // ;
102
+			'/%3C/', // <
103
+			'/%3D/', // =
104
+			'/%3E/', // >
105
+			'/%3F/', // ?
106
+			'/%40/', // @
107
+			'/%5B/', // [
108
+			'/%5C/', // \
109
+			'/%5D/', // ]
110
+			'/%5E/', // ^
111
+			'/%7B/', // {
112
+			'/%7C/', // |
113
+			'/%7D/', // }
114
+			'/%7E/', // ~
115
+			"/\./" // .
116
+		);
117
+		$rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
118
+		$title   = preg_replace($pattern, $rep_pat, $title);
119
+
120
+		// Transformation des caract�res accentu�s
121
+		$pattern = array(
122
+			'/%B0/', // °
123
+			'/%E8/', // è
124
+			'/%E9/', // é
125
+			'/%EA/', // ê
126
+			'/%EB/', // ë
127
+			'/%E7/', // ç
128
+			'/%E0/', // à
129
+			'/%E2/', // â
130
+			'/%E4/', // ä
131
+			'/%EE/', // î
132
+			'/%EF/', // ï
133
+			'/%F9/', // ù
134
+			'/%FC/', // ü
135
+			'/%FB/', // û
136
+			'/%F4/', // ô
137
+			'/%F6/', // ö
138
+		);        
139
+		$rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
140
+		$title   = preg_replace($pattern, $rep_pat, $title);
141
+
142
+		$tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
143
+		$tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
144
+		$title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
145
+
146
+		if (count($title) > 0) {
147
+			if ($withExt) {
148
+				$title .= '.html';
149
+			}
150
+
151
+			return $title;
152
+		} else {
153
+			return '';
154
+		}
155
+	}
156
+
157
+	/**
158
+	 * @param $document
159
+	 * @return mixed
160
+	 */
161
+	public function html2text($document)
162
+	{
163
+		return smart_html2text($document);
164
+	}
165
+
166
+	/**
167
+	 * @param $title
168
+	 */
169
+	public function setTitle($title)
170
+	{
171
+		global $xoopsModule, $xoopsModuleConfig;
172
+		$this->_title          = $this->html2text($title);
173
+		$this->_title          = $this->purifyText($this->_title);
174
+		$this->_original_title = $this->_title;
175
+
176
+		$moduleName = $xoopsModule->getVar('name');
177
+
178
+		$titleTag = array();
179
+
180
+		$show_mod_name_breadcrumb = isset($xoopsModuleConfig['show_mod_name_breadcrumb']) ? $xoopsModuleConfig['show_mod_name_breadcrumb'] : true;
181
+
182
+		if ($moduleName && $show_mod_name_breadcrumb) {
183
+			$titleTag['module'] = $moduleName;
184
+		}
185
+
186
+		if (isset($this->_title) && ($this->_title !== '') && (strtoupper($this->_title) != strtoupper($moduleName))) {
187
+			$titleTag['title'] = $this->_title;
188
+		}
189
+
190
+		if (isset($this->_categoryPath) && ($this->_categoryPath !== '')) {
191
+			$titleTag['category'] = $this->_categoryPath;
192
+		}
193
+
194
+		$ret = isset($titleTag['title']) ? $titleTag['title'] : '';
195
+
196
+		if (isset($titleTag['category']) && $titleTag['category'] !== '') {
197
+			if ($ret !== '') {
198
+				$ret .= ' - ';
199
+			}
200
+			$ret .= $titleTag['category'];
201
+		}
202
+		if (isset($titleTag['module']) && $titleTag['module'] !== '') {
203
+			if ($ret !== '') {
204
+				$ret .= ' - ';
205
+			}
206
+			$ret .= $titleTag['module'];
207
+		}
208
+		$this->_title = $ret;
209
+	}
210
+
211
+	/**
212
+	 * @param $keywords
213
+	 */
214
+	public function setKeywords($keywords)
215
+	{
216
+		$this->_keywords = $keywords;
217
+	}
218
+
219
+	/**
220
+	 * @param $categoryPath
221
+	 */
222
+	public function setCategoryPath($categoryPath)
223
+	{
224
+		$categoryPath        = $this->html2text($categoryPath);
225
+		$this->_categoryPath = $categoryPath;
226
+	}
227
+
228
+	/**
229
+	 * @param $description
230
+	 */
231
+	public function setDescription($description)
232
+	{
233
+		if (!$description) {
234
+			global $xoopsModuleConfig;
235
+			if (isset($xoopsModuleConfig['module_meta_description'])) {
236
+				$description = $xoopsModuleConfig['module_meta_description'];
237
+			}
238
+		}
239
+
240
+		$description = $this->html2text($description);
241
+		$description = $this->purifyText($description);
242
+
243
+		$description = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $description);
244
+		$description = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $description);
245
+		$description = preg_replace('/[ ]* [ ]*/', ' ', $description);
246
+		$description = stripslashes($description);
247
+
248
+		$this->_description      = $description;
249
+		$this->_meta_description = $this->createMetaDescription();
250
+	}
251
+
252
+	public function createTitleTag()
253
+	{
254
+	}
255
+
256
+	/**
257
+	 * @param               $text
258
+	 * @param  bool         $keyword
259
+	 * @return mixed|string
260
+	 */
261
+	public function purifyText($text, $keyword = false)
262
+	{
263
+		return smart_purifyText($text, $keyword);
264
+	}
265
+
266
+	/**
267
+	 * @param  int    $maxWords
268
+	 * @return string
269
+	 */
270
+	public function createMetaDescription($maxWords = 100)
271
+	{
272
+		$words = array();
273
+		$words = explode(' ', $this->_description);
274
+
275
+		// Only keep $maxWords words
276
+		$newWords = array();
277
+		$i        = 0;
278
+
279
+		while ($i < $maxWords - 1 && $i < count($words)) {
280
+			$newWords[] = $words[$i];
281
+			++$i;
282
+		}
283
+		$ret = implode(' ', $newWords);
284
+
285
+		return $ret;
286
+	}
287
+
288
+	/**
289
+	 * @param $text
290
+	 * @param $minChar
291
+	 * @return array
292
+	 */
293
+	public function findMetaKeywords($text, $minChar)
294
+	{
295
+		$keywords = array();
296
+
297
+		$text = $this->purifyText($text);
298
+		$text = $this->html2text($text);
299
+
300
+		$text = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $text);
301
+		$text = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $text);
302
+		$text = preg_replace('/[ ]* [ ]*/', ' ', $text);
303
+		$text = stripslashes($text);
304
+		$text =
305
+
306
+		$originalKeywords = preg_split('/[^a-zA-Z\'"-]+/', $text, -1, PREG_SPLIT_NO_EMPTY);
307
+
308
+		foreach ($originalKeywords as $originalKeyword) {
309
+			$secondRoundKeywords = explode("'", $originalKeyword);
310
+			foreach ($secondRoundKeywords as $secondRoundKeyword) {
311
+				if (strlen($secondRoundKeyword) >= $minChar) {
312
+					if (!in_array($secondRoundKeyword, $keywords)) {
313
+						$keywords[] = trim($secondRoundKeyword);
314
+					}
315
+				}
316
+			}
317
+		}
318
+
319
+		return $keywords;
320
+	}
321
+
322
+	/**
323
+	 * @return string
324
+	 */
325
+	public function createMetaKeywords()
326
+	{
327
+		global $xoopsModuleConfig;
328
+		$keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar);
329
+		if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) && $xoopsModuleConfig['moduleMetaKeywords'] !== '') {
330
+			$moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']);
331
+			$keywords       = array_merge($keywords, $moduleKeywords);
332
+		}
333
+
334
+		/* Commenting this out as it may cause problem on XOOPS ML websites
335 335
          $return_keywords = array();
336 336
 
337 337
          // Cleaning for duplicate keywords
@@ -341,43 +341,43 @@  discard block
 block discarded – undo
341 341
          }
342 342
          }*/
343 343
 
344
-        // Only take the first 90 keywords
345
-        $newKeywords = array();
346
-        $i           = 0;
347
-        while ($i < 90 - 1 && isset($keywords[$i])) {
348
-            $newKeywords[] = $keywords[$i];
349
-            ++$i;
350
-        }
351
-        $ret = implode(', ', $newKeywords);
352
-
353
-        return $ret;
354
-    }
355
-
356
-    public function autoBuildMeta_keywords()
357
-    {
358
-    }
359
-
360
-    public function buildAutoMetaTags()
361
-    {
362
-        global $xoopsModule, $xoopsModuleConfig;
363
-
364
-        $this->_keywords         = $this->createMetaKeywords();
365
-        $this->_meta_description = $this->createMetaDescription();
366
-        $this->_title            = $this->createTitleTag();
367
-    }
368
-
369
-    public function createMetaTags()
370
-    {
371
-        global $xoopsTpl, $xoTheme;
372
-
373
-        if (is_object($xoTheme)) {
374
-            $xoTheme->addMeta('meta', 'keywords', $this->_keywords);
375
-            $xoTheme->addMeta('meta', 'description', $this->_description);
376
-            $xoTheme->addMeta('meta', 'title', $this->_title);
377
-        } else {
378
-            $xoopsTpl->assign('xoops_meta_keywords', $this->_keywords);
379
-            $xoopsTpl->assign('xoops_meta_description', $this->_description);
380
-        }
381
-        $xoopsTpl->assign('xoops_pagetitle', $this->_title);
382
-    }
344
+		// Only take the first 90 keywords
345
+		$newKeywords = array();
346
+		$i           = 0;
347
+		while ($i < 90 - 1 && isset($keywords[$i])) {
348
+			$newKeywords[] = $keywords[$i];
349
+			++$i;
350
+		}
351
+		$ret = implode(', ', $newKeywords);
352
+
353
+		return $ret;
354
+	}
355
+
356
+	public function autoBuildMeta_keywords()
357
+	{
358
+	}
359
+
360
+	public function buildAutoMetaTags()
361
+	{
362
+		global $xoopsModule, $xoopsModuleConfig;
363
+
364
+		$this->_keywords         = $this->createMetaKeywords();
365
+		$this->_meta_description = $this->createMetaDescription();
366
+		$this->_title            = $this->createTitleTag();
367
+	}
368
+
369
+	public function createMetaTags()
370
+	{
371
+		global $xoopsTpl, $xoTheme;
372
+
373
+		if (is_object($xoTheme)) {
374
+			$xoTheme->addMeta('meta', 'keywords', $this->_keywords);
375
+			$xoTheme->addMeta('meta', 'description', $this->_description);
376
+			$xoTheme->addMeta('meta', 'title', $this->_title);
377
+		} else {
378
+			$xoopsTpl->assign('xoops_meta_keywords', $this->_keywords);
379
+			$xoopsTpl->assign('xoops_meta_description', $this->_description);
380
+		}
381
+		$xoopsTpl->assign('xoops_pagetitle', $this->_title);
382
+	}
383 383
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@
 block discarded – undo
325 325
     public function createMetaKeywords()
326 326
     {
327 327
         global $xoopsModuleConfig;
328
-        $keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar);
328
+        $keywords = $this->findMetaKeywords($this->_original_title.' '.$this->_description, $this->_minChar);
329 329
         if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) && $xoopsModuleConfig['moduleMetaKeywords'] !== '') {
330 330
             $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']);
331 331
             $keywords       = array_merge($keywords, $moduleKeywords);
Please login to merge, or discard this patch.
class/adsense.php 2 patches
Indentation   +307 added lines, -307 removed lines patch added patch discarded remove patch
@@ -36,87 +36,87 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class SmartobjectAdsense extends SmartObject
38 38
 {
39
-    /**
40
-     * SmartobjectAdsense constructor.
41
-     */
42
-    public function __construct()
43
-    {
44
-        $this->quickInitVar('adsenseid', XOBJ_DTYPE_INT, true);
45
-        $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_ADSENSE_DESCRIPTION, _CO_SOBJECT_ADSENSE_DESCRIPTION_DSC);
46
-        $this->quickInitVar('client_id', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_CLIENT_ID, _CO_SOBJECT_ADSENSE_CLIENT_ID_DSC);
47
-        $this->quickInitVar('tag', XOBJ_DTYPE_TXTBOX, false, _CO_SOBJECT_ADSENSE_TAG, _CO_SOBJECT_ADSENSE_TAG_DSC);
48
-        $this->quickInitVar('format', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_FORMAT, _CO_SOBJECT_ADSENSE_FORMAT_DSC);
49
-        $this->quickInitVar('border_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BORDER_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
50
-        $this->quickInitVar('background_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BACKGROUND_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
51
-        $this->quickInitVar('link_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_LINK_COLOR, _CO_SOBJECT_ADSENSE_LINK_COLOR_DSC);
52
-        $this->quickInitVar('url_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_URL_COLOR, _CO_SOBJECT_ADSENSE_URL_COLOR_DSC);
53
-        $this->quickInitVar('text_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_TEXT_COLOR, _CO_SOBJECT_ADSENSE_TEXT_COLOR_DSC);
54
-        $this->quickInitVar('style', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_ADSENSE_STYLE, _CO_SOBJECT_ADSENSE_STYLE_DSC);
55
-
56
-        $this->setControl('format', array(
57
-            'handler' => 'adsense',
58
-            'method'  => 'getFormats'
59
-        ));
60
-
61
-        $this->setControl('border_color', array(
62
-            'name'      => 'text',
63
-            'size'      => 6,
64
-            'maxlength' => 6
65
-        ));
66
-
67
-        $this->setControl('background_color', array(
68
-            'name'      => 'text',
69
-            'size'      => 6,
70
-            'maxlength' => 6
71
-        ));
72
-
73
-        $this->setControl('link_color', array(
74
-            'name'      => 'text',
75
-            'size'      => 6,
76
-            'maxlength' => 6
77
-        ));
78
-
79
-        $this->setControl('url_color', array(
80
-            'name'      => 'text',
81
-            'size'      => 6,
82
-            'maxlength' => 6
83
-        ));
84
-
85
-        $this->setControl('text_color', array(
86
-            'name'      => 'text',
87
-            'size'      => 6,
88
-            'maxlength' => 6
89
-        ));
90
-    }
91
-
92
-    /**
93
-     * @param  string $key
94
-     * @param  string $format
95
-     * @return mixed
96
-     */
97
-    public function getVar($key, $format = 's')
98
-    {
99
-        if ($format === 's' && in_array($key, array())) {
100
-            //            return call_user_func(array($this, $key));
101
-            return $this->{$key}();
102
-        }
103
-
104
-        return parent::getVar($key, $format);
105
-    }
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function render()
111
-    {
112
-        global $smartobjectAdsenseHandler;
113
-        if ($this->getVar('style', 'n') !== '') {
114
-            $ret = '<div style="' . $this->getVar('style', 'n') . '">';
115
-        } else {
116
-            $ret = '<div>';
117
-        }
118
-
119
-        $ret .= '<script type="text/javascript"><!--
39
+	/**
40
+	 * SmartobjectAdsense constructor.
41
+	 */
42
+	public function __construct()
43
+	{
44
+		$this->quickInitVar('adsenseid', XOBJ_DTYPE_INT, true);
45
+		$this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_ADSENSE_DESCRIPTION, _CO_SOBJECT_ADSENSE_DESCRIPTION_DSC);
46
+		$this->quickInitVar('client_id', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_CLIENT_ID, _CO_SOBJECT_ADSENSE_CLIENT_ID_DSC);
47
+		$this->quickInitVar('tag', XOBJ_DTYPE_TXTBOX, false, _CO_SOBJECT_ADSENSE_TAG, _CO_SOBJECT_ADSENSE_TAG_DSC);
48
+		$this->quickInitVar('format', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_FORMAT, _CO_SOBJECT_ADSENSE_FORMAT_DSC);
49
+		$this->quickInitVar('border_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BORDER_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
50
+		$this->quickInitVar('background_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BACKGROUND_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
51
+		$this->quickInitVar('link_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_LINK_COLOR, _CO_SOBJECT_ADSENSE_LINK_COLOR_DSC);
52
+		$this->quickInitVar('url_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_URL_COLOR, _CO_SOBJECT_ADSENSE_URL_COLOR_DSC);
53
+		$this->quickInitVar('text_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_TEXT_COLOR, _CO_SOBJECT_ADSENSE_TEXT_COLOR_DSC);
54
+		$this->quickInitVar('style', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_ADSENSE_STYLE, _CO_SOBJECT_ADSENSE_STYLE_DSC);
55
+
56
+		$this->setControl('format', array(
57
+			'handler' => 'adsense',
58
+			'method'  => 'getFormats'
59
+		));
60
+
61
+		$this->setControl('border_color', array(
62
+			'name'      => 'text',
63
+			'size'      => 6,
64
+			'maxlength' => 6
65
+		));
66
+
67
+		$this->setControl('background_color', array(
68
+			'name'      => 'text',
69
+			'size'      => 6,
70
+			'maxlength' => 6
71
+		));
72
+
73
+		$this->setControl('link_color', array(
74
+			'name'      => 'text',
75
+			'size'      => 6,
76
+			'maxlength' => 6
77
+		));
78
+
79
+		$this->setControl('url_color', array(
80
+			'name'      => 'text',
81
+			'size'      => 6,
82
+			'maxlength' => 6
83
+		));
84
+
85
+		$this->setControl('text_color', array(
86
+			'name'      => 'text',
87
+			'size'      => 6,
88
+			'maxlength' => 6
89
+		));
90
+	}
91
+
92
+	/**
93
+	 * @param  string $key
94
+	 * @param  string $format
95
+	 * @return mixed
96
+	 */
97
+	public function getVar($key, $format = 's')
98
+	{
99
+		if ($format === 's' && in_array($key, array())) {
100
+			//            return call_user_func(array($this, $key));
101
+			return $this->{$key}();
102
+		}
103
+
104
+		return parent::getVar($key, $format);
105
+	}
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function render()
111
+	{
112
+		global $smartobjectAdsenseHandler;
113
+		if ($this->getVar('style', 'n') !== '') {
114
+			$ret = '<div style="' . $this->getVar('style', 'n') . '">';
115
+		} else {
116
+			$ret = '<div>';
117
+		}
118
+
119
+		$ret .= '<script type="text/javascript"><!--
120 120
 google_ad_client = "' . $this->getVar('client_id', 'n') . '";
121 121
 google_ad_width = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['width'] . ';
122 122
 google_ad_height = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['height'] . ';
@@ -134,120 +134,120 @@  discard block
 block discarded – undo
134 134
 </script>
135 135
 </div>';
136 136
 
137
-        return $ret;
138
-    }
139
-
140
-    /**
141
-     * @return string
142
-     */
143
-    public function getXoopsCode()
144
-    {
145
-        $ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]';
146
-
147
-        return $ret;
148
-    }
149
-
150
-    /**
151
-     * @param $var
152
-     * @return bool
153
-     */
154
-    public function emptyString($var)
155
-    {
156
-        return (strlen($var) > 0);
157
-    }
158
-
159
-    /**
160
-     * @return mixed|string
161
-     */
162
-    public function generateTag()
163
-    {
164
-        $title = rawurlencode(strtolower($this->getVar('description', 'e')));
165
-        $title = xoops_substr($title, 0, 10, '');
166
-        // Transformation des ponctuations
167
-        $pattern = array(
168
-            '/%09/', // Tab
169
-            '/%20/', // Space
170
-            '/%21/', // !
171
-            '/%22/', // "
172
-            '/%23/', // #
173
-            '/%25/', // %
174
-            '/%26/', // &
175
-            '/%27/', // '
176
-            '/%28/', // (
177
-            '/%29/', // )
178
-            '/%2C/', // ,
179
-            '/%2F/', // /
180
-            '/%3A/', // :
181
-            '/%3B/', // ;
182
-            '/%3C/', // <
183
-            '/%3D/', // =
184
-            '/%3E/', // >
185
-            '/%3F/', // ?
186
-            '/%40/', // @
187
-            '/%5B/', // [
188
-            '/%5C/', // \
189
-            '/%5D/', // ]
190
-            '/%5E/', // ^
191
-            '/%7B/', // {
192
-            '/%7C/', // |
193
-            '/%7D/', // }
194
-            '/%7E/', // ~
195
-            "/\./" // .
196
-        );
197
-        $rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
198
-        $title   = preg_replace($pattern, $rep_pat, $title);
199
-
200
-        // Transformation des caract�res accentu�s
201
-        $pattern = array(
202
-            '/%B0/', // °
203
-            '/%E8/', // è
204
-            '/%E9/', // é
205
-            '/%EA/', // ê
206
-            '/%EB/', // ë
207
-            '/%E7/', // ç
208
-            '/%E0/', // à
209
-            '/%E2/', // â
210
-            '/%E4/', // ä
211
-            '/%EE/', // î
212
-            '/%EF/', // ï
213
-            '/%F9/', // ù
214
-            '/%FC/', // ü
215
-            '/%FB/', // û
216
-            '/%F4/', // ô
217
-            '/%F6/', // ö
218
-        );
219
-        $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
220
-        $title   = preg_replace($pattern, $rep_pat, $title);
221
-
222
-        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
223
-        $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
224
-        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
225
-
226
-        $title .= time();
227
-        $title = md5($title);
228
-
229
-        return $title;
230
-    }
231
-
232
-    /**
233
-     * @return string
234
-     */
235
-    public function getCloneLink()
236
-    {
237
-        $ret = '<a href="' .
238
-               SMARTOBJECT_URL .
239
-               'admin/adsense.php?op=clone&adsenseid=' .
240
-               $this->getVar('adsenseid') .
241
-               '"><img src="' .
242
-               SMARTOBJECT_IMAGES_ACTIONS_URL .
243
-               'editcopy.png" alt="' .
244
-               _CO_SOBJECT_ADSENSE_CLONE .
245
-               '" title="' .
246
-               _CO_SOBJECT_ADSENSE_CLONE .
247
-               '" /></a>';
248
-
249
-        return $ret;
250
-    }
137
+		return $ret;
138
+	}
139
+
140
+	/**
141
+	 * @return string
142
+	 */
143
+	public function getXoopsCode()
144
+	{
145
+		$ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]';
146
+
147
+		return $ret;
148
+	}
149
+
150
+	/**
151
+	 * @param $var
152
+	 * @return bool
153
+	 */
154
+	public function emptyString($var)
155
+	{
156
+		return (strlen($var) > 0);
157
+	}
158
+
159
+	/**
160
+	 * @return mixed|string
161
+	 */
162
+	public function generateTag()
163
+	{
164
+		$title = rawurlencode(strtolower($this->getVar('description', 'e')));
165
+		$title = xoops_substr($title, 0, 10, '');
166
+		// Transformation des ponctuations
167
+		$pattern = array(
168
+			'/%09/', // Tab
169
+			'/%20/', // Space
170
+			'/%21/', // !
171
+			'/%22/', // "
172
+			'/%23/', // #
173
+			'/%25/', // %
174
+			'/%26/', // &
175
+			'/%27/', // '
176
+			'/%28/', // (
177
+			'/%29/', // )
178
+			'/%2C/', // ,
179
+			'/%2F/', // /
180
+			'/%3A/', // :
181
+			'/%3B/', // ;
182
+			'/%3C/', // <
183
+			'/%3D/', // =
184
+			'/%3E/', // >
185
+			'/%3F/', // ?
186
+			'/%40/', // @
187
+			'/%5B/', // [
188
+			'/%5C/', // \
189
+			'/%5D/', // ]
190
+			'/%5E/', // ^
191
+			'/%7B/', // {
192
+			'/%7C/', // |
193
+			'/%7D/', // }
194
+			'/%7E/', // ~
195
+			"/\./" // .
196
+		);
197
+		$rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
198
+		$title   = preg_replace($pattern, $rep_pat, $title);
199
+
200
+		// Transformation des caract�res accentu�s
201
+		$pattern = array(
202
+			'/%B0/', // °
203
+			'/%E8/', // è
204
+			'/%E9/', // é
205
+			'/%EA/', // ê
206
+			'/%EB/', // ë
207
+			'/%E7/', // ç
208
+			'/%E0/', // à
209
+			'/%E2/', // â
210
+			'/%E4/', // ä
211
+			'/%EE/', // î
212
+			'/%EF/', // ï
213
+			'/%F9/', // ù
214
+			'/%FC/', // ü
215
+			'/%FB/', // û
216
+			'/%F4/', // ô
217
+			'/%F6/', // ö
218
+		);
219
+		$rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
220
+		$title   = preg_replace($pattern, $rep_pat, $title);
221
+
222
+		$tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
223
+		$tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
224
+		$title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
225
+
226
+		$title .= time();
227
+		$title = md5($title);
228
+
229
+		return $title;
230
+	}
231
+
232
+	/**
233
+	 * @return string
234
+	 */
235
+	public function getCloneLink()
236
+	{
237
+		$ret = '<a href="' .
238
+			   SMARTOBJECT_URL .
239
+			   'admin/adsense.php?op=clone&adsenseid=' .
240
+			   $this->getVar('adsenseid') .
241
+			   '"><img src="' .
242
+			   SMARTOBJECT_IMAGES_ACTIONS_URL .
243
+			   'editcopy.png" alt="' .
244
+			   _CO_SOBJECT_ADSENSE_CLONE .
245
+			   '" title="' .
246
+			   _CO_SOBJECT_ADSENSE_CLONE .
247
+			   '" /></a>';
248
+
249
+		return $ret;
250
+	}
251 251
 }
252 252
 
253 253
 /**
@@ -255,116 +255,116 @@  discard block
 block discarded – undo
255 255
  */
256 256
 class SmartobjectAdsenseHandler extends SmartPersistableObjectHandler
257 257
 {
258
-    public $adFormats;
259
-    public $adFormatsList;
260
-    public $objects = false;
261
-
262
-    /**
263
-     * SmartobjectAdsenseHandler constructor.
264
-     * @param XoopsDatabase $db
265
-     */
266
-    public function __construct(XoopsDatabase $db)
267
-    {
268
-        parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
269
-        $this->adFormats     = array();
270
-        $this->adFormatsList = array();
271
-
272
-        $this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
273
-        $this->adFormats['728x90_as']['width']   = 728;
274
-        $this->adFormats['728x90_as']['height']  = 90;
275
-        $this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
276
-
277
-        $this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
278
-        $this->adFormats['468x60_as']['width']   = 468;
279
-        $this->adFormats['468x60_as']['height']  = 60;
280
-        $this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
281
-
282
-        $this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
283
-        $this->adFormats['234x60_as']['width']   = 234;
284
-        $this->adFormats['234x60_as']['height']  = 60;
285
-        $this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
286
-
287
-        $this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
288
-        $this->adFormats['120x600_as']['width']   = 120;
289
-        $this->adFormats['120x600_as']['height']  = 600;
290
-        $this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
291
-
292
-        $this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
293
-        $this->adFormats['160x600_as']['width']   = 160;
294
-        $this->adFormats['160x600_as']['height']  = 600;
295
-        $this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
296
-
297
-        $this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
298
-        $this->adFormats['120x240_as']['width']   = 120;
299
-        $this->adFormats['120x240_as']['height']  = 240;
300
-        $this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
301
-
302
-        $this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
303
-        $this->adFormats['336x280_as']['width']   = 136;
304
-        $this->adFormats['336x280_as']['height']  = 280;
305
-        $this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
306
-
307
-        $this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
308
-        $this->adFormats['300x250_as']['width']   = 300;
309
-        $this->adFormats['300x250_as']['height']  = 250;
310
-        $this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
311
-
312
-        $this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
313
-        $this->adFormats['250x250_as']['width']   = 250;
314
-        $this->adFormats['250x250_as']['height']  = 250;
315
-        $this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
316
-
317
-        $this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
318
-        $this->adFormats['200x200_as']['width']   = 200;
319
-        $this->adFormats['200x200_as']['height']  = 200;
320
-        $this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
321
-
322
-        $this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
323
-        $this->adFormats['180x150_as']['width']   = 180;
324
-        $this->adFormats['180x150_as']['height']  = 150;
325
-        $this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
326
-
327
-        $this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
328
-        $this->adFormats['125x125_as']['width']   = 125;
329
-        $this->adFormats['125x125_as']['height']  = 125;
330
-        $this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
331
-    }
332
-
333
-    /**
334
-     * @return array
335
-     */
336
-    public function getFormats()
337
-    {
338
-        return $this->adFormatsList;
339
-    }
340
-
341
-    /**
342
-     * @param $obj
343
-     * @return bool
344
-     */
345
-    public function beforeSave($obj)
346
-    {
347
-        if ($obj->getVar('tag') === '') {
348
-            $obj->setVar('tag', $title = $obj->generateTag());
349
-        }
350
-
351
-        return true;
352
-    }
353
-
354
-    /**
355
-     * @return array|bool
356
-     */
357
-    public function getAdsensesByTag()
358
-    {
359
-        if (!$this->objects) {
360
-            $adsensesObj = $this->getObjects(null, true);
361
-            $ret         = array();
362
-            foreach ($adsensesObj as $adsenseObj) {
363
-                $ret[$adsenseObj->getVar('tag')] = $adsenseObj;
364
-            }
365
-            $this->objects = $ret;
366
-        }
367
-
368
-        return $this->objects;
369
-    }
258
+	public $adFormats;
259
+	public $adFormatsList;
260
+	public $objects = false;
261
+
262
+	/**
263
+	 * SmartobjectAdsenseHandler constructor.
264
+	 * @param XoopsDatabase $db
265
+	 */
266
+	public function __construct(XoopsDatabase $db)
267
+	{
268
+		parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
269
+		$this->adFormats     = array();
270
+		$this->adFormatsList = array();
271
+
272
+		$this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
273
+		$this->adFormats['728x90_as']['width']   = 728;
274
+		$this->adFormats['728x90_as']['height']  = 90;
275
+		$this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
276
+
277
+		$this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
278
+		$this->adFormats['468x60_as']['width']   = 468;
279
+		$this->adFormats['468x60_as']['height']  = 60;
280
+		$this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
281
+
282
+		$this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
283
+		$this->adFormats['234x60_as']['width']   = 234;
284
+		$this->adFormats['234x60_as']['height']  = 60;
285
+		$this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
286
+
287
+		$this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
288
+		$this->adFormats['120x600_as']['width']   = 120;
289
+		$this->adFormats['120x600_as']['height']  = 600;
290
+		$this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
291
+
292
+		$this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
293
+		$this->adFormats['160x600_as']['width']   = 160;
294
+		$this->adFormats['160x600_as']['height']  = 600;
295
+		$this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
296
+
297
+		$this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
298
+		$this->adFormats['120x240_as']['width']   = 120;
299
+		$this->adFormats['120x240_as']['height']  = 240;
300
+		$this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
301
+
302
+		$this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
303
+		$this->adFormats['336x280_as']['width']   = 136;
304
+		$this->adFormats['336x280_as']['height']  = 280;
305
+		$this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
306
+
307
+		$this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
308
+		$this->adFormats['300x250_as']['width']   = 300;
309
+		$this->adFormats['300x250_as']['height']  = 250;
310
+		$this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
311
+
312
+		$this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
313
+		$this->adFormats['250x250_as']['width']   = 250;
314
+		$this->adFormats['250x250_as']['height']  = 250;
315
+		$this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
316
+
317
+		$this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
318
+		$this->adFormats['200x200_as']['width']   = 200;
319
+		$this->adFormats['200x200_as']['height']  = 200;
320
+		$this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
321
+
322
+		$this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
323
+		$this->adFormats['180x150_as']['width']   = 180;
324
+		$this->adFormats['180x150_as']['height']  = 150;
325
+		$this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
326
+
327
+		$this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
328
+		$this->adFormats['125x125_as']['width']   = 125;
329
+		$this->adFormats['125x125_as']['height']  = 125;
330
+		$this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
331
+	}
332
+
333
+	/**
334
+	 * @return array
335
+	 */
336
+	public function getFormats()
337
+	{
338
+		return $this->adFormatsList;
339
+	}
340
+
341
+	/**
342
+	 * @param $obj
343
+	 * @return bool
344
+	 */
345
+	public function beforeSave($obj)
346
+	{
347
+		if ($obj->getVar('tag') === '') {
348
+			$obj->setVar('tag', $title = $obj->generateTag());
349
+		}
350
+
351
+		return true;
352
+	}
353
+
354
+	/**
355
+	 * @return array|bool
356
+	 */
357
+	public function getAdsensesByTag()
358
+	{
359
+		if (!$this->objects) {
360
+			$adsensesObj = $this->getObjects(null, true);
361
+			$ret         = array();
362
+			foreach ($adsensesObj as $adsenseObj) {
363
+				$ret[$adsenseObj->getVar('tag')] = $adsenseObj;
364
+			}
365
+			$this->objects = $ret;
366
+		}
367
+
368
+		return $this->objects;
369
+	}
370 370
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  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';
32
+include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php';
33 33
 
34 34
 /**
35 35
  * Class SmartobjectAdsense
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
     {
112 112
         global $smartobjectAdsenseHandler;
113 113
         if ($this->getVar('style', 'n') !== '') {
114
-            $ret = '<div style="' . $this->getVar('style', 'n') . '">';
114
+            $ret = '<div style="'.$this->getVar('style', 'n').'">';
115 115
         } else {
116 116
             $ret = '<div>';
117 117
         }
118 118
 
119 119
         $ret .= '<script type="text/javascript"><!--
120
-google_ad_client = "' . $this->getVar('client_id', 'n') . '";
121
-google_ad_width = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['width'] . ';
122
-google_ad_height = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['height'] . ';
123
-google_ad_format = "' . $this->getVar('format', 'n') . '";
120
+google_ad_client = "' . $this->getVar('client_id', 'n').'";
121
+google_ad_width = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['width'].';
122
+google_ad_height = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['height'].';
123
+google_ad_format = "' . $this->getVar('format', 'n').'";
124 124
 google_ad_type = "text";
125 125
 google_ad_channel ="";
126
-google_color_border = "' . $this->getVar('border_color', 'n') . '";
127
-google_color_bg = "' . $this->getVar('background_color', 'n') . '";
128
-google_color_link = "' . $this->getVar('link_color', 'n') . '";
129
-google_color_url = "' . $this->getVar('url_color', 'n') . '";
130
-google_color_text = "' . $this->getVar('text_color', 'n') . '";
126
+google_color_border = "' . $this->getVar('border_color', 'n').'";
127
+google_color_bg = "' . $this->getVar('background_color', 'n').'";
128
+google_color_link = "' . $this->getVar('link_color', 'n').'";
129
+google_color_url = "' . $this->getVar('url_color', 'n').'";
130
+google_color_text = "' . $this->getVar('text_color', 'n').'";
131 131
 //--></script>
132 132
 <script type="text/javascript"
133 133
   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function getXoopsCode()
144 144
     {
145
-        $ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]';
145
+        $ret = '[adsense]'.$this->getVar('tag', 'n').'[/adsense]';
146 146
 
147 147
         return $ret;
148 148
     }
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function getCloneLink()
236 236
     {
237
-        $ret = '<a href="' .
238
-               SMARTOBJECT_URL .
239
-               'admin/adsense.php?op=clone&adsenseid=' .
240
-               $this->getVar('adsenseid') .
241
-               '"><img src="' .
242
-               SMARTOBJECT_IMAGES_ACTIONS_URL .
243
-               'editcopy.png" alt="' .
244
-               _CO_SOBJECT_ADSENSE_CLONE .
245
-               '" title="' .
246
-               _CO_SOBJECT_ADSENSE_CLONE .
237
+        $ret = '<a href="'.
238
+               SMARTOBJECT_URL.
239
+               'admin/adsense.php?op=clone&adsenseid='.
240
+               $this->getVar('adsenseid').
241
+               '"><img src="'.
242
+               SMARTOBJECT_IMAGES_ACTIONS_URL.
243
+               'editcopy.png" alt="'.
244
+               _CO_SOBJECT_ADSENSE_CLONE.
245
+               '" title="'.
246
+               _CO_SOBJECT_ADSENSE_CLONE.
247 247
                '" /></a>';
248 248
 
249 249
         return $ret;
Please login to merge, or discard this patch.
class/form/smartobjectform.php 2 patches
Indentation   +796 added lines, -796 removed lines patch added patch discarded remove patch
@@ -30,790 +30,790 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class SmartObjectForm extends XoopsThemeForm
32 32
 {
33
-    public $targetObject           = null;
34
-    public $form_fields            = null;
35
-    public $_cancel_js_action      = false;
36
-    public $_custom_button         = false;
37
-    public $_captcha               = false;
38
-    public $_form_name             = false;
39
-    public $_form_caption          = false;
40
-    public $_submit_button_caption = false;
41
-
42
-    /**
43
-     * SmartobjectForm constructor.
44
-     * @param string $target
45
-     * @param string $form_name
46
-     * @param string $form_caption
47
-     * @param string $form_action
48
-     * @param null   $form_fields
49
-     * @param bool   $submit_button_caption
50
-     * @param bool   $cancel_js_action
51
-     * @param bool   $captcha
52
-     */
53
-    public function __construct(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false)
54
-    {
55
-        $this->targetObject           =& $target;
56
-        $this->form_fields            = $form_fields;
57
-        $this->_cancel_js_action      = $cancel_js_action;
58
-        $this->_captcha               = $captcha;
59
-        $this->_form_name             = $form_name;
60
-        $this->_form_caption          = $form_caption;
61
-        $this->_submit_button_caption = $submit_button_caption;
62
-
63
-        if (!isset($form_action)) {
64
-            $form_action = xoops_getenv('PHP_SELF');
65
-        }
66
-
67
-        parent::__construct($form_caption, $form_name, $form_action);
68
-        $this->setExtra('enctype="multipart/form-data"');
69
-
70
-        $this->createElements();
71
-
72
-        if ($captcha) {
73
-            $this->addCaptcha();
74
-        }
75
-
76
-        $this->createPermissionControls();
77
-
78
-        $this->createButtons($form_name, $form_caption, $submit_button_caption);
79
-    }
80
-
81
-    public function addCaptcha()
82
-    {
83
-        include_once(SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php');
84
-        $this->addElement(new XoopsFormCaptcha(), true);
85
-    }
86
-
87
-    /**
88
-     * @param      $name
89
-     * @param      $caption
90
-     * @param bool $onclick
91
-     */
92
-    public function addCustomButton($name, $caption, $onclick = false)
93
-    {
94
-        $custom_button_array    = array(
95
-            'name'    => $name,
96
-            'caption' => $caption,
97
-            'onclick' => $onclick
98
-        );
99
-        $this->_custom_button[] = $custom_button_array;
100
-    }
101
-
102
-    /**
103
-     * Add an element to the form
104
-     *
105
-     * @param string|XoopsFormElement      &$formElement reference to a {@link XoopsFormElement}
106
-     * @param bool        $key
107
-     * @param bool        $var
108
-     * @param bool|string $required     is this a "required" element?
109
-     */
110
-    public function addElement($formElement, $key = false, $var = false, $required = 'notset')
111
-    {
112
-        if ($key) {
113
-            if ($this->targetObject->vars[$key]['readonly']) {
114
-                $formElement->setExtra('disabled="disabled"');
115
-                $formElement->setName($key . '-readonly');
116
-                // Since this element is disable, we still want to pass it's value in the form
117
-                $hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
118
-                $this->addElement($hidden);
119
-            }
120
-            $formElement->setDescription($var['form_dsc']);
121
-            if (isset($this->targetObject->controls[$key]['onSelect'])) {
122
-                $hidden = new XoopsFormHidden('changedField', false);
123
-                $this->addElement($hidden);
124
-                $otherExtra      = isset($var['form_extra']) ? $var['form_extra'] : '';
125
-                $onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()";
126
-                $formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
127
-            } else {
128
-                if (isset($var['form_extra'])) {
129
-                    $formElement->setExtra($var['form_extra']);
130
-                }
131
-            }
132
-            $controls = $this->targetObject->controls;
133
-            if (isset($controls[$key]['js'])) {
134
-                $formElement->customValidationCode[] = $controls[$key]['js'];
135
-            }
136
-            parent::addElement($formElement, $required === 'notset' ? $var['required'] : $required);
137
-        } else {
138
-            parent::addElement($formElement, $required === 'notset' ? false : true);
139
-        }
140
-        unset($formElement);
141
-    }
142
-
143
-    public function createElements()
144
-    {
145
-        $controls = $this->targetObject->controls;
146
-        $vars     = $this->targetObject->vars;
147
-        foreach ($vars as $key => $var) {
148
-
149
-            // If $displayOnForm is false OR this is the primary key, it doesn't
150
-            // need to be displayed, then we only create an hidden field
151
-            if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) {
152
-                $elementToAdd = new XoopsFormHidden($key, $var['value']);
153
-                $this->addElement($elementToAdd, $key, $var, false);
154
-                unset($elementToAdd);
155
-                // If not, the we need to create the proper form control for this fields
156
-            } else {
157
-                // If this field has a specific control, we will use it
158
-
159
-                if ($key === 'parentid') {
160
-                    /**
161
-                     * Why this ?
162
-                     */
163
-                }
164
-                if (isset($controls[$key])) {
165
-                    /* If the control has name, it's because it's an object already present in the script
33
+	public $targetObject           = null;
34
+	public $form_fields            = null;
35
+	public $_cancel_js_action      = false;
36
+	public $_custom_button         = false;
37
+	public $_captcha               = false;
38
+	public $_form_name             = false;
39
+	public $_form_caption          = false;
40
+	public $_submit_button_caption = false;
41
+
42
+	/**
43
+	 * SmartobjectForm constructor.
44
+	 * @param string $target
45
+	 * @param string $form_name
46
+	 * @param string $form_caption
47
+	 * @param string $form_action
48
+	 * @param null   $form_fields
49
+	 * @param bool   $submit_button_caption
50
+	 * @param bool   $cancel_js_action
51
+	 * @param bool   $captcha
52
+	 */
53
+	public function __construct(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false)
54
+	{
55
+		$this->targetObject           =& $target;
56
+		$this->form_fields            = $form_fields;
57
+		$this->_cancel_js_action      = $cancel_js_action;
58
+		$this->_captcha               = $captcha;
59
+		$this->_form_name             = $form_name;
60
+		$this->_form_caption          = $form_caption;
61
+		$this->_submit_button_caption = $submit_button_caption;
62
+
63
+		if (!isset($form_action)) {
64
+			$form_action = xoops_getenv('PHP_SELF');
65
+		}
66
+
67
+		parent::__construct($form_caption, $form_name, $form_action);
68
+		$this->setExtra('enctype="multipart/form-data"');
69
+
70
+		$this->createElements();
71
+
72
+		if ($captcha) {
73
+			$this->addCaptcha();
74
+		}
75
+
76
+		$this->createPermissionControls();
77
+
78
+		$this->createButtons($form_name, $form_caption, $submit_button_caption);
79
+	}
80
+
81
+	public function addCaptcha()
82
+	{
83
+		include_once(SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php');
84
+		$this->addElement(new XoopsFormCaptcha(), true);
85
+	}
86
+
87
+	/**
88
+	 * @param      $name
89
+	 * @param      $caption
90
+	 * @param bool $onclick
91
+	 */
92
+	public function addCustomButton($name, $caption, $onclick = false)
93
+	{
94
+		$custom_button_array    = array(
95
+			'name'    => $name,
96
+			'caption' => $caption,
97
+			'onclick' => $onclick
98
+		);
99
+		$this->_custom_button[] = $custom_button_array;
100
+	}
101
+
102
+	/**
103
+	 * Add an element to the form
104
+	 *
105
+	 * @param string|XoopsFormElement      &$formElement reference to a {@link XoopsFormElement}
106
+	 * @param bool        $key
107
+	 * @param bool        $var
108
+	 * @param bool|string $required     is this a "required" element?
109
+	 */
110
+	public function addElement($formElement, $key = false, $var = false, $required = 'notset')
111
+	{
112
+		if ($key) {
113
+			if ($this->targetObject->vars[$key]['readonly']) {
114
+				$formElement->setExtra('disabled="disabled"');
115
+				$formElement->setName($key . '-readonly');
116
+				// Since this element is disable, we still want to pass it's value in the form
117
+				$hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
118
+				$this->addElement($hidden);
119
+			}
120
+			$formElement->setDescription($var['form_dsc']);
121
+			if (isset($this->targetObject->controls[$key]['onSelect'])) {
122
+				$hidden = new XoopsFormHidden('changedField', false);
123
+				$this->addElement($hidden);
124
+				$otherExtra      = isset($var['form_extra']) ? $var['form_extra'] : '';
125
+				$onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()";
126
+				$formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
127
+			} else {
128
+				if (isset($var['form_extra'])) {
129
+					$formElement->setExtra($var['form_extra']);
130
+				}
131
+			}
132
+			$controls = $this->targetObject->controls;
133
+			if (isset($controls[$key]['js'])) {
134
+				$formElement->customValidationCode[] = $controls[$key]['js'];
135
+			}
136
+			parent::addElement($formElement, $required === 'notset' ? $var['required'] : $required);
137
+		} else {
138
+			parent::addElement($formElement, $required === 'notset' ? false : true);
139
+		}
140
+		unset($formElement);
141
+	}
142
+
143
+	public function createElements()
144
+	{
145
+		$controls = $this->targetObject->controls;
146
+		$vars     = $this->targetObject->vars;
147
+		foreach ($vars as $key => $var) {
148
+
149
+			// If $displayOnForm is false OR this is the primary key, it doesn't
150
+			// need to be displayed, then we only create an hidden field
151
+			if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) {
152
+				$elementToAdd = new XoopsFormHidden($key, $var['value']);
153
+				$this->addElement($elementToAdd, $key, $var, false);
154
+				unset($elementToAdd);
155
+				// If not, the we need to create the proper form control for this fields
156
+			} else {
157
+				// If this field has a specific control, we will use it
158
+
159
+				if ($key === 'parentid') {
160
+					/**
161
+					 * Why this ?
162
+					 */
163
+				}
164
+				if (isset($controls[$key])) {
165
+					/* If the control has name, it's because it's an object already present in the script
166 166
                      * for example, "user"
167 167
                      * If the field does not have a name, than we will use a "select" (ie XoopsFormSelect)
168 168
                      */
169
-                    if (!isset($controls[$key]['name']) || !$controls[$key]['name']) {
170
-                        $controls[$key]['name'] = 'select';
171
-                    }
172
-
173
-                    $form_select = $this->getControl($controls[$key]['name'], $key);
174
-
175
-                    // Adding on the form, the control for this field
176
-                    $this->addElement($form_select, $key, $var);
177
-                    unset($form_select);
178
-
179
-                    // If this field don't have a specific control, we will use the standard one, depending on its data type
180
-                } else {
181
-                    switch ($var['data_type']) {
182
-
183
-                        case XOBJ_DTYPE_TXTBOX:
184
-
185
-                            $form_text = $this->getControl('text', $key);
186
-                            $this->addElement($form_text, $key, $var);
187
-                            unset($form_text);
188
-                            break;
189
-
190
-                        case XOBJ_DTYPE_INT:
191
-                            $this->targetObject->setControl($key, array(
192
-                                'name' => 'text',
193
-                                'size' => '5'
194
-                            ));
195
-                            $form_text = $this->getControl('text', $key);
196
-                            $this->addElement($form_text, $key, $var);
197
-                            unset($form_text);
198
-                            break;
199
-
200
-                        case XOBJ_DTYPE_FLOAT:
201
-                            $this->targetObject->setControl($key, array(
202
-                                'name' => 'text',
203
-                                'size' => '5'
204
-                            ));
205
-                            $form_text = $this->getControl('text', $key);
206
-                            $this->addElement($form_text, $key, $var);
207
-                            unset($form_text);
208
-                            break;
209
-
210
-                        case XOBJ_DTYPE_LTIME:
211
-                            $form_date_time = $this->getControl('date_time', $key);
212
-                            $this->addElement($form_date_time, $key, $var);
213
-                            unset($form_date_time);
214
-                            break;
215
-
216
-                        case XOBJ_DTYPE_STIME:
217
-                            $form_date_time = $this->getControl('date', $key);
218
-                            $this->addElement($form_date_time, $key, $var);
219
-                            unset($form_date_time);
220
-                            break;
221
-
222
-                        case XOBJ_DTYPE_TIME_ONLY:
223
-                            $form_time = $this->getControl('time', $key);
224
-                            $this->addElement($form_time, $key, $var);
225
-                            unset($form_time);
226
-                            break;
227
-
228
-                        case XOBJ_DTYPE_CURRENCY:
229
-                            $this->targetObject->setControl($key, array(
230
-                                'name' => 'text',
231
-                                'size' => '15'
232
-                            ));
233
-                            $form_currency = $this->getControl('text', $key);
234
-                            $this->addElement($form_currency, $key, $var);
235
-                            unset($form_currency);
236
-                            break;
237
-
238
-                        case XOBJ_DTYPE_URLLINK:
239
-                            $form_urllink = $this->getControl('urllink', $key);
240
-                            $this->addElement($form_urllink, $key, $var);
241
-                            unset($form_urllink);
242
-                            break;
243
-
244
-                        case XOBJ_DTYPE_FILE:
245
-                            $form_file = $this->getControl('richfile', $key);
246
-                            $this->addElement($form_file, $key, $var);
247
-                            unset($form_file);
248
-                            break;
249
-
250
-                        case XOBJ_DTYPE_TXTAREA:
251
-
252
-                            $form_text_area = $this->getTextArea($key, $var);
253
-                            $this->addElement($form_text_area, $key, $var);
254
-                            unset($form_text_area);
255
-                            break;
256
-
257
-                        case XOBJ_DTYPE_ARRAY:
258
-                            // TODO: To come...
259
-                            break;
260
-                        case XOBJ_DTYPE_SOURCE:
261
-                            // TODO: To come...
262
-                            break;
263
-                        case XOBJ_DTYPE_FORM_SECTION:
264
-                            $section_control = new SmartFormSection($key, $var['value']);
265
-                            $this->addElement($section_control, $key, $var);
266
-                            unset($section_control);
267
-                            break;
268
-                        case XOBJ_DTYPE_FORM_SECTION_CLOSE:
269
-                            $section_control = new SmartFormSectionClose($key, $var['value']);
270
-                            $this->addElement($section_control, $key, $var);
271
-                            unset($section_control);
272
-                            break;
273
-                    }
274
-                }
275
-            }
276
-        }
277
-        // Add an hidden field to store the URL of the page before this form
278
-        $this->addElement(new XoopsFormHidden('smart_page_before_form', smart_get_page_before_form()));
279
-    }
280
-
281
-    public function createPermissionControls()
282
-    {
283
-        $smartModuleConfig = $this->targetObject->handler->getModuleConfig();
284
-
285
-        $permissions = $this->targetObject->handler->getPermissions();
286
-
287
-        if ($permissions) {
288
-            $memberHandler = xoops_getHandler('member');
289
-            $group_list    = $memberHandler->getGroupList();
290
-            asort($group_list);
291
-            foreach ($permissions as $permission) {
292
-                if ($this->targetObject->isNew()) {
293
-                    if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) {
294
-                        $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']];
295
-                    }
296
-                } else {
297
-                    $groups_value = $this->targetObject->getGroupPerm($permission['perm_name']);
298
-                }
299
-                $groups_select = new XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true);
300
-                $groups_select->setDescription($permission['description']);
301
-                $groups_select->addOptionArray($group_list);
302
-                $this->addElement($groups_select);
303
-                unset($groups_select);
304
-            }
305
-        }
306
-    }
307
-
308
-    /**
309
-     * @param      $form_name
310
-     * @param      $form_caption
311
-     * @param bool $submit_button_caption
312
-     */
313
-    public function createButtons($form_name, $form_caption, $submit_button_caption = false)
314
-    {
315
-        $button_tray = new XoopsFormElementTray('', '');
316
-        $button_tray->addElement(new XoopsFormHidden('op', $form_name));
317
-        if (!$submit_button_caption) {
318
-            if ($this->targetObject->isNew()) {
319
-                $butt_create = new XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit');
320
-            } else {
321
-                $butt_create = new XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit');
322
-            }
323
-        } else {
324
-            $butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit');
325
-        }
326
-        $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"');
327
-        $button_tray->addElement($butt_create);
328
-
329
-        //creating custom buttons
330
-        if ($this->_custom_button) {
331
-            foreach ($this->_custom_button as $custom_button) {
332
-                $butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit');
333
-                if ($custom_button['onclick']) {
334
-                    $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"');
335
-                }
336
-                $button_tray->addElement($butt_custom);
337
-                unset($butt_custom);
338
-            }
339
-        }
340
-
341
-        // creating the "cancel" button
342
-        $butt_cancel = new XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button');
343
-        if ($this->_cancel_js_action) {
344
-            $butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"');
345
-        } else {
346
-            $butt_cancel->setExtra('onclick="history.go(-1)"');
347
-        }
348
-        $button_tray->addElement($butt_cancel);
349
-
350
-        $this->addElement($button_tray);
351
-    }
352
-
353
-    /**
354
-     * @param $controlName
355
-     * @param $key
356
-     * @return XoopsFormLabel
357
-     */
358
-    public function getControl($controlName, $key)
359
-    {
360
-        switch ($controlName) {
361
-            case 'check':
362
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php');
363
-                $control    = $this->targetObject->getControl($key);
364
-                $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
365
-                $controlObj->addOptionArray($control['options']);
366
-
367
-                return $controlObj;
368
-                break;
369
-
370
-            case 'color':
371
-                $control    = $this->targetObject->getControl($key);
372
-                $controlObj = new XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
373
-
374
-                return $controlObj;
375
-                break;
376
-
377
-            case 'radio':
378
-                $control = $this->targetObject->getControl($key);
379
-
380
-                $controlObj = new XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
381
-                $controlObj->addOptionArray($control['options']);
382
-
383
-                return $controlObj;
384
-                break;
385
-
386
-            case 'label':
387
-                return new XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key));
388
-                break;
389
-
390
-            case 'textarea':
391
-                return $this->getTextArea($key);
392
-
393
-            case 'theme':
394
-                return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
395
-
396
-            case 'theme_multi':
397
-                return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
398
-                break;
399
-
400
-            case 'timezone':
401
-                return new XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
402
-                break;
403
-
404
-            case 'group':
405
-                return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
406
-                break;
407
-
408
-            case 'group_multi':
409
-                return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
410
-                break;
411
-
412
-            /*case 'user':
169
+					if (!isset($controls[$key]['name']) || !$controls[$key]['name']) {
170
+						$controls[$key]['name'] = 'select';
171
+					}
172
+
173
+					$form_select = $this->getControl($controls[$key]['name'], $key);
174
+
175
+					// Adding on the form, the control for this field
176
+					$this->addElement($form_select, $key, $var);
177
+					unset($form_select);
178
+
179
+					// If this field don't have a specific control, we will use the standard one, depending on its data type
180
+				} else {
181
+					switch ($var['data_type']) {
182
+
183
+						case XOBJ_DTYPE_TXTBOX:
184
+
185
+							$form_text = $this->getControl('text', $key);
186
+							$this->addElement($form_text, $key, $var);
187
+							unset($form_text);
188
+							break;
189
+
190
+						case XOBJ_DTYPE_INT:
191
+							$this->targetObject->setControl($key, array(
192
+								'name' => 'text',
193
+								'size' => '5'
194
+							));
195
+							$form_text = $this->getControl('text', $key);
196
+							$this->addElement($form_text, $key, $var);
197
+							unset($form_text);
198
+							break;
199
+
200
+						case XOBJ_DTYPE_FLOAT:
201
+							$this->targetObject->setControl($key, array(
202
+								'name' => 'text',
203
+								'size' => '5'
204
+							));
205
+							$form_text = $this->getControl('text', $key);
206
+							$this->addElement($form_text, $key, $var);
207
+							unset($form_text);
208
+							break;
209
+
210
+						case XOBJ_DTYPE_LTIME:
211
+							$form_date_time = $this->getControl('date_time', $key);
212
+							$this->addElement($form_date_time, $key, $var);
213
+							unset($form_date_time);
214
+							break;
215
+
216
+						case XOBJ_DTYPE_STIME:
217
+							$form_date_time = $this->getControl('date', $key);
218
+							$this->addElement($form_date_time, $key, $var);
219
+							unset($form_date_time);
220
+							break;
221
+
222
+						case XOBJ_DTYPE_TIME_ONLY:
223
+							$form_time = $this->getControl('time', $key);
224
+							$this->addElement($form_time, $key, $var);
225
+							unset($form_time);
226
+							break;
227
+
228
+						case XOBJ_DTYPE_CURRENCY:
229
+							$this->targetObject->setControl($key, array(
230
+								'name' => 'text',
231
+								'size' => '15'
232
+							));
233
+							$form_currency = $this->getControl('text', $key);
234
+							$this->addElement($form_currency, $key, $var);
235
+							unset($form_currency);
236
+							break;
237
+
238
+						case XOBJ_DTYPE_URLLINK:
239
+							$form_urllink = $this->getControl('urllink', $key);
240
+							$this->addElement($form_urllink, $key, $var);
241
+							unset($form_urllink);
242
+							break;
243
+
244
+						case XOBJ_DTYPE_FILE:
245
+							$form_file = $this->getControl('richfile', $key);
246
+							$this->addElement($form_file, $key, $var);
247
+							unset($form_file);
248
+							break;
249
+
250
+						case XOBJ_DTYPE_TXTAREA:
251
+
252
+							$form_text_area = $this->getTextArea($key, $var);
253
+							$this->addElement($form_text_area, $key, $var);
254
+							unset($form_text_area);
255
+							break;
256
+
257
+						case XOBJ_DTYPE_ARRAY:
258
+							// TODO: To come...
259
+							break;
260
+						case XOBJ_DTYPE_SOURCE:
261
+							// TODO: To come...
262
+							break;
263
+						case XOBJ_DTYPE_FORM_SECTION:
264
+							$section_control = new SmartFormSection($key, $var['value']);
265
+							$this->addElement($section_control, $key, $var);
266
+							unset($section_control);
267
+							break;
268
+						case XOBJ_DTYPE_FORM_SECTION_CLOSE:
269
+							$section_control = new SmartFormSectionClose($key, $var['value']);
270
+							$this->addElement($section_control, $key, $var);
271
+							unset($section_control);
272
+							break;
273
+					}
274
+				}
275
+			}
276
+		}
277
+		// Add an hidden field to store the URL of the page before this form
278
+		$this->addElement(new XoopsFormHidden('smart_page_before_form', smart_get_page_before_form()));
279
+	}
280
+
281
+	public function createPermissionControls()
282
+	{
283
+		$smartModuleConfig = $this->targetObject->handler->getModuleConfig();
284
+
285
+		$permissions = $this->targetObject->handler->getPermissions();
286
+
287
+		if ($permissions) {
288
+			$memberHandler = xoops_getHandler('member');
289
+			$group_list    = $memberHandler->getGroupList();
290
+			asort($group_list);
291
+			foreach ($permissions as $permission) {
292
+				if ($this->targetObject->isNew()) {
293
+					if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) {
294
+						$groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']];
295
+					}
296
+				} else {
297
+					$groups_value = $this->targetObject->getGroupPerm($permission['perm_name']);
298
+				}
299
+				$groups_select = new XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true);
300
+				$groups_select->setDescription($permission['description']);
301
+				$groups_select->addOptionArray($group_list);
302
+				$this->addElement($groups_select);
303
+				unset($groups_select);
304
+			}
305
+		}
306
+	}
307
+
308
+	/**
309
+	 * @param      $form_name
310
+	 * @param      $form_caption
311
+	 * @param bool $submit_button_caption
312
+	 */
313
+	public function createButtons($form_name, $form_caption, $submit_button_caption = false)
314
+	{
315
+		$button_tray = new XoopsFormElementTray('', '');
316
+		$button_tray->addElement(new XoopsFormHidden('op', $form_name));
317
+		if (!$submit_button_caption) {
318
+			if ($this->targetObject->isNew()) {
319
+				$butt_create = new XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit');
320
+			} else {
321
+				$butt_create = new XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit');
322
+			}
323
+		} else {
324
+			$butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit');
325
+		}
326
+		$butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"');
327
+		$button_tray->addElement($butt_create);
328
+
329
+		//creating custom buttons
330
+		if ($this->_custom_button) {
331
+			foreach ($this->_custom_button as $custom_button) {
332
+				$butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit');
333
+				if ($custom_button['onclick']) {
334
+					$butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"');
335
+				}
336
+				$button_tray->addElement($butt_custom);
337
+				unset($butt_custom);
338
+			}
339
+		}
340
+
341
+		// creating the "cancel" button
342
+		$butt_cancel = new XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button');
343
+		if ($this->_cancel_js_action) {
344
+			$butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"');
345
+		} else {
346
+			$butt_cancel->setExtra('onclick="history.go(-1)"');
347
+		}
348
+		$button_tray->addElement($butt_cancel);
349
+
350
+		$this->addElement($button_tray);
351
+	}
352
+
353
+	/**
354
+	 * @param $controlName
355
+	 * @param $key
356
+	 * @return XoopsFormLabel
357
+	 */
358
+	public function getControl($controlName, $key)
359
+	{
360
+		switch ($controlName) {
361
+			case 'check':
362
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php');
363
+				$control    = $this->targetObject->getControl($key);
364
+				$controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
365
+				$controlObj->addOptionArray($control['options']);
366
+
367
+				return $controlObj;
368
+				break;
369
+
370
+			case 'color':
371
+				$control    = $this->targetObject->getControl($key);
372
+				$controlObj = new XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
373
+
374
+				return $controlObj;
375
+				break;
376
+
377
+			case 'radio':
378
+				$control = $this->targetObject->getControl($key);
379
+
380
+				$controlObj = new XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
381
+				$controlObj->addOptionArray($control['options']);
382
+
383
+				return $controlObj;
384
+				break;
385
+
386
+			case 'label':
387
+				return new XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key));
388
+				break;
389
+
390
+			case 'textarea':
391
+				return $this->getTextArea($key);
392
+
393
+			case 'theme':
394
+				return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
395
+
396
+			case 'theme_multi':
397
+				return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
398
+				break;
399
+
400
+			case 'timezone':
401
+				return new XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
402
+				break;
403
+
404
+			case 'group':
405
+				return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
406
+				break;
407
+
408
+			case 'group_multi':
409
+				return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
410
+				break;
411
+
412
+			/*case 'user':
413 413
              return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
414 414
              break;*/
415 415
 
416
-            case 'user_multi':
417
-                return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
418
-                break;
419
-
420
-            case 'password':
421
-                return new XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
422
-                break;
423
-
424
-            case 'country':
425
-                return new XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e'));
426
-                break;
427
-
428
-            case 'urllink':
429
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php');
430
-
431
-                return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
432
-                break;
433
-
434
-            case 'richfile':
435
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php');
436
-
437
-                return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
438
-                break;
439
-            case 'section':
440
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php');
441
-
442
-                return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
443
-                break;
444
-
445
-            default:
446
-                $classname = 'SmartForm' . ucfirst($controlName) . 'Element';
447
-                if (!class_exists($classname)) {
448
-                    if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) {
449
-                        include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php');
450
-                    } else {
451
-                        // perhaps this is a control created by the module
452
-                        $moduleName             = $this->targetObject->handler->_moduleName;
453
-                        $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
454
-                        $classname              = ucfirst($moduleName) . ucfirst($controlName) . 'Element';
455
-                        $classFileName          = strtolower($classname) . '.php';
456
-
457
-                        if (file_exists($moduleFormElementsPath . $classFileName)) {
458
-                            include_once($moduleFormElementsPath . $classFileName);
459
-                        } else {
460
-                            trigger_error($classname . ' Not found', E_USER_WARNING);
461
-
462
-                            return new XoopsFormLabel(); //Empty object
463
-                        }
464
-                    }
465
-                }
466
-
467
-                return new $classname($this->targetObject, $key);
468
-                break;
469
-        }
470
-    }
471
-
472
-    /**
473
-     * @param $key
474
-     * @return XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinyTextArea
475
-     */
476
-    public function getTextArea($key)
477
-    {
478
-        $var = $this->targetObject->vars[$key];
479
-
480
-        // if no control has been created, let's create a default one
481
-        if (!isset($this->targetObject->controls[$key])) {
482
-            $control = array(
483
-                'name'        => 'textarea',
484
-                'itemHandler' => false,
485
-                'method'      => false,
486
-                'module'      => false,
487
-                'form_editor' => 'default'
488
-            );
489
-        } else {
490
-            $control = $this->targetObject->controls[$key];
491
-        }
492
-        $xoops22 = smart_isXoops22();
493
-
494
-        $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
495
-        /**
496
-         * If the editor is 'default', retreive the default editor of this module
497
-         */
498
-        if ($form_editor === 'default') {
499
-            global $xoopsModuleConfig;
500
-            $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
501
-        }
502
-
503
-        $caption = $var['form_caption'];
504
-        $name    = $key;
505
-
506
-        $value = $this->targetObject->getVar($key);
507
-
508
-        $value = $this->targetObject->getValueFor($key, true);
509
-
510
-        $editor_configs          = array();
511
-        $editor_configs['name']  = $name;
512
-        $editor_configs['value'] = $value;
513
-        if ($form_editor !== 'textarea') {
514
-            $editor_configs['rows'] = 35;
515
-            $editor_configs['cols'] = 60;
516
-        }
517
-
518
-        if (isset($control['rows'])) {
519
-            $editor_configs['rows'] = $control['rows'];
520
-        }
521
-        if (isset($control['cols'])) {
522
-            $editor_configs['cols'] = $control['cols'];
523
-        }
524
-
525
-        $editor_configs['width']  = '100%';
526
-        $editor_configs['height'] = '400px';
527
-
528
-        $dhtml            = true;
529
-        $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
530
-
531
-        if (file_exists($xoopseditorclass)) {
532
-            include_once($xoopseditorclass);
533
-            $editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea');
534
-        } else {
535
-            switch ($form_editor) {
536
-
537
-                case 'tiny':
538
-                    if (!$xoops22) {
539
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php');
541
-                            $editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
542
-                        } else {
543
-                            if ($dhtml) {
544
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
545
-                            } else {
546
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
547
-                            }
548
-                        }
549
-                    } else {
550
-                        $editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
551
-                    }
552
-                    break;
553
-
554
-                case 'dhtmltextarea':
555
-                case 'dhtmltext':
556
-                    $editor = new XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60);
557
-                    if ($var['form_dsc']) {
558
-                        $editor->setDescription($var['form_dsc']);
559
-                    }
560
-                    break;
561
-
562
-                case 'fckeditor':
563
-                    if (!$xoops22) {
564
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php');
566
-                            $editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
567
-                        } else {
568
-                            if ($dhtml) {
569
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
570
-                            } else {
571
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
572
-                            }
573
-                        }
574
-                    } else {
575
-                        $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
576
-                    }
577
-                    break;
578
-
579
-                case 'inbetween':
580
-                    if (!$xoops22) {
581
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php');
583
-                            $editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
584
-                        } else {
585
-                            if ($dhtml) {
586
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
587
-                            } else {
588
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
589
-                            }
590
-                        }
591
-                    } else {
592
-                        $editor = new XoopsFormEditor($caption, 'inbetween', $editor_configs);
593
-                    }
594
-                    break;
595
-
596
-                case 'koivi':
597
-                    if (!$xoops22) {
598
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
599
-                            include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
600
-                            $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
601
-                        } else {
602
-                            if ($dhtml) {
603
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
604
-                            } else {
605
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
606
-                            }
607
-                        }
608
-                    } else {
609
-                        $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
610
-                    }
611
-                    break;
612
-
613
-                case 'spaw':
614
-                    if (!$xoops22) {
615
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) {
616
-                            include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php');
617
-                            $editor = new XoopsFormSpaw($caption, $name, $value);
618
-                        }
619
-                    } else {
620
-                        $editor = new XoopsFormEditor($caption, 'spaw', $editor_configs);
621
-                    }
622
-                    break;
623
-
624
-                case 'htmlarea':
625
-                    if (!$xoops22) {
626
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
627
-                            include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
628
-                            $editor = new XoopsFormHtmlarea($caption, $name, $value);
629
-                        }
630
-                    } else {
631
-                        $editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs);
632
-                    }
633
-                    break;
634
-
635
-                default:
636
-                case 'textarea':
637
-                    $form_rows = isset($control['rows']) ? $control['rows'] : 5;
638
-                    $form_cols = isset($control['cols']) ? $control['cols'] : 60;
639
-
640
-                    $editor = new XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols);
641
-                    if ($var['form_dsc']) {
642
-                        $editor->setDescription($var['form_dsc']);
643
-                    }
644
-                    break;
645
-
646
-            }
647
-        }
648
-
649
-        return $editor;
650
-    }
651
-
652
-    /**
653
-     * @param                  $key
654
-     * @param                  $var
655
-     * @param  bool            $multiple
656
-     * @return XoopsFormSelect
657
-     */
658
-    public function getThemeSelect($key, $var, $multiple = false)
659
-    {
660
-        $size         = $multiple ? 5 : 1;
661
-        $theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple);
662
-
663
-        $handle  = opendir(XOOPS_THEME_PATH . '/');
664
-        $dirlist = array();
665
-        while (false !== ($file = readdir($handle))) {
666
-            if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
667
-                $dirlist[$file] = $file;
668
-            }
669
-        }
670
-        closedir($handle);
671
-        if (!empty($dirlist)) {
672
-            asort($dirlist);
673
-            $theme_select->addOptionArray($dirlist);
674
-        }
675
-
676
-        return $theme_select;
677
-    }
678
-
679
-    /**
680
-     * @param $keyname
681
-     * @return bool
682
-     */
683
-    public function &getElementById($keyname)
684
-    {
685
-        foreach ($this->_elements as $eleObj) {
686
-            if ($eleObj->getName() == $keyname) {
687
-                $ret =& $eleObj;
688
-                break;
689
-            }
690
-        }
691
-
692
-        return isset($ret) ? $ret : false;
693
-    }
694
-
695
-    /**
696
-     * create HTML to output the form as a theme-enabled table with validation.
697
-     *
698
-     * @return string
699
-     */
700
-    public function render()
701
-    {
702
-        $required = $this->getRequired();
703
-        $ret      = "
416
+			case 'user_multi':
417
+				return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
418
+				break;
419
+
420
+			case 'password':
421
+				return new XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
422
+				break;
423
+
424
+			case 'country':
425
+				return new XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e'));
426
+				break;
427
+
428
+			case 'urllink':
429
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php');
430
+
431
+				return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
432
+				break;
433
+
434
+			case 'richfile':
435
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php');
436
+
437
+				return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
438
+				break;
439
+			case 'section':
440
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php');
441
+
442
+				return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
443
+				break;
444
+
445
+			default:
446
+				$classname = 'SmartForm' . ucfirst($controlName) . 'Element';
447
+				if (!class_exists($classname)) {
448
+					if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) {
449
+						include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php');
450
+					} else {
451
+						// perhaps this is a control created by the module
452
+						$moduleName             = $this->targetObject->handler->_moduleName;
453
+						$moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
454
+						$classname              = ucfirst($moduleName) . ucfirst($controlName) . 'Element';
455
+						$classFileName          = strtolower($classname) . '.php';
456
+
457
+						if (file_exists($moduleFormElementsPath . $classFileName)) {
458
+							include_once($moduleFormElementsPath . $classFileName);
459
+						} else {
460
+							trigger_error($classname . ' Not found', E_USER_WARNING);
461
+
462
+							return new XoopsFormLabel(); //Empty object
463
+						}
464
+					}
465
+				}
466
+
467
+				return new $classname($this->targetObject, $key);
468
+				break;
469
+		}
470
+	}
471
+
472
+	/**
473
+	 * @param $key
474
+	 * @return XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinyTextArea
475
+	 */
476
+	public function getTextArea($key)
477
+	{
478
+		$var = $this->targetObject->vars[$key];
479
+
480
+		// if no control has been created, let's create a default one
481
+		if (!isset($this->targetObject->controls[$key])) {
482
+			$control = array(
483
+				'name'        => 'textarea',
484
+				'itemHandler' => false,
485
+				'method'      => false,
486
+				'module'      => false,
487
+				'form_editor' => 'default'
488
+			);
489
+		} else {
490
+			$control = $this->targetObject->controls[$key];
491
+		}
492
+		$xoops22 = smart_isXoops22();
493
+
494
+		$form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
495
+		/**
496
+		 * If the editor is 'default', retreive the default editor of this module
497
+		 */
498
+		if ($form_editor === 'default') {
499
+			global $xoopsModuleConfig;
500
+			$form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
501
+		}
502
+
503
+		$caption = $var['form_caption'];
504
+		$name    = $key;
505
+
506
+		$value = $this->targetObject->getVar($key);
507
+
508
+		$value = $this->targetObject->getValueFor($key, true);
509
+
510
+		$editor_configs          = array();
511
+		$editor_configs['name']  = $name;
512
+		$editor_configs['value'] = $value;
513
+		if ($form_editor !== 'textarea') {
514
+			$editor_configs['rows'] = 35;
515
+			$editor_configs['cols'] = 60;
516
+		}
517
+
518
+		if (isset($control['rows'])) {
519
+			$editor_configs['rows'] = $control['rows'];
520
+		}
521
+		if (isset($control['cols'])) {
522
+			$editor_configs['cols'] = $control['cols'];
523
+		}
524
+
525
+		$editor_configs['width']  = '100%';
526
+		$editor_configs['height'] = '400px';
527
+
528
+		$dhtml            = true;
529
+		$xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
530
+
531
+		if (file_exists($xoopseditorclass)) {
532
+			include_once($xoopseditorclass);
533
+			$editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea');
534
+		} else {
535
+			switch ($form_editor) {
536
+
537
+				case 'tiny':
538
+					if (!$xoops22) {
539
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php');
541
+							$editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
542
+						} else {
543
+							if ($dhtml) {
544
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
545
+							} else {
546
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
547
+							}
548
+						}
549
+					} else {
550
+						$editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
551
+					}
552
+					break;
553
+
554
+				case 'dhtmltextarea':
555
+				case 'dhtmltext':
556
+					$editor = new XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60);
557
+					if ($var['form_dsc']) {
558
+						$editor->setDescription($var['form_dsc']);
559
+					}
560
+					break;
561
+
562
+				case 'fckeditor':
563
+					if (!$xoops22) {
564
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php');
566
+							$editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
567
+						} else {
568
+							if ($dhtml) {
569
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
570
+							} else {
571
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
572
+							}
573
+						}
574
+					} else {
575
+						$editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
576
+					}
577
+					break;
578
+
579
+				case 'inbetween':
580
+					if (!$xoops22) {
581
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php');
583
+							$editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
584
+						} else {
585
+							if ($dhtml) {
586
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
587
+							} else {
588
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
589
+							}
590
+						}
591
+					} else {
592
+						$editor = new XoopsFormEditor($caption, 'inbetween', $editor_configs);
593
+					}
594
+					break;
595
+
596
+				case 'koivi':
597
+					if (!$xoops22) {
598
+						if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
599
+							include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
600
+							$editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
601
+						} else {
602
+							if ($dhtml) {
603
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
604
+							} else {
605
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
606
+							}
607
+						}
608
+					} else {
609
+						$editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
610
+					}
611
+					break;
612
+
613
+				case 'spaw':
614
+					if (!$xoops22) {
615
+						if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) {
616
+							include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php');
617
+							$editor = new XoopsFormSpaw($caption, $name, $value);
618
+						}
619
+					} else {
620
+						$editor = new XoopsFormEditor($caption, 'spaw', $editor_configs);
621
+					}
622
+					break;
623
+
624
+				case 'htmlarea':
625
+					if (!$xoops22) {
626
+						if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
627
+							include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
628
+							$editor = new XoopsFormHtmlarea($caption, $name, $value);
629
+						}
630
+					} else {
631
+						$editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs);
632
+					}
633
+					break;
634
+
635
+				default:
636
+				case 'textarea':
637
+					$form_rows = isset($control['rows']) ? $control['rows'] : 5;
638
+					$form_cols = isset($control['cols']) ? $control['cols'] : 60;
639
+
640
+					$editor = new XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols);
641
+					if ($var['form_dsc']) {
642
+						$editor->setDescription($var['form_dsc']);
643
+					}
644
+					break;
645
+
646
+			}
647
+		}
648
+
649
+		return $editor;
650
+	}
651
+
652
+	/**
653
+	 * @param                  $key
654
+	 * @param                  $var
655
+	 * @param  bool            $multiple
656
+	 * @return XoopsFormSelect
657
+	 */
658
+	public function getThemeSelect($key, $var, $multiple = false)
659
+	{
660
+		$size         = $multiple ? 5 : 1;
661
+		$theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple);
662
+
663
+		$handle  = opendir(XOOPS_THEME_PATH . '/');
664
+		$dirlist = array();
665
+		while (false !== ($file = readdir($handle))) {
666
+			if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
667
+				$dirlist[$file] = $file;
668
+			}
669
+		}
670
+		closedir($handle);
671
+		if (!empty($dirlist)) {
672
+			asort($dirlist);
673
+			$theme_select->addOptionArray($dirlist);
674
+		}
675
+
676
+		return $theme_select;
677
+	}
678
+
679
+	/**
680
+	 * @param $keyname
681
+	 * @return bool
682
+	 */
683
+	public function &getElementById($keyname)
684
+	{
685
+		foreach ($this->_elements as $eleObj) {
686
+			if ($eleObj->getName() == $keyname) {
687
+				$ret =& $eleObj;
688
+				break;
689
+			}
690
+		}
691
+
692
+		return isset($ret) ? $ret : false;
693
+	}
694
+
695
+	/**
696
+	 * create HTML to output the form as a theme-enabled table with validation.
697
+	 *
698
+	 * @return string
699
+	 */
700
+	public function render()
701
+	{
702
+		$required = $this->getRequired();
703
+		$ret      = "
704 704
             <form name='" .
705
-                    $this->getName() .
706
-                    "' id='" .
707
-                    $this->getName() .
708
-                    "' action='" .
709
-                    $this->getAction() .
710
-                    "' method='" .
711
-                    $this->getMethod() .
712
-                    "' onsubmit='return xoopsFormValidate_" .
713
-                    $this->getName() .
714
-                    "(this);'" .
715
-                    $this->getExtra() .
716
-                    ">
705
+					$this->getName() .
706
+					"' id='" .
707
+					$this->getName() .
708
+					"' action='" .
709
+					$this->getAction() .
710
+					"' method='" .
711
+					$this->getMethod() .
712
+					"' onsubmit='return xoopsFormValidate_" .
713
+					$this->getName() .
714
+					"(this);'" .
715
+					$this->getExtra() .
716
+					">
717 717
             <table width='100%' class='outer' cellspacing='1'>
718 718
             <tr><th colspan='2'>" .
719
-                    $this->getTitle() .
720
-                    '</th></tr>
719
+					$this->getTitle() .
720
+					'</th></tr>
721 721
         ';
722
-        $hidden   = '';
723
-        $class    = 'even';
724
-        foreach ($this->getElements() as $ele) {
725
-            if (!is_object($ele)) {
726
-                $ret .= $ele;
727
-            } elseif (!$ele->isHidden()) {
728
-                //$class = ( $class == 'even' ) ? 'odd': 'even';
729
-                $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption();
730
-                if ($ele->getDescription() !== '') {
731
-                    $ret .= '<br><br><span style="font-weight: normal;">' . $ele->getDescription() . '</span>';
732
-                }
733
-                $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n";
734
-            } else {
735
-                $hidden .= $ele->render();
736
-            }
737
-        }
738
-        $ret .= "</table>\n$hidden\n</form>\n";
739
-        $ret .= $this->renderValidationJS(true);
740
-
741
-        return $ret;
742
-    }
743
-
744
-    /**
745
-     * assign to smarty form template instead of displaying directly
746
-     *
747
-     * @param XoopsTpl &$tpl       reference to a {@link Smarty} object
748
-     * @param bool   $smartyName
749
-     * @see     Smarty
750
-     */
751
-    public function assign(XoopsTpl $tpl, $smartyName = false)
752
-    {
753
-        $i        = 0;
754
-        $elements = array();
755
-        foreach ($this->getElements() as $ele) {
756
-            $n                             = ($ele->getName() !== '') ? $ele->getName() : $i;
757
-            $elements[$n]['name']          = $ele->getName();
758
-            $elements[$n]['caption']       = $ele->getCaption();
759
-            $elements[$n]['body']          = $ele->render();
760
-            $elements[$n]['hidden']        = $ele->isHidden();
761
-            $elements[$n]['section']       = strtolower(get_class($ele)) == strtolower('SmartFormSection');
762
-            $elements[$n]['section_close'] = get_class($ele) === 'SmartFormSectionClose';
763
-            $elements[$n]['hide']          = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false;
764
-            if ($ele->getDescription() !== '') {
765
-                $elements[$n]['description'] = $ele->getDescription();
766
-            }
767
-            ++$i;
768
-        }
769
-        $js = $this->renderValidationJS();
770
-        if (!$smartyName) {
771
-            $smartyName = $this->getName();
772
-        }
773
-
774
-        $tpl->assign($smartyName, array(
775
-            'title'      => $this->getTitle(),
776
-            'name'       => $this->getName(),
777
-            'action'     => $this->getAction(),
778
-            'method'     => $this->getMethod(),
779
-            'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(),
780
-            'javascript' => $js,
781
-            'elements'   => $elements
782
-        ));
783
-    }
784
-
785
-    /**
786
-     * @param  bool   $withtags
787
-     * @return string
788
-     */
789
-    public function renderValidationJS($withtags = true)
790
-    {
791
-        $js = '';
792
-        if ($withtags) {
793
-            $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
794
-        }
795
-        $myts     = MyTextSanitizer::getInstance();
796
-        $formname = $this->getName();
797
-        $js .= "function xoopsFormValidate_{$formname}(myform) {";
798
-        // First, output code to check required elements
799
-        $elements = $this->getRequired();
800
-        foreach ($elements as $elt) {
801
-            $eltname    = $elt->getName();
802
-            $eltcaption = trim($elt->getCaption());
803
-            $eltmsg     = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
804
-            $eltmsg     = str_replace('"', '\"', stripslashes($eltmsg));
805
-            if (strtolower(get_class($elt)) === 'xoopsformradio') {
806
-                $js .= 'var myOption = -1;';
807
-                $js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) {
722
+		$hidden   = '';
723
+		$class    = 'even';
724
+		foreach ($this->getElements() as $ele) {
725
+			if (!is_object($ele)) {
726
+				$ret .= $ele;
727
+			} elseif (!$ele->isHidden()) {
728
+				//$class = ( $class == 'even' ) ? 'odd': 'even';
729
+				$ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption();
730
+				if ($ele->getDescription() !== '') {
731
+					$ret .= '<br><br><span style="font-weight: normal;">' . $ele->getDescription() . '</span>';
732
+				}
733
+				$ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n";
734
+			} else {
735
+				$hidden .= $ele->render();
736
+			}
737
+		}
738
+		$ret .= "</table>\n$hidden\n</form>\n";
739
+		$ret .= $this->renderValidationJS(true);
740
+
741
+		return $ret;
742
+	}
743
+
744
+	/**
745
+	 * assign to smarty form template instead of displaying directly
746
+	 *
747
+	 * @param XoopsTpl &$tpl       reference to a {@link Smarty} object
748
+	 * @param bool   $smartyName
749
+	 * @see     Smarty
750
+	 */
751
+	public function assign(XoopsTpl $tpl, $smartyName = false)
752
+	{
753
+		$i        = 0;
754
+		$elements = array();
755
+		foreach ($this->getElements() as $ele) {
756
+			$n                             = ($ele->getName() !== '') ? $ele->getName() : $i;
757
+			$elements[$n]['name']          = $ele->getName();
758
+			$elements[$n]['caption']       = $ele->getCaption();
759
+			$elements[$n]['body']          = $ele->render();
760
+			$elements[$n]['hidden']        = $ele->isHidden();
761
+			$elements[$n]['section']       = strtolower(get_class($ele)) == strtolower('SmartFormSection');
762
+			$elements[$n]['section_close'] = get_class($ele) === 'SmartFormSectionClose';
763
+			$elements[$n]['hide']          = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false;
764
+			if ($ele->getDescription() !== '') {
765
+				$elements[$n]['description'] = $ele->getDescription();
766
+			}
767
+			++$i;
768
+		}
769
+		$js = $this->renderValidationJS();
770
+		if (!$smartyName) {
771
+			$smartyName = $this->getName();
772
+		}
773
+
774
+		$tpl->assign($smartyName, array(
775
+			'title'      => $this->getTitle(),
776
+			'name'       => $this->getName(),
777
+			'action'     => $this->getAction(),
778
+			'method'     => $this->getMethod(),
779
+			'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(),
780
+			'javascript' => $js,
781
+			'elements'   => $elements
782
+		));
783
+	}
784
+
785
+	/**
786
+	 * @param  bool   $withtags
787
+	 * @return string
788
+	 */
789
+	public function renderValidationJS($withtags = true)
790
+	{
791
+		$js = '';
792
+		if ($withtags) {
793
+			$js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
794
+		}
795
+		$myts     = MyTextSanitizer::getInstance();
796
+		$formname = $this->getName();
797
+		$js .= "function xoopsFormValidate_{$formname}(myform) {";
798
+		// First, output code to check required elements
799
+		$elements = $this->getRequired();
800
+		foreach ($elements as $elt) {
801
+			$eltname    = $elt->getName();
802
+			$eltcaption = trim($elt->getCaption());
803
+			$eltmsg     = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
804
+			$eltmsg     = str_replace('"', '\"', stripslashes($eltmsg));
805
+			if (strtolower(get_class($elt)) === 'xoopsformradio') {
806
+				$js .= 'var myOption = -1;';
807
+				$js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) {
808 808
                     if (myform.{$eltname}[i].checked) {
809 809
                         myOption = i; i = -1;
810 810
                     }
811 811
                 }
812 812
                 if (myOption == -1) {
813 813
                     window.alert(\"{$eltmsg}\"); myform.{$eltname}[0].focus(); return false; }\n";
814
-            } elseif (strtolower(get_class($elt)) === 'smartformselect_multielement') {
815
-                $js .= 'var hasSelections = false;';
816
-                $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
814
+			} elseif (strtolower(get_class($elt)) === 'smartformselect_multielement') {
815
+				$js .= 'var hasSelections = false;';
816
+				$js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
817 817
                     if (myform['{$eltname}[]'].options[i].selected) {
818 818
                         hasSelections = true;
819 819
                     }
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
                 }
822 822
                 if (hasSelections == false) {
823 823
                     window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'].options[0].focus(); return false; }\n";
824
-            } elseif (strtolower(get_class($elt)) === 'xoopsformcheckbox' || strtolower(get_class($elt)) === 'smartformcheckelement') {
825
-                $js .= 'var hasSelections = false;';
826
-                //sometimes, there is an implicit '[]', sometimes not
827
-                if (strpos($eltname, '[') === false) {
828
-                    $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
824
+			} elseif (strtolower(get_class($elt)) === 'xoopsformcheckbox' || strtolower(get_class($elt)) === 'smartformcheckelement') {
825
+				$js .= 'var hasSelections = false;';
826
+				//sometimes, there is an implicit '[]', sometimes not
827
+				if (strpos($eltname, '[') === false) {
828
+					$js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
829 829
                         if (myform['{$eltname}[]'][i].checked) {
830 830
                             hasSelections = true;
831 831
                         }
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
                     }
834 834
                     if (hasSelections == false) {
835 835
                         window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n";
836
-                } else {
837
-                    $js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) {
836
+				} else {
837
+					$js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) {
838 838
                         if (myform['{$eltname}'][i].checked) {
839 839
                             hasSelections = true;
840 840
                         }
@@ -842,25 +842,25 @@  discard block
 block discarded – undo
842 842
                     }
843 843
                     if (hasSelections == false) {
844 844
                         window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n";
845
-                }
846
-            } else {
847
-                $js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
848
-            }
849
-        }
850
-        // Now, handle custom validation code
851
-        $elements =& $this->getElements(true);
852
-        foreach ($elements as $elt) {
853
-            if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) !== 'xoopsformcheckbox') {
854
-                if ($eltjs = $elt->renderValidationJS()) {
855
-                    $js .= $eltjs . "\n";
856
-                }
857
-            }
858
-        }
859
-        $js .= "return true;\n}\n";
860
-        if ($withtags) {
861
-            $js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n";
862
-        }
863
-
864
-        return $js;
865
-    }
845
+				}
846
+			} else {
847
+				$js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
848
+			}
849
+		}
850
+		// Now, handle custom validation code
851
+		$elements =& $this->getElements(true);
852
+		foreach ($elements as $elt) {
853
+			if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) !== 'xoopsformcheckbox') {
854
+				if ($eltjs = $elt->renderValidationJS()) {
855
+					$js .= $eltjs . "\n";
856
+				}
857
+			}
858
+		}
859
+		$js .= "return true;\n}\n";
860
+		if ($withtags) {
861
+			$js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n";
862
+		}
863
+
864
+		return $js;
865
+	}
866 866
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Including the XoopsFormLoader classes
17 17
  */
18
-include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
19
-include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php';
20
-include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsectionclose.php';
18
+include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
19
+include_once SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformsection.php';
20
+include_once SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformsectionclose.php';
21 21
 
22 22
 /**
23 23
  * SmartForm base class
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function __construct(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false)
54 54
     {
55
-        $this->targetObject           =& $target;
55
+        $this->targetObject           = & $target;
56 56
         $this->form_fields            = $form_fields;
57 57
         $this->_cancel_js_action      = $cancel_js_action;
58 58
         $this->_captcha               = $captcha;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function addCaptcha()
82 82
     {
83
-        include_once(SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php');
83
+        include_once(SMARTOBJECT_ROOT_PATH.'include/captcha/formcaptcha.php');
84 84
         $this->addElement(new XoopsFormCaptcha(), true);
85 85
     }
86 86
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function addCustomButton($name, $caption, $onclick = false)
93 93
     {
94
-        $custom_button_array    = array(
94
+        $custom_button_array = array(
95 95
             'name'    => $name,
96 96
             'caption' => $caption,
97 97
             'onclick' => $onclick
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         if ($key) {
113 113
             if ($this->targetObject->vars[$key]['readonly']) {
114 114
                 $formElement->setExtra('disabled="disabled"');
115
-                $formElement->setName($key . '-readonly');
115
+                $formElement->setName($key.'-readonly');
116 116
                 // Since this element is disable, we still want to pass it's value in the form
117 117
                 $hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
118 118
                 $this->addElement($hidden);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 $this->addElement($hidden);
124 124
                 $otherExtra      = isset($var['form_extra']) ? $var['form_extra'] : '';
125 125
                 $onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()";
126
-                $formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
126
+                $formElement->setExtra('onchange="'.$onchangedString.'"'.' '.$otherExtra);
127 127
             } else {
128 128
                 if (isset($var['form_extra'])) {
129 129
                     $formElement->setExtra($var['form_extra']);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
             asort($group_list);
291 291
             foreach ($permissions as $permission) {
292 292
                 if ($this->targetObject->isNew()) {
293
-                    if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) {
294
-                        $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']];
293
+                    if (isset($smartModuleConfig['def_perm_'.$permission['perm_name']])) {
294
+                        $groups_value = $smartModuleConfig['def_perm_'.$permission['perm_name']];
295 295
                     }
296 296
                 } else {
297 297
                     $groups_value = $this->targetObject->getGroupPerm($permission['perm_name']);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         } else {
324 324
             $butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit');
325 325
         }
326
-        $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"');
326
+        $butt_create->setExtra('onclick="this.form.elements.op.value=\''.$form_name.'\'"');
327 327
         $button_tray->addElement($butt_create);
328 328
 
329 329
         //creating custom buttons
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             foreach ($this->_custom_button as $custom_button) {
332 332
                 $butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit');
333 333
                 if ($custom_button['onclick']) {
334
-                    $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"');
334
+                    $butt_custom->setExtra('onclick="'.$custom_button['onclick'].'"');
335 335
                 }
336 336
                 $button_tray->addElement($butt_custom);
337 337
                 unset($butt_custom);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         // creating the "cancel" button
342 342
         $butt_cancel = new XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button');
343 343
         if ($this->_cancel_js_action) {
344
-            $butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"');
344
+            $butt_cancel->setExtra('onclick="'.$this->_cancel_js_action.'"');
345 345
         } else {
346 346
             $butt_cancel->setExtra('onclick="history.go(-1)"');
347 347
         }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     {
360 360
         switch ($controlName) {
361 361
             case 'check':
362
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php');
362
+                include_once(SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformcheckelement.php');
363 363
                 $control    = $this->targetObject->getControl($key);
364 364
                 $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
365 365
                 $controlObj->addOptionArray($control['options']);
@@ -426,38 +426,38 @@  discard block
 block discarded – undo
426 426
                 break;
427 427
 
428 428
             case 'urllink':
429
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php');
429
+                include_once(SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformurllinkelement.php');
430 430
 
431 431
                 return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
432 432
                 break;
433 433
 
434 434
             case 'richfile':
435
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php');
435
+                include_once(SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformrichfileelement.php');
436 436
 
437 437
                 return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
438 438
                 break;
439 439
             case 'section':
440
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php');
440
+                include_once(SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformsection.php');
441 441
 
442 442
                 return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
443 443
                 break;
444 444
 
445 445
             default:
446
-                $classname = 'SmartForm' . ucfirst($controlName) . 'Element';
446
+                $classname = 'SmartForm'.ucfirst($controlName).'Element';
447 447
                 if (!class_exists($classname)) {
448
-                    if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) {
449
-                        include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php');
448
+                    if (file_exists(SMARTOBJECT_ROOT_PATH.'class/form/elements/'.strtolower($classname).'.php')) {
449
+                        include_once(SMARTOBJECT_ROOT_PATH.'class/form/elements/'.strtolower($classname).'.php');
450 450
                     } else {
451 451
                         // perhaps this is a control created by the module
452 452
                         $moduleName             = $this->targetObject->handler->_moduleName;
453
-                        $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
454
-                        $classname              = ucfirst($moduleName) . ucfirst($controlName) . 'Element';
455
-                        $classFileName          = strtolower($classname) . '.php';
453
+                        $moduleFormElementsPath = $this->targetObject->handler->_modulePath.'class/form/elements/';
454
+                        $classname              = ucfirst($moduleName).ucfirst($controlName).'Element';
455
+                        $classFileName          = strtolower($classname).'.php';
456 456
 
457
-                        if (file_exists($moduleFormElementsPath . $classFileName)) {
458
-                            include_once($moduleFormElementsPath . $classFileName);
457
+                        if (file_exists($moduleFormElementsPath.$classFileName)) {
458
+                            include_once($moduleFormElementsPath.$classFileName);
459 459
                         } else {
460
-                            trigger_error($classname . ' Not found', E_USER_WARNING);
460
+                            trigger_error($classname.' Not found', E_USER_WARNING);
461 461
 
462 462
                             return new XoopsFormLabel(); //Empty object
463 463
                         }
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         $editor_configs['height'] = '400px';
527 527
 
528 528
         $dhtml            = true;
529
-        $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
529
+        $xoopseditorclass = XOOPS_ROOT_PATH.'/class/xoopsform/formeditor.php';
530 530
 
531 531
         if (file_exists($xoopseditorclass)) {
532 532
             include_once($xoopseditorclass);
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
 
537 537
                 case 'tiny':
538 538
                     if (!$xoops22) {
539
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php');
539
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
+                            include_once(XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinytextarea.php');
541 541
                             $editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
542 542
                         } else {
543 543
                             if ($dhtml) {
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 
562 562
                 case 'fckeditor':
563 563
                     if (!$xoops22) {
564
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php');
564
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
+                            include_once(XOOPS_ROOT_PATH.'/class/xoopseditor/fckeditor/formfckeditor.php');
566 566
                             $editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
567 567
                         } else {
568 568
                             if ($dhtml) {
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
 
579 579
                 case 'inbetween':
580 580
                     if (!$xoops22) {
581
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php');
581
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
+                            include_once(XOOPS_ROOT_PATH.'/class/xoopseditor/inbetween/forminbetweentextarea.php');
583 583
                             $editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
584 584
                         } else {
585 585
                             if ($dhtml) {
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 
596 596
                 case 'koivi':
597 597
                     if (!$xoops22) {
598
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
599
-                            include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
598
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/wysiwyg/formwysiwygtextarea.php')) {
599
+                            include_once(XOOPS_ROOT_PATH.'/class/wysiwyg/formwysiwygtextarea.php');
600 600
                             $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
601 601
                         } else {
602 602
                             if ($dhtml) {
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 
613 613
                 case 'spaw':
614 614
                     if (!$xoops22) {
615
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) {
616
-                            include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php');
615
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/spaw/formspaw.php')) {
616
+                            include_once(XOOPS_ROOT_PATH.'/class/spaw/formspaw.php');
617 617
                             $editor = new XoopsFormSpaw($caption, $name, $value);
618 618
                         }
619 619
                     } else {
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 
624 624
                 case 'htmlarea':
625 625
                     if (!$xoops22) {
626
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
627
-                            include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
626
+                        if (is_readable(XOOPS_ROOT_PATH.'/class/htmlarea/formhtmlarea.php')) {
627
+                            include_once(XOOPS_ROOT_PATH.'/class/htmlarea/formhtmlarea.php');
628 628
                             $editor = new XoopsFormHtmlarea($caption, $name, $value);
629 629
                         }
630 630
                     } else {
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
         $size         = $multiple ? 5 : 1;
661 661
         $theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple);
662 662
 
663
-        $handle  = opendir(XOOPS_THEME_PATH . '/');
663
+        $handle  = opendir(XOOPS_THEME_PATH.'/');
664 664
         $dirlist = array();
665 665
         while (false !== ($file = readdir($handle))) {
666
-            if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
666
+            if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
667 667
                 $dirlist[$file] = $file;
668 668
             }
669 669
         }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
     {
685 685
         foreach ($this->_elements as $eleObj) {
686 686
             if ($eleObj->getName() == $keyname) {
687
-                $ret =& $eleObj;
687
+                $ret = & $eleObj;
688 688
                 break;
689 689
             }
690 690
         }
@@ -702,21 +702,21 @@  discard block
 block discarded – undo
702 702
         $required = $this->getRequired();
703 703
         $ret      = "
704 704
             <form name='" .
705
-                    $this->getName() .
706
-                    "' id='" .
707
-                    $this->getName() .
708
-                    "' action='" .
709
-                    $this->getAction() .
710
-                    "' method='" .
711
-                    $this->getMethod() .
712
-                    "' onsubmit='return xoopsFormValidate_" .
713
-                    $this->getName() .
714
-                    "(this);'" .
715
-                    $this->getExtra() .
705
+                    $this->getName().
706
+                    "' id='".
707
+                    $this->getName().
708
+                    "' action='".
709
+                    $this->getAction().
710
+                    "' method='".
711
+                    $this->getMethod().
712
+                    "' onsubmit='return xoopsFormValidate_".
713
+                    $this->getName().
714
+                    "(this);'".
715
+                    $this->getExtra().
716 716
                     ">
717 717
             <table width='100%' class='outer' cellspacing='1'>
718 718
             <tr><th colspan='2'>" .
719
-                    $this->getTitle() .
719
+                    $this->getTitle().
720 720
                     '</th></tr>
721 721
         ';
722 722
         $hidden   = '';
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
                 $ret .= $ele;
727 727
             } elseif (!$ele->isHidden()) {
728 728
                 //$class = ( $class == 'even' ) ? 'odd': 'even';
729
-                $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption();
729
+                $ret .= "<tr id='".$ele->getName()."' valign='top' align='left'><td class='head'>".$ele->getCaption();
730 730
                 if ($ele->getDescription() !== '') {
731
-                    $ret .= '<br><br><span style="font-weight: normal;">' . $ele->getDescription() . '</span>';
731
+                    $ret .= '<br><br><span style="font-weight: normal;">'.$ele->getDescription().'</span>';
732 732
                 }
733
-                $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n";
733
+                $ret .= "</td><td class='$class'>".$ele->render()."</td></tr>\n";
734 734
             } else {
735 735
                 $hidden .= $ele->render();
736 736
             }
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
             'name'       => $this->getName(),
777 777
             'action'     => $this->getAction(),
778 778
             'method'     => $this->getMethod(),
779
-            'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(),
779
+            'extra'      => 'onsubmit="return xoopsFormValidate_'.$this->getName().'(this);"'.$this->getExtra(),
780 780
             'javascript' => $js,
781 781
             'elements'   => $elements
782 782
         ));
@@ -844,15 +844,15 @@  discard block
 block discarded – undo
844 844
                         window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n";
845 845
                 }
846 846
             } else {
847
-                $js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
847
+                $js .= "if ( myform.{$eltname}.value == \"\" ) "."{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
848 848
             }
849 849
         }
850 850
         // Now, handle custom validation code
851
-        $elements =& $this->getElements(true);
851
+        $elements = & $this->getElements(true);
852 852
         foreach ($elements as $elt) {
853 853
             if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) !== 'xoopsformcheckbox') {
854 854
                 if ($eltjs = $elt->renderValidationJS()) {
855
-                    $js .= $eltjs . "\n";
855
+                    $js .= $eltjs."\n";
856 856
                 }
857 857
             }
858 858
         }
Please login to merge, or discard this patch.
class/form/elements/smartformuser_sigelement.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,23 +12,23 @@
 block discarded – undo
12 12
 
13 13
 class SmartFormUser_sigElement extends XoopsFormElementTray
14 14
 {
15
-    /**
16
-     * SmartFormUser_sigElement constructor.
17
-     * @param string $object
18
-     * @param string $key
19
-     */
20
-    public function __construct($object, $key)
21
-    {
22
-        $var     = $object->vars[$key];
23
-        $control = $object->controls[$key];
15
+	/**
16
+	 * SmartFormUser_sigElement constructor.
17
+	 * @param string $object
18
+	 * @param string $key
19
+	 */
20
+	public function __construct($object, $key)
21
+	{
22
+		$var     = $object->vars[$key];
23
+		$control = $object->controls[$key];
24 24
 
25
-        parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
25
+		parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
26 26
 
27
-        $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28
-        $this->addElement($signature_textarea);
27
+		$signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28
+		$this->addElement($signature_textarea);
29 29
 
30
-        $attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e'));
31
-        $attach_checkbox->addOption(1, _US_SHOWSIG);
32
-        $this->addElement($attach_checkbox);
33
-    }
30
+		$attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e'));
31
+		$attach_checkbox->addOption(1, _US_SHOWSIG);
32
+		$this->addElement($attach_checkbox);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         $var     = $object->vars[$key];
23 23
         $control = $object->controls[$key];
24 24
 
25
-        parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
25
+        parent::__construct($var['form_caption'], '<br><br>', $key.'_signature_tray');
26 26
 
27 27
         $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28 28
         $this->addElement($signature_textarea);
Please login to merge, or discard this patch.
class/form/elements/smartformurllinkelement.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormUrlLinkElement extends XoopsFormElementTray
13 13
 {
14
-    /**
15
-     * SmartFormUrlLinkElement constructor.
16
-     * @param string $form_caption
17
-     * @param string $key
18
-     * @param string $object
19
-     */
20
-    public function __construct($form_caption, $key, $object)
21
-    {
22
-        parent::__construct($form_caption, '&nbsp;');
14
+	/**
15
+	 * SmartFormUrlLinkElement constructor.
16
+	 * @param string $form_caption
17
+	 * @param string $key
18
+	 * @param string $object
19
+	 */
20
+	public function __construct($form_caption, $key, $object)
21
+	{
22
+		parent::__construct($form_caption, '&nbsp;');
23 23
 
24
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
-        $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
24
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
+		$this->addElement(new SmartFormTextElement($object, 'url_' . $key));
26 26
 
27
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
-        $this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
27
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
+		$this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
29 29
 
30
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
-        $this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
30
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
+		$this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
32 32
 
33
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
34
-        $targ_val    = $object->getVar('target');
35
-        $targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
36
-        $control     = $object->getControl('target');
37
-        $targetRadio->addOptionArray($control['options']);
33
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
34
+		$targ_val    = $object->getVar('target');
35
+		$targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
36
+		$control     = $object->getControl('target');
37
+		$targetRadio->addOptionArray($control['options']);
38 38
 
39
-        $this->addElement($targetRadio);
40
-    }
39
+		$this->addElement($targetRadio);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@
 block discarded – undo
21 21
     {
22 22
         parent::__construct($form_caption, '&nbsp;');
23 23
 
24
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
-        $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
24
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_URL));
25
+        $this->addElement(new SmartFormTextElement($object, 'url_'.$key));
26 26
 
27
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
-        $this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
27
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_CAPTION));
28
+        $this->addElement(new SmartFormTextElement($object, 'caption_'.$key));
29 29
 
30
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
-        $this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
30
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_DESC.'<br>'));
31
+        $this->addElement(new XoopsFormTextArea('', 'desc_'.$key, $object->getVar('description')));
32 32
 
33
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
33
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_TARGET));
34 34
         $targ_val    = $object->getVar('target');
35
-        $targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
35
+        $targetRadio = new XoopsFormRadio('', 'target_'.$key, $targ_val !== '' ? $targ_val : '_blank');
36 36
         $control     = $object->getControl('target');
37 37
         $targetRadio->addOptionArray($control['options']);
38 38
 
Please login to merge, or discard this patch.