Completed
Push — master ( 2d4977...3189d6 )
by Michael
10:50
created
class/urllink.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,22 +8,22 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class SmartobjectUrlLink extends SmartobjectBasedUrl
10 10
 {
11
-    /**
12
-     * SmartobjectUrlLink constructor.
13
-     */
14
-    public function __construct()
15
-    {
16
-        parent::__construct();
17
-        $this->quickInitVar('urllinkid', XOBJ_DTYPE_TXTBOX, true);
18
-        $this->quickInitVar('target', XOBJ_DTYPE_TXTBOX, true);
11
+	/**
12
+	 * SmartobjectUrlLink constructor.
13
+	 */
14
+	public function __construct()
15
+	{
16
+		parent::__construct();
17
+		$this->quickInitVar('urllinkid', XOBJ_DTYPE_TXTBOX, true);
18
+		$this->quickInitVar('target', XOBJ_DTYPE_TXTBOX, true);
19 19
 
20
-        $this->setControl('target', array(
21
-            'options' => array(
22
-                '_self'  => _CO_SOBJECT_URLLINK_SELF,
23
-                '_blank' => _CO_SOBJECT_URLLINK_BLANK
24
-            )
25
-        ));
26
-    }
20
+		$this->setControl('target', array(
21
+			'options' => array(
22
+				'_self'  => _CO_SOBJECT_URLLINK_SELF,
23
+				'_blank' => _CO_SOBJECT_URLLINK_BLANK
24
+			)
25
+		));
26
+	}
27 27
 }
28 28
 
29 29
 /**
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class SmartobjectUrlLinkHandler extends SmartPersistableObjectHandler
33 33
 {
34
-    /**
35
-     * SmartobjectUrlLinkHandler constructor.
36
-     * @param object|XoopsDatabase $db
37
-     */
38
-    public function __construct($db)
39
-    {
40
-        parent::__construct($db, 'urllink', 'urllinkid', 'caption', 'desc', 'smartobject');
41
-    }
34
+	/**
35
+	 * SmartobjectUrlLinkHandler constructor.
36
+	 * @param object|XoopsDatabase $db
37
+	 */
38
+	public function __construct($db)
39
+	{
40
+		parent::__construct($db, 'urllink', 'urllinkid', 'caption', 'desc', 'smartobject');
41
+	}
42 42
 }
Please login to merge, or discard this patch.
class/smartprinterfriendly.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@
 block discarded – undo
15 15
  */
16 16
 class SmartPrinterFriendly
17 17
 {
18
-    public $_title;
19
-    public $_dsc;
20
-    public $_content;
21
-    public $_tpl;
22
-    public $_pageTitle = false;
23
-    public $_width     = 680;
18
+	public $_title;
19
+	public $_dsc;
20
+	public $_content;
21
+	public $_tpl;
22
+	public $_pageTitle = false;
23
+	public $_width     = 680;
24 24
 
25
-    /**
26
-     * SmartPrinterFriendly constructor.
27
-     * @param      $content
28
-     * @param bool $title
29
-     * @param bool $dsc
30
-     */
31
-    public function __construct($content, $title = false, $dsc = false)
32
-    {
33
-        $this->_title   = $title;
34
-        $this->_dsc     = $dsc;
35
-        $this->_content = $content;
36
-    }
25
+	/**
26
+	 * SmartPrinterFriendly constructor.
27
+	 * @param      $content
28
+	 * @param bool $title
29
+	 * @param bool $dsc
30
+	 */
31
+	public function __construct($content, $title = false, $dsc = false)
32
+	{
33
+		$this->_title   = $title;
34
+		$this->_dsc     = $dsc;
35
+		$this->_content = $content;
36
+	}
37 37
 
38
-    public function render()
39
-    {
40
-        /**
41
-         * @todo move the output to a template
42
-         * @todo make the output XHTML compliant
43
-         */
38
+	public function render()
39
+	{
40
+		/**
41
+		 * @todo move the output to a template
42
+		 * @todo make the output XHTML compliant
43
+		 */
44 44
 
45
-        include_once XOOPS_ROOT_PATH . '/class/template.php';
45
+		include_once XOOPS_ROOT_PATH . '/class/template.php';
46 46
 
47
-        $this->_tpl = new XoopsTpl();
47
+		$this->_tpl = new XoopsTpl();
48 48
 
49
-        $this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title);
50
-        $this->_tpl->assign('smartobject_print_title', $this->_title);
51
-        $this->_tpl->assign('smartobject_print_dsc', $this->_dsc);
52
-        $this->_tpl->assign('smartobject_print_content', $this->_content);
53
-        $this->_tpl->assign('smartobject_print_width', $this->_width);
49
+		$this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title);
50
+		$this->_tpl->assign('smartobject_print_title', $this->_title);
51
+		$this->_tpl->assign('smartobject_print_dsc', $this->_dsc);
52
+		$this->_tpl->assign('smartobject_print_content', $this->_content);
53
+		$this->_tpl->assign('smartobject_print_width', $this->_width);
54 54
 
55
-        $current_urls = smart_getCurrentUrls();
56
-        $current_url  = $current_urls['full'];
55
+		$current_urls = smart_getCurrentUrls();
56
+		$current_url  = $current_urls['full'];
57 57
 
58
-        $this->_tpl->assign('smartobject_print_currenturl', $current_url);
59
-        $this->_tpl->assign('smartobject_print_url', $this->url);
58
+		$this->_tpl->assign('smartobject_print_currenturl', $current_url);
59
+		$this->_tpl->assign('smartobject_print_url', $this->url);
60 60
 
61
-        $this->_tpl->display('db:smartobject_print.tpl');
62
-    }
61
+		$this->_tpl->display('db:smartobject_print.tpl');
62
+	}
63 63
 
64
-    /**
65
-     * @param $text
66
-     */
67
-    public function setPageTitle($text)
68
-    {
69
-        $this->_pageTitle = $text;
70
-    }
64
+	/**
65
+	 * @param $text
66
+	 */
67
+	public function setPageTitle($text)
68
+	{
69
+		$this->_pageTitle = $text;
70
+	}
71 71
 
