Completed
Push — master ( 2a36d1...bf34f3 )
by Michael
03:21
created
class/currency.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -37,115 +37,115 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class SmartobjectCurrency extends SmartObject
39 39
 {
40
-    public $_modulePlugin = false;
41
-
42
-    /**
43
-     * SmartobjectCurrency constructor.
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
-        $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
-        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
-        $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
-        $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
-        $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
-
54
-        $this->setControl('symbol', [
55
-            'name'      => 'text',
56
-            'size'      => '15',
57
-            'maxlength' => '15'
58
-        ]);
59
-
60
-        $this->setControl('iso4217', [
61
-            'name'      => 'text',
62
-            'size'      => '5',
63
-            'maxlength' => '5'
64
-        ]);
65
-
66
-        $this->setControl('rate', [
67
-            'name'      => 'text',
68
-            'size'      => '5',
69
-            'maxlength' => '5'
70
-        ]);
71
-
72
-        $this->setControl('rate', [
73
-            'name'      => 'text',
74
-            'size'      => '5',
75
-            'maxlength' => '5'
76
-        ]);
77
-
78
-        $this->hideFieldFromForm('default_currency');
79
-    }
80
-
81
-    /**
82
-     * @param  string $key
83
-     * @param  string $format
84
-     * @return mixed
85
-     */
86
-    public function getVar($key, $format = 's')
87
-    {
88
-        if ('s' === $format && in_array($key, ['rate', 'default_currency'])) {
89
-            //            return call_user_func(array($this, $key));
90
-            return $this->{$key}();
91
-        }
92
-
93
-        return parent::getVar($key, $format);
94
-    }
95
-
96
-    /**
97
-     * @return mixed
98
-     */
99
-    public function getCurrencyLink()
100
-    {
101
-        $ret = $this->getVar('name', 'e');
102
-
103
-        return $ret;
104
-    }
105
-
106
-    /**
107
-     * @return mixed
108
-     */
109
-    public function getCode()
110
-    {
111
-        $ret = $this->getVar('iso4217', 'e');
112
-
113
-        return $ret;
114
-    }
115
-
116
-    /**
117
-     * @return float|int|mixed|string
118
-     */
119
-    public function rate()
120
-    {
121
-        return smart_currency($this->getVar('rate', 'e'));
122
-    }
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function defaultCurrency()
128
-    {
129
-        if (true === $this->getVar('default_currency', 'e')) {
130
-            return _YES;
131
-        } else {
132
-            return _NO;
133
-        }
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getDefaultCurrencyControl()
140
-    {
141
-        $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
-        if ($this->getVar('default_currency', 'e')) {
143
-            $radio_box .= 'checked';
144
-        }
145
-        $radio_box .= '>';
146
-
147
-        return $radio_box;
148
-    }
40
+	public $_modulePlugin = false;
41
+
42
+	/**
43
+	 * SmartobjectCurrency constructor.
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
+		$this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
+		$this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
+		$this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
+		$this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
+		$this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
+
54
+		$this->setControl('symbol', [
55
+			'name'      => 'text',
56
+			'size'      => '15',
57
+			'maxlength' => '15'
58
+		]);
59
+
60
+		$this->setControl('iso4217', [
61
+			'name'      => 'text',
62
+			'size'      => '5',
63
+			'maxlength' => '5'
64
+		]);
65
+
66
+		$this->setControl('rate', [
67
+			'name'      => 'text',
68
+			'size'      => '5',
69
+			'maxlength' => '5'
70
+		]);
71
+
72
+		$this->setControl('rate', [
73
+			'name'      => 'text',
74
+			'size'      => '5',
75
+			'maxlength' => '5'
76
+		]);
77
+
78
+		$this->hideFieldFromForm('default_currency');
79
+	}
80
+
81
+	/**
82
+	 * @param  string $key
83
+	 * @param  string $format
84
+	 * @return mixed
85
+	 */
86
+	public function getVar($key, $format = 's')
87
+	{
88
+		if ('s' === $format && in_array($key, ['rate', 'default_currency'])) {
89
+			//            return call_user_func(array($this, $key));
90
+			return $this->{$key}();
91
+		}
92
+
93
+		return parent::getVar($key, $format);
94
+	}
95
+
96
+	/**
97
+	 * @return mixed
98
+	 */
99
+	public function getCurrencyLink()
100
+	{
101
+		$ret = $this->getVar('name', 'e');
102
+
103
+		return $ret;
104
+	}
105
+
106
+	/**
107
+	 * @return mixed
108
+	 */
109
+	public function getCode()
110
+	{
111
+		$ret = $this->getVar('iso4217', 'e');
112
+
113
+		return $ret;
114
+	}
115
+
116
+	/**
117
+	 * @return float|int|mixed|string
118
+	 */
119
+	public function rate()
120
+	{
121
+		return smart_currency($this->getVar('rate', 'e'));
122
+	}
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function defaultCurrency()
128
+	{
129
+		if (true === $this->getVar('default_currency', 'e')) {
130
+			return _YES;
131
+		} else {
132
+			return _NO;
133
+		}
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getDefaultCurrencyControl()
140
+	{
141
+		$radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
+		if ($this->getVar('default_currency', 'e')) {
143
+			$radio_box .= 'checked';
144
+		}
145
+		$radio_box .= '>';
146
+
147
+		return $radio_box;
148
+	}
149 149
 }
150 150
 
151 151
 /**
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
  */
154 154
 class SmartObjectCurrencyHandler extends SmartPersistableObjectHandler
155 155
 {
156
-    /**
157
-     * SmartObjectCurrencyHandler constructor.
158
-     * @param XoopsDatabase $db
159
-     */
160
-    public function __construct(XoopsDatabase $db)
161
-    {
162
-        parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
-    }
164
-
165
-    /**
166
-     * @return array
167
-     */
168
-    public function getCurrencies()
169
-    {
170
-        $currenciesObj = $this->getObjects(null, true);
171
-
172
-        return $currenciesObj;
173
-    }
156
+	/**
157
+	 * SmartObjectCurrencyHandler constructor.
158
+	 * @param XoopsDatabase $db
159
+	 */
160
+	public function __construct(XoopsDatabase $db)
161
+	{
162
+		parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
+	}
164
+
165
+	/**
166
+	 * @return array
167
+	 */
168
+	public function getCurrencies()
169
+	{
170
+		$currenciesObj = $this->getObjects(null, true);
171
+
172
+		return $currenciesObj;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
class/smartobjecttreetable.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -22,157 +22,157 @@
 block discarded – undo
22 22
  */
23 23
 class SmartObjectTreeTable extends SmartObjectTable
24 24
 {
25
-    /**
26
-     * SmartObjectTreeTable constructor.
27
-     * @param SmartPersistableObjectHandler $objectHandler
28
-     * @param bool                          $criteria
29
-     * @param array                         $actions
30
-     * @param bool                          $userSide
31
-     */
32
-    public function __construct(
33
-        SmartPersistableObjectHandler $objectHandler,
34
-        $criteria = false,
35
-        $actions = ['edit', 'delete'],
36
-        $userSide = false
37
-    ) {
38
-        $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide);
39
-        $this->_isTree = true;
40
-    }
41
-
42
-    /**
43
-     * Get children objects given a specific parentid
44
-     *
45
-     * @var    int $parentid id of the parent which children we want to retreive
46
-     * @return array of SmartObject
47
-     */
48
-    public function getChildrenOf($parentid = 0)
49
-    {
50
-        return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false;
51
-    }
52
-
53
-    /**
54
-     * @param     $object
55
-     * @param int $level
56
-     */
57
-    public function createTableRow($object, $level = 0)
58
-    {
59
-        $aObject = [];
60
-
61
-        $i = 0;
62
-
63
-        $aColumns        = [];
64
-        $doWeHaveActions = false;
65
-
66
-        foreach ($this->_columns as $column) {
67
-            $aColumn = [];
68
-
69
-            if (0 == $i) {
70
-                $class = 'head';
71
-            } elseif (0 == $i % 2) {
72
-                $class = 'even';
73
-            } else {
74
-                $class = 'odd';
75
-            }
76
-
77
-            if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
78
-                $method = $column->_customMethodForValue;
79
-                $value  = $object->$method();
80
-            } else {
81
-                /**
82
-                 * If the column is the identifier, then put a link on it
83
-                 */
84
-                if ($column->getKeyName() == $this->_objectHandler->identifierName) {
85
-                    $value = $object->getItemLink();
86
-                } else {
87
-                    $value = $object->getVar($column->getKeyName());
88
-                }
89
-            }
90
-
91
-            $space = '';
92
-            if ($column->getKeyName() == $this->_objectHandler->identifierName) {
93
-                for ($i = 0; $i < $level; ++$i) {
94
-                    $space .= '--';
95
-                }
96
-            }
97
-
98
-            if ('' !== $space) {
99
-                $space .= '&nbsp;';
100
-            }
101
-
102
-            $aColumn['value'] = $space . $value;
103
-            $aColumn['class'] = $class;
104
-            $aColumn['width'] = $column->getWidth();
105
-            $aColumn['align'] = $column->getAlign();
106
-            $aColumn['key']   = $column->getKeyName();
107
-
108
-            $aColumns[] = $aColumn;
109
-            ++$i;
110
-        }
111
-
112
-        $aObject['columns'] = $aColumns;
113
-
114
-        $class            = 'even' === $class ? 'odd' : 'even';
115
-        $aObject['class'] = $class;
116
-
117
-        $actions = [];
118
-
119
-        // Adding the custom actions if any
120
-        foreach ($this->_custom_actions as $action) {
121
-            if (method_exists($object, $action)) {
122
-                $actions[] = $object->$action();
123
-            }
124
-        }
125
-
126
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
127
-        $controller = new SmartObjectController($this->_objectHandler);
128
-
129
-        if (in_array('edit', $this->_actions)) {
130
-            $actions[] = $controller->getEditItemLink($object, false, true);
131
-        }
132
-        if (in_array('delete', $this->_actions)) {
133
-            $actions[] = $controller->getDeleteItemLink($object, false, true);
134
-        }
135
-        $aObject['actions'] = $actions;
136
-
137
-        $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
138
-        $aObject['id']     = $object->id();
139
-        $this->_aObjects[] = $aObject;
140
-
141
-        $childrenObjects = $this->getChildrenOf($object->id());
142
-
143
-        $this->_hasActions = $this->_hasActions ? true : count($actions) > 0;
144
-
145
-        if ($childrenObjects) {
146
-            ++$level;
147
-            foreach ($childrenObjects as $subObject) {
148
-                $this->createTableRow($subObject, $level);
149
-            }
150
-        }
151
-    }
152
-
153
-    public function createTableRows()
154
-    {
155
-        $this->_aObjects = [];
156
-
157
-        if (count($this->_objects) > 0) {
158
-            foreach ($this->getChildrenOf() as $object) {
159
-                $this->createTableRow($object);
160
-            }
161
-
162
-            $this->_tpl->assign('smartobject_objects', $this->_aObjects);
163
-        } else {
164
-            $colspan = count($this->_columns) + 1;
165
-            $this->_tpl->assign('smartobject_colspan', $colspan);
166
-        }
167
-    }
168
-
169
-    /**
170
-     * @return mixed
171
-     */
172
-    public function fetchObjects()
173
-    {
174
-        $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid');
175
-
176
-        return $ret;
177
-    }
25
+	/**
26
+	 * SmartObjectTreeTable constructor.
27
+	 * @param SmartPersistableObjectHandler $objectHandler
28
+	 * @param bool                          $criteria
29
+	 * @param array                         $actions
30
+	 * @param bool                          $userSide
31
+	 */
32
+	public function __construct(
33
+		SmartPersistableObjectHandler $objectHandler,
34
+		$criteria = false,
35
+		$actions = ['edit', 'delete'],
36
+		$userSide = false
37
+	) {
38
+		$this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide);
39
+		$this->_isTree = true;
40
+	}
41
+
42
+	/**
43
+	 * Get children objects given a specific parentid
44
+	 *
45
+	 * @var    int $parentid id of the parent which children we want to retreive
46
+	 * @return array of SmartObject
47
+	 */
48
+	public function getChildrenOf($parentid = 0)
49
+	{
50
+		return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false;
51
+	}
52
+
53
+	/**
54
+	 * @param     $object
55
+	 * @param int $level
56
+	 */
57
+	public function createTableRow($object, $level = 0)
58
+	{
59
+		$aObject = [];
60
+
61
+		$i = 0;
62
+
63
+		$aColumns        = [];
64
+		$doWeHaveActions = false;
65
+
66
+		foreach ($this->_columns as $column) {
67
+			$aColumn = [];
68
+
69
+			if (0 == $i) {
70
+				$class = 'head';
71
+			} elseif (0 == $i % 2) {
72
+				$class = 'even';
73
+			} else {
74
+				$class = 'odd';
75
+			}
76
+
77
+			if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
78
+				$method = $column->_customMethodForValue;
79
+				$value  = $object->$method();
80
+			} else {
81
+				/**
82
+				 * If the column is the identifier, then put a link on it
83
+				 */
84
+				if ($column->getKeyName() == $this->_objectHandler->identifierName) {
85
+					$value = $object->getItemLink();
86
+				} else {
87
+					$value = $object->getVar($column->getKeyName());
88
+				}
89
+			}
90
+
91
+			$space = '';
92
+			if ($column->getKeyName() == $this->_objectHandler->identifierName) {
93
+				for ($i = 0; $i < $level; ++$i) {
94
+					$space .= '--';
95
+				}
96
+			}
97
+
98
+			if ('' !== $space) {
99
+				$space .= '&nbsp;';
100
+			}
101
+
102
+			$aColumn['value'] = $space . $value;
103
+			$aColumn['class'] = $class;
104
+			$aColumn['width'] = $column->getWidth();
105
+			$aColumn['align'] = $column->getAlign();
106
+			$aColumn['key']   = $column->getKeyName();
107
+
108
+			$aColumns[] = $aColumn;
109
+			++$i;
110
+		}
111
+
112
+		$aObject['columns'] = $aColumns;
113
+
114
+		$class            = 'even' === $class ? 'odd' : 'even';
115
+		$aObject['class'] = $class;
116
+
117
+		$actions = [];
118
+
119
+		// Adding the custom actions if any
120
+		foreach ($this->_custom_actions as $action) {
121
+			if (method_exists($object, $action)) {
122
+				$actions[] = $object->$action();
123
+			}
124
+		}
125
+
126
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
127
+		$controller = new SmartObjectController($this->_objectHandler);
128
+
129
+		if (in_array('edit', $this->_actions)) {
130
+			$actions[] = $controller->getEditItemLink($object, false, true);
131
+		}
132
+		if (in_array('delete', $this->_actions)) {
133
+			$actions[] = $controller->getDeleteItemLink($object, false, true);
134
+		}
135
+		$aObject['actions'] = $actions;
136
+
137
+		$this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
138
+		$aObject['id']     = $object->id();
139
+		$this->_aObjects[] = $aObject;
140
+
141
+		$childrenObjects = $this->getChildrenOf($object->id());
142
+
143
+		$this->_hasActions = $this->_hasActions ? true : count($actions) > 0;
144
+
145
+		if ($childrenObjects) {
146
+			++$level;
147
+			foreach ($childrenObjects as $subObject) {
148
+				$this->createTableRow($subObject, $level);
149
+			}
150
+		}
151
+	}
152
+
153
+	public function createTableRows()
154
+	{
155
+		$this->_aObjects = [];
156
+
157
+		if (count($this->_objects) > 0) {
158
+			foreach ($this->getChildrenOf() as $object) {
159
+				$this->createTableRow($object);
160
+			}
161
+
162
+			$this->_tpl->assign('smartobject_objects', $this->_aObjects);
163
+		} else {
164
+			$colspan = count($this->_columns) + 1;
165
+			$this->_tpl->assign('smartobject_colspan', $colspan);
166
+		}
167
+	}
168
+
169
+	/**
170
+	 * @return mixed
171
+	 */
172
+	public function fetchObjects()
173
+	{
174
+		$ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid');
175
+
176
+		return $ret;
177
+	}
178 178
 }
Please login to merge, or discard this patch.
class/smartobject.php 2 patches
Indentation   +1404 added lines, -1404 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@  discard block
 block discarded – undo
17 17
 require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
18 18
 
19 19
 if (!defined('XOBJ_DTYPE_SIMPLE_ARRAY')) {
20
-    define('XOBJ_DTYPE_SIMPLE_ARRAY', 101);
20
+	define('XOBJ_DTYPE_SIMPLE_ARRAY', 101);
21 21
 }
22 22
 if (!defined('XOBJ_DTYPE_CURRENCY')) {
23
-    define('XOBJ_DTYPE_CURRENCY', 200);
23
+	define('XOBJ_DTYPE_CURRENCY', 200);
24 24
 }
25 25
 if (!defined('XOBJ_DTYPE_FLOAT')) {
26
-    define('XOBJ_DTYPE_FLOAT', 201);
26
+	define('XOBJ_DTYPE_FLOAT', 201);
27 27
 }
28 28
 if (!defined('XOBJ_DTYPE_TIME_ONLY')) {
29
-    define('XOBJ_DTYPE_TIME_ONLY', 202);
29
+	define('XOBJ_DTYPE_TIME_ONLY', 202);
30 30
 }
31 31
 if (!defined('XOBJ_DTYPE_URLLINK')) {
32
-    define('XOBJ_DTYPE_URLLINK', 203);
32
+	define('XOBJ_DTYPE_URLLINK', 203);
33 33
 }
34 34
 if (!defined('XOBJ_DTYPE_FILE')) {
35
-    define('XOBJ_DTYPE_FILE', 204);
35
+	define('XOBJ_DTYPE_FILE', 204);
36 36
 }
37 37
 if (!defined('XOBJ_DTYPE_IMAGE')) {
38
-    define('XOBJ_DTYPE_IMAGE', 205);
38
+	define('XOBJ_DTYPE_IMAGE', 205);
39 39
 }
40 40
 if (!defined('XOBJ_DTYPE_FORM_SECTION')) {
41
-    define('XOBJ_DTYPE_FORM_SECTION', 210);
41
+	define('XOBJ_DTYPE_FORM_SECTION', 210);
42 42
 }
43 43
 if (!defined('XOBJ_DTYPE_FORM_SECTION_CLOSE')) {
44
-    define('XOBJ_DTYPE_FORM_SECTION_CLOSE', 211);
44
+	define('XOBJ_DTYPE_FORM_SECTION_CLOSE', 211);
45 45
 }
46 46
 
47 47
 /**
@@ -55,1399 +55,1399 @@  discard block
 block discarded – undo
55 55
  */
56 56
 class SmartObject extends XoopsObject
