@@ -29,87 +29,87 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class Adsense extends Smartobject\BaseSmartObject |
31 | 31 | { |
32 | - /** |
|
33 | - * SmartobjectAdsense constructor. |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - $this->quickInitVar('adsenseid', XOBJ_DTYPE_INT, true); |
|
38 | - $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_ADSENSE_DESCRIPTION, _CO_SOBJECT_ADSENSE_DESCRIPTION_DSC); |
|
39 | - $this->quickInitVar('client_id', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_CLIENT_ID, _CO_SOBJECT_ADSENSE_CLIENT_ID_DSC); |
|
40 | - $this->quickInitVar('tag', XOBJ_DTYPE_TXTBOX, false, _CO_SOBJECT_ADSENSE_TAG, _CO_SOBJECT_ADSENSE_TAG_DSC); |
|
41 | - $this->quickInitVar('format', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_FORMAT, _CO_SOBJECT_ADSENSE_FORMAT_DSC); |
|
42 | - $this->quickInitVar('border_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BORDER_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC); |
|
43 | - $this->quickInitVar('background_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BACKGROUND_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC); |
|
44 | - $this->quickInitVar('link_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_LINK_COLOR, _CO_SOBJECT_ADSENSE_LINK_COLOR_DSC); |
|
45 | - $this->quickInitVar('url_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_URL_COLOR, _CO_SOBJECT_ADSENSE_URL_COLOR_DSC); |
|
46 | - $this->quickInitVar('text_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_TEXT_COLOR, _CO_SOBJECT_ADSENSE_TEXT_COLOR_DSC); |
|
47 | - $this->quickInitVar('style', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_ADSENSE_STYLE, _CO_SOBJECT_ADSENSE_STYLE_DSC); |
|
32 | + /** |
|
33 | + * SmartobjectAdsense constructor. |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + $this->quickInitVar('adsenseid', XOBJ_DTYPE_INT, true); |
|
38 | + $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_ADSENSE_DESCRIPTION, _CO_SOBJECT_ADSENSE_DESCRIPTION_DSC); |
|
39 | + $this->quickInitVar('client_id', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_CLIENT_ID, _CO_SOBJECT_ADSENSE_CLIENT_ID_DSC); |
|
40 | + $this->quickInitVar('tag', XOBJ_DTYPE_TXTBOX, false, _CO_SOBJECT_ADSENSE_TAG, _CO_SOBJECT_ADSENSE_TAG_DSC); |
|
41 | + $this->quickInitVar('format', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_FORMAT, _CO_SOBJECT_ADSENSE_FORMAT_DSC); |
|
42 | + $this->quickInitVar('border_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BORDER_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC); |
|
43 | + $this->quickInitVar('background_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BACKGROUND_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC); |
|
44 | + $this->quickInitVar('link_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_LINK_COLOR, _CO_SOBJECT_ADSENSE_LINK_COLOR_DSC); |
|
45 | + $this->quickInitVar('url_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_URL_COLOR, _CO_SOBJECT_ADSENSE_URL_COLOR_DSC); |
|
46 | + $this->quickInitVar('text_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_TEXT_COLOR, _CO_SOBJECT_ADSENSE_TEXT_COLOR_DSC); |
|
47 | + $this->quickInitVar('style', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_ADSENSE_STYLE, _CO_SOBJECT_ADSENSE_STYLE_DSC); |
|
48 | 48 | |
49 | - $this->setControl('format', [ |
|
50 | - 'handler' => 'adsense', |
|
51 | - 'method' => 'getFormats' |
|
52 | - ]); |
|
49 | + $this->setControl('format', [ |
|
50 | + 'handler' => 'adsense', |
|
51 | + 'method' => 'getFormats' |
|
52 | + ]); |
|
53 | 53 | |
54 | - $this->setControl('border_color', [ |
|
55 | - 'name' => 'text', |
|
56 | - 'size' => 6, |
|
57 | - 'maxlength' => 6 |
|
58 | - ]); |
|
54 | + $this->setControl('border_color', [ |
|
55 | + 'name' => 'text', |
|
56 | + 'size' => 6, |
|
57 | + 'maxlength' => 6 |
|
58 | + ]); |
|
59 | 59 | |
60 | - $this->setControl('background_color', [ |
|
61 | - 'name' => 'text', |
|
62 | - 'size' => 6, |
|
63 | - 'maxlength' => 6 |
|
64 | - ]); |
|
60 | + $this->setControl('background_color', [ |
|
61 | + 'name' => 'text', |
|
62 | + 'size' => 6, |
|
63 | + 'maxlength' => 6 |
|
64 | + ]); |
|
65 | 65 | |
66 | - $this->setControl('link_color', [ |
|
67 | - 'name' => 'text', |
|
68 | - 'size' => 6, |
|
69 | - 'maxlength' => 6 |
|
70 | - ]); |
|
66 | + $this->setControl('link_color', [ |
|
67 | + 'name' => 'text', |
|
68 | + 'size' => 6, |
|
69 | + 'maxlength' => 6 |
|
70 | + ]); |
|
71 | 71 | |
72 | - $this->setControl('url_color', [ |
|
73 | - 'name' => 'text', |
|
74 | - 'size' => 6, |
|
75 | - 'maxlength' => 6 |
|
76 | - ]); |
|
72 | + $this->setControl('url_color', [ |
|
73 | + 'name' => 'text', |
|
74 | + 'size' => 6, |
|
75 | + 'maxlength' => 6 |
|
76 | + ]); |
|
77 | 77 | |
78 | - $this->setControl('text_color', [ |
|
79 | - 'name' => 'text', |
|
80 | - 'size' => 6, |
|
81 | - 'maxlength' => 6 |
|
82 | - ]); |
|
83 | - } |
|
78 | + $this->setControl('text_color', [ |
|
79 | + 'name' => 'text', |
|
80 | + 'size' => 6, |
|
81 | + 'maxlength' => 6 |
|
82 | + ]); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $key |
|
87 | - * @param string $format |
|
88 | - * @return mixed |
|
89 | - */ |
|
90 | - public function getVar($key, $format = 's') |
|
91 | - { |
|
92 | - if ('s' === $format && in_array($key, [])) { |
|
93 | - // return call_user_func(array($this, $key)); |
|
94 | - return $this->{$key}(); |
|
95 | - } |
|
85 | + /** |
|
86 | + * @param string $key |
|
87 | + * @param string $format |
|
88 | + * @return mixed |
|
89 | + */ |
|
90 | + public function getVar($key, $format = 's') |
|
91 | + { |
|
92 | + if ('s' === $format && in_array($key, [])) { |
|
93 | + // return call_user_func(array($this, $key)); |
|
94 | + return $this->{$key}(); |
|
95 | + } |
|
96 | 96 | |
97 | - return parent::getVar($key, $format); |
|
98 | - } |
|
97 | + return parent::getVar($key, $format); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function render() |
|
104 | - { |
|
105 | - global $smartobjectAdsenseHandler; |
|
106 | - if ('' !== $this->getVar('style', 'n')) { |
|
107 | - $ret = '<div style="' . $this->getVar('style', 'n') . '">'; |
|
108 | - } else { |
|
109 | - $ret = '<div>'; |
|
110 | - } |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function render() |
|
104 | + { |
|
105 | + global $smartobjectAdsenseHandler; |
|
106 | + if ('' !== $this->getVar('style', 'n')) { |
|
107 | + $ret = '<div style="' . $this->getVar('style', 'n') . '">'; |
|
108 | + } else { |
|
109 | + $ret = '<div>'; |
|
110 | + } |
|
111 | 111 | |
112 | - $ret .= '<script type="text/javascript"><!-- |
|
112 | + $ret .= '<script type="text/javascript"><!-- |
|
113 | 113 | google_ad_client = "' . $this->getVar('client_id', 'n') . '"; |
114 | 114 | google_ad_width = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['width'] . '; |
115 | 115 | google_ad_height = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['height'] . '; |
@@ -127,137 +127,137 @@ discard block |
||
127 | 127 | </script> |
128 | 128 | </div>'; |
129 | 129 | |
130 | - return $ret; |
|
131 | - } |
|
130 | + return $ret; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function getXoopsCode() |
|
137 | - { |
|
138 | - $ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]'; |
|
133 | + /** |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function getXoopsCode() |
|
137 | + { |
|
138 | + $ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]'; |
|
139 | 139 | |
140 | - return $ret; |
|
141 | - } |
|
140 | + return $ret; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * @param $var |
|
145 | - * @return bool |
|
146 | - */ |
|
147 | - public function emptyString($var) |
|
148 | - { |
|
149 | - return (strlen($var) > 0); |
|
150 | - } |
|
143 | + /** |
|
144 | + * @param $var |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | + public function emptyString($var) |
|
148 | + { |
|
149 | + return (strlen($var) > 0); |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @return mixed|string |
|
154 | - */ |
|
155 | - public function generateTag() |
|
156 | - { |
|
157 | - $title = rawurlencode(strtolower($this->getVar('description', 'e'))); |
|
158 | - $title = xoops_substr($title, 0, 10, ''); |
|
159 | - // Transformation des ponctuations |
|
160 | - $pattern = [ |
|
161 | - '/%09/', // Tab |
|
162 | - '/%20/', // Space |
|
163 | - '/%21/', // ! |
|
164 | - '/%22/', // " |
|
165 | - '/%23/', // # |
|
166 | - '/%25/', // % |
|
167 | - '/%26/', // & |
|
168 | - '/%27/', // ' |
|
169 | - '/%28/', // ( |
|
170 | - '/%29/', // ) |
|
171 | - '/%2C/', // , |
|
172 | - '/%2F/', // / |
|
173 | - '/%3A/', // : |
|
174 | - '/%3B/', // ; |
|
175 | - '/%3C/', // < |
|
176 | - '/%3D/', // = |
|
177 | - '/%3E/', // > |
|
178 | - '/%3F/', // ? |
|
179 | - '/%40/', // @ |
|
180 | - '/%5B/', // [ |
|
181 | - '/%5C/', // \ |
|
182 | - '/%5D/', // ] |
|
183 | - '/%5E/', // ^ |
|
184 | - '/%7B/', // { |
|
185 | - '/%7C/', // | |
|
186 | - '/%7D/', // } |
|
187 | - '/%7E/', // ~ |
|
188 | - "/\./" // . |
|
189 | - ]; |
|
190 | - $rep_pat = [ |
|
191 | - '-', |
|
192 | - '-', |
|
193 | - '-', |
|
194 | - '-', |
|
195 | - '-', |
|
196 | - '-100', |
|
197 | - '-', |
|
198 | - '-', |
|
199 | - '-', |
|
200 | - '-', |
|
201 | - '-', |
|
202 | - '-', |
|
203 | - '-', |
|
204 | - '-', |
|
205 | - '-', |
|
206 | - '-', |
|
207 | - '-', |
|
208 | - '-', |
|
209 | - '-at-', |
|
210 | - '-', |
|
211 | - '-', |
|
212 | - '-', |
|
213 | - '-', |
|
214 | - '-', |
|
215 | - '-', |
|
216 | - '-', |
|
217 | - '-', |
|
218 | - '-' |
|
219 | - ]; |
|
220 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
152 | + /** |
|
153 | + * @return mixed|string |
|
154 | + */ |
|
155 | + public function generateTag() |
|
156 | + { |
|
157 | + $title = rawurlencode(strtolower($this->getVar('description', 'e'))); |
|
158 | + $title = xoops_substr($title, 0, 10, ''); |
|
159 | + // Transformation des ponctuations |
|
160 | + $pattern = [ |
|
161 | + '/%09/', // Tab |
|
162 | + '/%20/', // Space |
|
163 | + '/%21/', // ! |
|
164 | + '/%22/', // " |
|
165 | + '/%23/', // # |
|
166 | + '/%25/', // % |
|
167 | + '/%26/', // & |
|
168 | + '/%27/', // ' |
|
169 | + '/%28/', // ( |
|
170 | + '/%29/', // ) |
|
171 | + '/%2C/', // , |
|
172 | + '/%2F/', // / |
|
173 | + '/%3A/', // : |
|
174 | + '/%3B/', // ; |
|
175 | + '/%3C/', // < |
|
176 | + '/%3D/', // = |
|
177 | + '/%3E/', // > |
|
178 | + '/%3F/', // ? |
|
179 | + '/%40/', // @ |
|
180 | + '/%5B/', // [ |
|
181 | + '/%5C/', // \ |
|
182 | + '/%5D/', // ] |
|
183 | + '/%5E/', // ^ |
|
184 | + '/%7B/', // { |
|
185 | + '/%7C/', // | |
|
186 | + '/%7D/', // } |
|
187 | + '/%7E/', // ~ |
|
188 | + "/\./" // . |
|
189 | + ]; |
|
190 | + $rep_pat = [ |
|
191 | + '-', |
|
192 | + '-', |
|
193 | + '-', |
|
194 | + '-', |
|
195 | + '-', |
|
196 | + '-100', |
|
197 | + '-', |
|
198 | + '-', |
|
199 | + '-', |
|
200 | + '-', |
|
201 | + '-', |
|
202 | + '-', |
|
203 | + '-', |
|
204 | + '-', |
|
205 | + '-', |
|
206 | + '-', |
|
207 | + '-', |
|
208 | + '-', |
|
209 | + '-at-', |
|
210 | + '-', |
|
211 | + '-', |
|
212 | + '-', |
|
213 | + '-', |
|
214 | + '-', |
|
215 | + '-', |
|
216 | + '-', |
|
217 | + '-', |
|
218 | + '-' |
|
219 | + ]; |
|
220 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
221 | 221 | |
222 | - // Transformation des caractères accentués |
|
223 | - $pattern = [ |
|
224 | - '/%B0/', // ° |
|
225 | - '/%E8/', // è |
|
226 | - '/%E9/', // é |
|
227 | - '/%EA/', // ê |
|
228 | - '/%EB/', // ë |
|
229 | - '/%E7/', // ç |
|
230 | - '/%E0/', // à |
|
231 | - '/%E2/', // â |
|
232 | - '/%E4/', // ä |
|
233 | - '/%EE/', // î |
|
234 | - '/%EF/', // ï |
|
235 | - '/%F9/', // ù |
|
236 | - '/%FC/', // ü |
|
237 | - '/%FB/', // û |
|
238 | - '/%F4/', // ô |
|
239 | - '/%F6/', // ö |
|
240 | - ]; |
|
241 | - $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o']; |
|
242 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
222 | + // Transformation des caractères accentués |
|
223 | + $pattern = [ |
|
224 | + '/%B0/', // ° |
|
225 | + '/%E8/', // è |
|
226 | + '/%E9/', // é |
|
227 | + '/%EA/', // ê |
|
228 | + '/%EB/', // ë |
|
229 | + '/%E7/', // ç |
|
230 | + '/%E0/', // à |
|
231 | + '/%E2/', // â |
|
232 | + '/%E4/', // ä |
|
233 | + '/%EE/', // î |
|
234 | + '/%EF/', // ï |
|
235 | + '/%F9/', // ù |
|
236 | + '/%FC/', // ü |
|
237 | + '/%FB/', // û |
|
238 | + '/%F4/', // ô |
|
239 | + '/%F6/', // ö |
|
240 | + ]; |
|
241 | + $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o']; |
|
242 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
243 | 243 | |
244 | - $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
245 | - $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau |
|
246 | - $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
244 | + $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
245 | + $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau |
|
246 | + $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
247 | 247 | |
248 | - $title .= time(); |
|
249 | - $title = md5($title); |
|
248 | + $title .= time(); |
|
249 | + $title = md5($title); |
|
250 | 250 | |
251 | - return $title; |
|
252 | - } |
|
251 | + return $title; |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * @return string |
|
256 | - */ |
|
257 | - public function getCloneLink() |
|
258 | - { |
|
259 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>'; |
|
254 | + /** |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + public function getCloneLink() |
|
258 | + { |
|
259 | + $ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>'; |
|
260 | 260 | |
261 | - return $ret; |
|
262 | - } |
|
261 | + return $ret; |
|
262 | + } |
|
263 | 263 | } |
@@ -19,18 +19,18 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class PermissionHandler extends \XoopsObjectHandler |
21 | 21 | { |
22 | - public $handler; |
|
23 | - |
|
24 | - /** |
|
25 | - * SmartobjectPermissionHandler constructor. |
|
26 | - * @param \XoopsDatabase $handler |
|
27 | - */ |
|
28 | - public function __construct($handler) |
|
29 | - { |
|
30 | - $this->handler = $handler; |
|
31 | - } |
|
32 | - |
|
33 | - /* |
|
22 | + public $handler; |
|
23 | + |
|
24 | + /** |
|
25 | + * SmartobjectPermissionHandler constructor. |
|
26 | + * @param \XoopsDatabase $handler |
|
27 | + */ |
|
28 | + public function __construct($handler) |
|
29 | + { |
|
30 | + $this->handler = $handler; |
|
31 | + } |
|
32 | + |
|
33 | + /* |
|
34 | 34 | * Returns permissions for a certain type |
35 | 35 | * |
36 | 36 | * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know) |
@@ -38,74 +38,74 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - /** |
|
42 | - * @param $gperm_name |
|
43 | - * @param null $id |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function getGrantedGroups($gperm_name, $id = null) |
|
47 | - { |
|
48 | - static $groups; |
|
49 | - |
|
50 | - if (!isset($groups[$gperm_name]) || (null !== $id && !isset($groups[$gperm_name][$id]))) { |
|
51 | - $smartModule = $this->handler->getModuleInfo(); |
|
52 | - //Get group permissions handler |
|
53 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
54 | - |
|
55 | - //Get groups allowed for an item id |
|
56 | - $allowedgroups = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid')); |
|
57 | - $groups[$gperm_name][$id] = $allowedgroups; |
|
58 | - } |
|
59 | - |
|
60 | - //Return the permission array |
|
61 | - return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : []; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param $item_ids_array |
|
66 | - * @param bool $gperm_name |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) |
|
70 | - { |
|
71 | - static $groups; |
|
72 | - |
|
73 | - if ($gperm_name) { |
|
74 | - if (isset($groups[$gperm_name])) { |
|
75 | - return $groups[$gperm_name]; |
|
76 | - } |
|
77 | - } else { |
|
78 | - // if !$gperm_name then we will fetch all permissions in the module so we don't need them again |
|
79 | - return $groups; |
|
80 | - } |
|
81 | - |
|
82 | - $smartModule = $this->handler->getModuleInfo(); |
|
83 | - |
|
84 | - $criteria = new \CriteriaCompo(); |
|
85 | - $criteria->add(new \Criteria('gperm_modid', $smartModule->getVar('mid'))); |
|
86 | - |
|
87 | - if ($gperm_name) { |
|
88 | - $criteria->add(new \Criteria('gperm_name', $gperm_name)); |
|
89 | - } |
|
90 | - |
|
91 | - //Get group permissions handler |
|
92 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
93 | - |
|
94 | - $permissionsObj = $gpermHandler->getObjects($criteria); |
|
95 | - |
|
96 | - foreach ($permissionsObj as $permissionObj) { |
|
97 | - $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); |
|
98 | - } |
|
99 | - |
|
100 | - //Return the permission array |
|
101 | - if ($gperm_name) { |
|
102 | - return isset($groups[$gperm_name]) ? $groups[$gperm_name] : []; |
|
103 | - } else { |
|
104 | - return isset($groups) ? $groups : []; |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /* |
|
41 | + /** |
|
42 | + * @param $gperm_name |
|
43 | + * @param null $id |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function getGrantedGroups($gperm_name, $id = null) |
|
47 | + { |
|
48 | + static $groups; |
|
49 | + |
|
50 | + if (!isset($groups[$gperm_name]) || (null !== $id && !isset($groups[$gperm_name][$id]))) { |
|
51 | + $smartModule = $this->handler->getModuleInfo(); |
|
52 | + //Get group permissions handler |
|
53 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
54 | + |
|
55 | + //Get groups allowed for an item id |
|
56 | + $allowedgroups = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid')); |
|
57 | + $groups[$gperm_name][$id] = $allowedgroups; |
|
58 | + } |
|
59 | + |
|
60 | + //Return the permission array |
|
61 | + return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : []; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param $item_ids_array |
|
66 | + * @param bool $gperm_name |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) |
|
70 | + { |
|
71 | + static $groups; |
|
72 | + |
|
73 | + if ($gperm_name) { |
|
74 | + if (isset($groups[$gperm_name])) { |
|
75 | + return $groups[$gperm_name]; |
|
76 | + } |
|
77 | + } else { |
|
78 | + // if !$gperm_name then we will fetch all permissions in the module so we don't need them again |
|
79 | + return $groups; |
|
80 | + } |
|
81 | + |
|
82 | + $smartModule = $this->handler->getModuleInfo(); |
|
83 | + |
|
84 | + $criteria = new \CriteriaCompo(); |
|
85 | + $criteria->add(new \Criteria('gperm_modid', $smartModule->getVar('mid'))); |
|
86 | + |
|
87 | + if ($gperm_name) { |
|
88 | + $criteria->add(new \Criteria('gperm_name', $gperm_name)); |
|
89 | + } |
|
90 | + |
|
91 | + //Get group permissions handler |
|
92 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
93 | + |
|
94 | + $permissionsObj = $gpermHandler->getObjects($criteria); |
|
95 | + |
|
96 | + foreach ($permissionsObj as $permissionObj) { |
|
97 | + $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); |
|
98 | + } |
|
99 | + |
|
100 | + //Return the permission array |
|
101 | + if ($gperm_name) { |
|
102 | + return isset($groups[$gperm_name]) ? $groups[$gperm_name] : []; |
|
103 | + } else { |
|
104 | + return isset($groups) ? $groups : []; |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /* |
|
109 | 109 | * Returns permissions for a certain type |
110 | 110 | * |
111 | 111 | * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know) |
@@ -113,123 +113,123 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - /** |
|
117 | - * @param $gperm_name |
|
118 | - * @param null $id |
|
119 | - * @return array |
|
120 | - */ |
|
121 | - public function getGrantedItems($gperm_name, $id = null) |
|
122 | - { |
|
123 | - global $xoopsUser; |
|
124 | - static $permissions; |
|
125 | - |
|
126 | - if (!isset($permissions[$gperm_name]) || (null !== $id && !isset($permissions[$gperm_name][$id]))) { |
|
127 | - $smartModule = $this->handler->getModuleInfo(); |
|
128 | - |
|
129 | - if (is_object($smartModule)) { |
|
130 | - |
|
131 | - //Get group permissions handler |
|
132 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
133 | - |
|
134 | - //Get user's groups |
|
135 | - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS]; |
|
136 | - |
|
137 | - //Get all allowed item ids in this module and for this user's groups |
|
138 | - $userpermissions = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid')); |
|
139 | - $permissions[$gperm_name] = $userpermissions; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - //Return the permission array |
|
144 | - return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : []; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param $id |
|
149 | - */ |
|
150 | - public function storeAllPermissionsForId($id) |
|
151 | - { |
|
152 | - foreach ($this->handler->getPermissions() as $permission) { |
|
153 | - $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']); |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Saves permissions for the selected item |
|
159 | - * |
|
160 | - * saveItem_Permissions() |
|
161 | - * |
|
162 | - * @param array $groups : group with granted permission |
|
163 | - * @param int $itemid categoryID on which we are setting permissions for Categories and Forums |
|
164 | - * @param string $perm_name : name of the permission |
|
165 | - * @return bool : TRUE if the no errors occured |
|
166 | - */ |
|
167 | - |
|
168 | - public function saveItem_Permissions($groups, $itemid, $perm_name) |
|
169 | - { |
|
170 | - $smartModule = $this->handler->getModuleInfo(); |
|
171 | - |
|
172 | - $result = true; |
|
173 | - $module_id = $smartModule->getVar('mid'); |
|
174 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
175 | - |
|
176 | - // First, if the permissions are already there, delete them |
|
177 | - $gpermHandler->deleteByModule($module_id, $perm_name, $itemid); |
|
178 | - //echo "itemid: $itemid - perm: $perm_name - modid: $module_id"; |
|
179 | - //exit; |
|
180 | - // Save the new permissions |
|
181 | - |
|
182 | - if (count($groups) > 0) { |
|
183 | - foreach ($groups as $group_id) { |
|
184 | - $gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $result; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Delete all permission for a specific item |
|
193 | - * |
|
194 | - * deletePermissions() |
|
195 | - * |
|
196 | - * @param integer $itemid : id of the item for which to delete the permissions |
|
197 | - * @param $gperm_name |
|
198 | - * @return bool: TRUE if the no errors occured |
|
199 | - */ |
|
200 | - public function deletePermissions($itemid, $gperm_name) |
|
201 | - { |
|
202 | - global $xoopsModule; |
|
203 | - |
|
204 | - $smartModule = smartsection_getModuleInfo(); |
|
205 | - |
|
206 | - $result = true; |
|
207 | - $module_id = $smartModule->getVar('mid'); |
|
208 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
209 | - |
|
210 | - $gpermHandler->deleteByModule($module_id, $gperm_name, $itemid); |
|
211 | - |
|
212 | - return $result; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Checks if the user has access to a specific permission on a given object |
|
217 | - * |
|
218 | - * @param string $gperm_name name of the permission to test |
|
219 | - * @param int $gperm_itemid id of the object to check |
|
220 | - * @return boolean: TRUE if user has access, FALSE if not |
|
221 | - **/ |
|
222 | - public function accessGranted($gperm_name, $gperm_itemid) |
|
223 | - { |
|
224 | - global $xoopsUser; |
|
225 | - |
|
226 | - $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS]; |
|
227 | - $smartModule = $this->handler->getModuleInfo(); |
|
228 | - $gperm_modid = $smartModule->getVar('mid'); |
|
229 | - |
|
230 | - //Get group permissions handler |
|
231 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
232 | - |
|
233 | - return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid); |
|
234 | - } |
|
116 | + /** |
|
117 | + * @param $gperm_name |
|
118 | + * @param null $id |
|
119 | + * @return array |
|
120 | + */ |
|
121 | + public function getGrantedItems($gperm_name, $id = null) |
|
122 | + { |
|
123 | + global $xoopsUser; |
|
124 | + static $permissions; |
|
125 | + |
|
126 | + if (!isset($permissions[$gperm_name]) || (null !== $id && !isset($permissions[$gperm_name][$id]))) { |
|
127 | + $smartModule = $this->handler->getModuleInfo(); |
|
128 | + |
|
129 | + if (is_object($smartModule)) { |
|
130 | + |
|
131 | + //Get group permissions handler |
|
132 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
133 | + |
|
134 | + //Get user's groups |
|
135 | + $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS]; |
|
136 | + |
|
137 | + //Get all allowed item ids in this module and for this user's groups |
|
138 | + $userpermissions = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid')); |
|
139 | + $permissions[$gperm_name] = $userpermissions; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + //Return the permission array |
|
144 | + return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : []; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param $id |
|
149 | + */ |
|
150 | + public function storeAllPermissionsForId($id) |
|
151 | + { |
|
152 | + foreach ($this->handler->getPermissions() as $permission) { |
|
153 | + $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']); |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Saves permissions for the selected item |
|
159 | + * |
|
160 | + * saveItem_Permissions() |
|
161 | + * |
|
162 | + * @param array $groups : group with granted permission |
|
163 | + * @param int $itemid categoryID on which we are setting permissions for Categories and Forums |
|
164 | + * @param string $perm_name : name of the permission |
|
165 | + * @return bool : TRUE if the no errors occured |
|
166 | + */ |
|
167 | + |
|
168 | + public function saveItem_Permissions($groups, $itemid, $perm_name) |
|
169 | + { |
|
170 | + $smartModule = $this->handler->getModuleInfo(); |
|
171 | + |
|
172 | + $result = true; |
|
173 | + $module_id = $smartModule->getVar('mid'); |
|
174 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
175 | + |
|
176 | + // First, if the permissions are already there, delete them |
|
177 | + $gpermHandler->deleteByModule($module_id, $perm_name, $itemid); |
|
178 | + //echo "itemid: $itemid - perm: $perm_name - modid: $module_id"; |
|
179 | + //exit; |
|
180 | + // Save the new permissions |
|
181 | + |
|
182 | + if (count($groups) > 0) { |
|
183 | + foreach ($groups as $group_id) { |
|
184 | + $gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $result; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Delete all permission for a specific item |
|
193 | + * |
|
194 | + * deletePermissions() |
|
195 | + * |
|
196 | + * @param integer $itemid : id of the item for which to delete the permissions |
|
197 | + * @param $gperm_name |
|
198 | + * @return bool: TRUE if the no errors occured |
|
199 | + */ |
|
200 | + public function deletePermissions($itemid, $gperm_name) |
|
201 | + { |
|
202 | + global $xoopsModule; |
|
203 | + |
|
204 | + $smartModule = smartsection_getModuleInfo(); |
|
205 | + |
|
206 | + $result = true; |
|
207 | + $module_id = $smartModule->getVar('mid'); |
|
208 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
209 | + |
|
210 | + $gpermHandler->deleteByModule($module_id, $gperm_name, $itemid); |
|
211 | + |
|
212 | + return $result; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Checks if the user has access to a specific permission on a given object |
|
217 | + * |
|
218 | + * @param string $gperm_name name of the permission to test |
|
219 | + * @param int $gperm_itemid id of the object to check |
|
220 | + * @return boolean: TRUE if user has access, FALSE if not |
|
221 | + **/ |
|
222 | + public function accessGranted($gperm_name, $gperm_itemid) |
|
223 | + { |
|
224 | + global $xoopsUser; |
|
225 | + |
|
226 | + $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS]; |
|
227 | + $smartModule = $this->handler->getModuleInfo(); |
|
228 | + $gperm_modid = $smartModule->getVar('mid'); |
|
229 | + |
|
230 | + //Get group permissions handler |
|
231 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
232 | + |
|
233 | + return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid); |
|
234 | + } |
|
235 | 235 | } |
@@ -17,65 +17,65 @@ |
||
17 | 17 | */ |
18 | 18 | class PrinterFriendly |
19 | 19 | { |
20 | - public $_title; |
|
21 | - public $_dsc; |
|
22 | - public $_content; |
|
23 | - public $_tpl; |
|
24 | - public $_pageTitle = false; |
|
25 | - public $_width = 680; |
|
20 | + public $_title; |
|
21 | + public $_dsc; |
|
22 | + public $_content; |
|
23 | + public $_tpl; |
|
24 | + public $_pageTitle = false; |
|
25 | + public $_width = 680; |
|
26 | 26 | |
27 | - /** |
|
28 | - * SmartPrinterFriendly constructor. |
|
29 | - * @param $content |
|
30 | - * @param bool $title |
|
31 | - * @param bool $dsc |
|
32 | - */ |
|
33 | - public function __construct($content, $title = false, $dsc = false) |
|
34 | - { |
|
35 | - $this->_title = $title; |
|
36 | - $this->_dsc = $dsc; |
|
37 | - $this->_content = $content; |
|
38 | - } |
|
27 | + /** |
|
28 | + * SmartPrinterFriendly constructor. |
|
29 | + * @param $content |
|
30 | + * @param bool $title |
|
31 | + * @param bool $dsc |
|
32 | + */ |
|
33 | + public function __construct($content, $title = false, $dsc = false) |
|
34 | + { |
|
35 | + $this->_title = $title; |
|
36 | + $this->_dsc = $dsc; |
|
37 | + $this->_content = $content; |
|
38 | + } |
|
39 | 39 | |
40 | - public function render() |
|
41 | - { |
|
42 | - /** |
|
43 | - * @todo move the output to a template |
|
44 | - * @todo make the output XHTML compliant |
|
45 | - */ |
|
40 | + public function render() |
|
41 | + { |
|
42 | + /** |
|
43 | + * @todo move the output to a template |
|
44 | + * @todo make the output XHTML compliant |
|
45 | + */ |
|
46 | 46 | |
47 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
47 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
48 | 48 | |
49 | - $this->_tpl = new \XoopsTpl(); |
|
49 | + $this->_tpl = new \XoopsTpl(); |
|
50 | 50 | |
51 | - $this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title); |
|
52 | - $this->_tpl->assign('smartobject_print_title', $this->_title); |
|
53 | - $this->_tpl->assign('smartobject_print_dsc', $this->_dsc); |
|
54 | - $this->_tpl->assign('smartobject_print_content', $this->_content); |
|
55 | - $this->_tpl->assign('smartobject_print_width', $this->_width); |
|
51 | + $this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title); |
|
52 | + $this->_tpl->assign('smartobject_print_title', $this->_title); |
|
53 | + $this->_tpl->assign('smartobject_print_dsc', $this->_dsc); |
|
54 | + $this->_tpl->assign('smartobject_print_content', $this->_content); |
|
55 | + $this->_tpl->assign('smartobject_print_width', $this->_width); |
|
56 | 56 | |
57 | - $current_urls = Smartobject\Utility::getCurrentUrls(); |
|
58 | - $current_url = $current_urls['full']; |
|
57 | + $current_urls = Smartobject\Utility::getCurrentUrls(); |
|
58 | + $current_url = $current_urls['full']; |
|
59 | 59 | |
60 | - $this->_tpl->assign('smartobject_print_currenturl', $current_url); |
|
61 | - $this->_tpl->assign('smartobject_print_url', $this->url); |
|
60 | + $this->_tpl->assign('smartobject_print_currenturl', $current_url); |
|
61 | + $this->_tpl->assign('smartobject_print_url', $this->url); |
|
62 | 62 | |
63 | - $this->_tpl->display('db:smartobject_print.tpl'); |
|
64 | - } |
|
63 | + $this->_tpl->display('db:smartobject_print.tpl'); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param $text |
|
68 | - */ |
|
69 | - public function setPageTitle($text) |
|
70 | - { |
|
71 | - $this->_pageTitle = $text; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @param $text |
|
68 | + */ |
|
69 | + public function setPageTitle($text) |
|
70 | + { |
|
71 | + $this->_pageTitle = $text; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param $width |
|
76 | - */ |
|
77 | - public function setWidth($width) |
|
78 | - { |
|
79 | - $this->_width = $width; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @param $width |
|
76 | + */ |
|
77 | + public function setWidth($width) |
|
78 | + { |
|
79 | + $this->_width = $width; |
|
80 | + } |
|
81 | 81 | } |
@@ -30,117 +30,117 @@ |
||
30 | 30 | */ |
31 | 31 | class AdsenseHandler extends Smartobject\PersistableObjectHandler |
32 | 32 | { |
33 | - public $adFormats; |
|
34 | - public $adFormatsList; |
|
35 | - public $objects = false; |
|
33 | + public $adFormats; |
|
34 | + public $adFormatsList; |
|
35 | + public $objects = false; |
|
36 | 36 | // public $classname = Adsense::class; |
37 | 37 | |
38 | - /** |
|
39 | - * SmartobjectAdsenseHandler constructor. |
|
40 | - * @param \XoopsDatabase $db |
|
41 | - */ |
|
42 | - public function __construct(\XoopsDatabase $db) |
|
43 | - { |
|
44 | - parent::__construct($db, Adsense::class, 'adsenseid', 'description', '', 'smartobject'); |
|
45 | - $this->adFormats = []; |
|
46 | - $this->adFormatsList = []; |
|
47 | - |
|
48 | - $this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard'; |
|
49 | - $this->adFormats['728x90_as']['width'] = 728; |
|
50 | - $this->adFormats['728x90_as']['height'] = 90; |
|
51 | - $this->adFormatsList['728x90_as'] = $this->adFormats['728x90_as']['caption']; |
|
52 | - |
|
53 | - $this->adFormats['468x60_as']['caption'] = '468 X 60 Banner'; |
|
54 | - $this->adFormats['468x60_as']['width'] = 468; |
|
55 | - $this->adFormats['468x60_as']['height'] = 60; |
|
56 | - $this->adFormatsList['468x60_as'] = $this->adFormats['468x60_as']['caption']; |
|
57 | - |
|
58 | - $this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner'; |
|
59 | - $this->adFormats['234x60_as']['width'] = 234; |
|
60 | - $this->adFormats['234x60_as']['height'] = 60; |
|
61 | - $this->adFormatsList['234x60_as'] = $this->adFormats['234x60_as']['caption']; |
|
62 | - |
|
63 | - $this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper'; |
|
64 | - $this->adFormats['120x600_as']['width'] = 120; |
|
65 | - $this->adFormats['120x600_as']['height'] = 600; |
|
66 | - $this->adFormatsList['120x600_as'] = $this->adFormats['120x600_as']['caption']; |
|
67 | - |
|
68 | - $this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper'; |
|
69 | - $this->adFormats['160x600_as']['width'] = 160; |
|
70 | - $this->adFormats['160x600_as']['height'] = 600; |
|
71 | - $this->adFormatsList['160x600_as'] = $this->adFormats['160x600_as']['caption']; |
|
72 | - |
|
73 | - $this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner'; |
|
74 | - $this->adFormats['120x240_as']['width'] = 120; |
|
75 | - $this->adFormats['120x240_as']['height'] = 240; |
|
76 | - $this->adFormatsList['120x240_as'] = $this->adFormats['120x240_as']['caption']; |
|
77 | - |
|
78 | - $this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle'; |
|
79 | - $this->adFormats['336x280_as']['width'] = 136; |
|
80 | - $this->adFormats['336x280_as']['height'] = 280; |
|
81 | - $this->adFormatsList['336x280_as'] = $this->adFormats['336x280_as']['caption']; |
|
82 | - |
|
83 | - $this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle'; |
|
84 | - $this->adFormats['300x250_as']['width'] = 300; |
|
85 | - $this->adFormats['300x250_as']['height'] = 250; |
|
86 | - $this->adFormatsList['300x250_as'] = $this->adFormats['300x250_as']['caption']; |
|
87 | - |
|
88 | - $this->adFormats['250x250_as']['caption'] = '250 X 250 Square'; |
|
89 | - $this->adFormats['250x250_as']['width'] = 250; |
|
90 | - $this->adFormats['250x250_as']['height'] = 250; |
|
91 | - $this->adFormatsList['250x250_as'] = $this->adFormats['250x250_as']['caption']; |
|
92 | - |
|
93 | - $this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square'; |
|
94 | - $this->adFormats['200x200_as']['width'] = 200; |
|
95 | - $this->adFormats['200x200_as']['height'] = 200; |
|
96 | - $this->adFormatsList['200x200_as'] = $this->adFormats['200x200_as']['caption']; |
|
97 | - |
|
98 | - $this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle'; |
|
99 | - $this->adFormats['180x150_as']['width'] = 180; |
|
100 | - $this->adFormats['180x150_as']['height'] = 150; |
|
101 | - $this->adFormatsList['180x150_as'] = $this->adFormats['180x150_as']['caption']; |
|
102 | - |
|
103 | - $this->adFormats['125x125_as']['caption'] = '125 X 125 Button'; |
|
104 | - $this->adFormats['125x125_as']['width'] = 125; |
|
105 | - $this->adFormats['125x125_as']['height'] = 125; |
|
106 | - $this->adFormatsList['125x125_as'] = $this->adFormats['125x125_as']['caption']; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function getFormats() |
|
113 | - { |
|
114 | - return $this->adFormatsList; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param $obj |
|
119 | - * @return bool |
|
120 | - */ |
|
121 | - public function beforeSave($obj) |
|
122 | - { |
|
123 | - if ('' === $obj->getVar('tag')) { |
|
124 | - $obj->setVar('tag', $title = $obj->generateTag()); |
|
125 | - } |
|
126 | - |
|
127 | - return true; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return array|bool |
|
132 | - */ |
|
133 | - public function getAdsensesByTag() |
|
134 | - { |
|
135 | - if (!$this->objects) { |
|
136 | - $adsensesObj =& $this->getObjects(null, true); |
|
137 | - $ret = []; |
|
138 | - foreach ($adsensesObj as $adsenseObj) { |
|
139 | - $ret[$adsenseObj->getVar('tag')] = $adsenseObj; |
|
140 | - } |
|
141 | - $this->objects = $ret; |
|
142 | - } |
|
143 | - |
|
144 | - return $this->objects; |
|
145 | - } |
|
38 | + /** |
|
39 | + * SmartobjectAdsenseHandler constructor. |
|
40 | + * @param \XoopsDatabase $db |
|
41 | + */ |
|
42 | + public function __construct(\XoopsDatabase $db) |
|
43 | + { |
|
44 | + parent::__construct($db, Adsense::class, 'adsenseid', 'description', '', 'smartobject'); |
|
45 | + $this->adFormats = []; |
|
46 | + $this->adFormatsList = []; |
|
47 | + |
|
48 | + $this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard'; |
|
49 | + $this->adFormats['728x90_as']['width'] = 728; |
|
50 | + $this->adFormats['728x90_as']['height'] = 90; |
|
51 | + $this->adFormatsList['728x90_as'] = $this->adFormats['728x90_as']['caption']; |
|
52 | + |
|
53 | + $this->adFormats['468x60_as']['caption'] = '468 X 60 Banner'; |
|
54 | + $this->adFormats['468x60_as']['width'] = 468; |
|
55 | + $this->adFormats['468x60_as']['height'] = 60; |
|
56 | + $this->adFormatsList['468x60_as'] = $this->adFormats['468x60_as']['caption']; |
|
57 | + |
|
58 | + $this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner'; |
|
59 | + $this->adFormats['234x60_as']['width'] = 234; |
|
60 | + $this->adFormats['234x60_as']['height'] = 60; |
|
61 | + $this->adFormatsList['234x60_as'] = $this->adFormats['234x60_as']['caption']; |
|
62 | + |
|
63 | + $this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper'; |
|
64 | + $this->adFormats['120x600_as']['width'] = 120; |
|
65 | + $this->adFormats['120x600_as']['height'] = 600; |
|
66 | + $this->adFormatsList['120x600_as'] = $this->adFormats['120x600_as']['caption']; |
|
67 | + |
|
68 | + $this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper'; |
|
69 | + $this->adFormats['160x600_as']['width'] = 160; |
|
70 | + $this->adFormats['160x600_as']['height'] = 600; |
|
71 | + $this->adFormatsList['160x600_as'] = $this->adFormats['160x600_as']['caption']; |
|
72 | + |
|
73 | + $this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner'; |
|
74 | + $this->adFormats['120x240_as']['width'] = 120; |
|
75 | + $this->adFormats['120x240_as']['height'] = 240; |
|
76 | + $this->adFormatsList['120x240_as'] = $this->adFormats['120x240_as']['caption']; |
|
77 | + |
|
78 | + $this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle'; |
|
79 | + $this->adFormats['336x280_as']['width'] = 136; |
|
80 | + $this->adFormats['336x280_as']['height'] = 280; |
|
81 | + $this->adFormatsList['336x280_as'] = $this->adFormats['336x280_as']['caption']; |
|
82 | + |
|
83 | + $this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle'; |
|
84 | + $this->adFormats['300x250_as']['width'] = 300; |
|
85 | + $this->adFormats['300x250_as']['height'] = 250; |
|
86 | + $this->adFormatsList['300x250_as'] = $this->adFormats['300x250_as']['caption']; |
|
87 | + |
|
88 | + $this->adFormats['250x250_as']['caption'] = '250 X 250 Square'; |
|
89 | + $this->adFormats['250x250_as']['width'] = 250; |
|
90 | + $this->adFormats['250x250_as']['height'] = 250; |
|
91 | + $this->adFormatsList['250x250_as'] = $this->adFormats['250x250_as']['caption']; |
|
92 | + |
|
93 | + $this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square'; |
|
94 | + $this->adFormats['200x200_as']['width'] = 200; |
|
95 | + $this->adFormats['200x200_as']['height'] = 200; |
|
96 | + $this->adFormatsList['200x200_as'] = $this->adFormats['200x200_as']['caption']; |
|
97 | + |
|
98 | + $this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle'; |
|
99 | + $this->adFormats['180x150_as']['width'] = 180; |
|
100 | + $this->adFormats['180x150_as']['height'] = 150; |
|
101 | + $this->adFormatsList['180x150_as'] = $this->adFormats['180x150_as']['caption']; |
|
102 | + |
|
103 | + $this->adFormats['125x125_as']['caption'] = '125 X 125 Button'; |
|
104 | + $this->adFormats['125x125_as']['width'] = 125; |
|
105 | + $this->adFormats['125x125_as']['height'] = 125; |
|
106 | + $this->adFormatsList['125x125_as'] = $this->adFormats['125x125_as']['caption']; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function getFormats() |
|
113 | + { |
|
114 | + return $this->adFormatsList; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param $obj |
|
119 | + * @return bool |
|
120 | + */ |
|
121 | + public function beforeSave($obj) |
|
122 | + { |
|
123 | + if ('' === $obj->getVar('tag')) { |
|
124 | + $obj->setVar('tag', $title = $obj->generateTag()); |
|
125 | + } |
|
126 | + |
|
127 | + return true; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return array|bool |
|
132 | + */ |
|
133 | + public function getAdsensesByTag() |
|
134 | + { |
|
135 | + if (!$this->objects) { |
|
136 | + $adsensesObj =& $this->getObjects(null, true); |
|
137 | + $ret = []; |
|
138 | + foreach ($adsensesObj as $adsenseObj) { |
|
139 | + $ret[$adsenseObj->getVar('tag')] = $adsenseObj; |
|
140 | + } |
|
141 | + $this->objects = $ret; |
|
142 | + } |
|
143 | + |
|
144 | + return $this->objects; |
|
145 | + } |
|
146 | 146 | } |
@@ -29,152 +29,152 @@ |
||
29 | 29 | */ |
30 | 30 | class Link extends Smartobject\BaseSmartObject |
31 | 31 | { |
32 | - /** |
|
33 | - * Link constructor. |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - $this->initVar('linkid', XOBJ_DTYPE_INT, '', true); |
|
38 | - $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false); |
|
39 | - $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC); |
|
40 | - $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true); |
|
41 | - $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true); |
|
42 | - $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC); |
|
43 | - $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true); |
|
44 | - $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true); |
|
45 | - $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true); |
|
46 | - $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true); |
|
47 | - $this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC); |
|
48 | - $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC); |
|
49 | - $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * returns a specific variable for the object in a proper format |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @param string $key key of the object's variable to be returned |
|
57 | - * @param string $format format to use for the output |
|
58 | - * @return mixed formatted value of the variable |
|
59 | - */ |
|
60 | - public function getVar($key, $format = 's') |
|
61 | - { |
|
62 | - if ('s' === $format && in_array($key, ['from_uid', 'to_uid', 'date', 'link'])) { |
|
63 | - // return call_user_func(array($this, $key)); |
|
64 | - return $this->{$key}(); |
|
65 | - } |
|
66 | - |
|
67 | - return parent::getVar($key, $format); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function from_uid() |
|
74 | - { |
|
75 | - $ret = Smartobject\Utility::getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true); |
|
76 | - |
|
77 | - return $ret; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @param bool $withContact |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function to_uid($withContact = false) |
|
85 | - { |
|
86 | - $ret = Smartobject\Utility::getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true); |
|
87 | - |
|
88 | - return $ret; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function date() |
|
95 | - { |
|
96 | - $ret = formatTimestamp($this->getVar('date', 'e')); |
|
97 | - |
|
98 | - return $ret; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param bool $full |
|
103 | - * @return mixed|string |
|
104 | - */ |
|
105 | - public function link($full = false) |
|
106 | - { |
|
107 | - $ret = $this->getVar('link', 'e'); |
|
108 | - if ($full) { |
|
109 | - $myts = \MyTextSanitizer::getInstance(); |
|
110 | - $ret = $myts->displayTarea($ret); |
|
111 | - |
|
112 | - return $ret; |
|
113 | - } else { |
|
114 | - $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
115 | - |
|
116 | - return $ret; |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function getViewItemLink() |
|
124 | - { |
|
125 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
126 | - |
|
127 | - return $ret; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function getFromInfo() |
|
134 | - { |
|
135 | - // check if from_uid represent a user |
|
136 | - |
|
137 | - if ($this->getVar('from_uid')) { |
|
138 | - $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('from_uid')); |
|
139 | - if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
140 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
141 | - } |
|
142 | - } else { |
|
143 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
144 | - } |
|
145 | - |
|
146 | - return $user; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - public function toArray() |
|
153 | - { |
|
154 | - $ret = parent::toArray(); |
|
155 | - $ret['fromInfo'] = $this->getFromInfo(); |
|
156 | - $ret['toInfo'] = $this->getToInfo(); |
|
157 | - $ret['fullLink'] = $this->link(true); |
|
158 | - |
|
159 | - return $ret; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getToInfo() |
|
166 | - { |
|
167 | - // check if from_uid represent a user |
|
168 | - |
|
169 | - if ($this->getVar('to_uid')) { |
|
170 | - $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('to_uid')); |
|
171 | - if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
172 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
173 | - } |
|
174 | - } else { |
|
175 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
176 | - } |
|
177 | - |
|
178 | - return $user; |
|
179 | - } |
|
32 | + /** |
|
33 | + * Link constructor. |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + $this->initVar('linkid', XOBJ_DTYPE_INT, '', true); |
|
38 | + $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false); |
|
39 | + $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC); |
|
40 | + $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true); |
|
41 | + $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true); |
|
42 | + $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC); |
|
43 | + $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true); |
|
44 | + $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true); |
|
45 | + $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true); |
|
46 | + $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true); |
|
47 | + $this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC); |
|
48 | + $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC); |
|
49 | + $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * returns a specific variable for the object in a proper format |
|
54 | + * |
|
55 | + * @access public |
|
56 | + * @param string $key key of the object's variable to be returned |
|
57 | + * @param string $format format to use for the output |
|
58 | + * @return mixed formatted value of the variable |
|
59 | + */ |
|
60 | + public function getVar($key, $format = 's') |
|
61 | + { |
|
62 | + if ('s' === $format && in_array($key, ['from_uid', 'to_uid', 'date', 'link'])) { |
|
63 | + // return call_user_func(array($this, $key)); |
|
64 | + return $this->{$key}(); |
|
65 | + } |
|
66 | + |
|
67 | + return parent::getVar($key, $format); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function from_uid() |
|
74 | + { |
|
75 | + $ret = Smartobject\Utility::getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true); |
|
76 | + |
|
77 | + return $ret; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @param bool $withContact |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function to_uid($withContact = false) |
|
85 | + { |
|
86 | + $ret = Smartobject\Utility::getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true); |
|
87 | + |
|
88 | + return $ret; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function date() |
|
95 | + { |
|
96 | + $ret = formatTimestamp($this->getVar('date', 'e')); |
|
97 | + |
|
98 | + return $ret; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param bool $full |
|
103 | + * @return mixed|string |
|
104 | + */ |
|
105 | + public function link($full = false) |
|
106 | + { |
|
107 | + $ret = $this->getVar('link', 'e'); |
|
108 | + if ($full) { |
|
109 | + $myts = \MyTextSanitizer::getInstance(); |
|
110 | + $ret = $myts->displayTarea($ret); |
|
111 | + |
|
112 | + return $ret; |
|
113 | + } else { |
|
114 | + $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
115 | + |
|
116 | + return $ret; |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function getViewItemLink() |
|
124 | + { |
|
125 | + $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
126 | + |
|
127 | + return $ret; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function getFromInfo() |
|
134 | + { |
|
135 | + // check if from_uid represent a user |
|
136 | + |
|
137 | + if ($this->getVar('from_uid')) { |
|
138 | + $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('from_uid')); |
|
139 | + if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
140 | + $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
141 | + } |
|
142 | + } else { |
|
143 | + $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
144 | + } |
|
145 | + |
|
146 | + return $user; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + public function toArray() |
|
153 | + { |
|
154 | + $ret = parent::toArray(); |
|
155 | + $ret['fromInfo'] = $this->getFromInfo(); |
|
156 | + $ret['toInfo'] = $this->getToInfo(); |
|
157 | + $ret['fullLink'] = $this->link(true); |
|
158 | + |
|
159 | + return $ret; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getToInfo() |
|
166 | + { |
|
167 | + // check if from_uid represent a user |
|
168 | + |
|
169 | + if ($this->getVar('to_uid')) { |
|
170 | + $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('to_uid')); |
|
171 | + if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
172 | + $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
173 | + } |
|
174 | + } else { |
|
175 | + $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
176 | + } |
|
177 | + |
|
178 | + return $user; |
|
179 | + } |
|
180 | 180 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | return $ret; |
113 | 113 | } else { |
114 | - $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
114 | + $ret = '<a href="'.$ret.'" alt="'.$this->getVar('link', 'e').'" title="'.$this->getVar('link', 'e').'">'._AM_SOBJECT_SENT_LINKS_GOTO.'</a>'; |
|
115 | 115 | |
116 | 116 | return $ret; |
117 | 117 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getViewItemLink() |
124 | 124 | { |
125 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
125 | + $ret = '<a href="'.SMARTOBJECT_URL.'admin/link.php?op=view&linkid='.$this->getVar('linkid').'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'mail_find.png" alt="'._AM_SOBJECT_SENT_LINK_VIEW.'" title="'._AM_SOBJECT_SENT_LINK_VIEW.'"></a>'; |
|
126 | 126 | |
127 | 127 | return $ret; |
128 | 128 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | if ($this->getVar('from_uid')) { |
138 | 138 | $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('from_uid')); |
139 | 139 | if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
140 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
140 | + $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>'; |
|
141 | 141 | } |
142 | 142 | } else { |
143 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
143 | + $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $user; |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | if ($this->getVar('to_uid')) { |
170 | 170 | $user = Smartobject\Utility::getLinkedUnameFromId($this->getVar('to_uid')); |
171 | 171 | if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
172 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
172 | + $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>'; |
|
173 | 173 | } |
174 | 174 | } else { |
175 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
175 | + $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>'; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $user; |
@@ -22,163 +22,163 @@ |
||
22 | 22 | */ |
23 | 23 | class About |
24 | 24 | { |
25 | - public $_lang_aboutTitle; |
|
26 | - public $_lang_author_info; |
|
27 | - public $_lang_developer_lead; |
|
28 | - public $_lang_developer_contributor; |
|
29 | - public $_lang_developer_website; |
|
30 | - public $_lang_developer_email; |
|
31 | - public $_lang_developer_credits; |
|
32 | - public $_lang_module_info; |
|
33 | - public $_lang_module_status; |
|
34 | - public $_lang_module_release_date; |
|
35 | - public $_lang_module_demo; |
|
36 | - public $_lang_module_support; |
|
37 | - public $_lang_module_bug; |
|
38 | - public $_lang_module_submit_bug; |
|
39 | - public $_lang_module_feature; |
|
40 | - public $_lang_module_submit_feature; |
|
41 | - public $_lang_module_disclaimer; |
|
42 | - public $_lang_author_word; |
|
43 | - public $_lang_version_history; |
|
44 | - public $_lang_by; |
|
45 | - public $_tpl; |
|
46 | - |
|
47 | - /** |
|
48 | - * SmartobjectAbout constructor. |
|
49 | - * @param string $aboutTitle |
|
50 | - */ |
|
51 | - public function __construct($aboutTitle = 'About') |
|
52 | - { |
|
53 | - global $xoopsModule, $xoopsConfig; |
|
54 | - |
|
55 | - /** @var Smartobject\Helper $helper */ |
|
56 | - $helper = Smartobject\Helper::getInstance(); |
|
57 | - $helper->loadLanguage('modinfo'); |
|
25 | + public $_lang_aboutTitle; |
|
26 | + public $_lang_author_info; |
|
27 | + public $_lang_developer_lead; |
|
28 | + public $_lang_developer_contributor; |
|
29 | + public $_lang_developer_website; |
|
30 | + public $_lang_developer_email; |
|
31 | + public $_lang_developer_credits; |
|
32 | + public $_lang_module_info; |
|
33 | + public $_lang_module_status; |
|
34 | + public $_lang_module_release_date; |
|
35 | + public $_lang_module_demo; |
|
36 | + public $_lang_module_support; |
|
37 | + public $_lang_module_bug; |
|
38 | + public $_lang_module_submit_bug; |
|
39 | + public $_lang_module_feature; |
|
40 | + public $_lang_module_submit_feature; |
|
41 | + public $_lang_module_disclaimer; |
|
42 | + public $_lang_author_word; |
|
43 | + public $_lang_version_history; |
|
44 | + public $_lang_by; |
|
45 | + public $_tpl; |
|
46 | + |
|
47 | + /** |
|
48 | + * SmartobjectAbout constructor. |
|
49 | + * @param string $aboutTitle |
|
50 | + */ |
|
51 | + public function __construct($aboutTitle = 'About') |
|
52 | + { |
|
53 | + global $xoopsModule, $xoopsConfig; |
|
54 | + |
|
55 | + /** @var Smartobject\Helper $helper */ |
|
56 | + $helper = Smartobject\Helper::getInstance(); |
|
57 | + $helper->loadLanguage('modinfo'); |
|
58 | 58 | |
59 | - $this->_aboutTitle = $aboutTitle; |
|
60 | - |
|
61 | - $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR; |
|
62 | - $this->_lang_developer_website = _CO_SOBJECT_DEVELOPER_WEBSITE; |
|
63 | - $this->_lang_developer_email = _CO_SOBJECT_DEVELOPER_EMAIL; |
|
64 | - $this->_lang_developer_credits = _CO_SOBJECT_DEVELOPER_CREDITS; |
|
65 | - $this->_lang_module_info = _CO_SOBJECT_MODULE_INFO; |
|
66 | - $this->_lang_module_status = _CO_SOBJECT_MODULE_STATUS; |
|
67 | - $this->_lang_module_release_date = _CO_SOBJECT_MODULE_RELEASE_DATE; |
|
68 | - $this->_lang_module_demo = _CO_SOBJECT_MODULE_DEMO; |
|
69 | - $this->_lang_module_support = _CO_SOBJECT_MODULE_SUPPORT; |
|
70 | - $this->_lang_module_bug = _CO_SOBJECT_MODULE_BUG; |
|
71 | - $this->_lang_module_submit_bug = _CO_SOBJECT_MODULE_SUBMIT_BUG; |
|
72 | - $this->_lang_module_feature = _CO_SOBJECT_MODULE_FEATURE; |
|
73 | - $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE; |
|
74 | - $this->_lang_module_disclaimer = _CO_SOBJECT_MODULE_DISCLAIMER; |
|
75 | - $this->_lang_author_word = _CO_SOBJECT_AUTHOR_WORD; |
|
76 | - $this->_lang_version_history = _CO_SOBJECT_VERSION_HISTORY; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param $value |
|
81 | - * @return mixed |
|
82 | - */ |
|
83 | - public function sanitize($value) |
|
84 | - { |
|
85 | - $myts = \MyTextSanitizer::getInstance(); |
|
86 | - |
|
87 | - return $myts->displayTarea($value, 1); |
|
88 | - } |
|
89 | - |
|
90 | - public function render() |
|
91 | - { |
|
92 | - /** |
|
93 | - * @todo move the output to a template |
|
94 | - * @todo make the output XHTML compliant |
|
95 | - */ |
|
96 | - |
|
97 | - $myts = \MyTextSanitizer::getInstance(); |
|
98 | - |
|
99 | - global $xoopsModule; |
|
100 | - |
|
101 | - Smartobject\Utility::getXoopsCpHeader(); |
|
102 | - |
|
103 | - /** @var XoopsModuleHandler $moduleHandler */ |
|
104 | - $moduleHandler = xoops_getHandler('module'); |
|
105 | - $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
|
106 | - |
|
107 | - //Smartobject\Utility::getAdminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
|
108 | - |
|
109 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
110 | - |
|
111 | - // --- |
|
112 | - // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
|
113 | - // $this->_tpl = new \XoopsTpl(); |
|
114 | - $this->_tpl = new \XoopsTpl(); |
|
115 | - // --- |
|
116 | - |
|
117 | - $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
118 | - $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
|
119 | - $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
|
120 | - $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
|
121 | - $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version')); |
|
122 | - |
|
123 | - // Left headings... |
|
124 | - if ('' !== $versioninfo->getInfo('author_realname')) { |
|
125 | - $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
126 | - } else { |
|
127 | - $author_name = $versioninfo->getInfo('author'); |
|
128 | - } |
|
129 | - $this->_tpl->assign('module_author_name', $author_name); |
|
130 | - |
|
131 | - $this->_tpl->assign('module_license', $versioninfo->getInfo('license')); |
|
132 | - |
|
133 | - $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits')); |
|
134 | - |
|
135 | - // Developers Information |
|
136 | - $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead')); |
|
137 | - $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor')); |
|
138 | - $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url')); |
|
139 | - $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name')); |
|
140 | - $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email')); |
|
141 | - |
|
142 | - $people = $versioninfo->getInfo('people'); |
|
143 | - if ($people) { |
|
144 | - $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false); |
|
145 | - $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false); |
|
146 | - $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false); |
|
147 | - $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false); |
|
148 | - $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false); |
|
149 | - } |
|
150 | - //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email')); |
|
151 | - |
|
152 | - // Module Development information |
|
153 | - $this->_tpl->assign('module_date', $versioninfo->getInfo('date')); |
|
154 | - $this->_tpl->assign('module_status', $versioninfo->getInfo('status')); |
|
155 | - $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url')); |
|
156 | - $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name')); |
|
157 | - $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url')); |
|
158 | - $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name')); |
|
159 | - $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug')); |
|
160 | - $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature')); |
|
161 | - |
|
162 | - // Warning |
|
163 | - $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning'))); |
|
164 | - |
|
165 | - // Author's note |
|
166 | - $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word')); |
|
167 | - |
|
168 | - // For changelog thanks to 3Dev |
|
169 | - global $xoopsModule; |
|
170 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
171 | - if (is_file($filename)) { |
|
172 | - $filesize = filesize($filename); |
|
173 | - $handle = fopen($filename, 'r'); |
|
174 | - $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true)); |
|
175 | - fclose($handle); |
|
176 | - } |
|
177 | - |
|
178 | - $this->_tpl->display('db:smartobject_about.tpl'); |
|
179 | - |
|
180 | - Smartobject\Utility::getModFooter(); |
|
181 | - |
|
182 | - xoops_cp_footer(); |
|
183 | - } |
|
59 | + $this->_aboutTitle = $aboutTitle; |
|
60 | + |
|
61 | + $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR; |
|
62 | + $this->_lang_developer_website = _CO_SOBJECT_DEVELOPER_WEBSITE; |
|
63 | + $this->_lang_developer_email = _CO_SOBJECT_DEVELOPER_EMAIL; |
|
64 | + $this->_lang_developer_credits = _CO_SOBJECT_DEVELOPER_CREDITS; |
|
65 | + $this->_lang_module_info = _CO_SOBJECT_MODULE_INFO; |
|
66 | + $this->_lang_module_status = _CO_SOBJECT_MODULE_STATUS; |
|
67 | + $this->_lang_module_release_date = _CO_SOBJECT_MODULE_RELEASE_DATE; |
|
68 | + $this->_lang_module_demo = _CO_SOBJECT_MODULE_DEMO; |
|
69 | + $this->_lang_module_support = _CO_SOBJECT_MODULE_SUPPORT; |
|
70 | + $this->_lang_module_bug = _CO_SOBJECT_MODULE_BUG; |
|
71 | + $this->_lang_module_submit_bug = _CO_SOBJECT_MODULE_SUBMIT_BUG; |
|
72 | + $this->_lang_module_feature = _CO_SOBJECT_MODULE_FEATURE; |
|
73 | + $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE; |
|
74 | + $this->_lang_module_disclaimer = _CO_SOBJECT_MODULE_DISCLAIMER; |
|
75 | + $this->_lang_author_word = _CO_SOBJECT_AUTHOR_WORD; |
|
76 | + $this->_lang_version_history = _CO_SOBJECT_VERSION_HISTORY; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @param $value |
|
81 | + * @return mixed |
|
82 | + */ |
|
83 | + public function sanitize($value) |
|
84 | + { |
|
85 | + $myts = \MyTextSanitizer::getInstance(); |
|
86 | + |
|
87 | + return $myts->displayTarea($value, 1); |
|
88 | + } |
|
89 | + |
|
90 | + public function render() |
|
91 | + { |
|
92 | + /** |
|
93 | + * @todo move the output to a template |
|
94 | + * @todo make the output XHTML compliant |
|
95 | + */ |
|
96 | + |
|
97 | + $myts = \MyTextSanitizer::getInstance(); |
|
98 | + |
|
99 | + global $xoopsModule; |
|
100 | + |
|
101 | + Smartobject\Utility::getXoopsCpHeader(); |
|
102 | + |
|
103 | + /** @var XoopsModuleHandler $moduleHandler */ |
|
104 | + $moduleHandler = xoops_getHandler('module'); |
|
105 | + $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
|
106 | + |
|
107 | + //Smartobject\Utility::getAdminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
|
108 | + |
|
109 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
110 | + |
|
111 | + // --- |
|
112 | + // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
|
113 | + // $this->_tpl = new \XoopsTpl(); |
|
114 | + $this->_tpl = new \XoopsTpl(); |
|
115 | + // --- |
|
116 | + |
|
117 | + $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
118 | + $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
|
119 | + $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
|
120 | + $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
|
121 | + $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version')); |
|
122 | + |
|
123 | + // Left headings... |
|
124 | + if ('' !== $versioninfo->getInfo('author_realname')) { |
|
125 | + $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
126 | + } else { |
|
127 | + $author_name = $versioninfo->getInfo('author'); |
|
128 | + } |
|
129 | + $this->_tpl->assign('module_author_name', $author_name); |
|
130 | + |
|
131 | + $this->_tpl->assign('module_license', $versioninfo->getInfo('license')); |
|
132 | + |
|
133 | + $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits')); |
|
134 | + |
|
135 | + // Developers Information |
|
136 | + $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead')); |
|
137 | + $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor')); |
|
138 | + $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url')); |
|
139 | + $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name')); |
|
140 | + $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email')); |
|
141 | + |
|
142 | + $people = $versioninfo->getInfo('people'); |
|
143 | + if ($people) { |
|
144 | + $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false); |
|
145 | + $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false); |
|
146 | + $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false); |
|
147 | + $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false); |
|
148 | + $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false); |
|
149 | + } |
|
150 | + //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email')); |
|
151 | + |
|
152 | + // Module Development information |
|
153 | + $this->_tpl->assign('module_date', $versioninfo->getInfo('date')); |
|
154 | + $this->_tpl->assign('module_status', $versioninfo->getInfo('status')); |
|
155 | + $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url')); |
|
156 | + $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name')); |
|
157 | + $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url')); |
|
158 | + $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name')); |
|
159 | + $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug')); |
|
160 | + $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature')); |
|
161 | + |
|
162 | + // Warning |
|
163 | + $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning'))); |
|
164 | + |
|
165 | + // Author's note |
|
166 | + $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word')); |
|
167 | + |
|
168 | + // For changelog thanks to 3Dev |
|
169 | + global $xoopsModule; |
|
170 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
171 | + if (is_file($filename)) { |
|
172 | + $filesize = filesize($filename); |
|
173 | + $handle = fopen($filename, 'r'); |
|
174 | + $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true)); |
|
175 | + fclose($handle); |
|
176 | + } |
|
177 | + |
|
178 | + $this->_tpl->display('db:smartobject_about.tpl'); |
|
179 | + |
|
180 | + Smartobject\Utility::getModFooter(); |
|
181 | + |
|
182 | + xoops_cp_footer(); |
|
183 | + } |
|
184 | 184 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | //Smartobject\Utility::getAdminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
108 | 108 | |
109 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
109 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
110 | 110 | |
111 | 111 | // --- |
112 | 112 | // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->_tpl = new \XoopsTpl(); |
115 | 115 | // --- |
116 | 116 | |
117 | - $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
117 | + $this->_tpl->assign('module_url', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/'); |
|
118 | 118 | $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
119 | 119 | $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
120 | 120 | $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | // Left headings... |
124 | 124 | if ('' !== $versioninfo->getInfo('author_realname')) { |
125 | - $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
125 | + $author_name = $versioninfo->getInfo('author').' ('.$versioninfo->getInfo('author_realname').')'; |
|
126 | 126 | } else { |
127 | 127 | $author_name = $versioninfo->getInfo('author'); |
128 | 128 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | // For changelog thanks to 3Dev |
169 | 169 | global $xoopsModule; |
170 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
170 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/changelog.txt'; |
|
171 | 171 | if (is_file($filename)) { |
172 | 172 | $filesize = filesize($filename); |
173 | 173 | $handle = fopen($filename, 'r'); |
@@ -40,548 +40,548 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class SmartObjectForm extends \XoopsThemeForm |
42 | 42 | { |
43 | - public $targetObject = null; |
|
44 | - public $form_fields = null; |
|
45 | - public $_cancel_js_action = false; |
|
46 | - public $_custom_button = false; |
|
47 | - public $_captcha = false; |
|
48 | - public $_form_name = false; |
|
49 | - public $_form_caption = false; |
|
50 | - public $_submit_button_caption = false; |
|
51 | - |
|
52 | - /** |
|
53 | - * SmartobjectForm constructor. |
|
54 | - * @param string $target |
|
55 | - * @param string $form_name |
|
56 | - * @param string $form_caption |
|
57 | - * @param string $form_action |
|
58 | - * @param null $form_fields |
|
59 | - * @param bool $submit_button_caption |
|
60 | - * @param bool $cancel_js_action |
|
61 | - * @param bool $captcha |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - &$target, |
|
65 | - $form_name, |
|
66 | - $form_caption, |
|
67 | - $form_action, |
|
68 | - $form_fields = null, |
|
69 | - $submit_button_caption = false, |
|
70 | - $cancel_js_action = false, |
|
71 | - $captcha = false |
|
72 | - ) { |
|
73 | - $this->targetObject =& $target; |
|
74 | - $this->form_fields = $form_fields; |
|
75 | - $this->_cancel_js_action = $cancel_js_action; |
|
76 | - $this->_captcha = $captcha; |
|
77 | - $this->_form_name = $form_name; |
|
78 | - $this->_form_caption = $form_caption; |
|
79 | - $this->_submit_button_caption = $submit_button_caption; |
|
80 | - |
|
81 | - if (!isset($form_action)) { |
|
82 | - $form_action = xoops_getenv('PHP_SELF'); |
|
83 | - } |
|
84 | - |
|
85 | - parent::__construct($form_caption, $form_name, $form_action, 'post', true); |
|
86 | - $this->setExtra('enctype="multipart/form-data"'); |
|
87 | - |
|
88 | - $this->createElements(); |
|
89 | - |
|
90 | - if ($captcha) { |
|
91 | - $this->addCaptcha(); |
|
92 | - } |
|
93 | - |
|
94 | - $this->createPermissionControls(); |
|
95 | - |
|
96 | - $this->createButtons($form_name, $form_caption, $submit_button_caption); |
|
97 | - } |
|
98 | - |
|
99 | - public function addCaptcha() |
|
100 | - { |
|
101 | - require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php'; |
|
102 | - $this->addElement(new \XoopsFormCaptcha(), true); |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @param $name |
|
107 | - * @param $caption |
|
108 | - * @param bool $onclick |
|
109 | - */ |
|
110 | - public function addCustomButton($name, $caption, $onclick = false) |
|
111 | - { |
|
112 | - $custom_button_array = [ |
|
113 | - 'name' => $name, |
|
114 | - 'caption' => $caption, |
|
115 | - 'onclick' => $onclick |
|
116 | - ]; |
|
117 | - $this->_custom_button[] = $custom_button_array; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Add an element to the form |
|
122 | - * |
|
123 | - * @param string|XoopsFormElement &$formElement reference to a {@link XoopsFormElement} |
|
124 | - * @param bool $key |
|
125 | - * @param bool $var |
|
126 | - * @param bool|string $required is this a "required" element? |
|
127 | - */ |
|
128 | - public function addElement($formElement, $key = false, $var = false, $required = 'notset') |
|
129 | - { |
|
130 | - if ($key) { |
|
131 | - if ($this->targetObject->vars[$key]['readonly']) { |
|
132 | - $formElement->setExtra('disabled="disabled"'); |
|
133 | - $formElement->setName($key . '-readonly'); |
|
134 | - // Since this element is disable, we still want to pass it's value in the form |
|
135 | - $hidden = new \XoopsFormHidden($key, $this->targetObject->vars[$key]['value']); |
|
136 | - $this->addElement($hidden); |
|
137 | - } |
|
138 | - $formElement->setDescription($var['form_dsc']); |
|
139 | - if (isset($this->targetObject->controls[$key]['onSelect'])) { |
|
140 | - $hidden = new \XoopsFormHidden('changedField', false); |
|
141 | - $this->addElement($hidden); |
|
142 | - $otherExtra = isset($var['form_extra']) ? $var['form_extra'] : ''; |
|
143 | - $onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()"; |
|
144 | - $formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra); |
|
145 | - } else { |
|
146 | - if (isset($var['form_extra'])) { |
|
147 | - $formElement->setExtra($var['form_extra']); |
|
148 | - } |
|
149 | - } |
|
150 | - $controls = $this->targetObject->controls; |
|
151 | - if (isset($controls[$key]['js'])) { |
|
152 | - $formElement->customValidationCode[] = $controls[$key]['js']; |
|
153 | - } |
|
154 | - parent::addElement($formElement, 'notset' === $required ? $var['required'] : $required); |
|
155 | - } else { |
|
156 | - parent::addElement($formElement, 'notset' === $required ? false : true); |
|
157 | - } |
|
158 | - unset($formElement); |
|
159 | - } |
|
160 | - |
|
161 | - public function createElements() |
|
162 | - { |
|
163 | - $controls = $this->targetObject->controls; |
|
164 | - $vars = $this->targetObject->vars; |
|
165 | - foreach ($vars as $key => $var) { |
|
166 | - |
|
167 | - // If $displayOnForm is false OR this is the primary key, it doesn't |
|
168 | - // need to be displayed, then we only create an hidden field |
|
169 | - if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) { |
|
170 | - $elementToAdd = new \XoopsFormHidden($key, $var['value']); |
|
171 | - $this->addElement($elementToAdd, $key, $var, false); |
|
172 | - unset($elementToAdd); |
|
173 | - // If not, the we need to create the proper form control for this fields |
|
174 | - } else { |
|
175 | - // If this field has a specific control, we will use it |
|
176 | - |
|
177 | - if ('parentid' === $key) { |
|
178 | - /** |
|
179 | - * Why this ? |
|
180 | - */ |
|
181 | - } |
|
182 | - if (isset($controls[$key])) { |
|
183 | - /* If the control has name, it's because it's an object already present in the script |
|
43 | + public $targetObject = null; |
|
44 | + public $form_fields = null; |
|
45 | + public $_cancel_js_action = false; |
|
46 | + public $_custom_button = false; |
|
47 | + public $_captcha = false; |
|
48 | + public $_form_name = false; |
|
49 | + public $_form_caption = false; |
|
50 | + public $_submit_button_caption = false; |
|
51 | + |
|
52 | + /** |
|
53 | + * SmartobjectForm constructor. |
|
54 | + * @param string $target |
|
55 | + * @param string $form_name |
|
56 | + * @param string $form_caption |
|
57 | + * @param string $form_action |
|
58 | + * @param null $form_fields |
|
59 | + * @param bool $submit_button_caption |
|
60 | + * @param bool $cancel_js_action |
|
61 | + * @param bool $captcha |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + &$target, |
|
65 | + $form_name, |
|
66 | + $form_caption, |
|
67 | + $form_action, |
|
68 | + $form_fields = null, |
|
69 | + $submit_button_caption = false, |
|
70 | + $cancel_js_action = false, |
|
71 | + $captcha = false |
|
72 | + ) { |
|
73 | + $this->targetObject =& $target; |
|
74 | + $this->form_fields = $form_fields; |
|
75 | + $this->_cancel_js_action = $cancel_js_action; |
|
76 | + $this->_captcha = $captcha; |
|
77 | + $this->_form_name = $form_name; |
|
78 | + $this->_form_caption = $form_caption; |
|
79 | + $this->_submit_button_caption = $submit_button_caption; |
|
80 | + |
|
81 | + if (!isset($form_action)) { |
|
82 | + $form_action = xoops_getenv('PHP_SELF'); |
|
83 | + } |
|
84 | + |
|
85 | + parent::__construct($form_caption, $form_name, $form_action, 'post', true); |
|
86 | + $this->setExtra('enctype="multipart/form-data"'); |
|
87 | + |
|
88 | + $this->createElements(); |
|
89 | + |
|
90 | + if ($captcha) { |
|
91 | + $this->addCaptcha(); |
|
92 | + } |
|
93 | + |
|
94 | + $this->createPermissionControls(); |
|
95 | + |
|
96 | + $this->createButtons($form_name, $form_caption, $submit_button_caption); |
|
97 | + } |
|
98 | + |
|
99 | + public function addCaptcha() |
|
100 | + { |
|
101 | + require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php'; |
|
102 | + $this->addElement(new \XoopsFormCaptcha(), true); |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @param $name |
|
107 | + * @param $caption |
|
108 | + * @param bool $onclick |
|
109 | + */ |
|
110 | + public function addCustomButton($name, $caption, $onclick = false) |
|
111 | + { |
|
112 | + $custom_button_array = [ |
|
113 | + 'name' => $name, |
|
114 | + 'caption' => $caption, |
|
115 | + 'onclick' => $onclick |
|
116 | + ]; |
|
117 | + $this->_custom_button[] = $custom_button_array; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Add an element to the form |
|
122 | + * |
|
123 | + * @param string|XoopsFormElement &$formElement reference to a {@link XoopsFormElement} |
|
124 | + * @param bool $key |
|
125 | + * @param bool $var |
|
126 | + * @param bool|string $required is this a "required" element? |
|
127 | + */ |
|
128 | + public function addElement($formElement, $key = false, $var = false, $required = 'notset') |
|
129 | + { |
|
130 | + if ($key) { |
|
131 | + if ($this->targetObject->vars[$key]['readonly']) { |
|
132 | + $formElement->setExtra('disabled="disabled"'); |
|
133 | + $formElement->setName($key . '-readonly'); |
|
134 | + // Since this element is disable, we still want to pass it's value in the form |
|
135 | + $hidden = new \XoopsFormHidden($key, $this->targetObject->vars[$key]['value']); |
|
136 | + $this->addElement($hidden); |
|
137 | + } |
|
138 | + $formElement->setDescription($var['form_dsc']); |
|
139 | + if (isset($this->targetObject->controls[$key]['onSelect'])) { |
|
140 | + $hidden = new \XoopsFormHidden('changedField', false); |
|
141 | + $this->addElement($hidden); |
|
142 | + $otherExtra = isset($var['form_extra']) ? $var['form_extra'] : ''; |
|
143 | + $onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()"; |
|
144 | + $formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra); |
|
145 | + } else { |
|
146 | + if (isset($var['form_extra'])) { |
|
147 | + $formElement->setExtra($var['form_extra']); |
|
148 | + } |
|
149 | + } |
|
150 | + $controls = $this->targetObject->controls; |
|
151 | + if (isset($controls[$key]['js'])) { |
|
152 | + $formElement->customValidationCode[] = $controls[$key]['js']; |
|
153 | + } |
|
154 | + parent::addElement($formElement, 'notset' === $required ? $var['required'] : $required); |
|
155 | + } else { |
|
156 | + parent::addElement($formElement, 'notset' === $required ? false : true); |
|
157 | + } |
|
158 | + unset($formElement); |
|
159 | + } |
|
160 | + |
|
161 | + public function createElements() |
|
162 | + { |
|
163 | + $controls = $this->targetObject->controls; |
|
164 | + $vars = $this->targetObject->vars; |
|
165 | + foreach ($vars as $key => $var) { |
|
166 | + |
|
167 | + // If $displayOnForm is false OR this is the primary key, it doesn't |
|
168 | + // need to be displayed, then we only create an hidden field |
|
169 | + if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) { |
|
170 | + $elementToAdd = new \XoopsFormHidden($key, $var['value']); |
|
171 | + $this->addElement($elementToAdd, $key, $var, false); |
|
172 | + unset($elementToAdd); |
|
173 | + // If not, the we need to create the proper form control for this fields |
|
174 | + } else { |
|
175 | + // If this field has a specific control, we will use it |
|
176 | + |
|
177 | + if ('parentid' === $key) { |
|
178 | + /** |
|
179 | + * Why this ? |
|
180 | + */ |
|
181 | + } |
|
182 | + if (isset($controls[$key])) { |
|
183 | + /* If the control has name, it's because it's an object already present in the script |
|
184 | 184 | * for example, "user" |
185 | 185 | * If the field does not have a name, than we will use a "select" (ie XoopsFormSelect) |
186 | 186 | */ |
187 | - if (!isset($controls[$key]['name']) || !$controls[$key]['name']) { |
|
188 | - $controls[$key]['name'] = 'select'; |
|
189 | - } |
|
190 | - |
|
191 | - $form_select = $this->getControl($controls[$key]['name'], $key); |
|
192 | - |
|
193 | - // Adding on the form, the control for this field |
|
194 | - $this->addElement($form_select, $key, $var); |
|
195 | - unset($form_select); |
|
196 | - |
|
197 | - // If this field don't have a specific control, we will use the standard one, depending on its data type |
|
198 | - } else { |
|
199 | - switch ($var['data_type']) { |
|
200 | - |
|
201 | - case XOBJ_DTYPE_TXTBOX: |
|
202 | - |
|
203 | - $form_text = $this->getControl('text', $key); |
|
204 | - $this->addElement($form_text, $key, $var); |
|
205 | - unset($form_text); |
|
206 | - break; |
|
207 | - |
|
208 | - case XOBJ_DTYPE_INT: |
|
209 | - $this->targetObject->setControl($key, [ |
|
210 | - 'name' => 'text', |
|
211 | - 'size' => '5' |
|
212 | - ]); |
|
213 | - $form_text = $this->getControl('text', $key); |
|
214 | - $this->addElement($form_text, $key, $var); |
|
215 | - unset($form_text); |
|
216 | - break; |
|
217 | - |
|
218 | - case XOBJ_DTYPE_FLOAT: |
|
219 | - $this->targetObject->setControl($key, [ |
|
220 | - 'name' => 'text', |
|
221 | - 'size' => '5' |
|
222 | - ]); |
|
223 | - $form_text = $this->getControl('text', $key); |
|
224 | - $this->addElement($form_text, $key, $var); |
|
225 | - unset($form_text); |
|
226 | - break; |
|
227 | - |
|
228 | - case XOBJ_DTYPE_LTIME: |
|
229 | - $form_date_time = $this->getControl('date_time', $key); |
|
230 | - $this->addElement($form_date_time, $key, $var); |
|
231 | - unset($form_date_time); |
|
232 | - break; |
|
233 | - |
|
234 | - case XOBJ_DTYPE_STIME: |
|
235 | - $form_date_time = $this->getControl('date', $key); |
|
236 | - $this->addElement($form_date_time, $key, $var); |
|
237 | - unset($form_date_time); |
|
238 | - break; |
|
239 | - |
|
240 | - case XOBJ_DTYPE_TIME_ONLY: |
|
241 | - $form_time = $this->getControl('time', $key); |
|
242 | - $this->addElement($form_time, $key, $var); |
|
243 | - unset($form_time); |
|
244 | - break; |
|
245 | - |
|
246 | - case XOBJ_DTYPE_CURRENCY: |
|
247 | - $this->targetObject->setControl($key, [ |
|
248 | - 'name' => 'text', |
|
249 | - 'size' => '15' |
|
250 | - ]); |
|
251 | - $form_currency = $this->getControl('text', $key); |
|
252 | - $this->addElement($form_currency, $key, $var); |
|
253 | - unset($form_currency); |
|
254 | - break; |
|
255 | - |
|
256 | - case XOBJ_DTYPE_URLLINK: |
|
257 | - $form_urllink = $this->getControl('urllink', $key); |
|
258 | - $this->addElement($form_urllink, $key, $var); |
|
259 | - unset($form_urllink); |
|
260 | - break; |
|
261 | - |
|
262 | - case XOBJ_DTYPE_FILE: |
|
263 | - $form_file = $this->getControl('richfile', $key); |
|
264 | - $this->addElement($form_file, $key, $var); |
|
265 | - unset($form_file); |
|
266 | - break; |
|
267 | - |
|
268 | - case XOBJ_DTYPE_TXTAREA: |
|
269 | - |
|
270 | - $form_text_area = $this->getTextArea($key, $var); |
|
271 | - $this->addElement($form_text_area, $key, $var); |
|
272 | - unset($form_text_area); |
|
273 | - break; |
|
274 | - |
|
275 | - case XOBJ_DTYPE_ARRAY: |
|
276 | - // TODO: To come... |
|
277 | - break; |
|
278 | - case XOBJ_DTYPE_SOURCE: |
|
279 | - // TODO: To come... |
|
280 | - break; |
|
281 | - case XOBJ_DTYPE_FORM_SECTION: |
|
282 | - $section_control = new SmartFormSection($key, $var['value']); |
|
283 | - $this->addElement($section_control, $key, $var); |
|
284 | - unset($section_control); |
|
285 | - break; |
|
286 | - case XOBJ_DTYPE_FORM_SECTION_CLOSE: |
|
287 | - $section_control = new SmartFormSectionClose($key, $var['value']); |
|
288 | - $this->addElement($section_control, $key, $var); |
|
289 | - unset($section_control); |
|
290 | - break; |
|
291 | - } |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
295 | - // Add an hidden field to store the URL of the page before this form |
|
296 | - $this->addElement(new \XoopsFormHidden('smart_page_before_form', Smartobject\Utility::getPageBeforeForm())); |
|
297 | - } |
|
298 | - |
|
299 | - public function createPermissionControls() |
|
300 | - { |
|
301 | - $smartModuleConfig = $this->targetObject->handler->getModuleConfig(); |
|
302 | - |
|
303 | - $permissions = $this->targetObject->handler->getPermissions(); |
|
304 | - |
|
305 | - if ($permissions) { |
|
306 | - $memberHandler = xoops_getHandler('member'); |
|
307 | - $group_list = $memberHandler->getGroupList(); |
|
308 | - asort($group_list); |
|
309 | - foreach ($permissions as $permission) { |
|
310 | - if ($this->targetObject->isNew()) { |
|
311 | - if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) { |
|
312 | - $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']]; |
|
313 | - } |
|
314 | - } else { |
|
315 | - $groups_value = $this->targetObject->getGroupPerm($permission['perm_name']); |
|
316 | - } |
|
317 | - $groups_select = new \XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true); |
|
318 | - $groups_select->setDescription($permission['description']); |
|
319 | - $groups_select->addOptionArray($group_list); |
|
320 | - $this->addElement($groups_select); |
|
321 | - unset($groups_select); |
|
322 | - } |
|
323 | - } |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * @param $form_name |
|
328 | - * @param $form_caption |
|
329 | - * @param bool $submit_button_caption |
|
330 | - */ |
|
331 | - public function createButtons($form_name, $form_caption, $submit_button_caption = false) |
|
332 | - { |
|
333 | - $button_tray = new \XoopsFormElementTray('', ''); |
|
334 | - $button_tray->addElement(new \XoopsFormHidden('op', $form_name)); |
|
335 | - if (!$submit_button_caption) { |
|
336 | - if ($this->targetObject->isNew()) { |
|
337 | - $butt_create = new \XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit'); |
|
338 | - } else { |
|
339 | - $butt_create = new \XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit'); |
|
340 | - } |
|
341 | - } else { |
|
342 | - $butt_create = new \XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit'); |
|
343 | - } |
|
344 | - $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"'); |
|
345 | - $button_tray->addElement($butt_create); |
|
346 | - |
|
347 | - //creating custom buttons |
|
348 | - if ($this->_custom_button) { |
|
349 | - foreach ($this->_custom_button as $custom_button) { |
|
350 | - $butt_custom = new \XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit'); |
|
351 | - if ($custom_button['onclick']) { |
|
352 | - $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"'); |
|
353 | - } |
|
354 | - $button_tray->addElement($butt_custom); |
|
355 | - unset($butt_custom); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - // creating the "cancel" button |
|
360 | - $butt_cancel = new \XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button'); |
|
361 | - if ($this->_cancel_js_action) { |
|
362 | - $butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"'); |
|
363 | - } else { |
|
364 | - $butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
365 | - } |
|
366 | - $button_tray->addElement($butt_cancel); |
|
367 | - |
|
368 | - $this->addElement($button_tray); |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * @param $controlName |
|
373 | - * @param $key |
|
374 | - * @return \XoopsFormLabel |
|
375 | - */ |
|
376 | - public function getControl($controlName, $key) |
|
377 | - { |
|
378 | - switch ($controlName) { |
|
379 | - case 'check': |
|
187 | + if (!isset($controls[$key]['name']) || !$controls[$key]['name']) { |
|
188 | + $controls[$key]['name'] = 'select'; |
|
189 | + } |
|
190 | + |
|
191 | + $form_select = $this->getControl($controls[$key]['name'], $key); |
|
192 | + |
|
193 | + // Adding on the form, the control for this field |
|
194 | + $this->addElement($form_select, $key, $var); |
|
195 | + unset($form_select); |
|
196 | + |
|
197 | + // If this field don't have a specific control, we will use the standard one, depending on its data type |
|
198 | + } else { |
|
199 | + switch ($var['data_type']) { |
|
200 | + |
|
201 | + case XOBJ_DTYPE_TXTBOX: |
|
202 | + |
|
203 | + $form_text = $this->getControl('text', $key); |
|
204 | + $this->addElement($form_text, $key, $var); |
|
205 | + unset($form_text); |
|
206 | + break; |
|
207 | + |
|
208 | + case XOBJ_DTYPE_INT: |
|
209 | + $this->targetObject->setControl($key, [ |
|
210 | + 'name' => 'text', |
|
211 | + 'size' => '5' |
|
212 | + ]); |
|
213 | + $form_text = $this->getControl('text', $key); |
|
214 | + $this->addElement($form_text, $key, $var); |
|
215 | + unset($form_text); |
|
216 | + break; |
|
217 | + |
|
218 | + case XOBJ_DTYPE_FLOAT: |
|
219 | + $this->targetObject->setControl($key, [ |
|
220 | + 'name' => 'text', |
|
221 | + 'size' => '5' |
|
222 | + ]); |
|
223 | + $form_text = $this->getControl('text', $key); |
|
224 | + $this->addElement($form_text, $key, $var); |
|
225 | + unset($form_text); |
|
226 | + break; |
|
227 | + |
|
228 | + case XOBJ_DTYPE_LTIME: |
|
229 | + $form_date_time = $this->getControl('date_time', $key); |
|
230 | + $this->addElement($form_date_time, $key, $var); |
|
231 | + unset($form_date_time); |
|
232 | + break; |
|
233 | + |
|
234 | + case XOBJ_DTYPE_STIME: |
|
235 | + $form_date_time = $this->getControl('date', $key); |
|
236 | + $this->addElement($form_date_time, $key, $var); |
|
237 | + unset($form_date_time); |
|
238 | + break; |
|
239 | + |
|
240 | + case XOBJ_DTYPE_TIME_ONLY: |
|
241 | + $form_time = $this->getControl('time', $key); |
|
242 | + $this->addElement($form_time, $key, $var); |
|
243 | + unset($form_time); |
|
244 | + break; |
|
245 | + |
|
246 | + case XOBJ_DTYPE_CURRENCY: |
|
247 | + $this->targetObject->setControl($key, [ |
|
248 | + 'name' => 'text', |
|
249 | + 'size' => '15' |
|
250 | + ]); |
|
251 | + $form_currency = $this->getControl('text', $key); |
|
252 | + $this->addElement($form_currency, $key, $var); |
|
253 | + unset($form_currency); |
|
254 | + break; |
|
255 | + |
|
256 | + case XOBJ_DTYPE_URLLINK: |
|
257 | + $form_urllink = $this->getControl('urllink', $key); |
|
258 | + $this->addElement($form_urllink, $key, $var); |
|
259 | + unset($form_urllink); |
|
260 | + break; |
|
261 | + |
|
262 | + case XOBJ_DTYPE_FILE: |
|
263 | + $form_file = $this->getControl('richfile', $key); |
|
264 | + $this->addElement($form_file, $key, $var); |
|
265 | + unset($form_file); |
|
266 | + break; |
|
267 | + |
|
268 | + case XOBJ_DTYPE_TXTAREA: |
|
269 | + |
|
270 | + $form_text_area = $this->getTextArea($key, $var); |
|
271 | + $this->addElement($form_text_area, $key, $var); |
|
272 | + unset($form_text_area); |
|
273 | + break; |
|
274 | + |
|
275 | + case XOBJ_DTYPE_ARRAY: |
|
276 | + // TODO: To come... |
|
277 | + break; |
|
278 | + case XOBJ_DTYPE_SOURCE: |
|
279 | + // TODO: To come... |
|
280 | + break; |
|
281 | + case XOBJ_DTYPE_FORM_SECTION: |
|
282 | + $section_control = new SmartFormSection($key, $var['value']); |
|
283 | + $this->addElement($section_control, $key, $var); |
|
284 | + unset($section_control); |
|
285 | + break; |
|
286 | + case XOBJ_DTYPE_FORM_SECTION_CLOSE: |
|
287 | + $section_control = new SmartFormSectionClose($key, $var['value']); |
|
288 | + $this->addElement($section_control, $key, $var); |
|
289 | + unset($section_control); |
|
290 | + break; |
|
291 | + } |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | + // Add an hidden field to store the URL of the page before this form |
|
296 | + $this->addElement(new \XoopsFormHidden('smart_page_before_form', Smartobject\Utility::getPageBeforeForm())); |
|
297 | + } |
|
298 | + |
|
299 | + public function createPermissionControls() |
|
300 | + { |
|
301 | + $smartModuleConfig = $this->targetObject->handler->getModuleConfig(); |
|
302 | + |
|
303 | + $permissions = $this->targetObject->handler->getPermissions(); |
|
304 | + |
|
305 | + if ($permissions) { |
|
306 | + $memberHandler = xoops_getHandler('member'); |
|
307 | + $group_list = $memberHandler->getGroupList(); |
|
308 | + asort($group_list); |
|
309 | + foreach ($permissions as $permission) { |
|
310 | + if ($this->targetObject->isNew()) { |
|
311 | + if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) { |
|
312 | + $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']]; |
|
313 | + } |
|
314 | + } else { |
|
315 | + $groups_value = $this->targetObject->getGroupPerm($permission['perm_name']); |
|
316 | + } |
|
317 | + $groups_select = new \XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true); |
|
318 | + $groups_select->setDescription($permission['description']); |
|
319 | + $groups_select->addOptionArray($group_list); |
|
320 | + $this->addElement($groups_select); |
|
321 | + unset($groups_select); |
|
322 | + } |
|
323 | + } |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * @param $form_name |
|
328 | + * @param $form_caption |
|
329 | + * @param bool $submit_button_caption |
|
330 | + */ |
|
331 | + public function createButtons($form_name, $form_caption, $submit_button_caption = false) |
|
332 | + { |
|
333 | + $button_tray = new \XoopsFormElementTray('', ''); |
|
334 | + $button_tray->addElement(new \XoopsFormHidden('op', $form_name)); |
|
335 | + if (!$submit_button_caption) { |
|
336 | + if ($this->targetObject->isNew()) { |
|
337 | + $butt_create = new \XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit'); |
|
338 | + } else { |
|
339 | + $butt_create = new \XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit'); |
|
340 | + } |
|
341 | + } else { |
|
342 | + $butt_create = new \XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit'); |
|
343 | + } |
|
344 | + $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"'); |
|
345 | + $button_tray->addElement($butt_create); |
|
346 | + |
|
347 | + //creating custom buttons |
|
348 | + if ($this->_custom_button) { |
|
349 | + foreach ($this->_custom_button as $custom_button) { |
|
350 | + $butt_custom = new \XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit'); |
|
351 | + if ($custom_button['onclick']) { |
|
352 | + $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"'); |
|
353 | + } |
|
354 | + $button_tray->addElement($butt_custom); |
|
355 | + unset($butt_custom); |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + // creating the "cancel" button |
|
360 | + $butt_cancel = new \XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button'); |
|
361 | + if ($this->_cancel_js_action) { |
|
362 | + $butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"'); |
|
363 | + } else { |
|
364 | + $butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
365 | + } |
|
366 | + $button_tray->addElement($butt_cancel); |
|
367 | + |
|
368 | + $this->addElement($button_tray); |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * @param $controlName |
|
373 | + * @param $key |
|
374 | + * @return \XoopsFormLabel |
|
375 | + */ |
|
376 | + public function getControl($controlName, $key) |
|
377 | + { |
|
378 | + switch ($controlName) { |
|
379 | + case 'check': |
|
380 | 380 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
381 | - $control = $this->targetObject->getControl($key); |
|
382 | - $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
383 | - $controlObj->addOptionArray($control['options']); |
|
381 | + $control = $this->targetObject->getControl($key); |
|
382 | + $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
383 | + $controlObj->addOptionArray($control['options']); |
|
384 | 384 | |
385 | - return $controlObj; |
|
386 | - break; |
|
385 | + return $controlObj; |
|
386 | + break; |
|
387 | 387 | |
388 | - case 'color': |
|
389 | - $control = $this->targetObject->getControl($key); |
|
390 | - $controlObj = new \XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
388 | + case 'color': |
|
389 | + $control = $this->targetObject->getControl($key); |
|
390 | + $controlObj = new \XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
391 | 391 | |
392 | - return $controlObj; |
|
393 | - break; |
|
392 | + return $controlObj; |
|
393 | + break; |
|
394 | 394 | |
395 | - case 'radio': |
|
396 | - $control = $this->targetObject->getControl($key); |
|
395 | + case 'radio': |
|
396 | + $control = $this->targetObject->getControl($key); |
|
397 | 397 | |
398 | - $controlObj = new \XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
399 | - $controlObj->addOptionArray($control['options']); |
|
398 | + $controlObj = new \XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
399 | + $controlObj->addOptionArray($control['options']); |
|
400 | 400 | |
401 | - return $controlObj; |
|
402 | - break; |
|
401 | + return $controlObj; |
|
402 | + break; |
|
403 | 403 | |
404 | - case 'label': |
|
405 | - return new \XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key)); |
|
406 | - break; |
|
404 | + case 'label': |
|
405 | + return new \XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key)); |
|
406 | + break; |
|
407 | 407 | |
408 | - case 'textarea': |
|
409 | - return $this->getTextArea($key); |
|
408 | + case 'textarea': |
|
409 | + return $this->getTextArea($key); |
|
410 | 410 | |
411 | - case 'theme': |
|
412 | - return $this->getThemeSelect($key, $this->targetObject->vars[$key]); |
|
411 | + case 'theme': |
|
412 | + return $this->getThemeSelect($key, $this->targetObject->vars[$key]); |
|
413 | 413 | |
414 | - case 'theme_multi': |
|
415 | - return $this->getThemeSelect($key, $this->targetObject->vars[$key], true); |
|
416 | - break; |
|
414 | + case 'theme_multi': |
|
415 | + return $this->getThemeSelect($key, $this->targetObject->vars[$key], true); |
|
416 | + break; |
|
417 | 417 | |
418 | - case 'timezone': |
|
419 | - return new \XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
420 | - break; |
|
418 | + case 'timezone': |
|
419 | + return new \XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
|
420 | + break; |
|
421 | 421 | |
422 | - case 'group': |
|
423 | - return new \XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false); |
|
424 | - break; |
|
422 | + case 'group': |
|
423 | + return new \XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false); |
|
424 | + break; |
|
425 | 425 | |
426 | - case 'group_multi': |
|
427 | - return new \XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true); |
|
428 | - break; |
|
426 | + case 'group_multi': |
|
427 | + return new \XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true); |
|
428 | + break; |
|
429 | 429 | |
430 | - /*case 'user': |
|
430 | + /*case 'user': |
|
431 | 431 | return new \XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false); |
432 | 432 | break;*/ |
433 | 433 | |
434 | - case 'user_multi': |
|
435 | - return new \XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true); |
|
436 | - break; |
|
434 | + case 'user_multi': |
|
435 | + return new \XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true); |
|
436 | + break; |
|
437 | 437 | |
438 | - case 'password': |
|
439 | - return new \XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e')); |
|
440 | - break; |
|
438 | + case 'password': |
|
439 | + return new \XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e')); |
|
440 | + break; |
|
441 | 441 | |
442 | - case 'country': |
|
443 | - return new \XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e')); |
|
444 | - break; |
|
442 | + case 'country': |
|
443 | + return new \XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e')); |
|
444 | + break; |
|
445 | 445 | |
446 | - case 'urllink': |
|
446 | + case 'urllink': |
|
447 | 447 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php'; |
448 | 448 | |
449 | - return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key)); |
|
450 | - break; |
|
449 | + return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key)); |
|
450 | + break; |
|
451 | 451 | |
452 | - case 'richfile': |
|
452 | + case 'richfile': |
|
453 | 453 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php'; |
454 | 454 | |
455 | - return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key)); |
|
456 | - break; |
|
457 | - case 'section': |
|
455 | + return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key)); |
|
456 | + break; |
|
457 | + case 'section': |
|
458 | 458 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php'; |
459 | 459 | |
460 | - return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']); |
|
461 | - break; |
|
460 | + return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']); |
|
461 | + break; |
|
462 | 462 | |
463 | - default: |
|
464 | - $classname = 'SmartForm' . ucfirst($controlName) . 'Element'; |
|
465 | - if (!class_exists($classname)) { |
|
466 | - if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) { |
|
463 | + default: |
|
464 | + $classname = 'SmartForm' . ucfirst($controlName) . 'Element'; |
|
465 | + if (!class_exists($classname)) { |
|
466 | + if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) { |
|
467 | 467 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php'; |
468 | - } else { |
|
469 | - // perhaps this is a control created by the module |
|
470 | - $moduleName = $this->targetObject->handler->_moduleName; |
|
471 | - $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/'; |
|
472 | - $classname = ucfirst($moduleName) . ucfirst($controlName) . 'Element'; |
|
473 | - $classFileName = strtolower($classname) . '.php'; |
|
474 | - |
|
475 | - if (file_exists($moduleFormElementsPath . $classFileName)) { |
|
468 | + } else { |
|
469 | + // perhaps this is a control created by the module |
|
470 | + $moduleName = $this->targetObject->handler->_moduleName; |
|
471 | + $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/'; |
|
472 | + $classname = ucfirst($moduleName) . ucfirst($controlName) . 'Element'; |
|
473 | + $classFileName = strtolower($classname) . '.php'; |
|
474 | + |
|
475 | + if (file_exists($moduleFormElementsPath . $classFileName)) { |
|
476 | 476 | // require_once $moduleFormElementsPath . $classFileName; |
477 | - } else { |
|
478 | - trigger_error($classname . ' Not found', E_USER_WARNING); |
|
479 | - |
|
480 | - return new \XoopsFormLabel(); //Empty object |
|
481 | - } |
|
482 | - } |
|
483 | - } |
|
484 | - |
|
485 | - return new $classname($this->targetObject, $key); |
|
486 | - break; |
|
487 | - } |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * @param $key |
|
492 | - * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor|\XoopsFormTextArea|\XoopsFormTinymce|\XoopsFormTinymce4 |
|
493 | - */ |
|
494 | - public function getTextArea($key) |
|
495 | - { |
|
496 | - $var = $this->targetObject->vars[$key]; |
|
497 | - |
|
498 | - // if no control has been created, let's create a default one |
|
499 | - if (!isset($this->targetObject->controls[$key])) { |
|
500 | - $control = [ |
|
501 | - 'name' => 'textarea', |
|
502 | - 'itemHandler' => false, |
|
503 | - 'method' => false, |
|
504 | - 'module' => false, |
|
505 | - 'form_editor' => 'default' |
|
506 | - ]; |
|
507 | - } else { |
|
508 | - $control = $this->targetObject->controls[$key]; |
|
509 | - } |
|
510 | - $xoops22 = Smartobject\Utility::isXoops22(); |
|
511 | - |
|
512 | - $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea'; |
|
513 | - /** |
|
514 | - * If the editor is 'default', retreive the default editor of this module |
|
515 | - */ |
|
516 | - if ('default' === $form_editor) { |
|
517 | - global $xoopsModuleConfig; |
|
518 | - $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea'; |
|
519 | - } |
|
520 | - |
|
521 | - $caption = $var['form_caption']; |
|
522 | - $name = $key; |
|
523 | - |
|
524 | - $value = $this->targetObject->getVar($key); |
|
525 | - |
|
526 | - $value = $this->targetObject->getValueFor($key, true); |
|
527 | - |
|
528 | - $editor_configs = []; |
|
529 | - $editor_configs['name'] = $name; |
|
530 | - $editor_configs['value'] = $value; |
|
531 | - if ('textarea' !== $form_editor) { |
|
532 | - $editor_configs['rows'] = 35; |
|
533 | - $editor_configs['cols'] = 60; |
|
534 | - } |
|
535 | - |
|
536 | - if (isset($control['rows'])) { |
|
537 | - $editor_configs['rows'] = $control['rows']; |
|
538 | - } |
|
539 | - if (isset($control['cols'])) { |
|
540 | - $editor_configs['cols'] = $control['cols']; |
|
541 | - } |
|
542 | - |
|
543 | - $editor_configs['width'] = '100%'; |
|
544 | - $editor_configs['height'] = '400px'; |
|
545 | - |
|
546 | - $dhtml = true; |
|
547 | - $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php'; |
|
548 | - |
|
549 | - if (file_exists($xoopseditorclass)) { |
|
550 | - require_once $xoopseditorclass; |
|
551 | - $editor = new \XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea'); |
|
552 | - } else { |
|
553 | - switch ($form_editor) { |
|
554 | - |
|
555 | - case 'tiny': |
|
556 | - if (!$xoops22) { |
|
557 | - if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) { |
|
558 | - require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php'; |
|
559 | - $editor = new \XoopsFormTinymce([ |
|
560 | - 'caption' => $caption, |
|
561 | - 'name' => $name, |
|
562 | - 'value' => $value, |
|
563 | - 'width' => '100%', |
|
564 | - 'height' => '300px' |
|
565 | - ], true); |
|
566 | - } else { |
|
567 | - if ($dhtml) { |
|
568 | - $editor = new \XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
|
569 | - } else { |
|
570 | - $editor = new \XoopsFormTextArea($caption, $name, $value, 7, 60); |
|
571 | - } |
|
572 | - } |
|
573 | - } else { |
|
574 | - $editor = new \XoopsFormEditor($caption, 'tinyeditor', $editor_configs); |
|
575 | - } |
|
576 | - break; |
|
577 | - |
|
578 | - case 'dhtmltextarea': |
|
579 | - case 'dhtmltext': |
|
580 | - $editor = new \XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60); |
|
581 | - if ($var['form_dsc']) { |
|
582 | - $editor->setDescription($var['form_dsc']); |
|
583 | - } |
|
584 | - break; |
|
477 | + } else { |
|
478 | + trigger_error($classname . ' Not found', E_USER_WARNING); |
|
479 | + |
|
480 | + return new \XoopsFormLabel(); //Empty object |
|
481 | + } |
|
482 | + } |
|
483 | + } |
|
484 | + |
|
485 | + return new $classname($this->targetObject, $key); |
|
486 | + break; |
|
487 | + } |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * @param $key |
|
492 | + * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor|\XoopsFormTextArea|\XoopsFormTinymce|\XoopsFormTinymce4 |
|
493 | + */ |
|
494 | + public function getTextArea($key) |
|
495 | + { |
|
496 | + $var = $this->targetObject->vars[$key]; |
|
497 | + |
|
498 | + // if no control has been created, let's create a default one |
|
499 | + if (!isset($this->targetObject->controls[$key])) { |
|
500 | + $control = [ |
|
501 | + 'name' => 'textarea', |
|
502 | + 'itemHandler' => false, |
|
503 | + 'method' => false, |
|
504 | + 'module' => false, |
|
505 | + 'form_editor' => 'default' |
|
506 | + ]; |
|
507 | + } else { |
|
508 | + $control = $this->targetObject->controls[$key]; |
|
509 | + } |
|
510 | + $xoops22 = Smartobject\Utility::isXoops22(); |
|
511 | + |
|
512 | + $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea'; |
|
513 | + /** |
|
514 | + * If the editor is 'default', retreive the default editor of this module |
|
515 | + */ |
|
516 | + if ('default' === $form_editor) { |
|
517 | + global $xoopsModuleConfig; |
|
518 | + $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea'; |
|
519 | + } |
|
520 | + |
|
521 | + $caption = $var['form_caption']; |
|
522 | + $name = $key; |
|
523 | + |
|
524 | + $value = $this->targetObject->getVar($key); |
|
525 | + |
|
526 | + $value = $this->targetObject->getValueFor($key, true); |
|
527 | + |
|
528 | + $editor_configs = []; |
|
529 | + $editor_configs['name'] = $name; |
|
530 | + $editor_configs['value'] = $value; |
|
531 | + if ('textarea' !== $form_editor) { |
|
532 | + $editor_configs['rows'] = 35; |
|
533 | + $editor_configs['cols'] = 60; |
|
534 | + } |
|
535 | + |
|
536 | + if (isset($control['rows'])) { |
|
537 | + $editor_configs['rows'] = $control['rows']; |
|
538 | + } |
|
539 | + if (isset($control['cols'])) { |
|
540 | + $editor_configs['cols'] = $control['cols']; |
|
541 | + } |
|
542 | + |
|
543 | + $editor_configs['width'] = '100%'; |
|
544 | + $editor_configs['height'] = '400px'; |
|
545 | + |
|
546 | + $dhtml = true; |
|
547 | + $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php'; |
|
548 | + |
|
549 | + if (file_exists($xoopseditorclass)) { |
|
550 | + require_once $xoopseditorclass; |
|
551 | + $editor = new \XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea'); |
|
552 | + } else { |
|
553 | + switch ($form_editor) { |
|
554 | + |
|
555 | + case 'tiny': |
|
556 | + if (!$xoops22) { |
|
557 | + if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) { |
|
558 | + require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php'; |
|
559 | + $editor = new \XoopsFormTinymce([ |
|
560 | + 'caption' => $caption, |
|
561 | + 'name' => $name, |
|
562 | + 'value' => $value, |
|
563 | + 'width' => '100%', |
|
564 | + 'height' => '300px' |
|
565 | + ], true); |
|
566 | + } else { |
|
567 | + if ($dhtml) { |
|
568 | + $editor = new \XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
|
569 | + } else { |
|
570 | + $editor = new \XoopsFormTextArea($caption, $name, $value, 7, 60); |
|
571 | + } |
|
572 | + } |
|
573 | + } else { |
|
574 | + $editor = new \XoopsFormEditor($caption, 'tinyeditor', $editor_configs); |
|
575 | + } |
|
576 | + break; |
|
577 | + |
|
578 | + case 'dhtmltextarea': |
|
579 | + case 'dhtmltext': |
|
580 | + $editor = new \XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60); |
|
581 | + if ($var['form_dsc']) { |
|
582 | + $editor->setDescription($var['form_dsc']); |
|
583 | + } |
|
584 | + break; |
|
585 | 585 | |
586 | 586 | // case 'inbetween': |
587 | 587 | // if (!$xoops22) { |
@@ -634,177 +634,177 @@ discard block |
||
634 | 634 | // } |
635 | 635 | // break; |
636 | 636 | |
637 | - default: |
|
638 | - case 'textarea': |
|
639 | - $form_rows = isset($control['rows']) ? $control['rows'] : 5; |
|
640 | - $form_cols = isset($control['cols']) ? $control['cols'] : 60; |
|
641 | - |
|
642 | - $editor = new \XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols); |
|
643 | - if ($var['form_dsc']) { |
|
644 | - $editor->setDescription($var['form_dsc']); |
|
645 | - } |
|
646 | - break; |
|
647 | - |
|
648 | - } |
|
649 | - } |
|
650 | - |
|
651 | - return $editor; |
|
652 | - } |
|
653 | - |
|
654 | - /** |
|
655 | - * @param $key |
|
656 | - * @param $var |
|
657 | - * @param bool $multiple |
|
658 | - * @return \XoopsFormSelect |
|
659 | - */ |
|
660 | - public function getThemeSelect($key, $var, $multiple = false) |
|
661 | - { |
|
662 | - $size = $multiple ? 5 : 1; |
|
663 | - $theme_select = new \XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple); |
|
664 | - |
|
665 | - $handle = opendir(XOOPS_THEME_PATH . '/'); |
|
666 | - $dirlist = []; |
|
667 | - while (false !== ($file = readdir($handle))) { |
|
668 | - if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match('/^[.]{1,2}$/', $file) |
|
669 | - && 'cvs' !== strtolower($file)) { |
|
670 | - $dirlist[$file] = $file; |
|
671 | - } |
|
672 | - } |
|
673 | - closedir($handle); |
|
674 | - if (!empty($dirlist)) { |
|
675 | - asort($dirlist); |
|
676 | - $theme_select->addOptionArray($dirlist); |
|
677 | - } |
|
678 | - |
|
679 | - return $theme_select; |
|
680 | - } |
|
681 | - |
|
682 | - /** |
|
683 | - * @param $keyname |
|
684 | - * @return bool |
|
685 | - */ |
|
686 | - public function &getElementById($keyname) |
|
687 | - { |
|
688 | - foreach ($this->_elements as $eleObj) { |
|
689 | - if ($eleObj->getName() == $keyname) { |
|
690 | - $ret =& $eleObj; |
|
691 | - break; |
|
692 | - } |
|
693 | - } |
|
694 | - |
|
695 | - return isset($ret) ? $ret : false; |
|
696 | - } |
|
697 | - |
|
698 | - /** |
|
699 | - * create HTML to output the form as a theme-enabled table with validation. |
|
700 | - * |
|
701 | - * @return string |
|
702 | - */ |
|
703 | - public function render() |
|
704 | - { |
|
705 | - $required = $this->getRequired(); |
|
706 | - $ret = " |
|
637 | + default: |
|
638 | + case 'textarea': |
|
639 | + $form_rows = isset($control['rows']) ? $control['rows'] : 5; |
|
640 | + $form_cols = isset($control['cols']) ? $control['cols'] : 60; |
|
641 | + |
|
642 | + $editor = new \XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols); |
|
643 | + if ($var['form_dsc']) { |
|
644 | + $editor->setDescription($var['form_dsc']); |
|
645 | + } |
|
646 | + break; |
|
647 | + |
|
648 | + } |
|
649 | + } |
|
650 | + |
|
651 | + return $editor; |
|
652 | + } |
|
653 | + |
|
654 | + /** |
|
655 | + * @param $key |
|
656 | + * @param $var |
|
657 | + * @param bool $multiple |
|
658 | + * @return \XoopsFormSelect |
|
659 | + */ |
|
660 | + public function getThemeSelect($key, $var, $multiple = false) |
|
661 | + { |
|
662 | + $size = $multiple ? 5 : 1; |
|
663 | + $theme_select = new \XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple); |
|
664 | + |
|
665 | + $handle = opendir(XOOPS_THEME_PATH . '/'); |
|
666 | + $dirlist = []; |
|
667 | + while (false !== ($file = readdir($handle))) { |
|
668 | + if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match('/^[.]{1,2}$/', $file) |
|
669 | + && 'cvs' !== strtolower($file)) { |
|
670 | + $dirlist[$file] = $file; |
|
671 | + } |
|
672 | + } |
|
673 | + closedir($handle); |
|
674 | + if (!empty($dirlist)) { |
|
675 | + asort($dirlist); |
|
676 | + $theme_select->addOptionArray($dirlist); |
|
677 | + } |
|
678 | + |
|
679 | + return $theme_select; |
|
680 | + } |
|
681 | + |
|
682 | + /** |
|
683 | + * @param $keyname |
|
684 | + * @return bool |
|
685 | + */ |
|
686 | + public function &getElementById($keyname) |
|
687 | + { |
|
688 | + foreach ($this->_elements as $eleObj) { |
|
689 | + if ($eleObj->getName() == $keyname) { |
|
690 | + $ret =& $eleObj; |
|
691 | + break; |
|
692 | + } |
|
693 | + } |
|
694 | + |
|
695 | + return isset($ret) ? $ret : false; |
|
696 | + } |
|
697 | + |
|
698 | + /** |
|
699 | + * create HTML to output the form as a theme-enabled table with validation. |
|
700 | + * |
|
701 | + * @return string |
|
702 | + */ |
|
703 | + public function render() |
|
704 | + { |
|
705 | + $required = $this->getRequired(); |
|
706 | + $ret = " |
|
707 | 707 | <form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "' onsubmit='return xoopsFormValidate_" . $this->getName() . "(this);'" . $this->getExtra() . "> |
708 | 708 | <table width='100%' class='outer' cellspacing='1'> |
709 | 709 | <tr><th colspan='2'>" . $this->getTitle() . '</th></tr> |
710 | 710 | '; |
711 | - $hidden = ''; |
|
712 | - $class = 'even'; |
|
713 | - foreach ($this->getElements() as $ele) { |
|
714 | - if (!is_object($ele)) { |
|
715 | - $ret .= $ele; |
|
716 | - } elseif (!$ele->isHidden()) { |
|
717 | - //$class = ( $class == 'even' ) ? 'odd': 'even'; |
|
718 | - $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption(); |
|
719 | - if ('' !== $ele->getDescription()) { |
|
720 | - $ret .= '<br><br><span style="font-weight: normal;">' . $ele->getDescription() . '</span>'; |
|
721 | - } |
|
722 | - $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n"; |
|
723 | - } else { |
|
724 | - $hidden .= $ele->render(); |
|
725 | - } |
|
726 | - } |
|
727 | - $ret .= "</table>\n$hidden\n</form>\n"; |
|
728 | - $ret .= $this->renderValidationJS(true); |
|
729 | - |
|
730 | - return $ret; |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * assign to smarty form template instead of displaying directly |
|
735 | - * |
|
736 | - * @param \XoopsTpl $tpl |
|
737 | - * |
|
738 | - * object |
|
739 | - * @param bool $smartyName |
|
740 | - * @see Smarty |
|
741 | - */ |
|
742 | - public function assign(\XoopsTpl $tpl, $smartyName = false) |
|
743 | - { |
|
744 | - $i = 0; |
|
745 | - $elements = []; |
|
746 | - foreach ($this->getElements() as $ele) { |
|
747 | - $n = ('' !== $ele->getName()) ? $ele->getName() : $i; |
|
748 | - $elements[$n]['name'] = $ele->getName(); |
|
749 | - $elements[$n]['caption'] = $ele->getCaption(); |
|
750 | - $elements[$n]['body'] = $ele->render(); |
|
751 | - $elements[$n]['hidden'] = $ele->isHidden(); |
|
752 | - $elements[$n]['section'] = strtolower(get_class($ele)) == strtolower('SmartFormSection'); |
|
753 | - $elements[$n]['section_close'] = $ele instanceof \XoopsModules\Smartobject\Form\Elements\SmartFormSectionClose; |
|
754 | - $elements[$n]['hide'] = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false; |
|
755 | - if ('' !== $ele->getDescription()) { |
|
756 | - $elements[$n]['description'] = $ele->getDescription(); |
|
757 | - } |
|
758 | - ++$i; |
|
759 | - } |
|
760 | - $js = $this->renderValidationJS(); |
|
761 | - if (!$smartyName) { |
|
762 | - $smartyName = $this->getName(); |
|
763 | - } |
|
764 | - |
|
765 | - $tpl->assign($smartyName, [ |
|
766 | - 'title' => $this->getTitle(), |
|
767 | - 'name' => $this->getName(), |
|
768 | - 'action' => $this->getAction(), |
|
769 | - 'method' => $this->getMethod(), |
|
770 | - 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(), |
|
771 | - 'javascript' => $js, |
|
772 | - 'elements' => $elements |
|
773 | - ]); |
|
774 | - } |
|
775 | - |
|
776 | - /** |
|
777 | - * @param bool $withtags |
|
778 | - * @return string |
|
779 | - */ |
|
780 | - public function renderValidationJS($withtags = true) |
|
781 | - { |
|
782 | - $js = ''; |
|
783 | - if ($withtags) { |
|
784 | - $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n"; |
|
785 | - } |
|
786 | - $myts = \MyTextSanitizer::getInstance(); |
|
787 | - $formname = $this->getName(); |
|
788 | - $js .= "function xoopsFormValidate_{$formname}(myform) {"; |
|
789 | - // First, output code to check required elements |
|
790 | - $elements = $this->getRequired(); |
|
791 | - foreach ($elements as $elt) { |
|
792 | - $eltname = $elt->getName(); |
|
793 | - $eltcaption = trim($elt->getCaption()); |
|
794 | - $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); |
|
795 | - $eltmsg = str_replace('"', '\"', stripslashes($eltmsg)); |
|
796 | - if ('xoopsformradio' === strtolower(get_class($elt))) { |
|
797 | - $js .= 'var myOption = -1;'; |
|
798 | - $js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) { |
|
711 | + $hidden = ''; |
|
712 | + $class = 'even'; |
|
713 | + foreach ($this->getElements() as $ele) { |
|
714 | + if (!is_object($ele)) { |
|
715 | + $ret .= $ele; |
|
716 | + } elseif (!$ele->isHidden()) { |
|
717 | + //$class = ( $class == 'even' ) ? 'odd': 'even'; |
|
718 | + $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption(); |
|
719 | + if ('' !== $ele->getDescription()) { |
|
720 | + $ret .= '<br><br><span style="font-weight: normal;">' . $ele->getDescription() . '</span>'; |
|
721 | + } |
|
722 | + $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n"; |
|
723 | + } else { |
|
724 | + $hidden .= $ele->render(); |
|
725 | + } |
|
726 | + } |
|
727 | + $ret .= "</table>\n$hidden\n</form>\n"; |
|
728 | + $ret .= $this->renderValidationJS(true); |
|
729 | + |
|
730 | + return $ret; |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * assign to smarty form template instead of displaying directly |
|
735 | + * |
|
736 | + * @param \XoopsTpl $tpl |
|
737 | + * |
|
738 | + * object |
|
739 | + * @param bool $smartyName |
|
740 | + * @see Smarty |
|
741 | + */ |
|
742 | + public function assign(\XoopsTpl $tpl, $smartyName = false) |
|
743 | + { |
|
744 | + $i = 0; |
|
745 | + $elements = []; |
|
746 | + foreach ($this->getElements() as $ele) { |
|
747 | + $n = ('' !== $ele->getName()) ? $ele->getName() : $i; |
|
748 | + $elements[$n]['name'] = $ele->getName(); |
|
749 | + $elements[$n]['caption'] = $ele->getCaption(); |
|
750 | + $elements[$n]['body'] = $ele->render(); |
|
751 | + $elements[$n]['hidden'] = $ele->isHidden(); |
|
752 | + $elements[$n]['section'] = strtolower(get_class($ele)) == strtolower('SmartFormSection'); |
|
753 | + $elements[$n]['section_close'] = $ele instanceof \XoopsModules\Smartobject\Form\Elements\SmartFormSectionClose; |
|
754 | + $elements[$n]['hide'] = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false; |
|
755 | + if ('' !== $ele->getDescription()) { |
|
756 | + $elements[$n]['description'] = $ele->getDescription(); |
|
757 | + } |
|
758 | + ++$i; |
|
759 | + } |
|
760 | + $js = $this->renderValidationJS(); |
|
761 | + if (!$smartyName) { |
|
762 | + $smartyName = $this->getName(); |
|
763 | + } |
|
764 | + |
|
765 | + $tpl->assign($smartyName, [ |
|
766 | + 'title' => $this->getTitle(), |
|
767 | + 'name' => $this->getName(), |
|
768 | + 'action' => $this->getAction(), |
|
769 | + 'method' => $this->getMethod(), |
|
770 | + 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(), |
|
771 | + 'javascript' => $js, |
|
772 | + 'elements' => $elements |
|
773 | + ]); |
|
774 | + } |
|
775 | + |
|
776 | + /** |
|
777 | + * @param bool $withtags |
|
778 | + * @return string |
|
779 | + */ |
|
780 | + public function renderValidationJS($withtags = true) |
|
781 | + { |
|
782 | + $js = ''; |
|
783 | + if ($withtags) { |
|
784 | + $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n"; |
|
785 | + } |
|
786 | + $myts = \MyTextSanitizer::getInstance(); |
|
787 | + $formname = $this->getName(); |
|
788 | + $js .= "function xoopsFormValidate_{$formname}(myform) {"; |
|
789 | + // First, output code to check required elements |
|
790 | + $elements = $this->getRequired(); |
|
791 | + foreach ($elements as $elt) { |
|
792 | + $eltname = $elt->getName(); |
|
793 | + $eltcaption = trim($elt->getCaption()); |
|
794 | + $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); |
|
795 | + $eltmsg = str_replace('"', '\"', stripslashes($eltmsg)); |
|
796 | + if ('xoopsformradio' === strtolower(get_class($elt))) { |
|
797 | + $js .= 'var myOption = -1;'; |
|
798 | + $js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) { |
|
799 | 799 | if (myform.{$eltname}[i].checked) { |
800 | 800 | myOption = i; i = -1; |
801 | 801 | } |
802 | 802 | } |
803 | 803 | if (myOption == -1) { |
804 | 804 | window.alert(\"{$eltmsg}\"); myform.{$eltname}[0].focus(); return false; }\n"; |
805 | - } elseif ('smartformselect_multielement' === strtolower(get_class($elt))) { |
|
806 | - $js .= 'var hasSelections = false;'; |
|
807 | - $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
805 | + } elseif ('smartformselect_multielement' === strtolower(get_class($elt))) { |
|
806 | + $js .= 'var hasSelections = false;'; |
|
807 | + $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
808 | 808 | if (myform['{$eltname}[]'].options[i].selected) { |
809 | 809 | hasSelections = true; |
810 | 810 | } |
@@ -812,12 +812,12 @@ discard block |
||
812 | 812 | } |
813 | 813 | if (hasSelections === false) { |
814 | 814 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'].options[0].focus(); return false; }\n"; |
815 | - } elseif ('xoopsformcheckbox' === strtolower(get_class($elt)) |
|
816 | - || 'smartformcheckelement' === strtolower(get_class($elt))) { |
|
817 | - $js .= 'var hasSelections = false;'; |
|
818 | - //sometimes, there is an implicit '[]', sometimes not |
|
819 | - if (false === strpos($eltname, '[')) { |
|
820 | - $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
815 | + } elseif ('xoopsformcheckbox' === strtolower(get_class($elt)) |
|
816 | + || 'smartformcheckelement' === strtolower(get_class($elt))) { |
|
817 | + $js .= 'var hasSelections = false;'; |
|
818 | + //sometimes, there is an implicit '[]', sometimes not |
|
819 | + if (false === strpos($eltname, '[')) { |
|
820 | + $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
821 | 821 | if (myform['{$eltname}[]'][i].checked) { |
822 | 822 | hasSelections = true; |
823 | 823 | } |
@@ -825,8 +825,8 @@ discard block |
||
825 | 825 | } |
826 | 826 | if (hasSelections === false) { |
827 | 827 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n"; |
828 | - } else { |
|
829 | - $js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) { |
|
828 | + } else { |
|
829 | + $js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) { |
|
830 | 830 | if (myform['{$eltname}'][i].checked) { |
831 | 831 | hasSelections = true; |
832 | 832 | } |
@@ -834,25 +834,25 @@ discard block |
||
834 | 834 | } |
835 | 835 | if (hasSelections === false) { |
836 | 836 | window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n"; |
837 | - } |
|
838 | - } else { |
|
839 | - $js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n"; |
|
840 | - } |
|
841 | - } |
|
842 | - // Now, handle custom validation code |
|
843 | - $elements =& $this->getElements(true); |
|
844 | - foreach ($elements as $elt) { |
|
845 | - if (method_exists($elt, 'renderValidationJS') && 'xoopsformcheckbox' !== strtolower(get_class($elt))) { |
|
846 | - if ($eltjs = $elt->renderValidationJS()) { |
|
847 | - $js .= $eltjs . "\n"; |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - $js .= "return true;\n}\n"; |
|
852 | - if ($withtags) { |
|
853 | - $js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n"; |
|
854 | - } |
|
855 | - |
|
856 | - return $js; |
|
857 | - } |
|
837 | + } |
|
838 | + } else { |
|
839 | + $js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n"; |
|
840 | + } |
|
841 | + } |
|
842 | + // Now, handle custom validation code |
|
843 | + $elements =& $this->getElements(true); |
|
844 | + foreach ($elements as $elt) { |
|
845 | + if (method_exists($elt, 'renderValidationJS') && 'xoopsformcheckbox' !== strtolower(get_class($elt))) { |
|
846 | + if ($eltjs = $elt->renderValidationJS()) { |
|
847 | + $js .= $eltjs . "\n"; |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + $js .= "return true;\n}\n"; |
|
852 | + if ($withtags) { |
|
853 | + $js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n"; |
|
854 | + } |
|
855 | + |
|
856 | + return $js; |
|
857 | + } |
|
858 | 858 | } |
@@ -30,22 +30,22 @@ |
||
30 | 30 | */ |
31 | 31 | class ObjectCurrencyHandler extends Smartobject\PersistableObjectHandler |
32 | 32 | { |
33 | - /** |
|
34 | - * SmartObjectCurrencyHandler constructor. |
|
35 | - * @param \XoopsDatabase $db |
|
36 | - */ |
|
37 | - public function __construct(\XoopsDatabase $db) |
|
38 | - { |
|
39 | - parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - public function getCurrencies() |
|
46 | - { |
|
47 | - $currenciesObj =& $this->getObjects(null, true); |
|
48 | - |
|
49 | - return $currenciesObj; |
|
50 | - } |
|
33 | + /** |
|
34 | + * SmartObjectCurrencyHandler constructor. |
|
35 | + * @param \XoopsDatabase $db |
|
36 | + */ |
|
37 | + public function __construct(\XoopsDatabase $db) |
|
38 | + { |
|
39 | + parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + public function getCurrencies() |
|
46 | + { |
|
47 | + $currenciesObj =& $this->getObjects(null, true); |
|
48 | + |
|
49 | + return $currenciesObj; |
|
50 | + } |
|
51 | 51 | } |
@@ -29,27 +29,27 @@ |
||
29 | 29 | */ |
30 | 30 | class TagHandler extends Smartobject\PersistableMlObjectHandler |
31 | 31 | { |
32 | - /** |
|
33 | - * SmartobjectTagHandler constructor. |
|
34 | - * @param \XoopsDatabase $db |
|
35 | - */ |
|
36 | - public function __construct(\XoopsDatabase $db) |
|
37 | - { |
|
38 | - parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject'); |
|
39 | - } |
|
32 | + /** |
|
33 | + * SmartobjectTagHandler constructor. |
|
34 | + * @param \XoopsDatabase $db |
|
35 | + */ |
|
36 | + public function __construct(\XoopsDatabase $db) |
|
37 | + { |
|
38 | + parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return mixed |
|
43 | - */ |
|
44 | - public function getLanguages() |
|
45 | - { |
|
46 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
47 | - $aLanguages = XoopsLists::getLangList(); |
|
48 | - $ret['default'] = _CO_SOBJECT_ALL; |
|
49 | - foreach ($aLanguages as $lang) { |
|
50 | - $ret[$lang] = $lang; |
|
51 | - } |
|
41 | + /** |
|
42 | + * @return mixed |
|
43 | + */ |
|
44 | + public function getLanguages() |
|
45 | + { |
|
46 | + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
47 | + $aLanguages = XoopsLists::getLangList(); |
|
48 | + $ret['default'] = _CO_SOBJECT_ALL; |
|
49 | + foreach ($aLanguages as $lang) { |
|
50 | + $ret[$lang] = $lang; |
|
51 | + } |
|
52 | 52 | |
53 | - return $ret; |
|
54 | - } |
|
53 | + return $ret; |
|
54 | + } |
|
55 | 55 | } |