72
-    /**
73
-     * @param $width
74
-     */
75
-    public function setWidth($width)
76
-    {
77
-        $this->_width = $width;
78
-    }
72
+	/**
73
+	 * @param $width
74
+	 */
75
+	public function setWidth($width)
76
+	{
77
+		$this->_width = $width;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
class/smartobjectcategory.php 1 patch
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -18,123 +18,123 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class SmartobjectCategory extends SmartSeoObject
20 20
 {
21
-    public $_categoryPath;
22
-
23
-    /**
24
-     * SmartobjectCategory constructor.
25
-     */
26
-    public function __construct()
27
-    {
28
-        $this->initVar('categoryid', XOBJ_DTYPE_INT, '', true);
29
-        $this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC);
30
-        $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC);
31
-        $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC);
32
-        $this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC);
33
-
34
-        $this->initCommonVar('doxcode');
35
-
36
-        $this->setControl('image', array('name' => 'image'));
37
-        $this->setControl('parentid', array('name' => 'parentcategory'));
38
-        $this->setControl('description', array(
39
-            'name'        => 'textarea',
40
-            'itemHandler' => false,
41
-            'method'      => false,
42
-            'module'      => false,
43
-            'form_editor' => 'default'
44
-        ));
45
-
46
-        // call parent constructor to get SEO fields initiated
47
-        parent::__construct;
48
-    }
49
-
50
-    /**
51
-     * returns a specific variable for the object in a proper format
52
-     *
53
-     * @access public
54
-     * @param  string $key    key of the object's variable to be returned
55
-     * @param  string $format format to use for the output
56
-     * @return mixed  formatted value of the variable
57
-     */
58
-    public function getVar($key, $format = 's')
59
-    {
60
-        if ($format === 's' && in_array($key, array('description', 'image'))) {
61
-            //            return call_user_func(array($this, $key));
62
-            return $this->{$key}();
63
-        }
64
-
65
-        return parent::getVar($key, $format);
66
-    }
67
-
68
-    /**
69
-     * @return string
70
-     */
71
-    public function description()
72
-    {
73
-        return $this->getValueFor('description', false);
74
-    }
75
-
76
-    /**
77
-     * @return bool|mixed
78
-     */
79
-    public function image()
80
-    {
81
-        $ret = $this->getVar('image', 'e');
82
-        if ($ret == '-1') {
83
-            return false;
84
-        } else {
85
-            return $ret;
86
-        }
87
-    }
88
-
89
-    /**
90
-     * @return array
91
-     */
92
-    public function toArray()
93
-    {
94
-        $this->setVar('doxcode', true);
95
-        global $myts;
96
-        $objectArray = parent::toArray();
97
-        if ($objectArray['image']) {
98
-            $objectArray['image'] = $this->getImageDir() . $objectArray['image'];
99
-        }
100
-
101
-        return $objectArray;
102
-    }
103
-
104
-    /**
105
-     * Create the complete path of a category
106
-     *
107
-     * @todo this could be improved as it uses multiple queries
108
-     * @param  bool $withAllLink make all name clickable
109
-     * @param  bool $currentCategory
110
-     * @return string complete path (breadcrumb)
111
-     */
112
-    public function getCategoryPath($withAllLink = true, $currentCategory = false)
113
-    {
114
-        include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
115
-        $controller = new SmartObjectController($this->handler);
116
-
117
-        if (!$this->_categoryPath) {
118
-            if ($withAllLink && !$currentCategory) {
119
-                $ret = $controller->getItemLink($this);
120
-            } else {
121
-                $currentCategory = false;
122
-                $ret             = $this->getVar('name');
123
-            }
124
-            $parentid = $this->getVar('parentid');
125
-            if ($parentid != 0) {
126
-                $parentObj = $this->handler->get($parentid);
127
-                if ($parentObj->isNew()) {
128
-                    exit;
129
-                }
130
-                $parentid = $parentObj->getVar('parentid');
131
-                $ret      = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret;
132
-            }
133
-            $this->_categoryPath = $ret;
134
-        }
135
-
136
-        return $this->_categoryPath;
137
-    }
21
+	public $_categoryPath;
22
+
23
+	/**
24
+	 * SmartobjectCategory constructor.
25
+	 */
26
+	public function __construct()
27
+	{
28
+		$this->initVar('categoryid', XOBJ_DTYPE_INT, '', true);
29
+		$this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC);
30
+		$this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC);
31
+		$this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC);
32
+		$this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC);
33
+
34
+		$this->initCommonVar('doxcode');
35
+
36
+		$this->setControl('image', array('name' => 'image'));
37
+		$this->setControl('parentid', array('name' => 'parentcategory'));
38
+		$this->setControl('description', array(
39
+			'name'        => 'textarea',
40
+			'itemHandler' => false,
41
+			'method'      => false,
42
+			'module'      => false,
43
+			'form_editor' => 'default'
44
+		));
45
+
46
+		// call parent constructor to get SEO fields initiated
47
+		parent::__construct;
48
+	}
49
+
50
+	/**
51
+	 * returns a specific variable for the object in a proper format
52
+	 *
53
+	 * @access public
54
+	 * @param  string $key    key of the object's variable to be returned
55
+	 * @param  string $format format to use for the output
56
+	 * @return mixed  formatted value of the variable
57
+	 */
58
+	public function getVar($key, $format = 's')
59
+	{
60
+		if ($format === 's' && in_array($key, array('description', 'image'))) {
61
+			//            return call_user_func(array($this, $key));
62
+			return $this->{$key}();
63
+		}
64
+
65
+		return parent::getVar($key, $format);
66
+	}
67
+
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function description()
72
+	{
73
+		return $this->getValueFor('description', false);
74
+	}
75
+
76
+	/**
77
+	 * @return bool|mixed
78
+	 */
79
+	public function image()
80
+	{
81
+		$ret = $this->getVar('image', 'e');
82
+		if ($ret == '-1') {
83
+			return false;
84
+		} else {
85
+			return $ret;
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * @return array
91
+	 */
92
+	public function toArray()
93
+	{
94
+		$this->setVar('doxcode', true);
95
+		global $myts;
96
+		$objectArray = parent::toArray();
97
+		if ($objectArray['image']) {
98
+			$objectArray['image'] = $this->getImageDir() . $objectArray['image'];
99
+		}
100
+
101
+		return $objectArray;
102
+	}
103
+
104
+	/**
105
+	 * Create the complete path of a category
106
+	 *
107
+	 * @todo this could be improved as it uses multiple queries
108
+	 * @param  bool $withAllLink make all name clickable
109
+	 * @param  bool $currentCategory
110
+	 * @return string complete path (breadcrumb)
111
+	 */
112
+	public function getCategoryPath($withAllLink = true, $currentCategory = false)
113
+	{
114
+		include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
115
+		$controller = new SmartObjectController($this->handler);
116
+
117
+		if (!$this->_categoryPath) {
118
+			if ($withAllLink && !$currentCategory) {
119
+				$ret = $controller->getItemLink($this);
120
+			} else {
121
+				$currentCategory = false;
122
+				$ret             = $this->getVar('name');
123
+			}
124
+			$parentid = $this->getVar('parentid');
125
+			if ($parentid != 0) {
126
+				$parentObj = $this->handler->get($parentid);
127
+				if ($parentObj->isNew()) {
128
+					exit;
129
+				}
130
+				$parentid = $parentObj->getVar('parentid');
131
+				$ret      = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret;
132
+			}
133
+			$this->_categoryPath = $ret;
134
+		}
135
+
136
+		return $this->_categoryPath;
137
+	}
138 138
 }
139 139
 
140 140
 /**
@@ -142,91 +142,91 @@  discard block
 block discarded – undo
142 142
  */
143 143
 class SmartobjectCategoryHandler extends SmartPersistableObjectHandler
144 144
 {
145
-    public $allCategoriesObj = false;
146
-    public $_allCategoriesId = false;
147
-
148
-    /**
149
-     * SmartobjectCategoryHandler constructor.
150
-     * @param object|XoopsDatabase $db
151
-     * @param                      $modulename
152
-     */
153
-    public function __construct($db, $modulename)
154
-    {
155
-        parent::__construct($db, 'category', 'categoryid', 'name', 'description', $modulename);
156
-    }
157
-
158
-    /**
159
-     * @param  int    $parentid
160
-     * @param  bool   $perm_name
161
-     * @param  string $sort
162
-     * @param  string $order
163
-     * @return array|bool
164
-     */
165
-    public function getAllCategoriesArray($parentid = 0, $perm_name = false, $sort = 'parentid', $order = 'ASC')
166
-    {
167
-        if (!$this->allCategoriesObj) {
168
-            $criteria = new CriteriaCompo();
169
-            $criteria->setSort($sort);
170
-            $criteria->setOrder($order);
171
-            global $xoopsUser;
172
-            $userIsAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin();
173
-
174
-            if ($perm_name && !$userIsAdmin) {
175
-                if (!$this->setGrantedObjectsCriteria($criteria, $perm_name)) {
176
-                    return false;
177
-                }
178
-            }
179
-
180
-            $this->allCategoriesObj = $this->getObjects($criteria, 'parentid');
181
-        }
182
-
183
-        $ret = array();
184
-        if (isset($this->allCategoriesObj[$parentid])) {
185
-            foreach ($this->allCategoriesObj[$parentid] as $categoryid => $categoryObj) {
186
-                $ret[$categoryid]['self'] = $categoryObj->toArray();
187
-                if (isset($this->allCategoriesObj[$categoryid])) {
188
-                    $ret[$categoryid]['sub']          = $this->getAllCategoriesArray($categoryid);
189
-                    $ret[$categoryid]['subcatscount'] = count($ret[$categoryid]['sub']);
190
-                }
191
-            }
192
-        }
193
-
194
-        return $ret;
195
-    }
196
-
197
-    /**
198
-     * @param       $parentid
199
-     * @param  bool $asString
200
-     * @return array|string
201
-     */
202
-    public function getParentIds($parentid, $asString = true)
203
-    {
204
-        if (!$this->allCategoriesId) {
205
-            $ret = array();
206
-            $sql = 'SELECT categoryid, parentid FROM ' . $this->table . ' AS ' . $this->_itemname . ' ORDER BY parentid';
207
-
208
-            $result = $this->db->query($sql);
209
-
210
-            if (!$result) {
211
-                return $ret;
212
-            }
213
-
214
-            while ($myrow = $this->db->fetchArray($result)) {
215
-                $this->allCategoriesId[$myrow['categoryid']] = $myrow['parentid'];
216
-            }
217
-        }
218
-
219
-        $retArray = array($parentid);
220
-        while ($parentid != 0) {
221
-            $parentid = $this->allCategoriesId[$parentid];
222
-            if ($parentid != 0) {
223
-                $retArray[] = $parentid;
224
-            }
225
-        }
226
-        if ($asString) {
227
-            return implode(', ', $retArray);
228
-        } else {
229
-            return $retArray;
230
-        }
231
-    }
145
+	public $allCategoriesObj = false;
146
+	public $_allCategoriesId = false;
147
+
148
+	/**
149
+	 * SmartobjectCategoryHandler constructor.
150
+	 * @param object|XoopsDatabase $db
151
+	 * @param                      $modulename
152
+	 */
153
+	public function __construct($db, $modulename)
154
+	{
155
+		parent::__construct($db, 'category', 'categoryid', 'name', 'description', $modulename);
156
+	}
157
+
158
+	/**
159
+	 * @param  int    $parentid
160
+	 * @param  bool   $perm_name
161
+	 * @param  string $sort
162
+	 * @param  string $order
163
+	 * @return array|bool
164
+	 */
165
+	public function getAllCategoriesArray($parentid = 0, $perm_name = false, $sort = 'parentid', $order = 'ASC')
166
+	{
167
+		if (!$this->allCategoriesObj) {
168
+			$criteria = new CriteriaCompo();
169
+			$criteria->setSort($sort);
170
+			$criteria->setOrder($order);
171
+			global $xoopsUser;
172
+			$userIsAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin();
173
+
174
+			if ($perm_name && !$userIsAdmin) {
175
+				if (!$this->setGrantedObjectsCriteria($criteria, $perm_name)) {
176
+					return false;
177
+				}
178
+			}
179
+
180
+			$this->allCategoriesObj = $this->getObjects($criteria, 'parentid');
181
+		}
182
+
183
+		$ret = array();
184
+		if (isset($this->allCategoriesObj[$parentid])) {
185
+			foreach ($this->allCategoriesObj[$parentid] as $categoryid => $categoryObj) {
186
+				$ret[$categoryid]['self'] = $categoryObj->toArray();
187
+				if (isset($this->allCategoriesObj[$categoryid])) {
188
+					$ret[$categoryid]['sub']          = $this->getAllCategoriesArray($categoryid);
189
+					$ret[$categoryid]['subcatscount'] = count($ret[$categoryid]['sub']);
190
+				}
191
+			}
192
+		}
193
+
194
+		return $ret;
195
+	}
196
+
197
+	/**
198
+	 * @param       $parentid
199
+	 * @param  bool $asString
200
+	 * @return array|string
201
+	 */
202
+	public function getParentIds($parentid, $asString = true)
203
+	{
204
+		if (!$this->allCategoriesId) {
205
+			$ret = array();
206
+			$sql = 'SELECT categoryid, parentid FROM ' . $this->table . ' AS ' . $this->_itemname . ' ORDER BY parentid';
207
+
208
+			$result = $this->db->query($sql);
209
+
210
+			if (!$result) {
211
+				return $ret;
212
+			}
213
+
214
+			while ($myrow = $this->db->fetchArray($result)) {
215
+				$this->allCategoriesId[$myrow['categoryid']] = $myrow['parentid'];
216
+			}
217
+		}
218
+
219
+		$retArray = array($parentid);
220
+		while ($parentid != 0) {
221
+			$parentid = $this->allCategoriesId[$parentid];
222
+			if ($parentid != 0) {
223
+				$retArray[] = $parentid;
224
+			}
225
+		}
226
+		if ($asString) {
227
+			return implode(', ', $retArray);
228
+		} else {
229
+			return $retArray;
230
+		}
231
+	}
232 232
 }
Please login to merge, or discard this patch.
class/smartobjectsregistry.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -13,169 +13,169 @@
 block discarded – undo
13 13
  */
14 14
 class SmartObjectsRegistry
15 15
 {
16
-    public $_registryArray;
16
+	public $_registryArray;
17 17
 
18
-    /**
19
-     * Access the only instance of this class
20
-     *
21
-     * @return object
22
-     *
23
-     * @static
24
-     * @staticvar   object
25
-     */
26
-    public function getInstance()
27
-    {
28
-        static $instance;
29
-        if (!isset($instance)) {
30
-            $instance = new SmartObjectsRegistry();
31
-        }
18
+	/**
19
+	 * Access the only instance of this class
20
+	 *
21
+	 * @return object
22
+	 *
23
+	 * @static
24
+	 * @staticvar   object
25
+	 */
26
+	public function getInstance()
27
+	{
28
+		static $instance;
29
+		if (!isset($instance)) {
30
+			$instance = new SmartObjectsRegistry();
31
+		}
32 32
 
33
-        return $instance;
34
-    }
33
+		return $instance;
34
+	}
35 35
 
36
-    /**
37
-     * Adding objects to the registry
38
-     *
39
-     * @param  SmartPersistableObjectHandler $handler  of the objects to add
40
-     * @param  bool|CriteriaCompo            $criteria to pass to the getObjects method of the handler (with id_as_key)
41
-     * @return FALSE                         if an error occured
42
-     */
43
-    public function addObjectsFromHandler(&$handler, $criteria = false)
44
-    {
45
-        if (method_exists($handler, 'getObjects')) {
46
-            $objects                                                                     = $handler->getObjects($criteria, true);
47
-            $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects;
36
+	/**
37
+	 * Adding objects to the registry
38
+	 *
39
+	 * @param  SmartPersistableObjectHandler $handler  of the objects to add
40
+	 * @param  bool|CriteriaCompo            $criteria to pass to the getObjects method of the handler (with id_as_key)
41
+	 * @return FALSE                         if an error occured
42
+	 */
43
+	public function addObjectsFromHandler(&$handler, $criteria = false)
44
+	{
45
+		if (method_exists($handler, 'getObjects')) {
46
+			$objects                                                                     = $handler->getObjects($criteria, true);
47
+			$this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects;
48 48
 
49
-            return $objects;
50
-        } else {
51
-            return false;
52
-        }
53
-    }
49
+			return $objects;
50
+		} else {
51
+			return false;
52
+		}
53
+	}
54 54
 
55
-    /**
56
-     * Adding objects to the registry from an item name
57
-     * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
-     *
59
-     * @param  string             $item       name of the item
60
-     * @param  bool|string        $modulename name of the module
61
-     * @param  bool|CriteriaCompo $criteria   to pass to the getObjects method of the handler (with id_as_key)
62
-     * @return FALSE              if an error occured
63
-     */
64
-    public function addObjectsFromItemName($item, $modulename = false, $criteria = false)
65
-    {
66
-        if (!$modulename) {
67
-            global $xoopsModule;
68
-            if (!is_object($xoopsModule)) {
69
-                return false;
70
-            } else {
71
-                $modulename = $xoopsModule->dirname();
72
-            }
73
-        }
74
-        $objectHandler = xoops_getModuleHandler($item, $modulename);
55
+	/**
56
+	 * Adding objects to the registry from an item name
57
+	 * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
+	 *
59
+	 * @param  string             $item       name of the item
60
+	 * @param  bool|string        $modulename name of the module
61
+	 * @param  bool|CriteriaCompo $criteria   to pass to the getObjects method of the handler (with id_as_key)
62
+	 * @return FALSE              if an error occured
63
+	 */
64
+	public function addObjectsFromItemName($item, $modulename = false, $criteria = false)
65
+	{
66
+		if (!$modulename) {
67
+			global $xoopsModule;
68
+			if (!is_object($xoopsModule)) {
69
+				return false;
70
+			} else {
71
+				$modulename = $xoopsModule->dirname();
72
+			}
73
+		}
74
+		$objectHandler = xoops_getModuleHandler($item, $modulename);
75 75
 
76
-        if (method_exists($objectHandler, 'getObjects')) {
77
-            $objects                                                                                   = $objectHandler->getObjects($criteria, true);
78
-            $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects;
76
+		if (method_exists($objectHandler, 'getObjects')) {
77
+			$objects                                                                                   = $objectHandler->getObjects($criteria, true);
78
+			$this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects;
79 79
 
80
-            return $objects;
81
-        } else {
82
-            return false;
83
-        }
84
-    }
80
+			return $objects;
81
+		} else {
82
+			return false;
83
+		}
84
+	}
85 85
 
86
-    /**
87
-     * Fetching objects from the registry
88
-     *
89
-     * @param string $itemname
90
-     * @param string $modulename
91
-     *
92
-     * @return the requested objects or FALSE if they don't exists in the registry
93
-     */
94
-    public function getObjects($itemname, $modulename)
95
-    {
96
-        if (!$modulename) {
97
-            global $xoopsModule;
98
-            if (!is_object($xoopsModule)) {
99
-                return false;
100
-            } else {
101
-                $modulename = $xoopsModule->dirname();
102
-            }
103
-        }
104
-        if (isset($this->_registryArray['objects'][$modulename][$itemname])) {
105
-            return $this->_registryArray['objects'][$modulename][$itemname];
106
-        } else {
107
-            // if they were not in registry, let's fetch them and add them to the reigistry
108
-            $moduleHandler = xoops_getModuleHandler($itemname, $modulename);
109
-            if (method_exists($moduleHandler, 'getObjects')) {
110
-                $objects = $moduleHandler->getObjects();
111
-            }
112
-            $this->_registryArray['objects'][$modulename][$itemname] = $objects;
86
+	/**
87
+	 * Fetching objects from the registry
88
+	 *
89
+	 * @param string $itemname
90
+	 * @param string $modulename
91
+	 *
92
+	 * @return the requested objects or FALSE if they don't exists in the registry
93
+	 */
94
+	public function getObjects($itemname, $modulename)
95
+	{
96
+		if (!$modulename) {
97
+			global $xoopsModule;
98
+			if (!is_object($xoopsModule)) {
99
+				return false;
100
+			} else {
101
+				$modulename = $xoopsModule->dirname();
102
+			}
103
+		}
104
+		if (isset($this->_registryArray['objects'][$modulename][$itemname])) {
105
+			return $this->_registryArray['objects'][$modulename][$itemname];
106
+		} else {
107
+			// if they were not in registry, let's fetch them and add them to the reigistry
108
+			$moduleHandler = xoops_getModuleHandler($itemname, $modulename);
109
+			if (method_exists($moduleHandler, 'getObjects')) {
110
+				$objects = $moduleHandler->getObjects();
111
+			}
112
+			$this->_registryArray['objects'][$modulename][$itemname] = $objects;
113 113
 
114
-            return $objects;
115
-        }
116
-    }
114
+			return $objects;
115
+		}
116
+	}
117 117
 
118
-    /**
119
-     * Fetching objects from the registry, as a list: objectid => identifier
120
-     *
121
-     * @param string $itemname
122
-     * @param string $modulename
123
-     *
124
-     * @return the requested objects or FALSE if they don't exists in the registry
125
-     */
126
-    public function getList($itemname, $modulename)
127
-    {
128
-        if (!$modulename) {
129
-            global $xoopsModule;
130
-            if (!is_object($xoopsModule)) {
131
-                return false;
132
-            } else {
133
-                $modulename = $xoopsModule->dirname();
134
-            }
135
-        }
136
-        if (isset($this->_registryArray['list'][$modulename][$itemname])) {
137
-            return $this->_registryArray['list'][$modulename][$itemname];
138
-        } else {
139
-            // if they were not in registry, let's fetch them and add them to the reigistry
140
-            $moduleHandler = xoops_getModuleHandler($itemname, $modulename);
141
-            if (method_exists($moduleHandler, 'getList')) {
142
-                $objects = $moduleHandler->getList();
143
-            }
144
-            $this->_registryArray['list'][$modulename][$itemname] = $objects;
118
+	/**
119
+	 * Fetching objects from the registry, as a list: objectid => identifier
120
+	 *
121
+	 * @param string $itemname
122
+	 * @param string $modulename
123
+	 *
124
+	 * @return the requested objects or FALSE if they don't exists in the registry
125
+	 */
126
+	public function getList($itemname, $modulename)
127
+	{
128
+		if (!$modulename) {
129
+			global $xoopsModule;
130
+			if (!is_object($xoopsModule)) {
131
+				return false;
132
+			} else {
133
+				$modulename = $xoopsModule->dirname();
134
+			}
135
+		}
136
+		if (isset($this->_registryArray['list'][$modulename][$itemname])) {
137
+			return $this->_registryArray['list'][$modulename][$itemname];
138
+		} else {
139
+			// if they were not in registry, let's fetch them and add them to the reigistry
140
+			$moduleHandler = xoops_getModuleHandler($itemname, $modulename);
141
+			if (method_exists($moduleHandler, 'getList')) {
142
+				$objects = $moduleHandler->getList();
143
+			}
144
+			$this->_registryArray['list'][$modulename][$itemname] = $objects;
145 145
 
146
-            return $objects;
147
-        }
148
-    }
146
+			return $objects;
147
+		}
148
+	}
149 149
 
150
-    /**
151
-     * Retreive a single object
152
-     *
153
-     * @param string $itemname
154
-     * @param string $key
155
-     *
156
-     * @param  bool  $modulename
157
-     * @return the  requestd object or FALSE if they don't exists in the registry
158
-     */
159
-    public function getSingleObject($itemname, $key, $modulename = false)
160
-    {
161
-        if (!$modulename) {
162
-            global $xoopsModule;
163
-            if (!is_object($xoopsModule)) {
164
-                return false;
165
-            } else {
166
-                $modulename = $xoopsModule->dirname();
167
-            }
168
-        }
169
-        if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) {
170
-            return $this->_registryArray['objects'][$modulename][$itemname][$key];
171
-        } else {
172
-            $objectHandler = xoops_getModuleHandler($itemname, $modulename);
173
-            $object        = $objectHandler->get($key);
174
-            if (!$object->isNew()) {
175
-                return $object;
176
-            } else {
177
-                return false;
178
-            }
179
-        }
180
-    }
150
+	/**
151
+	 * Retreive a single object
152
+	 *
153
+	 * @param string $itemname
154
+	 * @param string $key
155
+	 *
156
+	 * @param  bool  $modulename
157
+	 * @return the  requestd object or FALSE if they don't exists in the registry
158
+	 */
159
+	public function getSingleObject($itemname, $key, $modulename = false)
160
+	{
161
+		if (!$modulename) {
162
+			global $xoopsModule;
163
+			if (!is_object($xoopsModule)) {
164
+				return false;
165
+			} else {
166
+				$modulename = $xoopsModule->dirname();
167
+			}
168
+		}
169
+		if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) {
170
+			return $this->_registryArray['objects'][$modulename][$itemname][$key];
171
+		} else {
172
+			$objectHandler = xoops_getModuleHandler($itemname, $modulename);
173
+			$object        = $objectHandler->get($key);
174
+			if (!$object->isNew()) {
175
+				return $object;
176
+			} else {
177
+				return false;
178
+			}
179
+		}
180
+	}
181 181
 }