57 57
 {
58
-    public $_image_path;
59
-    public $_image_url;
60
-
61
-    public $seoEnabled   = false;
62
-    public $titleField;
63
-    public $summaryField = false;
64
-
65
-    /**
66
-     * Reference to the handler managing this object
67
-     *
68
-     * @var SmartPersistableObjectHandler reference to {@link SmartPersistableObjectHandler}
69
-     */
70
-    public $handler;
71
-
72
-    /**
73
-     * References to control objects, managing the form fields of this object
74
-     */
75
-    public $controls = [];
76
-
77
-    /**
78
-     * SmartObject constructor.
79
-     * @param $handler
80
-     */
81
-    public function __construct($handler)
82
-    {
83
-        $this->handler = $handler;
84
-    }
85
-
86
-    /**
87
-     * Checks if the user has a specific access on this object
88
-     *
89
-     * @param $perm_name
90
-     * @return bool: TRUE if user has access, false if not
91
-     * @internal param string $gperm_name name of the permission to test
92
-     */
93
-    public function accessGranted($perm_name)
94
-    {
95
-        $smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
96
-
97
-        return $smartPermissionsHandler->accessGranted($perm_name, $this->id());
98
-    }
99
-
100
-    /**
101
-     * @param      $section_name
102
-     * @param bool $value
103
-     * @param bool $hide
104
-     */
105
-    public function addFormSection($section_name, $value = false, $hide = false)
106
-    {
107
-        $this->initVar($section_name, XOBJ_DTYPE_FORM_SECTION, $value, false, null, '', false, '', '', false, false, true);
108
-        $this->vars[$section_name]['hide'] = $hide;
109
-    }
110
-
111
-    /**
112
-     * @param $section_name
113
-     */
114
-    public function closeSection($section_name)
115
-    {
116
-        $this->initVar('close_section_' . $section_name, XOBJ_DTYPE_FORM_SECTION_CLOSE, '', false, null, '', false, '', '', false, false, true);
117
-    }
118
-
119
-    /**
120
-     *
121
-     * @param string $key          key of this field. This needs to be the name of the field in the related database table
122
-     * @param int    $data_type    set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
123
-     * @param mixed  $value        default value of this variable
124
-     * @param bool   $required     set to TRUE if this variable needs to have a value set before storing the object in the table
125
-     * @param int    $maxlength    maximum length of this variable, for XOBJ_DTYPE_TXTBOX type only
126
-     * @param string $options      does this data have any select options?
127
-     * @param bool   $multilingual is this field needs to support multilingual features (NOT YET IMPLEMENTED...)
128
-     * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
129
-     * @param string $form_dsc     description of this variable in a {@link SmartobjectForm}
130
-     * @param bool   $sortby       set to TRUE to make this field used to sort objects in SmartObjectTable
131
-     * @param bool   $persistent   set to FALSE if this field is not to be saved in the database
132
-     * @param bool   $displayOnForm
133
-     */
134
-    public function initVar(
135
-        $key,
136
-        $data_type,
137
-        $value = null,
138
-        $required = false,
139
-        $maxlength = null,
140
-        $options = '',
141
-        $multilingual = false,
142
-        $form_caption = '',
143
-        $form_dsc = '',
144
-        $sortby = false,
145
-        $persistent = true,
146
-        $displayOnForm = true
147
-    ) {
148
-        //url_ is reserved for files.
149
-        if (0 === strpos($key, 'url_')) {
150
-            trigger_error("Cannot use variable starting with 'url_'.");
151
-        }
152
-        parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
153
-        if ($this->handler && (!$form_caption || '' === $form_caption)) {
154
-            $dyn_form_caption = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key);
155
-            if (defined($dyn_form_caption)) {
156
-                $form_caption = constant($dyn_form_caption);
157
-            }
158
-        }
159
-        if ($this->handler && (!$form_dsc || '' === $form_dsc)) {
160
-            $dyn_form_dsc = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key . '_DSC');
161
-            if (defined($dyn_form_dsc)) {
162
-                $form_dsc = constant($dyn_form_dsc);
163
-            }
164
-        }
165
-
166
-        $this->vars[$key] = array_merge($this->vars[$key], [
167
-            'multilingual'        => $multilingual,
168
-            'form_caption'        => $form_caption,
169
-            'form_dsc'            => $form_dsc,
170
-            'sortby'              => $sortby,
171
-            'persistent'          => $persistent,
172
-            'displayOnForm'       => $displayOnForm,
173
-            'displayOnSingleView' => true,
174
-            'readonly'            => false
175
-        ]);
176
-    }
177
-
178
-    /**
179
-     * @param        $key
180
-     * @param        $data_type
181
-     * @param bool   $itemName
182
-     * @param string $form_caption
183
-     * @param bool   $sortby
184
-     * @param string $value
185
-     * @param bool   $displayOnForm
186
-     * @param bool   $required
187
-     */
188
-    public function initNonPersistableVar(
189
-        $key,
190
-        $data_type,
191
-        $itemName = false,
192
-        $form_caption = '',
193
-        $sortby = false,
194
-        $value = '',
195
-        $displayOnForm = false,
196
-        $required = false
197
-    ) {
198
-        $this->initVar($key, $data_type, $value, $required, null, '', false, $form_caption, '', $sortby, false, $displayOnForm);
199
-        $this->vars[$key]['itemName'] = $itemName;
200
-    }
201
-
202
-    /**
203
-     * Quickly initiate a var
204
-     *
205
-     * Since many vars do have the same config, let's use this method with some of these configuration as a convention ;-)
206
-     *
207
-     * - $maxlength = 0 unless $data_type is a TEXTBOX, then $maxlength will be 255
208
-     * - all other vars are NULL or '' depending of the parameter
209
-     *
210
-     * @param string $key          key of this field. This needs to be the name of the field in the related database table
211
-     * @param int    $data_type    set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
212
-     * @param bool   $required     set to TRUE if this variable needs to have a value set before storing the object in the table
213
-     * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
214
-     * @param string $form_dsc     description of this variable in a {@link SmartobjectForm}
215
-     * @param mixed  $value        default value of this variable
216
-     */
217
-    public function quickInitVar(
218
-        $key,
219
-        $data_type,
220
-        $required = false,
221
-        $form_caption = '',
222
-        $form_dsc = '',
223
-        $value = null
224
-    ) {
225
-        $maxlength = 'XOBJ_DTYPE_TXTBOX' === $data_type ? 255 : null;
226
-        $this->initVar($key, $data_type, $value, $required, $maxlength, '', false, $form_caption, $form_dsc, false, true, true);
227
-    }
228
-
229
-    /**
230
-     * @param        $varname
231
-     * @param bool   $displayOnForm
232
-     * @param string $default
233
-     */
234
-    public function initCommonVar($varname, $displayOnForm = true, $default = 'notdefined')
235
-    {
236
-        switch ($varname) {
237
-            case 'dohtml':
238
-                $value = 'notdefined' !== $default ? $default : true;
239
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOHTML_FORM_CAPTION, '', false, true, $displayOnForm);
240
-                $this->setControl($varname, 'yesno');
241
-                break;
242
-
243
-            case 'dobr':
244
-                $value = ('notdefined' === $default) ? true : $default;
245
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
246
-                $this->setControl($varname, 'yesno');
247
-                break;
248
-
249
-            case 'doimage':
250
-                $value = 'notdefined' !== $default ? $default : true;
251
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
252
-                $this->setControl($varname, 'yesno');
253
-                break;
254
-
255
-            case 'dosmiley':
256
-                $value = 'notdefined' !== $default ? $default : true;
257
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
258
-                $this->setControl($varname, 'yesno');
259
-                break;
260
-
261
-            case 'doxcode':
262
-                $value = 'notdefined' !== $default ? $default : true;
263
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
264
-                $this->setControl($varname, 'yesno');
265
-                break;
266
-
267
-            case 'meta_keywords':
268
-                $value = 'notdefined' !== $default ? $default : '';
269
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_KEYWORDS, _CO_SOBJECT_META_KEYWORDS_DSC, false, true, $displayOnForm);
270
-                $this->setControl('meta_keywords', [
271
-                    'name'        => 'textarea',
272
-                    'form_editor' => 'textarea'
273
-                ]);
274
-                break;
275
-
276
-            case 'meta_description':
277
-                $value = 'notdefined' !== $default ? $default : '';
278
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_DESCRIPTION, _CO_SOBJECT_META_DESCRIPTION_DSC, false, true, $displayOnForm);
279
-                $this->setControl('meta_description', [
280
-                    'name'        => 'textarea',
281
-                    'form_editor' => 'textarea'
282
-                ]);
283
-                break;
284
-
285
-            case 'short_url':
286
-                $value = 'notdefined' !== $default ? $default : '';
287
-                $this->initVar($varname, XOBJ_DTYPE_TXTBOX, $value, false, null, '', false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
288
-                break;
289
-
290
-            case 'hierarchy_path':
291
-                $value = 'notdefined' !== $default ? $default : '';
292
-                $this->initVar($varname, XOBJ_DTYPE_ARRAY, $value, false, null, '', false, _CO_SOBJECT_HIERARCHY_PATH, _CO_SOBJECT_HIERARCHY_PATH_DSC, false, true, $displayOnForm);
293
-                break;
294
-
295
-            case 'counter':
296
-                $value = 'notdefined' !== $default ? $default : 0;
297
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
298
-                break;
299
-
300
-            case 'weight':
301
-                $value = 'notdefined' !== $default ? $default : 0;
302
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
303
-                break;
304
-            case 'custom_css':
305
-                $value = 'notdefined' !== $default ? $default : '';
306
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_CUSTOM_CSS, _CO_SOBJECT_CUSTOM_CSS_DSC, false, true, $displayOnForm);
307
-                $this->setControl('custom_css', [
308
-                    'name'        => 'textarea',
309
-                    'form_editor' => 'textarea'
310
-                ]);
311
-                break;
312
-        }
313
-        $this->hideFieldFromSingleView($varname);
314
-    }
315
-
316
-    /**
317
-     * Set control information for an instance variable
318
-     *
319
-     * The $options parameter can be a string or an array. Using a string
320
-     * is the quickest way:
321
-     *
322
-     * $this->setControl('date', 'date_time');
323
-     *
324
-     * This will create a date and time selectbox for the 'date' var on the
325
-     * form to edit or create this item.
326
-     *
327
-     * Here are the currently supported controls:
328
-     *
329
-     *      - color
330
-     *      - country
331
-     *      - date_time
332
-     *      - date
333
-     *      - email
334
-     *      - group
335
-     *      - group_multi
336
-     *      - image
337
-     *      - imageupload
338
-     *      - label
339
-     *      - language
340
-     *      - parentcategory
341
-     *      - password
342
-     *      - select_multi
343
-     *      - select
344
-     *      - text
345
-     *      - textarea
346
-     *      - theme
347
-     *      - theme_multi
348
-     *      - timezone
349
-     *      - user
350
-     *      - user_multi
351
-     *      - yesno
352
-     *
353
-     * Now, using an array as $options, you can customize what information to
354
-     * use in the control. For example, if one needs to display a select box for
355
-     * the user to choose the status of an item. We only need to tell SmartObject
356
-     * what method to execute within what handler to retreive the options of the
357
-     * selectbox.
358
-     *
359
-     * $this->setControl('status', array('name' => false,
360
-     *                                   'itemHandler' => 'item',
361
-     *                                   'method' => 'getStatus',
362
-     *                                   'module' => 'smartshop'));
363
-     *
364
-     * In this example, the array elements are the following:
365
-     *      - name: false, as we don't need to set a special control here.
366
-     *               we will use the default control related to the object type (defined in initVar)
367
-     *      - itemHandler: name of the object for which we will use the handler
368
-     *      - method: name of the method of this handler that we will execute
369
-     *      - module: name of the module from wich the handler is
370
-     *
371
-     * So in this example, SmartObject will create a selectbox for the variable 'status' and it will
372
-     * populate this selectbox with the result from SmartshopItemHandler::getStatus()
373
-     *
374
-     * Another example of the use of $options as an array is for TextArea:
375
-     *
376
-     * $this->setControl('body', array('name' => 'textarea',
377
-     *                                   'form_editor' => 'default'));
378
-     *
379
-     * In this example, SmartObject will create a TextArea for the variable 'body'. And it will use
380
-     * the 'default' editor, providing it is defined in the module
381
-     * preferences: $xoopsModuleConfig['default_editor']
382
-     *
383
-     * Of course, you can force the use of a specific editor:
384
-     *
385
-     * $this->setControl('body', array('name' => 'textarea',
386
-     *                                   'form_editor' => 'koivi'));
387
-     *
388
-     * Here is a list of supported editor:
389
-     *      - tiny: TinyEditor
390
-     *      - dhtmltextarea: XOOPS DHTML Area
391
-     *      - fckeditor: FCKEditor
392
-     *      - inbetween: InBetween
393
-     *      - koivi: Koivi
394
-     *      - spaw: Spaw WYSIWYG Editor
395
-     *      - htmlarea: HTMLArea
396
-     *      - textarea: basic textarea with no options
397
-     *
398
-     * @param string $var name of the variable for which we want to set a control
399
-     * @param array  $options
400
-     */
401
-    public function setControl($var, $options = [])
402
-    {
403
-        if (isset($this->controls[$var])) {
404
-            unset($this->controls[$var]);
405
-        }
406
-        if (is_string($options)) {
407
-            $options = ['name' => $options];
408
-        }
409
-        $this->controls[$var] = $options;
410
-    }
411
-
412
-    /**
413
-     * Get control information for an instance variable
414
-     *
415
-     * @param  string $var
416
-     * @return bool|mixed
417
-     */
418
-    public function getControl($var)
419
-    {
420
-        return isset($this->controls[$var]) ? $this->controls[$var] : false;
421
-    }
422
-
423
-    /**
424
-     * Create the form for this object
425
-     *
426
-     * @param         $form_caption
427
-     * @param         $form_name
428
-     * @param  bool   $form_action
429
-     * @param  string $submit_button_caption
430
-     * @param  bool   $cancel_js_action
431
-     * @param  bool   $captcha
432
-     * @return a      <a href='psi_element://SmartobjectForm'>SmartobjectForm</a> object for this object
433
-     *                                      object for this object
434
-     * @see SmartObjectForm::SmartObjectForm()
435
-     */
436
-    public function getForm(
437
-        $form_caption,
438
-        $form_name,
439
-        $form_action = false,
440
-        $submit_button_caption = _CO_SOBJECT_SUBMIT,
441
-        $cancel_js_action = false,
442
-        $captcha = false
443
-    ) {
444
-        require_once SMARTOBJECT_ROOT_PATH . 'class/form/smartobjectform.php';
445
-        $form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
446
-
447
-        return $form;
448
-    }
449
-
450
-    /**
451
-     * @return array
452
-     */
453
-    public function toArray()
454
-    {
455
-        $ret  = [];
456
-        $vars =& $this->getVars();
457
-        foreach ($vars as $key => $var) {
458
-            $value     = $this->getVar($key);
459
-            $ret[$key] = $value;
460
-        }
461
-        if ('' !== $this->handler->identifierName) {
462
-            $controller = new SmartObjectController($this->handler);
463
-            /**
464
-             * Addition of some automatic value
465
-             */
466
-            $ret['itemLink']         = $controller->getItemLink($this);
467
-            $ret['itemUrl']          = $controller->getItemLink($this, true);
468
-            $ret['editItemLink']     = $controller->getEditItemLink($this, false, true);
469
-            $ret['deleteItemLink']   = $controller->getDeleteItemLink($this, false, true);
470
-            $ret['printAndMailLink'] = $controller->getPrintAndMailLink($this);
471
-        }
472
-
473
-        // Hightlighting searched words
474
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smarthighlighter.php';
475
-        $highlight = smart_getConfig('module_search_highlighter', false, true);
476
-
477
-        if ($highlight && isset($_GET['keywords'])) {
478
-            $myts     = MyTextSanitizer::getInstance();
479
-            $keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords'])));
480
-            $h        = new SmartHighlighter($keywords, true, 'smart_highlighter');
481
-            foreach ($this->handler->highlightFields as $field) {
482
-                $ret[$field] = $h->highlight($ret[$field]);
483
-            }
484
-        }
485
-
486
-        return $ret;
487
-    }
488
-
489
-    /**
490
-     * add an error
491
-     *
492
-     * @param      $err_str
493
-     * @param bool $prefix
494
-     * @internal param string $value error to add
495
-     * @access   public
496
-     */
497
-    public function setErrors($err_str, $prefix = false)
498
-    {
499
-        if (is_array($err_str)) {
500
-            foreach ($err_str as $str) {
501
-                $this->setErrors($str, $prefix);
502
-            }
503
-        } else {
504
-            if ($prefix) {
505
-                $err_str = '[' . $prefix . '] ' . $err_str;
506
-            }
507
-            parent::setErrors($err_str);
508
-        }
509
-    }
510
-
511
-    /**
512
-     * @param      $field
513
-     * @param bool $required
514
-     */
515
-    public function setFieldAsRequired($field, $required = true)
516
-    {
517
-        if (is_array($field)) {
518
-            foreach ($field as $v) {
519
-                $this->doSetFieldAsRequired($v, $required);
520
-            }
521
-        } else {
522
-            $this->doSetFieldAsRequired($field, $required);
523
-        }
524
-    }
525
-
526
-    /**
527
-     * @param $field
528
-     */
529
-    public function setFieldForSorting($field)
530
-    {
531
-        if (is_array($field)) {
532
-            foreach ($field as $v) {
533
-                $this->doSetFieldForSorting($v);
534
-            }
535
-        } else {
536
-            $this->doSetFieldForSorting($field);
537
-        }
538
-    }
539
-
540
-    /**
541
-     * @return bool
542
-     */
543
-    public function hasError()
544
-    {
545
-        return count($this->_errors) > 0;
546
-    }
547
-
548
-    /**
549
-     * @param $url
550
-     * @param $path
551
-     */
552
-    public function setImageDir($url, $path)
553
-    {
554
-        $this->_image_url  = $url;
555
-        $this->_image_path = $path;
556
-    }
557
-
558
-    /**
559
-     * Retreive the group that have been granted access to a specific permission for this object
560
-     *
561
-     * @param $group_perm
562
-     * @return string $group_perm name of the permission
563
-     */
564
-    public function getGroupPerm($group_perm)
565
-    {
566
-        if (!$this->handler->getPermissions()) {
567
-            $this->setError("Trying to access a permission that does not exists for thisobject's handler");
568
-
569
-            return false;
570
-        }
571
-
572
-        $smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
573
-        $ret                     = $smartPermissionsHandler->getGrantedGroups($group_perm, $this->id());
574
-
575
-        if (0 == count($ret)) {
576
-            return false;
577
-        } else {
578
-            return $ret;
579
-        }
580
-    }
581
-
582
-    /**
583
-     * @param  bool $path
584
-     * @return mixed
585
-     */
586
-    public function getImageDir($path = false)
587
-    {
588
-        if ($path) {
589
-            return $this->_image_path;
590
-        } else {
591
-            return $this->_image_url;
592
-        }
593
-    }
594
-
595
-    /**
596
-     * @param  bool $path
597
-     * @return mixed
598
-     */
599
-    public function getUploadDir($path = false)
600
-    {
601
-        if ($path) {
602
-            return $this->_image_path;
603
-        } else {
604
-            return $this->_image_url;
605
-        }
606
-    }
607
-
608
-    /**
609
-     * @param  string $key
610
-     * @param  string $info
611
-     * @return array
612
-     */
613
-    public function getVarInfo($key = '', $info = '')
614
-    {
615
-        if (isset($this->vars[$key][$info])) {
616
-            return $this->vars[$key][$info];
617
-        } elseif ('' === $info && isset($this->vars[$key])) {
618
-            return $this->vars[$key];
619
-        } else {
620
-            return $this->vars;
621
-        }
622
-    }
623
-
624
-    /**
625
-     * Get the id of the object
626
-     *
627
-     * @return int id of this object
628
-     */
629
-    public function id()
630
-    {
631
-        return $this->getVar($this->handler->keyName, 'e');
632
-    }
633
-
634
-    /**
635
-     * Return the value of the title field of this object
636
-     *
637
-     * @param  string $format
638
-     * @return string
639
-     */
640
-    public function title($format = 's')
641
-    {
642
-        return $this->getVar($this->handler->identifierName, $format);
643
-    }
644
-
645
-    /**
646
-     * Return the value of the title field of this object
647
-     *
648
-     * @return string
649
-     */
650
-    public function summary()
651
-    {
652
-        if ($this->handler->summaryName) {
653
-            return $this->getVar($this->handler->summaryName);
654
-        } else {
655
-            return false;
656
-        }
657
-    }
658
-
659
-    /**
660
-     * Retreive the object admin side link, displayijng a SingleView page
661
-     *
662
-     * @param  bool $onlyUrl wether or not to return a simple URL or a full <a> link
663
-     * @return string user side link to the object
664
-     */
665
-    public function getAdminViewItemLink($onlyUrl = false)
666
-    {
667
-        $controller = new SmartObjectController($this->handler);
668
-
669
-        return $controller->getAdminViewItemLink($this, $onlyUrl);
670
-    }
671
-
672
-    /**
673
-     * Retreive the object user side link
674
-     *
675
-     * @param  bool $onlyUrl wether or not to return a simple URL or a full <a> link
676
-     * @return string user side link to the object
677
-     */
678
-    public function getItemLink($onlyUrl = false)
679
-    {
680
-        $controller = new SmartObjectController($this->handler);
681
-
682
-        return $controller->getItemLink($this, $onlyUrl);
683
-    }
684
-
685
-    /**
686
-     * @param  bool $onlyUrl
687
-     * @param  bool $withimage
688
-     * @param  bool $userSide
689
-     * @return string
690
-     */
691
-    public function getEditItemLink($onlyUrl = false, $withimage = true, $userSide = false)
692
-    {
693
-        $controller = new SmartObjectController($this->handler);
694
-
695
-        return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
696
-    }
697
-
698
-    /**
699
-     * @param  bool $onlyUrl
700
-     * @param  bool $withimage
701
-     * @param  bool $userSide
702
-     * @return string
703
-     */
704
-    public function getDeleteItemLink($onlyUrl = false, $withimage = false, $userSide = false)
705
-    {
706
-        $controller = new SmartObjectController($this->handler);
707
-
708
-        return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
709
-    }
710
-
711
-    /**
712
-     * @return string
713
-     */
714
-    public function getPrintAndMailLink()
715
-    {
716
-        $controller = new SmartObjectController($this->handler);
717
-
718
-        return $controller->getPrintAndMailLink($this);
719
-    }
720
-
721
-    /**
722
-     * @param $sortsel
723
-     * @return array|bool
724
-     */
725
-    public function getFieldsForSorting($sortsel)
726
-    {
727
-        $ret = [];
728
-
729
-        foreach ($this->vars as $key => $field_info) {
730
-            if ($field_info['sortby']) {
731
-                $ret[$key]['caption']  = $field_info['form_caption'];
732
-                $ret[$key]['selected'] = $key == $sortsel ? 'selected' : '';
733
-            }
734
-        }
735
-
736
-        if (count($ret) > 0) {
737
-            return $ret;
738
-        } else {
739
-            return false;
740
-        }
741
-    }
742
-
743
-    /**
744
-     * @param $key
745
-     * @param $newType
746
-     */
747
-    public function setType($key, $newType)
748
-    {
749
-        $this->vars[$key]['data_type'] = $newType;
750
-    }
751
-
752
-    /**
753
-     * @param $key
754
-     * @param $info
755
-     * @param $value
756
-     */
757
-    public function setVarInfo($key, $info, $value)
758
-    {
759
-        $this->vars[$key][$info] = $value;
760
-    }
761
-
762
-    /**
763
-     * @param         $key
764
-     * @param  bool   $editor
765
-     * @return string
766
-     */
767
-    public function getValueFor($key, $editor = true)
768
-    {
769
-        global $xoopsModuleConfig;
770
-
771
-        $ret  = $this->getVar($key, 'n');
772
-        $myts = MyTextSanitizer::getInstance();
773
-
774
-        $control     = isset($this->controls[$key]) ? $this->controls[$key] : false;
775
-        $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
776
-
777
-        $html     = isset($this->vars['dohtml']) ? $this->getVar('dohtml') : true;
778
-        $smiley   = true;
779
-        $xcode    = true;
780
-        $image    = true;
781
-        $br       = isset($this->vars['dobr']) ? $this->getVar('dobr') : true;
782
-        $formatML = true;
783
-
784
-        if ('default' === $form_editor) {
785
-            global $xoopsModuleConfig;
786
-            $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
787
-        }
788
-
789
-        if ($editor) {
790
-            if (defined('XOOPS_EDITOR_IS_HTML')
791
-                && !in_array($form_editor, ['formtextarea', 'textarea', 'dhtmltextarea'])) {
792
-                $br       = false;
793
-                $formatML = !$editor;
794
-            } else {
795
-                return htmlspecialchars($ret, ENT_QUOTES);
796
-            }
797
-        }
798
-
799
-        if (method_exists($myts, 'formatForML')) {
800
-            return $myts->displayTarea($ret, $html, $smiley, $xcode, $image, $br, $formatML);
801
-        } else {
802
-            return $myts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
803
-        }
804
-    }
805
-
806
-    /**
807
-     * clean values of all variables of the object for storage.
808
-     * also add slashes whereever needed
809
-     *
810
-     * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
811
-     * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
812
-     * as a string separated by |
813
-     *
814
-     * @return bool true if successful
815
-     * @access public
816
-     */
817
-    public function cleanVars()
818
-    {
819
-        $ts              = MyTextSanitizer::getInstance();
820
-        $existing_errors = $this->getErrors();
821
-        $this->_errors   = [];
822
-        foreach ($this->vars as $k => $v) {
823
-            $cleanv = $v['value'];
824
-            if (!$v['changed']) {
825
-            } else {
826
-                $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
827
-                switch ($v['data_type']) {
828
-                    case XOBJ_DTYPE_TXTBOX:
829
-                        if ($v['required'] && '0' != $cleanv && '' == $cleanv) {
830
-                            $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
831
-                            continue 2;
832
-                        }
833
-                        if (isset($v['maxlength']) && strlen($cleanv) > (int)$v['maxlength']) {
834
-                            $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, (int)$v['maxlength']));
835
-                            continue 2;
836
-                        }
837
-                        if (!$v['not_gpc']) {
838
-                            $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
839
-                        } else {
840
-                            $cleanv = $ts->censorString($cleanv);
841
-                        }
842
-                        break;
843
-                    case XOBJ_DTYPE_TXTAREA:
844
-                        if ($v['required'] && '0' != $cleanv && '' == $cleanv) {
845
-                            $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
846
-                            continue 2;
847
-                        }
848
-                        if (!$v['not_gpc']) {
849
-                            $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
850
-                        } else {
851
-                            $cleanv = $ts->censorString($cleanv);
852
-                        }
853
-                        break;
854
-                    case XOBJ_DTYPE_SOURCE:
855
-                        if (!$v['not_gpc']) {
856
-                            $cleanv = $ts->stripSlashesGPC($cleanv);
857
-                        } else {
858
-                            $cleanv = $cleanv;
859
-                        }
860
-                        break;
861
-                    case XOBJ_DTYPE_INT:
862
-                    case XOBJ_DTYPE_TIME_ONLY:
863
-                        $cleanv = (int)$cleanv;
864
-                        break;
865
-
866
-                    case XOBJ_DTYPE_CURRENCY:
867
-                        $cleanv = smart_currency($cleanv);
868
-                        break;
869
-
870
-                    case XOBJ_DTYPE_FLOAT:
871
-                        $cleanv = smart_float($cleanv);
872
-                        break;
873
-
874
-                    case XOBJ_DTYPE_EMAIL:
875
-                        if ($v['required'] && '' === $cleanv) {
876
-                            $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
877
-                            continue 2;
878
-                        }
879
-                        if ('' !== $cleanv
880
-                            && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $cleanv)) {
881
-                            $this->setErrors('Invalid Email');
882
-                            continue 2;
883
-                        }
884
-                        if (!$v['not_gpc']) {
885
-                            $cleanv = $ts->stripSlashesGPC($cleanv);
886
-                        }
887
-                        break;
888
-                    case XOBJ_DTYPE_URL:
889
-                        if ($v['required'] && '' === $cleanv) {
890
-                            $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
891
-                            continue 2;
892
-                        }
893
-                        if ('' !== $cleanv && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
894
-                            $cleanv = 'http://' . $cleanv;
895
-                        }
896
-                        if (!$v['not_gpc']) {
897
-                            $cleanv =& $ts->stripSlashesGPC($cleanv);
898
-                        }
899
-                        break;
900
-                    case XOBJ_DTYPE_SIMPLE_ARRAY:
901
-                        $cleanv = implode('|', $cleanv);
902
-                        break;
903
-                    case XOBJ_DTYPE_ARRAY:
904
-                        $cleanv = serialize($cleanv);
905
-                        break;
906
-                    case XOBJ_DTYPE_STIME:
907
-                    case XOBJ_DTYPE_MTIME:
908
-                    case XOBJ_DTYPE_LTIME:
909
-                        $cleanv = !is_string($cleanv) ? (int)$cleanv : strtotime($cleanv);
910
-                        if (!($cleanv > 0)) {
911
-                            $cleanv = strtotime($cleanv);
912
-                        }
913
-                        break;
914
-                    default:
915
-                        break;
916
-                }
917
-            }
918
-            $this->cleanVars[$k] =& $cleanv;
919
-            unset($cleanv);
920
-        }
921
-        if (count($this->_errors) > 0) {
922
-            $this->_errors = array_merge($existing_errors, $this->_errors);
923
-
924
-            return false;
925
-        }
926
-        $this->_errors = array_merge($existing_errors, $this->_errors);
927
-        $this->unsetDirty();
928
-
929
-        return true;
930
-    }
931
-
932
-    /**
933
-     * returns a specific variable for the object in a proper format
934
-     *
935
-     * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
936
-     * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
937
-     * as a string separated by |
938
-     *
939
-     * @access public
940
-     * @param  string $key    key of the object's variable to be returned
941
-     * @param  string $format format to use for the output
942
-     * @return mixed  formatted value of the variable
943
-     */
944
-    public function getVar($key, $format = 's')
945
-    {
946
-        global $myts;
947
-
948
-        $ret = $this->vars[$key]['value'];
949
-
950
-        switch ($this->vars[$key]['data_type']) {
951
-
952
-            case XOBJ_DTYPE_TXTBOX:
953
-                switch (strtolower($format)) {
954
-                    case 's':
955
-                    case 'show':
956
-                        // ML Hack by marcan
957
-                        $ts  = MyTextSanitizer::getInstance();
958
-                        $ret = $ts->htmlSpecialChars($ret);
959
-
960
-                        if (method_exists($myts, 'formatForML')) {
961
-                            return $ts->formatForML($ret);
962
-                        } else {
963
-                            return $ret;
964
-                        }
965
-                        break 1;
966
-                    // End of ML Hack by marcan
967
-
968
-                    case 'clean':
969
-                        $ts = MyTextSanitizer::getInstance();
970
-
971
-                        $ret = smart_html2text($ret);
972
-                        $ret = smart_purifyText($ret);
973
-
974
-                        if (method_exists($myts, 'formatForML')) {
975
-                            return $ts->formatForML($ret);
976
-                        } else {
977
-                            return $ret;
978
-                        }
979
-                        break 1;
980
-                    // End of ML Hack by marcan
981
-
982
-                    case 'e':
983
-                    case 'edit':
984
-                        $ts = MyTextSanitizer::getInstance();
985
-
986
-                        return $ts->htmlSpecialChars($ret);
987
-                        break 1;
988
-                    case 'p':
989
-                    case 'preview':
990
-                    case 'f':
991
-                    case 'formpreview':
992
-                        $ts = MyTextSanitizer::getInstance();
993
-
994
-                        return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
995
-                        break 1;
996
-                    case 'n':
997
-                    case 'none':
998
-                    default:
999
-                        break 1;
1000
-                }
1001
-                break;
1002
-            case XOBJ_DTYPE_LTIME:
1003
-                switch (strtolower($format)) {
1004
-                    case 's':
1005
-                    case 'show':
1006
-                    case 'p':
1007
-                    case 'preview':
1008
-                    case 'f':
1009
-                    case 'formpreview':
1010
-                        $ret = formatTimestamp($ret, _DATESTRING);
1011
-
1012
-                        return $ret;
1013
-                        break 1;
1014
-                    case 'n':
1015
-                    case 'none':
1016
-                    case 'e':
1017
-                    case 'edit':
1018
-                        break 1;
1019
-                    default:
1020
-                        break 1;
1021
-                }
1022
-                break;
1023
-            case XOBJ_DTYPE_STIME:
1024
-                switch (strtolower($format)) {
1025
-                    case 's':
1026
-                    case 'show':
1027
-                    case 'p':
1028
-                    case 'preview':
1029
-                    case 'f':
1030
-                    case 'formpreview':
1031
-                        $ret = formatTimestamp($ret, _SHORTDATESTRING);
1032
-
1033
-                        return $ret;
1034
-                        break 1;
1035
-                    case 'n':
1036
-                    case 'none':
1037
-                    case 'e':
1038
-                    case 'edit':
1039
-                        break 1;
1040
-                    default:
1041
-                        break 1;
1042
-                }
1043
-                break;
1044
-            case XOBJ_DTYPE_TIME_ONLY:
1045
-                switch (strtolower($format)) {
1046
-                    case 's':
1047
-                    case 'show':
1048
-                    case 'p':
1049
-                    case 'preview':
1050
-                    case 'f':
1051
-                    case 'formpreview':
1052
-                        $ret = formatTimestamp($ret, 'G:i');
1053
-
1054
-                        return $ret;
1055
-                        break 1;
1056
-                    case 'n':
1057
-                    case 'none':
1058
-                    case 'e':
1059
-                    case 'edit':
1060
-                        break 1;
1061
-                    default:
1062
-                        break 1;
1063
-                }
1064
-                break;
1065
-
1066
-            case XOBJ_DTYPE_CURRENCY:
1067
-                $decimal_section_original = strstr($ret, '.');
1068
-                $decimal_section          = $decimal_section_original;
1069
-                if ($decimal_section) {
1070
-                    if (1 == strlen($decimal_section)) {
1071
-                        $decimal_section = '.00';
1072
-                    } elseif (2 == strlen($decimal_section)) {
1073
-                        $decimal_section .= '0';
1074
-                    }
1075
-                    $ret = str_replace($decimal_section_original, $decimal_section, $ret);
1076
-                } else {
1077
-                    $ret .= '.00';
1078
-                }
1079
-                break;
1080
-
1081
-            case XOBJ_DTYPE_TXTAREA:
1082
-                switch (strtolower($format)) {
1083
-                    case 's':
1084
-                    case 'show':
1085
-                        $ts   = MyTextSanitizer::getInstance();
1086
-                        $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
1087
-
1088
-                        $xcode = (!isset($this->vars['doxcode']['value'])
1089
-                                  || 1 == $this->vars['doxcode']['value']) ? 1 : 0;
1090
-
1091
-                        $smiley = (!isset($this->vars['dosmiley']['value'])
1092
-                                   || 1 == $this->vars['dosmiley']['value']) ? 1 : 0;
1093
-                        $image  = (!isset($this->vars['doimage']['value'])
1094
-                                   || 1 == $this->vars['doimage']['value']) ? 1 : 0;
1095
-                        $br     = (!isset($this->vars['dobr']['value']) || 1 == $this->vars['dobr']['value']) ? 1 : 0;
1096
-
1097
-                        /**
1098
-                         * Hack by marcan <INBOX> for SCSPRO
1099
-                         * Setting mastop as the main editor
1100
-                         */
1101
-                        if (defined('XOOPS_EDITOR_IS_HTML')) {
1102
-                            $br = false;
1103
-                        }
1104
-
1105
-                        /**
1106
-                         * Hack by marcan <INBOX> for SCSPRO
1107
-                         * Setting mastop as the main editor
1108
-                         */
1109
-
1110
-                        return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
1111
-                        break 1;
1112
-                    case 'e':
1113
-                    case 'edit':
1114
-                        return htmlspecialchars($ret, ENT_QUOTES);
1115
-                        break 1;
1116
-                    case 'p':
1117
-                    case 'preview':
1118
-                        $ts     = MyTextSanitizer::getInstance();
1119
-                        $html   = !empty($this->vars['dohtml']['value']) ? 1 : 0;
1120
-                        $xcode  = (!isset($this->vars['doxcode']['value'])
1121
-                                   || 1 == $this->vars['doxcode']['value']) ? 1 : 0;
1122
-                        $smiley = (!isset($this->vars['dosmiley']['value'])
1123
-                                   || 1 == $this->vars['dosmiley']['value']) ? 1 : 0;
1124
-                        $image  = (!isset($this->vars['doimage']['value'])
1125
-                                   || 1 == $this->vars['doimage']['value']) ? 1 : 0;
1126
-                        $br     = (!isset($this->vars['dobr']['value']) || 1 == $this->vars['dobr']['value']) ? 1 : 0;
1127
-
1128
-                        return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
1129
-                        break 1;
1130
-                    case 'f':
1131
-                    case 'formpreview':
1132
-                        $ts = MyTextSanitizer::getInstance();
1133
-
1134
-                        return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
1135
-                        break 1;
1136
-                    case 'n':
1137
-                    case 'none':
1138
-                    default:
1139
-                        break 1;
1140
-                }
1141
-                break;
1142
-            case XOBJ_DTYPE_SIMPLE_ARRAY:
1143
-                $ret =& explode('|', $ret);
1144
-                break;
1145
-            case XOBJ_DTYPE_ARRAY:
1146
-                $ret =& unserialize($ret);
1147
-                break;
1148
-            case XOBJ_DTYPE_SOURCE:
1149
-                switch (strtolower($format)) {
1150
-                    case 's':
1151
-                    case 'show':
1152
-                        break 1;
1153
-                    case 'e':
1154
-                    case 'edit':
1155
-                        return htmlspecialchars($ret, ENT_QUOTES);
1156
-                        break 1;
1157
-                    case 'p':
1158
-                    case 'preview':
1159
-                        $ts = MyTextSanitizer::getInstance();
1160
-
1161
-                        return $ts->stripSlashesGPC($ret);
1162
-                        break 1;
1163
-                    case 'f':
1164
-                    case 'formpreview':
1165
-                        $ts = MyTextSanitizer::getInstance();
1166
-
1167
-                        return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
1168
-                        break 1;
1169
-                    case 'n':
1170
-                    case 'none':
1171
-                    default:
1172
-                        break 1;
1173
-                }
1174
-                break;
1175
-            default:
1176
-                if ('' !== $this->vars[$key]['options'] && '' != $ret) {
1177
-                    switch (strtolower($format)) {
1178
-                        case 's':
1179
-                        case 'show':
1180
-                            $selected = explode('|', $ret);
1181
-                            $options  = explode('|', $this->vars[$key]['options']);
1182
-                            $i        = 1;
1183
-                            $ret      = [];
1184
-                            foreach ($options as $op) {
1185
-                                if (in_array($i, $selected)) {
1186
-                                    $ret[] = $op;
1187
-                                }
1188
-                                ++$i;
1189
-                            }
1190
-
1191
-                            return implode(', ', $ret);
1192
-                        case 'e':
1193
-                        case 'edit':
1194
-                            $ret = explode('|', $ret);
1195
-                            break 1;
1196
-                        default:
1197
-                            break 1;
1198
-                    }
1199
-                }
1200
-                break;
1201
-        }
1202
-
1203
-        return $ret;
1204
-    }
1205
-
1206
-    /**
1207
-     * @param $key
1208
-     */
1209
-    public function doMakeFieldreadOnly($key)
1210
-    {
1211
-        if (isset($this->vars[$key])) {
1212
-            $this->vars[$key]['readonly']      = true;
1213
-            $this->vars[$key]['displayOnForm'] = true;
1214
-        }
1215
-    }
1216
-
1217
-    /**
1218
-     * @param $key
1219
-     */
1220
-    public function makeFieldReadOnly($key)
1221
-    {
1222
-        if (is_array($key)) {
1223
-            foreach ($key as $v) {
1224
-                $this->doMakeFieldreadOnly($v);
1225
-            }
1226
-        } else {
1227
-            $this->doMakeFieldreadOnly($key);
1228
-        }
1229
-    }
1230
-
1231
-    /**
1232
-     * @param $key
1233
-     */
1234
-    public function doHideFieldFromForm($key)
1235
-    {
1236
-        if (isset($this->vars[$key])) {
1237
-            $this->vars[$key]['displayOnForm'] = false;
1238
-        }
1239
-    }
1240
-
1241
-    /**
1242
-     * @param $key
1243
-     */
1244
-    public function doHideFieldFromSingleView($key)
1245
-    {
1246
-        if (isset($this->vars[$key])) {
1247
-            $this->vars[$key]['displayOnSingleView'] = false;
1248
-        }
1249
-    }
1250
-
1251
-    /**
1252
-     * @param $key
1253
-     */
1254
-    public function hideFieldFromForm($key)
1255
-    {
1256
-        if (is_array($key)) {
1257
-            foreach ($key as $v) {
1258
-                $this->doHideFieldFromForm($v);
1259
-            }
1260
-        } else {
1261
-            $this->doHideFieldFromForm($key);
1262
-        }
1263
-    }
1264
-
1265
-    /**
1266
-     * @param $key
1267
-     */
1268
-    public function hideFieldFromSingleView($key)
1269
-    {
1270
-        if (is_array($key)) {
1271
-            foreach ($key as $v) {
1272
-                $this->doHideFieldFromSingleView($v);
1273
-            }
1274
-        } else {
1275
-            $this->doHideFieldFromSingleView($key);
1276
-        }
1277
-    }
1278
-
1279
-    /**
1280
-     * @param $key
1281
-     */
1282
-    public function doShowFieldOnForm($key)
1283
-    {
1284
-        if (isset($this->vars[$key])) {
1285
-            $this->vars[$key]['displayOnForm'] = true;
1286
-        }
1287
-    }
1288
-
1289
-    /**
1290
-     * Display an automatic SingleView of the object, based on the displayOnSingleView param of each vars
1291
-     *
1292
-     * @param  bool  $fetchOnly if set to TRUE, then the content will be return, if set to FALSE, the content will be outputed
1293
-     * @param  bool  $userSide  for futur use, to do something different on the user side
1294
-     * @param  array $actions
1295
-     * @param  bool  $headerAsRow
1296
-     * @return content of the template if $fetchOnly or nothing if !$fetchOnly
1297
-     */
1298
-    public function displaySingleObject(
1299
-        $fetchOnly = false,
1300
-        $userSide = false,
1301
-        $actions = [],
1302
-        $headerAsRow = true
1303
-    ) {
1304
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectsingleview.php';
1305
-        $singleview = new SmartObjectSingleView($this, $userSide, $actions, $headerAsRow);
1306
-        // add all fields mark as displayOnSingleView except the keyid
1307
-        foreach ($this->vars as $key => $var) {
1308
-            if ($key != $this->handler->keyName && $var['displayOnSingleView']) {
1309
-                $is_header = ($key == $this->handler->identifierName);
1310
-                $singleview->addRow(new SmartObjectRow($key, false, $is_header));
1311
-            }
1312
-        }
1313
-
1314
-        if ($fetchOnly) {
1315
-            $ret = $singleview->render($fetchOnly);
1316
-
1317
-            return $ret;
1318
-        } else {
1319
-            $singleview->render($fetchOnly);
1320
-        }
1321
-    }
1322
-
1323
-    /**
1324
-     * @param $key
1325
-     */
1326
-    public function doDisplayFieldOnSingleView($key)
1327
-    {
1328
-        if (isset($this->vars[$key])) {
1329
-            $this->vars[$key]['displayOnSingleView'] = true;
1330
-        }
1331
-    }
1332
-
1333
-    /**
1334
-     * @param      $field
1335
-     * @param bool $required
1336
-     */
1337
-    public function doSetFieldAsRequired($field, $required = true)
1338
-    {
1339
-        $this->setVarInfo($field, 'required', $required);
1340
-    }
1341
-
1342
-    /**
1343
-     * @param $field
1344
-     */
1345
-    public function doSetFieldForSorting($field)
1346
-    {
1347
-        $this->setVarInfo($field, 'sortby', true);
1348
-    }
1349
-
1350
-    /**
1351
-     * @param $key
1352
-     */
1353
-    public function showFieldOnForm($key)
1354
-    {
1355
-        if (is_array($key)) {
1356
-            foreach ($key as $v) {
1357
-                $this->doShowFieldOnForm($v);
1358
-            }
1359
-        } else {
1360
-            $this->doShowFieldOnForm($key);
1361
-        }
1362
-    }
1363
-
1364
-    /**
1365
-     * @param $key
1366
-     */
1367
-    public function displayFieldOnSingleView($key)
1368
-    {
1369
-        if (is_array($key)) {
1370
-            foreach ($key as $v) {
1371
-                $this->doDisplayFieldOnSingleView($v);
1372
-            }
1373
-        } else {
1374
-            $this->doDisplayFieldOnSingleView($key);
1375
-        }
1376
-    }
1377
-
1378
-    /**
1379
-     * @param $key
1380
-     */
1381
-    public function doSetAdvancedFormFields($key)
1382
-    {
1383
-        if (isset($this->vars[$key])) {
1384
-            $this->vars[$key]['advancedform'] = true;
1385
-        }
1386
-    }
1387
-
1388
-    /**
1389
-     * @param $key
1390
-     */
1391
-    public function setAdvancedFormFields($key)
1392
-    {
1393
-        if (is_array($key)) {
1394
-            foreach ($key as $v) {
1395
-                $this->doSetAdvancedFormFields($v);
1396
-            }
1397
-        } else {
1398
-            $this->doSetAdvancedFormFields($key);
1399
-        }
1400
-    }
1401
-
1402
-    /**
1403
-     * @param $key
1404
-     * @return mixed
1405
-     */
1406
-    public function getUrlLinkObj($key)
1407
-    {
1408
-        $smartobjectLinkurlHandler = xoops_getModuleHandler('urllink', 'smartobject');
1409
-        $urllinkid                 = null !== $this->getVar($key) ? $this->getVar($key) : 0;
1410
-        if (0 != $urllinkid) {
1411
-            return $smartobjectLinkurlHandler->get($urllinkid);
1412
-        } else {
1413
-            return $smartobjectLinkurlHandler->create();
1414
-        }
1415
-    }
1416
-
1417
-    /**
1418
-     * @param $urlLinkObj
1419
-     * @return mixed
1420
-     */
1421
-    public function &storeUrlLinkObj($urlLinkObj)
1422
-    {
1423
-        $smartobjectLinkurlHandler = xoops_getModuleHandler('urllink', 'smartobject');
1424
-
1425
-        return $smartobjectLinkurlHandler->insert($urlLinkObj);
1426
-    }
1427
-
1428
-    /**
1429
-     * @param $key
1430
-     * @return mixed
1431
-     */
1432
-    public function getFileObj($key)
1433
-    {
1434
-        $smartobjectFileHandler = xoops_getModuleHandler('file', 'smartobject');
1435
-        $fileid                 = null !== $this->getVar($key) ? $this->getVar($key) : 0;
1436
-        if (0 != $fileid) {
1437
-            return $smartobjectFileHandler->get($fileid);
1438
-        } else {
1439
-            return $smartobjectFileHandler->create();
1440
-        }
1441
-    }
1442
-
1443
-    /**
1444
-     * @param $fileObj
1445
-     * @return mixed
1446
-     */
1447
-    public function &storeFileObj($fileObj)
1448
-    {
1449
-        $smartobjectFileHandler = xoops_getModuleHandler('file', 'smartobject');
1450
-
1451
-        return $smartobjectFileHandler->insert($fileObj);
1452
-    }
58
+	public $_image_path;
59
+	public $_image_url;
60
+
61
+	public $seoEnabled   = false;
62
+	public $titleField;
63
+	public $summaryField = false;
64
+
65
+	/**
66
+	 * Reference to the handler managing this object
67
+	 *
68
+	 * @var SmartPersistableObjectHandler reference to {@link SmartPersistableObjectHandler}
69
+	 */
70
+	public $handler;
71
+
72
+	/**
73
+	 * References to control objects, managing the form fields of this object
74
+	 */
75
+	public $controls = [];
76
+
77
+	/**
78
+	 * SmartObject constructor.
79
+	 * @param $handler
80
+	 */
81
+	public function __construct($handler)
82
+	{
83
+		$this->handler = $handler;
84
+	}
85
+
86
+	/**
87
+	 * Checks if the user has a specific access on this object
88
+	 *
89
+	 * @param $perm_name
90
+	 * @return bool: TRUE if user has access, false if not
91
+	 * @internal param string $gperm_name name of the permission to test
92
+	 */
93
+	public function accessGranted($perm_name)
94
+	{
95
+		$smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
96
+
97
+		return $smartPermissionsHandler->accessGranted($perm_name, $this->id());
98
+	}
99
+
100
+	/**
101
+	 * @param      $section_name
102
+	 * @param bool $value
103
+	 * @param bool $hide
104
+	 */
105
+	public function addFormSection($section_name, $value = false, $hide = false)
106
+	{
107
+		$this->initVar($section_name, XOBJ_DTYPE_FORM_SECTION, $value, false, null, '', false, '', '', false, false, true);
108
+		$this->vars[$section_name]['hide'] = $hide;
109
+	}
110
+
111
+	/**
112
+	 * @param $section_name
113
+	 */
114
+	public function closeSection($section_name)
115
+	{
116
+		$this->initVar('close_section_' . $section_name, XOBJ_DTYPE_FORM_SECTION_CLOSE, '', false, null, '', false, '', '', false, false, true);
117
+	}
118
+
119
+	/**
120
+	 *
121
+	 * @param string $key          key of this field. This needs to be the name of the field in the related database table
122
+	 * @param int    $data_type    set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
123
+	 * @param mixed  $value        default value of this variable
124
+	 * @param bool   $required     set to TRUE if this variable needs to have a value set before storing the object in the table
125
+	 * @param int    $maxlength    maximum length of this variable, for XOBJ_DTYPE_TXTBOX type only
126
+	 * @param string $options      does this data have any select options?
127
+	 * @param bool   $multilingual is this field needs to support multilingual features (NOT YET IMPLEMENTED...)
128
+	 * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
129
+	 * @param string $form_dsc     description of this variable in a {@link SmartobjectForm}
130
+	 * @param bool   $sortby       set to TRUE to make this field used to sort objects in SmartObjectTable
131
+	 * @param bool   $persistent   set to FALSE if this field is not to be saved in the database
132
+	 * @param bool   $displayOnForm
133
+	 */
134
+	public function initVar(
135
+		$key,
136
+		$data_type,
137
+		$value = null,
138
+		$required = false,
139
+		$maxlength = null,
140
+		$options = '',
141
+		$multilingual = false,
142
+		$form_caption = '',
143
+		$form_dsc = '',
144
+		$sortby = false,
145
+		$persistent = true,
146
+		$displayOnForm = true
147
+	) {
148
+		//url_ is reserved for files.
149
+		if (0 === strpos($key, 'url_')) {
150
+			trigger_error("Cannot use variable starting with 'url_'.");
151
+		}
152
+		parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
153
+		if ($this->handler && (!$form_caption || '' === $form_caption)) {
154
+			$dyn_form_caption = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key);
155
+			if (defined($dyn_form_caption)) {
156
+				$form_caption = constant($dyn_form_caption);
157
+			}
158
+		}
159
+		if ($this->handler && (!$form_dsc || '' === $form_dsc)) {
160
+			$dyn_form_dsc = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key . '_DSC');
161
+			if (defined($dyn_form_dsc)) {
162
+				$form_dsc = constant($dyn_form_dsc);
163
+			}
164
+		}
165
+
166
+		$this->vars[$key] = array_merge($this->vars[$key], [
167
+			'multilingual'        => $multilingual,
168
+			'form_caption'        => $form_caption,
169
+			'form_dsc'            => $form_dsc,
170
+			'sortby'              => $sortby,
171
+			'persistent'          => $persistent,
172
+			'displayOnForm'       => $displayOnForm,
173
+			'displayOnSingleView' => true,
174
+			'readonly'            => false
175
+		]);
176
+	}
177
+
178
+	/**
179
+	 * @param        $key
180
+	 * @param        $data_type
181
+	 * @param bool   $itemName
182
+	 * @param string $form_caption
183
+	 * @param bool   $sortby
184
+	 * @param string $value
185
+	 * @param bool   $displayOnForm
186
+	 * @param bool   $required
187
+	 */
188
+	public function initNonPersistableVar(
189
+		$key,
190
+		$data_type,
191
+		$itemName = false,
192
+		$form_caption = '',
193
+		$sortby = false,
194
+		$value = '',
195
+		$displayOnForm = false,
196
+		$required = false
197
+	) {
198
+		$this->initVar($key, $data_type, $value, $required, null, '', false, $form_caption, '', $sortby, false, $displayOnForm);
199
+		$this->vars[$key]['itemName'] = $itemName;
200
+	}
201
+
202
+	/**
203
+	 * Quickly initiate a var
204
+	 *
205
+	 * Since many vars do have the same config, let's use this method with some of these configuration as a convention ;-)
206
+	 *
207
+	 * - $maxlength = 0 unless $data_type is a TEXTBOX, then $maxlength will be 255
208
+	 * - all other vars are NULL or '' depending of the parameter
209
+	 *
210
+	 * @param string $key          key of this field. This needs to be the name of the field in the related database table
211
+	 * @param int    $data_type    set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
212
+	 * @param bool   $required     set to TRUE if this variable needs to have a value set before storing the object in the table
213
+	 * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
214
+	 * @param string $form_dsc     description of this variable in a {@link SmartobjectForm}
215
+	 * @param mixed  $value        default value of this variable
216
+	 */
217
+	public function quickInitVar(
218
+		$key,
219
+		$data_type,
220
+		$required = false,
221
+		$form_caption = '',
222
+		$form_dsc = '',
223
+		$value = null
224
+	) {
225
+		$maxlength = 'XOBJ_DTYPE_TXTBOX' === $data_type ? 255 : null;
226
+		$this->initVar($key, $data_type, $value, $required, $maxlength, '', false, $form_caption, $form_dsc, false, true, true);
227
+	}
228
+
229
+	/**
230
+	 * @param        $varname
231
+	 * @param bool   $displayOnForm
232
+	 * @param string $default
233
+	 */
234
+	public function initCommonVar($varname, $displayOnForm = true, $default = 'notdefined')
235
+	{
236
+		switch ($varname) {
237
+			case 'dohtml':
238
+				$value = 'notdefined' !== $default ? $default : true;
239
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOHTML_FORM_CAPTION, '', false, true, $displayOnForm);
240
+				$this->setControl($varname, 'yesno');
241
+				break;
242
+
243
+			case 'dobr':
244
+				$value = ('notdefined' === $default) ? true : $default;
245
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
246
+				$this->setControl($varname, 'yesno');
247
+				break;
248
+
249
+			case 'doimage':
250
+				$value = 'notdefined' !== $default ? $default : true;
251
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
252
+				$this->setControl($varname, 'yesno');
253
+				break;
254
+
255
+			case 'dosmiley':
256
+				$value = 'notdefined' !== $default ? $default : true;
257
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
258
+				$this->setControl($varname, 'yesno');
259
+				break;
260
+
261
+			case 'doxcode':
262
+				$value = 'notdefined' !== $default ? $default : true;
263
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
264
+				$this->setControl($varname, 'yesno');
265
+				break;
266
+
267
+			case 'meta_keywords':
268
+				$value = 'notdefined' !== $default ? $default : '';
269
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_KEYWORDS, _CO_SOBJECT_META_KEYWORDS_DSC, false, true, $displayOnForm);
270
+				$this->setControl('meta_keywords', [
271
+					'name'        => 'textarea',
272
+					'form_editor' => 'textarea'
273
+				]);
274
+				break;
275
+
276
+			case 'meta_description':
277
+				$value = 'notdefined' !== $default ? $default : '';
278
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_DESCRIPTION, _CO_SOBJECT_META_DESCRIPTION_DSC, false, true, $displayOnForm);
279
+				$this->setControl('meta_description', [
280
+					'name'        => 'textarea',
281
+					'form_editor' => 'textarea'
282
+				]);
283
+				break;
284
+
285
+			case 'short_url':
286
+				$value = 'notdefined' !== $default ? $default : '';
287
+				$this->initVar($varname, XOBJ_DTYPE_TXTBOX, $value, false, null, '', false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
288
+				break;
289
+
290
+			case 'hierarchy_path':
291
+				$value = 'notdefined' !== $default ? $default : '';
292
+				$this->initVar($varname, XOBJ_DTYPE_ARRAY, $value, false, null, '', false, _CO_SOBJECT_HIERARCHY_PATH, _CO_SOBJECT_HIERARCHY_PATH_DSC, false, true, $displayOnForm);
293
+				break;
294
+
295
+			case 'counter':
296
+				$value = 'notdefined' !== $default ? $default : 0;
297
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
298
+				break;
299
+
300
+			case 'weight':
301
+				$value = 'notdefined' !== $default ? $default : 0;
302
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
303
+				break;
304
+			case 'custom_css':
305
+				$value = 'notdefined' !== $default ? $default : '';
306
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_CUSTOM_CSS, _CO_SOBJECT_CUSTOM_CSS_DSC, false, true, $displayOnForm);
307
+				$this->setControl('custom_css', [
308
+					'name'        => 'textarea',
309
+					'form_editor' => 'textarea'
310
+				]);
311
+				break;
312
+		}
313
+		$this->hideFieldFromSingleView($varname);
314
+	}
315
+
316
+	/**
317
+	 * Set control information for an instance variable
318
+	 *
319
+	 * The $options parameter can be a string or an array. Using a string
320
+	 * is the quickest way:
321
+	 *
322
+	 * $this->setControl('date', 'date_time');
323
+	 *
324
+	 * This will create a date and time selectbox for the 'date' var on the
325
+	 * form to edit or create this item.
326
+	 *
327
+	 * Here are the currently supported controls:
328
+	 *
329
+	 *      - color
330
+	 *      - country
331
+	 *      - date_time
332
+	 *      - date
333
+	 *      - email
334
+	 *      - group
335
+	 *      - group_multi
336
+	 *      - image
337
+	 *      - imageupload
338
+	 *      - label
339
+	 *      - language
340
+	 *      - parentcategory
341
+	 *      - password
342
+	 *      - select_multi
343
+	 *      - select
344
+	 *      - text
345
+	 *      - textarea
346
+	 *      - theme
347
+	 *      - theme_multi
348
+	 *      - timezone
349
+	 *      - user
350
+	 *      - user_multi
351
+	 *      - yesno
352
+	 *
353
+	 * Now, using an array as $options, you can customize what information to
354
+	 * use in the control. For example, if one needs to display a select box for
355
+	 * the user to choose the status of an item. We only need to tell SmartObject
356
+	 * what method to execute within what handler to retreive the options of the
357
+	 * selectbox.
358
+	 *
359
+	 * $this->setControl('status', array('name' => false,
360
+	 *                                   'itemHandler' => 'item',
361
+	 *                                   'method' => 'getStatus',
362
+	 *                                   'module' => 'smartshop'));
363
+	 *
364
+	 * In this example, the array elements are the following:
365
+	 *      - name: false, as we don't need to set a special control here.
366
+	 *               we will use the default control related to the object type (defined in initVar)
367
+	 *      - itemHandler: name of the object for which we will use the handler
368
+	 *      - method: name of the method of this handler that we will execute
369
+	 *      - module: name of the module from wich the handler is
370
+	 *
371
+	 * So in this example, SmartObject will create a selectbox for the variable 'status' and it will
372
+	 * populate this selectbox with the result from SmartshopItemHandler::getStatus()
373
+	 *
374
+	 * Another example of the use of $options as an array is for TextArea:
375
+	 *
376
+	 * $this->setControl('body', array('name' => 'textarea',
377
+	 *                                   'form_editor' => 'default'));
378
+	 *
379
+	 * In this example, SmartObject will create a TextArea for the variable 'body'. And it will use
380
+	 * the 'default' editor, providing it is defined in the module
381
+	 * preferences: $xoopsModuleConfig['default_editor']
382
+	 *
383
+	 * Of course, you can force the use of a specific editor:
384
+	 *
385
+	 * $this->setControl('body', array('name' => 'textarea',
386
+	 *                                   'form_editor' => 'koivi'));
387
+	 *
388
+	 * Here is a list of supported editor:
389
+	 *      - tiny: TinyEditor
390
+	 *      - dhtmltextarea: XOOPS DHTML Area
391
+	 *      - fckeditor: FCKEditor
392
+	 *      - inbetween: InBetween
393
+	 *      - koivi: Koivi
394
+	 *      - spaw: Spaw WYSIWYG Editor
395
+	 *      - htmlarea: HTMLArea
396
+	 *      - textarea: basic textarea with no options
397
+	 *
398
+	 * @param string $var name of the variable for which we want to set a control
399
+	 * @param array  $options
400
+	 */
401
+	public function setControl($var, $options = [])
402
+	{
403
+		if (isset($this->controls[$var])) {
404
+			unset($this->controls[$var]);
405
+		}
406
+		if (is_string($options)) {
407
+			$options = ['name' => $options];
408
+		}
409
+		$this->controls[$var] = $options;
410
+	}
411
+
412
+	/**
413
+	 * Get control information for an instance variable
414
+	 *
415
+	 * @param  string $var
416
+	 * @return bool|mixed
417
+	 */
418
+	public function getControl($var)
419
+	{
420
+		return isset($this->controls[$var]) ? $this->controls[$var] : false;
421
+	}
422
+
423
+	/**
424
+	 * Create the form for this object
425
+	 *
426
+	 * @param         $form_caption
427
+	 * @param         $form_name
428
+	 * @param  bool   $form_action
429
+	 * @param  string $submit_button_caption
430
+	 * @param  bool   $cancel_js_action
431
+	 * @param  bool   $captcha
432
+	 * @return a      <a href='psi_element://SmartobjectForm'>SmartobjectForm</a> object for this object
433
+	 *                                      object for this object
434
+	 * @see SmartObjectForm::SmartObjectForm()
435
+	 */
436
+	public function getForm(
437
+		$form_caption,
438
+		$form_name,
439
+		$form_action = false,
440
+		$submit_button_caption = _CO_SOBJECT_SUBMIT,
441
+		$cancel_js_action = false,
442
+		$captcha = false
443
+	) {
444
+		require_once SMARTOBJECT_ROOT_PATH . 'class/form/smartobjectform.php';
445
+		$form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
446
+
447
+		return $form;
448
+	}
449
+
450
+	/**
451
+	 * @return array
452
+	 */
453
+	public function toArray()
454
+	{
455
+		$ret  = [];
456
+		$vars =& $this->getVars();
457
+		foreach ($vars as $key => $var) {
458
+			$value     = $this->getVar($key);
459
+			$ret[$key] = $value;
460
+		}
461
+		if ('' !== $this->handler->identifierName) {
462
+			$controller = new SmartObjectController($this->handler);
463
+			/**
464
+			 * Addition of some automatic value
465
+			 */
466
+			$ret['itemLink']         = $controller->getItemLink($this);
467
+			$ret['itemUrl']          = $controller->getItemLink($this, true);
468
+			$ret['editItemLink']     = $controller->getEditItemLink($this, false, true);
469
+			$ret['deleteItemLink']   = $controller->getDeleteItemLink($this, false, true);
470
+			$ret['printAndMailLink'] = $controller->getPrintAndMailLink($this);
471
+		}
472
+
473
+		// Hightlighting searched words
474
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smarthighlighter.php';
475
+		$highlight = smart_getConfig('module_search_highlighter', false, true);
476
+
477
+		if ($highlight && isset($_GET['keywords'])) {
478
+			$myts     = MyTextSanitizer::getInstance();
479
+			$keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords'])));
480
+			$h        = new SmartHighlighter($keywords, true, 'smart_highlighter');
481
+			foreach ($this->handler->highlightFields as $field) {
482
+				$ret[$field] = $h->highlight($ret[$field]);
483
+			}
484
+		}
485
+
486
+		return $ret;
487
+	}
488
+
489
+	/**
490
+	 * add an error
491
+	 *
492
+	 * @param      $err_str
493
+	 * @param bool $prefix
494
+	 * @internal param string $value error to add
495
+	 * @access   public
496
+	 */
497
+	public function setErrors($err_str, $prefix = false)
498
+	{
499
+		if (is_array($err_str)) {
500
+			foreach ($err_str as $str) {
501
+				$this->setErrors($str, $prefix);
502
+			}
503
+		} else {
504
+			if ($prefix) {
505
+				$err_str = '[' . $prefix . '] ' . $err_str;
506
+			}
507
+			parent::setErrors($err_str);
508
+		}
509
+	}
510
+
511
+	/**
512
+	 * @param      $field
513
+	 * @param bool $required
514
+	 */
515
+	public function setFieldAsRequired($field, $required = true)
516
+	{
517
+		if (is_array($field)) {
518
+			foreach ($field as $v) {
519
+				$this->doSetFieldAsRequired($v, $required);
520
+			}
521
+		} else {
522
+			$this->doSetFieldAsRequired($field, $required);
523
+		}
524
+	}
525
+
526
+	/**
527
+	 * @param $field
528
+	 */
529
+	public function setFieldForSorting($field)
530
+	{
531
+		if (is_array($field)) {
532
+			foreach ($field as $v) {
533
+				$this->doSetFieldForSorting($v);
534
+			}
535
+		} else {
536
+			$this->doSetFieldForSorting($field);
537
+		}
538
+	}
539
+
540
+	/**
541
+	 * @return bool
542
+	 */
543
+	public function hasError()
544
+	{
545
+		return count($this->_errors) > 0;
546
+	}
547
+
548
+	/**
549
+	 * @param $url
550
+	 * @param $path
551
+	 */
552
+	public function setImageDir($url, $path)
553
+	{
554
+		$this->_image_url  = $url;
555
+		$this->_image_path = $path;
556
+	}
557
+
558
+	/**
559
+	 * Retreive the group that have been granted access to a specific permission for this object
560
+	 *
561
+	 * @param $group_perm
562
+	 * @return string $group_perm name of the permission
563
+	 */
564
+	public function getGroupPerm($group_perm)
565
+	{
566
+		if (!$this->handler->getPermissions()) {
567
+			$this->setError("Trying to access a permission that does not exists for thisobject's handler");
568
+
569
+			return false;
570
+		}
571
+
572
+		$smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler);
573
+		$ret                     = $smartPermissionsHandler->getGrantedGroups($group_perm, $this->id());
574
+
575
+		if (0 == count($ret)) {
576
+			return false;
577
+		} else {
578
+			return $ret;
579
+		}
580
+	}
581
+
582
+	/**
583
+	 * @param  bool $path
584
+	 * @return mixed
585
+	 */
586
+	public function getImageDir($path = false)
587
+	{
588
+		if ($path) {
589
+			return $this->_image_path;
590
+		} else {
591
+			return $this->_image_url;
592
+		}
593
+	}
594
+
595
+	/**
596
+	 * @param  bool $path
597
+	 * @return mixed
598
+	 */
599
+	public function getUploadDir($path = false)
600
+	{
601
+		if ($path) {
602
+			return $this->_image_path;
603
+		} else {
604
+			return $this->_image_url;
605
+		}
606
+	}
607
+
608
+	/**
609
+	 * @param  string $key
610
+	 * @param  string $info
611
+	 * @return array
612
+	 */
613
+	public function getVarInfo($key = '', $info = '')
614
+	{
615
+		if (isset($this->vars[$key][$info])) {
616
+			return $this->vars[$key][$info];
617
+		} elseif ('' === $info && isset($this->vars[$key])) {
618
+			return $this->vars[$key];
619
+		} else {
620
+			return $this->vars;
621
+		}
622
+	}
623
+
624
+	/**
625
+	 * Get the id of the object
626
+	 *
627
+	 * @return int id of this object
628
+	 */
629
+	public function id()
630
+	{
631
+		return $this->getVar($this->handler->keyName, 'e');
632
+	}
633
+
634
+	/**
635
+	 * Return the value of the title field of this object
636
+	 *
637
+	 * @param  string $format
638
+	 * @return string
639
+	 */
640
+	public function title($format = 's')
641
+	{
642
+		return $this->getVar($this->handler->identifierName, $format);
643
+	}
644
+
645
+	/**
646
+	 * Return the value of the title field of this object
647
+	 *
648
+	 * @return string
649
+	 */
650
+	public function summary()
651
+	{
652
+		if ($this->handler->summaryName) {
653
+			return $this->getVar($this->handler->summaryName);
654
+		} else {
655
+			return false;
656
+		}
657
+	}
658
+
659
+	/**
660
+	 * Retreive the object admin side link, displayijng a SingleView page
661
+	 *
662
+	 * @param  bool $onlyUrl wether or not to return a simple URL or a full <a> link
663
+	 * @return string user side link to the object
664
+	 */
665
+	public function getAdminViewItemLink($onlyUrl = false)
666
+	{
667
+		$controller = new SmartObjectController($this->handler);
668
+
669
+		return $controller->getAdminViewItemLink($this, $onlyUrl);
670
+	}
671
+
672
+	/**
673
+	 * Retreive the object user side link
674
+	 *
675
+	 * @param  bool $onlyUrl wether or not to return a simple URL or a full <a> link
676
+	 * @return string user side link to the object
677
+	 */
678
+	public function getItemLink($onlyUrl = false)
679
+	{
680
+		$controller = new SmartObjectController($this->handler);
681
+
682
+		return $controller->getItemLink($this, $onlyUrl);
683
+	}
684
+
685
+	/**
686
+	 * @param  bool $onlyUrl
687
+	 * @param  bool $withimage
688
+	 * @param  bool $userSide
689
+	 * @return string
690
+	 */
691
+	public function getEditItemLink($onlyUrl = false, $withimage = true, $userSide = false)
692
+	{
693
+		$controller = new SmartObjectController($this->handler);
694
+
695
+		return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
696
+	}
697
+
698
+	/**
699
+	 * @param  bool $onlyUrl
700
+	 * @param  bool $withimage
701
+	 * @param  bool $userSide
702
+	 * @return string
703
+	 */
704
+	public function getDeleteItemLink($onlyUrl = false, $withimage = false, $userSide = false)
705
+	{
706
+		$controller = new SmartObjectController($this->handler);
707
+
708
+		return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
709
+	}
710
+
711
+	/**
712
+	 * @return string
713
+	 */
714
+	public function getPrintAndMailLink()
715
+	{
716
+		$controller = new SmartObjectController($this->handler);
717
+
718
+		return $controller->getPrintAndMailLink($this);
719
+	}
720
+
721
+	/**
722
+	 * @param $sortsel
723
+	 * @return array|bool
724
+	 */
725
+	public function getFieldsForSorting($sortsel)
726
+	{
727
+		$ret = [];
728
+
729
+		foreach ($this->vars as $key => $field_info) {
730
+			if ($field_info['sortby']) {
731
+				$ret[$key]['caption']  = $field_info['form_caption'];
732
+				$ret[$key]['selected'] = $key == $sortsel ? 'selected' : '';
733
+			}
734
+		}
735
+
736
+		if (count($ret) > 0) {
737
+			return $ret;
738
+		} else {
739
+			return false;
740
+		}
741
+	}
742
+
743
+	/**
744
+	 * @param $key
745
+	 * @param $newType
746
+	 */
747
+	public function setType($key, $newType)
748
+	{
749
+		$this->vars[$key]['data_type'] = $newType;
750
+	}
751
+
752
+	/**
753
+	 * @param $key
754
+	 * @param $info
755
+	 * @param $value
756
+	 */
757
+	public function setVarInfo($key, $info, $value)
758
+	{
759
+		$this->vars[$key][$info] = $value;
760
+	}
761
+
762
+	/**
763
+	 * @param         $key
764
+	 * @param  bool   $editor
765
+	 * @return string
766
+	 */
767
+	public function getValueFor($key, $editor = true)
768
+	{
769
+		global $xoopsModuleConfig;
770
+
771
+		$ret  = $this->getVar($key, 'n');
772
+		$myts = MyTextSanitizer::getInstance();
773
+
774
+		$control     = isset($this->controls[$key]) ? $this->controls[$key] : false;
775
+		$form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
776
+
777
+		$html     = isset($this->vars['dohtml']) ? $this->getVar('dohtml') : true;
778
+		$smiley   = true;
779
+		$xcode    = true;
780
+		$image    = true;
781
+		$br       = isset($this->vars['dobr']) ? $this->getVar('dobr') : true;
782
+		$formatML = true;
783
+
784
+		if ('default' === $form_editor) {
785
+			global $xoopsModuleConfig;
786
+			$form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
787
+		}
788
+
789
+		if ($editor) {
790
+			if (defined('XOOPS_EDITOR_IS_HTML')
791
+				&& !in_array($form_editor, ['formtextarea', 'textarea', 'dhtmltextarea'])) {
792
+				$br       = false;
793
+				$formatML = !$editor;
794
+			} else {
795
+				return htmlspecialchars($ret, ENT_QUOTES);
796
+			}
797
+		}
798
+
799
+		if (method_exists($myts, 'formatForML')) {
800
+			return $myts->displayTarea($ret, $html, $smiley, $xcode, $image, $br, $formatML);
801
+		} else {
802
+			return $myts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
803
+		}
804
+	}
805
+
806
+	/**
807
+	 * clean values of all variables of the object for storage.
808
+	 * also add slashes whereever needed
809
+	 *
810
+	 * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
811
+	 * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
812
+	 * as a string separated by |
813
+	 *
814
+	 * @return bool true if successful
815
+	 * @access public
816
+	 */
817
+	public function cleanVars()
818
+	{
819
+		$ts              = MyTextSanitizer::getInstance();
820
+		$existing_errors = $this->getErrors();
821
+		$this->_errors   = [];
822
+		foreach ($this->vars as $k => $v) {
823
+			$cleanv = $v['value'];
824
+			if (!$v['changed']) {
825
+			} else {
826
+				$cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
827
+				switch ($v['data_type']) {
828
+					case XOBJ_DTYPE_TXTBOX:
829
+						if ($v['required'] && '0' != $cleanv && '' == $cleanv) {
830
+							$this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
831
+							continue 2;
832
+						}
833
+						if (isset($v['maxlength']) && strlen($cleanv) > (int)$v['maxlength']) {
834
+							$this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, (int)$v['maxlength']));
835
+							continue 2;
836
+						}
837
+						if (!$v['not_gpc']) {
838
+							$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
839
+						} else {
840
+							$cleanv = $ts->censorString($cleanv);
841
+						}
842
+						break;
843
+					case XOBJ_DTYPE_TXTAREA:
844
+						if ($v['required'] && '0' != $cleanv && '' == $cleanv) {
845
+							$this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
846
+							continue 2;
847
+						}
848
+						if (!$v['not_gpc']) {
849
+							$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
850
+						} else {
851
+							$cleanv = $ts->censorString($cleanv);
852
+						}
853
+						break;
854
+					case XOBJ_DTYPE_SOURCE:
855
+						if (!$v['not_gpc']) {
856
+							$cleanv = $ts->stripSlashesGPC($cleanv);
857
+						} else {
858
+							$cleanv = $cleanv;
859
+						}
860
+						break;
861
+					case XOBJ_DTYPE_INT:
862
+					case XOBJ_DTYPE_TIME_ONLY:
863
+						$cleanv = (int)$cleanv;
864
+						break;
865
+
866
+					case XOBJ_DTYPE_CURRENCY:
867
+						$cleanv = smart_currency($cleanv);
868
+						break;
869
+
870
+					case XOBJ_DTYPE_FLOAT:
871
+						$cleanv = smart_float($cleanv);
872
+						break;
873
+
874
+					case XOBJ_DTYPE_EMAIL:
875
+						if ($v['required'] && '' === $cleanv) {
876
+							$this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
877
+							continue 2;
878
+						}
879
+						if ('' !== $cleanv
880
+							&& !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $cleanv)) {
881
+							$this->setErrors('Invalid Email');
882
+							continue 2;
883
+						}
884
+						if (!$v['not_gpc']) {
885
+							$cleanv = $ts->stripSlashesGPC($cleanv);
886
+						}
887
+						break;
888
+					case XOBJ_DTYPE_URL:
889
+						if ($v['required'] && '' === $cleanv) {
890
+							$this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
891
+							continue 2;
892
+						}
893
+						if ('' !== $cleanv && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
894
+							$cleanv = 'http://' . $cleanv;
895
+						}
896
+						if (!$v['not_gpc']) {
897
+							$cleanv =& $ts->stripSlashesGPC($cleanv);
898
+						}
899
+						break;
900
+					case XOBJ_DTYPE_SIMPLE_ARRAY:
901
+						$cleanv = implode('|', $cleanv);
902
+						break;
903
+					case XOBJ_DTYPE_ARRAY:
904
+						$cleanv = serialize($cleanv);
905
+						break;
906
+					case XOBJ_DTYPE_STIME:
907
+					case XOBJ_DTYPE_MTIME:
908
+					case XOBJ_DTYPE_LTIME:
909
+						$cleanv = !is_string($cleanv) ? (int)$cleanv : strtotime($cleanv);
910
+						if (!($cleanv > 0)) {
911
+							$cleanv = strtotime($cleanv);
912
+						}
913
+						break;
914
+					default:
915
+						break;
916
+				}
917
+			}
918
+			$this->cleanVars[$k] =& $cleanv;
919
+			unset($cleanv);
920
+		}
921
+		if (count($this->_errors) > 0) {
922
+			$this->_errors = array_merge($existing_errors, $this->_errors);
923
+
924
+			return false;
925
+		}
926
+		$this->_errors = array_merge($existing_errors, $this->_errors);
927
+		$this->unsetDirty();
928
+
929
+		return true;
930
+	}
931
+
932
+	/**
933
+	 * returns a specific variable for the object in a proper format
934
+	 *
935
+	 * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
936
+	 * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
937
+	 * as a string separated by |
938
+	 *
939
+	 * @access public
940
+	 * @param  string $key    key of the object's variable to be returned
941
+	 * @param  string $format format to use for the output
942
+	 * @return mixed  formatted value of the variable
943
+	 */
944
+	public function getVar($key, $format = 's')
945
+	{
946
+		global $myts;
947
+
948
+		$ret = $this->vars[$key]['value'];
949
+
950
+		switch ($this->vars[$key]['data_type']) {
951
+
952
+			case XOBJ_DTYPE_TXTBOX:
953
+				switch (strtolower($format)) {
954
+					case 's':
955
+					case 'show':
956
+						// ML Hack by marcan
957
+						$ts  = MyTextSanitizer::getInstance();
958
+						$ret = $ts->htmlSpecialChars($ret);
959
+
960
+						if (method_exists($myts, 'formatForML')) {
961
+							return $ts->formatForML($ret);
962
+						} else {
963
+							return $ret;
964
+						}
965
+						break 1;
966
+					// End of ML Hack by marcan
967
+
968
+					case 'clean':
969
+						$ts = MyTextSanitizer::getInstance();
970
+
971
+						$ret = smart_html2text($ret);
972
+						$ret = smart_purifyText($ret);
973
+
974
+						if (method_exists($myts, 'formatForML')) {
975
+							return $ts->formatForML($ret);
976
+						} else {
977
+							return $ret;
978
+						}
979
+						break 1;
980
+					// End of ML Hack by marcan
981
+
982
+					case 'e':
983
+					case 'edit':
984
+						$ts = MyTextSanitizer::getInstance();
985
+
986
+						return $ts->htmlSpecialChars($ret);
987
+						break 1;
988
+					case 'p':
989
+					case 'preview':
990
+					case 'f':
991
+					case 'formpreview':
992
+						$ts = MyTextSanitizer::getInstance();
993
+
994
+						return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
995
+						break 1;
996
+					case 'n':
997
+					case 'none':
998
+					default:
999
+						break 1;
1000
+				}
1001
+				break;
1002
+			case XOBJ_DTYPE_LTIME:
1003
+				switch (strtolower($format)) {
1004
+					case 's':
1005
+					case 'show':
1006
+					case 'p':
1007
+					case 'preview':
1008
+					case 'f':
1009
+					case 'formpreview':
1010
+						$ret = formatTimestamp($ret, _DATESTRING);
1011
+
1012
+						return $ret;
1013
+						break 1;
1014
+					case 'n':
1015
+					case 'none':
1016
+					case 'e':
1017
+					case 'edit':
1018
+						break 1;
1019
+					default:
1020
+						break 1;
1021
+				}
1022
+				break;
1023
+			case XOBJ_DTYPE_STIME:
1024
+				switch (strtolower($format)) {
1025
+					case 's':
1026
+					case 'show':
1027
+					case 'p':
1028
+					case 'preview':
1029
+					case 'f':
1030
+					case 'formpreview':
1031
+						$ret = formatTimestamp($ret, _SHORTDATESTRING);
1032
+
1033
+						return $ret;
1034
+						break 1;
1035
+					case 'n':
1036
+					case 'none':
1037
+					case 'e':
1038
+					case 'edit':
1039
+						break 1;
1040
+					default:
1041
+						break 1;
1042
+				}
1043
+				break;
1044
+			case XOBJ_DTYPE_TIME_ONLY:
1045
+				switch (strtolower($format)) {
1046
+					case 's':
1047
+					case 'show':
1048
+					case 'p':
1049
+					case 'preview':
1050
+					case 'f':
1051
+					case 'formpreview':
1052
+						$ret = formatTimestamp($ret, 'G:i');
1053
+
1054
+						return $ret;
1055
+						break 1;
1056
+					case 'n':
1057
+					case 'none':
1058
+					case 'e':
1059
+					case 'edit':
1060
+						break 1;
1061
+					default:
1062
+						break 1;
1063
+				}
1064
+				break;
1065
+
1066
+			case XOBJ_DTYPE_CURRENCY:
1067
+				$decimal_section_original = strstr($ret, '.');
1068
+				$decimal_section          = $decimal_section_original;
1069
+				if ($decimal_section) {
1070
+					if (1 == strlen($decimal_section)) {
1071
+						$decimal_section = '.00';
1072
+					} elseif (2 == strlen($decimal_section)) {
1073
+						$decimal_section .= '0';
1074
+					}
1075
+					$ret = str_replace($decimal_section_original, $decimal_section, $ret);
1076
+				} else {
1077
+					$ret .= '.00';
1078
+				}
1079
+				break;
1080
+
1081
+			case XOBJ_DTYPE_TXTAREA:
1082
+				switch (strtolower($format)) {
1083
+					case 's':
1084
+					case 'show':
1085
+						$ts   = MyTextSanitizer::getInstance();
1086
+						$html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
1087
+
1088
+						$xcode = (!isset($this->vars['doxcode']['value'])
1089
+								  || 1 == $this->vars['doxcode']['value']) ? 1 : 0;
1090
+
1091
+						$smiley = (!isset($this->vars['dosmiley']['value'])
1092
+								   || 1 == $this->vars['dosmiley']['value']) ? 1 : 0;
1093
+						$image  = (!isset($this->vars['doimage']['value'])
1094
+								   || 1 == $this->vars['doimage']['value']) ? 1 : 0;
1095
+						$br     = (!isset($this->vars['dobr']['value']) || 1 == $this->vars['dobr']['value']) ? 1 : 0;
1096
+
1097
+						/**
1098
+						 * Hack by marcan <INBOX> for SCSPRO
1099
+						 * Setting mastop as the main editor
1100
+						 */
1101
+						if (defined('XOOPS_EDITOR_IS_HTML')) {
1102
+							$br = false;
1103
+						}
1104
+
1105
+						/**
1106
+						 * Hack by marcan <INBOX> for SCSPRO
1107
+						 * Setting mastop as the main editor
1108
+						 */
1109
+
1110
+						return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
1111
+						break 1;
1112
+					case 'e':
1113
+					case 'edit':
1114
+						return htmlspecialchars($ret, ENT_QUOTES);
1115
+						break 1;
1116
+					case 'p':
1117
+					case 'preview':
1118
+						$ts     = MyTextSanitizer::getInstance();
1119
+						$html   = !empty($this->vars['dohtml']['value']) ? 1 : 0;
1120
+						$xcode  = (!isset($this->vars['doxcode']['value'])
1121
+								   || 1 == $this->vars['doxcode']['value']) ? 1 : 0;
1122
+						$smiley = (!isset($this->vars['dosmiley']['value'])
1123
+								   || 1 == $this->vars['dosmiley']['value']) ? 1 : 0;
1124
+						$image  = (!isset($this->vars['doimage']['value'])
1125
+								   || 1 == $this->vars['doimage']['value']) ? 1 : 0;
1126
+						$br     = (!isset($this->vars['dobr']['value']) || 1 == $this->vars['dobr']['value']) ? 1 : 0;
1127
+
1128
+						return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
1129
+						break 1;
1130
+					case 'f':
1131
+					case 'formpreview':
1132
+						$ts = MyTextSanitizer::getInstance();
1133
+
1134
+						return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
1135
+						break 1;
1136
+					case 'n':
1137
+					case 'none':
1138
+					default:
1139
+						break 1;
1140
+				}
1141
+				break;
1142
+			case XOBJ_DTYPE_SIMPLE_ARRAY:
1143
+				$ret =& explode('|', $ret);
1144
+				break;
1145
+			case XOBJ_DTYPE_ARRAY:
1146
+				$ret =& unserialize($ret);
1147
+				break;
1148
+			case XOBJ_DTYPE_SOURCE:
1149
+				switch (strtolower($format)) {
1150
+					case 's':
1151
+					case 'show':
1152
+						break 1;
1153
+					case 'e':
1154
+					case 'edit':
1155
+						return htmlspecialchars($ret, ENT_QUOTES);
1156
+						break 1;
1157
+					case 'p':
1158
+					case 'preview':
1159
+						$ts = MyTextSanitizer::getInstance();
1160
+
1161
+						return $ts->stripSlashesGPC($ret);
1162
+						break 1;
1163
+					case 'f':
1164
+					case 'formpreview':
1165
+						$ts = MyTextSanitizer::getInstance();
1166
+
1167
+						return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
1168
+						break 1;
1169
+					case 'n':
1170
+					case 'none':
1171
+					default:
1172
+						break 1;
1173
+				}
1174
+				break;
1175
+			default:
1176
+				if ('' !== $this->vars[$key]['options'] && '' != $ret) {
1177
+					switch (strtolower($format)) {
1178
+						case 's':
1179
+						case 'show':
1180
+							$selected = explode('|', $ret);
1181
+							$options  = explode('|', $this->vars[$key]['options']);
1182
+							$i        = 1;
1183
+							$ret      = [];
1184
+							foreach ($options as $op) {
1185
+								if (in_array($i, $selected)) {
1186
+									$ret[] = $op;
1187
+								}
1188
+								++$i;
1189
+							}
1190
+
1191
+							return implode(', ', $ret);
1192
+						case 'e':
1193
+						case 'edit':
1194
+							$ret = explode('|', $ret);
1195
+							break 1;
1196
+						default:
1197
+							break 1;
1198
+					}
1199
+				}
1200
+				break;
1201
+		}
1202
+
1203
+		return $ret;
1204
+	}
1205
+
1206
+	/**
1207
+	 * @param $key
1208
+	 */
1209
+	public function doMakeFieldreadOnly($key)
1210
+	{
1211
+		if (isset($this->vars[$key])) {
1212
+			$this->vars[$key]['readonly']      = true;
1213
+			$this->vars[$key]['displayOnForm'] = true;
1214
+		}
1215
+	}
1216
+
1217
+	/**
1218
+	 * @param $key
1219
+	 */
1220
+	public function makeFieldReadOnly($key)
1221
+	{
1222
+		if (is_array($key)) {
1223
+			foreach ($key as $v) {
1224
+				$this->doMakeFieldreadOnly($v);
1225
+			}
1226
+		} else {
1227
+			$this->doMakeFieldreadOnly($key);
1228
+		}
1229
+	}
1230
+
1231
+	/**
1232
+	 * @param $key
1233
+	 */
1234
+	public function doHideFieldFromForm($key)
1235
+	{
1236
+		if (isset($this->vars[$key])) {
1237
+			$this->vars[$key]['displayOnForm'] = false;
1238
+		}
1239
+	}
1240
+
1241
+	/**
1242
+	 * @param $key
1243
+	 */
1244
+	public function doHideFieldFromSingleView($key)
1245
+	{
1246
+		if (isset($this->vars[$key])) {
1247
+			$this->vars[$key]['displayOnSingleView'] = false;
1248
+		}
1249
+	}
1250
+
1251
+	/**
1252
+	 * @param $key
1253
+	 */
1254
+	public function hideFieldFromForm($key)
1255
+	{
1256
+		if (is_array($key)) {
1257
+			foreach ($key as $v) {
1258
+				$this->doHideFieldFromForm($v);
1259
+			}
1260
+		} else {
1261
+			$this->doHideFieldFromForm($key);
1262
+		}
1263
+	}
1264
+
1265
+	/**
1266
+	 * @param $key
1267
+	 */
1268
+	public function hideFieldFromSingleView($key)
1269
+	{
1270
+		if (is_array($key)) {
1271
+			foreach ($key as $v) {
1272
+				$this->doHideFieldFromSingleView($v);
1273
+			}
1274
+		} else {
1275
+			$this->doHideFieldFromSingleView($key);
1276
+		}
1277
+	}
1278
+
1279
+	/**
1280
+	 * @param $key
1281
+	 */
1282
+	public function doShowFieldOnForm($key)
1283
+	{
1284
+		if (isset($this->vars[$key])) {
1285
+			$this->vars[$key]['displayOnForm'] = true;
1286
+		}
1287
+	}
1288
+
1289
+	/**
1290
+	 * Display an automatic SingleView of the object, based on the displayOnSingleView param of each vars
1291
+	 *
1292
+	 * @param  bool  $fetchOnly if set to TRUE, then the content will be return, if set to FALSE, the content will be outputed
1293
+	 * @param  bool  $userSide  for futur use, to do something different on the user side
1294
+	 * @param  array $actions
1295
+	 * @param  bool  $headerAsRow
1296
+	 * @return content of the template if $fetchOnly or nothing if !$fetchOnly
1297
+	 */
1298
+	public function displaySingleObject(
1299
+		$fetchOnly = false,
1300
+		$userSide = false,
1301
+		$actions = [],
1302
+		$headerAsRow = true
1303
+	) {
1304
+		require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectsingleview.php';
1305
+		$singleview = new SmartObjectSingleView($this, $userSide, $actions, $headerAsRow);
1306
+		// add all fields mark as displayOnSingleView except the keyid
1307
+		foreach ($this->vars as $key => $var) {
1308
+			if ($key != $this->handler->keyName && $var['displayOnSingleView']) {
1309
+				$is_header = ($key == $this->handler->identifierName);
1310
+				$singleview->addRow(new SmartObjectRow($key, false, $is_header));
1311
+			}
1312
+		}
1313
+
1314
+		if ($fetchOnly) {
1315
+			$ret = $singleview->render($fetchOnly);
1316
+
1317
+			return $ret;
1318
+		} else {
1319
+			$singleview->render($fetchOnly);
1320
+		}
1321
+	}
1322
+
1323
+	/**
1324
+	 * @param $key
1325
+	 */
1326
+	public function doDisplayFieldOnSingleView($key)
1327
+	{
1328
+		if (isset($this->vars[$key])) {
1329
+			$this->vars[$key]['displayOnSingleView'] = true;
1330
+		}
1331
+	}
1332
+
1333
+	/**
1334
+	 * @param      $field
1335
+	 * @param bool $required
1336
+	 */
1337
+	public function doSetFieldAsRequired($field, $required = true)
1338
+	{
1339
+		$this->setVarInfo($field, 'required', $required);
1340
+	}
1341
+
1342
+	/**
1343
+	 * @param $field
1344
+	 */
1345
+	public function doSetFieldForSorting($field)
1346
+	{
1347
+		$this->setVarInfo($field, 'sortby', true);
1348
+	}
1349
+
1350
+	/**
1351
+	 * @param $key
1352
+	 */
1353
+	public function showFieldOnForm($key)
1354
+	{
1355
+		if (is_array($key)) {
1356
+			foreach ($key as $v) {
1357
+				$this->doShowFieldOnForm($v);
1358
+			}
1359
+		} else {
1360
+			$this->doShowFieldOnForm($key);
1361
+		}
1362
+	}
1363
+
1364
+	/**
1365
+	 * @param $key
1366
+	 */
1367
+	public function displayFieldOnSingleView($key)
1368
+	{
1369
+		if (is_array($key)) {
1370
+			foreach ($key as $v) {
1371
+				$this->doDisplayFieldOnSingleView($v);
1372
+			}
1373
+		} else {
1374
+			$this->doDisplayFieldOnSingleView($key);
1375
+		}
1376
+	}
1377
+
1378
+	/**
1379
+	 * @param $key
1380
+	 */
1381
+	public function doSetAdvancedFormFields($key)
1382
+	{
1383
+		if (isset($this->vars[$key])) {
1384
+			$this->vars[$key]['advancedform'] = true;
1385
+		}
1386
+	}
1387
+
1388
+	/**
1389
+	 * @param $key
1390
+	 */
1391
+	public function setAdvancedFormFields($key)
1392
+	{
1393
+		if (is_array($key)) {
1394
+			foreach ($key as $v) {
1395
+				$this->doSetAdvancedFormFields($v);
1396
+			}
1397
+		} else {
1398
+			$this->doSetAdvancedFormFields($key);
1399
+		}
1400
+	}
1401
+
1402
+	/**
1403
+	 * @param $key
1404
+	 * @return mixed
1405
+	 */
1406
+	public function getUrlLinkObj($key)
1407
+	{
1408
+		$smartobjectLinkurlHandler = xoops_getModuleHandler('urllink', 'smartobject');
1409
+		$urllinkid                 = null !== $this->getVar($key) ? $this->getVar($key) : 0;
1410
+		if (0 != $urllinkid) {
1411
+			return $smartobjectLinkurlHandler->get($urllinkid);
1412
+		} else {
1413
+			return $smartobjectLinkurlHandler->create();
1414
+		}
1415
+	}
1416
+
1417
+	/**
1418
+	 * @param $urlLinkObj
1419
+	 * @return mixed
1420
+	 */
1421
+	public function &storeUrlLinkObj($urlLinkObj)
1422
+	{
1423
+		$smartobjectLinkurlHandler = xoops_getModuleHandler('urllink', 'smartobject');
1424
+
1425
+		return $smartobjectLinkurlHandler->insert($urlLinkObj);
1426
+	}
1427
+
1428
+	/**
1429
+	 * @param $key
1430
+	 * @return mixed
1431
+	 */
1432
+	public function getFileObj($key)
1433
+	{
1434
+		$smartobjectFileHandler = xoops_getModuleHandler('file', 'smartobject');
1435
+		$fileid                 = null !== $this->getVar($key) ? $this->getVar($key) : 0;
1436
+		if (0 != $fileid) {
1437
+			return $smartobjectFileHandler->get($fileid);
1438
+		} else {
1439
+			return $smartobjectFileHandler->create();
1440
+		}
1441
+	}
1442
+
1443
+	/**
1444
+	 * @param $fileObj
1445
+	 * @return mixed
1446
+	 */
1447
+	public function &storeFileObj($fileObj)
1448
+	{
1449
+		$smartobjectFileHandler = xoops_getModuleHandler('file', 'smartobject');
1450
+
1451
+		return $smartobjectFileHandler->insert($fileObj);
1452
+	}
1453 1453
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
14 14
 