Please login to merge, or discard this patch.
class/smartexport.php 1 patch
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Contains the classes for easily exporting data
4
- *
5
- * @license GNU
6
- * @author  marcan <[email protected]>
7
- * @link    http://www.smartfactory.ca The SmartFactory
8
- * @package SmartObject
9
- */
3
+	 * Contains the classes for easily exporting data
4
+	 *
5
+	 * @license GNU
6
+	 * @author  marcan <[email protected]>
7
+	 * @link    http://www.smartfactory.ca The SmartFactory
8
+	 * @package SmartObject
9
+	 */
10 10
 
11 11
 /**
12 12
  * SmartObjectExport class
@@ -19,110 +19,110 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class SmartObjectExport
21 21
 {
22
-    public $handler;
23
-    public $criteria;
24
-    public $fields;
25
-    public $format;
26
-    public $filename;
27
-    public $filepath;
28
-    public $options;
29
-    public $outputMethods = false;
30
-    public $notDisplayFields;
22
+	public $handler;
23
+	public $criteria;
24
+	public $fields;
25
+	public $format;
26
+	public $filename;
27
+	public $filepath;
28
+	public $options;
29
+	public $outputMethods = false;
30
+	public $notDisplayFields;
31 31
 
32
-    /**
33
-     * Constructor
34
-     *
35
-     * @param object      $objectHandler SmartObjectHandler handling the data we want to export
36
-     * @param object      $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($objectHandler, $criteria = null, $fields = false, $filename = false, $filepath = false, $format = 'csv', $options = false)
44
-    {
45
-        $this->handler          = $objectHandler;
46
-        $this->criteria         = $criteria;
47
-        $this->fields           = $fields;
48
-        $this->filename         = $filename;
49
-        $this->format           = $format;
50
-        $this->options          = $options;
51
-        $this->notDisplayFields = false;
52
-    }
32
+	/**
33
+	 * Constructor
34
+	 *
35
+	 * @param object      $objectHandler SmartObjectHandler handling the data we want to export
36
+	 * @param object      $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($objectHandler, $criteria = null, $fields = false, $filename = false, $filepath = false, $format = 'csv', $options = false)
44
+	{
45
+		$this->handler          = $objectHandler;
46
+		$this->criteria         = $criteria;
47
+		$this->fields           = $fields;
48
+		$this->filename         = $filename;
49
+		$this->format           = $format;
50
+		$this->options          = $options;
51
+		$this->notDisplayFields = false;
52
+	}
53 53
 
54
-    /**
55
-     * Renders the export
56
-     * @param $filename
57
-     */
58
-    public function render($filename)
59
-    {
60
-        $this->filename = $filename;
54
+	/**
55
+	 * Renders the export
56
+	 * @param $filename
57
+	 */
58
+	public function render($filename)
59
+	{
60
+		$this->filename = $filename;
61 61
 
62
-        $objects        = $this->handler->getObjects($this->criteria);
63
-        $rows           = array();
64
-        $columnsHeaders = array();
65
-        $firstObject    = true;
66
-        foreach ($objects as $object) {
67
-            $row = array();
68
-            foreach ($object->vars as $key => $var) {
69
-                if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
70
-                    if ($this->outputMethods && isset($this->outputMethods[$key]) && method_exists($object, $this->outputMethods[$key])) {
71
-                        $method    = $this->outputMethods[$key];
72
-                        $row[$key] = $object->$method();
73
-                    } else {
74
-                        $row[$key] = $object->getVar($key);
75
-                    }
76
-                    if ($firstObject) {
77
-                        // then set the columnsHeaders array as well
78
-                        $columnsHeaders[$key] = $var['form_caption'];
79
-                    }
80
-                }
81
-            }
82
-            $firstObject = false;
83
-            $rows[]      = $row;
84
-            unset($row);
85
-        }
86
-        $data                   = array();
87
-        $data['rows']           = $rows;
88
-        $data['columnsHeaders'] = $columnsHeaders;
89
-        $smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
90
-        $smartExportRenderer->execute();
91
-    }
62
+		$objects        = $this->handler->getObjects($this->criteria);
63
+		$rows           = array();
64
+		$columnsHeaders = array();
65
+		$firstObject    = true;
66
+		foreach ($objects as $object) {
67
+			$row = array();
68
+			foreach ($object->vars as $key => $var) {
69
+				if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) {
70
+					if ($this->outputMethods && isset($this->outputMethods[$key]) && method_exists($object, $this->outputMethods[$key])) {
71
+						$method    = $this->outputMethods[$key];
72
+						$row[$key] = $object->$method();
73
+					} else {
74
+						$row[$key] = $object->getVar($key);
75
+					}
76
+					if ($firstObject) {
77
+						// then set the columnsHeaders array as well
78
+						$columnsHeaders[$key] = $var['form_caption'];
79
+					}
80
+				}
81
+			}
82
+			$firstObject = false;
83
+			$rows[]      = $row;
84
+			unset($row);
85
+		}
86
+		$data                   = array();
87
+		$data['rows']           = $rows;
88
+		$data['columnsHeaders'] = $columnsHeaders;
89
+		$smartExportRenderer    = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options);
90
+		$smartExportRenderer->execute();
91
+	}
92 92
 
93
-    /**
94
-     * Set an array contaning the alternate methods to use instead of the default getVar()
95
-     *
96
-     * $outputMethods array example: 'uid' => 'getUserName'...
97
-     * @param $outputMethods
98
-     */
99
-    public function setOuptutMethods($outputMethods)
100
-    {
101
-        $this->outputMethods = $outputMethods;
102
-    }
93
+	/**
94
+	 * Set an array contaning the alternate methods to use instead of the default getVar()
95
+	 *
96
+	 * $outputMethods array example: 'uid' => 'getUserName'...
97
+	 * @param $outputMethods
98
+	 */
99
+	public function setOuptutMethods($outputMethods)
100
+	{
101
+		$this->outputMethods = $outputMethods;
102
+	}
103 103
 
104
-    /*
104
+	/*
105 105
      * Set an array of fields that we don't want in export
106 106
      */
107
-    /**
108
-     * @param $fields
109
-     */
110
-    public function setNotDisplayFields($fields)
111
-    {
112
-        if (!$this->notDisplayFields) {
113
-            if (is_array($fields)) {
114
-                $this->notDisplayFields = $fields;
115
-            } else {
116
-                $this->notDisplayFields = array($fields);
117
-            }
118
-        } else {
119
-            if (is_array($fields)) {
120
-                $this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
121
-            } else {
122
-                $this->notDisplayFields[] = $fields;
123
-            }
124
-        }
125
-    }
107
+	/**
108
+	 * @param $fields
109
+	 */
110
+	public function setNotDisplayFields($fields)
111
+	{
112
+		if (!$this->notDisplayFields) {
113
+			if (is_array($fields)) {
114
+				$this->notDisplayFields = $fields;
115
+			} else {
116
+				$this->notDisplayFields = array($fields);
117
+			}
118
+		} else {
119
+			if (is_array($fields)) {
120
+				$this->notDisplayFields = array_merge($this->notDisplayFields, $fields);
121
+			} else {
122
+				$this->notDisplayFields[] = $fields;
123
+			}
124
+		}
125
+	}
126 126
 }
127 127
 
128 128
 /**
@@ -136,181 +136,181 @@  discard block
 block discarded – undo
136 136
  */
137 137
 class SmartExportRenderer
138 138
 {
139
-    public $data;
140
-    public $format;
141
-    public $filename;
142
-    public $filepath;
143
-    public $options;
139
+	public $data;
140
+	public $format;
141
+	public $filename;
142
+	public $filepath;
143
+	public $options;
144 144
 
145
-    /**
146
-     * Constructor
147
-     *
148
-     * @param array       $data     contains the data to be exported
149
-     * @param bool|string $filename name of the file in which the exported data will be saved
150
-     * @param bool|string $filepath path where the file will be saved
151
-     * @param string      $format   format of the ouputed export. Currently only supports CSV
152
-     * @param array       $options  options of the format to be exported in
153
-     */
154
-    public function __construct($data, $filename = false, $filepath = false, $format = 'csv', $options = array('separator' => ';'))
155
-    {
156
-        $this->data     = $data;
157
-        $this->format   = $format;
158
-        $this->filename = $filename;
159
-        $this->filepath = $filepath;
160
-        $this->options  = $options;
161
-    }
145
+	/**
146
+	 * Constructor
147
+	 *
148
+	 * @param array       $data     contains the data to be exported
149
+	 * @param bool|string $filename name of the file in which the exported data will be saved
150
+	 * @param bool|string $filepath path where the file will be saved
151
+	 * @param string      $format   format of the ouputed export. Currently only supports CSV
152
+	 * @param array       $options  options of the format to be exported in
153
+	 */
154
+	public function __construct($data, $filename = false, $filepath = false, $format = 'csv', $options = array('separator' => ';'))
155
+	{
156
+		$this->data     = $data;
157
+		$this->format   = $format;
158
+		$this->filename = $filename;
159
+		$this->filepath = $filepath;
160
+		$this->options  = $options;
161
+	}
162 162
 
163
-    /**
164
-     * @param         $dataArray
165
-     * @param         $separator
166
-     * @param  string $trim
167
-     * @param  bool   $removeEmptyLines
168
-     * @return string
169
-     */
170
-    public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
171
-    {
172
-        if (!is_array($dataArray) || empty($dataArray)) {
173
-            return '';
174
-        }
175
-        switch ($trim) {
176
-            case 'none':
177
-                $trimFunction = false;
178
-                break;
179
-            case 'left':
180
-                $trimFunction = 'ltrim';
181
-                break;
182
-            case 'right':
183
-                $trimFunction = 'rtrim';
184
-                break;
185
-            default: //'both':
186
-                $trimFunction = 'trim';
187
-                break;
188
-        }
189
-        $ret = array();
190
-        foreach ($dataArray as $key => $field) {
191
-            $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
192
-        }
163
+	/**
164
+	 * @param         $dataArray
165
+	 * @param         $separator
166
+	 * @param  string $trim
167
+	 * @param  bool   $removeEmptyLines
168
+	 * @return string
169
+	 */
170
+	public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true)
171
+	{
172
+		if (!is_array($dataArray) || empty($dataArray)) {
173
+			return '';
174
+		}
175
+		switch ($trim) {
176
+			case 'none':
177
+				$trimFunction = false;
178
+				break;
179
+			case 'left':
180
+				$trimFunction = 'ltrim';
181
+				break;
182
+			case 'right':
183
+				$trimFunction = 'rtrim';
184
+				break;
185
+			default: //'both':
186
+				$trimFunction = 'trim';
187
+				break;
188
+		}
189
+		$ret = array();
190
+		foreach ($dataArray as $key => $field) {
191
+			$ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction);
192
+		}
193 193
 
194
-        return implode($separator, $ret);
195
-    }
194
+		return implode($separator, $ret);
195
+	}
196 196
 
197
-    /**
198
-     * @param $val
199
-     * @param $separator
200
-     * @param $trimFunction
201
-     * @return mixed|string
202
-     */
203
-    public function valToCsvHelper($val, $separator, $trimFunction)
204
-    {
205
-        if ($trimFunction) {
206
-            $val = $trimFunction ($val);
207
-        }
208
-        //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
209
-        $needQuote = false;
210
-        do {
211
-            if (strpos($val, '"') !== false) {
212
-                $val       = str_replace('"', '""', $val);
213
-                $needQuote = true;
214
-                break;
215
-            }
216
-            if (strpos($val, $separator) !== false) {
217
-                $needQuote = true;
218
-                break;
219
-            }
220
-            if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac
221
-                $needQuote = true;
222
-                break;
223
-            }
224
-        } while (false);
225
-        if ($needQuote) {
226
-            $val = '"' . $val . '"';
227
-        }
197
+	/**
198
+	 * @param $val
199
+	 * @param $separator
200
+	 * @param $trimFunction
201
+	 * @return mixed|string
202
+	 */
203
+	public function valToCsvHelper($val, $separator, $trimFunction)
204
+	{
205
+		if ($trimFunction) {
206
+			$val = $trimFunction ($val);
207
+		}
208
+		//If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it.
209
+		$needQuote = false;
210
+		do {
211
+			if (strpos($val, '"') !== false) {
212
+				$val       = str_replace('"', '""', $val);
213
+				$needQuote = true;
214
+				break;
215
+			}
216
+			if (strpos($val, $separator) !== false) {
217
+				$needQuote = true;
218
+				break;
219
+			}
220
+			if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac
221
+				$needQuote = true;
222
+				break;
223
+			}
224
+		} while (false);
225
+		if ($needQuote) {
226
+			$val = '"' . $val . '"';
227
+		}
228 228
 
229
-        return $val;
230
-    }
229
+		return $val;
230
+	}
231 231
 
232
-    public function execute()
233
-    {
234
-        $exportFileData = '';
232
+	public function execute()
233
+	{
234
+		$exportFileData = '';
235 235
 
236
-        switch ($this->format) {
237
-            case 'csv':
238
-                $separator = isset($this->options['separator']) ? $this->options['separator'] : ';';
239
-                $firstRow  = implode($separator, $this->data['columnsHeaders']);
240
-                $exportFileData .= $firstRow . "\r\n";
236
+		switch ($this->format) {
237
+			case 'csv':
238
+				$separator = isset($this->options['separator']) ? $this->options['separator'] : ';';
239
+				$firstRow  = implode($separator, $this->data['columnsHeaders']);
240
+				$exportFileData .= $firstRow . "\r\n";
241 241
 
242
-                foreach ($this->data['rows'] as $cols) {
243
-                    $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
244
-                }
245
-                break;
246
-        }
247
-        $this->saveExportFile($exportFileData);
248
-    }
242
+				foreach ($this->data['rows'] as $cols) {
243
+					$exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n";
244
+				}
245
+				break;
246
+		}
247
+		$this->saveExportFile($exportFileData);
248
+	}
249 249
 