15
-require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
15
+require_once XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php';
16 16
 
17
-require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
17
+require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectcontroller.php';
18 18
 
19 19
 if (!defined('XOBJ_DTYPE_SIMPLE_ARRAY')) {
20 20
     define('XOBJ_DTYPE_SIMPLE_ARRAY', 101);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function closeSection($section_name)
115 115
     {
116
-        $this->initVar('close_section_' . $section_name, XOBJ_DTYPE_FORM_SECTION_CLOSE, '', false, null, '', false, '', '', false, false, true);
116
+        $this->initVar('close_section_'.$section_name, XOBJ_DTYPE_FORM_SECTION_CLOSE, '', false, null, '', false, '', '', false, false, true);
117 117
     }
118 118
 
119 119
     /**
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         }
152 152
         parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
153 153
         if ($this->handler && (!$form_caption || '' === $form_caption)) {
154
-            $dyn_form_caption = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key);
154
+            $dyn_form_caption = strtoupper('_CO_'.$this->handler->_moduleName.'_'.$this->handler->_itemname.'_'.$key);
155 155
             if (defined($dyn_form_caption)) {
156 156
                 $form_caption = constant($dyn_form_caption);
157 157
             }
158 158
         }
159 159
         if ($this->handler && (!$form_dsc || '' === $form_dsc)) {
160
-            $dyn_form_dsc = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key . '_DSC');
160
+            $dyn_form_dsc = strtoupper('_CO_'.$this->handler->_moduleName.'_'.$this->handler->_itemname.'_'.$key.'_DSC');
161 161
             if (defined($dyn_form_dsc)) {
162 162
                 $form_dsc = constant($dyn_form_dsc);
163 163
             }
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         $cancel_js_action = false,
442 442
         $captcha = false
443 443
     ) {
444
-        require_once SMARTOBJECT_ROOT_PATH . 'class/form/smartobjectform.php';
444
+        require_once SMARTOBJECT_ROOT_PATH.'class/form/smartobjectform.php';
445 445
         $form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
446 446
 
447 447
         return $form;
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     public function toArray()
454 454
     {
455 455
         $ret  = [];
456
-        $vars =& $this->getVars();
456
+        $vars = & $this->getVars();
457 457
         foreach ($vars as $key => $var) {
458 458
             $value     = $this->getVar($key);
459 459
             $ret[$key] = $value;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         }
472 472
 
473 473
         // Hightlighting searched words
474
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smarthighlighter.php';
474
+        require_once SMARTOBJECT_ROOT_PATH.'class/smarthighlighter.php';
475 475
         $highlight = smart_getConfig('module_search_highlighter', false, true);
476 476
 
477 477
         if ($highlight && isset($_GET['keywords'])) {
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
             }
503 503
         } else {
504 504
             if ($prefix) {
505
-                $err_str = '[' . $prefix . '] ' . $err_str;
505
+                $err_str = '['.$prefix.'] '.$err_str;
506 506
             }
507 507
             parent::setErrors($err_str);
508 508
         }
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
                             $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
831 831
                             continue 2;
832 832
                         }
833
-                        if (isset($v['maxlength']) && strlen($cleanv) > (int)$v['maxlength']) {
834
-                            $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, (int)$v['maxlength']));
833
+                        if (isset($v['maxlength']) && strlen($cleanv) > (int) $v['maxlength']) {
834
+                            $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, (int) $v['maxlength']));
835 835
                             continue 2;
836 836
                         }
837 837
                         if (!$v['not_gpc']) {
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
                         break;
861 861
                     case XOBJ_DTYPE_INT:
862 862
                     case XOBJ_DTYPE_TIME_ONLY:
863
-                        $cleanv = (int)$cleanv;
863
+                        $cleanv = (int) $cleanv;
864 864
                         break;
865 865
 
866 866
                     case XOBJ_DTYPE_CURRENCY:
@@ -891,10 +891,10 @@  discard block
 block discarded – undo
891 891
                             continue 2;
892 892
                         }
893 893
                         if ('' !== $cleanv && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
894
-                            $cleanv = 'http://' . $cleanv;
894
+                            $cleanv = 'http://'.$cleanv;
895 895
                         }
896 896
                         if (!$v['not_gpc']) {
897
-                            $cleanv =& $ts->stripSlashesGPC($cleanv);
897
+                            $cleanv = & $ts->stripSlashesGPC($cleanv);
898 898
                         }
899 899
                         break;
900 900
                     case XOBJ_DTYPE_SIMPLE_ARRAY:
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
                     case XOBJ_DTYPE_STIME:
907 907
                     case XOBJ_DTYPE_MTIME:
908 908
                     case XOBJ_DTYPE_LTIME:
909
-                        $cleanv = !is_string($cleanv) ? (int)$cleanv : strtotime($cleanv);
909
+                        $cleanv = !is_string($cleanv) ? (int) $cleanv : strtotime($cleanv);
910 910
                         if (!($cleanv > 0)) {
911 911
                             $cleanv = strtotime($cleanv);
912 912
                         }
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
                         break;
916 916
                 }
917 917
             }
918
-            $this->cleanVars[$k] =& $cleanv;
918
+            $this->cleanVars[$k] = & $cleanv;
919 919
             unset($cleanv);
920 920
         }
921 921
         if (count($this->_errors) > 0) {
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
                 }
1141 1141
                 break;
1142 1142
             case XOBJ_DTYPE_SIMPLE_ARRAY:
1143
-                $ret =& explode('|', $ret);
1143
+                $ret = & explode('|', $ret);
1144 1144
                 break;
1145 1145
             case XOBJ_DTYPE_ARRAY:
1146
-                $ret =& unserialize($ret);
1146
+                $ret = & unserialize($ret);
1147 1147
                 break;
1148 1148
             case XOBJ_DTYPE_SOURCE:
1149 1149
                 switch (strtolower($format)) {
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
         $actions = [],
1302 1302
         $headerAsRow = true
1303 1303
     ) {
1304
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectsingleview.php';
1304
+        require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectsingleview.php';
1305 1305
         $singleview = new SmartObjectSingleView($this, $userSide, $actions, $headerAsRow);
1306 1306
         // add all fields mark as displayOnSingleView except the keyid
1307 1307
         foreach ($this->vars as $key => $var) {
Please login to merge, or discard this patch.
class/customtag.php 1 patch
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -36,227 +36,227 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class SmartobjectCustomtag extends SmartObject
38 38
 {
39
-    public $content = false;
40
-
41
-    /**
42
-     * SmartobjectCustomtag constructor.
43
-     */
44
-    public function __construct()
45
-    {
46
-        $this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true);
47
-        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC);
48
-        $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC);
49
-        $this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC);
50
-        $this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC);
51
-
52
-        $this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true);
53
-        $this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true);
54
-        $this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true);
55
-        $this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true);
56
-
57
-        $this->setControl('content', [
58
-            'name'        => 'textarea',
59
-            'form_editor' => 'textarea',
60
-            'form_rows'   => 25
61
-        ]);
62
-        $this->setControl('language', [
63
-            'name' => 'language',
64
-            'all'  => true
65
-        ]);
66
-    }
67
-
68
-    /**
69
-     * @param  string $key
70
-     * @param  string $format
71
-     * @return mixed
72
-     */
73
-    public function getVar($key, $format = 's')
74
-    {
75
-        if ('s' === $format && in_array($key, [])) {
76
-            //            return call_user_func(array($this, $key));
77
-            return $this->{$key}();
78
-        }
79
-
80
-        return parent::getVar($key, $format);
81
-    }
82
-
83
-    /**
84
-     * @return bool|mixed
85
-     */
86
-    public function render()
87
-    {
88
-        if (!$this->content) {
89
-            $ret           = $this->getVar('content');
90
-            $this->content = $ret;
91
-        }
92
-
93
-        return $this->content;
94
-    }
95
-
96
-    /**
97
-     * @return bool|mixed|string
98
-     */
99
-    public function renderWithPhp()
100
-    {
101
-        if (!$this->content) {
102
-            $ret           = $this->getVar('content');
103
-            $this->content = $ret;
104
-        } else {
105
-            $ret = $this->content;
106
-        }
107
-
108
-        // check for PHP if we are not on admin side
109
-        if (!defined('XOOPS_CPFUNC_LOADED') && !(false === strpos($ret, '[php]'))) {
110
-            $ret = str_replace('[php]', '', $ret);
111
-            // we have PHP code, let's evaluate
112
-            eval($ret);
113
-
114
-            return '';
115
-        }
116
-
117
-        return $this->content;
118
-    }
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function getXoopsCode()
124
-    {
125
-        $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]';
126
-
127
-        return $ret;
128
-    }
129
-
130
-    /**
131
-     * @return string
132
-     */
133
-    public function getCloneLink()
134
-    {
135
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>';
136
-
137
-        return $ret;
138
-    }
139
-
140
-    /**
141
-     * @param $var
142
-     * @return bool
143
-     */
144
-    public function emptyString($var)
145
-    {
146
-        return (strlen($var) > 0);
147
-    }
148
-
149
-    /**
150
-     * @return mixed|string
151
-     */
152
-    public function generateTag()
153
-    {
154
-        $title = rawurlencode(strtolower($this->getVar('description', 'e')));
155
-        $title = xoops_substr($title, 0, 10, '');
156
-        // Transformation des ponctuations
157
-        $pattern = [
158
-            '/%09/', // Tab
159
-            '/%20/', // Space
160
-            '/%21/', // !
161
-            '/%22/', // "
162
-            '/%23/', // #
163
-            '/%25/', // %
164
-            '/%26/', // &
165
-            '/%27/', // '
166
-            '/%28/', // (
167
-            '/%29/', // )
168
-            '/%2C/', // ,
169
-            '/%2F/', // /
170
-            '/%3A/', // :
171
-            '/%3B/', // ;
172
-            '/%3C/', // <
173
-            '/%3D/', // =
174
-            '/%3E/', // >
175
-            '/%3F/', // ?
176
-            '/%40/', // @
177
-            '/%5B/', // [
178
-            '/%5C/', // \
179
-            '/%5D/', // ]
180
-            '/%5E/', // ^
181
-            '/%7B/', // {
182
-            '/%7C/', // |
183
-            '/%7D/', // }
184
-            '/%7E/', // ~
185
-            "/\./" // .
186
-        ];
187
-        $rep_pat = [
188
-            '-',
189
-            '-',
190
-            '-',
191
-            '-',
192
-            '-',
193
-            '-100',
194
-            '-',
195
-            '-',
196
-            '-',
197
-            '-',
198
-            '-',
199
-            '-',
200
-            '-',
201
-            '-',
202
-            '-',
203
-            '-',
204
-            '-',
205
-            '-',
206
-            '-at-',
207
-            '-',
208
-            '-',
209
-            '-',
210
-            '-',
211
-            '-',
212
-            '-',
213
-            '-',
214
-            '-',
215
-            '-'
216
-        ];
217
-        $title   = preg_replace($pattern, $rep_pat, $title);
218
-
219
-        // Transformation des caractères accentués
220
-        $pattern = [
221
-            '/%B0/', // °
222
-            '/%E8/', // è
223
-            '/%E9/', // é
224
-            '/%EA/', // ê
225
-            '/%EB/', // ë
226
-            '/%E7/', // ç
227
-            '/%E0/', // à
228
-            '/%E2/', // â
229
-            '/%E4/', // ä
230
-            '/%EE/', // î
231
-            '/%EF/', // ï
232
-            '/%F9/', // ù
233
-            '/%FC/', // ü
234
-            '/%FB/', // û
235
-            '/%F4/', // ô
236
-            '/%F6/', // ö
237
-        ];
238
-        $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
239
-        $title   = preg_replace($pattern, $rep_pat, $title);
240
-
241
-        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
242
-        $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
243
-        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
244
-
245
-        $title .= time();
246
-        $title = md5($title);
247
-
248
-        return $title;
249
-    }
250
-
251
-    /**
252
-     * @return mixed
253
-     */
254
-    public function getCustomtagName()
255
-    {
256
-        $ret = $this->getVar('name');
257
-
258
-        return $ret;
259
-    }
39
+	public $content = false;
40
+
41
+	/**
42
+	 * SmartobjectCustomtag constructor.
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true);
47
+		$this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC);
48
+		$this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC);
49
+		$this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC);
50
+		$this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC);
51
+
52
+		$this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true);
53
+		$this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true);
54
+		$this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true);
55
+		$this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true);
56
+
57
+		$this->setControl('content', [
58
+			'name'        => 'textarea',
59
+			'form_editor' => 'textarea',
60
+			'form_rows'   => 25
61
+		]);
62
+		$this->setControl('language', [
63
+			'name' => 'language',
64
+			'all'  => true
65
+		]);
66
+	}
67
+
68
+	/**
69
+	 * @param  string $key
70
+	 * @param  string $format
71
+	 * @return mixed
72
+	 */
73
+	public function getVar($key, $format = 's')
74
+	{
75
+		if ('s' === $format && in_array($key, [])) {
76
+			//            return call_user_func(array($this, $key));
77
+			return $this->{$key}();
78
+		}
79
+
80
+		return parent::getVar($key, $format);
81
+	}
82
+
83
+	/**
84
+	 * @return bool|mixed
85
+	 */
86
+	public function render()
87
+	{
88
+		if (!$this->content) {
89
+			$ret           = $this->getVar('content');
90
+			$this->content = $ret;
91
+		}
92
+
93
+		return $this->content;
94
+	}
95
+
96
+	/**
97
+	 * @return bool|mixed|string
98
+	 */
99
+	public function renderWithPhp()
100
+	{
101
+		if (!$this->content) {
102
+			$ret           = $this->getVar('content');
103
+			$this->content = $ret;
104
+		} else {
105
+			$ret = $this->content;
106
+		}
107
+
108
+		// check for PHP if we are not on admin side
109
+		if (!defined('XOOPS_CPFUNC_LOADED') && !(false === strpos($ret, '[php]'))) {
110
+			$ret = str_replace('[php]', '', $ret);
111
+			// we have PHP code, let's evaluate
112
+			eval($ret);
113
+
114
+			return '';
115
+		}
116
+
117
+		return $this->content;
118
+	}
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function getXoopsCode()
124
+	{
125
+		$ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]';
126
+
127
+		return $ret;
128
+	}
129
+
130
+	/**
131
+	 * @return string
132
+	 */
133
+	public function getCloneLink()
134
+	{
135
+		$ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>';
136
+
137
+		return $ret;
138
+	}
139
+
140
+	/**
141
+	 * @param $var
142
+	 * @return bool
143
+	 */
144
+	public function emptyString($var)
145
+	{
146
+		return (strlen($var) > 0);
147
+	}
148
+
149
+	/**
150
+	 * @return mixed|string
151
+	 */
152
+	public function generateTag()
153
+	{
154
+		$title = rawurlencode(strtolower($this->getVar('description', 'e')));
155
+		$title = xoops_substr($title, 0, 10, '');
156
+		// Transformation des ponctuations
157
+		$pattern = [
158
+			'/%09/', // Tab
159
+			'/%20/', // Space
160
+			'/%21/', // !
161
+			'/%22/', // "
162
+			'/%23/', // #
163
+			'/%25/', // %
164
+			'/%26/', // &
165
+			'/%27/', // '
166
+			'/%28/', // (
167
+			'/%29/', // )
168
+			'/%2C/', // ,
169
+			'/%2F/', // /
170
+			'/%3A/', // :
171
+			'/%3B/', // ;
172
+			'/%3C/', // <
173
+			'/%3D/', // =
174
+			'/%3E/', // >
175
+			'/%3F/', // ?
176
+			'/%40/', // @
177
+			'/%5B/', // [
178
+			'/%5C/', // \
179
+			'/%5D/', // ]
180
+			'/%5E/', // ^
181
+			'/%7B/', // {
182
+			'/%7C/', // |
183
+			'/%7D/', // }
184
+			'/%7E/', // ~
185
+			"/\./" // .
186
+		];
187
+		$rep_pat = [
188
+			'-',
189
+			'-',
190
+			'-',
191
+			'-',
192
+			'-',
193
+			'-100',
194
+			'-',
195
+			'-',
196
+			'-',
197
+			'-',
198
+			'-',
199
+			'-',
200
+			'-',
201
+			'-',
202
+			'-',
203
+			'-',
204
+			'-',
205
+			'-',
206
+			'-at-',
207
+			'-',
208
+			'-',
209
+			'-',
210
+			'-',
211
+			'-',
212
+			'-',
213
+			'-',
214
+			'-',
215
+			'-'
216
+		];
217
+		$title   = preg_replace($pattern, $rep_pat, $title);
218
+
219
+		// Transformation des caractères accentués
220
+		$pattern = [
221
+			'/%B0/', // °
222
+			'/%E8/', // è
223
+			'/%E9/', // é
224
+			'/%EA/', // ê
225
+			'/%EB/', // ë
226
+			'/%E7/', // ç
227
+			'/%E0/', // à
228
+			'/%E2/', // â
229
+			'/%E4/', // ä
230
+			'/%EE/', // î
231
+			'/%EF/', // ï
232
+			'/%F9/', // ù
233
+			'/%FC/', // ü
234
+			'/%FB/', // û
235
+			'/%F4/', // ô
236
+			'/%F6/', // ö
237
+		];
238
+		$rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
239
+		$title   = preg_replace($pattern, $rep_pat, $title);
240
+
241
+		$tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
242
+		$tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
243
+		$title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
244
+
245
+		$title .= time();
246
+		$title = md5($title);
247
+
248
+		return $title;
249
+	}
250
+
251
+	/**
252
+	 * @return mixed
253
+	 */
254
+	public function getCustomtagName()
255
+	{
256
+		$ret = $this->getVar('name');
257
+
258
+		return $ret;
259
+	}
260 260
 }
261 261
 
262 262
 /**
@@ -264,48 +264,48 @@  discard block
 block discarded – undo
264 264
  */
265 265
 class SmartobjectCustomtagHandler extends SmartPersistableObjectHandler
266 266
 {
267
-    public $objects = false;
268
-
269
-    /**
270
-     * SmartobjectCustomtagHandler constructor.
271
-     * @param XoopsDatabase $db
272
-     */
273
-    public function __construct(XoopsDatabase $db)
274
-    {
275
-        parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject');
276
-        $this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC);
277
-    }
278
-
279
-    /**
280
-     * @return array|bool
281
-     */
282
-    public function getCustomtagsByName()
283
-    {
284
-        if (!$this->objects) {
285
-            global $xoopsConfig;
286
-
287
-            $ret = [];
288
-
289
-            $criteria = new CriteriaCompo();
290
-
291
-            $criteria_language = new CriteriaCompo();
292
-            $criteria_language->add(new Criteria('language', $xoopsConfig['language']));
293
-            $criteria_language->add(new Criteria('language', 'all'), 'OR');
294
-            $criteria->add($criteria_language);
295
-
296
-            $smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this);
297
-            $granted_ids                   = $smartobjectPermissionsHandler->getGrantedItems('view');
298
-
299
-            if ($granted_ids && count($granted_ids) > 0) {
300
-                $criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN'));
301
-                $customtagsObj = $this->getObjects($criteria, true);
302
-                foreach ($customtagsObj as $customtagObj) {
303
-                    $ret[$customtagObj->getVar('name')] = $customtagObj;
304
-                }
305
-            }
306
-            $this->objects = $ret;
307
-        }
308
-
309
-        return $this->objects;
310
-    }
267
+	public $objects = false;
268
+
269
+	/**
270
+	 * SmartobjectCustomtagHandler constructor.
271
+	 * @param XoopsDatabase $db
272
+	 */
273
+	public function __construct(XoopsDatabase $db)
274
+	{
275
+		parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject');
276
+		$this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC);
277
+	}
278
+
279
+	/**
280
+	 * @return array|bool
281
+	 */
282
+	public function getCustomtagsByName()
283
+	{
284
+		if (!$this->objects) {
285
+			global $xoopsConfig;
286
+
287
+			$ret = [];
288
+
289
+			$criteria = new CriteriaCompo();
290
+
291
+			$criteria_language = new CriteriaCompo();
292
+			$criteria_language->add(new Criteria('language', $xoopsConfig['language']));
293
+			$criteria_language->add(new Criteria('language', 'all'), 'OR');
294
+			$criteria->add($criteria_language);
295
+
296
+			$smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this);
297
+			$granted_ids                   = $smartobjectPermissionsHandler->getGrantedItems('view');
298
+
299
+			if ($granted_ids && count($granted_ids) > 0) {
300
+				$criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN'));
301
+				$customtagsObj = $this->getObjects($criteria, true);
302
+				foreach ($customtagsObj as $customtagObj) {
303
+					$ret[$customtagObj->getVar('name')] = $customtagObj;
304
+				}
305
+			}
306
+			$this->objects = $ret;
307
+		}
308
+
309
+		return $this->objects;
310
+	}
311 311
 }