250
-    /**
251
-     * @param $content
252
-     */
253
-    public function saveExportFile($content)
254
-    {
255
-        switch ($this->format) {
256
-            case 'csv':
257
-                $this->saveCsv($content);
258
-                break;
259
-        }
260
-    }
250
+	/**
251
+	 * @param $content
252
+	 */
253
+	public function saveExportFile($content)
254
+	{
255
+		switch ($this->format) {
256
+			case 'csv':
257
+				$this->saveCsv($content);
258
+				break;
259
+		}
260
+	}
261 261
 
262
-    /**
263
-     * @param $content
264
-     */
265
-    public function saveCsv($content)
266
-    {
267
-        if (!$this->filepath) {
268
-            $this->filepath = XOOPS_UPLOAD_PATH . '/';
269
-        }
270
-        if (!$this->filename) {
271
-            $this->filename .= time();
272
-            $this->filename .= '.csv';
273
-        }
262
+	/**
263
+	 * @param $content
264
+	 */
265
+	public function saveCsv($content)
266
+	{
267
+		if (!$this->filepath) {
268
+			$this->filepath = XOOPS_UPLOAD_PATH . '/';
269
+		}
270
+		if (!$this->filename) {
271
+			$this->filename .= time();
272
+			$this->filename .= '.csv';
273
+		}
274 274
 
275
-        $fullFileName = $this->filepath . $this->filename;
275
+		$fullFileName = $this->filepath . $this->filename;
276 276
 
277
-        if (!$handle = fopen($fullFileName, 'a+')) {
278
-            trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
279
-        } elseif (fwrite($handle, $content) === false) {
280
-            trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
281
-        } else {
282
-            $mimeType  = 'text/csv';
283
-            $file      = strrev($this->filename);
284
-            $temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
285
-            if ($temp_name == '') {
286
-                $file_name = $this->filename;
287
-            } else {
288
-                $file_name = $temp_name;
289
-            }
290
-            $fullFileName = $this->filepath . stripslashes(trim($this->filename));
277
+		if (!$handle = fopen($fullFileName, 'a+')) {
278
+			trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING);
279
+		} elseif (fwrite($handle, $content) === false) {
280
+			trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING);
281
+		} else {
282
+			$mimeType  = 'text/csv';
283
+			$file      = strrev($this->filename);
284
+			$temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
285
+			if ($temp_name == '') {
286
+				$file_name = $this->filename;
287
+			} else {
288
+				$file_name = $temp_name;
289
+			}
290
+			$fullFileName = $this->filepath . stripslashes(trim($this->filename));
291 291
 
292
-            if (ini_get('zlib.output_compression')) {
293
-                ini_set('zlib.output_compression', 'Off');
294
-            }
292
+			if (ini_get('zlib.output_compression')) {
293
+				ini_set('zlib.output_compression', 'Off');
294
+			}
295 295
 
296
-            header('Pragma: public');
297
-            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
298
-            header('Cache-Control: private', false);
299
-            header('Content-Transfer-Encoding: binary');
300
-            if (isset($mimeType)) {
301
-                header('Content-Type: ' . $mimeType);
302
-            }
296
+			header('Pragma: public');
297
+			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
298
+			header('Cache-Control: private', false);
299
+			header('Content-Transfer-Encoding: binary');
300
+			if (isset($mimeType)) {
301
+				header('Content-Type: ' . $mimeType);
302
+			}
303 303
 
304
-            header('Content-Disposition: attachment; filename=' . $file_name);
304
+			header('Content-Disposition: attachment; filename=' . $file_name);
305 305
 
306
-            if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
307
-                $fp = fopen($fullFileName, 'r');
308
-            } else {
309
-                $fp = fopen($fullFileName, 'rb');
310
-            }
311
-            fpassthru($fp);
312
-            exit();
313
-        }
314
-        fclose($handle);
315
-    }
306
+			if (isset($mimeType) && false !== strpos($mimeType, 'text/')) {
307
+				$fp = fopen($fullFileName, 'r');
308
+			} else {
309
+				$fp = fopen($fullFileName, 'rb');
310
+			}
311
+			fpassthru($fp);
312
+			exit();
313
+		}
314
+		fclose($handle);
315
+	}
316 316
 }
Please login to merge, or discard this patch.
class/smartobjecttable.php 1 patch
Indentation   +845 added lines, -845 removed lines patch added patch discarded remove patch
@@ -21,77 +21,77 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class SmartObjectColumn
23 23
 {
24
-    public $_keyname;
25
-    public $_align;
26
-    public $_width;
27
-    public $_customMethodForValue;
28
-    public $_extraParams;
29
-    public $_sortable;
30
-    public $_customCaption;
31
-
32
-    /**
33
-     * SmartObjectColumn constructor.
34
-     * @param        $keyname
35
-     * @param string $align
36
-     * @param bool   $width
37
-     * @param bool   $customMethodForValue
38
-     * @param bool   $param
39
-     * @param bool   $customCaption
40
-     * @param bool   $sortable
41
-     */
42
-    public function __construct($keyname, $align = 'left', $width = false, $customMethodForValue = false, $param = false, $customCaption = false, $sortable = true)
43
-    {
44
-        $this->_keyname              = $keyname;
45
-        $this->_align                = $align;
46
-        $this->_width                = $width;
47
-        $this->_customMethodForValue = $customMethodForValue;
48
-        $this->_sortable             = $sortable;
49
-        $this->_param                = $param;
50
-        $this->_customCaption        = $customCaption;
51
-    }
52
-
53
-    public function getKeyName()
54
-    {
55
-        return $this->_keyname;
56
-    }
57
-
58
-    /**
59
-     * @return string
60
-     */
61
-    public function getAlign()
62
-    {
63
-        return $this->_align;
64
-    }
65
-
66
-    /**
67
-     * @return bool
68
-     */
69
-    public function isSortable()
70
-    {
71
-        return $this->_sortable;
72
-    }
73
-
74
-    /**
75
-     * @return bool|string
76
-     */
77
-    public function getWidth()
78
-    {
79
-        if ($this->_width) {
80
-            $ret = $this->_width;
81
-        } else {
82
-            $ret = '';
83
-        }
84
-
85
-        return $ret;
86
-    }
87
-
88
-    /**
89
-     * @return bool
90
-     */
91
-    public function getCustomCaption()
92
-    {
93
-        return $this->_customCaption;
94
-    }
24
+	public $_keyname;
25
+	public $_align;
26
+	public $_width;
27
+	public $_customMethodForValue;
28
+	public $_extraParams;
29
+	public $_sortable;
30
+	public $_customCaption;
31
+
32
+	/**
33
+	 * SmartObjectColumn constructor.
34
+	 * @param        $keyname
35
+	 * @param string $align
36
+	 * @param bool   $width
37
+	 * @param bool   $customMethodForValue
38
+	 * @param bool   $param
39
+	 * @param bool   $customCaption
40
+	 * @param bool   $sortable
41
+	 */
42
+	public function __construct($keyname, $align = 'left', $width = false, $customMethodForValue = false, $param = false, $customCaption = false, $sortable = true)
43
+	{
44
+		$this->_keyname              = $keyname;
45
+		$this->_align                = $align;
46
+		$this->_width                = $width;
47
+		$this->_customMethodForValue = $customMethodForValue;
48
+		$this->_sortable             = $sortable;
49
+		$this->_param                = $param;
50
+		$this->_customCaption        = $customCaption;
51
+	}
52
+
53
+	public function getKeyName()
54
+	{
55
+		return $this->_keyname;
56
+	}
57
+
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function getAlign()
62
+	{
63
+		return $this->_align;
64
+	}
65
+
66
+	/**
67
+	 * @return bool
68
+	 */
69
+	public function isSortable()
70
+	{
71
+		return $this->_sortable;
72
+	}
73
+
74
+	/**
75
+	 * @return bool|string
76
+	 */
77
+	public function getWidth()
78
+	{
79
+		if ($this->_width) {
80
+			$ret = $this->_width;
81
+		} else {
82
+			$ret = '';
83
+		}
84
+
85
+		return $ret;
86
+	}
87
+
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	public function getCustomCaption()
92
+	{
93
+		return $this->_customCaption;
94
+	}
95 95
 }
96 96
 
97 97
 /**
@@ -105,778 +105,778 @@  discard block
 block discarded – undo
105 105
  */
106 106
 class SmartObjectTable