Please login to merge, or discard this patch.
class/smartobjectabout.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -19,165 +19,165 @@
 block discarded – undo
19 19
  */
20 20
 class SmartobjectAbout
21 21
 {
22
-    public $_lang_aboutTitle;
23
-    public $_lang_author_info;
24
-    public $_lang_developer_lead;
25
-    public $_lang_developer_contributor;
26
-    public $_lang_developer_website;
27
-    public $_lang_developer_email;
28
-    public $_lang_developer_credits;
29
-    public $_lang_module_info;
30
-    public $_lang_module_status;
31
-    public $_lang_module_release_date;
32
-    public $_lang_module_demo;
33
-    public $_lang_module_support;
34
-    public $_lang_module_bug;
35
-    public $_lang_module_submit_bug;
36
-    public $_lang_module_feature;
37
-    public $_lang_module_submit_feature;
38
-    public $_lang_module_disclaimer;
39
-    public $_lang_author_word;
40
-    public $_lang_version_history;
41
-    public $_lang_by;
42
-    public $_tpl;
43
-
44
-    /**
45
-     * SmartobjectAbout constructor.
46
-     * @param string $aboutTitle
47
-     */
48
-    public function __construct($aboutTitle = 'About')
49
-    {
50
-        global $xoopsModule, $xoopsConfig;
51
-
52
-        $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
53
-        if (file_exists($fileName)) {
54
-            require_once $fileName;
55
-        } else {
56
-            require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
57
-        }
58
-        $this->_aboutTitle = $aboutTitle;
59
-
60
-        $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR;
61
-        $this->_lang_developer_website     = _CO_SOBJECT_DEVELOPER_WEBSITE;
62
-        $this->_lang_developer_email       = _CO_SOBJECT_DEVELOPER_EMAIL;
63
-        $this->_lang_developer_credits     = _CO_SOBJECT_DEVELOPER_CREDITS;
64
-        $this->_lang_module_info           = _CO_SOBJECT_MODULE_INFO;
65
-        $this->_lang_module_status         = _CO_SOBJECT_MODULE_STATUS;
66
-        $this->_lang_module_release_date   = _CO_SOBJECT_MODULE_RELEASE_DATE;
67
-        $this->_lang_module_demo           = _CO_SOBJECT_MODULE_DEMO;
68
-        $this->_lang_module_support        = _CO_SOBJECT_MODULE_SUPPORT;
69
-        $this->_lang_module_bug            = _CO_SOBJECT_MODULE_BUG;
70
-        $this->_lang_module_submit_bug     = _CO_SOBJECT_MODULE_SUBMIT_BUG;
71
-        $this->_lang_module_feature        = _CO_SOBJECT_MODULE_FEATURE;
72
-        $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE;
73
-        $this->_lang_module_disclaimer     = _CO_SOBJECT_MODULE_DISCLAIMER;
74
-        $this->_lang_author_word           = _CO_SOBJECT_AUTHOR_WORD;
75
-        $this->_lang_version_history       = _CO_SOBJECT_VERSION_HISTORY;
76
-    }
77
-
78
-    /**
79
-     * @param $value
80
-     * @return mixed
81
-     */
82
-    public function sanitize($value)
83
-    {
84
-        $myts = MyTextSanitizer::getInstance();
85
-
86
-        return $myts->displayTarea($value, 1);
87
-    }
88
-
89
-    public function render()
90
-    {
91
-        /**
92
-         * @todo move the output to a template
93
-         * @todo make the output XHTML compliant
94
-         */
95
-
96
-        $myts = MyTextSanitizer::getInstance();
97
-
98
-        global $xoopsModule;
99
-
100
-        smart_xoops_cp_header();
101
-
102
-        /** @var XoopsModuleHandler $moduleHandler */
103
-        $moduleHandler = xoops_getHandler('module');
104
-        $versioninfo   = $moduleHandler->get($xoopsModule->getVar('mid'));
105
-
106
-        //smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name'));
107
-
108
-        require_once XOOPS_ROOT_PATH . '/class/template.php';
109
-
110
-        // ---
111
-        // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
112
-        //      $this->_tpl = new XoopsTpl();
113
-        $this->_tpl = new XoopsTpl();
114
-        // ---
115
-
116
-        $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/');
117
-        $this->_tpl->assign('module_image', $versioninfo->getInfo('image'));
118
-        $this->_tpl->assign('module_name', $versioninfo->getInfo('name'));
119
-        $this->_tpl->assign('module_version', $versioninfo->getInfo('version'));
120
-        $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version'));
121
-
122
-        // Left headings...
123
-        if ('' !== $versioninfo->getInfo('author_realname')) {
124
-            $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')';
125
-        } else {
126
-            $author_name = $versioninfo->getInfo('author');
127
-        }
128
-        $this->_tpl->assign('module_author_name', $author_name);
129
-
130
-        $this->_tpl->assign('module_license', $versioninfo->getInfo('license'));
131
-
132
-        $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits'));
133
-
134
-        // Developers Information
135
-        $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead'));
136
-        $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor'));
137
-        $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url'));
138
-        $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name'));
139
-        $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email'));
140
-
141
-        $people = $versioninfo->getInfo('people');
142
-        if ($people) {
143
-            $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false);
144
-            $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false);
145
-            $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false);
146
-            $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false);
147
-            $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false);
148
-        }
149
-        //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email'));
150
-
151
-        // Module Development information
152
-        $this->_tpl->assign('module_date', $versioninfo->getInfo('date'));
153
-        $this->_tpl->assign('module_status', $versioninfo->getInfo('status'));
154
-        $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url'));
155
-        $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name'));
156
-        $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url'));
157
-        $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name'));
158
-        $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug'));
159
-        $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature'));
160
-
161
-        // Warning
162
-        $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning')));
163
-
164
-        // Author's note
165
-        $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word'));
166
-
167
-        // For changelog thanks to 3Dev
168
-        global $xoopsModule;
169
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt';
170
-        if (is_file($filename)) {
171
-            $filesize = filesize($filename);
172
-            $handle   = fopen($filename, 'r');
173
-            $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true));
174
-            fclose($handle);
175
-        }
176
-
177
-        $this->_tpl->display('db:smartobject_about.tpl');
178
-
179
-        smart_modFooter();
180
-
181
-        xoops_cp_footer();
182
-    }
22
+	public $_lang_aboutTitle;
23
+	public $_lang_author_info;
24
+	public $_lang_developer_lead;
25
+	public $_lang_developer_contributor;
26
+	public $_lang_developer_website;
27
+	public $_lang_developer_email;
28
+	public $_lang_developer_credits;
29
+	public $_lang_module_info;
30
+	public $_lang_module_status;
31
+	public $_lang_module_release_date;
32
+	public $_lang_module_demo;
33
+	public $_lang_module_support;
34
+	public $_lang_module_bug;
35
+	public $_lang_module_submit_bug;
36
+	public $_lang_module_feature;
37
+	public $_lang_module_submit_feature;
38
+	public $_lang_module_disclaimer;
39
+	public $_lang_author_word;
40
+	public $_lang_version_history;
41
+	public $_lang_by;
42
+	public $_tpl;
43
+
44
+	/**
45
+	 * SmartobjectAbout constructor.
46
+	 * @param string $aboutTitle
47
+	 */
48
+	public function __construct($aboutTitle = 'About')
49
+	{
50
+		global $xoopsModule, $xoopsConfig;
51
+
52
+		$fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
53
+		if (file_exists($fileName)) {
54
+			require_once $fileName;
55
+		} else {
56
+			require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
57
+		}
58
+		$this->_aboutTitle = $aboutTitle;
59
+
60
+		$this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR;
61
+		$this->_lang_developer_website     = _CO_SOBJECT_DEVELOPER_WEBSITE;
62
+		$this->_lang_developer_email       = _CO_SOBJECT_DEVELOPER_EMAIL;
63
+		$this->_lang_developer_credits     = _CO_SOBJECT_DEVELOPER_CREDITS;
64
+		$this->_lang_module_info           = _CO_SOBJECT_MODULE_INFO;
65
+		$this->_lang_module_status         = _CO_SOBJECT_MODULE_STATUS;
66
+		$this->_lang_module_release_date   = _CO_SOBJECT_MODULE_RELEASE_DATE;
67
+		$this->_lang_module_demo           = _CO_SOBJECT_MODULE_DEMO;
68
+		$this->_lang_module_support        = _CO_SOBJECT_MODULE_SUPPORT;
69
+		$this->_lang_module_bug            = _CO_SOBJECT_MODULE_BUG;
70
+		$this->_lang_module_submit_bug     = _CO_SOBJECT_MODULE_SUBMIT_BUG;
71
+		$this->_lang_module_feature        = _CO_SOBJECT_MODULE_FEATURE;
72
+		$this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE;
73
+		$this->_lang_module_disclaimer     = _CO_SOBJECT_MODULE_DISCLAIMER;
74
+		$this->_lang_author_word           = _CO_SOBJECT_AUTHOR_WORD;
75
+		$this->_lang_version_history       = _CO_SOBJECT_VERSION_HISTORY;
76
+	}
77
+
78
+	/**
79
+	 * @param $value
80
+	 * @return mixed
81
+	 */
82
+	public function sanitize($value)
83
+	{
84
+		$myts = MyTextSanitizer::getInstance();
85
+
86
+		return $myts->displayTarea($value, 1);
87
+	}
88
+
89
+	public function render()
90
+	{
91
+		/**
92
+		 * @todo move the output to a template
93
+		 * @todo make the output XHTML compliant
94
+		 */
95
+
96
+		$myts = MyTextSanitizer::getInstance();
97
+
98
+		global $xoopsModule;
99
+
100
+		smart_xoops_cp_header();
101
+
102
+		/** @var XoopsModuleHandler $moduleHandler */
103
+		$moduleHandler = xoops_getHandler('module');
104
+		$versioninfo   = $moduleHandler->get($xoopsModule->getVar('mid'));
105
+
106
+		//smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name'));
107
+
108
+		require_once XOOPS_ROOT_PATH . '/class/template.php';
109
+
110
+		// ---
111
+		// 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
112
+		//      $this->_tpl = new XoopsTpl();
113
+		$this->_tpl = new XoopsTpl();
114
+		// ---
115
+
116
+		$this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/');
117
+		$this->_tpl->assign('module_image', $versioninfo->getInfo('image'));
118
+		$this->_tpl->assign('module_name', $versioninfo->getInfo('name'));
119
+		$this->_tpl->assign('module_version', $versioninfo->getInfo('version'));
120
+		$this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version'));
121
+
122
+		// Left headings...
123
+		if ('' !== $versioninfo->getInfo('author_realname')) {
124
+			$author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')';
125
+		} else {
126
+			$author_name = $versioninfo->getInfo('author');
127
+		}
128
+		$this->_tpl->assign('module_author_name', $author_name);
129
+
130
+		$this->_tpl->assign('module_license', $versioninfo->getInfo('license'));
131
+
132
+		$this->_tpl->assign('module_credits', $versioninfo->getInfo('credits'));
133
+
134
+		// Developers Information
135
+		$this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead'));
136
+		$this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor'));
137
+		$this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url'));
138
+		$this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name'));
139
+		$this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email'));
140
+
141
+		$people = $versioninfo->getInfo('people');
142
+		if ($people) {
143
+			$this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false);
144
+			$this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false);
145
+			$this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false);
146
+			$this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false);
147
+			$this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false);
148
+		}
149
+		//$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email'));
150
+
151
+		// Module Development information
152
+		$this->_tpl->assign('module_date', $versioninfo->getInfo('date'));
153
+		$this->_tpl->assign('module_status', $versioninfo->getInfo('status'));
154
+		$this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url'));
155
+		$this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name'));
156
+		$this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url'));
157
+		$this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name'));
158
+		$this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug'));
159
+		$this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature'));
160
+
161
+		// Warning
162
+		$this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning')));
163
+
164
+		// Author's note
165
+		$this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word'));
166
+
167
+		// For changelog thanks to 3Dev
168
+		global $xoopsModule;
169
+		$filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt';
170
+		if (is_file($filename)) {
171
+			$filesize = filesize($filename);
172
+			$handle   = fopen($filename, 'r');
173
+			$this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true));
174
+			fclose($handle);
175
+		}
176
+
177
+		$this->_tpl->display('db:smartobject_about.tpl');
178
+
179
+		smart_modFooter();
180
+
181
+		xoops_cp_footer();
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
     {
50 50
         global $xoopsModule, $xoopsConfig;
51 51
 
52
-        $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
52
+        $fileName = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php';
53 53
         if (file_exists($fileName)) {
54 54
             require_once $fileName;
55 55
         } else {
56
-            require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
56
+            require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/modinfo.php';
57 57
         }
58 58
         $this->_aboutTitle = $aboutTitle;
59 59
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
         //smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name'));
107 107
 
108
-        require_once XOOPS_ROOT_PATH . '/class/template.php';
108
+        require_once XOOPS_ROOT_PATH.'/class/template.php';
109 109
 
110 110
         // ---
111 111
         // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $this->_tpl = new XoopsTpl();
114 114
         // ---
115 115
 
116
-        $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/');
116
+        $this->_tpl->assign('module_url', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/');
117 117
         $this->_tpl->assign('module_image', $versioninfo->getInfo('image'));
118 118
         $this->_tpl->assign('module_name', $versioninfo->getInfo('name'));
119 119
         $this->_tpl->assign('module_version', $versioninfo->getInfo('version'));
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
         // Left headings...
123 123
         if ('' !== $versioninfo->getInfo('author_realname')) {
124
-            $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')';
124
+            $author_name = $versioninfo->getInfo('author').' ('.$versioninfo->getInfo('author_realname').')';
125 125
         } else {
126 126
             $author_name = $versioninfo->getInfo('author');
127 127
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
         // For changelog thanks to 3Dev
168 168
         global $xoopsModule;
169
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt';
169
+        $filename = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/changelog.txt';
170 170
         if (is_file($filename)) {
171 171
             $filesize = filesize($filename);
172 172
             $handle   = fopen($filename, 'r');
Please login to merge, or discard this patch.
class/member.php 1 patch
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -34,227 +34,227 @@
 block discarded – undo
34 34
  */
35 35
 class SmartobjectMemberHandler extends XoopsMemberHandler
36 36
 {
37
-    /**
38
-     * constructor
39
-     * @param XoopsDatabase $db
40
-     */
41
-    public function __construct(XoopsDatabase $db)
42
-    {
43
-        parent::__construct($db);
44
-        $this->_uHandler = xoops_getModuleHandler('user', 'smartobject');
45
-    }
37
+	/**
38
+	 * constructor
39
+	 * @param XoopsDatabase $db
40
+	 */
41
+	public function __construct(XoopsDatabase $db)
42
+	{
43
+		parent::__construct($db);
44
+		$this->_uHandler = xoops_getModuleHandler('user', 'smartobject');
45
+	}
46 46
 
47
-    /**
48
-     * @param       $userObj
49
-     * @param  bool $groups
50
-     * @param  bool $notifyUser
51
-     * @param  bool $password
52
-     * @return bool
53
-     */
54
-    public function addAndActivateUser($userObj, $groups = false, $notifyUser = true, &$password = false)
55
-    {
56
-        $email = $userObj->getVar('email');
57
-        if (!$userObj->getVar('email') || '' === $email) {
58
-            $userObj->setErrors(_CO_SOBJECT_USER_NEED_EMAIL);
47
+	/**
48
+	 * @param       $userObj
49
+	 * @param  bool $groups
50
+	 * @param  bool $notifyUser
51
+	 * @param  bool $password
52
+	 * @return bool
53
+	 */
54
+	public function addAndActivateUser($userObj, $groups = false, $notifyUser = true, &$password = false)
55
+	{
56
+		$email = $userObj->getVar('email');
57
+		if (!$userObj->getVar('email') || '' === $email) {
58
+			$userObj->setErrors(_CO_SOBJECT_USER_NEED_EMAIL);
59 59
 
60
-            return false;
61
-        }
60
+			return false;
61
+		}
62 62
 
63
-        $password = $userObj->getVar('pass');
64
-        // randomly generating the password if not already set
65
-        if ('' === $password) {
66
-            $password = substr(md5(uniqid(mt_rand(), 1)), 0, 6);
67
-        }
68
-        $userObj->setVar('pass', md5($password));
63
+		$password = $userObj->getVar('pass');
64
+		// randomly generating the password if not already set
65
+		if ('' === $password) {
66
+			$password = substr(md5(uniqid(mt_rand(), 1)), 0, 6);
67
+		}
68
+		$userObj->setVar('pass', md5($password));
69 69
 
70
-        // if no username is set, let's generate one
71
-        $unamecount = 20;
72
-        $uname      = $userObj->getVar('uname');
73
-        if (!$uname || '' === $uname) {
74
-            $usernames = $this->genUserNames($email, $unamecount);
75
-            $newuser   = false;
76
-            $i         = 0;
77
-            while (false === $newuser) {
78
-                $crit  = new Criteria('uname', $usernames[$i]);
79
-                $count = $this->getUserCount($crit);
80
-                if (0 == $count) {
81
-                    $newuser = true;
82
-                } else {
83
-                    //Move to next username
84
-                    ++$i;
85
-                    if ($i == $unamecount) {
86
-                        //Get next batch of usernames to try, reset counter
87
-                        $usernames = $this->genUserNames($email, $unamecount);
88
-                        $i         = 0;
89
-                    }
90
-                }
91
-            }
92
-        }
70
+		// if no username is set, let's generate one
71
+		$unamecount = 20;
72
+		$uname      = $userObj->getVar('uname');
73
+		if (!$uname || '' === $uname) {
74
+			$usernames = $this->genUserNames($email, $unamecount);
75
+			$newuser   = false;
76
+			$i         = 0;
77
+			while (false === $newuser) {
78
+				$crit  = new Criteria('uname', $usernames[$i]);
79
+				$count = $this->getUserCount($crit);
80
+				if (0 == $count) {
81
+					$newuser = true;
82
+				} else {
83
+					//Move to next username
84
+					++$i;
85
+					if ($i == $unamecount) {
86
+						//Get next batch of usernames to try, reset counter
87
+						$usernames = $this->genUserNames($email, $unamecount);
88
+						$i         = 0;
89
+					}
90
+				}
91
+			}
92
+		}
93 93
 
94
-        global $xoopsConfig;
94
+		global $xoopsConfig;
95 95
 
96
-        $configHandler   = xoops_getHandler('config');
97
-        $xoopsConfigUser = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
98
-        switch ($xoopsConfigUser['activation_type']) {
99
-            case 0:
100
-                $level           = 0;
101
-                $mailtemplate    = 'smartmail_activate_user.tpl';
102
-                $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_NEED_ACT, $user_email);
103
-                break;
104
-            case 1:
105
-                $level           = 1;
106
-                $mailtemplate    = 'smartmail_auto_activate_user.tpl';
107
-                $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_AUTO_ACT, $user_email);
108
-                break;
109
-            case 2:
110
-            default:
111
-                $level           = 0;
112
-                $mailtemplate    = 'smartmail_admin_activate_user.tpl';
113
-                $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_ADMIN_ACT, $user_email);
114
-        }
96
+		$configHandler   = xoops_getHandler('config');
97
+		$xoopsConfigUser = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
98
+		switch ($xoopsConfigUser['activation_type']) {
99
+			case 0:
100
+				$level           = 0;
101
+				$mailtemplate    = 'smartmail_activate_user.tpl';
102
+				$aInfoMessages[] = sprintf(_NL_MA_NEW_USER_NEED_ACT, $user_email);
103
+				break;
104
+			case 1:
105
+				$level           = 1;
106
+				$mailtemplate    = 'smartmail_auto_activate_user.tpl';
107
+				$aInfoMessages[] = sprintf(_NL_MA_NEW_USER_AUTO_ACT, $user_email);
108
+				break;
109
+			case 2:
110
+			default:
111
+				$level           = 0;
112
+				$mailtemplate    = 'smartmail_admin_activate_user.tpl';
113
+				$aInfoMessages[] = sprintf(_NL_MA_NEW_USER_ADMIN_ACT, $user_email);
114
+		}
115 115
 
116
-        $userObj->setVar('uname', $usernames[$i]);
117
-        $userObj->setVar('user_avatar', 'blank.gif');
118
-        $userObj->setVar('user_regdate', time());
119
-        $userObj->setVar('timezone_offset', $xoopsConfig['default_TZ']);
120
-        $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
121
-        $userObj->setVar('actkey', $actkey);
122
-        $userObj->setVar('email', $email);
123
-        $userObj->setVar('notify_method', 2);
124
-        $userObj->setVar('level', $userObj);
116
+		$userObj->setVar('uname', $usernames[$i]);
117
+		$userObj->setVar('user_avatar', 'blank.gif');
118
+		$userObj->setVar('user_regdate', time());
119
+		$userObj->setVar('timezone_offset', $xoopsConfig['default_TZ']);
120
+		$actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
121
+		$userObj->setVar('actkey', $actkey);
122
+		$userObj->setVar('email', $email);
123
+		$userObj->setVar('notify_method', 2);
124
+		$userObj->setVar('level', $userObj);
125 125
 
126
-        if ($this->insertUser($userObj)) {
126
+		if ($this->insertUser($userObj)) {
127 127
 
128
-            // if $groups=false, Add the user to Registered Users group
129
-            if (!$groups) {
130
-                $this->addUserToGroup(XOOPS_GROUP_USERS, $userObj->getVar('uid'));
131
-            } else {
132
-                foreach ($groups as $groupid) {
133
-                    $this->addUserToGroup($groupid, $userObj->getVar('uid'));
134
-                }
135
-            }
136
-        } else {
137
-            return false;
138
-        }
128
+			// if $groups=false, Add the user to Registered Users group
129
+			if (!$groups) {
130
+				$this->addUserToGroup(XOOPS_GROUP_USERS, $userObj->getVar('uid'));
131
+			} else {
132
+				foreach ($groups as $groupid) {
133
+					$this->addUserToGroup($groupid, $userObj->getVar('uid'));
134
+				}
135
+			}
136
+		} else {
137
+			return false;
138
+		}
139 139
 
140
-        if ($notifyUser) {
141
-            // send some notifications
142
-            $xoopsMailer = xoops_getMailer();
143
-            $xoopsMailer->useMail();
144
-            $xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/mail_template');
145
-            $xoopsMailer->setTemplate('smartobject_notify_user_added_by_admin.tpl');
146
-            $xoopsMailer->assign('XOOPS_USER_PASSWORD', $password);
147
-            $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
148
-            $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
149
-            $xoopsMailer->assign('SITEURL', XOOPS_URL . '/');
150
-            $xoopsMailer->assign('NAME', $userObj->getVar('name'));
151
-            $xoopsMailer->assign('UNAME', $userObj->getVar('uname'));
152
-            $xoopsMailer->setToUsers($userObj);
153
-            $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
154
-            $xoopsMailer->setFromName($xoopsConfig['sitename']);
155
-            $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_NEW_USER_NOTIFICATION_SUBJECT, $xoopsConfig['sitename']));
140
+		if ($notifyUser) {
141
+			// send some notifications
142
+			$xoopsMailer = xoops_getMailer();
143
+			$xoopsMailer->useMail();
144
+			$xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/mail_template');
145
+			$xoopsMailer->setTemplate('smartobject_notify_user_added_by_admin.tpl');
146
+			$xoopsMailer->assign('XOOPS_USER_PASSWORD', $password);
147
+			$xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
148
+			$xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
149
+			$xoopsMailer->assign('SITEURL', XOOPS_URL . '/');
150
+			$xoopsMailer->assign('NAME', $userObj->getVar('name'));
151
+			$xoopsMailer->assign('UNAME', $userObj->getVar('uname'));
152
+			$xoopsMailer->setToUsers($userObj);
153
+			$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
154
+			$xoopsMailer->setFromName($xoopsConfig['sitename']);
155
+			$xoopsMailer->setSubject(sprintf(_CO_SOBJECT_NEW_USER_NOTIFICATION_SUBJECT, $xoopsConfig['sitename']));
156 156
 
157
-            if (!$xoopsMailer->send(true)) {
158
-                /**
159
-                 * @todo trap error if email was not sent
160
-                 */
161
-                $xoopsMailer->getErrors(true);
162
-            }
163
-        }
157
+			if (!$xoopsMailer->send(true)) {
158
+				/**
159
+				 * @todo trap error if email was not sent
160
+				 */
161
+				$xoopsMailer->getErrors(true);
162
+			}
163
+		}
164 164
 
165
-        return true;
166
-    }
165
+		return true;
166
+	}
167 167
 
168
-    /**
169
-     * Generates an array of usernames
170
-     *
171
-     * @param  string $email email of user
172
-     * @param  int    $count number of names to generate
173
-     * @return array  $names
174
-     * @internal param string $name name of user
175
-     * @author   xHelp Team
176
-     *
177
-     * @access   public
178
-     */
179
-    public function genUserNames($email, $count = 20)
180
-    {
181
-        $name = substr($email, 0, strpos($email, '@')); //Take the email adress without domain as username
168
+	/**
169
+	 * Generates an array of usernames
170
+	 *
171
+	 * @param  string $email email of user
172
+	 * @param  int    $count number of names to generate
173
+	 * @return array  $names
174
+	 * @internal param string $name name of user
175
+	 * @author   xHelp Team
176
+	 *
177
+	 * @access   public
178
+	 */
179
+	public function genUserNames($email, $count = 20)
180
+	{
181
+		$name = substr($email, 0, strpos($email, '@')); //Take the email adress without domain as username
182 182
 
183
-        $names  = [];
184
-        $userid = explode('@', $email);
183
+		$names  = [];
184
+		$userid = explode('@', $email);
185 185
 
186
-        $basename    = '';
187
-        $hasbasename = false;
188
-        $emailname   = $userid[0];
186
+		$basename    = '';
187
+		$hasbasename = false;
188
+		$emailname   = $userid[0];
189 189
 
190
-        $names[] = $emailname;
190
+		$names[] = $emailname;
191 191
 
192
-        if (strlen($name) > 0) {
193
-            $name = explode(' ', trim($name));
194
-            if (count($name) > 1) {
195
-                $basename = strtolower(substr($name[0], 0, 1) . $name[count($name) - 1]);
196
-            } else {
197
-                $basename = strtolower($name[0]);
198
-            }
199
-            $basename = xoops_substr($basename, 0, 60, '');
200
-            //Prevent Duplication of Email Username and Name
201
-            if (!in_array($basename, $names)) {
202
-                $names[]     = $basename;
203
-                $hasbasename = true;
204
-            }
205
-        }
192
+		if (strlen($name) > 0) {
193
+			$name = explode(' ', trim($name));
194
+			if (count($name) > 1) {
195
+				$basename = strtolower(substr($name[0], 0, 1) . $name[count($name) - 1]);
196
+			} else {
197
+				$basename = strtolower($name[0]);
198
+			}
199
+			$basename = xoops_substr($basename, 0, 60, '');
200
+			//Prevent Duplication of Email Username and Name
201
+			if (!in_array($basename, $names)) {
202
+				$names[]     = $basename;
203
+				$hasbasename = true;
204
+			}
205
+		}
206 206
 
207
-        $i          = count($names);
208
-        $onbasename = 1;
209
-        while ($i < $count) {
210
-            $num = $this->genRandNumber();
211
-            if ($onbasename < 0 && $hasbasename) {
212
-                $names[] = xoops_substr($basename, 0, 58, '') . $num;
213
-            } else {
214
-                $names[] = xoops_substr($emailname, 0, 58, '') . $num;
215
-            }
216
-            $i          = count($names);
217
-            $onbasename = ~$onbasename;
218
-            $num        = '';
219
-        }
207
+		$i          = count($names);
208
+		$onbasename = 1;
209
+		while ($i < $count) {
210
+			$num = $this->genRandNumber();
211
+			if ($onbasename < 0 && $hasbasename) {
212
+				$names[] = xoops_substr($basename, 0, 58, '') . $num;
213
+			} else {
214
+				$names[] = xoops_substr($emailname, 0, 58, '') . $num;
215
+			}
216
+			$i          = count($names);
217
+			$onbasename = ~$onbasename;
218
+			$num        = '';
219
+		}
220 220
 
221
-        return $names;
222
-    }
221
+		return $names;
222
+	}
223 223
 
224
-    /**
225
-     * Creates a random number with a specified number of $digits
226
-     *
227
-     * @param  int $digits number of digits
228
-     * @return return int random number
229
-     * @author xHelp Team
230
-     *
231
-     * @access public
232
-     */
233
-    public function genRandNumber($digits = 2)
234
-    {
235
-        $this->initRand();
236
-        $tmp = [];
224
+	/**
225
+	 * Creates a random number with a specified number of $digits
226
+	 *
227
+	 * @param  int $digits number of digits
228
+	 * @return return int random number
229
+	 * @author xHelp Team
230
+	 *
231
+	 * @access public
232
+	 */
233
+	public function genRandNumber($digits = 2)
234
+	{
235
+		$this->initRand();
236
+		$tmp = [];
237 237
 
238
-        for ($i = 0; $i < $digits; ++$i) {
239
-            $tmp[$i] = (mt_rand() % 9);
240
-        }
238
+		for ($i = 0; $i < $digits; ++$i) {
239
+			$tmp[$i] = (mt_rand() % 9);
240
+		}
241 241
 
242
-        return implode('', $tmp);
243
-    }
242
+		return implode('', $tmp);
243
+	}
244 244
 
245
-    /**
246
-     * Gives the random number generator a seed to start from
247
-     *
248
-     * @return void
249
-     *
250
-     * @access public
251
-     */
252
-    public function initRand()
253
-    {
254
-        static $randCalled = false;
255
-        if (!$randCalled) {
256
-            mt_srand((double)microtime() * 1000000);
257
-            $randCalled = true;
258
-        }
259
-    }
245
+	/**
246
+	 * Gives the random number generator a seed to start from
247
+	 *
248
+	 * @return void
249
+	 *
250
+	 * @access public
251
+	 */
252
+	public function initRand()
253
+	{
254
+		static $randCalled = false;
255
+		if (!$randCalled) {
256
+			mt_srand((double)microtime() * 1000000);
257
+			$randCalled = true;
258
+		}
259
+	}
260 260
 }
Please login to merge, or discard this patch.
class/smartexport.php 2 patches
Indentation   +271 added lines, -271 removed lines patch added patch discarded remove patch
@@ -19,118 +19,118 @@  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(
44
-        SmartPersistableObjectHandler $objectHandler,
45
-        CriteriaElement $criteria = null,
46
-        $fields = false,
47
-        $filename = false,
48
-        $filepath = false,
49
-        $format = 'csv',
50
-        $options = false
51
-    ) {
52
-        $this->handler          = $objectHandler;
53
-        $this->criteria         = $criteria;
54
-        $this->fields           = $fields;
55
-        $this->filename         = $filename;
56
-        $this->format           = $format;
57
-        $this->options          = $options;
58
-        $this->notDisplayFields = false;
59
-    }
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(
44
+		SmartPersistableObjectHandler $objectHandler,
45
+		CriteriaElement $criteria = null,
46
+		$fields = false,
47
+		$filename = false,
48
+		$filepath = false,
49
+		$format = 'csv',
50
+		$options = false
51
+	) {
52
+		$this->handler          = $objectHandler;
53
+		$this->criteria         = $criteria;
54
+		$this->fields           = $fields;
55
+		$this->filename         = $filename;
56
+		$this->format           = $format;
57
+		$this->options          = $options;
58
+		$this->notDisplayFields = false;
59
+	}
60 60
 
61
-    /**
62
-     * Renders the export
63
-     * @param $filename
64
-     */
65
-    public function render($filename)
66
-    {
67
-        $this->filename = $filename;
61
+	/**
62
+	 * Renders the export
63
+	 * @param $filename
64
+	 */
65
+	public function render($filename)
66
+	{
67
+		$this->filename = $filename;
68 68
 
69
-        $objects        = $this->handler->getObjects($this->criteria);
70
-        $rows           = [];
71
-        $columnsHeaders = [];
72
-        $firstObject    = true;
73
-        foreach ($objects as $object) {
74
-            $row = [];
75
-            foreach ($object->vars as $key => $var) {
76
-                if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
77
-                    if ($this->outputMethods && isset($this->outputMethods[$key])
78
-                        && method_exists($object, $this->outputMethods[$key])) {
79
-                        $method    = $this->outputMethods[$key];
80
-                        $row[$key] = $object->$method();
81
-                    } else {
82
-                        $row[$key] = $object->getVar($key);
83
-                    }
84
-                    if ($firstObject) {
85
-                        // then set the columnsHeaders array as well
86
-                        $columnsHeaders[$key] = $var['form_caption'];
87
-                    }
88
-                }
89
-            }
90
-            $firstObject = false;
91
-            $rows[]      = $row;
92
-            unset($row);
93
-        }
94
-        $data                   = [];
95
-        $data['rows']           = $rows;
96
-        $data['columnsHeaders'] = $columnsHeaders;
97
-        $smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
98
-        $smartExportRenderer->execute();
99
-    }
69
+		$objects        = $this->handler->getObjects($this->criteria);
70
+		$rows           = [];
71
+		$columnsHeaders = [];
72
+		$firstObject    = true;
73
+		foreach ($objects as $object) {
74
+			$row = [];
75
+			foreach ($object->vars as $key => $var) {
76
+				if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
77
+					if ($this->outputMethods && isset($this->outputMethods[$key])
78
+						&& method_exists($object, $this->outputMethods[$key])) {
79
+						$method    = $this->outputMethods[$key];
80
+						$row[$key] = $object->$method();
81
+					} else {
82
+						$row[$key] = $object->getVar($key);
83
+					}
84
+					if ($firstObject) {
85
+						// then set the columnsHeaders array as well
86
+						$columnsHeaders[$key] = $var['form_caption'];
87
+					}
88
+				}
89
+			}
90
+			$firstObject = false;
91
+			$rows[]      = $row;
92
+			unset($row);
93
+		}
94
+		$data                   = [];
95
+		$data['rows']           = $rows;
96
+		$data['columnsHeaders'] = $columnsHeaders;
97
+		$smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
98
+		$smartExportRenderer->execute();
99
+	}
100 100
 
101
-    /**
102
-     * Set an array contaning the alternate methods to use instead of the default getVar()
103
-     *
104
-     * $outputMethods array example: 'uid' => 'getUserName'...
105
-     * @param $outputMethods
106
-     */
107
-    public function setOuptutMethods($outputMethods)
108
-    {
109
-        $this->outputMethods = $outputMethods;
110
-    }
101
+	/**
102
+	 * Set an array contaning the alternate methods to use instead of the default getVar()
103
+	 *
104
+	 * $outputMethods array example: 'uid' => 'getUserName'...
105
+	 * @param $outputMethods
106
+	 */
107
+	public function setOuptutMethods($outputMethods)
108
+	{
109
+		$this->outputMethods = $outputMethods;
110
+	}
111 111
 
112
-    /*
112
+	/*
113 113
      * Set an array of fields that we don't want in export
114 114
      */
115
-    /**
116
-     * @param $fields
117
-     */
118
-    public function setNotDisplayFields($fields)
119
-    {
120
-        if (!$this->notDisplayFields) {
121
-            if (is_array($fields)) {
122
-                $this->notDisplayFields = $fields;
123
-            } else {
124
-                $this->notDisplayFields = [$fields];
125
-            }
126
-        } else {
127
-            if (is_array($fields)) {
128
-                $this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
129
-            } else {
130
-                $this->notDisplayFields[] = $fields;
131
-            }
132
-        }
133
-    }
115
+	/**
116
+	 * @param $fields
117
+	 */
118
+	public function setNotDisplayFields($fields)
119
+	{
120
+		if (!$this->notDisplayFields) {
121
+			if (is_array($fields)) {
122
+				$this->notDisplayFields = $fields;
123
+			} else {
124
+				$this->notDisplayFields = [$fields];
125
+			}
126
+		} else {
127
+			if (is_array($fields)) {
128
+				$this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
129
+			} else {
130
+				$this->notDisplayFields[] = $fields;
131
+			}
132
+		}
133
+	}
134 134
 }
135 135
 
136 136
 /**
@@ -144,186 +144,186 @@  discard block
 block discarded – undo
144 144
  */
145 145
 class SmartExportRenderer