107 107
 {
108
-    public $_id;
109
-    public $_objectHandler;
110
-    public $_columns;
111
-    public $_criteria;
112
-    public $_actions;
113
-    public $_objects = false;
114
-    public $_aObjects;
115
-    public $_custom_actions;
116
-    public $_sortsel;
117
-    public $_ordersel;
118
-    public $_limitsel;
119
-    public $_filtersel;
120
-    public $_filterseloptions;
121
-    public $_filtersel2;
122
-    public $_filtersel2options;
123
-    public $_filtersel2optionsDefault;
124
-
125
-    public $_tempObject;
126
-    public $_tpl;
127
-    public $_introButtons;
128
-    public $_quickSearch            = false;
129
-    public $_actionButtons          = false;
130
-    public $_head_css_class         = 'bg3';
131
-    public $_hasActions             = false;
132
-    public $_userSide               = false;
133
-    public $_printerFriendlyPage    = false;
134
-    public $_tableHeader            = false;
135
-    public $_tableFooter            = false;
136
-    public $_showActionsColumnTitle = true;
137
-    public $_isTree                 = false;
138
-    public $_showFilterAndLimit     = true;
139
-    public $_enableColumnsSorting   = true;
140
-    public $_customTemplate         = false;
141
-    public $_withSelectedActions    = array();
142
-
143
-    /**
144
-     * Constructor
145
-     *
146
-     * @param object      $objectHandler {@link SmartPersistableObjectHandler}
147
-     * @param bool|object $criteria
148
-     * @param array       $actions       array representing the actions to offer
149
-     *
150
-     * @param bool        $userSide
151
-     * @internal param array $columns array representing the columns to display in the table
152
-     */
153
-    public function __construct($objectHandler, $criteria = false, $actions = array('edit', 'delete'), $userSide = false)
154
-    {
155
-        $this->_id            = $objectHandler->className;
156
-        $this->_objectHandler = $objectHandler;
157
-
158
-        if (!$criteria) {
159
-            $criteria = new CriteriaCompo();
160
-        }
161
-        $this->_criteria       = $criteria;
162
-        $this->_actions        = $actions;
163
-        $this->_custom_actions = array();
164
-        $this->_userSide       = $userSide;
165
-        if ($userSide) {
166
-            $this->_head_css_class = 'head';
167
-        }
168
-    }
169
-
170
-    /**
171
-     * @param      $op
172
-     * @param bool $caption
173
-     * @param bool $text
174
-     */
175
-    public function addActionButton($op, $caption = false, $text = false)
176
-    {
177
-        $action                 = array(
178
-            'op'      => $op,
179
-            'caption' => $caption,
180
-            'text'    => $text
181
-        );
182
-        $this->_actionButtons[] = $action;
183
-    }
184
-
185
-    /**
186
-     * @param $columnObj
187
-     */
188
-    public function addColumn($columnObj)
189
-    {
190
-        $this->_columns[] = $columnObj;
191
-    }
192
-
193
-    /**
194
-     * @param $name
195
-     * @param $location
196
-     * @param $value
197
-     */
198
-    public function addIntroButton($name, $location, $value)
199
-    {
200
-        $introButton             = array();
201
-        $introButton['name']     = $name;
202
-        $introButton['location'] = $location;
203
-        $introButton['value']    = $value;
204
-        $this->_introButtons[]   = $introButton;
205
-        unset($introButton);
206
-    }
207
-
208
-    public function addPrinterFriendlyLink()
209
-    {
210
-        $current_urls               = smart_getCurrentUrls();
211
-        $current_url                = $current_urls['full'];
212
-        $this->_printerFriendlyPage = $current_url . '&print';
213
-    }
214
-
215
-    /**
216
-     * @param        $fields
217
-     * @param string $caption
218
-     */
219
-    public function addQuickSearch($fields, $caption = _CO_SOBJECT_QUICK_SEARCH)
220
-    {
221
-        $this->_quickSearch = array('fields' => $fields, 'caption' => $caption);
222
-    }
223
-
224
-    /**
225
-     * @param $content
226
-     */
227
-    public function addHeader($content)
228
-    {
229
-        $this->_tableHeader = $content;
230
-    }
231
-
232
-    /**
233
-     * @param $content
234
-     */
235
-    public function addFooter($content)
236
-    {
237
-        $this->_tableFooter = $content;
238
-    }
239
-
240
-    /**
241
-     * @param $caption
242
-     */
243
-    public function addDefaultIntroButton($caption)
244
-    {
245
-        $this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page . '?op=mod', $caption);
246
-    }
247
-
248
-    /**
249
-     * @param $method
250
-     */
251
-    public function addCustomAction($method)
252
-    {
253
-        $this->_custom_actions[] = $method;
254
-    }
255
-
256
-    /**
257
-     * @param $default_sort
258
-     */
259
-    public function setDefaultSort($default_sort)
260
-    {
261
-        $this->_sortsel = $default_sort;
262
-    }
263
-
264
-    /**
265
-     * @return string
266
-     */
267
-    public function getDefaultSort()
268
-    {
269
-        if ($this->_sortsel) {
270
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
271
-        } else {
272
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_objectHandler->identifierName);
273
-        }
274
-    }
275
-
276
-    /**
277
-     * @param $default_order
278
-     */
279
-    public function setDefaultOrder($default_order)
280
-    {
281
-        $this->_ordersel = $default_order;
282
-    }
283
-
284
-    /**
285
-     * @return string
286
-     */
287
-    public function getDefaultOrder()
288
-    {
289
-        if ($this->_ordersel) {
290
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
291
-        } else {
292
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', 'ASC');
293
-        }
294
-    }
295
-
296
-    /**
297
-     * @param array $actions
298
-     */
299
-    public function addWithSelectedActions($actions = array())
300
-    {
301
-        $this->addColumn(new SmartObjectColumn('checked', 'center', 20, false, false, '&nbsp;'));
302
-        $this->_withSelectedActions = $actions;
303
-    }
304
-
305
-    /**
306
-     * Adding a filter in the table
307
-     *
308
-     * @param string $key    key to the field that will be used for sorting
309
-     * @param string $method method of the handler that will be called to populate the options when this filter is selected
310
-     * @param bool   $default
311
-     */
312
-    public function addFilter($key, $method, $default = false)
313
-    {
314
-        $this->_filterseloptions[$key]   = $method;
315
-        $this->_filtersel2optionsDefault = $default;
316
-    }
317
-
318
-    /**
319
-     * @param $default_filter
320
-     */
321
-    public function setDefaultFilter($default_filter)
322
-    {
323
-        $this->_filtersel = $default_filter;
324
-    }
325
-
326
-    public function isForUserSide()
327
-    {
328
-        $this->_userSide = true;
329
-    }
330
-
331
-    /**
332
-     * @param $template
333
-     */
334
-    public function setCustomTemplate($template)
335
-    {
336
-        $this->_customTemplate = $template;
337
-    }
338
-
339
-    public function setSortOrder()
340
-    {
341
-        $this->_sortsel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] : $this->getDefaultSort();
342
-        //$this->_sortsel = isset($_POST['sortsel']) ? $_POST['sortsel']: $this->_sortsel;
343
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
344
-        $fieldsForSorting = $this->_tempObject->getFieldsForSorting($this->_sortsel);
345
-
346
-        if (isset($this->_tempObject->vars[$this->_sortsel]['itemName']) && $this->_tempObject->vars[$this->_sortsel]['itemName']) {
347
-            $this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'] . '.' . $this->_sortsel);
348
-        } else {
349
-            $this->_criteria->setSort($this->_objectHandler->_itemname . '.' . $this->_sortsel);
350
-        }
351
-
352
-        $this->_ordersel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : $this->getDefaultOrder();
353
-        //$this->_ordersel = isset($_POST['ordersel']) ? $_POST['ordersel']:$this->_ordersel;
354
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
355
-        $ordersArray = $this->getOrdersArray();
356
-        $this->_criteria->setOrder($this->_ordersel);
357
-    }
358
-
359
-    /**
360
-     * @param $id
361
-     */
362
-    public function setTableId($id)
363
-    {
364
-        $this->_id = $id;
365
-    }
366
-
367
-    /**
368
-     * @param $objects
369
-     */
370
-    public function setObjects($objects)
371
-    {
372
-        $this->_objects = $objects;
373
-    }
374
-
375
-    public function createTableRows()
376
-    {
377
-        $this->_aObjects = array();
378
-
379
-        $doWeHaveActions = false;
380
-
381
-        $objectclass = 'odd';
382
-        if (count($this->_objects) > 0) {
383
-            foreach ($this->_objects as $object) {
384
-                $aObject = array();
385
-
386
-                $i = 0;
387
-
388
-                $aColumns = array();
389
-
390
-                foreach ($this->_columns as $column) {
391
-                    $aColumn = array();
392
-
393
-                    if ($i == 0) {
394
-                        $class = 'head';
395
-                    } elseif ($i % 2 == 0) {
396
-                        $class = 'even';
397
-                    } else {
398
-                        $class = 'odd';
399
-                    }
400
-                    if (method_exists($object, 'initiateCustomFields')) {
401
-                        //$object->initiateCustomFields();
402
-                    }
403
-                    if ($column->_keyname === 'checked') {
404
-                        $value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
405
-                    } elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
406
-                        $method = $column->_customMethodForValue;
407
-                        if ($column->_param) {
408
-                            $value = $object->$method($column->_param);
409
-                        } else {
410
-                            $value = $object->$method();
411
-                        }
412
-                    } else {
413
-                        /**
414
-                         * If the column is the identifier, then put a link on it
415
-                         */
416
-                        if ($column->getKeyName() == $this->_objectHandler->identifierName) {
417
-                            $value = $object->getItemLink();
418
-                        } else {
419
-                            $value = $object->getVar($column->getKeyName());
420
-                        }
421
-                    }
422
-
423
-                    $aColumn['value'] = $value;
424
-                    $aColumn['class'] = $class;
425
-                    $aColumn['width'] = $column->getWidth();
426
-                    $aColumn['align'] = $column->getAlign();
427
-
428
-                    $aColumns[] = $aColumn;
429
-                    ++$i;
430
-                }
431
-
432
-                $aObject['columns'] = $aColumns;
433
-                $aObject['id']      = $object->id();
434
-
435
-                $objectclass = ($objectclass === 'even') ? 'odd' : 'even';
436
-
437
-                $aObject['class'] = $objectclass;
438
-
439
-                $actions = array();
440
-
441
-                // Adding the custom actions if any
442
-                foreach ($this->_custom_actions as $action) {
443
-                    if (method_exists($object, $action)) {
444
-                        $actions[] = $object->$action();
445
-                    }
446
-                }
447
-
448
-                include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
449
-                $controller = new SmartObjectController($this->_objectHandler);
450
-
451
-                if ((!is_array($this->_actions)) || in_array('edit', $this->_actions)) {
452
-                    $actions[] = $controller->getEditItemLink($object, false, true, $this->_userSide);
453
-                }
454
-                if ((!is_array($this->_actions)) || in_array('delete', $this->_actions)) {
455
-                    $actions[] = $controller->getDeleteItemLink($object, false, true, $this->_userSide);
456
-                }
457
-                $aObject['actions'] = $actions;
458
-
459
-                $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
460
-
461
-                $doWeHaveActions = $doWeHaveActions ? true : count($actions) > 0;
462
-
463
-                $this->_aObjects[] = $aObject;
464
-            }
465
-            $this->_tpl->assign('smartobject_objects', $this->_aObjects);
466
-        } else {
467
-            $colspan = count($this->_columns) + 1;
468
-            $this->_tpl->assign('smartobject_colspan', $colspan);
469
-        }
470
-        $this->_hasActions = $doWeHaveActions;
471
-    }
472
-
473
-    /**
474
-     * @param  bool $debug
475
-     * @return mixed
476
-     */
477
-    public function fetchObjects($debug = false)
478
-    {
479
-        return $this->_objectHandler->getObjects($this->_criteria, true, true, false, $debug);
480
-    }
481
-
482
-    /**
483
-     * @return string
484
-     */
485
-    public function getDefaultFilter()
486
-    {
487
-        if ($this->_filtersel) {
488
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
489
-        } else {
490
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', 'default');
491
-        }
492
-    }
493
-
494
-    /**
495
-     * @return array|bool
496
-     */
497
-    public function getFiltersArray()
498
-    {
499
-        $ret               = array();
500
-        $field             = array();
501
-        $field['caption']  = _CO_OBJ_NONE;
502
-        $field['selected'] = '';
503
-        $ret['default']    = $field;
504
-        unset($field);
505
-
506
-        if ($this->_filterseloptions) {
507
-            foreach ($this->_filterseloptions as $key => $value) {
508
-                $field = array();
509
-                if (is_array($value)) {
510
-                    $field['caption']  = $key;
511
-                    $field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
512
-                } else {
513
-                    $field['caption']  = $this->_tempObject->vars[$key]['form_caption'];
514
-                    $field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
515
-                }
516
-                $ret[$key] = $field;
517
-                unset($field);
518
-            }
519
-        } else {
520
-            $ret = false;
521
-        }
522
-
523
-        return $ret;
524
-    }
525
-
526
-    /**
527
-     * @param $default_filter2
528
-     */
529
-    public function setDefaultFilter2($default_filter2)
530
-    {
531
-        $this->_filtersel2 = $default_filter2;
532
-    }
533
-
534
-    /**
535
-     * @return string
536
-     */
537
-    public function getDefaultFilter2()
538
-    {
539
-        if ($this->_filtersel2) {
540
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
541
-        } else {
542
-            return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', 'default');
543
-        }
544
-    }
545
-
546
-    /**
547
-     * @return array
548
-     */
549
-    public function getFilters2Array()
550
-    {
551
-        $ret = array();
552
-
553
-        foreach ($this->_filtersel2options as $key => $value) {
554
-            $field             = array();
555
-            $field['caption']  = $value;
556
-            $field['selected'] = $this->_filtersel2 == $key ? "selected='selected'" : '';
557
-            $ret[$key]         = $field;
558
-            unset($field);
559
-        }
560
-
561
-        return $ret;
562
-    }
563
-
564
-    /**
565
-     * @param $limitsArray
566
-     * @param $params_of_the_options_sel
567
-     */
568
-    public function renderOptionSelection($limitsArray, $params_of_the_options_sel)
569
-    {
570
-        // Rendering the form to select options on the table
571
-        $current_urls = smart_getCurrentUrls();
572
-        $current_url  = $current_urls['full'];
573
-
574
-        /**
575
-         * What was $params_of_the_options_sel doing again ?
576
-         */
577
-        //$this->_tpl->assign('smartobject_optionssel_action', $_SERVER['PHP_SELF'] . "?" . implode('&', $params_of_the_options_sel));
578
-        $this->_tpl->assign('smartobject_optionssel_action', $current_url);
579
-        $this->_tpl->assign('smartobject_optionssel_limitsArray', $limitsArray);
580
-    }
581
-
582
-    /**
583
-     * @return array
584
-     */
585
-    public function getLimitsArray()
586
-    {
587
-        $ret                    = array();
588
-        $ret['all']['caption']  = _CO_SOBJECT_LIMIT_ALL;
589
-        $ret['all']['selected'] = ('all' === $this->_limitsel) ? "selected='selected'" : '';
590
-
591
-        $ret['5']['caption']  = '5';
592
-        $ret['5']['selected'] = ('5' == $this->_limitsel) ? "selected='selected'" : '';
593
-
594
-        $ret['10']['caption']  = '10';
595
-        $ret['10']['selected'] = ('10' == $this->_limitsel) ? "selected='selected'" : '';
596
-
597
-        $ret['15']['caption']  = '15';
598
-        $ret['15']['selected'] = ('15' == $this->_limitsel) ? "selected='selected'" : '';
599
-
600
-        $ret['20']['caption']  = '20';
601
-        $ret['20']['selected'] = ('20' == $this->_limitsel) ? "selected='selected'" : '';
602
-
603
-        $ret['25']['caption']  = '25';
604
-        $ret['25']['selected'] = ('25' == $this->_limitsel) ? "selected='selected'" : '';
605
-
606
-        $ret['30']['caption']  = '30';
607
-        $ret['30']['selected'] = ('30' == $this->_limitsel) ? "selected='selected'" : '';
608
-
609
-        $ret['35']['caption']  = '35';
610
-        $ret['35']['selected'] = ('35' == $this->_limitsel) ? "selected='selected'" : '';
611
-
612
-        $ret['40']['caption']  = '40';
613
-        $ret['40']['selected'] = ('40' == $this->_limitsel) ? "selected='selected'" : '';
614
-
615
-        return $ret;
616
-    }
617
-
618
-    /**
619
-     * @return bool
620
-     */
621
-    public function getObjects()
622
-    {
623
-        return $this->_objects;
624
-    }
625
-
626
-    public function hideActionColumnTitle()
627
-    {
628
-        $this->_showActionsColumnTitle = false;
629
-    }
630
-
631
-    public function hideFilterAndLimit()
632
-    {
633
-        $this->_showFilterAndLimit = false;
634
-    }
635
-
636
-    /**
637
-     * @return array
638
-     */
639
-    public function getOrdersArray()
640
-    {
641
-        $ret                    = array();
642
-        $ret['ASC']['caption']  = _CO_SOBJECT_SORT_ASC;
643
-        $ret['ASC']['selected'] = ('ASC' === $this->_ordersel) ? "selected='selected'" : '';
644
-
645
-        $ret['DESC']['caption']  = _CO_SOBJECT_SORT_DESC;
646
-        $ret['DESC']['selected'] = ('DESC' === $this->_ordersel) ? "selected='selected'" : '';
647
-
648
-        return $ret;
649
-    }
650
-
651
-    /**
652
-     * @return mixed|string|void
653
-     */
654
-    public function renderD()
655
-    {
656
-        return $this->render(false, true);
657
-    }
658
-
659
-    public function renderForPrint()
660
-    {
661
-    }
662
-
663
-    /**
664
-     * @param  bool $fetchOnly
665
-     * @param  bool $debug
666
-     * @return mixed|string|void
667
-     */
668
-    public function render($fetchOnly = false, $debug = false)
669
-    {
670
-        include_once XOOPS_ROOT_PATH . '/class/template.php';
671
-
672
-        $this->_tpl = new XoopsTpl();
673
-
674
-        /**
675
-         * We need access to the vars of the SmartObject for a few things in the table creation.
676
-         * Since we may not have a SmartObject to look into now, let's create one for this purpose
677
-         * and we will free it after
678
-         */
679
-        $this->_tempObject = $this->_objectHandler->create();
680
-
681
-        $this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int)$_GET['start' . $this->_objectHandler->keyName] : 0);
682
-
683
-        $this->setSortOrder();
684
-
685
-        if (!$this->_isTree) {
686
-            $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15');
687
-        } else {
688
-            $this->_limitsel = 'all';
689
-        }
690
-
691
-        $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
692
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel);
693
-        $limitsArray = $this->getLimitsArray();
694
-        $this->_criteria->setLimit($this->_limitsel);
695
-
696
-        $this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter();
697
-        $this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel;
698
-        smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
699
-        $filtersArray = $this->getFiltersArray();
700
-
701
-        if ($filtersArray) {
702
-            $this->_tpl->assign('smartobject_optionssel_filtersArray', $filtersArray);
703
-        }
704
-
705
-        // Check if the selected filter is defined and if so, create the selfilter2
706
-        if (isset($this->_filterseloptions[$this->_filtersel])) {
707
-            // check if method associate with this filter exists in the handler
708
-            if (is_array($this->_filterseloptions[$this->_filtersel])) {
709
-                $filter = $this->_filterseloptions[$this->_filtersel];
710
-                $this->_criteria->add($filter['criteria']);
711
-            } else {
712
-                if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) {
713
-
714
-                    // then we will create the selfilter2 options by calling this method
715
-                    $method                   = $this->_filterseloptions[$this->_filtersel];
716
-                    $this->_filtersel2options = $this->_objectHandler->$method();
717
-
718
-                    $this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2();
719
-                    $this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2;
720
-
721
-                    $filters2Array = $this->getFilters2Array();
722
-                    $this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array);
723
-
724
-                    smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
725
-                    if ($this->_filtersel2 !== 'default') {
726
-                        $this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2));
727
-                    }
728
-                }
729
-            }
730
-        }
731
-        // Check if we have a quicksearch
732
-
733
-        if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
734
-            $quicksearch_criteria = new CriteriaCompo();
735
-            if (is_array($this->_quickSearch['fields'])) {
736
-                foreach ($this->_quickSearch['fields'] as $v) {
737
-                    $quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
738
-                }
739
-            } else {
740
-                $quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
741
-            }
742
-            $this->_criteria->add($quicksearch_criteria);
743
-        }
744
-
745
-        $this->_objects = $this->fetchObjects($debug);
746
-
747
-        include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
748
-        if ($this->_criteria->getLimit() > 0) {
749
-
750
-            /**
751
-             * Geeting rid of the old params
752
-             * $new_get_array is an array containing the new GET parameters
753
-             */
754
-            $new_get_array = array();
755
-
756
-            /**
757
-             * $params_of_the_options_sel is an array with all the parameters of the page
758
-             * but without the pagenave parameters. This array will be used in the
759
-             * OptionsSelection
760
-             */
761
-            $params_of_the_options_sel = array();
762
-
763
-            $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName);
764
-            foreach ($_GET as $k => $v) {
765
-                if (!in_array($k, $not_needed_params)) {
766
-                    $new_get_array[]             = "$k=$v";
767
-                    $params_of_the_options_sel[] = "$k=$v";
768
-                }
769
-            }
770
-
771
-            /**
772
-             * Adding the new params of the pagenav
773
-             */
774
-            $new_get_array[] = 'sortsel=' . $this->_sortsel;
775
-            $new_get_array[] = 'ordersel=' . $this->_ordersel;
776
-            $new_get_array[] = 'limitsel=' . $this->_limitsel;
777
-            $otherParams     = implode('&', $new_get_array);
778
-
779
-            $pagenav = new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
780
-            $this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav());
781
-        }
782
-        $this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
783
-
784
-        // retreive the current url and the query string
785
-        $current_urls = smart_getCurrentUrls();
786
-        $current_url  = $current_urls['full_phpself'];
787
-        $query_string = $current_urls['querystring'];
788
-        if ($query_string) {
789
-            $query_string = str_replace('?', '', $query_string);
790
-        }
791
-        $query_stringArray     = explode('&', $query_string);
792
-        $new_query_stringArray = array();
793
-        foreach ($query_stringArray as $query_string) {
794
-            if (strpos($query_string, 'sortsel') == false && strpos($query_string, 'ordersel') == false) {
795
-                $new_query_stringArray[] = $query_string;
796
-            }
797
-        }
798
-        $new_query_string = implode('&', $new_query_stringArray);
799
-
800
-        $orderArray                     = array();
801
-        $orderArray['ASC']['image']     = 'desc.png';
802
-        $orderArray['ASC']['neworder']  = 'DESC';
803
-        $orderArray['DESC']['image']    = 'asc.png';
804
-        $orderArray['DESC']['neworder'] = 'ASC';
805
-
806
-        $aColumns = array();
807
-
808
-        foreach ($this->_columns as $column) {
809
-            $qs_param         = '';
810
-            $aColumn          = array();
811
-            $aColumn['width'] = $column->getWidth();
812
-            $aColumn['align'] = $column->getAlign();
813
-            $aColumn['key']   = $column->getKeyName();
814
-            if ($column->_keyname === 'checked') {
815
-                $aColumn['caption'] = '<input type ="checkbox" id="checkall_smartobjects" name="checkall_smartobjects"' . ' value="checkall_smartobjects" onclick="smartobject_checkall(window.document.form_' . $this->_id . ', \'selected_smartobjects\');" />';
816
-            } elseif ($column->getCustomCaption()) {
817
-                $aColumn['caption'] = $column->getCustomCaption();
818
-            } else {
819
-                $aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName();
820
-            }
821
-            // Are we doing a GET sort on this column ?
822
-            $getSort = (isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName()) || ($this->_sortsel == $column->getKeyName());
823
-            $order   = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC';
824
-
825
-            if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') {
826
-                $qs_param = '&quicksearch_' . $this->_id . '=' . $_REQUEST['quicksearch_' . $this->_id];
827
-            }
828
-            if (!$this->_enableColumnsSorting || $column->_keyname === 'checked' || !$column->isSortable()) {
829
-                $aColumn['caption'] = $aColumn['caption'];
830
-            } elseif ($getSort) {
831
-                $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=' . $orderArray[$order]['neworder'] . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . ' <img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . $orderArray[$order]['image'] . '" alt="ASC" /></a>';
832
-            } else {
833
-                $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=ASC' . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . '</a>';
834
-            }
835
-            $aColumns[] = $aColumn;
836
-        }
837
-        $this->_tpl->assign('smartobject_columns', $aColumns);
838
-
839
-        if ($this->_quickSearch) {
840
-            $this->_tpl->assign('smartobject_quicksearch', $this->_quickSearch['caption']);
841
-        }
842
-
843
-        $this->createTableRows();
844
-
845
-        $this->_tpl->assign('smartobject_showFilterAndLimit', $this->_showFilterAndLimit);
846
-        $this->_tpl->assign('smartobject_isTree', $this->_isTree);
847
-        $this->_tpl->assign('smartobject_show_action_column_title', $this->_showActionsColumnTitle);
848
-        $this->_tpl->assign('smartobject_table_header', $this->_tableHeader);
849
-        $this->_tpl->assign('smartobject_table_footer', $this->_tableFooter);
850
-        $this->_tpl->assign('smartobject_printer_friendly_page', $this->_printerFriendlyPage);
851
-        $this->_tpl->assign('smartobject_user_side', $this->_userSide);
852
-        $this->_tpl->assign('smartobject_has_actions', $this->_hasActions);
853
-        $this->_tpl->assign('smartobject_head_css_class', $this->_head_css_class);
854
-        $this->_tpl->assign('smartobject_actionButtons', $this->_actionButtons);
855
-        $this->_tpl->assign('smartobject_introButtons', $this->_introButtons);
856
-        $this->_tpl->assign('smartobject_id', $this->_id);
857
-        if (!empty($this->_withSelectedActions)) {
858
-            $this->_tpl->assign('smartobject_withSelectedActions', $this->_withSelectedActions);
859
-        }
860
-
861
-        $smartobjectTable_template = $this->_customTemplate ?: 'smartobject_smarttable_display.tpl';
862
-        if ($fetchOnly) {
863
-            return $this->_tpl->fetch('db:' . $smartobjectTable_template);
864
-        } else {
865
-            $this->_tpl->display('db:' . $smartobjectTable_template);
866
-        }
867
-    }
868
-
869
-    public function disableColumnsSorting()
870
-    {
871
-        $this->_enableColumnsSorting = false;
872
-    }
873
-
874
-    /**
875
-     * @param  bool $debug
876
-     * @return mixed|string|void
877
-     */
878
-    public function fetch($debug = false)
879
-    {
880
-        return $this->render(true, $debug);
881
-    }
108
+	public $_id;
109
+	public $_objectHandler;
110
+	public $_columns;
111
+	public $_criteria;
112
+	public $_actions;
113
+	public $_objects = false;
114
+	public $_aObjects;
115
+	public $_custom_actions;
116
+	public $_sortsel;
117
+	public $_ordersel;
118
+	public $_limitsel;
119
+	public $_filtersel;
120
+	public $_filterseloptions;
121
+	public $_filtersel2;
122
+	public $_filtersel2options;
123
+	public $_filtersel2optionsDefault;
124
+
125
+	public $_tempObject;
126
+	public $_tpl;
127
+	public $_introButtons;
128
+	public $_quickSearch            = false;
129
+	public $_actionButtons          = false;
130
+	public $_head_css_class         = 'bg3';
131
+	public $_hasActions             = false;
132
+	public $_userSide               = false;
133
+	public $_printerFriendlyPage    = false;
134
+	public $_tableHeader            = false;
135
+	public $_tableFooter            = false;
136
+	public $_showActionsColumnTitle = true;
137
+	public $_isTree                 = false;
138
+	public $_showFilterAndLimit     = true;
139
+	public $_enableColumnsSorting   = true;
140
+	public $_customTemplate         = false;
141
+	public $_withSelectedActions    = array();
142
+
143
+	/**
144
+	 * Constructor
145
+	 *
146
+	 * @param object      $objectHandler {@link SmartPersistableObjectHandler}
147
+	 * @param bool|object $criteria
148
+	 * @param array       $actions       array representing the actions to offer
149
+	 *
150
+	 * @param bool        $userSide
151
+	 * @internal param array $columns array representing the columns to display in the table
152
+	 */
153
+	public function __construct($objectHandler, $criteria = false, $actions = array('edit', 'delete'), $userSide = false)
154
+	{
155
+		$this->_id            = $objectHandler->className;
156
+		$this->_objectHandler = $objectHandler;
157
+
158
+		if (!$criteria) {
159
+			$criteria = new CriteriaCompo();
160
+		}
161
+		$this->_criteria       = $criteria;
162
+		$this->_actions        = $actions;
163
+		$this->_custom_actions = array();
164
+		$this->_userSide       = $userSide;
165
+		if ($userSide) {
166
+			$this->_head_css_class = 'head';
167
+		}
168
+	}
169
+
170
+	/**
171
+	 * @param      $op
172
+	 * @param bool $caption
173
+	 * @param bool $text
174
+	 */
175
+	public function addActionButton($op, $caption = false, $text = false)
176
+	{
177
+		$action                 = array(
178
+			'op'      => $op,
179
+			'caption' => $caption,
180
+			'text'    => $text
181
+		);
182
+		$this->_actionButtons[] = $action;
183
+	}
184
+
185
+	/**
186
+	 * @param $columnObj
187
+	 */
188
+	public function addColumn($columnObj)
189
+	{
190
+		$this->_columns[] = $columnObj;
191
+	}
192
+
193
+	/**
194
+	 * @param $name
195
+	 * @param $location
196
+	 * @param $value
197
+	 */
198
+	public function addIntroButton($name, $location, $value)
199
+	{
200
+		$introButton             = array();
201
+		$introButton['name']     = $name;
202
+		$introButton['location'] = $location;
203
+		$introButton['value']    = $value;
204
+		$this->_introButtons[]   = $introButton;
205
+		unset($introButton);
206
+	}
207
+
208
+	public function addPrinterFriendlyLink()
209
+	{
210
+		$current_urls               = smart_getCurrentUrls();
211
+		$current_url                = $current_urls['full'];
212
+		$this->_printerFriendlyPage = $current_url . '&print';
213
+	}
214
+
215
+	/**
216
+	 * @param        $fields
217
+	 * @param string $caption
218
+	 */
219
+	public function addQuickSearch($fields, $caption = _CO_SOBJECT_QUICK_SEARCH)
220
+	{
221
+		$this->_quickSearch = array('fields' => $fields, 'caption' => $caption);
222
+	}
223
+
224
+	/**
225
+	 * @param $content
226
+	 */
227
+	public function addHeader($content)
228
+	{
229
+		$this->_tableHeader = $content;
230
+	}
231
+
232
+	/**
233
+	 * @param $content
234
+	 */
235
+	public function addFooter($content)
236
+	{
237
+		$this->_tableFooter = $content;
238
+	}
239
+
240
+	/**
241
+	 * @param $caption
242
+	 */
243
+	public function addDefaultIntroButton($caption)
244
+	{
245
+		$this->addIntroButton($this->_objectHandler->_itemname, $this->_objectHandler->_page . '?op=mod', $caption);
246
+	}
247
+
248
+	/**
249
+	 * @param $method
250
+	 */
251
+	public function addCustomAction($method)
252
+	{
253
+		$this->_custom_actions[] = $method;
254
+	}
255
+
256
+	/**
257
+	 * @param $default_sort
258
+	 */
259
+	public function setDefaultSort($default_sort)
260
+	{
261
+		$this->_sortsel = $default_sort;
262
+	}
263
+
264
+	/**
265
+	 * @return string
266
+	 */
267
+	public function getDefaultSort()
268
+	{
269
+		if ($this->_sortsel) {
270
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
271
+		} else {
272
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_objectHandler->identifierName);
273
+		}
274
+	}
275
+
276
+	/**
277
+	 * @param $default_order
278
+	 */
279
+	public function setDefaultOrder($default_order)
280
+	{
281
+		$this->_ordersel = $default_order;
282
+	}
283
+
284
+	/**
285
+	 * @return string
286
+	 */
287
+	public function getDefaultOrder()
288
+	{
289
+		if ($this->_ordersel) {
290
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
291
+		} else {
292
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', 'ASC');
293
+		}
294
+	}
295
+
296
+	/**
297
+	 * @param array $actions
298
+	 */
299
+	public function addWithSelectedActions($actions = array())
300
+	{
301
+		$this->addColumn(new SmartObjectColumn('checked', 'center', 20, false, false, '&nbsp;'));
302
+		$this->_withSelectedActions = $actions;
303
+	}
304
+
305
+	/**
306
+	 * Adding a filter in the table
307
+	 *
308
+	 * @param string $key    key to the field that will be used for sorting
309
+	 * @param string $method method of the handler that will be called to populate the options when this filter is selected
310
+	 * @param bool   $default
311
+	 */
312
+	public function addFilter($key, $method, $default = false)
313
+	{
314
+		$this->_filterseloptions[$key]   = $method;
315
+		$this->_filtersel2optionsDefault = $default;
316
+	}
317
+
318
+	/**
319
+	 * @param $default_filter
320
+	 */
321
+	public function setDefaultFilter($default_filter)
322
+	{
323
+		$this->_filtersel = $default_filter;
324
+	}
325
+
326
+	public function isForUserSide()
327
+	{
328
+		$this->_userSide = true;
329
+	}
330
+
331
+	/**
332
+	 * @param $template
333
+	 */
334
+	public function setCustomTemplate($template)
335
+	{
336
+		$this->_customTemplate = $template;
337
+	}
338
+
339
+	public function setSortOrder()
340
+	{
341
+		$this->_sortsel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] : $this->getDefaultSort();
342
+		//$this->_sortsel = isset($_POST['sortsel']) ? $_POST['sortsel']: $this->_sortsel;
343
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_sortsel', $this->_sortsel);
344
+		$fieldsForSorting = $this->_tempObject->getFieldsForSorting($this->_sortsel);
345
+
346
+		if (isset($this->_tempObject->vars[$this->_sortsel]['itemName']) && $this->_tempObject->vars[$this->_sortsel]['itemName']) {
347
+			$this->_criteria->setSort($this->_tempObject->vars[$this->_sortsel]['itemName'] . '.' . $this->_sortsel);
348
+		} else {
349
+			$this->_criteria->setSort($this->_objectHandler->_itemname . '.' . $this->_sortsel);
350
+		}
351
+
352
+		$this->_ordersel = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : $this->getDefaultOrder();
353
+		//$this->_ordersel = isset($_POST['ordersel']) ? $_POST['ordersel']:$this->_ordersel;
354
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_ordersel', $this->_ordersel);
355
+		$ordersArray = $this->getOrdersArray();
356
+		$this->_criteria->setOrder($this->_ordersel);
357
+	}
358
+
359
+	/**
360
+	 * @param $id
361
+	 */
362
+	public function setTableId($id)
363
+	{
364
+		$this->_id = $id;
365
+	}
366
+
367
+	/**
368
+	 * @param $objects
369
+	 */
370
+	public function setObjects($objects)
371
+	{
372
+		$this->_objects = $objects;
373
+	}
374
+
375
+	public function createTableRows()
376
+	{
377
+		$this->_aObjects = array();
378
+
379
+		$doWeHaveActions = false;
380
+
381
+		$objectclass = 'odd';
382
+		if (count($this->_objects) > 0) {
383
+			foreach ($this->_objects as $object) {
384
+				$aObject = array();
385
+
386
+				$i = 0;
387
+
388
+				$aColumns = array();
389
+
390
+				foreach ($this->_columns as $column) {
391
+					$aColumn = array();
392
+
393
+					if ($i == 0) {
394
+						$class = 'head';
395
+					} elseif ($i % 2 == 0) {
396
+						$class = 'even';
397
+					} else {
398
+						$class = 'odd';
399
+					}
400
+					if (method_exists($object, 'initiateCustomFields')) {
401
+						//$object->initiateCustomFields();
402
+					}
403
+					if ($column->_keyname === 'checked') {
404
+						$value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
405
+					} elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
406
+						$method = $column->_customMethodForValue;
407
+						if ($column->_param) {
408
+							$value = $object->$method($column->_param);
409
+						} else {
410
+							$value = $object->$method();
411
+						}
412
+					} else {
413
+						/**
414
+						 * If the column is the identifier, then put a link on it
415
+						 */
416
+						if ($column->getKeyName() == $this->_objectHandler->identifierName) {
417
+							$value = $object->getItemLink();
418
+						} else {
419
+							$value = $object->getVar($column->getKeyName());
420
+						}
421
+					}
422
+
423
+					$aColumn['value'] = $value;
424
+					$aColumn['class'] = $class;
425
+					$aColumn['width'] = $column->getWidth();
426
+					$aColumn['align'] = $column->getAlign();
427
+
428
+					$aColumns[] = $aColumn;
429
+					++$i;
430
+				}
431
+
432
+				$aObject['columns'] = $aColumns;
433
+				$aObject['id']      = $object->id();
434
+
435
+				$objectclass = ($objectclass === 'even') ? 'odd' : 'even';
436
+
437
+				$aObject['class'] = $objectclass;
438
+
439
+				$actions = array();
440
+
441
+				// Adding the custom actions if any
442
+				foreach ($this->_custom_actions as $action) {
443
+					if (method_exists($object, $action)) {
444
+						$actions[] = $object->$action();
445
+					}
446
+				}
447
+
448
+				include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
449
+				$controller = new SmartObjectController($this->_objectHandler);
450
+
451
+				if ((!is_array($this->_actions)) || in_array('edit', $this->_actions)) {
452
+					$actions[] = $controller->getEditItemLink($object, false, true, $this->_userSide);
453
+				}
454
+				if ((!is_array($this->_actions)) || in_array('delete', $this->_actions)) {
455
+					$actions[] = $controller->getDeleteItemLink($object, false, true, $this->_userSide);
456
+				}
457
+				$aObject['actions'] = $actions;
458
+
459
+				$this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
460
+
461
+				$doWeHaveActions = $doWeHaveActions ? true : count($actions) > 0;
462
+
463
+				$this->_aObjects[] = $aObject;
464
+			}
465
+			$this->_tpl->assign('smartobject_objects', $this->_aObjects);
466
+		} else {
467
+			$colspan = count($this->_columns) + 1;
468
+			$this->_tpl->assign('smartobject_colspan', $colspan);
469
+		}
470
+		$this->_hasActions = $doWeHaveActions;
471
+	}
472
+
473
+	/**
474
+	 * @param  bool $debug
475
+	 * @return mixed
476
+	 */
477
+	public function fetchObjects($debug = false)
478
+	{
479
+		return $this->_objectHandler->getObjects($this->_criteria, true, true, false, $debug);
480
+	}
481
+
482
+	/**
483
+	 * @return string
484
+	 */
485
+	public function getDefaultFilter()
486
+	{
487
+		if ($this->_filtersel) {
488
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
489
+		} else {
490
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', 'default');
491
+		}
492
+	}
493
+
494
+	/**
495
+	 * @return array|bool
496
+	 */
497
+	public function getFiltersArray()
498
+	{
499
+		$ret               = array();
500
+		$field             = array();
501
+		$field['caption']  = _CO_OBJ_NONE;
502
+		$field['selected'] = '';
503
+		$ret['default']    = $field;
504
+		unset($field);
505
+
506
+		if ($this->_filterseloptions) {
507
+			foreach ($this->_filterseloptions as $key => $value) {
508
+				$field = array();
509
+				if (is_array($value)) {
510
+					$field['caption']  = $key;
511
+					$field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
512
+				} else {
513
+					$field['caption']  = $this->_tempObject->vars[$key]['form_caption'];
514
+					$field['selected'] = $this->_filtersel == $key ? "selected='selected'" : '';
515
+				}
516
+				$ret[$key] = $field;
517
+				unset($field);
518
+			}
519
+		} else {
520
+			$ret = false;
521
+		}
522
+
523
+		return $ret;
524
+	}
525
+
526
+	/**
527
+	 * @param $default_filter2
528
+	 */
529
+	public function setDefaultFilter2($default_filter2)
530
+	{
531
+		$this->_filtersel2 = $default_filter2;
532
+	}
533
+
534
+	/**
535
+	 * @return string
536
+	 */
537
+	public function getDefaultFilter2()
538
+	{
539
+		if ($this->_filtersel2) {
540
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
541
+		} else {
542
+			return smart_getCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', 'default');
543
+		}
544
+	}
545
+
546
+	/**
547
+	 * @return array
548
+	 */
549
+	public function getFilters2Array()
550
+	{
551
+		$ret = array();
552
+
553
+		foreach ($this->_filtersel2options as $key => $value) {
554
+			$field             = array();
555
+			$field['caption']  = $value;
556
+			$field['selected'] = $this->_filtersel2 == $key ? "selected='selected'" : '';
557
+			$ret[$key]         = $field;
558
+			unset($field);
559
+		}
560
+
561
+		return $ret;
562
+	}
563
+
564
+	/**
565
+	 * @param $limitsArray
566
+	 * @param $params_of_the_options_sel
567
+	 */
568
+	public function renderOptionSelection($limitsArray, $params_of_the_options_sel)
569
+	{
570
+		// Rendering the form to select options on the table
571
+		$current_urls = smart_getCurrentUrls();
572
+		$current_url  = $current_urls['full'];
573
+
574
+		/**
575
+		 * What was $params_of_the_options_sel doing again ?
576
+		 */
577
+		//$this->_tpl->assign('smartobject_optionssel_action', $_SERVER['PHP_SELF'] . "?" . implode('&', $params_of_the_options_sel));
578
+		$this->_tpl->assign('smartobject_optionssel_action', $current_url);
579
+		$this->_tpl->assign('smartobject_optionssel_limitsArray', $limitsArray);
580
+	}
581
+
582
+	/**
583
+	 * @return array
584
+	 */
585
+	public function getLimitsArray()
586
+	{
587
+		$ret                    = array();
588
+		$ret['all']['caption']  = _CO_SOBJECT_LIMIT_ALL;
589
+		$ret['all']['selected'] = ('all' === $this->_limitsel) ? "selected='selected'" : '';
590
+
591
+		$ret['5']['caption']  = '5';
592
+		$ret['5']['selected'] = ('5' == $this->_limitsel) ? "selected='selected'" : '';
593
+
594
+		$ret['10']['caption']  = '10';
595
+		$ret['10']['selected'] = ('10' == $this->_limitsel) ? "selected='selected'" : '';
596
+
597
+		$ret['15']['caption']  = '15';
598
+		$ret['15']['selected'] = ('15' == $this->_limitsel) ? "selected='selected'" : '';
599
+
600
+		$ret['20']['caption']  = '20';
601
+		$ret['20']['selected'] = ('20' == $this->_limitsel) ? "selected='selected'" : '';
602
+
603
+		$ret['25']['caption']  = '25';
604
+		$ret['25']['selected'] = ('25' == $this->_limitsel) ? "selected='selected'" : '';
605
+
606
+		$ret['30']['caption']  = '30';
607
+		$ret['30']['selected'] = ('30' == $this->_limitsel) ? "selected='selected'" : '';
608
+
609
+		$ret['35']['caption']  = '35';
610
+		$ret['35']['selected'] = ('35' == $this->_limitsel) ? "selected='selected'" : '';
611
+
612
+		$ret['40']['caption']  = '40';
613
+		$ret['40']['selected'] = ('40' == $this->_limitsel) ? "selected='selected'" : '';
614
+
615
+		return $ret;
616
+	}
617
+
618
+	/**
619
+	 * @return bool
620
+	 */
621
+	public function getObjects()
622
+	{
623
+		return $this->_objects;
624
+	}
625
+
626
+	public function hideActionColumnTitle()
627
+	{
628
+		$this->_showActionsColumnTitle = false;
629
+	}
630
+
631
+	public function hideFilterAndLimit()
632
+	{
633
+		$this->_showFilterAndLimit = false;
634
+	}
635
+
636
+	/**
637
+	 * @return array
638
+	 */
639
+	public function getOrdersArray()
640
+	{
641
+		$ret                    = array();
642
+		$ret['ASC']['caption']  = _CO_SOBJECT_SORT_ASC;
643
+		$ret['ASC']['selected'] = ('ASC' === $this->_ordersel) ? "selected='selected'" : '';
644
+
645
+		$ret['DESC']['caption']  = _CO_SOBJECT_SORT_DESC;
646
+		$ret['DESC']['selected'] = ('DESC' === $this->_ordersel) ? "selected='selected'" : '';
647
+
648
+		return $ret;
649
+	}
650
+
651
+	/**
652
+	 * @return mixed|string|void
653
+	 */
654
+	public function renderD()
655
+	{
656
+		return $this->render(false, true);
657
+	}
658
+
659
+	public function renderForPrint()
660
+	{
661
+	}
662
+
663
+	/**
664
+	 * @param  bool $fetchOnly
665
+	 * @param  bool $debug
666
+	 * @return mixed|string|void
667
+	 */
668
+	public function render($fetchOnly = false, $debug = false)
669
+	{
670
+		include_once XOOPS_ROOT_PATH . '/class/template.php';
671
+
672
+		$this->_tpl = new XoopsTpl();
673
+
674
+		/**
675
+		 * We need access to the vars of the SmartObject for a few things in the table creation.
676
+		 * Since we may not have a SmartObject to look into now, let's create one for this purpose
677
+		 * and we will free it after
678
+		 */
679
+		$this->_tempObject = $this->_objectHandler->create();
680
+
681
+		$this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int)$_GET['start' . $this->_objectHandler->keyName] : 0);
682
+
683
+		$this->setSortOrder();
684
+
685
+		if (!$this->_isTree) {
686
+			$this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15');
687
+		} else {
688
+			$this->_limitsel = 'all';
689
+		}
690
+
691
+		$this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
692
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel);
693
+		$limitsArray = $this->getLimitsArray();
694
+		$this->_criteria->setLimit($this->_limitsel);
695
+
696
+		$this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter();
697
+		$this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel;
698
+		smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
699
+		$filtersArray = $this->getFiltersArray();
700
+
701
+		if ($filtersArray) {
702
+			$this->_tpl->assign('smartobject_optionssel_filtersArray', $filtersArray);
703
+		}
704
+
705
+		// Check if the selected filter is defined and if so, create the selfilter2
706
+		if (isset($this->_filterseloptions[$this->_filtersel])) {
707
+			// check if method associate with this filter exists in the handler
708
+			if (is_array($this->_filterseloptions[$this->_filtersel])) {
709
+				$filter = $this->_filterseloptions[$this->_filtersel];
710
+				$this->_criteria->add($filter['criteria']);
711
+			} else {
712
+				if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) {
713
+
714
+					// then we will create the selfilter2 options by calling this method
715
+					$method                   = $this->_filterseloptions[$this->_filtersel];
716
+					$this->_filtersel2options = $this->_objectHandler->$method();
717
+
718
+					$this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2();
719
+					$this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2;
720
+
721
+					$filters2Array = $this->getFilters2Array();
722
+					$this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array);
723
+
724
+					smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2);
725
+					if ($this->_filtersel2 !== 'default') {
726
+						$this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2));
727
+					}
728
+				}
729
+			}
730
+		}
731
+		// Check if we have a quicksearch
732
+
733
+		if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
734
+			$quicksearch_criteria = new CriteriaCompo();
735
+			if (is_array($this->_quickSearch['fields'])) {
736
+				foreach ($this->_quickSearch['fields'] as $v) {
737
+					$quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
738
+				}
739
+			} else {
740
+				$quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
741
+			}
742
+			$this->_criteria->add($quicksearch_criteria);
743
+		}
744
+
745
+		$this->_objects = $this->fetchObjects($debug);
746
+
747
+		include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
748
+		if ($this->_criteria->getLimit() > 0) {
749
+
750
+			/**
751
+			 * Geeting rid of the old params
752
+			 * $new_get_array is an array containing the new GET parameters
753
+			 */
754
+			$new_get_array = array();
755
+
756
+			/**
757
+			 * $params_of_the_options_sel is an array with all the parameters of the page
758
+			 * but without the pagenave parameters. This array will be used in the
759
+			 * OptionsSelection
760
+			 */
761
+			$params_of_the_options_sel = array();
762
+
763
+			$not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName);
764
+			foreach ($_GET as $k => $v) {
765
+				if (!in_array($k, $not_needed_params)) {
766
+					$new_get_array[]             = "$k=$v";
767
+					$params_of_the_options_sel[] = "$k=$v";
768
+				}
769
+			}
770
+
771
+			/**
772
+			 * Adding the new params of the pagenav
773
+			 */
774
+			$new_get_array[] = 'sortsel=' . $this->_sortsel;
775
+			$new_get_array[] = 'ordersel=' . $this->_ordersel;
776
+			$new_get_array[] = 'limitsel=' . $this->_limitsel;
777
+			$otherParams     = implode('&', $new_get_array);
778
+
779
+			$pagenav = new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
780
+			$this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav());
781
+		}
782
+		$this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
783
+
784
+		// retreive the current url and the query string
785
+		$current_urls = smart_getCurrentUrls();
786
+		$current_url  = $current_urls['full_phpself'];
787
+		$query_string = $current_urls['querystring'];
788
+		if ($query_string) {
789
+			$query_string = str_replace('?', '', $query_string);
790
+		}
791
+		$query_stringArray     = explode('&', $query_string);
792
+		$new_query_stringArray = array();
793
+		foreach ($query_stringArray as $query_string) {
794
+			if (strpos($query_string, 'sortsel') == false && strpos($query_string, 'ordersel') == false) {
795
+				$new_query_stringArray[] = $query_string;
796
+			}
797
+		}
798
+		$new_query_string = implode('&', $new_query_stringArray);
799
+
800
+		$orderArray                     = array();
801
+		$orderArray['ASC']['image']     = 'desc.png';
802
+		$orderArray['ASC']['neworder']  = 'DESC';
803
+		$orderArray['DESC']['image']    = 'asc.png';
804
+		$orderArray['DESC']['neworder'] = 'ASC';
805
+
806
+		$aColumns = array();
807
+
808
+		foreach ($this->_columns as $column) {
809
+			$qs_param         = '';
810
+			$aColumn          = array();
811
+			$aColumn['width'] = $column->getWidth();
812
+			$aColumn['align'] = $column->getAlign();
813
+			$aColumn['key']   = $column->getKeyName();
814
+			if ($column->_keyname === 'checked') {
815
+				$aColumn['caption'] = '<input type ="checkbox" id="checkall_smartobjects" name="checkall_smartobjects"' . ' value="checkall_smartobjects" onclick="smartobject_checkall(window.document.form_' . $this->_id . ', \'selected_smartobjects\');" />';
816
+			} elseif ($column->getCustomCaption()) {
817
+				$aColumn['caption'] = $column->getCustomCaption();
818
+			} else {
819
+				$aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName();
820
+			}
821
+			// Are we doing a GET sort on this column ?
822
+			$getSort = (isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName()) || ($this->_sortsel == $column->getKeyName());
823
+			$order   = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC';
824
+
825
+			if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') {
826
+				$qs_param = '&quicksearch_' . $this->_id . '=' . $_REQUEST['quicksearch_' . $this->_id];
827
+			}
828
+			if (!$this->_enableColumnsSorting || $column->_keyname === 'checked' || !$column->isSortable()) {
829
+				$aColumn['caption'] = $aColumn['caption'];
830
+			} elseif ($getSort) {
831
+				$aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=' . $orderArray[$order]['neworder'] . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . ' <img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . $orderArray[$order]['image'] . '" alt="ASC" /></a>';
832
+			} else {
833
+				$aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=ASC' . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . '</a>';
834
+			}
835
+			$aColumns[] = $aColumn;
836
+		}
837
+		$this->_tpl->assign('smartobject_columns', $aColumns);
838
+
839
+		if ($this->_quickSearch) {
840
+			$this->_tpl->assign('smartobject_quicksearch', $this->_quickSearch['caption']);
841
+		}
842
+
843
+		$this->createTableRows();
844
+
845
+		$this->_tpl->assign('smartobject_showFilterAndLimit', $this->_showFilterAndLimit);
846
+		$this->_tpl->assign('smartobject_isTree', $this->_isTree);
847
+		$this->_tpl->assign('smartobject_show_action_column_title', $this->_showActionsColumnTitle);
848
+		$this->_tpl->assign('smartobject_table_header', $this->_tableHeader);
849
+		$this->_tpl->assign('smartobject_table_footer', $this->_tableFooter);
850
+		$this->_tpl->assign('smartobject_printer_friendly_page', $this->_printerFriendlyPage);
851
+		$this->_tpl->assign('smartobject_user_side', $this->_userSide);
852
+		$this->_tpl->assign('smartobject_has_actions', $this->_hasActions);
853
+		$this->_tpl->assign('smartobject_head_css_class', $this->_head_css_class);
854
+		$this->_tpl->assign('smartobject_actionButtons', $this->_actionButtons);
855
+		$this->_tpl->assign('smartobject_introButtons', $this->_introButtons);
856
+		$this->_tpl->assign('smartobject_id', $this->_id);
857
+		if (!empty($this->_withSelectedActions)) {
858
+			$this->_tpl->assign('smartobject_withSelectedActions', $this->_withSelectedActions);
859
+		}
860
+
861
+		$smartobjectTable_template = $this->_customTemplate ?: 'smartobject_smarttable_display.tpl';
862
+		if ($fetchOnly) {
863
+			return $this->_tpl->fetch('db:' . $smartobjectTable_template);
864
+		} else {
865
+			$this->_tpl->display('db:' . $smartobjectTable_template);
866
+		}
867
+	}
868
+
869
+	public function disableColumnsSorting()
870
+	{
871
+		$this->_enableColumnsSorting = false;
872
+	}
873
+
874
+	/**
875
+	 * @param  bool $debug
876
+	 * @return mixed|string|void
877
+	 */
878
+	public function fetch($debug = false)
879
+	{
880
+		return $this->render(true, $debug);
881
+	}
882 882
 }