146 146
 {
147
-    public $data;
148
-    public $format;
149
-    public $filename;
150
-    public $filepath;
151
-    public $options;
147
+	public $data;
148
+	public $format;
149
+	public $filename;
150
+	public $filepath;
151
+	public $options;
152 152
 
153
-    /**
154
-     * Constructor
155
-     *
156
-     * @param array       $data     contains the data to be exported
157
-     * @param bool|string $filename name of the file in which the exported data will be saved
158
-     * @param bool|string $filepath path where the file will be saved
159
-     * @param string      $format   format of the ouputed export. Currently only supports CSV
160
-     * @param array       $options  options of the format to be exported in
161
-     */
162
-    public function __construct(
163
-        $data,
164
-        $filename = false,
165
-        $filepath = false,
166
-        $format = 'csv',
167
-        $options = ['separator' => ';']
168
-    ) {
169
-        $this->data     = $data;
170
-        $this->format   = $format;
171
-        $this->filename = $filename;
172
-        $this->filepath = $filepath;
173
-        $this->options  = $options;
174
-    }
153
+	/**
154
+	 * Constructor
155
+	 *
156
+	 * @param array       $data     contains the data to be exported
157
+	 * @param bool|string $filename name of the file in which the exported data will be saved
158
+	 * @param bool|string $filepath path where the file will be saved
159
+	 * @param string      $format   format of the ouputed export. Currently only supports CSV
160
+	 * @param array       $options  options of the format to be exported in
161
+	 */
162
+	public function __construct(
163
+		$data,
164
+		$filename = false,
165
+		$filepath = false,
166
+		$format = 'csv',
167
+		$options = ['separator' => ';']
168
+	) {
169
+		$this->data     = $data;
170
+		$this->format   = $format;
171
+		$this->filename = $filename;
172
+		$this->filepath = $filepath;
173
+		$this->options  = $options;
174
+	}
175 175
 
176
-    /**
177
-     * @param         $dataArray
178
-     * @param         $separator
179
-     * @param  string $trim
180
-     * @param  bool   $removeEmptyLines
181
-     * @return string
182
-     */
183
-    public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
184
-    {
185
-        if (!is_array($dataArray) || empty($dataArray)) {
186
-            return '';
187
-        }
188
-        switch ($trim) {
189
-            case 'none':
190
-                $trimFunction = false;
191
-                break;
192
-            case 'left':
193
-                $trimFunction = 'ltrim';
194
-                break;
195
-            case 'right':
196
-                $trimFunction = 'rtrim';
197
-                break;
198
-            default: //'both':
199
-                $trimFunction = 'trim';
200
-                break;
201
-        }
202
-        $ret = [];
203
-        foreach ($dataArray as $key => $field) {
204
-            $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
205
-        }
176
+	/**
177
+	 * @param         $dataArray
178
+	 * @param         $separator
179
+	 * @param  string $trim
180
+	 * @param  bool   $removeEmptyLines
181
+	 * @return string
182
+	 */
183
+	public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
184
+	{
185
+		if (!is_array($dataArray) || empty($dataArray)) {
186
+			return '';
187
+		}
188
+		switch ($trim) {
189
+			case 'none':
190
+				$trimFunction = false;
191
+				break;
192
+			case 'left':
193
+				$trimFunction = 'ltrim';
194
+				break;
195
+			case 'right':
196
+				$trimFunction = 'rtrim';
197
+				break;
198
+			default: //'both':
199
+				$trimFunction = 'trim';
200
+				break;
201
+		}
202
+		$ret = [];
203
+		foreach ($dataArray as $key => $field) {
204
+			$ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
205
+		}
206 206
 
207
-        return implode($separator, $ret);
208
-    }
207
+		return implode($separator, $ret);
208
+	}
209 209
 
210
-    /**
211
-     * @param $val
212
-     * @param $separator
213
-     * @param $trimFunction
214
-     * @return mixed|string
215
-     */
216
-    public function valToCsvHelper($val, $separator, $trimFunction)
217
-    {
218
-        if ($trimFunction) {
219
-            $val = $trimFunction($val);
220
-        }
221
-        //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
222
-        $needQuote = false;
223
-        do {
224
-            if (false !== strpos($val, '"')) {
225
-                $val       = str_replace('"', '""', $val);
226
-                $needQuote = true;
227
-                break;
228
-            }
229
-            if (false !== strpos($val, $separator)) {
230
-                $needQuote = true;
231
-                break;
232
-            }
233
-            if ((false !== strpos($val, "\n")) || (false !== strpos($val, "\r"))) { // \r is for mac
234
-                $needQuote = true;
235
-                break;
236
-            }
237
-        } while (false);
238
-        if ($needQuote) {
239
-            $val = '"' . $val . '"';
240
-        }
210
+	/**
211
+	 * @param $val
212
+	 * @param $separator
213
+	 * @param $trimFunction
214
+	 * @return mixed|string
215
+	 */
216
+	public function valToCsvHelper($val, $separator, $trimFunction)
217
+	{
218
+		if ($trimFunction) {
219
+			$val = $trimFunction($val);
220
+		}
221
+		//If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
222
+		$needQuote = false;
223
+		do {
224
+			if (false !== strpos($val, '"')) {
225
+				$val       = str_replace('"', '""', $val);
226
+				$needQuote = true;
227
+				break;
228
+			}
229
+			if (false !== strpos($val, $separator)) {
230
+				$needQuote = true;
231
+				break;
232
+			}
233
+			if ((false !== strpos($val, "\n")) || (false !== strpos($val, "\r"))) { // \r is for mac
234
+				$needQuote = true;
235
+				break;
236
+			}
237
+		} while (false);
238
+		if ($needQuote) {
239
+			$val = '"' . $val . '"';
240
+		}
241 241
 
242
-        return $val;
243
-    }
242
+		return $val;
243
+	}
244 244
 
245
-    public function execute()
246
-    {
247
-        $exportFileData = '';
245
+	public function execute()
246
+	{
247
+		$exportFileData = '';
248 248
 
249
-        switch ($this->format) {
250
-            case 'csv':
251
-                $separator      = isset($this->options['separator']) ? $this->options['separator'] : ';';
252
-                $firstRow       = implode($separator, $this->data['columnsHeaders']);
253
-                $exportFileData .= $firstRow . "\r\n";
249
+		switch ($this->format) {
250
+			case 'csv':
251
+				$separator      = isset($this->options['separator']) ? $this->options['separator'] : ';';
252
+				$firstRow       = implode($separator, $this->data['columnsHeaders']);
253
+				$exportFileData .= $firstRow . "\r\n";
254 254
 
255
-                foreach ($this->data['rows'] as $cols) {
256
-                    $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
257
-                }
258
-                break;
259
-        }
260
-        $this->saveExportFile($exportFileData);
261
-    }
255
+				foreach ($this->data['rows'] as $cols) {
256
+					$exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
257
+				}
258
+				break;
259
+		}
260
+		$this->saveExportFile($exportFileData);
261
+	}
262 262
 
263
-    /**
264
-     * @param $content
265
-     */
266
-    public function saveExportFile($content)
267
-    {
268
-        switch ($this->format) {
269
-            case 'csv':
270
-                $this->saveCsv($content);
271
-                break;
272
-        }
273
-    }
263
+	/**
264
+	 * @param $content
265
+	 */
266
+	public function saveExportFile($content)
267
+	{
268
+		switch ($this->format) {
269
+			case 'csv':
270
+				$this->saveCsv($content);
271
+				break;
272
+		}
273
+	}
274 274
 
275
-    /**
276
-     * @param $content
277
-     */
278
-    public function saveCsv($content)
279
-    {
280
-        if (!$this->filepath) {
281
-            $this->filepath = XOOPS_UPLOAD_PATH . '/';
282
-        }
283
-        if (!$this->filename) {
284
-            $this->filename .= time();
285
-            $this->filename .= '.csv';
286
-        }
275
+	/**
276
+	 * @param $content
277
+	 */
278
+	public function saveCsv($content)
279
+	{
280
+		if (!$this->filepath) {
281
+			$this->filepath = XOOPS_UPLOAD_PATH . '/';
282
+		}
283
+		if (!$this->filename) {
284
+			$this->filename .= time();
285
+			$this->filename .= '.csv';
286
+		}
287 287
 
288
-        $fullFileName = $this->filepath . $this->filename;
288
+		$fullFileName = $this->filepath . $this->filename;
289 289
 
290
-        if (!$handle = fopen($fullFileName, 'a+')) {
291
-            trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
292
-        } elseif (false === fwrite($handle, $content)) {
293
-            trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
294
-        } else {
295
-            $mimeType  = 'text/csv';
296
-            $file      = strrev($this->filename);
297
-            $temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
298
-            if ('' === $temp_name) {
299
-                $file_name = $this->filename;
300
-            } else {
301
-                $file_name = $temp_name;
302
-            }
303
-            $fullFileName = $this->filepath . stripslashes(trim($this->filename));
290
+		if (!$handle = fopen($fullFileName, 'a+')) {
291
+			trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
292
+		} elseif (false === fwrite($handle, $content)) {
293
+			trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
294
+		} else {
295
+			$mimeType  = 'text/csv';
296
+			$file      = strrev($this->filename);
297
+			$temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
298
+			if ('' === $temp_name) {
299
+				$file_name = $this->filename;
300
+			} else {
301
+				$file_name = $temp_name;
302
+			}
303
+			$fullFileName = $this->filepath . stripslashes(trim($this->filename));
304 304
 
305
-            if (ini_get('zlib.output_compression')) {
306
-                ini_set('zlib.output_compression', 'Off');
307
-            }
305
+			if (ini_get('zlib.output_compression')) {
306
+				ini_set('zlib.output_compression', 'Off');
307
+			}
308 308
 
309
-            header('Pragma: public');
310
-            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
311
-            header('Cache-Control: private', false);
312
-            header('Content-Transfer-Encoding: binary');
313
-            if (isset($mimeType)) {
314
-                header('Content-Type: ' . $mimeType);
315
-            }
309
+			header('Pragma: public');
310
+			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
311
+			header('Cache-Control: private', false);
312
+			header('Content-Transfer-Encoding: binary');
313
+			if (isset($mimeType)) {
314
+				header('Content-Type: ' . $mimeType);
315
+			}
316 316
 
317
-            header('Content-Disposition: attachment; filename=' . $file_name);
317
+			header('Content-Disposition: attachment; filename=' . $file_name);
318 318
 
319
-            if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
320
-                $fp = fopen($fullFileName, 'r');
321
-            } else {
322
-                $fp = fopen($fullFileName, 'rb');
323
-            }
324
-            fpassthru($fp);
325
-            exit();
326
-        }
327
-        fclose($handle);
328
-    }
319
+			if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
320
+				$fp = fopen($fullFileName, 'r');
321
+			} else {
322
+				$fp = fopen($fullFileName, 'rb');
323
+			}
324
+			fpassthru($fp);
325
+			exit();
326
+		}
327
+		fclose($handle);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             }
237 237
         } while (false);
238 238
         if ($needQuote) {
239
-            $val = '"' . $val . '"';
239
+            $val = '"'.$val.'"';
240 240
         }
241 241
 
242 242
         return $val;
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
             case 'csv':
251 251
                 $separator      = isset($this->options['separator']) ? $this->options['separator'] : ';';
252 252
                 $firstRow       = implode($separator, $this->data['columnsHeaders']);
253
-                $exportFileData .= $firstRow . "\r\n";
253
+                $exportFileData .= $firstRow."\r\n";
254 254
 
255 255
                 foreach ($this->data['rows'] as $cols) {
256
-                    $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
256
+                    $exportFileData .= $this->arrayToCsvString($cols, $separator)."\r\n";
257 257
                 }
258 258
                 break;
259 259
         }
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
     public function saveCsv($content)
279 279
     {
280 280
         if (!$this->filepath) {
281
-            $this->filepath = XOOPS_UPLOAD_PATH . '/';
281
+            $this->filepath = XOOPS_UPLOAD_PATH.'/';
282 282
         }
283 283
         if (!$this->filename) {
284 284
             $this->filename .= time();
285 285
             $this->filename .= '.csv';
286 286
         }
287 287
 
288
-        $fullFileName = $this->filepath . $this->filename;
288
+        $fullFileName = $this->filepath.$this->filename;
289 289
 
290 290
         if (!$handle = fopen($fullFileName, 'a+')) {
291
-            trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
291
+            trigger_error('Unable to open '.$fullFileName, E_USER_WARNING);
292 292
         } elseif (false === fwrite($handle, $content)) {
293
-            trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
293
+            trigger_error('Unable to write in '.$fullFileName, E_USER_WARNING);
294 294
         } else {
295 295
             $mimeType  = 'text/csv';
296 296
             $file      = strrev($this->filename);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             } else {
301 301
                 $file_name = $temp_name;
302 302
             }
303
-            $fullFileName = $this->filepath . stripslashes(trim($this->filename));
303
+            $fullFileName = $this->filepath.stripslashes(trim($this->filename));
304 304
 
305 305
             if (ini_get('zlib.output_compression')) {
306 306
                 ini_set('zlib.output_compression', 'Off');
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
             header('Cache-Control: private', false);
312 312
             header('Content-Transfer-Encoding: binary');
313 313
             if (isset($mimeType)) {
314
-                header('Content-Type: ' . $mimeType);
314
+                header('Content-Type: '.$mimeType);
315 315
             }
316 316
 
317
-            header('Content-Disposition: attachment; filename=' . $file_name);
317
+            header('Content-Disposition: attachment; filename='.$file_name);
318 318
 
319 319
             if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
320 320
                 $fp = fopen($fullFileName, 'r');
Please login to merge, or discard this patch.
class/adsense.php 2 patches
Indentation   +326 added lines, -326 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', [
57
-            'handler' => 'adsense',
58
-            'method'  => 'getFormats'
59
-        ]);
60
-
61
-        $this->setControl('border_color', [
62
-            'name'      => 'text',
63
-            'size'      => 6,
64
-            'maxlength' => 6
65
-        ]);
66
-
67
-        $this->setControl('background_color', [
68
-            'name'      => 'text',
69
-            'size'      => 6,
70
-            'maxlength' => 6
71
-        ]);
72
-
73
-        $this->setControl('link_color', [
74
-            'name'      => 'text',
75
-            'size'      => 6,
76
-            'maxlength' => 6
77
-        ]);
78
-
79
-        $this->setControl('url_color', [
80
-            'name'      => 'text',
81
-            'size'      => 6,
82
-            'maxlength' => 6
83
-        ]);
84
-
85
-        $this->setControl('text_color', [
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 ('s' === $format && in_array($key, [])) {
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', [
57
+			'handler' => 'adsense',
58
+			'method'  => 'getFormats'
59
+		]);
60
+
61
+		$this->setControl('border_color', [
62
+			'name'      => 'text',
63
+			'size'      => 6,
64
+			'maxlength' => 6
65
+		]);
66
+
67
+		$this->setControl('background_color', [
68
+			'name'      => 'text',
69
+			'size'      => 6,
70
+			'maxlength' => 6
71
+		]);
72
+
73
+		$this->setControl('link_color', [
74
+			'name'      => 'text',
75
+			'size'      => 6,
76
+			'maxlength' => 6
77
+		]);
78
+
79
+		$this->setControl('url_color', [
80
+			'name'      => 'text',
81
+			'size'      => 6,
82
+			'maxlength' => 6
83
+		]);
84
+
85
+		$this->setControl('text_color', [
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 ('s' === $format && in_array($key, [])) {
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,139 +134,139 @@  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 = [
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 = [
198
-            '-',
199
-            '-',
200
-            '-',
201
-            '-',
202
-            '-',
203
-            '-100',
204
-            '-',
205
-            '-',
206
-            '-',
207
-            '-',
208
-            '-',
209
-            '-',
210
-            '-',
211
-            '-',
212
-            '-',
213
-            '-',
214
-            '-',
215
-            '-',
216
-            '-at-',
217
-            '-',
218
-            '-',
219
-            '-',
220
-            '-',
221
-            '-',
222
-            '-',
223
-            '-',
224
-            '-',
225
-            '-'
226
-        ];
227
-        $title   = preg_replace($pattern, $rep_pat, $title);
228
-
229
-        // Transformation des caractères accentués
230
-        $pattern = [
231
-            '/%B0/', // °
232
-            '/%E8/', // è
233
-            '/%E9/', // é
234
-            '/%EA/', // ê
235
-            '/%EB/', // ë
236
-            '/%E7/', // ç
237
-            '/%E0/', // à
238
-            '/%E2/', // â
239
-            '/%E4/', // ä
240
-            '/%EE/', // î
241
-            '/%EF/', // ï
242
-            '/%F9/', // ù
243
-            '/%FC/', // ü
244
-            '/%FB/', // û
245
-            '/%F4/', // ô
246
-            '/%F6/', // ö
247
-        ];
248
-        $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
249
-        $title   = preg_replace($pattern, $rep_pat, $title);
250
-
251
-        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
252
-        $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
253
-        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
254
-
255
-        $title .= time();
256
-        $title = md5($title);
257
-
258
-        return $title;
259
-    }
260
-
261
-    /**
262
-     * @return string
263
-     */
264
-    public function getCloneLink()
265
-    {
266
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>';
267
-
268
-        return $ret;
269
-    }
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 = [
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 = [
198
+			'-',
199
+			'-',
200
+			'-',
201
+			'-',
202
+			'-',
203
+			'-100',
204
+			'-',
205
+			'-',
206
+			'-',
207
+			'-',
208
+			'-',
209
+			'-',
210
+			'-',
211
+			'-',
212
+			'-',
213
+			'-',
214
+			'-',
215
+			'-',
216
+			'-at-',
217
+			'-',
218
+			'-',
219
+			'-',
220
+			'-',
221
+			'-',
222
+			'-',
223
+			'-',
224
+			'-',
225
+			'-'
226
+		];
227
+		$title   = preg_replace($pattern, $rep_pat, $title);
228
+
229
+		// Transformation des caractères accentués
230
+		$pattern = [
231
+			'/%B0/', // °
232
+			'/%E8/', // è
233
+			'/%E9/', // é
234
+			'/%EA/', // ê
235
+			'/%EB/', // ë
236
+			'/%E7/', // ç
237
+			'/%E0/', // à
238
+			'/%E2/', // â
239
+			'/%E4/', // ä
240
+			'/%EE/', // î
241
+			'/%EF/', // ï
242
+			'/%F9/', // ù
243
+			'/%FC/', // ü
244
+			'/%FB/', // û
245
+			'/%F4/', // ô
246
+			'/%F6/', // ö
247
+		];
248
+		$rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
249
+		$title   = preg_replace($pattern, $rep_pat, $title);
250
+
251
+		$tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
252
+		$tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
253
+		$title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
254
+
255
+		$title .= time();
256
+		$title = md5($title);
257
+
258
+		return $title;
259
+	}
260
+
261
+	/**
262
+	 * @return string
263
+	 */
264
+	public function getCloneLink()
265
+	{
266
+		$ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>';
267
+
268
+		return $ret;
269
+	}
270 270
 }
271 271
 
272 272
 /**
@@ -274,116 +274,116 @@  discard block
 block discarded – undo
274 274
  */
275 275
 class SmartobjectAdsenseHandler extends SmartPersistableObjectHandler
276 276
 {
277
-    public $adFormats;
278
-    public $adFormatsList;
279
-    public $objects = false;
280
-
281
-    /**
282
-     * SmartobjectAdsenseHandler constructor.
283
-     * @param XoopsDatabase $db
284
-     */
285
-    public function __construct(XoopsDatabase $db)
286
-    {
287
-        parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
288
-        $this->adFormats     = [];
289
-        $this->adFormatsList = [];
290
-
291
-        $this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
292
-        $this->adFormats['728x90_as']['width']   = 728;
293
-        $this->adFormats['728x90_as']['height']  = 90;
294
-        $this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
295
-
296
-        $this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
297
-        $this->adFormats['468x60_as']['width']   = 468;
298
-        $this->adFormats['468x60_as']['height']  = 60;
299
-        $this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
300
-
301
-        $this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
302
-        $this->adFormats['234x60_as']['width']   = 234;
303
-        $this->adFormats['234x60_as']['height']  = 60;
304
-        $this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
305
-
306
-        $this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
307
-        $this->adFormats['120x600_as']['width']   = 120;
308
-        $this->adFormats['120x600_as']['height']  = 600;
309
-        $this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
310
-
311
-        $this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
312
-        $this->adFormats['160x600_as']['width']   = 160;
313
-        $this->adFormats['160x600_as']['height']  = 600;
314
-        $this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
315
-
316
-        $this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
317
-        $this->adFormats['120x240_as']['width']   = 120;
318
-        $this->adFormats['120x240_as']['height']  = 240;
319
-        $this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
320
-
321
-        $this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
322
-        $this->adFormats['336x280_as']['width']   = 136;
323
-        $this->adFormats['336x280_as']['height']  = 280;
324
-        $this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
325
-
326
-        $this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
327
-        $this->adFormats['300x250_as']['width']   = 300;
328
-        $this->adFormats['300x250_as']['height']  = 250;
329
-        $this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
330
-
331
-        $this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
332
-        $this->adFormats['250x250_as']['width']   = 250;
333
-        $this->adFormats['250x250_as']['height']  = 250;
334
-        $this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
335
-
336
-        $this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
337
-        $this->adFormats['200x200_as']['width']   = 200;
338
-        $this->adFormats['200x200_as']['height']  = 200;
339
-        $this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
340
-
341
-        $this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
342
-        $this->adFormats['180x150_as']['width']   = 180;
343
-        $this->adFormats['180x150_as']['height']  = 150;
344
-        $this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
345
-
346
-        $this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
347
-        $this->adFormats['125x125_as']['width']   = 125;
348
-        $this->adFormats['125x125_as']['height']  = 125;
349
-        $this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
350
-    }
351
-
352
-    /**
353
-     * @return array
354
-     */
355
-    public function getFormats()
356
-    {
357
-        return $this->adFormatsList;
358
-    }
359
-
360
-    /**
361
-     * @param $obj
362
-     * @return bool
363
-     */
364
-    public function beforeSave($obj)
365
-    {
366
-        if ('' === $obj->getVar('tag')) {
367
-            $obj->setVar('tag', $title = $obj->generateTag());
368
-        }
369
-
370
-        return true;
371
-    }
372
-
373
-    /**
374
-     * @return array|bool
375
-     */
376
-    public function getAdsensesByTag()
377
-    {
378
-        if (!$this->objects) {
379
-            $adsensesObj = $this->getObjects(null, true);
380
-            $ret         = [];
381
-            foreach ($adsensesObj as $adsenseObj) {
382
-                $ret[$adsenseObj->getVar('tag')] = $adsenseObj;
383
-            }
384
-            $this->objects = $ret;
385
-        }
386
-
387
-        return $this->objects;
388
-    }
277
+	public $adFormats;
278
+	public $adFormatsList;
279
+	public $objects = false;
280
+
281
+	/**
282
+	 * SmartobjectAdsenseHandler constructor.
283
+	 * @param XoopsDatabase $db
284
+	 */
285
+	public function __construct(XoopsDatabase $db)
286
+	{
287
+		parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
288
+		$this->adFormats     = [];
289
+		$this->adFormatsList = [];
290
+
291
+		$this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
292
+		$this->adFormats['728x90_as']['width']   = 728;
293
+		$this->adFormats['728x90_as']['height']  = 90;
294
+		$this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
295
+
296
+		$this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
297
+		$this->adFormats['468x60_as']['width']   = 468;
298
+		$this->adFormats['468x60_as']['height']  = 60;
299
+		$this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
300
+
301
+		$this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
302
+		$this->adFormats['234x60_as']['width']   = 234;
303
+		$this->adFormats['234x60_as']['height']  = 60;
304
+		$this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
305
+
306
+		$this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
307
+		$this->adFormats['120x600_as']['width']   = 120;
308
+		$this->adFormats['120x600_as']['height']  = 600;
309
+		$this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
310
+
311
+		$this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
312
+		$this->adFormats['160x600_as']['width']   = 160;
313
+		$this->adFormats['160x600_as']['height']  = 600;
314
+		$this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
315
+
316
+		$this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
317
+		$this->adFormats['120x240_as']['width']   = 120;
318
+		$this->adFormats['120x240_as']['height']  = 240;
319
+		$this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
320
+
321
+		$this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
322
+		$this->adFormats['336x280_as']['width']   = 136;
323
+		$this->adFormats['336x280_as']['height']  = 280;
324
+		$this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
325
+
326
+		$this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
327
+		$this->adFormats['300x250_as']['width']   = 300;
328
+		$this->adFormats['300x250_as']['height']  = 250;
329
+		$this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
330
+
331
+		$this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
332
+		$this->adFormats['250x250_as']['width']   = 250;
333
+		$this->adFormats['250x250_as']['height']  = 250;
334
+		$this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
335
+
336
+		$this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
337
+		$this->adFormats['200x200_as']['width']   = 200;
338
+		$this->adFormats['200x200_as']['height']  = 200;
339
+		$this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
340
+
341
+		$this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
342
+		$this->adFormats['180x150_as']['width']   = 180;
343
+		$this->adFormats['180x150_as']['height']  = 150;
344
+		$this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
345
+
346
+		$this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
347
+		$this->adFormats['125x125_as']['width']   = 125;
348
+		$this->adFormats['125x125_as']['height']  = 125;
349
+		$this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
350
+	}
351
+
352
+	/**
353
+	 * @return array
354
+	 */
355
+	public function getFormats()
356
+	{
357
+		return $this->adFormatsList;
358
+	}
359
+
360
+	/**
361
+	 * @param $obj
362
+	 * @return bool
363
+	 */
364
+	public function beforeSave($obj)
365
+	{
366
+		if ('' === $obj->getVar('tag')) {
367
+			$obj->setVar('tag', $title = $obj->generateTag());
368
+		}
369
+
370
+		return true;
371
+	}
372
+
373
+	/**
374
+	 * @return array|bool
375
+	 */
376
+	public function getAdsensesByTag()
377
+	{
378
+		if (!$this->objects) {
379
+			$adsensesObj = $this->getObjects(null, true);
380
+			$ret         = [];
381
+			foreach ($adsensesObj as $adsenseObj) {
382
+				$ret[$adsenseObj->getVar('tag')] = $adsenseObj;
383
+			}
384
+			$this->objects = $ret;
385
+		}
386
+
387
+		return $this->objects;
388
+	}
389 389
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 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('Restricted access.');
31 31
 
32
-require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
32
+require_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
     }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function getCloneLink()
265 265
     {
266
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>';
266
+        $ret = '<a href="'.SMARTOBJECT_URL.'admin/adsense.php?op=clone&adsenseid='.$this->getVar('adsenseid').'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'editcopy.png" alt="'._CO_SOBJECT_ADSENSE_CLONE.'" title="'._CO_SOBJECT_ADSENSE_CLONE.'"></a>';
267 267
 
268 268
         return $ret;
269 269
     }
Please login to merge, or discard this patch.
admin/update.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -18,180 +18,180 @@  discard block
 block discarded – undo
18 18
 // =========================================================================================
19 19
 function update_tables_to_300()
20 20
 {
21
-    $dbupdater = new WfdownloadsDbupdater();
21
+	$dbupdater = new WfdownloadsDbupdater();
22 22
 
23
-    if (!wfdownloads_TableExists('wfdownloads_meta')) {
24
-        // Create table wfdownloads_meta
25
-        $table = new WfdownloadsTable('wfdownloads_meta');
26
-        $table->setStructure("CREATE TABLE %s (
23
+	if (!wfdownloads_TableExists('wfdownloads_meta')) {
24
+		// Create table wfdownloads_meta
25
+		$table = new WfdownloadsTable('wfdownloads_meta');
26
+		$table->setStructure("CREATE TABLE %s (
27 27
                                 metakey varchar(50) NOT NULL default '',
28 28
                                 metavalue varchar(255) NOT NULL default '',
29 29
                                 PRIMARY KEY (metakey))
30 30
                                 ENGINE=MyISAM;");
31 31
 
32
-        $table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2)));
33
-        if ($dbupdater->updateTable($table)) {
34
-            echo 'wfdownloads_meta table created<br>';
35
-        }
36
-    }
32
+		$table->setData(sprintf("'version', %s", round($GLOBALS['xoopsModule']->getVar('version') / 100, 2)));
33
+		if ($dbupdater->updateTable($table)) {
34
+			echo 'wfdownloads_meta table created<br>';
35
+		}
36
+	}
37 37
 
38
-    $download_fields = [
39
-        'lid'           => ['Type' => 'int(11) unsigned NOT NULL auto_increment', 'Default' => false],
40
-        'cid'           => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
41
-        'title'         => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
42
-        'url'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
43
-        'filename'      => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
44
-        'filetype'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
45
-        'homepage'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
46
-        'version'       => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
47
-        'size'          => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
48
-        'platform'      => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
49
-        'screenshot'    => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
50
-        'submitter'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
51
-        'publisher'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
52
-        'status'        => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
53
-        'date'          => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
54
-        'hits'          => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
55
-        'rating'        => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
56
-        'votes'         => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
57
-        'comments'      => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
58
-        'license'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
59
-        'mirror'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
60
-        'price'         => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
61
-        'paypalemail'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
62
-        'features'      => ['Type' => 'text NOT NULL', 'Default' => false],
63
-        'requirements'  => ['Type' => 'text NOT NULL', 'Default' => false],
64
-        'homepagetitle' => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
65
-        'forumid'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
66
-        'limitations'   => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
67
-        'dhistory'      => ['Type' => 'text NOT NULL', 'Default' => false],
68
-        'published'     => ['Type' => "int(11) NOT NULL default '1089662528'", 'Default' => true],
69
-        'expired'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
70
-        'updated'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
71
-        'offline'       => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
72
-        'description'   => ['Type' => 'text NOT NULL', 'Default' => false],
73
-        'ipaddress'     => ['Type' => "varchar(120) NOT NULL default '0'", 'Default' => true],
74
-        'notifypub'     => ['Type' => "int(1) NOT NULL default '0'", 'Default' => true],
75
-        'summary'       => ['Type' => 'text NOT NULL', 'Default' => false]
76
-    ];
38
+	$download_fields = [
39
+		'lid'           => ['Type' => 'int(11) unsigned NOT NULL auto_increment', 'Default' => false],
40
+		'cid'           => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
41
+		'title'         => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
42
+		'url'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
43
+		'filename'      => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
44
+		'filetype'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
45
+		'homepage'      => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
46
+		'version'       => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
47
+		'size'          => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
48
+		'platform'      => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
49
+		'screenshot'    => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
50
+		'submitter'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
51
+		'publisher'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
52
+		'status'        => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
53
+		'date'          => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
54
+		'hits'          => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
55
+		'rating'        => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
56
+		'votes'         => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
57
+		'comments'      => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
58
+		'license'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
59
+		'mirror'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
60
+		'price'         => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
61
+		'paypalemail'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
62
+		'features'      => ['Type' => 'text NOT NULL', 'Default' => false],
63
+		'requirements'  => ['Type' => 'text NOT NULL', 'Default' => false],
64
+		'homepagetitle' => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
65
+		'forumid'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
66
+		'limitations'   => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
67
+		'dhistory'      => ['Type' => 'text NOT NULL', 'Default' => false],
68
+		'published'     => ['Type' => "int(11) NOT NULL default '1089662528'", 'Default' => true],
69
+		'expired'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
70
+		'updated'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
71
+		'offline'       => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
72
+		'description'   => ['Type' => 'text NOT NULL', 'Default' => false],
73
+		'ipaddress'     => ['Type' => "varchar(120) NOT NULL default '0'", 'Default' => true],
74
+		'notifypub'     => ['Type' => "int(1) NOT NULL default '0'", 'Default' => true],
75
+		'summary'       => ['Type' => 'text NOT NULL', 'Default' => false]
76
+	];
77 77
 
78
-    $renamed_fields = [
79
-        'logourl' => 'screenshot'
80
-    ];
78
+	$renamed_fields = [
79
+		'logourl' => 'screenshot'
80
+	];
81 81
 
82
-    echo '<br><b>Checking Download table</b><br>';
83
-    $downloadHandler = xoops_getModuleHandler('download', 'wfdownloads');
84
-    $download_table  = new WfdownloadsTable('wfdownloads_downloads');
85
-    $fields          = get_table_info($downloadHandler->table, $download_fields);
86
-    // Check for renamed fields
87
-    rename_fields($download_table, $renamed_fields, $fields, $download_fields);
88
-    update_table($download_fields, $fields, $download_table);
89
-    if ($dbupdater->updateTable($download_table)) {
90
-        echo 'Downloads table updated<br>';
91
-    }
92
-    unset($fields);
82
+	echo '<br><b>Checking Download table</b><br>';
83
+	$downloadHandler = xoops_getModuleHandler('download', 'wfdownloads');
84
+	$download_table  = new WfdownloadsTable('wfdownloads_downloads');
85
+	$fields          = get_table_info($downloadHandler->table, $download_fields);
86
+	// Check for renamed fields
87
+	rename_fields($download_table, $renamed_fields, $fields, $download_fields);
88
+	update_table($download_fields, $fields, $download_table);
89
+	if ($dbupdater->updateTable($download_table)) {
90
+		echo 'Downloads table updated<br>';
91
+	}
92
+	unset($fields);
93 93
 
94
-    $mod_fields = [
95
-        'requestid'       => ['Type' => 'int(11) NOT NULL auto_increment', 'Default' => false],
96
-        'lid'             => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
97
-        'cid'             => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
98
-        'title'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
99
-        'url'             => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
100
-        'filename'        => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
101
-        'filetype'        => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
102
-        'homepage'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
103
-        'version'         => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
104
-        'size'            => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
105
-        'platform'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
106
-        'screenshot'      => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
107
-        'submitter'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
108
-        'publisher'       => ['Type' => 'text NOT NULL', 'Default' => false],
109
-        'status'          => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
110
-        'date'            => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
111
-        'hits'            => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
112
-        'rating'          => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
113
-        'votes'           => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
114
-        'comments'        => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
115
-        'license'         => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
116
-        'mirror'          => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
117
-        'price'           => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
118
-        'paypalemail'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
119
-        'features'        => ['Type' => 'text NOT NULL', 'Default' => false],
120
-        'requirements'    => ['Type' => 'text NOT NULL', 'Default' => false],
121
-        'homepagetitle'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
122
-        'forumid'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
123
-        'limitations'     => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
124
-        'dhistory'        => ['Type' => 'text NOT NULL', 'Default' => false],
125
-        'published'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
126
-        'expired'         => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
127
-        'updated'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
128
-        'offline'         => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
129
-        'summary'         => ['Type' => 'text NOT NULL', 'Default' => false],
130
-        'description'     => ['Type' => 'text NOT NULL', 'Default' => false],
131
-        'modifysubmitter' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
132
-        'requestdate'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
133
-    ];
94
+	$mod_fields = [
95
+		'requestid'       => ['Type' => 'int(11) NOT NULL auto_increment', 'Default' => false],
96
+		'lid'             => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
97
+		'cid'             => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
98
+		'title'           => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
99
+		'url'             => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
100
+		'filename'        => ['Type' => "varchar(150) NOT NULL default ''", 'Default' => true],
101
+		'filetype'        => ['Type' => "varchar(100) NOT NULL default ''", 'Default' => true],
102
+		'homepage'        => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
103
+		'version'         => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
104
+		'size'            => ['Type' => "int(8) NOT NULL default '0'", 'Default' => true],
105
+		'platform'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
106
+		'screenshot'      => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
107
+		'submitter'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
108
+		'publisher'       => ['Type' => 'text NOT NULL', 'Default' => false],
109
+		'status'          => ['Type' => "tinyint(2) NOT NULL default '0'", 'Default' => true],
110
+		'date'            => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
111
+		'hits'            => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
112
+		'rating'          => ['Type' => "double(6,4) NOT NULL default '0.0000'", 'Default' => true],
113
+		'votes'           => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
114
+		'comments'        => ['Type' => "int(11) unsigned NOT NULL default '0'", 'Default' => true],
115
+		'license'         => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
116
+		'mirror'          => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
117
+		'price'           => ['Type' => "varchar(10) NOT NULL default 'Free'", 'Default' => true],
118
+		'paypalemail'     => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
119
+		'features'        => ['Type' => 'text NOT NULL', 'Default' => false],
120
+		'requirements'    => ['Type' => 'text NOT NULL', 'Default' => false],
121
+		'homepagetitle'   => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
122
+		'forumid'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
123
+		'limitations'     => ['Type' => "varchar(255) NOT NULL default '30 day trial'", 'Default' => true],
124
+		'dhistory'        => ['Type' => 'text NOT NULL', 'Default' => false],
125
+		'published'       => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
126
+		'expired'         => ['Type' => "int(10) NOT NULL default '0'", 'Default' => true],
127
+		'updated'         => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
128
+		'offline'         => ['Type' => "tinyint(1) NOT NULL default '0'", 'Default' => true],
129
+		'summary'         => ['Type' => 'text NOT NULL', 'Default' => false],
130
+		'description'     => ['Type' => 'text NOT NULL', 'Default' => false],
131
+		'modifysubmitter' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
132
+		'requestdate'     => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
133
+	];
134 134
 
135
-    $renamed_fields = [
136
-        'logourl' => 'screenshot'
137
-    ];
135
+	$renamed_fields = [
136
+		'logourl' => 'screenshot'
137
+	];
138 138
 
139
-    echo '<br><b>Checking Modified Downloads table</b><br>';
140
-    $moduleHandler = xoops_getModuleHandler('modification', 'wfdownloads');
141
-    $mod_table     = new WfdownloadsTable('wfdownloads_mod');
142
-    $fields        = get_table_info($moduleHandler->table, $mod_fields);
143
-    rename_fields($mod_table, $renamed_fields, $fields, $mod_fields);
144
-    update_table($mod_fields, $fields, $mod_table);
145
-    if ($dbupdater->updateTable($mod_table)) {
146
-        echo 'Modified Downloads table updated <br>';
147
-    }
148
-    unset($fields);
139
+	echo '<br><b>Checking Modified Downloads table</b><br>';
140
+	$moduleHandler = xoops_getModuleHandler('modification', 'wfdownloads');
141
+	$mod_table     = new WfdownloadsTable('wfdownloads_mod');
142
+	$fields        = get_table_info($moduleHandler->table, $mod_fields);
143
+	rename_fields($mod_table, $renamed_fields, $fields, $mod_fields);
144
+	update_table($mod_fields, $fields, $mod_table);
145
+	if ($dbupdater->updateTable($mod_table)) {
146
+		echo 'Modified Downloads table updated <br>';
147
+	}
148
+	unset($fields);
149 149
 
150
-    $cat_fields = [
151
-        'cid'          => ['Type' => 'int(5) unsigned NOT NULL auto_increment', 'Default' => false],
152
-        'pid'          => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
153
-        'title'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
154
-        'imgurl'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
155
-        'description'  => ['Type' => "text NULL", 'Default' => true],
156
-        'total'        => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
157
-        'summary'      => ['Type' => 'text NOT NULL', 'Default' => false],
158
-        'spotlighttop' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
159
-        'spotlighthis' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
160
-        'dohtml'       => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
161
-        'dosmiley'     => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
162
-        'doxcode'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
163
-        'doimage'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
164
-        'dobr'         => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
165
-        'weight'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
166
-    ];
167
-    echo '<br><b>Checking Category table</b><br>';
168
-    $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
169
-    $cat_table  = new WfdownloadsTable('wfdownloads_cat');
170
-    $fields     = get_table_info($catHandler->table, $cat_fields);
171
-    update_table($cat_fields, $fields, $cat_table);
172
-    if ($dbupdater->updateTable($cat_table)) {
173
-        echo 'Category table updated<br>';
174
-    }
175
-    unset($fields);
150
+	$cat_fields = [
151
+		'cid'          => ['Type' => 'int(5) unsigned NOT NULL auto_increment', 'Default' => false],
152
+		'pid'          => ['Type' => "int(5) unsigned NOT NULL default '0'", 'Default' => true],
153
+		'title'        => ['Type' => "varchar(50) NOT NULL default ''", 'Default' => true],
154
+		'imgurl'       => ['Type' => "varchar(255) NOT NULL default ''", 'Default' => true],
155
+		'description'  => ['Type' => "text NULL", 'Default' => true],
156
+		'total'        => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
157
+		'summary'      => ['Type' => 'text NOT NULL', 'Default' => false],
158
+		'spotlighttop' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
159
+		'spotlighthis' => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
160
+		'dohtml'       => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
161
+		'dosmiley'     => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
162
+		'doxcode'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
163
+		'doimage'      => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
164
+		'dobr'         => ['Type' => "tinyint(1) NOT NULL default '1'", 'Default' => true],
165
+		'weight'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true]
166
+	];
167
+	echo '<br><b>Checking Category table</b><br>';
168
+	$catHandler = xoops_getModuleHandler('category', 'wfdownloads');
169
+	$cat_table  = new WfdownloadsTable('wfdownloads_cat');
170
+	$fields     = get_table_info($catHandler->table, $cat_fields);
171
+	update_table($cat_fields, $fields, $cat_table);
172
+	if ($dbupdater->updateTable($cat_table)) {
173
+		echo 'Category table updated<br>';
174
+	}
175
+	unset($fields);
176 176
 
177
-    $broken_fields = [
178
-        'reportid'     => ['Type' => 'int(5) NOT NULL auto_increment', 'Default' => false],
179
-        'lid'          => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
180
-        'sender'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
181
-        'ip'           => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
182
-        'date'         => ['Type' => "varchar(11) NOT NULL default '0'", 'Default' => true],
183
-        'confirmed'    => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true],
184
-        'acknowledged' => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true]
185
-    ];
186
-    echo '<br><b>Checking Broken Report table</b><br>';
187
-    $brokenHandler = xoops_getModuleHandler('report', 'wfdownloads');
188
-    $broken_table  = new WfdownloadsTable('wfdownloads_broken');
189
-    $fields        = get_table_info($brokenHandler->table, $broken_fields);
190
-    update_table($broken_fields, $fields, $broken_table);
191
-    if ($dbupdater->updateTable($broken_table)) {
192
-        echo 'Broken Reports table updated<br>';
193
-    }
194
-    unset($fields);
177
+	$broken_fields = [
178
+		'reportid'     => ['Type' => 'int(5) NOT NULL auto_increment', 'Default' => false],
179
+		'lid'          => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
180
+		'sender'       => ['Type' => "int(11) NOT NULL default '0'", 'Default' => true],
181
+		'ip'           => ['Type' => "varchar(20) NOT NULL default ''", 'Default' => true],
182
+		'date'         => ['Type' => "varchar(11) NOT NULL default '0'", 'Default' => true],
183
+		'confirmed'    => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true],
184
+		'acknowledged' => ['Type' => "enum('0','1') NOT NULL default '0'", 'Default' => true]
185
+	];
186
+	echo '<br><b>Checking Broken Report table</b><br>';
187
+	$brokenHandler = xoops_getModuleHandler('report', 'wfdownloads');
188
+	$broken_table  = new WfdownloadsTable('wfdownloads_broken');
189
+	$fields        = get_table_info($brokenHandler->table, $broken_fields);
190
+	update_table($broken_fields, $fields, $broken_table);
191
+	if ($dbupdater->updateTable($broken_table)) {
192
+		echo 'Broken Reports table updated<br>';
193
+	}
194
+	unset($fields);
195 195
 }
196 196
 
197 197
 // =========================================================================================
@@ -204,48 +204,48 @@  discard block
 block discarded – undo
204 204
  */
205 205
 function invert_nohtm_dohtml_values()
206 206
 {
207
-    $ret = [];
208
-    global $xoopsDB;
209
-    $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
-    $result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
211
-    while ($existing_field = $xoopsDB->fetchArray($result)) {
212
-        $fields[$existing_field['field']] = $existing_field['type'];
213
-    }
214
-    if (in_array('nohtml', array_keys($fields))) {
215
-        $dbupdater = new WfdownloadsDbupdater();
216
-        //Invert column values
217
-        // alter options in wfdownloads_cat
218
-        $table = new WfdownloadsTable('wfdownloads_cat');
219
-        $table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'");
220
-        $table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'");
221
-        $table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'");
222
-        $table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'");
223
-        $table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'");
207
+	$ret = [];
208
+	global $xoopsDB;
209
+	$catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
+	$result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
211
+	while ($existing_field = $xoopsDB->fetchArray($result)) {
212
+		$fields[$existing_field['field']] = $existing_field['type'];
213
+	}
214
+	if (in_array('nohtml', array_keys($fields))) {
215
+		$dbupdater = new WfdownloadsDbupdater();
216
+		//Invert column values
217
+		// alter options in wfdownloads_cat
218
+		$table = new WfdownloadsTable('wfdownloads_cat');
219
+		$table->addAlteredField('nohtml', "dohtml tinyint(1) NOT NULL DEFAULT '1'");
220
+		$table->addAlteredField('nosmiley', "dosmiley tinyint(1) NOT NULL DEFAULT '1'");
221
+		$table->addAlteredField('noxcodes', "doxcode tinyint(1) NOT NULL DEFAULT '1'");
222
+		$table->addAlteredField('noimages', "doimage tinyint(1) NOT NULL DEFAULT '1'");
223
+		$table->addAlteredField('nobreak', "dobr tinyint(1) NOT NULL DEFAULT '1'");
224 224
 
225
-        //inverting values no=1 <=> do=0
226
-        // have to store teporarly as value = 2 to
227
-        // avoid putting everithing to same value
228
-        // if you change 1 to 0, then 0 to one,
229
-        // every value will be 1, follow me?
230
-        $table->addUpdatedWhere('dohtml', 2, '=1');
231
-        $table->addUpdatedWhere('dohtml', 1, '=0');
232
-        $table->addUpdatedWhere('dohtml', 0, '=2');
225
+		//inverting values no=1 <=> do=0
226
+		// have to store teporarly as value = 2 to
227
+		// avoid putting everithing to same value
228
+		// if you change 1 to 0, then 0 to one,
229
+		// every value will be 1, follow me?
230
+		$table->addUpdatedWhere('dohtml', 2, '=1');
231
+		$table->addUpdatedWhere('dohtml', 1, '=0');
232
+		$table->addUpdatedWhere('dohtml', 0, '=2');
233 233
 
234
-        $table->addUpdatedWhere('dosmiley', 2, '=1');
235
-        $table->addUpdatedWhere('dosmiley', 1, '=0');
236
-        $table->addUpdatedWhere('dosmiley', 0, '=2');
234
+		$table->addUpdatedWhere('dosmiley', 2, '=1');
235
+		$table->addUpdatedWhere('dosmiley', 1, '=0');
236
+		$table->addUpdatedWhere('dosmiley', 0, '=2');
237 237
 
238
-        $table->addUpdatedWhere('doxcode', 2, '=1');
239
-        $table->addUpdatedWhere('doxcode', 1, '=0');
240
-        $table->addUpdatedWhere('doxcode', 0, '=2');
238
+		$table->addUpdatedWhere('doxcode', 2, '=1');
239
+		$table->addUpdatedWhere('doxcode', 1, '=0');
240
+		$table->addUpdatedWhere('doxcode', 0, '=2');
241 241
 
242
-        $table->addUpdatedWhere('doimage', 2, '=1');
243
-        $table->addUpdatedWhere('doimage', 1, '=0');
244
-        $table->addUpdatedWhere('doimage', 0, '=2');
245
-        $ret = $dbupdater->updateTable($table);
246
-    }
242
+		$table->addUpdatedWhere('doimage', 2, '=1');
243
+		$table->addUpdatedWhere('doimage', 1, '=0');
244
+		$table->addUpdatedWhere('doimage', 0, '=2');
245
+		$ret = $dbupdater->updateTable($table);
246
+	}
247 247
 
248
-    return $ret;
248
+	return $ret;
249 249
 }
250 250
 
251 251
 /**
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
  */
259 259
 function update_table($new_fields, $existing_fields, &$table)
260 260
 {
261
-    foreach ($new_fields as $field => $fieldinfo) {
262
-        $type = $fieldinfo['Type'];
263
-        if (!in_array($field, array_keys($existing_fields))) {
264
-            //Add field as it is missing
265
-            $table->addNewField($field, $type);
266
-            //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267
-            //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268
-        } elseif ($existing_fields[$field] != $type) {
269
-            $table->addAlteredField($field, $field . ' ' . $type);
270
-            // check $fields[$field]['type'] for things like "int(10) unsigned"
271
-            //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272
-            //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
273
-        } else {
274
-            //echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br>";
275
-        }
276
-    }
261
+	foreach ($new_fields as $field => $fieldinfo) {
262
+		$type = $fieldinfo['Type'];
263
+		if (!in_array($field, array_keys($existing_fields))) {
264
+			//Add field as it is missing
265
+			$table->addNewField($field, $type);
266
+			//$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267
+			//echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268
+		} elseif ($existing_fields[$field] != $type) {
269
+			$table->addAlteredField($field, $field . ' ' . $type);
270
+			// check $fields[$field]['type'] for things like "int(10) unsigned"
271
+			//$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272
+			//echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
273
+		} else {
274
+			//echo $field." <FONT COLOR='#0033FF'>Uptodate</FONT><br>";
275
+		}
276
+	}
277 277
 }
278 278
 
279 279
 /**
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function get_table_info($table, $default_fields)
288 288
 {
289
-    global $xoopsDB;
290
-    $result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
291
-    while ($existing_field = $xoopsDB->fetchArray($result)) {
292
-        $fields[$existing_field['Field']] = $existing_field['Type'];
293
-        if ('YES' !== $existing_field['Null']) {
294
-            $fields[$existing_field['Field']] .= ' NOT NULL';
295
-        }
296
-        if ($existing_field['Extra']) {
297
-            $fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
298
-        }
299
-        if ($default_fields[$existing_field['Field']]['Default']) {
300
-            $fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
301
-        }
302
-    }
289
+	global $xoopsDB;
290
+	$result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
291
+	while ($existing_field = $xoopsDB->fetchArray($result)) {
292
+		$fields[$existing_field['Field']] = $existing_field['Type'];
293
+		if ('YES' !== $existing_field['Null']) {
294
+			$fields[$existing_field['Field']] .= ' NOT NULL';
295
+		}
296
+		if ($existing_field['Extra']) {
297
+			$fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
298
+		}
299
+		if ($default_fields[$existing_field['Field']]['Default']) {
300
+			$fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
301
+		}
302
+	}
303 303
 
304
-    return $fields;
304
+	return $fields;
305 305
 }
306 306
 
307 307
 /**
@@ -315,60 +315,60 @@  discard block
 block discarded – undo
315 315
  */
316 316
 function rename_fields(&$table, $renamed_fields, &$fields, $new_fields)
317 317
 {
318
-    foreach (array_keys($fields) as $field) {
319
-        if (in_array($field, array_keys($renamed_fields))) {
320
-            $new_field_name = $renamed_fields[$field];
321
-            $new_field_type = $new_fields[$new_field_name]['Type'];
322
-            $table->addAltered($field, $new_field_name . ' ' . $new_field_type);
323
-            //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324
-            //echo $field." Renamed to ".$new_field_name."<br>";
325
-            $fields[$new_field_name] = $new_field_type;
326
-        }
327
-    }
328
-    //return $fields;
318
+	foreach (array_keys($fields) as $field) {
319
+		if (in_array($field, array_keys($renamed_fields))) {
320
+			$new_field_name = $renamed_fields[$field];
321
+			$new_field_type = $new_fields[$new_field_name]['Type'];
322
+			$table->addAltered($field, $new_field_name . ' ' . $new_field_type);
323
+			//$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324
+			//echo $field." Renamed to ".$new_field_name."<br>";
325
+			$fields[$new_field_name] = $new_field_type;
326
+		}
327
+	}
328
+	//return $fields;
329 329
 }
330 330
 
331 331
 $op = isset($_REQUEST['op']) ? (int)$_REQUEST['op'] : 0;
332 332
 switch ($op) {
333
-    case 1:
334
-        // Make sure that nohtml is properly changed to dohtml
335
-        invert_nohtm_dohtml_values();
336
-        // Ensure that the proper tables are present
337
-        update_tables_to_300();
338
-        // Import data from MyDownloads
339
-        import_mydownloads_to_wfdownloads();
340
-        break;
333
+	case 1:
334
+		// Make sure that nohtml is properly changed to dohtml
335
+		invert_nohtm_dohtml_values();
336
+		// Ensure that the proper tables are present
337
+		update_tables_to_300();
338
+		// Import data from MyDownloads
339
+		import_mydownloads_to_wfdownloads();
340
+		break;
341 341
 
342
-    case 2:
343
-        // Update WF-Downloads
344
-        $log = invert_nohtm_dohtml_values();
345
-        update_tables_to_300();
346
-        break;
342
+	case 2:
343
+		// Update WF-Downloads
344
+		$log = invert_nohtm_dohtml_values();
345
+		update_tables_to_300();
346
+		break;
347 347
 
348
-    default:
349
-        //ask what to do
350
-        include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
351
-        $form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
348
+	default:
349
+		//ask what to do
350
+		include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
351
+		$form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
352 352
 
353
-        //Is MyDownloads installed?
354
-        /** @var XoopsModuleHandler $moduleHandler */
355
-        $moduleHandler     = xoops_getHandler('module');
356
-        $mydownloadsModule = $moduleHandler->getByDirname('mydownloads');
357
-        if (is_object($mydownloadsModule)) {
358
-            $mydownloadsButton = new XoopsFormButton('Import data from MyDownloads', 'myd_button', 'Import', 'submit');
359
-            $mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'");
360
-            $form->addElement($mydownloadsButton);
361
-        }
353
+		//Is MyDownloads installed?
354
+		/** @var XoopsModuleHandler $moduleHandler */
355
+		$moduleHandler     = xoops_getHandler('module');
356
+		$mydownloadsModule = $moduleHandler->getByDirname('mydownloads');
357
+		if (is_object($mydownloadsModule)) {
358
+			$mydownloadsButton = new XoopsFormButton('Import data from MyDownloads', 'myd_button', 'Import', 'submit');
359
+			$mydownloadsButton->setExtra("onclick='document.forms.form.op.value=\"1\"'");
360
+			$form->addElement($mydownloadsButton);
361
+		}
362 362
 
363
-        if (!wfdownloads_TableExists('wfdownloads_meta')) {
364
-            $updateButton = new XoopsFormButton('Update WF-Downloads', 'upd_button', 'Update', 'submit');
365
-            $updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'");
366
-            $form->addElement($updateButton);
367
-        }
363
+		if (!wfdownloads_TableExists('wfdownloads_meta')) {
364
+			$updateButton = new XoopsFormButton('Update WF-Downloads', 'upd_button', 'Update', 'submit');
365
+			$updateButton->setExtra("onclick='document.forms.form.op.value=\"2\"'");
366
+			$form->addElement($updateButton);
367
+		}
368 368
 
369
-        $form->addElement(new XoopsFormHidden('op', 0));
370
-        $form->display();
371
-        break;
369
+		$form->addElement(new XoopsFormHidden('op', 0));
370
+		$form->display();
371
+		break;
372 372
 }
373 373
 //wfdownloads_modFooter();
374 374
 //xoops_cp_footer();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * Licence: GNU
8 8
  */
9 9
 
10
-require_once __DIR__ . '/admin_header.php';
11
-require_once SMARTCONTENT_ROOT_PATH . 'class/dbupdater.php';
10
+require_once __DIR__.'/admin_header.php';
11
+require_once SMARTCONTENT_ROOT_PATH.'class/dbupdater.php';
12 12
 
13 13
 smartcontent_xoops_cp_header();
14 14
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     $ret = [];
208 208
     global $xoopsDB;
209 209
     $catHandler = xoops_getModuleHandler('category', 'wfdownloads');
210
-    $result     = $xoopsDB->query('SHOW COLUMNS FROM ' . $catHandler->table);
210
+    $result     = $xoopsDB->query('SHOW COLUMNS FROM '.$catHandler->table);
211 211
     while ($existing_field = $xoopsDB->fetchArray($result)) {
212 212
         $fields[$existing_field['field']] = $existing_field['type'];
213 213
     }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             //$xoopsDB->query("ALTER TABLE ".$table." ADD ".$field." ".$type);
267 267
             //echo $field."(".$type.") <FONT COLOR='##22DD51'>Added</FONT><br>";
268 268
         } elseif ($existing_fields[$field] != $type) {
269
-            $table->addAlteredField($field, $field . ' ' . $type);
269
+            $table->addAlteredField($field, $field.' '.$type);
270 270
             // check $fields[$field]['type'] for things like "int(10) unsigned"
271 271
             //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$field." ".$type);
272 272
             //echo $field." <FONT COLOR='#FF6600'>Changed to</FONT> ".$type."<br>";
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 function get_table_info($table, $default_fields)
288 288
 {
289 289
     global $xoopsDB;
290
-    $result = $xoopsDB->query('SHOW COLUMNS FROM ' . $table);
290
+    $result = $xoopsDB->query('SHOW COLUMNS FROM '.$table);
291 291
     while ($existing_field = $xoopsDB->fetchArray($result)) {
292 292
         $fields[$existing_field['Field']] = $existing_field['Type'];
293 293
         if ('YES' !== $existing_field['Null']) {
294 294
             $fields[$existing_field['Field']] .= ' NOT NULL';
295 295
         }
296 296
         if ($existing_field['Extra']) {
297
-            $fields[$existing_field['Field']] .= ' ' . $existing_field['Extra'];
297
+            $fields[$existing_field['Field']] .= ' '.$existing_field['Extra'];
298 298
         }
299 299
         if ($default_fields[$existing_field['Field']]['Default']) {
300
-            $fields[$existing_field['Field']] .= " default '" . $existing_field['Default'] . "'";
300
+            $fields[$existing_field['Field']] .= " default '".$existing_field['Default']."'";
301 301
         }
302 302
     }
303 303
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
         if (in_array($field, array_keys($renamed_fields))) {
320 320
             $new_field_name = $renamed_fields[$field];
321 321
             $new_field_type = $new_fields[$new_field_name]['Type'];
322
-            $table->addAltered($field, $new_field_name . ' ' . $new_field_type);
322
+            $table->addAltered($field, $new_field_name.' '.$new_field_type);
323 323
             //$xoopsDB->query("ALTER TABLE ".$table." CHANGE ".$field." ".$new_field_name." ".$new_field_type);
324 324
             //echo $field." Renamed to ".$new_field_name."<br>";
325 325
             $fields[$new_field_name] = $new_field_type;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     //return $fields;
329 329
 }
330 330
 
331
-$op = isset($_REQUEST['op']) ? (int)$_REQUEST['op'] : 0;
331
+$op = isset($_REQUEST['op']) ? (int) $_REQUEST['op'] : 0;
332 332
 switch ($op) {
333 333
     case 1:
334 334
         // Make sure that nohtml is properly changed to dohtml
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
     default:
349 349
         //ask what to do
350
-        include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
350
+        include XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
351 351
         $form = new XoopsThemeForm('Upgrade WF-Downloads', 'form', $_SERVER['REQUEST_URI']);
352 352
 
353 353
         //Is MyDownloads installed?
@@ -372,4 +372,4 @@  discard block
 block discarded – undo
372 372
 }
373 373
 //wfdownloads_modFooter();
374 374
 //xoops_cp_footer();
375
-require_once __DIR__ . '/admin_footer.php';
375
+require_once __DIR__.'/admin_footer.php';
Please login to merge, or discard this patch.