Please login to merge, or discard this patch.
class/smarthookhandler.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
6 6
  */
7 7
 class SmartHookHandler
8 8
 {
9
-    /**
10
-     * SmartHookHandler constructor.
11
-     */
12
-    public function __construct()
13
-    {
14
-    }
9
+	/**
10
+	 * SmartHookHandler constructor.
11
+	 */
12
+	public function __construct()
13
+	{
14
+	}
15 15
 
16
-    /**
17
-     * Access the only instance of this class
18
-     *
19
-     * @return object
20
-     *
21
-     * @static
22
-     * @staticvar   object
23
-     */
24
-    public static function getInstance()
25
-    {
26
-        static $instance;
27
-        if (!isset($instance)) {
28
-            $instance = new SmartHookHandler();
29
-        }
16
+	/**
17
+	 * Access the only instance of this class
18
+	 *
19
+	 * @return object
20
+	 *
21
+	 * @static
22
+	 * @staticvar   object
23
+	 */
24
+	public static function getInstance()
25
+	{
26
+		static $instance;
27
+		if (!isset($instance)) {
28
+			$instance = new SmartHookHandler();
29
+		}
30 30
 
31
-        return $instance;
32
-    }
31
+		return $instance;
32
+	}
33 33
 
34
-    /**
35
-     * @param $hook_name
36
-     */
37
-    public function executeHook($hook_name)
38
-    {
39
-        $lower_hook_name = strtolower($hook_name);
40
-        $filename        = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
41
-        if (file_exists($filename)) {
42
-            include_once($filename);
43
-            $function = 'smarthook_' . $lower_hook_name;
44
-            if (function_exists($function)) {
45
-                $function();
46
-            }
47
-        }
48
-    }
34
+	/**
35
+	 * @param $hook_name
36
+	 */
37
+	public function executeHook($hook_name)
38
+	{
39
+		$lower_hook_name = strtolower($hook_name);
40
+		$filename        = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
41
+		if (file_exists($filename)) {
42
+			include_once($filename);
43
+			$function = 'smarthook_' . $lower_hook_name;
44
+			if (function_exists($function)) {
45
+				$function();
46
+			}
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
class/smartloader.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Loader for the SmartObject framework
4
- *
5
- * This file is responible for including some main files used by the smartobject framework.
6
- *
7
- * @license    GNU
8
- * @author     marcan <[email protected]>
9
- * @link       http://smartfactory.ca The SmartFactory
10
- * @package    SmartObject
11
- * @subpackage SmartObjectCore
12
- */
3
+	 * Loader for the SmartObject framework
4
+	 *
5
+	 * This file is responible for including some main files used by the smartobject framework.
6
+	 *
7
+	 * @license    GNU
8
+	 * @author     marcan <[email protected]>
9
+	 * @link       http://smartfactory.ca The SmartFactory
10
+	 * @package    SmartObject
11
+	 * @subpackage SmartObjectCore
12
+	 */
13 13
 
14 14
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
15 15
 
@@ -30,6 +30,6 @@  discard block
 block discarded – undo
30 30
 $smarthookHandler = SmartHookHandler::getInstance();
31 31
 
32 32
 if (!class_exists('smartmetagen')) {
33
-    include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php');
33
+	include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php');
34 34
 }
35 35
 //$smartobjectConfig = smart_getModuleConfig('smartobject');
Please login to merge, or discard this patch.
class/smartplugins.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -5,68 +5,68 @@  discard block
 block discarded – undo
5 5
  */
6 6
 class SmartPlugin
7 7
 {
8
-    public $_infoArray;
9
-
10
-    /**
11
-     * SmartPlugin constructor.
12
-     * @param $array
13
-     */
14
-    public function __construct($array)
15
-    {
16
-        $this->_infoArray = $array;
17
-    }
18
-
19
-    /**
20
-     * @param $item
21
-     * @return bool
22
-     */
23
-    public function getItemInfo($item)
24
-    {
25
-        if (isset($this->_infoArray['items'][$item])) {
26
-            return $this->_infoArray['items'][$item];
27
-        } else {
28
-            return false;
29
-        }
30
-    }
31
-
32
-    /**
33
-     * @return mixed
34
-     */
35
-    public function getItemList()
36
-    {
37
-        $itemsArray = $this->_infoArray['items'];
38
-        foreach ($itemsArray as $k => $v) {
39
-            $ret[$k] = $v['caption'];
40
-        }
41
-
42
-        return $ret;
43
-    }
44
-
45
-    /**
46
-     * @return bool|int|string
47
-     */
48
-    public function getItem()
49
-    {
50
-        $ret = false;
51
-        foreach ($this->_infoArray['items'] as $k => $v) {
52
-            $search_str = str_replace('%u', '', $v['url']);
53
-            if (strpos($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], $search_str) > 0) {
54
-                $ret = $k;
55
-                break;
56
-            }
57
-        }
58
-
59
-        return $ret;
60
-    }
61
-
62
-    /**
63
-     * @param $item
64
-     * @return mixed
65
-     */
66
-    public function getItemIdForItem($item)
67
-    {
68
-        return $_REQUEST[$this->_infoArray['items'][$item]['request']];
69
-    }
8
+	public $_infoArray;
9
+
10
+	/**
11
+	 * SmartPlugin constructor.
12
+	 * @param $array
13
+	 */
14
+	public function __construct($array)
15
+	{
16
+		$this->_infoArray = $array;
17
+	}
18
+
19
+	/**
20
+	 * @param $item
21
+	 * @return bool
22
+	 */
23
+	public function getItemInfo($item)
24
+	{
25
+		if (isset($this->_infoArray['items'][$item])) {
26
+			return $this->_infoArray['items'][$item];
27
+		} else {
28
+			return false;
29
+		}
30
+	}
31
+
32
+	/**
33
+	 * @return mixed
34
+	 */
35
+	public function getItemList()
36
+	{
37
+		$itemsArray = $this->_infoArray['items'];
38
+		foreach ($itemsArray as $k => $v) {
39
+			$ret[$k] = $v['caption'];
40
+		}
41
+
42
+		return $ret;
43
+	}
44
+
45
+	/**
46
+	 * @return bool|int|string
47
+	 */
48
+	public function getItem()
49
+	{
50
+		$ret = false;
51
+		foreach ($this->_infoArray['items'] as $k => $v) {
52
+			$search_str = str_replace('%u', '', $v['url']);
53
+			if (strpos($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], $search_str) > 0) {
54
+				$ret = $k;
55
+				break;
56
+			}
57
+		}
58
+
59
+		return $ret;
60
+	}
61
+
62
+	/**
63
+	 * @param $item
64
+	 * @return mixed
65
+	 */
66
+	public function getItemIdForItem($item)
67
+	{
68
+		return $_REQUEST[$this->_infoArray['items'][$item]['request']];
69
+	}
70 70
 }
71 71
 
72 72
 /**
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
  */
75 75
 class SmartPluginHandler
76 76
 {
77
-    public $pluginPatterns = false;
78
-
79
-    /**
80
-     * @param $dirname
81
-     * @return bool|SmartPlugin
82
-     */
83
-    public function getPlugin($dirname)
84
-    {
85
-        $pluginName = SMARTOBJECT_ROOT_PATH . 'plugins/' . $dirname . '.php';
86
-        if (file_exists($pluginName)) {
87
-            include_once($pluginName);
88
-            $function = 'smartobject_plugin_' . $dirname;
89
-            if (function_exists($function)) {
90
-                $array = $function();
91
-                $ret   = new SmartPlugin($array);
92
-
93
-                return $ret;
94
-            }
95
-        }
96
-
97
-        return false;
98
-    }
99
-
100
-    /**
101
-     * @return array
102
-     */
103
-    public function getPluginsArray()
104
-    {
105
-        include_once(XOOPS_ROOT_PATH . '/class/xoopslists.php');
106
-
107
-        $moduleHandler = xoops_getHandler('module');
108
-        $criteria       = new CriteriaCompo();
109
-        $criteria->add(new Criteria('isactive', 1));
110
-        $tempModulesObj = $moduleHandler->getObjects($criteria);
111
-        $modulesObj     = array();
112
-        foreach ($tempModulesObj as $moduleObj) {
113
-            $modulesObj[$moduleObj->getVar('dirname')] = $moduleObj;
114
-        }
115
-
116
-        $aFiles = XoopsLists::getFileListAsArray(SMARTOBJECT_ROOT_PATH . 'plugins/');
117
-        $ret    = array();
118
-        foreach ($aFiles as $file) {
119
-            if (substr($file, strlen($file) - 4, 4) === '.php') {
120
-                $pluginName                = str_replace('.php', '', $file);
121
-                $module_xoops_version_file = XOOPS_ROOT_PATH . "/modules/$pluginName/xoops_version.php";
122
-                if (file_exists($module_xoops_version_file) && isset($modulesObj[$pluginName])) {
123
-                    $ret[$pluginName] = $modulesObj[$pluginName]->getVar('name');
124
-                }
125
-            }
126
-        }
127
-
128
-        return $ret;
129
-    }
77
+	public $pluginPatterns = false;
78
+
79
+	/**
80
+	 * @param $dirname
81
+	 * @return bool|SmartPlugin
82
+	 */
83
+	public function getPlugin($dirname)
84
+	{
85
+		$pluginName = SMARTOBJECT_ROOT_PATH . 'plugins/' . $dirname . '.php';
86
+		if (file_exists($pluginName)) {
87
+			include_once($pluginName);
88
+			$function = 'smartobject_plugin_' . $dirname;
89
+			if (function_exists($function)) {
90
+				$array = $function();
91
+				$ret   = new SmartPlugin($array);
92
+
93
+				return $ret;
94
+			}
95
+		}
96
+
97
+		return false;
98
+	}
99
+
100
+	/**
101
+	 * @return array
102
+	 */
103
+	public function getPluginsArray()
104
+	{
105
+		include_once(XOOPS_ROOT_PATH . '/class/xoopslists.php');
106
+
107
+		$moduleHandler = xoops_getHandler('module');
108
+		$criteria       = new CriteriaCompo();
109
+		$criteria->add(new Criteria('isactive', 1));
110
+		$tempModulesObj = $moduleHandler->getObjects($criteria);
111
+		$modulesObj     = array();
112
+		foreach ($tempModulesObj as $moduleObj) {
113
+			$modulesObj[$moduleObj->getVar('dirname')] = $moduleObj;
114
+		}
115
+
116
+		$aFiles = XoopsLists::getFileListAsArray(SMARTOBJECT_ROOT_PATH . 'plugins/');
117
+		$ret    = array();
118
+		foreach ($aFiles as $file) {
119
+			if (substr($file, strlen($file) - 4, 4) === '.php') {
120
+				$pluginName                = str_replace('.php', '', $file);
121
+				$module_xoops_version_file = XOOPS_ROOT_PATH . "/modules/$pluginName/xoops_version.php";
122
+				if (file_exists($module_xoops_version_file) && isset($modulesObj[$pluginName])) {
123
+					$ret[$pluginName] = $modulesObj[$pluginName]->getVar('name');
124
+				}
125
+			}
126
+		}
127
+
128
+		return $ret;
129
+	}
130 130
 }
Please login to merge, or discard this patch.