@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Access the only instance of this class |
20 | 20 | * |
21 | - * @return XoopsObject |
|
21 | + * @return SmartObjectsRegistry |
|
22 | 22 | * |
23 | 23 | * @static |
24 | 24 | * @staticvar object |
@@ -13,169 +13,169 @@ |
||
13 | 13 | */ |
14 | 14 | class SmartObjectsRegistry |
15 | 15 | { |
16 | - public $_registryArray; |
|
16 | + public $_registryArray; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Access the only instance of this class |
|
20 | - * |
|
21 | - * @return XoopsObject |
|
22 | - * |
|
23 | - * @static |
|
24 | - * @staticvar object |
|
25 | - */ |
|
26 | - public static function getInstance() |
|
27 | - { |
|
28 | - static $instance; |
|
29 | - if (null === $instance) { |
|
30 | - $instance = new static(); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Access the only instance of this class |
|
20 | + * |
|
21 | + * @return XoopsObject |
|
22 | + * |
|
23 | + * @static |
|
24 | + * @staticvar object |
|
25 | + */ |
|
26 | + public static function getInstance() |
|
27 | + { |
|
28 | + static $instance; |
|
29 | + if (null === $instance) { |
|
30 | + $instance = new static(); |
|
31 | + } |
|
32 | 32 | |
33 | - return $instance; |
|
34 | - } |
|
33 | + return $instance; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Adding objects to the registry |
|
38 | - * |
|
39 | - * @param SmartPersistableObjectHandler $handler of the objects to add |
|
40 | - * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
41 | - * @return FALSE if an error occured |
|
42 | - */ |
|
43 | - public function addObjectsFromHandler(&$handler, $criteria = false) |
|
44 | - { |
|
45 | - if (method_exists($handler, 'getObjects')) { |
|
46 | - $objects = $handler->getObjects($criteria, true); |
|
47 | - $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects; |
|
36 | + /** |
|
37 | + * Adding objects to the registry |
|
38 | + * |
|
39 | + * @param SmartPersistableObjectHandler $handler of the objects to add |
|
40 | + * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
41 | + * @return FALSE if an error occured |
|
42 | + */ |
|
43 | + public function addObjectsFromHandler(&$handler, $criteria = false) |
|
44 | + { |
|
45 | + if (method_exists($handler, 'getObjects')) { |
|
46 | + $objects = $handler->getObjects($criteria, true); |
|
47 | + $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects; |
|
48 | 48 | |
49 | - return $objects; |
|
50 | - } else { |
|
51 | - return false; |
|
52 | - } |
|
53 | - } |
|
49 | + return $objects; |
|
50 | + } else { |
|
51 | + return false; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Adding objects to the registry from an item name |
|
57 | - * This method will fetch the handler of the item / module and call the addObjectsFromHandler |
|
58 | - * |
|
59 | - * @param string $item name of the item |
|
60 | - * @param bool|string $modulename name of the module |
|
61 | - * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
62 | - * @return FALSE if an error occured |
|
63 | - */ |
|
64 | - public function addObjectsFromItemName($item, $modulename = false, $criteria = false) |
|
65 | - { |
|
66 | - if (!$modulename) { |
|
67 | - global $xoopsModule; |
|
68 | - if (!is_object($xoopsModule)) { |
|
69 | - return false; |
|
70 | - } else { |
|
71 | - $modulename = $xoopsModule->dirname(); |
|
72 | - } |
|
73 | - } |
|
74 | - $objectHandler = xoops_getModuleHandler($item, $modulename); |
|
55 | + /** |
|
56 | + * Adding objects to the registry from an item name |
|
57 | + * This method will fetch the handler of the item / module and call the addObjectsFromHandler |
|
58 | + * |
|
59 | + * @param string $item name of the item |
|
60 | + * @param bool|string $modulename name of the module |
|
61 | + * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
62 | + * @return FALSE if an error occured |
|
63 | + */ |
|
64 | + public function addObjectsFromItemName($item, $modulename = false, $criteria = false) |
|
65 | + { |
|
66 | + if (!$modulename) { |
|
67 | + global $xoopsModule; |
|
68 | + if (!is_object($xoopsModule)) { |
|
69 | + return false; |
|
70 | + } else { |
|
71 | + $modulename = $xoopsModule->dirname(); |
|
72 | + } |
|
73 | + } |
|
74 | + $objectHandler = xoops_getModuleHandler($item, $modulename); |
|
75 | 75 | |
76 | - if (method_exists($objectHandler, 'getObjects')) { |
|
77 | - $objects = $objectHandler->getObjects($criteria, true); |
|
78 | - $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects; |
|
76 | + if (method_exists($objectHandler, 'getObjects')) { |
|
77 | + $objects = $objectHandler->getObjects($criteria, true); |
|
78 | + $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects; |
|
79 | 79 | |
80 | - return $objects; |
|
81 | - } else { |
|
82 | - return false; |
|
83 | - } |
|
84 | - } |
|
80 | + return $objects; |
|
81 | + } else { |
|
82 | + return false; |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Fetching objects from the registry |
|
88 | - * |
|
89 | - * @param string $itemname |
|
90 | - * @param string $modulename |
|
91 | - * |
|
92 | - * @return the requested objects or FALSE if they don't exists in the registry |
|
93 | - */ |
|
94 | - public function getObjects($itemname, $modulename) |
|
95 | - { |
|
96 | - if (!$modulename) { |
|
97 | - global $xoopsModule; |
|
98 | - if (!is_object($xoopsModule)) { |
|
99 | - return false; |
|
100 | - } else { |
|
101 | - $modulename = $xoopsModule->dirname(); |
|
102 | - } |
|
103 | - } |
|
104 | - if (isset($this->_registryArray['objects'][$modulename][$itemname])) { |
|
105 | - return $this->_registryArray['objects'][$modulename][$itemname]; |
|
106 | - } else { |
|
107 | - // if they were not in registry, let's fetch them and add them to the reigistry |
|
108 | - $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
109 | - if (method_exists($moduleHandler, 'getObjects')) { |
|
110 | - $objects = $moduleHandler->getObjects(); |
|
111 | - } |
|
112 | - $this->_registryArray['objects'][$modulename][$itemname] = $objects; |
|
86 | + /** |
|
87 | + * Fetching objects from the registry |
|
88 | + * |
|
89 | + * @param string $itemname |
|
90 | + * @param string $modulename |
|
91 | + * |
|
92 | + * @return the requested objects or FALSE if they don't exists in the registry |
|
93 | + */ |
|
94 | + public function getObjects($itemname, $modulename) |
|
95 | + { |
|
96 | + if (!$modulename) { |
|
97 | + global $xoopsModule; |
|
98 | + if (!is_object($xoopsModule)) { |
|
99 | + return false; |
|
100 | + } else { |
|
101 | + $modulename = $xoopsModule->dirname(); |
|
102 | + } |
|
103 | + } |
|
104 | + if (isset($this->_registryArray['objects'][$modulename][$itemname])) { |
|
105 | + return $this->_registryArray['objects'][$modulename][$itemname]; |
|
106 | + } else { |
|
107 | + // if they were not in registry, let's fetch them and add them to the reigistry |
|
108 | + $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
109 | + if (method_exists($moduleHandler, 'getObjects')) { |
|
110 | + $objects = $moduleHandler->getObjects(); |
|
111 | + } |
|
112 | + $this->_registryArray['objects'][$modulename][$itemname] = $objects; |
|
113 | 113 | |
114 | - return $objects; |
|
115 | - } |
|
116 | - } |
|
114 | + return $objects; |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Fetching objects from the registry, as a list: objectid => identifier |
|
120 | - * |
|
121 | - * @param string $itemname |
|
122 | - * @param string $modulename |
|
123 | - * |
|
124 | - * @return the requested objects or FALSE if they don't exists in the registry |
|
125 | - */ |
|
126 | - public function getList($itemname, $modulename) |
|
127 | - { |
|
128 | - if (!$modulename) { |
|
129 | - global $xoopsModule; |
|
130 | - if (!is_object($xoopsModule)) { |
|
131 | - return false; |
|
132 | - } else { |
|
133 | - $modulename = $xoopsModule->dirname(); |
|
134 | - } |
|
135 | - } |
|
136 | - if (isset($this->_registryArray['list'][$modulename][$itemname])) { |
|
137 | - return $this->_registryArray['list'][$modulename][$itemname]; |
|
138 | - } else { |
|
139 | - // if they were not in registry, let's fetch them and add them to the reigistry |
|
140 | - $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
141 | - if (method_exists($moduleHandler, 'getList')) { |
|
142 | - $objects = $moduleHandler->getList(); |
|
143 | - } |
|
144 | - $this->_registryArray['list'][$modulename][$itemname] = $objects; |
|
118 | + /** |
|
119 | + * Fetching objects from the registry, as a list: objectid => identifier |
|
120 | + * |
|
121 | + * @param string $itemname |
|
122 | + * @param string $modulename |
|
123 | + * |
|
124 | + * @return the requested objects or FALSE if they don't exists in the registry |
|
125 | + */ |
|
126 | + public function getList($itemname, $modulename) |
|
127 | + { |
|
128 | + if (!$modulename) { |
|
129 | + global $xoopsModule; |
|
130 | + if (!is_object($xoopsModule)) { |
|
131 | + return false; |
|
132 | + } else { |
|
133 | + $modulename = $xoopsModule->dirname(); |
|
134 | + } |
|
135 | + } |
|
136 | + if (isset($this->_registryArray['list'][$modulename][$itemname])) { |
|
137 | + return $this->_registryArray['list'][$modulename][$itemname]; |
|
138 | + } else { |
|
139 | + // if they were not in registry, let's fetch them and add them to the reigistry |
|
140 | + $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
141 | + if (method_exists($moduleHandler, 'getList')) { |
|
142 | + $objects = $moduleHandler->getList(); |
|
143 | + } |
|
144 | + $this->_registryArray['list'][$modulename][$itemname] = $objects; |
|
145 | 145 | |
146 | - return $objects; |
|
147 | - } |
|
148 | - } |
|
146 | + return $objects; |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Retreive a single object |
|
152 | - * |
|
153 | - * @param string $itemname |
|
154 | - * @param string $key |
|
155 | - * |
|
156 | - * @param bool $modulename |
|
157 | - * @return the requestd object or FALSE if they don't exists in the registry |
|
158 | - */ |
|
159 | - public function getSingleObject($itemname, $key, $modulename = false) |
|
160 | - { |
|
161 | - if (!$modulename) { |
|
162 | - global $xoopsModule; |
|
163 | - if (!is_object($xoopsModule)) { |
|
164 | - return false; |
|
165 | - } else { |
|
166 | - $modulename = $xoopsModule->dirname(); |
|
167 | - } |
|
168 | - } |
|
169 | - if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) { |
|
170 | - return $this->_registryArray['objects'][$modulename][$itemname][$key]; |
|
171 | - } else { |
|
172 | - $objectHandler = xoops_getModuleHandler($itemname, $modulename); |
|
173 | - $object = $objectHandler->get($key); |
|
174 | - if (!$object->isNew()) { |
|
175 | - return $object; |
|
176 | - } else { |
|
177 | - return false; |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
150 | + /** |
|
151 | + * Retreive a single object |
|
152 | + * |
|
153 | + * @param string $itemname |
|
154 | + * @param string $key |
|
155 | + * |
|
156 | + * @param bool $modulename |
|
157 | + * @return the requestd object or FALSE if they don't exists in the registry |
|
158 | + */ |
|
159 | + public function getSingleObject($itemname, $key, $modulename = false) |
|
160 | + { |
|
161 | + if (!$modulename) { |
|
162 | + global $xoopsModule; |
|
163 | + if (!is_object($xoopsModule)) { |
|
164 | + return false; |
|
165 | + } else { |
|
166 | + $modulename = $xoopsModule->dirname(); |
|
167 | + } |
|
168 | + } |
|
169 | + if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) { |
|
170 | + return $this->_registryArray['objects'][$modulename][$itemname][$key]; |
|
171 | + } else { |
|
172 | + $objectHandler = xoops_getModuleHandler($itemname, $modulename); |
|
173 | + $object = $objectHandler->get($key); |
|
174 | + if (!$object->isNew()) { |
|
175 | + return $object; |
|
176 | + } else { |
|
177 | + return false; |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | 181 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
328 | - * @param $key |
|
328 | + * @param string $key |
|
329 | 329 | * @param bool $moduleName |
330 | 330 | * @param string $default |
331 | 331 | * @return null|string |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Thanks to the NewBB2 Development Team |
390 | - * @param $target |
|
390 | + * @param string $target |
|
391 | 391 | * @return bool |
392 | 392 | */ |
393 | 393 | function smart_admin_mkdir($target) |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | |
541 | 541 | /** |
542 | 542 | * @param $dirname |
543 | - * @return bool |
|
543 | + * @return boolean|null |
|
544 | 544 | */ |
545 | 545 | function smart_deleteFile($dirname) |
546 | 546 | { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | - * @param $name |
|
758 | + * @param string $name |
|
759 | 759 | */ |
760 | 760 | function smart_close_collapsable($name) |
761 | 761 | { |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
768 | - * @param $name |
|
768 | + * @param string $name |
|
769 | 769 | * @param $value |
770 | 770 | * @param int $time |
771 | 771 | */ |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
782 | - * @param $name |
|
782 | + * @param string $name |
|
783 | 783 | * @param string $default |
784 | 784 | * @return string |
785 | 785 | */ |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | } |
939 | 939 | |
940 | 940 | /** |
941 | - * @param $src |
|
941 | + * @param string $src |
|
942 | 942 | */ |
943 | 943 | function smart_addScript($src) |
944 | 944 | { |
@@ -1115,8 +1115,8 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
1118 | - * @param $module |
|
1119 | - * @param $file |
|
1118 | + * @param string $module |
|
1119 | + * @param string $file |
|
1120 | 1120 | */ |
1121 | 1121 | function smart_loadLanguageFile($module, $file) |
1122 | 1122 | { |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | * This function should be able to cover almost all floats that appear in an european environment. |
1233 | 1233 | * @param $str |
1234 | 1234 | * @param bool $set |
1235 | - * @return float|int |
|
1235 | + * @return double |
|
1236 | 1236 | */ |
1237 | 1237 | function smart_getfloat($str, $set = false) |
1238 | 1238 | { |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | /** |
1268 | 1268 | * @param $var |
1269 | 1269 | * @param bool $currencyObj |
1270 | - * @return float|int|mixed|string |
|
1270 | + * @return string |
|
1271 | 1271 | */ |
1272 | 1272 | function smart_currency($var, $currencyObj = false) |
1273 | 1273 | { |
@@ -1295,7 +1295,7 @@ discard block |
||
1295 | 1295 | |
1296 | 1296 | /** |
1297 | 1297 | * @param $var |
1298 | - * @return float|int|mixed|string |
|
1298 | + * @return string |
|
1299 | 1299 | */ |
1300 | 1300 | function smart_float($var) |
1301 | 1301 | { |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | /** |
1344 | 1344 | * @param $moduleName |
1345 | 1345 | * @param $items |
1346 | - * @return array |
|
1346 | + * @return string[] |
|
1347 | 1347 | */ |
1348 | 1348 | function smart_getTablesArray($moduleName, $items) |
1349 | 1349 | { |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | |
12 | 12 | function smart_get_css_link($cssfile) |
13 | 13 | { |
14 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />'; |
|
14 | + $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />'; |
|
15 | 15 | |
16 | - return $ret; |
|
16 | + return $ret; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function smart_get_page_before_form() |
23 | 23 | { |
24 | - global $smart_previous_page; |
|
24 | + global $smart_previous_page; |
|
25 | 25 | |
26 | - return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
26 | + return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function smart_userIsAdmin($module = false) |
36 | 36 | { |
37 | - global $xoopsUser; |
|
38 | - static $smart_isAdmin; |
|
39 | - if (!$module) { |
|
40 | - global $xoopsModule; |
|
41 | - $module = $xoopsModule->getVar('dirname'); |
|
42 | - } |
|
43 | - if (isset($smart_isAdmin[$module])) { |
|
44 | - return $smart_isAdmin[$module]; |
|
45 | - } |
|
46 | - if (!$xoopsUser) { |
|
47 | - $smart_isAdmin[$module] = false; |
|
48 | - |
|
49 | - return $smart_isAdmin[$module]; |
|
50 | - } |
|
51 | - $smart_isAdmin[$module] = false; |
|
52 | - $smartModule = smart_getModuleInfo($module); |
|
53 | - if (!is_object($smartModule)) { |
|
54 | - return false; |
|
55 | - } |
|
56 | - $module_id = $smartModule->getVar('mid'); |
|
57 | - $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
58 | - |
|
59 | - return $smart_isAdmin[$module]; |
|
37 | + global $xoopsUser; |
|
38 | + static $smart_isAdmin; |
|
39 | + if (!$module) { |
|
40 | + global $xoopsModule; |
|
41 | + $module = $xoopsModule->getVar('dirname'); |
|
42 | + } |
|
43 | + if (isset($smart_isAdmin[$module])) { |
|
44 | + return $smart_isAdmin[$module]; |
|
45 | + } |
|
46 | + if (!$xoopsUser) { |
|
47 | + $smart_isAdmin[$module] = false; |
|
48 | + |
|
49 | + return $smart_isAdmin[$module]; |
|
50 | + } |
|
51 | + $smart_isAdmin[$module] = false; |
|
52 | + $smartModule = smart_getModuleInfo($module); |
|
53 | + if (!is_object($smartModule)) { |
|
54 | + return false; |
|
55 | + } |
|
56 | + $module_id = $smartModule->getVar('mid'); |
|
57 | + $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
58 | + |
|
59 | + return $smart_isAdmin[$module]; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function smart_isXoops22() |
66 | 66 | { |
67 | - $xoops22 = false; |
|
68 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
69 | - if (substr($xv, 2, 1) == '2') { |
|
70 | - $xoops22 = true; |
|
71 | - } |
|
67 | + $xoops22 = false; |
|
68 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
69 | + if (substr($xv, 2, 1) == '2') { |
|
70 | + $xoops22 = true; |
|
71 | + } |
|
72 | 72 | |
73 | - return $xoops22; |
|
73 | + return $xoops22; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,34 +81,34 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) |
83 | 83 | { |
84 | - if (!$moduleName) { |
|
85 | - global $xoopsModule; |
|
86 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
87 | - } |
|
88 | - $smartModule = smart_getModuleInfo($moduleName); |
|
89 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
90 | - if (!isset($smartModule)) { |
|
91 | - return ''; |
|
92 | - } |
|
93 | - |
|
94 | - if ($forBreadCrumb && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
95 | - return ''; |
|
96 | - } |
|
97 | - if (!$withLink) { |
|
98 | - return $smartModule->getVar('name'); |
|
99 | - } else { |
|
100 | - $seoMode = smart_getModuleModeSEO($moduleName); |
|
101 | - if ($seoMode === 'rewrite') { |
|
102 | - $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
103 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
104 | - } elseif ($seoMode === 'pathinfo') { |
|
105 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
106 | - } else { |
|
107 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
108 | - } |
|
109 | - |
|
110 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
111 | - } |
|
84 | + if (!$moduleName) { |
|
85 | + global $xoopsModule; |
|
86 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
87 | + } |
|
88 | + $smartModule = smart_getModuleInfo($moduleName); |
|
89 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
90 | + if (!isset($smartModule)) { |
|
91 | + return ''; |
|
92 | + } |
|
93 | + |
|
94 | + if ($forBreadCrumb && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
95 | + return ''; |
|
96 | + } |
|
97 | + if (!$withLink) { |
|
98 | + return $smartModule->getVar('name'); |
|
99 | + } else { |
|
100 | + $seoMode = smart_getModuleModeSEO($moduleName); |
|
101 | + if ($seoMode === 'rewrite') { |
|
102 | + $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
103 | + $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
104 | + } elseif ($seoMode === 'pathinfo') { |
|
105 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
106 | + } else { |
|
107 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
108 | + } |
|
109 | + |
|
110 | + return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function smart_getModuleNameForSEO($moduleName = false) |
119 | 119 | { |
120 | - $smartModule = smart_getModuleInfo($moduleName); |
|
121 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
122 | - if (isset($smartModuleConfig['seo_module_name'])) { |
|
123 | - return $smartModuleConfig['seo_module_name']; |
|
124 | - } |
|
125 | - $ret = smart_getModuleName(false, false, $moduleName); |
|
126 | - |
|
127 | - return strtolower($ret); |
|
120 | + $smartModule = smart_getModuleInfo($moduleName); |
|
121 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
122 | + if (isset($smartModuleConfig['seo_module_name'])) { |
|
123 | + return $smartModuleConfig['seo_module_name']; |
|
124 | + } |
|
125 | + $ret = smart_getModuleName(false, false, $moduleName); |
|
126 | + |
|
127 | + return strtolower($ret); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | */ |
134 | 134 | function smart_getModuleModeSEO($moduleName = false) |
135 | 135 | { |
136 | - $smartModule = smart_getModuleInfo($moduleName); |
|
137 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
136 | + $smartModule = smart_getModuleInfo($moduleName); |
|
137 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
138 | 138 | |
139 | - return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
139 | + return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function smart_getModuleIncludeIdSEO($moduleName = false) |
147 | 147 | { |
148 | - $smartModule = smart_getModuleInfo($moduleName); |
|
149 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
148 | + $smartModule = smart_getModuleInfo($moduleName); |
|
149 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
150 | 150 | |
151 | - return !empty($smartModuleConfig['seo_inc_id']); |
|
151 | + return !empty($smartModuleConfig['seo_inc_id']); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -157,26 +157,26 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function smart_getenv($key) |
159 | 159 | { |
160 | - $ret = ''; |
|
161 | - $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
160 | + $ret = ''; |
|
161 | + $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
162 | 162 | |
163 | - return $ret; |
|
163 | + return $ret; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | function smart_xoops_cp_header() |
167 | 167 | { |
168 | - xoops_cp_header(); |
|
169 | - global $xoopsModule, $xoopsConfig; |
|
170 | - /** |
|
171 | - * include SmartObject admin language file |
|
172 | - */ |
|
173 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
174 | - if (file_exists($fileName)) { |
|
175 | - include_once $fileName; |
|
176 | - } else { |
|
177 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
178 | - } |
|
179 | - ?> |
|
168 | + xoops_cp_header(); |
|
169 | + global $xoopsModule, $xoopsConfig; |
|
170 | + /** |
|
171 | + * include SmartObject admin language file |
|
172 | + */ |
|
173 | + $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
174 | + if (file_exists($fileName)) { |
|
175 | + include_once $fileName; |
|
176 | + } else { |
|
177 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
178 | + } |
|
179 | + ?> |
|
180 | 180 | <script type='text/javascript'> |
181 | 181 | <!-- |
182 | 182 | var smart_url = '<?php echo SMARTOBJECT_URL ?>'; |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script> |
190 | 190 | <?php |
191 | 191 | |
192 | - /** |
|
193 | - * Include the admin language constants for the SmartObject Framework |
|
194 | - */ |
|
195 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
196 | - if (!file_exists($admin_file)) { |
|
197 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
198 | - } |
|
199 | - include_once($admin_file); |
|
192 | + /** |
|
193 | + * Include the admin language constants for the SmartObject Framework |
|
194 | + */ |
|
195 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
196 | + if (!file_exists($admin_file)) { |
|
197 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
198 | + } |
|
199 | + include_once($admin_file); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | */ |
211 | 211 | function smart_TableExists($table) |
212 | 212 | { |
213 | - $bRetVal = false; |
|
214 | - //Verifies that a MySQL table exists |
|
215 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
216 | - $realname = $xoopsDB->prefix($table); |
|
217 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
218 | - $ret = $xoopsDB->queryF($sql); |
|
219 | - while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
220 | - if ($m_table == $realname) { |
|
221 | - $bRetVal = true; |
|
222 | - break; |
|
223 | - } |
|
224 | - } |
|
225 | - $xoopsDB->freeRecordSet($ret); |
|
226 | - |
|
227 | - return $bRetVal; |
|
213 | + $bRetVal = false; |
|
214 | + //Verifies that a MySQL table exists |
|
215 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
216 | + $realname = $xoopsDB->prefix($table); |
|
217 | + $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
218 | + $ret = $xoopsDB->queryF($sql); |
|
219 | + while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
220 | + if ($m_table == $realname) { |
|
221 | + $bRetVal = true; |
|
222 | + break; |
|
223 | + } |
|
224 | + } |
|
225 | + $xoopsDB->freeRecordSet($ret); |
|
226 | + |
|
227 | + return $bRetVal; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -239,19 +239,19 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function smart_GetMeta($key, $moduleName = false) |
241 | 241 | { |
242 | - if (!$moduleName) { |
|
243 | - $moduleName = smart_getCurrentModuleName(); |
|
244 | - } |
|
245 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
246 | - $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
247 | - $ret = $xoopsDB->query($sql); |
|
248 | - if (!$ret) { |
|
249 | - $value = false; |
|
250 | - } else { |
|
251 | - list($value) = $xoopsDB->fetchRow($ret); |
|
252 | - } |
|
253 | - |
|
254 | - return $value; |
|
242 | + if (!$moduleName) { |
|
243 | + $moduleName = smart_getCurrentModuleName(); |
|
244 | + } |
|
245 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
246 | + $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
247 | + $ret = $xoopsDB->query($sql); |
|
248 | + if (!$ret) { |
|
249 | + $value = false; |
|
250 | + } else { |
|
251 | + list($value) = $xoopsDB->fetchRow($ret); |
|
252 | + } |
|
253 | + |
|
254 | + return $value; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function smart_getCurrentModuleName() |
261 | 261 | { |
262 | - global $xoopsModule; |
|
263 | - if (is_object($xoopsModule)) { |
|
264 | - return $xoopsModule->getVar('dirname'); |
|
265 | - } else { |
|
266 | - return false; |
|
267 | - } |
|
262 | + global $xoopsModule; |
|
263 | + if (is_object($xoopsModule)) { |
|
264 | + return $xoopsModule->getVar('dirname'); |
|
265 | + } else { |
|
266 | + return false; |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -280,22 +280,22 @@ discard block |
||
280 | 280 | */ |
281 | 281 | function smart_SetMeta($key, $value, $moduleName = false) |
282 | 282 | { |
283 | - if (!$moduleName) { |
|
284 | - $moduleName = smart_getCurrentModuleName(); |
|
285 | - } |
|
286 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
287 | - $ret = smart_GetMeta($key, $moduleName); |
|
288 | - if ($ret === '0' || $ret > 0) { |
|
289 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
290 | - } else { |
|
291 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
292 | - } |
|
293 | - $ret = $xoopsDB->queryF($sql); |
|
294 | - if (!$ret) { |
|
295 | - return false; |
|
296 | - } |
|
297 | - |
|
298 | - return true; |
|
283 | + if (!$moduleName) { |
|
284 | + $moduleName = smart_getCurrentModuleName(); |
|
285 | + } |
|
286 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
287 | + $ret = smart_GetMeta($key, $moduleName); |
|
288 | + if ($ret === '0' || $ret > 0) { |
|
289 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
290 | + } else { |
|
291 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
292 | + } |
|
293 | + $ret = $xoopsDB->queryF($sql); |
|
294 | + if (!$ret) { |
|
295 | + return false; |
|
296 | + } |
|
297 | + |
|
298 | + return true; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Thanks to Mithrandir:-) |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | */ |
309 | 309 | function smart_substr($str, $start, $length, $trimmarker = '...') |
310 | 310 | { |
311 | - // if the string is empty, let's get out ;-) |
|
312 | - if ($str === '') { |
|
313 | - return $str; |
|
314 | - } |
|
315 | - // reverse a string that is shortened with '' as trimmarker |
|
316 | - $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
317 | - // find first space in reversed string |
|
318 | - $position_of_space = strpos($reversed_string, ' ', 0); |
|
319 | - // truncate the original string to a length of $length |
|
320 | - // minus the position of the last space |
|
321 | - // plus the length of the $trimmarker |
|
322 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
323 | - |
|
324 | - return $truncated_string; |
|
311 | + // if the string is empty, let's get out ;-) |
|
312 | + if ($str === '') { |
|
313 | + return $str; |
|
314 | + } |
|
315 | + // reverse a string that is shortened with '' as trimmarker |
|
316 | + $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
317 | + // find first space in reversed string |
|
318 | + $position_of_space = strpos($reversed_string, ' ', 0); |
|
319 | + // truncate the original string to a length of $length |
|
320 | + // minus the position of the last space |
|
321 | + // plus the length of the $trimmarker |
|
322 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
323 | + |
|
324 | + return $truncated_string; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | */ |
333 | 333 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') |
334 | 334 | { |
335 | - if (!$moduleName) { |
|
336 | - $moduleName = smart_getCurrentModuleName(); |
|
337 | - } |
|
338 | - $configs = smart_getModuleConfig($moduleName); |
|
339 | - if (isset($configs[$key])) { |
|
340 | - return $configs[$key]; |
|
341 | - } else { |
|
342 | - if ($default === 'default_is_undefined') { |
|
343 | - return null; |
|
344 | - } else { |
|
345 | - return $default; |
|
346 | - } |
|
347 | - } |
|
335 | + if (!$moduleName) { |
|
336 | + $moduleName = smart_getCurrentModuleName(); |
|
337 | + } |
|
338 | + $configs = smart_getModuleConfig($moduleName); |
|
339 | + if (isset($configs[$key])) { |
|
340 | + return $configs[$key]; |
|
341 | + } else { |
|
342 | + if ($default === 'default_is_undefined') { |
|
343 | + return null; |
|
344 | + } else { |
|
345 | + return $default; |
|
346 | + } |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -357,32 +357,32 @@ discard block |
||
357 | 357 | */ |
358 | 358 | function smart_copyr($source, $dest) |
359 | 359 | { |
360 | - // Simple copy for a file |
|
361 | - if (is_file($source)) { |
|
362 | - return copy($source, $dest); |
|
363 | - } |
|
364 | - // Make destination directory |
|
365 | - if (!is_dir($dest)) { |
|
366 | - mkdir($dest); |
|
367 | - } |
|
368 | - // Loop through the folder |
|
369 | - $dir = dir($source); |
|
370 | - while (false !== $entry = $dir->read()) { |
|
371 | - // Skip pointers |
|
372 | - if ($entry === '.' || $entry === '..') { |
|
373 | - continue; |
|
374 | - } |
|
375 | - // Deep copy directories |
|
376 | - if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
377 | - copyr("$source/$entry", "$dest/$entry"); |
|
378 | - } else { |
|
379 | - copy("$source/$entry", "$dest/$entry"); |
|
380 | - } |
|
381 | - } |
|
382 | - // Clean up |
|
383 | - $dir->close(); |
|
384 | - |
|
385 | - return true; |
|
360 | + // Simple copy for a file |
|
361 | + if (is_file($source)) { |
|
362 | + return copy($source, $dest); |
|
363 | + } |
|
364 | + // Make destination directory |
|
365 | + if (!is_dir($dest)) { |
|
366 | + mkdir($dest); |
|
367 | + } |
|
368 | + // Loop through the folder |
|
369 | + $dir = dir($source); |
|
370 | + while (false !== $entry = $dir->read()) { |
|
371 | + // Skip pointers |
|
372 | + if ($entry === '.' || $entry === '..') { |
|
373 | + continue; |
|
374 | + } |
|
375 | + // Deep copy directories |
|
376 | + if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
377 | + copyr("$source/$entry", "$dest/$entry"); |
|
378 | + } else { |
|
379 | + copy("$source/$entry", "$dest/$entry"); |
|
380 | + } |
|
381 | + } |
|
382 | + // Clean up |
|
383 | + $dir->close(); |
|
384 | + |
|
385 | + return true; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -392,26 +392,26 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function smart_admin_mkdir($target) |
394 | 394 | { |
395 | - // http://www.php.net/manual/en/function.mkdir.php |
|
396 | - // saint at corenova.com |
|
397 | - // bart at cdasites dot com |
|
398 | - if (is_dir($target) || empty($target)) { |
|
399 | - return true; // best case check first |
|
400 | - } |
|
401 | - if (file_exists($target) && !is_dir($target)) { |
|
402 | - return false; |
|
403 | - } |
|
404 | - if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
405 | - if (!file_exists($target)) { |
|
406 | - $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
407 | - smart_admin_chmod($target); |
|
408 | - |
|
409 | - return $res; |
|
410 | - } |
|
411 | - } |
|
412 | - $res = is_dir($target); |
|
413 | - |
|
414 | - return $res; |
|
395 | + // http://www.php.net/manual/en/function.mkdir.php |
|
396 | + // saint at corenova.com |
|
397 | + // bart at cdasites dot com |
|
398 | + if (is_dir($target) || empty($target)) { |
|
399 | + return true; // best case check first |
|
400 | + } |
|
401 | + if (file_exists($target) && !is_dir($target)) { |
|
402 | + return false; |
|
403 | + } |
|
404 | + if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
405 | + if (!file_exists($target)) { |
|
406 | + $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
407 | + smart_admin_chmod($target); |
|
408 | + |
|
409 | + return $res; |
|
410 | + } |
|
411 | + } |
|
412 | + $res = is_dir($target); |
|
413 | + |
|
414 | + return $res; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | */ |
423 | 423 | function smart_admin_chmod($target, $mode = 0777) |
424 | 424 | { |
425 | - return @ chmod($target, $mode); |
|
425 | + return @ chmod($target, $mode); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -433,31 +433,31 @@ discard block |
||
433 | 433 | */ |
434 | 434 | function smart_imageResize($src, $maxWidth, $maxHeight) |
435 | 435 | { |
436 | - $width = ''; |
|
437 | - $height = ''; |
|
438 | - $type = ''; |
|
439 | - $attr = ''; |
|
440 | - if (file_exists($src)) { |
|
441 | - list($width, $height, $type, $attr) = getimagesize($src); |
|
442 | - if ($width > $maxWidth) { |
|
443 | - $originalWidth = $width; |
|
444 | - $width = $maxWidth; |
|
445 | - $height = $width * $height / $originalWidth; |
|
446 | - } |
|
447 | - if ($height > $maxHeight) { |
|
448 | - $originalHeight = $height; |
|
449 | - $height = $maxHeight; |
|
450 | - $width = $height * $width / $originalHeight; |
|
451 | - } |
|
452 | - $attr = " width='$width' height='$height'"; |
|
453 | - } |
|
454 | - |
|
455 | - return array( |
|
456 | - $width, |
|
457 | - $height, |
|
458 | - $type, |
|
459 | - $attr |
|
460 | - ); |
|
436 | + $width = ''; |
|
437 | + $height = ''; |
|
438 | + $type = ''; |
|
439 | + $attr = ''; |
|
440 | + if (file_exists($src)) { |
|
441 | + list($width, $height, $type, $attr) = getimagesize($src); |
|
442 | + if ($width > $maxWidth) { |
|
443 | + $originalWidth = $width; |
|
444 | + $width = $maxWidth; |
|
445 | + $height = $width * $height / $originalWidth; |
|
446 | + } |
|
447 | + if ($height > $maxHeight) { |
|
448 | + $originalHeight = $height; |
|
449 | + $height = $maxHeight; |
|
450 | + $width = $height * $width / $originalHeight; |
|
451 | + } |
|
452 | + $attr = " width='$width' height='$height'"; |
|
453 | + } |
|
454 | + |
|
455 | + return array( |
|
456 | + $width, |
|
457 | + $height, |
|
458 | + $type, |
|
459 | + $attr |
|
460 | + ); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -466,34 +466,34 @@ discard block |
||
466 | 466 | */ |
467 | 467 | function smart_getModuleInfo($moduleName = false) |
468 | 468 | { |
469 | - static $smartModules; |
|
470 | - if (isset($smartModules[$moduleName])) { |
|
471 | - $ret =& $smartModules[$moduleName]; |
|
472 | - |
|
473 | - return $ret; |
|
474 | - } |
|
475 | - global $xoopsModule; |
|
476 | - if (!$moduleName) { |
|
477 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
478 | - $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
479 | - |
|
480 | - return $smartModules[$xoopsModule->getVar('dirname')]; |
|
481 | - } |
|
482 | - } |
|
483 | - if (!isset($smartModules[$moduleName])) { |
|
484 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
485 | - $smartModules[$moduleName] = $xoopsModule; |
|
486 | - } else { |
|
487 | - $hModule = xoops_getHandler('module'); |
|
488 | - if ($moduleName !== 'xoops') { |
|
489 | - $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
490 | - } else { |
|
491 | - $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - |
|
496 | - return $smartModules[$moduleName]; |
|
469 | + static $smartModules; |
|
470 | + if (isset($smartModules[$moduleName])) { |
|
471 | + $ret =& $smartModules[$moduleName]; |
|
472 | + |
|
473 | + return $ret; |
|
474 | + } |
|
475 | + global $xoopsModule; |
|
476 | + if (!$moduleName) { |
|
477 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
478 | + $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
479 | + |
|
480 | + return $smartModules[$xoopsModule->getVar('dirname')]; |
|
481 | + } |
|
482 | + } |
|
483 | + if (!isset($smartModules[$moduleName])) { |
|
484 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
485 | + $smartModules[$moduleName] = $xoopsModule; |
|
486 | + } else { |
|
487 | + $hModule = xoops_getHandler('module'); |
|
488 | + if ($moduleName !== 'xoops') { |
|
489 | + $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
490 | + } else { |
|
491 | + $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
492 | + } |
|
493 | + } |
|
494 | + } |
|
495 | + |
|
496 | + return $smartModules[$moduleName]; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -502,40 +502,40 @@ discard block |
||
502 | 502 | */ |
503 | 503 | function smart_getModuleConfig($moduleName = false) |
504 | 504 | { |
505 | - static $smartConfigs; |
|
506 | - if (isset($smartConfigs[$moduleName])) { |
|
507 | - $ret =& $smartConfigs[$moduleName]; |
|
508 | - |
|
509 | - return $ret; |
|
510 | - } |
|
511 | - global $xoopsModule, $xoopsModuleConfig; |
|
512 | - if (!$moduleName) { |
|
513 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
514 | - $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
515 | - |
|
516 | - return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
517 | - } |
|
518 | - } |
|
519 | - // if we still did not found the xoopsModule, this is because there is none |
|
520 | - if (!$moduleName) { |
|
521 | - $ret = false; |
|
522 | - |
|
523 | - return $ret; |
|
524 | - } |
|
525 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
526 | - $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
527 | - } else { |
|
528 | - $module = smart_getModuleInfo($moduleName); |
|
529 | - if (!is_object($module)) { |
|
530 | - $ret = false; |
|
531 | - |
|
532 | - return $ret; |
|
533 | - } |
|
534 | - $hModConfig = xoops_getHandler('config'); |
|
535 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
536 | - } |
|
537 | - |
|
538 | - return $smartConfigs[$moduleName]; |
|
505 | + static $smartConfigs; |
|
506 | + if (isset($smartConfigs[$moduleName])) { |
|
507 | + $ret =& $smartConfigs[$moduleName]; |
|
508 | + |
|
509 | + return $ret; |
|
510 | + } |
|
511 | + global $xoopsModule, $xoopsModuleConfig; |
|
512 | + if (!$moduleName) { |
|
513 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
514 | + $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
515 | + |
|
516 | + return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
517 | + } |
|
518 | + } |
|
519 | + // if we still did not found the xoopsModule, this is because there is none |
|
520 | + if (!$moduleName) { |
|
521 | + $ret = false; |
|
522 | + |
|
523 | + return $ret; |
|
524 | + } |
|
525 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
526 | + $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
527 | + } else { |
|
528 | + $module = smart_getModuleInfo($moduleName); |
|
529 | + if (!is_object($module)) { |
|
530 | + $ret = false; |
|
531 | + |
|
532 | + return $ret; |
|
533 | + } |
|
534 | + $hModConfig = xoops_getHandler('config'); |
|
535 | + $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
536 | + } |
|
537 | + |
|
538 | + return $smartConfigs[$moduleName]; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | */ |
545 | 545 | function smart_deleteFile($dirname) |
546 | 546 | { |
547 | - // Simple delete for a file |
|
548 | - if (is_file($dirname)) { |
|
549 | - return unlink($dirname); |
|
550 | - } |
|
547 | + // Simple delete for a file |
|
548 | + if (is_file($dirname)) { |
|
549 | + return unlink($dirname); |
|
550 | + } |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | */ |
557 | 557 | function smart_formatErrors($errors = array()) |
558 | 558 | { |
559 | - $ret = ''; |
|
560 | - foreach ($errors as $key => $value) { |
|
561 | - $ret .= '<br> - ' . $value; |
|
562 | - } |
|
559 | + $ret = ''; |
|
560 | + foreach ($errors as $key => $value) { |
|
561 | + $ret .= '<br> - ' . $value; |
|
562 | + } |
|
563 | 563 | |
564 | - return $ret; |
|
564 | + return $ret; |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -575,64 +575,64 @@ discard block |
||
575 | 575 | */ |
576 | 576 | function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false) |
577 | 577 | { |
578 | - if (!is_numeric($userid)) { |
|
579 | - return $userid; |
|
580 | - } |
|
581 | - $userid = (int)$userid; |
|
582 | - if ($userid > 0) { |
|
583 | - if ($users == array()) { |
|
584 | - //fetching users |
|
585 | - $memberHandler = xoops_getHandler('member'); |
|
586 | - $user =& $memberHandler->getUser($userid); |
|
587 | - } else { |
|
588 | - if (!isset($users[$userid])) { |
|
589 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
590 | - } |
|
591 | - $user =& $users[$userid]; |
|
592 | - } |
|
593 | - if (is_object($user)) { |
|
594 | - $ts = MyTextSanitizer:: getInstance(); |
|
595 | - $username = $user->getVar('uname'); |
|
596 | - $fullname = ''; |
|
597 | - $fullname2 = $user->getVar('name'); |
|
598 | - if ($name && !empty($fullname2)) { |
|
599 | - $fullname = $user->getVar('name'); |
|
600 | - } |
|
601 | - if (!empty($fullname)) { |
|
602 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
603 | - } else { |
|
604 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
605 | - } |
|
606 | - // add contact info: email + PM |
|
607 | - if ($withContact) { |
|
608 | - $linkeduser .= ' <a href="mailto:' . |
|
609 | - $user->getVar('email') . |
|
610 | - '"><img style="vertical-align: middle;" src="' . |
|
611 | - XOOPS_URL . |
|
612 | - '/images/icons/email.gif' . |
|
613 | - '" alt="' . |
|
614 | - _CO_SOBJECT_SEND_EMAIL . |
|
615 | - '" title="' . |
|
616 | - _CO_SOBJECT_SEND_EMAIL . |
|
617 | - '"/></a>'; |
|
618 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
619 | - $linkeduser .= ' <a href="' . |
|
620 | - $js . |
|
621 | - '"><img style="vertical-align: middle;" src="' . |
|
622 | - XOOPS_URL . |
|
623 | - '/images/icons/pm.gif' . |
|
624 | - '" alt="' . |
|
625 | - _CO_SOBJECT_SEND_PM . |
|
626 | - '" title="' . |
|
627 | - _CO_SOBJECT_SEND_PM . |
|
628 | - '"/></a>'; |
|
629 | - } |
|
630 | - |
|
631 | - return $linkeduser; |
|
632 | - } |
|
633 | - } |
|
634 | - |
|
635 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
578 | + if (!is_numeric($userid)) { |
|
579 | + return $userid; |
|
580 | + } |
|
581 | + $userid = (int)$userid; |
|
582 | + if ($userid > 0) { |
|
583 | + if ($users == array()) { |
|
584 | + //fetching users |
|
585 | + $memberHandler = xoops_getHandler('member'); |
|
586 | + $user =& $memberHandler->getUser($userid); |
|
587 | + } else { |
|
588 | + if (!isset($users[$userid])) { |
|
589 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
590 | + } |
|
591 | + $user =& $users[$userid]; |
|
592 | + } |
|
593 | + if (is_object($user)) { |
|
594 | + $ts = MyTextSanitizer:: getInstance(); |
|
595 | + $username = $user->getVar('uname'); |
|
596 | + $fullname = ''; |
|
597 | + $fullname2 = $user->getVar('name'); |
|
598 | + if ($name && !empty($fullname2)) { |
|
599 | + $fullname = $user->getVar('name'); |
|
600 | + } |
|
601 | + if (!empty($fullname)) { |
|
602 | + $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
603 | + } else { |
|
604 | + $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
605 | + } |
|
606 | + // add contact info: email + PM |
|
607 | + if ($withContact) { |
|
608 | + $linkeduser .= ' <a href="mailto:' . |
|
609 | + $user->getVar('email') . |
|
610 | + '"><img style="vertical-align: middle;" src="' . |
|
611 | + XOOPS_URL . |
|
612 | + '/images/icons/email.gif' . |
|
613 | + '" alt="' . |
|
614 | + _CO_SOBJECT_SEND_EMAIL . |
|
615 | + '" title="' . |
|
616 | + _CO_SOBJECT_SEND_EMAIL . |
|
617 | + '"/></a>'; |
|
618 | + $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
619 | + $linkeduser .= ' <a href="' . |
|
620 | + $js . |
|
621 | + '"><img style="vertical-align: middle;" src="' . |
|
622 | + XOOPS_URL . |
|
623 | + '/images/icons/pm.gif' . |
|
624 | + '" alt="' . |
|
625 | + _CO_SOBJECT_SEND_PM . |
|
626 | + '" title="' . |
|
627 | + _CO_SOBJECT_SEND_PM . |
|
628 | + '"/></a>'; |
|
629 | + } |
|
630 | + |
|
631 | + return $linkeduser; |
|
632 | + } |
|
633 | + } |
|
634 | + |
|
635 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -643,33 +643,33 @@ discard block |
||
643 | 643 | */ |
644 | 644 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
645 | 645 | { |
646 | - global $xoopsModule, $xoopsConfig; |
|
647 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
648 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
649 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
650 | - } else { |
|
651 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
652 | - } |
|
653 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
654 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
655 | - } else { |
|
656 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
657 | - } |
|
658 | - $headermenu = array(); |
|
659 | - $adminmenu = array(); |
|
660 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
661 | - $tpl = new XoopsTpl(); |
|
662 | - $tpl->assign(array( |
|
663 | - 'headermenu' => $headermenu, |
|
664 | - 'adminmenu' => $adminmenu, |
|
665 | - 'current' => $currentoption, |
|
666 | - 'breadcrumb' => $breadcrumb, |
|
667 | - 'headermenucount' => count($headermenu), |
|
668 | - 'submenus' => $submenus, |
|
669 | - 'currentsub' => $currentsub, |
|
670 | - 'submenuscount' => count($submenus) |
|
671 | - )); |
|
672 | - $tpl->display('db:smartobject_admin_menu.tpl'); |
|
646 | + global $xoopsModule, $xoopsConfig; |
|
647 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
648 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
649 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
650 | + } else { |
|
651 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
652 | + } |
|
653 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
654 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
655 | + } else { |
|
656 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
657 | + } |
|
658 | + $headermenu = array(); |
|
659 | + $adminmenu = array(); |
|
660 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
661 | + $tpl = new XoopsTpl(); |
|
662 | + $tpl->assign(array( |
|
663 | + 'headermenu' => $headermenu, |
|
664 | + 'adminmenu' => $adminmenu, |
|
665 | + 'current' => $currentoption, |
|
666 | + 'breadcrumb' => $breadcrumb, |
|
667 | + 'headermenucount' => count($headermenu), |
|
668 | + 'submenus' => $submenus, |
|
669 | + 'currentsub' => $currentsub, |
|
670 | + 'submenuscount' => count($submenus) |
|
671 | + )); |
|
672 | + $tpl->display('db:smartobject_admin_menu.tpl'); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | */ |
680 | 680 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
681 | 681 | { |
682 | - global $xoopsModule; |
|
683 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
684 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
685 | - echo "<div id='" . $id . "'>"; |
|
686 | - if ($dsc !== '') { |
|
687 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
688 | - } |
|
682 | + global $xoopsModule; |
|
683 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
684 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
685 | + echo "<div id='" . $id . "'>"; |
|
686 | + if ($dsc !== '') { |
|
687 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
688 | + } |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -695,15 +695,15 @@ discard block |
||
695 | 695 | */ |
696 | 696 | function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '') |
697 | 697 | { |
698 | - global $xoopsModule; |
|
699 | - $onClick = "ajaxtogglecollapse('$id')"; |
|
700 | - //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
701 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
702 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
703 | - echo "<div id='" . $id . "'>"; |
|
704 | - if ($dsc !== '') { |
|
705 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
706 | - } |
|
698 | + global $xoopsModule; |
|
699 | + $onClick = "ajaxtogglecollapse('$id')"; |
|
700 | + //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
701 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
702 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
703 | + echo "<div id='" . $id . "'>"; |
|
704 | + if ($dsc !== '') { |
|
705 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
706 | + } |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -730,20 +730,20 @@ discard block |
||
730 | 730 | */ |
731 | 731 | function smart_openclose_collapsable($name) |
732 | 732 | { |
733 | - $urls = smart_getCurrentUrls(); |
|
734 | - $path = $urls['phpself']; |
|
735 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
736 | - $cookie_name = str_replace('.', '_', $cookie_name); |
|
737 | - $cookie = smart_getCookieVar($cookie_name, ''); |
|
738 | - if ($cookie === 'none') { |
|
739 | - echo ' |
|
733 | + $urls = smart_getCurrentUrls(); |
|
734 | + $path = $urls['phpself']; |
|
735 | + $cookie_name = $path . '_smart_collaps_' . $name; |
|
736 | + $cookie_name = str_replace('.', '_', $cookie_name); |
|
737 | + $cookie = smart_getCookieVar($cookie_name, ''); |
|
738 | + if ($cookie === 'none') { |
|
739 | + echo ' |
|
740 | 740 | <script type="text/javascript"><!-- |
741 | 741 | togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
742 | 742 | //--> |
743 | 743 | </script> |
744 | 744 | '; |
745 | - } |
|
746 | - /* if ($cookie == 'none') { |
|
745 | + } |
|
746 | + /* if ($cookie == 'none') { |
|
747 | 747 | echo ' |
748 | 748 | <script type="text/javascript"><!-- |
749 | 749 | hideElement("' . $name . '"); |
@@ -759,9 +759,9 @@ discard block |
||
759 | 759 | */ |
760 | 760 | function smart_close_collapsable($name) |
761 | 761 | { |
762 | - echo '</div>'; |
|
763 | - smart_openclose_collapsable($name); |
|
764 | - echo '<br>'; |
|
762 | + echo '</div>'; |
|
763 | + smart_openclose_collapsable($name); |
|
764 | + echo '<br>'; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -771,11 +771,11 @@ discard block |
||
771 | 771 | */ |
772 | 772 | function smart_setCookieVar($name, $value, $time = 0) |
773 | 773 | { |
774 | - if ($time == 0) { |
|
775 | - $time = time() + 3600 * 24 * 365; |
|
776 | - //$time = ''; |
|
777 | - } |
|
778 | - setcookie($name, $value, $time, '/'); |
|
774 | + if ($time == 0) { |
|
775 | + $time = time() + 3600 * 24 * 365; |
|
776 | + //$time = ''; |
|
777 | + } |
|
778 | + setcookie($name, $value, $time, '/'); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -785,12 +785,12 @@ discard block |
||
785 | 785 | */ |
786 | 786 | function smart_getCookieVar($name, $default = '') |
787 | 787 | { |
788 | - $name = str_replace('.', '_', $name); |
|
789 | - if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
790 | - return $_COOKIE[$name]; |
|
791 | - } else { |
|
792 | - return $default; |
|
793 | - } |
|
788 | + $name = str_replace('.', '_', $name); |
|
789 | + if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
790 | + return $_COOKIE[$name]; |
|
791 | + } else { |
|
792 | + return $default; |
|
793 | + } |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -798,25 +798,25 @@ discard block |
||
798 | 798 | */ |
799 | 799 | function smart_getCurrentUrls() |
800 | 800 | { |
801 | - $urls = array(); |
|
802 | - $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
803 | - $phpself = $_SERVER['PHP_SELF']; |
|
804 | - $httphost = $_SERVER['HTTP_HOST']; |
|
805 | - $querystring = $_SERVER['QUERY_STRING']; |
|
806 | - if ($querystring !== '') { |
|
807 | - $querystring = '?' . $querystring; |
|
808 | - } |
|
809 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
810 | - $urls = array(); |
|
811 | - $urls['http'] = $http; |
|
812 | - $urls['httphost'] = $httphost; |
|
813 | - $urls['phpself'] = $phpself; |
|
814 | - $urls['querystring'] = $querystring; |
|
815 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
816 | - $urls['full'] = $currenturl; |
|
817 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
818 | - |
|
819 | - return $urls; |
|
801 | + $urls = array(); |
|
802 | + $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
803 | + $phpself = $_SERVER['PHP_SELF']; |
|
804 | + $httphost = $_SERVER['HTTP_HOST']; |
|
805 | + $querystring = $_SERVER['QUERY_STRING']; |
|
806 | + if ($querystring !== '') { |
|
807 | + $querystring = '?' . $querystring; |
|
808 | + } |
|
809 | + $currenturl = $http . $httphost . $phpself . $querystring; |
|
810 | + $urls = array(); |
|
811 | + $urls['http'] = $http; |
|
812 | + $urls['httphost'] = $httphost; |
|
813 | + $urls['phpself'] = $phpself; |
|
814 | + $urls['querystring'] = $querystring; |
|
815 | + $urls['full_phpself'] = $http . $httphost . $phpself; |
|
816 | + $urls['full'] = $currenturl; |
|
817 | + $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
818 | + |
|
819 | + return $urls; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -824,9 +824,9 @@ discard block |
||
824 | 824 | */ |
825 | 825 | function smart_getCurrentPage() |
826 | 826 | { |
827 | - $urls = smart_getCurrentUrls(); |
|
827 | + $urls = smart_getCurrentUrls(); |
|
828 | 828 | |
829 | - return $urls['full']; |
|
829 | + return $urls['full']; |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -889,39 +889,39 @@ discard block |
||
889 | 889 | */ |
890 | 890 | function smart_modFooter() |
891 | 891 | { |
892 | - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
893 | - |
|
894 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
895 | - $tpl = new XoopsTpl(); |
|
896 | - |
|
897 | - $hModule = xoops_getHandler('module'); |
|
898 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
899 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
900 | - $modfooter = "<a href='" . |
|
901 | - $versioninfo->getInfo('support_site_url') . |
|
902 | - "' target='_blank'><img src='" . |
|
903 | - XOOPS_URL . |
|
904 | - '/modules/' . |
|
905 | - $xoopsModule->getVar('dirname') . |
|
906 | - "/assets/images/cssbutton.gif' title='" . |
|
907 | - $modfootertxt . |
|
908 | - "' alt='" . |
|
909 | - $modfootertxt . |
|
910 | - "'/></a>"; |
|
911 | - $tpl->assign('modfooter', $modfooter); |
|
912 | - |
|
913 | - if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
914 | - define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
915 | - } |
|
916 | - $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
917 | - $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
918 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html'); |
|
892 | + global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
893 | + |
|
894 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
895 | + $tpl = new XoopsTpl(); |
|
896 | + |
|
897 | + $hModule = xoops_getHandler('module'); |
|
898 | + $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
899 | + $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
900 | + $modfooter = "<a href='" . |
|
901 | + $versioninfo->getInfo('support_site_url') . |
|
902 | + "' target='_blank'><img src='" . |
|
903 | + XOOPS_URL . |
|
904 | + '/modules/' . |
|
905 | + $xoopsModule->getVar('dirname') . |
|
906 | + "/assets/images/cssbutton.gif' title='" . |
|
907 | + $modfootertxt . |
|
908 | + "' alt='" . |
|
909 | + $modfootertxt . |
|
910 | + "'/></a>"; |
|
911 | + $tpl->assign('modfooter', $modfooter); |
|
912 | + |
|
913 | + if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
914 | + define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
915 | + } |
|
916 | + $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
917 | + $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
918 | + $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html'); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | function smart_xoops_cp_footer() |
922 | 922 | { |
923 | - smart_modFooter(); |
|
924 | - xoops_cp_footer(); |
|
923 | + smart_modFooter(); |
|
924 | + xoops_cp_footer(); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -930,11 +930,11 @@ discard block |
||
930 | 930 | */ |
931 | 931 | function smart_sanitizeForCommonTags($text) |
932 | 932 | { |
933 | - global $xoopsConfig; |
|
934 | - $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
935 | - $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
933 | + global $xoopsConfig; |
|
934 | + $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
935 | + $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
936 | 936 | |
937 | - return $text; |
|
937 | + return $text; |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | /** |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | */ |
943 | 943 | function smart_addScript($src) |
944 | 944 | { |
945 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
945 | + echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | /** |
@@ -950,17 +950,17 @@ discard block |
||
950 | 950 | */ |
951 | 951 | function smart_addStyle($src) |
952 | 952 | { |
953 | - if ($src === 'smartobject') { |
|
954 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
955 | - } |
|
956 | - echo smart_get_css_link($src); |
|
953 | + if ($src === 'smartobject') { |
|
954 | + $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
955 | + } |
|
956 | + echo smart_get_css_link($src); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | function smart_addAdminAjaxSupport() |
960 | 960 | { |
961 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
962 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
963 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
961 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
962 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
963 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -969,11 +969,11 @@ discard block |
||
969 | 969 | */ |
970 | 970 | function smart_sanitizeForSmartpopupLink($text) |
971 | 971 | { |
972 | - $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
973 | - $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
974 | - $ret = preg_replace($patterns, $replacements, $text); |
|
972 | + $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
973 | + $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
974 | + $ret = preg_replace($patterns, $replacements, $text); |
|
975 | 975 | |
976 | - return $ret; |
|
976 | + return $ret; |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | /** |
@@ -988,25 +988,25 @@ discard block |
||
988 | 988 | */ |
989 | 989 | function smart_getImageSize($url, & $width, & $height) |
990 | 990 | { |
991 | - if (empty($width) || empty($height)) { |
|
992 | - if (!$dimension = @ getimagesize($url)) { |
|
993 | - return false; |
|
994 | - } |
|
995 | - if (!empty($width)) { |
|
996 | - $height = $dimension[1] * $width / $dimension[0]; |
|
997 | - } elseif (!empty($height)) { |
|
998 | - $width = $dimension[0] * $height / $dimension[1]; |
|
999 | - } else { |
|
1000 | - list($width, $height) = array( |
|
1001 | - $dimension[0], |
|
1002 | - $dimension[1] |
|
1003 | - ); |
|
1004 | - } |
|
1005 | - |
|
1006 | - return true; |
|
1007 | - } else { |
|
1008 | - return true; |
|
1009 | - } |
|
991 | + if (empty($width) || empty($height)) { |
|
992 | + if (!$dimension = @ getimagesize($url)) { |
|
993 | + return false; |
|
994 | + } |
|
995 | + if (!empty($width)) { |
|
996 | + $height = $dimension[1] * $width / $dimension[0]; |
|
997 | + } elseif (!empty($height)) { |
|
998 | + $width = $dimension[0] * $height / $dimension[1]; |
|
999 | + } else { |
|
1000 | + list($width, $height) = array( |
|
1001 | + $dimension[0], |
|
1002 | + $dimension[1] |
|
1003 | + ); |
|
1004 | + } |
|
1005 | + |
|
1006 | + return true; |
|
1007 | + } else { |
|
1008 | + return true; |
|
1009 | + } |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | /** |
@@ -1019,8 +1019,8 @@ discard block |
||
1019 | 1019 | */ |
1020 | 1020 | function smart_htmlnumericentities($str) |
1021 | 1021 | { |
1022 | - // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
1023 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str); |
|
1022 | + // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
1023 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1030,24 +1030,24 @@ discard block |
||
1030 | 1030 | */ |
1031 | 1031 | function smart_getcorehandler($name, $optional = false) |
1032 | 1032 | { |
1033 | - static $handlers; |
|
1034 | - $name = strtolower(trim($name)); |
|
1035 | - if (!isset($handlers[$name])) { |
|
1036 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
1037 | - require_once $hnd_file; |
|
1038 | - } |
|
1039 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
1040 | - if (class_exists($class)) { |
|
1041 | - $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
1042 | - } |
|
1043 | - } |
|
1044 | - if (!isset($handlers[$name]) && !$optional) { |
|
1045 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
1046 | - } |
|
1047 | - if (isset($handlers[$name])) { |
|
1048 | - return $handlers[$name]; |
|
1049 | - } |
|
1050 | - $inst = false; |
|
1033 | + static $handlers; |
|
1034 | + $name = strtolower(trim($name)); |
|
1035 | + if (!isset($handlers[$name])) { |
|
1036 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
1037 | + require_once $hnd_file; |
|
1038 | + } |
|
1039 | + $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
1040 | + if (class_exists($class)) { |
|
1041 | + $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
1042 | + } |
|
1043 | + } |
|
1044 | + if (!isset($handlers[$name]) && !$optional) { |
|
1045 | + trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
1046 | + } |
|
1047 | + if (isset($handlers[$name])) { |
|
1048 | + return $handlers[$name]; |
|
1049 | + } |
|
1050 | + $inst = false; |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | /** |
@@ -1056,15 +1056,15 @@ discard block |
||
1056 | 1056 | */ |
1057 | 1057 | function smart_sanitizeAdsenses_callback($matches) |
1058 | 1058 | { |
1059 | - global $smartobjectAdsenseHandler; |
|
1060 | - if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
1061 | - $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
1062 | - $ret = $adsenseObj->render(); |
|
1063 | - |
|
1064 | - return $ret; |
|
1065 | - } else { |
|
1066 | - return ''; |
|
1067 | - } |
|
1059 | + global $smartobjectAdsenseHandler; |
|
1060 | + if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
1061 | + $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
1062 | + $ret = $adsenseObj->render(); |
|
1063 | + |
|
1064 | + return $ret; |
|
1065 | + } else { |
|
1066 | + return ''; |
|
1067 | + } |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1073,13 +1073,13 @@ discard block |
||
1073 | 1073 | */ |
1074 | 1074 | function smart_sanitizeAdsenses($text) |
1075 | 1075 | { |
1076 | - $patterns = array(); |
|
1077 | - $replacements = array(); |
|
1076 | + $patterns = array(); |
|
1077 | + $replacements = array(); |
|
1078 | 1078 | |
1079 | - $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
1080 | - $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
1079 | + $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
1080 | + $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
1081 | 1081 | |
1082 | - return $text; |
|
1082 | + return $text; |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1088,15 +1088,15 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | function smart_sanitizeCustomtags_callback($matches) |
1090 | 1090 | { |
1091 | - global $smartobjectCustomtagHandler; |
|
1092 | - if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
1093 | - $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
1094 | - $ret = $customObj->renderWithPhp(); |
|
1095 | - |
|
1096 | - return $ret; |
|
1097 | - } else { |
|
1098 | - return ''; |
|
1099 | - } |
|
1091 | + global $smartobjectCustomtagHandler; |
|
1092 | + if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
1093 | + $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
1094 | + $ret = $customObj->renderWithPhp(); |
|
1095 | + |
|
1096 | + return $ret; |
|
1097 | + } else { |
|
1098 | + return ''; |
|
1099 | + } |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1105,13 +1105,13 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | function smart_sanitizeCustomtags($text) |
1107 | 1107 | { |
1108 | - $patterns = array(); |
|
1109 | - $replacements = array(); |
|
1108 | + $patterns = array(); |
|
1109 | + $replacements = array(); |
|
1110 | 1110 | |
1111 | - $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
1112 | - $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
1111 | + $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
1112 | + $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
1113 | 1113 | |
1114 | - return $text; |
|
1114 | + return $text; |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
@@ -1120,20 +1120,20 @@ discard block |
||
1120 | 1120 | */ |
1121 | 1121 | function smart_loadLanguageFile($module, $file) |
1122 | 1122 | { |
1123 | - global $xoopsConfig; |
|
1124 | - |
|
1125 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
1126 | - if (!file_exists($filename)) { |
|
1127 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
1128 | - } |
|
1129 | - if (file_exists($filename)) { |
|
1130 | - include_once($filename); |
|
1131 | - } |
|
1123 | + global $xoopsConfig; |
|
1124 | + |
|
1125 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
1126 | + if (!file_exists($filename)) { |
|
1127 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
1128 | + } |
|
1129 | + if (file_exists($filename)) { |
|
1130 | + include_once($filename); |
|
1131 | + } |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | function smart_loadCommonLanguageFile() |
1135 | 1135 | { |
1136 | - smart_loadLanguageFile('smartobject', 'common'); |
|
1136 | + smart_loadLanguageFile('smartobject', 'common'); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | /** |
@@ -1143,35 +1143,35 @@ discard block |
||
1143 | 1143 | */ |
1144 | 1144 | function smart_purifyText($text, $keyword = false) |
1145 | 1145 | { |
1146 | - global $myts; |
|
1147 | - $text = str_replace(' ', ' ', $text); |
|
1148 | - $text = str_replace('<br>', ' ', $text); |
|
1149 | - $text = str_replace('<br>', ' ', $text); |
|
1150 | - $text = str_replace('<br', ' ', $text); |
|
1151 | - $text = strip_tags($text); |
|
1152 | - $text = html_entity_decode($text); |
|
1153 | - $text = $myts->undoHtmlSpecialChars($text); |
|
1154 | - $text = str_replace(')', ' ', $text); |
|
1155 | - $text = str_replace('(', ' ', $text); |
|
1156 | - $text = str_replace(':', ' ', $text); |
|
1157 | - $text = str_replace('&euro', ' euro ', $text); |
|
1158 | - $text = str_replace('&hellip', '...', $text); |
|
1159 | - $text = str_replace('&rsquo', ' ', $text); |
|
1160 | - $text = str_replace('!', ' ', $text); |
|
1161 | - $text = str_replace('?', ' ', $text); |
|
1162 | - $text = str_replace('"', ' ', $text); |
|
1163 | - $text = str_replace('-', ' ', $text); |
|
1164 | - $text = str_replace('\n', ' ', $text); |
|
1165 | - $text = str_replace('―', ' ', $text); |
|
1166 | - |
|
1167 | - if ($keyword) { |
|
1168 | - $text = str_replace('.', ' ', $text); |
|
1169 | - $text = str_replace(',', ' ', $text); |
|
1170 | - $text = str_replace('\'', ' ', $text); |
|
1171 | - } |
|
1172 | - $text = str_replace(';', ' ', $text); |
|
1173 | - |
|
1174 | - return $text; |
|
1146 | + global $myts; |
|
1147 | + $text = str_replace(' ', ' ', $text); |
|
1148 | + $text = str_replace('<br>', ' ', $text); |
|
1149 | + $text = str_replace('<br>', ' ', $text); |
|
1150 | + $text = str_replace('<br', ' ', $text); |
|
1151 | + $text = strip_tags($text); |
|
1152 | + $text = html_entity_decode($text); |
|
1153 | + $text = $myts->undoHtmlSpecialChars($text); |
|
1154 | + $text = str_replace(')', ' ', $text); |
|
1155 | + $text = str_replace('(', ' ', $text); |
|
1156 | + $text = str_replace(':', ' ', $text); |
|
1157 | + $text = str_replace('&euro', ' euro ', $text); |
|
1158 | + $text = str_replace('&hellip', '...', $text); |
|
1159 | + $text = str_replace('&rsquo', ' ', $text); |
|
1160 | + $text = str_replace('!', ' ', $text); |
|
1161 | + $text = str_replace('?', ' ', $text); |
|
1162 | + $text = str_replace('"', ' ', $text); |
|
1163 | + $text = str_replace('-', ' ', $text); |
|
1164 | + $text = str_replace('\n', ' ', $text); |
|
1165 | + $text = str_replace('―', ' ', $text); |
|
1166 | + |
|
1167 | + if ($keyword) { |
|
1168 | + $text = str_replace('.', ' ', $text); |
|
1169 | + $text = str_replace(',', ' ', $text); |
|
1170 | + $text = str_replace('\'', ' ', $text); |
|
1171 | + } |
|
1172 | + $text = str_replace(';', ' ', $text); |
|
1173 | + |
|
1174 | + return $text; |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | /** |
@@ -1180,49 +1180,49 @@ discard block |
||
1180 | 1180 | */ |
1181 | 1181 | function smart_html2text($document) |
1182 | 1182 | { |
1183 | - // PHP Manual:: function preg_replace |
|
1184 | - // $document should contain an HTML document. |
|
1185 | - // This will remove HTML tags, javascript sections |
|
1186 | - // and white space. It will also convert some |
|
1187 | - // common HTML entities to their text equivalent. |
|
1188 | - // Credits: newbb2 |
|
1189 | - $search = array( |
|
1190 | - "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
1191 | - "'<img.*?/>'si", // Strip out img tags |
|
1192 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
1193 | - "'([\r\n])[\s]+'", // Strip out white space |
|
1194 | - "'&(quot|#34);'i", // Replace HTML entities |
|
1195 | - "'&(amp|#38);'i", |
|
1196 | - "'&(lt|#60);'i", |
|
1197 | - "'&(gt|#62);'i", |
|
1198 | - "'&(nbsp|#160);'i", |
|
1199 | - "'&(iexcl|#161);'i", |
|
1200 | - "'&(cent|#162);'i", |
|
1201 | - "'&(pound|#163);'i", |
|
1202 | - "'&(copy|#169);'i", |
|
1203 | - "'&#(\d+);'e" |
|
1204 | - ); // evaluate as php |
|
1205 | - |
|
1206 | - $replace = array( |
|
1207 | - '', |
|
1208 | - '', |
|
1209 | - '', |
|
1210 | - "\\1", |
|
1211 | - "\"", |
|
1212 | - '&', |
|
1213 | - '<', |
|
1214 | - '>', |
|
1215 | - ' ', |
|
1216 | - chr(161), |
|
1217 | - chr(162), |
|
1218 | - chr(163), |
|
1219 | - chr(169), |
|
1220 | - "chr(\\1)" |
|
1221 | - ); |
|
1222 | - |
|
1223 | - $text = preg_replace($search, $replace, $document); |
|
1224 | - |
|
1225 | - return $text; |
|
1183 | + // PHP Manual:: function preg_replace |
|
1184 | + // $document should contain an HTML document. |
|
1185 | + // This will remove HTML tags, javascript sections |
|
1186 | + // and white space. It will also convert some |
|
1187 | + // common HTML entities to their text equivalent. |
|
1188 | + // Credits: newbb2 |
|
1189 | + $search = array( |
|
1190 | + "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
1191 | + "'<img.*?/>'si", // Strip out img tags |
|
1192 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
1193 | + "'([\r\n])[\s]+'", // Strip out white space |
|
1194 | + "'&(quot|#34);'i", // Replace HTML entities |
|
1195 | + "'&(amp|#38);'i", |
|
1196 | + "'&(lt|#60);'i", |
|
1197 | + "'&(gt|#62);'i", |
|
1198 | + "'&(nbsp|#160);'i", |
|
1199 | + "'&(iexcl|#161);'i", |
|
1200 | + "'&(cent|#162);'i", |
|
1201 | + "'&(pound|#163);'i", |
|
1202 | + "'&(copy|#169);'i", |
|
1203 | + "'&#(\d+);'e" |
|
1204 | + ); // evaluate as php |
|
1205 | + |
|
1206 | + $replace = array( |
|
1207 | + '', |
|
1208 | + '', |
|
1209 | + '', |
|
1210 | + "\\1", |
|
1211 | + "\"", |
|
1212 | + '&', |
|
1213 | + '<', |
|
1214 | + '>', |
|
1215 | + ' ', |
|
1216 | + chr(161), |
|
1217 | + chr(162), |
|
1218 | + chr(163), |
|
1219 | + chr(169), |
|
1220 | + "chr(\\1)" |
|
1221 | + ); |
|
1222 | + |
|
1223 | + $text = preg_replace($search, $replace, $document); |
|
1224 | + |
|
1225 | + return $text; |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | /** |
@@ -1236,32 +1236,32 @@ discard block |
||
1236 | 1236 | */ |
1237 | 1237 | function smart_getfloat($str, $set = false) |
1238 | 1238 | { |
1239 | - if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
1240 | - // Found number in $str, so set $str that number |
|
1241 | - $str = $match[0]; |
|
1242 | - if (false !== strpos($str, ',')) { |
|
1243 | - // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
1244 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
1245 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
1246 | - |
|
1247 | - return (float)$str; |
|
1248 | - } else { |
|
1249 | - // No comma exists, so we have to decide, how a single dot shall be treated |
|
1250 | - if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) { |
|
1251 | - // Treat single dot as decimal separator |
|
1252 | - return (float)$str; |
|
1253 | - } else { |
|
1254 | - //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
1255 | - // Else, treat all dots as thousand seps |
|
1256 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
1257 | - |
|
1258 | - return (float)$str; |
|
1259 | - } |
|
1260 | - } |
|
1261 | - } else { |
|
1262 | - // No number found, return zero |
|
1263 | - return 0; |
|
1264 | - } |
|
1239 | + if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
1240 | + // Found number in $str, so set $str that number |
|
1241 | + $str = $match[0]; |
|
1242 | + if (false !== strpos($str, ',')) { |
|
1243 | + // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
1244 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
1245 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
1246 | + |
|
1247 | + return (float)$str; |
|
1248 | + } else { |
|
1249 | + // No comma exists, so we have to decide, how a single dot shall be treated |
|
1250 | + if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) { |
|
1251 | + // Treat single dot as decimal separator |
|
1252 | + return (float)$str; |
|
1253 | + } else { |
|
1254 | + //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
1255 | + // Else, treat all dots as thousand seps |
|
1256 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
1257 | + |
|
1258 | + return (float)$str; |
|
1259 | + } |
|
1260 | + } |
|
1261 | + } else { |
|
1262 | + // No number found, return zero |
|
1263 | + return 0; |
|
1264 | + } |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1271,26 +1271,26 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | function smart_currency($var, $currencyObj = false) |
1273 | 1273 | { |
1274 | - $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
1275 | - $ret = round($ret, 2); |
|
1276 | - // make sur we have at least .00 in the $var |
|
1277 | - $decimal_section_original = strstr($ret, '.'); |
|
1278 | - $decimal_section = $decimal_section_original; |
|
1279 | - if ($decimal_section) { |
|
1280 | - if (strlen($decimal_section) == 1) { |
|
1281 | - $decimal_section = '.00'; |
|
1282 | - } elseif (strlen($decimal_section) == 2) { |
|
1283 | - $decimal_section .= '0'; |
|
1284 | - } |
|
1285 | - $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
1286 | - } else { |
|
1287 | - $ret .= '.00'; |
|
1288 | - } |
|
1289 | - if ($currencyObj) { |
|
1290 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
1291 | - } |
|
1292 | - |
|
1293 | - return $ret; |
|
1274 | + $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
1275 | + $ret = round($ret, 2); |
|
1276 | + // make sur we have at least .00 in the $var |
|
1277 | + $decimal_section_original = strstr($ret, '.'); |
|
1278 | + $decimal_section = $decimal_section_original; |
|
1279 | + if ($decimal_section) { |
|
1280 | + if (strlen($decimal_section) == 1) { |
|
1281 | + $decimal_section = '.00'; |
|
1282 | + } elseif (strlen($decimal_section) == 2) { |
|
1283 | + $decimal_section .= '0'; |
|
1284 | + } |
|
1285 | + $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
1286 | + } else { |
|
1287 | + $ret .= '.00'; |
|
1288 | + } |
|
1289 | + if ($currencyObj) { |
|
1290 | + $ret = $ret . ' ' . $currencyObj->getCode(); |
|
1291 | + } |
|
1292 | + |
|
1293 | + return $ret; |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | /** |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | */ |
1300 | 1300 | function smart_float($var) |
1301 | 1301 | { |
1302 | - return smart_currency($var); |
|
1302 | + return smart_currency($var); |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | /** |
@@ -1308,16 +1308,16 @@ discard block |
||
1308 | 1308 | */ |
1309 | 1309 | function smart_getModuleAdminLink($moduleName = false) |
1310 | 1310 | { |
1311 | - global $xoopsModule; |
|
1312 | - if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
1313 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
1314 | - } |
|
1315 | - $ret = ''; |
|
1316 | - if ($moduleName) { |
|
1317 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
1318 | - } |
|
1319 | - |
|
1320 | - return $ret; |
|
1311 | + global $xoopsModule; |
|
1312 | + if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
1313 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
1314 | + } |
|
1315 | + $ret = ''; |
|
1316 | + if ($moduleName) { |
|
1317 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
1318 | + } |
|
1319 | + |
|
1320 | + return $ret; |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | /** |
@@ -1325,19 +1325,19 @@ discard block |
||
1325 | 1325 | */ |
1326 | 1326 | function smart_getEditors() |
1327 | 1327 | { |
1328 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
1329 | - if (!file_exists($filename)) { |
|
1330 | - return false; |
|
1331 | - } |
|
1332 | - include_once $filename; |
|
1333 | - $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
1334 | - $aList = $xoopseditorHandler->getList(); |
|
1335 | - $ret = array(); |
|
1336 | - foreach ($aList as $k => $v) { |
|
1337 | - $ret[$v] = $k; |
|
1338 | - } |
|
1339 | - |
|
1340 | - return $ret; |
|
1328 | + $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
1329 | + if (!file_exists($filename)) { |
|
1330 | + return false; |
|
1331 | + } |
|
1332 | + include_once $filename; |
|
1333 | + $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
1334 | + $aList = $xoopseditorHandler->getList(); |
|
1335 | + $ret = array(); |
|
1336 | + foreach ($aList as $k => $v) { |
|
1337 | + $ret[$v] = $k; |
|
1338 | + } |
|
1339 | + |
|
1340 | + return $ret; |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | /** |
@@ -1347,11 +1347,11 @@ discard block |
||
1347 | 1347 | */ |
1348 | 1348 | function smart_getTablesArray($moduleName, $items) |
1349 | 1349 | { |
1350 | - $ret = array(); |
|
1351 | - foreach ($items as $item) { |
|
1352 | - $ret[] = $moduleName . '_' . $item; |
|
1353 | - } |
|
1354 | - $ret[] = $moduleName . '_meta'; |
|
1350 | + $ret = array(); |
|
1351 | + foreach ($items as $item) { |
|
1352 | + $ret[] = $moduleName . '_' . $item; |
|
1353 | + } |
|
1354 | + $ret[] = $moduleName . '_meta'; |
|
1355 | 1355 | |
1356 | - return $ret; |
|
1356 | + return $ret; |
|
1357 | 1357 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function smart_get_css_link($cssfile) |
13 | 13 | { |
14 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '" />'; |
|
14 | + $ret = '<link rel="stylesheet" type="text/css" href="'.$cssfile.'" />'; |
|
15 | 15 | |
16 | 16 | return $ret; |
17 | 17 | } |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | $seoMode = smart_getModuleModeSEO($moduleName); |
101 | 101 | if ($seoMode === 'rewrite') { |
102 | 102 | $seoModuleName = smart_getModuleNameForSEO($moduleName); |
103 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
103 | + $ret = XOOPS_URL.'/'.$seoModuleName.'/'; |
|
104 | 104 | } elseif ($seoMode === 'pathinfo') { |
105 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
105 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/seo.php/'.$seoModuleName.'/'; |
|
106 | 106 | } else { |
107 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
107 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/'; |
|
108 | 108 | } |
109 | 109 | |
110 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
110 | + return '<a href="'.$ret.'">'.$smartModule->getVar('name').'</a>'; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * include SmartObject admin language file |
172 | 172 | */ |
173 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
173 | + $fileName = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php'; |
|
174 | 174 | if (file_exists($fileName)) { |
175 | 175 | include_once $fileName; |
176 | 176 | } else { |
177 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
177 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php'; |
|
178 | 178 | } |
179 | 179 | ?> |
180 | 180 | <script type='text/javascript'> |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | /** |
193 | 193 | * Include the admin language constants for the SmartObject Framework |
194 | 194 | */ |
195 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
195 | + $admin_file = SMARTOBJECT_ROOT_PATH.'language/'.$xoopsConfig['language'].'/admin.php'; |
|
196 | 196 | if (!file_exists($admin_file)) { |
197 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
197 | + $admin_file = SMARTOBJECT_ROOT_PATH.'language/english/admin.php'; |
|
198 | 198 | } |
199 | 199 | include_once($admin_file); |
200 | 200 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | //Verifies that a MySQL table exists |
215 | 215 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
216 | 216 | $realname = $xoopsDB->prefix($table); |
217 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
217 | + $sql = 'SHOW TABLES FROM '.XOOPS_DB_NAME; |
|
218 | 218 | $ret = $xoopsDB->queryF($sql); |
219 | 219 | while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
220 | 220 | if ($m_table == $realname) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $moduleName = smart_getCurrentModuleName(); |
244 | 244 | } |
245 | 245 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
246 | - $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
246 | + $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key)); |
|
247 | 247 | $ret = $xoopsDB->query($sql); |
248 | 248 | if (!$ret) { |
249 | 249 | $value = false; |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
287 | 287 | $ret = smart_GetMeta($key, $moduleName); |
288 | 288 | if ($ret === '0' || $ret > 0) { |
289 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
289 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
290 | 290 | } else { |
291 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
291 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
292 | 292 | } |
293 | 293 | $ret = $xoopsDB->queryF($sql); |
294 | 294 | if (!$ret) { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | { |
469 | 469 | static $smartModules; |
470 | 470 | if (isset($smartModules[$moduleName])) { |
471 | - $ret =& $smartModules[$moduleName]; |
|
471 | + $ret = & $smartModules[$moduleName]; |
|
472 | 472 | |
473 | 473 | return $ret; |
474 | 474 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | { |
505 | 505 | static $smartConfigs; |
506 | 506 | if (isset($smartConfigs[$moduleName])) { |
507 | - $ret =& $smartConfigs[$moduleName]; |
|
507 | + $ret = & $smartConfigs[$moduleName]; |
|
508 | 508 | |
509 | 509 | return $ret; |
510 | 510 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | return $ret; |
533 | 533 | } |
534 | 534 | $hModConfig = xoops_getHandler('config'); |
535 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
535 | + $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | return $smartConfigs[$moduleName]; |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | { |
559 | 559 | $ret = ''; |
560 | 560 | foreach ($errors as $key => $value) { |
561 | - $ret .= '<br> - ' . $value; |
|
561 | + $ret .= '<br> - '.$value; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | return $ret; |
@@ -578,17 +578,17 @@ discard block |
||
578 | 578 | if (!is_numeric($userid)) { |
579 | 579 | return $userid; |
580 | 580 | } |
581 | - $userid = (int)$userid; |
|
581 | + $userid = (int) $userid; |
|
582 | 582 | if ($userid > 0) { |
583 | 583 | if ($users == array()) { |
584 | 584 | //fetching users |
585 | 585 | $memberHandler = xoops_getHandler('member'); |
586 | - $user =& $memberHandler->getUser($userid); |
|
586 | + $user = & $memberHandler->getUser($userid); |
|
587 | 587 | } else { |
588 | 588 | if (!isset($users[$userid])) { |
589 | 589 | return $GLOBALS['xoopsConfig']['anonymous']; |
590 | 590 | } |
591 | - $user =& $users[$userid]; |
|
591 | + $user = & $users[$userid]; |
|
592 | 592 | } |
593 | 593 | if (is_object($user)) { |
594 | 594 | $ts = MyTextSanitizer:: getInstance(); |
@@ -599,32 +599,32 @@ discard block |
||
599 | 599 | $fullname = $user->getVar('name'); |
600 | 600 | } |
601 | 601 | if (!empty($fullname)) { |
602 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
602 | + $linkeduser = "$fullname [<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".$ts->htmlSpecialChars($username).'</a>]'; |
|
603 | 603 | } else { |
604 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
604 | + $linkeduser = "<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".ucwords($ts->htmlSpecialChars($username)).'</a>'; |
|
605 | 605 | } |
606 | 606 | // add contact info: email + PM |
607 | 607 | if ($withContact) { |
608 | - $linkeduser .= ' <a href="mailto:' . |
|
609 | - $user->getVar('email') . |
|
610 | - '"><img style="vertical-align: middle;" src="' . |
|
611 | - XOOPS_URL . |
|
612 | - '/images/icons/email.gif' . |
|
613 | - '" alt="' . |
|
614 | - _CO_SOBJECT_SEND_EMAIL . |
|
615 | - '" title="' . |
|
616 | - _CO_SOBJECT_SEND_EMAIL . |
|
608 | + $linkeduser .= ' <a href="mailto:'. |
|
609 | + $user->getVar('email'). |
|
610 | + '"><img style="vertical-align: middle;" src="'. |
|
611 | + XOOPS_URL. |
|
612 | + '/images/icons/email.gif'. |
|
613 | + '" alt="'. |
|
614 | + _CO_SOBJECT_SEND_EMAIL. |
|
615 | + '" title="'. |
|
616 | + _CO_SOBJECT_SEND_EMAIL. |
|
617 | 617 | '"/></a>'; |
618 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
619 | - $linkeduser .= ' <a href="' . |
|
620 | - $js . |
|
621 | - '"><img style="vertical-align: middle;" src="' . |
|
622 | - XOOPS_URL . |
|
623 | - '/images/icons/pm.gif' . |
|
624 | - '" alt="' . |
|
625 | - _CO_SOBJECT_SEND_PM . |
|
626 | - '" title="' . |
|
627 | - _CO_SOBJECT_SEND_PM . |
|
618 | + $js = "javascript:openWithSelfMain('".XOOPS_URL.'/pmlite.php?send2=1&to_userid='.$userid."', 'pmlite',450,370);"; |
|
619 | + $linkeduser .= ' <a href="'. |
|
620 | + $js. |
|
621 | + '"><img style="vertical-align: middle;" src="'. |
|
622 | + XOOPS_URL. |
|
623 | + '/images/icons/pm.gif'. |
|
624 | + '" alt="'. |
|
625 | + _CO_SOBJECT_SEND_PM. |
|
626 | + '" title="'. |
|
627 | + _CO_SOBJECT_SEND_PM. |
|
628 | 628 | '"/></a>'; |
629 | 629 | } |
630 | 630 | |
@@ -644,20 +644,20 @@ discard block |
||
644 | 644 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
645 | 645 | { |
646 | 646 | global $xoopsModule, $xoopsConfig; |
647 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
648 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
649 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
647 | + include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
648 | + if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) { |
|
649 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php'; |
|
650 | 650 | } else { |
651 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
651 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/modinfo.php'; |
|
652 | 652 | } |
653 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
654 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
653 | + if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php')) { |
|
654 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php'; |
|
655 | 655 | } else { |
656 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
656 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php'; |
|
657 | 657 | } |
658 | 658 | $headermenu = array(); |
659 | 659 | $adminmenu = array(); |
660 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
660 | + include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/admin/menu.php'; |
|
661 | 661 | $tpl = new XoopsTpl(); |
662 | 662 | $tpl->assign(array( |
663 | 663 | 'headermenu' => $headermenu, |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
681 | 681 | { |
682 | 682 | global $xoopsModule; |
683 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
684 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
685 | - echo "<div id='" . $id . "'>"; |
|
683 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('".$id."'); toggleIcon('".$id."_icon')\";>"; |
|
684 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt='' /></a> ".$title.'</h3>'; |
|
685 | + echo "<div id='".$id."'>"; |
|
686 | 686 | if ($dsc !== '') { |
687 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
687 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>'; |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | |
@@ -698,11 +698,11 @@ discard block |
||
698 | 698 | global $xoopsModule; |
699 | 699 | $onClick = "ajaxtogglecollapse('$id')"; |
700 | 700 | //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
701 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
702 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a> " . $title . '</h3>'; |
|
703 | - echo "<div id='" . $id . "'>"; |
|
701 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="'.$onClick.'">'; |
|
702 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt='' /></a> ".$title.'</h3>'; |
|
703 | + echo "<div id='".$id."'>"; |
|
704 | 704 | if ($dsc !== '') { |
705 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
705 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>'; |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | { |
733 | 733 | $urls = smart_getCurrentUrls(); |
734 | 734 | $path = $urls['phpself']; |
735 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
735 | + $cookie_name = $path.'_smart_collaps_'.$name; |
|
736 | 736 | $cookie_name = str_replace('.', '_', $cookie_name); |
737 | 737 | $cookie = smart_getCookieVar($cookie_name, ''); |
738 | 738 | if ($cookie === 'none') { |
739 | 739 | echo ' |
740 | 740 | <script type="text/javascript"><!-- |
741 | - togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
|
741 | + togglecollapse("' . $name.'"); toggleIcon("'.$name.'_icon"); |
|
742 | 742 | //--> |
743 | 743 | </script> |
744 | 744 | '; |
@@ -804,17 +804,17 @@ discard block |
||
804 | 804 | $httphost = $_SERVER['HTTP_HOST']; |
805 | 805 | $querystring = $_SERVER['QUERY_STRING']; |
806 | 806 | if ($querystring !== '') { |
807 | - $querystring = '?' . $querystring; |
|
807 | + $querystring = '?'.$querystring; |
|
808 | 808 | } |
809 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
809 | + $currenturl = $http.$httphost.$phpself.$querystring; |
|
810 | 810 | $urls = array(); |
811 | 811 | $urls['http'] = $http; |
812 | 812 | $urls['httphost'] = $httphost; |
813 | 813 | $urls['phpself'] = $phpself; |
814 | 814 | $urls['querystring'] = $querystring; |
815 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
815 | + $urls['full_phpself'] = $http.$httphost.$phpself; |
|
816 | 816 | $urls['full'] = $currenturl; |
817 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
817 | + $urls['isHomePage'] = (XOOPS_URL.'/index.php') == ($http.$httphost.$phpself); |
|
818 | 818 | |
819 | 819 | return $urls; |
820 | 820 | } |
@@ -891,22 +891,22 @@ discard block |
||
891 | 891 | { |
892 | 892 | global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
893 | 893 | |
894 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
894 | + include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
895 | 895 | $tpl = new XoopsTpl(); |
896 | 896 | |
897 | 897 | $hModule = xoops_getHandler('module'); |
898 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
899 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
900 | - $modfooter = "<a href='" . |
|
901 | - $versioninfo->getInfo('support_site_url') . |
|
902 | - "' target='_blank'><img src='" . |
|
903 | - XOOPS_URL . |
|
904 | - '/modules/' . |
|
905 | - $xoopsModule->getVar('dirname') . |
|
906 | - "/assets/images/cssbutton.gif' title='" . |
|
907 | - $modfootertxt . |
|
908 | - "' alt='" . |
|
909 | - $modfootertxt . |
|
898 | + $versioninfo = & $hModule->get($xoopsModule->getVar('mid')); |
|
899 | + $modfootertxt = 'Module '.$versioninfo->getInfo('name').' - Version '.$versioninfo->getInfo('version').''; |
|
900 | + $modfooter = "<a href='". |
|
901 | + $versioninfo->getInfo('support_site_url'). |
|
902 | + "' target='_blank'><img src='". |
|
903 | + XOOPS_URL. |
|
904 | + '/modules/'. |
|
905 | + $xoopsModule->getVar('dirname'). |
|
906 | + "/assets/images/cssbutton.gif' title='". |
|
907 | + $modfootertxt. |
|
908 | + "' alt='". |
|
909 | + $modfootertxt. |
|
910 | 910 | "'/></a>"; |
911 | 911 | $tpl->assign('modfooter', $modfooter); |
912 | 912 | |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } |
916 | 916 | $smartobjectConfig = smart_getModuleConfig('smartobject'); |
917 | 917 | $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
918 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html'); |
|
918 | + $tpl->display(SMARTOBJECT_ROOT_PATH.'templates/smartobject_admin_footer.html'); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | function smart_xoops_cp_footer() |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | */ |
943 | 943 | function smart_addScript($src) |
944 | 944 | { |
945 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
945 | + echo '<script src="'.$src.'" type="text/javascript"></script>'; |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | /** |
@@ -951,16 +951,16 @@ discard block |
||
951 | 951 | function smart_addStyle($src) |
952 | 952 | { |
953 | 953 | if ($src === 'smartobject') { |
954 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
954 | + $src = SMARTOBJECT_URL.'assets/css/module.css'; |
|
955 | 955 | } |
956 | 956 | echo smart_get_css_link($src); |
957 | 957 | } |
958 | 958 | |
959 | 959 | function smart_addAdminAjaxSupport() |
960 | 960 | { |
961 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
962 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
963 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
961 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/lib/prototype.js'); |
|
962 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/scriptaculous.js'); |
|
963 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/smart.js'); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | function smart_htmlnumericentities($str) |
1021 | 1021 | { |
1022 | 1022 | // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
1023 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str); |
|
1023 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function($m) { return '&#'.ord($m[0]).chr(59); }, $str); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1033,16 +1033,16 @@ discard block |
||
1033 | 1033 | static $handlers; |
1034 | 1034 | $name = strtolower(trim($name)); |
1035 | 1035 | if (!isset($handlers[$name])) { |
1036 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
1036 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH.'/kernel/'.$name.'.php')) { |
|
1037 | 1037 | require_once $hnd_file; |
1038 | 1038 | } |
1039 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
1039 | + $class = 'Xoops'.ucfirst($name).'Handler'; |
|
1040 | 1040 | if (class_exists($class)) { |
1041 | - $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops'); |
|
1041 | + $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | if (!isset($handlers[$name]) && !$optional) { |
1045 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
1045 | + trigger_error('Class <b>'.$class.'</b> does not exist<br>Handler Name: '.$name, E_USER_ERROR); |
|
1046 | 1046 | } |
1047 | 1047 | if (isset($handlers[$name])) { |
1048 | 1048 | return $handlers[$name]; |
@@ -1122,9 +1122,9 @@ discard block |
||
1122 | 1122 | { |
1123 | 1123 | global $xoopsConfig; |
1124 | 1124 | |
1125 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
1125 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/'.$xoopsConfig['language'].'/'.$file.'.php'; |
|
1126 | 1126 | if (!file_exists($filename)) { |
1127 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
1127 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/english/'.$file.'.php'; |
|
1128 | 1128 | } |
1129 | 1129 | if (file_exists($filename)) { |
1130 | 1130 | include_once($filename); |
@@ -1187,11 +1187,11 @@ discard block |
||
1187 | 1187 | // common HTML entities to their text equivalent. |
1188 | 1188 | // Credits: newbb2 |
1189 | 1189 | $search = array( |
1190 | - "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
1191 | - "'<img.*?/>'si", // Strip out img tags |
|
1192 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
1193 | - "'([\r\n])[\s]+'", // Strip out white space |
|
1194 | - "'&(quot|#34);'i", // Replace HTML entities |
|
1190 | + "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
1191 | + "'<img.*?/>'si", // Strip out img tags |
|
1192 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
1193 | + "'([\r\n])[\s]+'", // Strip out white space |
|
1194 | + "'&(quot|#34);'i", // Replace HTML entities |
|
1195 | 1195 | "'&(amp|#38);'i", |
1196 | 1196 | "'&(lt|#60);'i", |
1197 | 1197 | "'&(gt|#62);'i", |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | "'&(pound|#163);'i", |
1202 | 1202 | "'&(copy|#169);'i", |
1203 | 1203 | "'&#(\d+);'e" |
1204 | - ); // evaluate as php |
|
1204 | + ); // evaluate as php |
|
1205 | 1205 | |
1206 | 1206 | $replace = array( |
1207 | 1207 | '', |
@@ -1241,21 +1241,21 @@ discard block |
||
1241 | 1241 | $str = $match[0]; |
1242 | 1242 | if (false !== strpos($str, ',')) { |
1243 | 1243 | // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
1244 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
1245 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
1244 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
1245 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
1246 | 1246 | |
1247 | - return (float)$str; |
|
1247 | + return (float) $str; |
|
1248 | 1248 | } else { |
1249 | 1249 | // No comma exists, so we have to decide, how a single dot shall be treated |
1250 | 1250 | if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) { |
1251 | 1251 | // Treat single dot as decimal separator |
1252 | - return (float)$str; |
|
1252 | + return (float) $str; |
|
1253 | 1253 | } else { |
1254 | 1254 | //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
1255 | 1255 | // Else, treat all dots as thousand seps |
1256 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
1256 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
1257 | 1257 | |
1258 | - return (float)$str; |
|
1258 | + return (float) $str; |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } else { |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | $ret .= '.00'; |
1288 | 1288 | } |
1289 | 1289 | if ($currencyObj) { |
1290 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
1290 | + $ret = $ret.' '.$currencyObj->getCode(); |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | return $ret; |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | } |
1315 | 1315 | $ret = ''; |
1316 | 1316 | if ($moduleName) { |
1317 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
1317 | + $ret = "<a href='".XOOPS_URL."/modules/$moduleName/admin/index.php'>"._CO_SOBJECT_ADMIN_PAGE.'</a>'; |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | return $ret; |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | */ |
1326 | 1326 | function smart_getEditors() |
1327 | 1327 | { |
1328 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
1328 | + $filename = XOOPS_ROOT_PATH.'/class/xoopseditor/xoopseditor.php'; |
|
1329 | 1329 | if (!file_exists($filename)) { |
1330 | 1330 | return false; |
1331 | 1331 | } |
@@ -1349,9 +1349,9 @@ discard block |
||
1349 | 1349 | { |
1350 | 1350 | $ret = array(); |
1351 | 1351 | foreach ($items as $item) { |
1352 | - $ret[] = $moduleName . '_' . $item; |
|
1352 | + $ret[] = $moduleName.'_'.$item; |
|
1353 | 1353 | } |
1354 | - $ret[] = $moduleName . '_meta'; |
|
1354 | + $ret[] = $moduleName.'_meta'; |
|
1355 | 1355 | |
1356 | 1356 | return $ret; |
1357 | 1357 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * Licence: GNU |
7 | 7 | */ |
8 | 8 | |
9 | -include dirname(dirname(__DIR__)) . '/mainfile.php'; |
|
10 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'; |
|
9 | +include dirname(dirname(__DIR__)).'/mainfile.php'; |
|
10 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php'; |
|
11 | 11 | |
12 | 12 | smart_loadCommonLanguageFile(); |
@@ -46,227 +46,227 @@ |
||
46 | 46 | */ |
47 | 47 | class SmartobjectMemberHandler extends XoopsMemberHandler |
48 | 48 | { |
49 | - /** |
|
50 | - * constructor |
|
51 | - * @param XoopsDatabase $db |
|
52 | - */ |
|
53 | - public function __construct(XoopsDatabase $db) |
|
54 | - { |
|
55 | - parent::__construct($db); |
|
56 | - $this->_uHandler = xoops_getModuleHandler('user', 'smartobject'); |
|
57 | - } |
|
49 | + /** |
|
50 | + * constructor |
|
51 | + * @param XoopsDatabase $db |
|
52 | + */ |
|
53 | + public function __construct(XoopsDatabase $db) |
|
54 | + { |
|
55 | + parent::__construct($db); |
|
56 | + $this->_uHandler = xoops_getModuleHandler('user', 'smartobject'); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param $userObj |
|
61 | - * @param bool $groups |
|
62 | - * @param bool $notifyUser |
|
63 | - * @param bool $password |
|
64 | - * @return bool |
|
65 | - */ |
|
66 | - public function addAndActivateUser($userObj, $groups = false, $notifyUser = true, &$password = false) |
|
67 | - { |
|
68 | - $email = $userObj->getVar('email'); |
|
69 | - if (!$userObj->getVar('email') || $email === '') { |
|
70 | - $userObj->setErrors(_CO_SOBJECT_USER_NEED_EMAIL); |
|
59 | + /** |
|
60 | + * @param $userObj |
|
61 | + * @param bool $groups |
|
62 | + * @param bool $notifyUser |
|
63 | + * @param bool $password |
|
64 | + * @return bool |
|
65 | + */ |
|
66 | + public function addAndActivateUser($userObj, $groups = false, $notifyUser = true, &$password = false) |
|
67 | + { |
|
68 | + $email = $userObj->getVar('email'); |
|
69 | + if (!$userObj->getVar('email') || $email === '') { |
|
70 | + $userObj->setErrors(_CO_SOBJECT_USER_NEED_EMAIL); |
|
71 | 71 | |
72 | - return false; |
|
73 | - } |
|
72 | + return false; |
|
73 | + } |
|
74 | 74 | |
75 | - $password = $userObj->getVar('pass'); |
|
76 | - // randomly generating the password if not already set |
|
77 | - if ('' === $password) { |
|
78 | - $password = substr(md5(uniqid(mt_rand(), 1)), 0, 6); |
|
79 | - } |
|
80 | - $userObj->setVar('pass', md5($password)); |
|
75 | + $password = $userObj->getVar('pass'); |
|
76 | + // randomly generating the password if not already set |
|
77 | + if ('' === $password) { |
|
78 | + $password = substr(md5(uniqid(mt_rand(), 1)), 0, 6); |
|
79 | + } |
|
80 | + $userObj->setVar('pass', md5($password)); |
|
81 | 81 | |
82 | - // if no username is set, let's generate one |
|
83 | - $unamecount = 20; |
|
84 | - $uname = $userObj->getVar('uname'); |
|
85 | - if (!$uname || $uname === '') { |
|
86 | - $usernames = $this->genUserNames($email, $unamecount); |
|
87 | - $newuser = false; |
|
88 | - $i = 0; |
|
89 | - while ($newuser === false) { |
|
90 | - $crit = new Criteria('uname', $usernames[$i]); |
|
91 | - $count = $this->getUserCount($crit); |
|
92 | - if ($count == 0) { |
|
93 | - $newuser = true; |
|
94 | - } else { |
|
95 | - //Move to next username |
|
96 | - ++$i; |
|
97 | - if ($i == $unamecount) { |
|
98 | - //Get next batch of usernames to try, reset counter |
|
99 | - $usernames = $this->genUserNames($email, $unamecount); |
|
100 | - $i = 0; |
|
101 | - } |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
82 | + // if no username is set, let's generate one |
|
83 | + $unamecount = 20; |
|
84 | + $uname = $userObj->getVar('uname'); |
|
85 | + if (!$uname || $uname === '') { |
|
86 | + $usernames = $this->genUserNames($email, $unamecount); |
|
87 | + $newuser = false; |
|
88 | + $i = 0; |
|
89 | + while ($newuser === false) { |
|
90 | + $crit = new Criteria('uname', $usernames[$i]); |
|
91 | + $count = $this->getUserCount($crit); |
|
92 | + if ($count == 0) { |
|
93 | + $newuser = true; |
|
94 | + } else { |
|
95 | + //Move to next username |
|
96 | + ++$i; |
|
97 | + if ($i == $unamecount) { |
|
98 | + //Get next batch of usernames to try, reset counter |
|
99 | + $usernames = $this->genUserNames($email, $unamecount); |
|
100 | + $i = 0; |
|
101 | + } |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - global $xoopsConfig; |
|
106 | + global $xoopsConfig; |
|
107 | 107 | |
108 | - $configHandler = xoops_getHandler('config'); |
|
109 | - $xoopsConfigUser = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
|
110 | - switch ($xoopsConfigUser['activation_type']) { |
|
111 | - case 0: |
|
112 | - $level = 0; |
|
113 | - $mailtemplate = 'smartmail_activate_user.tpl'; |
|
114 | - $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_NEED_ACT, $user_email); |
|
115 | - break; |
|
116 | - case 1: |
|
117 | - $level = 1; |
|
118 | - $mailtemplate = 'smartmail_auto_activate_user.tpl'; |
|
119 | - $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_AUTO_ACT, $user_email); |
|
120 | - break; |
|
121 | - case 2: |
|
122 | - default: |
|
123 | - $level = 0; |
|
124 | - $mailtemplate = 'smartmail_admin_activate_user.tpl'; |
|
125 | - $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_ADMIN_ACT, $user_email); |
|
126 | - } |
|
108 | + $configHandler = xoops_getHandler('config'); |
|
109 | + $xoopsConfigUser = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
|
110 | + switch ($xoopsConfigUser['activation_type']) { |
|
111 | + case 0: |
|
112 | + $level = 0; |
|
113 | + $mailtemplate = 'smartmail_activate_user.tpl'; |
|
114 | + $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_NEED_ACT, $user_email); |
|
115 | + break; |
|
116 | + case 1: |
|
117 | + $level = 1; |
|
118 | + $mailtemplate = 'smartmail_auto_activate_user.tpl'; |
|
119 | + $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_AUTO_ACT, $user_email); |
|
120 | + break; |
|
121 | + case 2: |
|
122 | + default: |
|
123 | + $level = 0; |
|
124 | + $mailtemplate = 'smartmail_admin_activate_user.tpl'; |
|
125 | + $aInfoMessages[] = sprintf(_NL_MA_NEW_USER_ADMIN_ACT, $user_email); |
|
126 | + } |
|
127 | 127 | |
128 | - $userObj->setVar('uname', $usernames[$i]); |
|
129 | - $userObj->setVar('user_avatar', 'blank.gif'); |
|
130 | - $userObj->setVar('user_regdate', time()); |
|
131 | - $userObj->setVar('timezone_offset', $xoopsConfig['default_TZ']); |
|
132 | - $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); |
|
133 | - $userObj->setVar('actkey', $actkey); |
|
134 | - $userObj->setVar('email', $email); |
|
135 | - $userObj->setVar('notify_method', 2); |
|
136 | - $userObj->setVar('level', $userObj); |
|
128 | + $userObj->setVar('uname', $usernames[$i]); |
|
129 | + $userObj->setVar('user_avatar', 'blank.gif'); |
|
130 | + $userObj->setVar('user_regdate', time()); |
|
131 | + $userObj->setVar('timezone_offset', $xoopsConfig['default_TZ']); |
|
132 | + $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); |
|
133 | + $userObj->setVar('actkey', $actkey); |
|
134 | + $userObj->setVar('email', $email); |
|
135 | + $userObj->setVar('notify_method', 2); |
|
136 | + $userObj->setVar('level', $userObj); |
|
137 | 137 | |
138 | - if ($this->insertUser($userObj)) { |
|
138 | + if ($this->insertUser($userObj)) { |
|
139 | 139 | |
140 | - // if $groups=false, Add the user to Registered Users group |
|
141 | - if (!$groups) { |
|
142 | - $this->addUserToGroup(XOOPS_GROUP_USERS, $userObj->getVar('uid')); |
|
143 | - } else { |
|
144 | - foreach ($groups as $groupid) { |
|
145 | - $this->addUserToGroup($groupid, $userObj->getVar('uid')); |
|
146 | - } |
|
147 | - } |
|
148 | - } else { |
|
149 | - return false; |
|
150 | - } |
|
140 | + // if $groups=false, Add the user to Registered Users group |
|
141 | + if (!$groups) { |
|
142 | + $this->addUserToGroup(XOOPS_GROUP_USERS, $userObj->getVar('uid')); |
|
143 | + } else { |
|
144 | + foreach ($groups as $groupid) { |
|
145 | + $this->addUserToGroup($groupid, $userObj->getVar('uid')); |
|
146 | + } |
|
147 | + } |
|
148 | + } else { |
|
149 | + return false; |
|
150 | + } |
|
151 | 151 | |
152 | - if ($notifyUser) { |
|
153 | - // send some notifications |
|
154 | - $xoopsMailer =& getMailer(); |
|
155 | - $xoopsMailer->useMail(); |
|
156 | - $xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/mail_template'); |
|
157 | - $xoopsMailer->setTemplate('smartobject_notify_user_added_by_admin.tpl'); |
|
158 | - $xoopsMailer->assign('XOOPS_USER_PASSWORD', $password); |
|
159 | - $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); |
|
160 | - $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
161 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
162 | - $xoopsMailer->assign('NAME', $userObj->getVar('name')); |
|
163 | - $xoopsMailer->assign('UNAME', $userObj->getVar('uname')); |
|
164 | - $xoopsMailer->setToUsers($userObj); |
|
165 | - $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); |
|
166 | - $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
167 | - $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_NEW_USER_NOTIFICATION_SUBJECT, $xoopsConfig['sitename'])); |
|
152 | + if ($notifyUser) { |
|
153 | + // send some notifications |
|
154 | + $xoopsMailer =& getMailer(); |
|
155 | + $xoopsMailer->useMail(); |
|
156 | + $xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/mail_template'); |
|
157 | + $xoopsMailer->setTemplate('smartobject_notify_user_added_by_admin.tpl'); |
|
158 | + $xoopsMailer->assign('XOOPS_USER_PASSWORD', $password); |
|
159 | + $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); |
|
160 | + $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
161 | + $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
162 | + $xoopsMailer->assign('NAME', $userObj->getVar('name')); |
|
163 | + $xoopsMailer->assign('UNAME', $userObj->getVar('uname')); |
|
164 | + $xoopsMailer->setToUsers($userObj); |
|
165 | + $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); |
|
166 | + $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
167 | + $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_NEW_USER_NOTIFICATION_SUBJECT, $xoopsConfig['sitename'])); |
|
168 | 168 | |
169 | - if (!$xoopsMailer->send(true)) { |
|
170 | - /** |
|
171 | - * @todo trap error if email was not sent |
|
172 | - */ |
|
173 | - $xoopsMailer->getErrors(true); |
|
174 | - } |
|
175 | - } |
|
169 | + if (!$xoopsMailer->send(true)) { |
|
170 | + /** |
|
171 | + * @todo trap error if email was not sent |
|
172 | + */ |
|
173 | + $xoopsMailer->getErrors(true); |
|
174 | + } |
|
175 | + } |
|
176 | 176 | |
177 | - return true; |
|
178 | - } |
|
177 | + return true; |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
181 | - * Generates an array of usernames |
|
182 | - * |
|
183 | - * @param string $email email of user |
|
184 | - * @param int $count number of names to generate |
|
185 | - * @return array $names |
|
186 | - * @internal param string $name name of user |
|
187 | - * @author xHelp Team |
|
188 | - * |
|
189 | - * @access public |
|
190 | - */ |
|
191 | - public function genUserNames($email, $count = 20) |
|
192 | - { |
|
193 | - $name = substr($email, 0, strpos($email, '@')); //Take the email adress without domain as username |
|
180 | + /** |
|
181 | + * Generates an array of usernames |
|
182 | + * |
|
183 | + * @param string $email email of user |
|
184 | + * @param int $count number of names to generate |
|
185 | + * @return array $names |
|
186 | + * @internal param string $name name of user |
|
187 | + * @author xHelp Team |
|
188 | + * |
|
189 | + * @access public |
|
190 | + */ |
|
191 | + public function genUserNames($email, $count = 20) |
|
192 | + { |
|
193 | + $name = substr($email, 0, strpos($email, '@')); //Take the email adress without domain as username |
|
194 | 194 | |
195 | - $names = array(); |
|
196 | - $userid = explode('@', $email); |
|
195 | + $names = array(); |
|
196 | + $userid = explode('@', $email); |
|
197 | 197 | |
198 | - $basename = ''; |
|
199 | - $hasbasename = false; |
|
200 | - $emailname = $userid[0]; |
|
198 | + $basename = ''; |
|
199 | + $hasbasename = false; |
|
200 | + $emailname = $userid[0]; |
|
201 | 201 | |
202 | - $names[] = $emailname; |
|
202 | + $names[] = $emailname; |
|
203 | 203 | |
204 | - if (strlen($name) > 0) { |
|
205 | - $name = explode(' ', trim($name)); |
|
206 | - if (count($name) > 1) { |
|
207 | - $basename = strtolower(substr($name[0], 0, 1) . $name[count($name) - 1]); |
|
208 | - } else { |
|
209 | - $basename = strtolower($name[0]); |
|
210 | - } |
|
211 | - $basename = xoops_substr($basename, 0, 60, ''); |
|
212 | - //Prevent Duplication of Email Username and Name |
|
213 | - if (!in_array($basename, $names)) { |
|
214 | - $names[] = $basename; |
|
215 | - $hasbasename = true; |
|
216 | - } |
|
217 | - } |
|
204 | + if (strlen($name) > 0) { |
|
205 | + $name = explode(' ', trim($name)); |
|
206 | + if (count($name) > 1) { |
|
207 | + $basename = strtolower(substr($name[0], 0, 1) . $name[count($name) - 1]); |
|
208 | + } else { |
|
209 | + $basename = strtolower($name[0]); |
|
210 | + } |
|
211 | + $basename = xoops_substr($basename, 0, 60, ''); |
|
212 | + //Prevent Duplication of Email Username and Name |
|
213 | + if (!in_array($basename, $names)) { |
|
214 | + $names[] = $basename; |
|
215 | + $hasbasename = true; |
|
216 | + } |
|
217 | + } |
|
218 | 218 | |
219 | - $i = count($names); |
|
220 | - $onbasename = 1; |
|
221 | - while ($i < $count) { |
|
222 | - $num = $this->genRandNumber(); |
|
223 | - if ($onbasename < 0 && $hasbasename) { |
|
224 | - $names[] = xoops_substr($basename, 0, 58, '') . $num; |
|
225 | - } else { |
|
226 | - $names[] = xoops_substr($emailname, 0, 58, '') . $num; |
|
227 | - } |
|
228 | - $i = count($names); |
|
229 | - $onbasename = ~$onbasename; |
|
230 | - $num = ''; |
|
231 | - } |
|
219 | + $i = count($names); |
|
220 | + $onbasename = 1; |
|
221 | + while ($i < $count) { |
|
222 | + $num = $this->genRandNumber(); |
|
223 | + if ($onbasename < 0 && $hasbasename) { |
|
224 | + $names[] = xoops_substr($basename, 0, 58, '') . $num; |
|
225 | + } else { |
|
226 | + $names[] = xoops_substr($emailname, 0, 58, '') . $num; |
|
227 | + } |
|
228 | + $i = count($names); |
|
229 | + $onbasename = ~$onbasename; |
|
230 | + $num = ''; |
|
231 | + } |
|
232 | 232 | |
233 | - return $names; |
|
234 | - } |
|
233 | + return $names; |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Creates a random number with a specified number of $digits |
|
238 | - * |
|
239 | - * @param int $digits number of digits |
|
240 | - * @return return int random number |
|
241 | - * @author xHelp Team |
|
242 | - * |
|
243 | - * @access public |
|
244 | - */ |
|
245 | - public function genRandNumber($digits = 2) |
|
246 | - { |
|
247 | - $this->initRand(); |
|
248 | - $tmp = array(); |
|
236 | + /** |
|
237 | + * Creates a random number with a specified number of $digits |
|
238 | + * |
|
239 | + * @param int $digits number of digits |
|
240 | + * @return return int random number |
|
241 | + * @author xHelp Team |
|
242 | + * |
|
243 | + * @access public |
|
244 | + */ |
|
245 | + public function genRandNumber($digits = 2) |
|
246 | + { |
|
247 | + $this->initRand(); |
|
248 | + $tmp = array(); |
|
249 | 249 | |
250 | - for ($i = 0; $i < $digits; ++$i) { |
|
251 | - $tmp[$i] = (mt_rand() % 9); |
|
252 | - } |
|
250 | + for ($i = 0; $i < $digits; ++$i) { |
|
251 | + $tmp[$i] = (mt_rand() % 9); |
|
252 | + } |
|
253 | 253 | |
254 | - return implode('', $tmp); |
|
255 | - } |
|
254 | + return implode('', $tmp); |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * Gives the random number generator a seed to start from |
|
259 | - * |
|
260 | - * @return void |
|
261 | - * |
|
262 | - * @access public |
|
263 | - */ |
|
264 | - public function initRand() |
|
265 | - { |
|
266 | - static $randCalled = false; |
|
267 | - if (!$randCalled) { |
|
268 | - mt_srand((double)microtime() * 1000000); |
|
269 | - $randCalled = true; |
|
270 | - } |
|
271 | - } |
|
257 | + /** |
|
258 | + * Gives the random number generator a seed to start from |
|
259 | + * |
|
260 | + * @return void |
|
261 | + * |
|
262 | + * @access public |
|
263 | + */ |
|
264 | + public function initRand() |
|
265 | + { |
|
266 | + static $randCalled = false; |
|
267 | + if (!$randCalled) { |
|
268 | + mt_srand((double)microtime() * 1000000); |
|
269 | + $randCalled = true; |
|
270 | + } |
|
271 | + } |
|
272 | 272 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | // ------------------------------------------------------------------------- // |
31 | 31 | |
32 | 32 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
33 | -require_once XOOPS_ROOT_PATH . '/kernel/user.php'; |
|
34 | -require_once XOOPS_ROOT_PATH . '/kernel/group.php'; |
|
35 | -require_once XOOPS_ROOT_PATH . '/kernel/member.php'; |
|
33 | +require_once XOOPS_ROOT_PATH.'/kernel/user.php'; |
|
34 | +require_once XOOPS_ROOT_PATH.'/kernel/group.php'; |
|
35 | +require_once XOOPS_ROOT_PATH.'/kernel/member.php'; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * XOOPS member handler class. |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | |
152 | 152 | if ($notifyUser) { |
153 | 153 | // send some notifications |
154 | - $xoopsMailer =& getMailer(); |
|
154 | + $xoopsMailer = & getMailer(); |
|
155 | 155 | $xoopsMailer->useMail(); |
156 | - $xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/mail_template'); |
|
156 | + $xoopsMailer->setTemplateDir(SMARTOBJECT_ROOT_PATH.'language/'.$xoopsConfig['language'].'/mail_template'); |
|
157 | 157 | $xoopsMailer->setTemplate('smartobject_notify_user_added_by_admin.tpl'); |
158 | 158 | $xoopsMailer->assign('XOOPS_USER_PASSWORD', $password); |
159 | 159 | $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); |
160 | 160 | $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
161 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
161 | + $xoopsMailer->assign('SITEURL', XOOPS_URL.'/'); |
|
162 | 162 | $xoopsMailer->assign('NAME', $userObj->getVar('name')); |
163 | 163 | $xoopsMailer->assign('UNAME', $userObj->getVar('uname')); |
164 | 164 | $xoopsMailer->setToUsers($userObj); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if (strlen($name) > 0) { |
205 | 205 | $name = explode(' ', trim($name)); |
206 | 206 | if (count($name) > 1) { |
207 | - $basename = strtolower(substr($name[0], 0, 1) . $name[count($name) - 1]); |
|
207 | + $basename = strtolower(substr($name[0], 0, 1).$name[count($name) - 1]); |
|
208 | 208 | } else { |
209 | 209 | $basename = strtolower($name[0]); |
210 | 210 | } |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | while ($i < $count) { |
222 | 222 | $num = $this->genRandNumber(); |
223 | 223 | if ($onbasename < 0 && $hasbasename) { |
224 | - $names[] = xoops_substr($basename, 0, 58, '') . $num; |
|
224 | + $names[] = xoops_substr($basename, 0, 58, '').$num; |
|
225 | 225 | } else { |
226 | - $names[] = xoops_substr($emailname, 0, 58, '') . $num; |
|
226 | + $names[] = xoops_substr($emailname, 0, 58, '').$num; |
|
227 | 227 | } |
228 | 228 | $i = count($names); |
229 | 229 | $onbasename = ~$onbasename; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | { |
266 | 266 | static $randCalled = false; |
267 | 267 | if (!$randCalled) { |
268 | - mt_srand((double)microtime() * 1000000); |
|
268 | + mt_srand((double) microtime() * 1000000); |
|
269 | 269 | $randCalled = true; |
270 | 270 | } |
271 | 271 | } |
@@ -237,7 +237,7 @@ |
||
237 | 237 | * Creates a random number with a specified number of $digits |
238 | 238 | * |
239 | 239 | * @param int $digits number of digits |
240 | - * @return return int random number |
|
240 | + * @return string int random number |
|
241 | 241 | * @author xHelp Team |
242 | 242 | * |
243 | 243 | * @access public |
@@ -24,82 +24,82 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class SmartMlObject extends SmartObject |
26 | 26 | { |
27 | - /** |
|
28 | - * SmartMlObject constructor. |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
33 | - $this->setControl('language', 'language'); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * If object is not new, change the control of the not-multilanguage fields |
|
38 | - * |
|
39 | - * We need to intercept this function from SmartObject because if the object is not new... |
|
40 | - */ |
|
41 | - // function getForm() { |
|
42 | - |
|
43 | - //} |
|
44 | - |
|
45 | - /** |
|
46 | - * Strip Multilanguage Fields |
|
47 | - * |
|
48 | - * Get rid of all the multilanguage fields to have an object with only global fields. |
|
49 | - * This will be usefull when creating the ML object for the first time. Then we will be able |
|
50 | - * to create translations. |
|
51 | - */ |
|
52 | - public function stripMultilanguageFields() |
|
53 | - { |
|
54 | - $objectVars =& $this->getVars(); |
|
55 | - $newObjectVars = array(); |
|
56 | - foreach ($objectVars as $key => $var) { |
|
57 | - if (!$var['multilingual']) { |
|
58 | - $newObjectVars[$key] = $var; |
|
59 | - } |
|
60 | - } |
|
61 | - $this->vars = $newObjectVars; |
|
62 | - } |
|
63 | - |
|
64 | - public function stripNonMultilanguageFields() |
|
65 | - { |
|
66 | - $objectVars =& $this->getVars(); |
|
67 | - $newObjectVars = array(); |
|
68 | - foreach ($objectVars as $key => $var) { |
|
69 | - if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
70 | - $newObjectVars[$key] = $var; |
|
71 | - } |
|
72 | - } |
|
73 | - $this->vars = $newObjectVars; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Make non multilanguage fields read only |
|
78 | - * |
|
79 | - * This is used when we are creating/editing a translation. |
|
80 | - * We only want to edit the multilanguag fields, not the global one. |
|
81 | - */ |
|
82 | - public function makeNonMLFieldReadOnly() |
|
83 | - { |
|
84 | - foreach ($this->getVars() as $key => $var) { |
|
85 | - //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
86 | - if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
87 | - $this->setControl($key, 'label'); |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param bool $onlyUrl |
|
94 | - * @param bool $withimage |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
98 | - { |
|
99 | - $controller = new SmartObjectController($this->handler); |
|
100 | - |
|
101 | - return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
102 | - } |
|
27 | + /** |
|
28 | + * SmartMlObject constructor. |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
33 | + $this->setControl('language', 'language'); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * If object is not new, change the control of the not-multilanguage fields |
|
38 | + * |
|
39 | + * We need to intercept this function from SmartObject because if the object is not new... |
|
40 | + */ |
|
41 | + // function getForm() { |
|
42 | + |
|
43 | + //} |
|
44 | + |
|
45 | + /** |
|
46 | + * Strip Multilanguage Fields |
|
47 | + * |
|
48 | + * Get rid of all the multilanguage fields to have an object with only global fields. |
|
49 | + * This will be usefull when creating the ML object for the first time. Then we will be able |
|
50 | + * to create translations. |
|
51 | + */ |
|
52 | + public function stripMultilanguageFields() |
|
53 | + { |
|
54 | + $objectVars =& $this->getVars(); |
|
55 | + $newObjectVars = array(); |
|
56 | + foreach ($objectVars as $key => $var) { |
|
57 | + if (!$var['multilingual']) { |
|
58 | + $newObjectVars[$key] = $var; |
|
59 | + } |
|
60 | + } |
|
61 | + $this->vars = $newObjectVars; |
|
62 | + } |
|
63 | + |
|
64 | + public function stripNonMultilanguageFields() |
|
65 | + { |
|
66 | + $objectVars =& $this->getVars(); |
|
67 | + $newObjectVars = array(); |
|
68 | + foreach ($objectVars as $key => $var) { |
|
69 | + if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
70 | + $newObjectVars[$key] = $var; |
|
71 | + } |
|
72 | + } |
|
73 | + $this->vars = $newObjectVars; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Make non multilanguage fields read only |
|
78 | + * |
|
79 | + * This is used when we are creating/editing a translation. |
|
80 | + * We only want to edit the multilanguag fields, not the global one. |
|
81 | + */ |
|
82 | + public function makeNonMLFieldReadOnly() |
|
83 | + { |
|
84 | + foreach ($this->getVars() as $key => $var) { |
|
85 | + //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
86 | + if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
87 | + $this->setControl($key, 'label'); |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param bool $onlyUrl |
|
94 | + * @param bool $withimage |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
98 | + { |
|
99 | + $controller = new SmartObjectController($this->handler); |
|
100 | + |
|
101 | + return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -107,70 +107,70 @@ discard block |
||
107 | 107 | */ |
108 | 108 | class SmartPersistableMlObjectHandler extends SmartPersistableObjectHandler |
109 | 109 | { |
110 | - /** |
|
111 | - * @param null $criteria |
|
112 | - * @param bool $id_as_key |
|
113 | - * @param bool $as_object |
|
114 | - * @param bool $debug |
|
115 | - * @param bool $language |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false) |
|
119 | - { |
|
120 | - // Create the first part of the SQL query to join the "_text" table |
|
121 | - $sql = 'SELECT * FROM ' . |
|
122 | - $this->table . |
|
123 | - ' AS ' . |
|
124 | - $this->_itemname . |
|
125 | - ' INNER JOIN ' . |
|
126 | - $this->table . |
|
127 | - '_text AS ' . |
|
128 | - $this->_itemname . |
|
129 | - '_text ON ' . |
|
130 | - $this->_itemname . |
|
131 | - '.' . |
|
132 | - $this->keyName . |
|
133 | - '=' . |
|
134 | - $this->_itemname . |
|
135 | - '_text.' . |
|
136 | - $this->keyName; |
|
137 | - |
|
138 | - if ($language) { |
|
139 | - // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
140 | - |
|
141 | - // if no criteria was previously created, let's create it |
|
142 | - if (!$criteria) { |
|
143 | - $criteria = new CriteriaCompo(); |
|
144 | - } |
|
145 | - $criteria->add(new Criteria('language', $language)); |
|
146 | - |
|
147 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
148 | - } |
|
149 | - |
|
150 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param mixed $id |
|
155 | - * @param bool $language |
|
156 | - * @param bool $as_object |
|
157 | - * @param bool $debug |
|
158 | - * @return mixed |
|
159 | - */ |
|
160 | - public function &get($id, $language = false, $as_object = true, $debug = false) |
|
161 | - { |
|
162 | - if (!$language) { |
|
163 | - return parent::get($id, $as_object, $debug); |
|
164 | - } else { |
|
165 | - $criteria = new CriteriaCompo(); |
|
166 | - $criteria->add(new Criteria('language', $language)); |
|
167 | - |
|
168 | - return parent::get($id, $as_object, $debug, $criteria); |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - public function changeTableNameForML() |
|
173 | - { |
|
174 | - $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
175 | - } |
|
110 | + /** |
|
111 | + * @param null $criteria |
|
112 | + * @param bool $id_as_key |
|
113 | + * @param bool $as_object |
|
114 | + * @param bool $debug |
|
115 | + * @param bool $language |
|
116 | + * @return array |
|
117 | + */ |
|
118 | + public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false) |
|
119 | + { |
|
120 | + // Create the first part of the SQL query to join the "_text" table |
|
121 | + $sql = 'SELECT * FROM ' . |
|
122 | + $this->table . |
|
123 | + ' AS ' . |
|
124 | + $this->_itemname . |
|
125 | + ' INNER JOIN ' . |
|
126 | + $this->table . |
|
127 | + '_text AS ' . |
|
128 | + $this->_itemname . |
|
129 | + '_text ON ' . |
|
130 | + $this->_itemname . |
|
131 | + '.' . |
|
132 | + $this->keyName . |
|
133 | + '=' . |
|
134 | + $this->_itemname . |
|
135 | + '_text.' . |
|
136 | + $this->keyName; |
|
137 | + |
|
138 | + if ($language) { |
|
139 | + // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
140 | + |
|
141 | + // if no criteria was previously created, let's create it |
|
142 | + if (!$criteria) { |
|
143 | + $criteria = new CriteriaCompo(); |
|
144 | + } |
|
145 | + $criteria->add(new Criteria('language', $language)); |
|
146 | + |
|
147 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
148 | + } |
|
149 | + |
|
150 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param mixed $id |
|
155 | + * @param bool $language |
|
156 | + * @param bool $as_object |
|
157 | + * @param bool $debug |
|
158 | + * @return mixed |
|
159 | + */ |
|
160 | + public function &get($id, $language = false, $as_object = true, $debug = false) |
|
161 | + { |
|
162 | + if (!$language) { |
|
163 | + return parent::get($id, $as_object, $debug); |
|
164 | + } else { |
|
165 | + $criteria = new CriteriaCompo(); |
|
166 | + $criteria->add(new Criteria('language', $language)); |
|
167 | + |
|
168 | + return parent::get($id, $as_object, $debug, $criteria); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + public function changeTableNameForML() |
|
173 | + { |
|
174 | + $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
175 | + } |
|
176 | 176 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
14 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
14 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * SmartObject base Multilanguage-enabled class |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function stripMultilanguageFields() |
53 | 53 | { |
54 | - $objectVars =& $this->getVars(); |
|
54 | + $objectVars = & $this->getVars(); |
|
55 | 55 | $newObjectVars = array(); |
56 | 56 | foreach ($objectVars as $key => $var) { |
57 | 57 | if (!$var['multilingual']) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function stripNonMultilanguageFields() |
65 | 65 | { |
66 | - $objectVars =& $this->getVars(); |
|
66 | + $objectVars = & $this->getVars(); |
|
67 | 67 | $newObjectVars = array(); |
68 | 68 | foreach ($objectVars as $key => $var) { |
69 | 69 | if ($var['multilingual'] || $key == $this->handler->keyName) { |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | public function getObjects($criteria = null, $id_as_key = false, $as_object = true, $debug = false, $language = false) |
119 | 119 | { |
120 | 120 | // Create the first part of the SQL query to join the "_text" table |
121 | - $sql = 'SELECT * FROM ' . |
|
122 | - $this->table . |
|
123 | - ' AS ' . |
|
124 | - $this->_itemname . |
|
125 | - ' INNER JOIN ' . |
|
126 | - $this->table . |
|
127 | - '_text AS ' . |
|
128 | - $this->_itemname . |
|
129 | - '_text ON ' . |
|
130 | - $this->_itemname . |
|
131 | - '.' . |
|
132 | - $this->keyName . |
|
133 | - '=' . |
|
134 | - $this->_itemname . |
|
135 | - '_text.' . |
|
121 | + $sql = 'SELECT * FROM '. |
|
122 | + $this->table. |
|
123 | + ' AS '. |
|
124 | + $this->_itemname. |
|
125 | + ' INNER JOIN '. |
|
126 | + $this->table. |
|
127 | + '_text AS '. |
|
128 | + $this->_itemname. |
|
129 | + '_text ON '. |
|
130 | + $this->_itemname. |
|
131 | + '.'. |
|
132 | + $this->keyName. |
|
133 | + '='. |
|
134 | + $this->_itemname. |
|
135 | + '_text.'. |
|
136 | 136 | $this->keyName; |
137 | 137 | |
138 | 138 | if ($language) { |
@@ -171,6 +171,6 @@ discard block |
||
171 | 171 | |
172 | 172 | public function changeTableNameForML() |
173 | 173 | { |
174 | - $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
174 | + $this->table = $this->db->prefix($this->_moduleName.'_'.$this->_itemname.'_text'); |
|
175 | 175 | } |
176 | 176 | } |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class SmartobjectFile extends SmartobjectBasedUrl |
10 | 10 | { |
11 | - /** |
|
12 | - * SmartobjectFile constructor. |
|
13 | - */ |
|
14 | - public function __construct() |
|
15 | - { |
|
16 | - parent::__construct(); |
|
17 | - $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
18 | - } |
|
11 | + /** |
|
12 | + * SmartobjectFile constructor. |
|
13 | + */ |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + parent::__construct(); |
|
17 | + $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class SmartobjectFileHandler extends SmartPersistableObjectHandler |
25 | 25 | { |
26 | - /** |
|
27 | - * SmartobjectFileHandler constructor. |
|
28 | - * @param XoopsDatabase $db |
|
29 | - */ |
|
30 | - public function __construct(XoopsDatabase $db) |
|
31 | - { |
|
32 | - parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject'); |
|
33 | - } |
|
26 | + /** |
|
27 | + * SmartobjectFileHandler constructor. |
|
28 | + * @param XoopsDatabase $db |
|
29 | + */ |
|
30 | + public function __construct(XoopsDatabase $db) |
|
31 | + { |
|
32 | + parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject'); |
|
33 | + } |
|
34 | 34 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
3 | 3 | |
4 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/basedurl.php'; |
|
4 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/basedurl.php'; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class SmartobjectFile |
@@ -37,115 +37,115 @@ discard block |
||
37 | 37 | */ |
38 | 38 | class SmartobjectCurrency extends SmartObject |
39 | 39 | { |
40 | - public $_modulePlugin = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * SmartobjectCurrency constructor. |
|
44 | - */ |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true); |
|
48 | - $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC); |
|
49 | - $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME); |
|
50 | - $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL); |
|
51 | - $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0'); |
|
52 | - $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false); |
|
53 | - |
|
54 | - $this->setControl('symbol', array( |
|
55 | - 'name' => 'text', |
|
56 | - 'size' => '15', |
|
57 | - 'maxlength' => '15' |
|
58 | - )); |
|
59 | - |
|
60 | - $this->setControl('iso4217', array( |
|
61 | - 'name' => 'text', |
|
62 | - 'size' => '5', |
|
63 | - 'maxlength' => '5' |
|
64 | - )); |
|
65 | - |
|
66 | - $this->setControl('rate', array( |
|
67 | - 'name' => 'text', |
|
68 | - 'size' => '5', |
|
69 | - 'maxlength' => '5' |
|
70 | - )); |
|
71 | - |
|
72 | - $this->setControl('rate', array( |
|
73 | - 'name' => 'text', |
|
74 | - 'size' => '5', |
|
75 | - 'maxlength' => '5' |
|
76 | - )); |
|
77 | - |
|
78 | - $this->hideFieldFromForm('default_currency'); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $key |
|
83 | - * @param string $format |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public function getVar($key, $format = 's') |
|
87 | - { |
|
88 | - if ($format === 's' && in_array($key, array('rate', 'default_currency'))) { |
|
89 | - // return call_user_func(array($this, $key)); |
|
90 | - return $this->{$key}(); |
|
91 | - } |
|
92 | - |
|
93 | - return parent::getVar($key, $format); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @return mixed |
|
98 | - */ |
|
99 | - public function getCurrencyLink() |
|
100 | - { |
|
101 | - $ret = $this->getVar('name', 'e'); |
|
102 | - |
|
103 | - return $ret; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return mixed |
|
108 | - */ |
|
109 | - public function getCode() |
|
110 | - { |
|
111 | - $ret = $this->getVar('iso4217', 'e'); |
|
112 | - |
|
113 | - return $ret; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @return float|int|mixed|string |
|
118 | - */ |
|
119 | - public function rate() |
|
120 | - { |
|
121 | - return smart_currency($this->getVar('rate', 'e')); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function defaultCurrency() |
|
128 | - { |
|
129 | - if ($this->getVar('default_currency', 'e') === true) { |
|
130 | - return _YES; |
|
131 | - } else { |
|
132 | - return _NO; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function getDefaultCurrencyControl() |
|
140 | - { |
|
141 | - $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
142 | - if ($this->getVar('default_currency', 'e')) { |
|
143 | - $radio_box .= 'checked="checked"'; |
|
144 | - } |
|
145 | - $radio_box .= '>'; |
|
146 | - |
|
147 | - return $radio_box; |
|
148 | - } |
|
40 | + public $_modulePlugin = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * SmartobjectCurrency constructor. |
|
44 | + */ |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true); |
|
48 | + $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC); |
|
49 | + $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME); |
|
50 | + $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL); |
|
51 | + $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0'); |
|
52 | + $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false); |
|
53 | + |
|
54 | + $this->setControl('symbol', array( |
|
55 | + 'name' => 'text', |
|
56 | + 'size' => '15', |
|
57 | + 'maxlength' => '15' |
|
58 | + )); |
|
59 | + |
|
60 | + $this->setControl('iso4217', array( |
|
61 | + 'name' => 'text', |
|
62 | + 'size' => '5', |
|
63 | + 'maxlength' => '5' |
|
64 | + )); |
|
65 | + |
|
66 | + $this->setControl('rate', array( |
|
67 | + 'name' => 'text', |
|
68 | + 'size' => '5', |
|
69 | + 'maxlength' => '5' |
|
70 | + )); |
|
71 | + |
|
72 | + $this->setControl('rate', array( |
|
73 | + 'name' => 'text', |
|
74 | + 'size' => '5', |
|
75 | + 'maxlength' => '5' |
|
76 | + )); |
|
77 | + |
|
78 | + $this->hideFieldFromForm('default_currency'); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $key |
|
83 | + * @param string $format |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public function getVar($key, $format = 's') |
|
87 | + { |
|
88 | + if ($format === 's' && in_array($key, array('rate', 'default_currency'))) { |
|
89 | + // return call_user_func(array($this, $key)); |
|
90 | + return $this->{$key}(); |
|
91 | + } |
|
92 | + |
|
93 | + return parent::getVar($key, $format); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @return mixed |
|
98 | + */ |
|
99 | + public function getCurrencyLink() |
|
100 | + { |
|
101 | + $ret = $this->getVar('name', 'e'); |
|
102 | + |
|
103 | + return $ret; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return mixed |
|
108 | + */ |
|
109 | + public function getCode() |
|
110 | + { |
|
111 | + $ret = $this->getVar('iso4217', 'e'); |
|
112 | + |
|
113 | + return $ret; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @return float|int|mixed|string |
|
118 | + */ |
|
119 | + public function rate() |
|
120 | + { |
|
121 | + return smart_currency($this->getVar('rate', 'e')); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function defaultCurrency() |
|
128 | + { |
|
129 | + if ($this->getVar('default_currency', 'e') === true) { |
|
130 | + return _YES; |
|
131 | + } else { |
|
132 | + return _NO; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function getDefaultCurrencyControl() |
|
140 | + { |
|
141 | + $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
142 | + if ($this->getVar('default_currency', 'e')) { |
|
143 | + $radio_box .= 'checked="checked"'; |
|
144 | + } |
|
145 | + $radio_box .= '>'; |
|
146 | + |
|
147 | + return $radio_box; |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | */ |
154 | 154 | class SmartObjectCurrencyHandler extends SmartPersistableObjectHandler |
155 | 155 | { |
156 | - /** |
|
157 | - * SmartObjectCurrencyHandler constructor. |
|
158 | - * @param XoopsDatabase $db |
|
159 | - */ |
|
160 | - public function __construct(XoopsDatabase $db) |
|
161 | - { |
|
162 | - parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @return array |
|
167 | - */ |
|
168 | - public function getCurrencies() |
|
169 | - { |
|
170 | - $currenciesObj = $this->getObjects(null, true); |
|
171 | - |
|
172 | - return $currenciesObj; |
|
173 | - } |
|
156 | + /** |
|
157 | + * SmartObjectCurrencyHandler constructor. |
|
158 | + * @param XoopsDatabase $db |
|
159 | + */ |
|
160 | + public function __construct(XoopsDatabase $db) |
|
161 | + { |
|
162 | + parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @return array |
|
167 | + */ |
|
168 | + public function getCurrencies() |
|
169 | + { |
|
170 | + $currenciesObj = $this->getObjects(null, true); |
|
171 | + |
|
172 | + return $currenciesObj; |
|
173 | + } |
|
174 | 174 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
33 | -include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
32 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
33 | +include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Class SmartobjectCurrency |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getDefaultCurrencyControl() |
140 | 140 | { |
141 | - $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
141 | + $radio_box = '<input name="default_currency" value="'.$this->getVar('currencyid').'" type="radio"'; |
|
142 | 142 | if ($this->getVar('default_currency', 'e')) { |
143 | 143 | $radio_box .= 'checked="checked"'; |
144 | 144 | } |
@@ -30,6 +30,6 @@ |
||
30 | 30 | $smarthookHandler = SmartHookHandler::getInstance(); |
31 | 31 | |
32 | 32 | if (!class_exists('smartmetagen')) { |
33 | - include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php'); |
|
33 | + include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php'); |
|
34 | 34 | } |
35 | 35 | //$smartobjectConfig = smart_getModuleConfig('smartobject'); |
@@ -13,23 +13,23 @@ |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
15 | 15 | |
16 | -include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
16 | +include_once(XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php'); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Include other classes used by the SmartObject |
20 | 20 | */ |
21 | -include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjecthandler.php'); |
|
22 | -include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobject.php'); |
|
23 | -include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectsregistry.php'); |
|
21 | +include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjecthandler.php'); |
|
22 | +include_once(SMARTOBJECT_ROOT_PATH.'class/smartobject.php'); |
|
23 | +include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjectsregistry.php'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Including SmartHook feature |
27 | 27 | */ |
28 | 28 | |
29 | -include_once(SMARTOBJECT_ROOT_PATH . 'class/smarthookhandler.php'); |
|
29 | +include_once(SMARTOBJECT_ROOT_PATH.'class/smarthookhandler.php'); |
|
30 | 30 | $smarthookHandler = SmartHookHandler::getInstance(); |
31 | 31 | |
32 | 32 | if (!class_exists('smartmetagen')) { |
33 | - include_once(SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php'); |
|
33 | + include_once(SMARTOBJECT_ROOT_PATH.'class/smartmetagen.php'); |
|
34 | 34 | } |
35 | 35 | //$smartobjectConfig = smart_getModuleConfig('smartobject'); |
@@ -22,153 +22,153 @@ |
||
22 | 22 | */ |
23 | 23 | class SmartObjectTreeTable extends SmartObjectTable |
24 | 24 | { |
25 | - /** |
|
26 | - * SmartObjectTreeTable constructor. |
|
27 | - * @param SmartPersistableObjectHandler $objectHandler |
|
28 | - * @param bool $criteria |
|
29 | - * @param array $actions |
|
30 | - * @param bool $userSide |
|
31 | - */ |
|
32 | - public function __construct(SmartPersistableObjectHandler $objectHandler, $criteria = false, $actions = array('edit', 'delete'), $userSide = false) |
|
33 | - { |
|
34 | - $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide); |
|
35 | - $this->_isTree = true; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Get children objects given a specific parentid |
|
40 | - * |
|
41 | - * @var int $parentid id of the parent which children we want to retreive |
|
42 | - * @return array of SmartObject |
|
43 | - */ |
|
44 | - public function getChildrenOf($parentid = 0) |
|
45 | - { |
|
46 | - return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param $object |
|
51 | - * @param int $level |
|
52 | - */ |
|
53 | - public function createTableRow($object, $level = 0) |
|
54 | - { |
|
55 | - $aObject = array(); |
|
56 | - |
|
57 | - $i = 0; |
|
58 | - |
|
59 | - $aColumns = array(); |
|
60 | - $doWeHaveActions = false; |
|
61 | - |
|
62 | - foreach ($this->_columns as $column) { |
|
63 | - $aColumn = array(); |
|
64 | - |
|
65 | - if ($i == 0) { |
|
66 | - $class = 'head'; |
|
67 | - } elseif ($i % 2 == 0) { |
|
68 | - $class = 'even'; |
|
69 | - } else { |
|
70 | - $class = 'odd'; |
|
71 | - } |
|
72 | - |
|
73 | - if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) { |
|
74 | - $method = $column->_customMethodForValue; |
|
75 | - $value = $object->$method(); |
|
76 | - } else { |
|
77 | - /** |
|
78 | - * If the column is the identifier, then put a link on it |
|
79 | - */ |
|
80 | - if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
81 | - $value = $object->getItemLink(); |
|
82 | - } else { |
|
83 | - $value = $object->getVar($column->getKeyName()); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - $space = ''; |
|
88 | - if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
89 | - for ($i = 0; $i < $level; ++$i) { |
|
90 | - $space .= '--'; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - if ($space !== '') { |
|
95 | - $space .= ' '; |
|
96 | - } |
|
97 | - |
|
98 | - $aColumn['value'] = $space . $value; |
|
99 | - $aColumn['class'] = $class; |
|
100 | - $aColumn['width'] = $column->getWidth(); |
|
101 | - $aColumn['align'] = $column->getAlign(); |
|
102 | - $aColumn['key'] = $column->getKeyName(); |
|
103 | - |
|
104 | - $aColumns[] = $aColumn; |
|
105 | - ++$i; |
|
106 | - } |
|
107 | - |
|
108 | - $aObject['columns'] = $aColumns; |
|
109 | - |
|
110 | - $class = $class === 'even' ? 'odd' : 'even'; |
|
111 | - $aObject['class'] = $class; |
|
112 | - |
|
113 | - $actions = array(); |
|
114 | - |
|
115 | - // Adding the custom actions if any |
|
116 | - foreach ($this->_custom_actions as $action) { |
|
117 | - if (method_exists($object, $action)) { |
|
118 | - $actions[] = $object->$action(); |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
123 | - $controller = new SmartObjectController($this->_objectHandler); |
|
124 | - |
|
125 | - if (in_array('edit', $this->_actions)) { |
|
126 | - $actions[] = $controller->getEditItemLink($object, false, true); |
|
127 | - } |
|
128 | - if (in_array('delete', $this->_actions)) { |
|
129 | - $actions[] = $controller->getDeleteItemLink($object, false, true); |
|
130 | - } |
|
131 | - $aObject['actions'] = $actions; |
|
132 | - |
|
133 | - $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30); |
|
134 | - $aObject['id'] = $object->id(); |
|
135 | - $this->_aObjects[] = $aObject; |
|
136 | - |
|
137 | - $childrenObjects = $this->getChildrenOf($object->id()); |
|
138 | - |
|
139 | - $this->_hasActions = $this->_hasActions ? true : count($actions) > 0; |
|
140 | - |
|
141 | - if ($childrenObjects) { |
|
142 | - ++$level; |
|
143 | - foreach ($childrenObjects as $subObject) { |
|
144 | - $this->createTableRow($subObject, $level); |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - public function createTableRows() |
|
150 | - { |
|
151 | - $this->_aObjects = array(); |
|
152 | - |
|
153 | - if (count($this->_objects) > 0) { |
|
154 | - foreach ($this->getChildrenOf() as $object) { |
|
155 | - $this->createTableRow($object); |
|
156 | - } |
|
157 | - |
|
158 | - $this->_tpl->assign('smartobject_objects', $this->_aObjects); |
|
159 | - } else { |
|
160 | - $colspan = count($this->_columns) + 1; |
|
161 | - $this->_tpl->assign('smartobject_colspan', $colspan); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @return mixed |
|
167 | - */ |
|
168 | - public function fetchObjects() |
|
169 | - { |
|
170 | - $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid'); |
|
171 | - |
|
172 | - return $ret; |
|
173 | - } |
|
25 | + /** |
|
26 | + * SmartObjectTreeTable constructor. |
|
27 | + * @param SmartPersistableObjectHandler $objectHandler |
|
28 | + * @param bool $criteria |
|
29 | + * @param array $actions |
|
30 | + * @param bool $userSide |
|
31 | + */ |
|
32 | + public function __construct(SmartPersistableObjectHandler $objectHandler, $criteria = false, $actions = array('edit', 'delete'), $userSide = false) |
|
33 | + { |
|
34 | + $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide); |
|
35 | + $this->_isTree = true; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Get children objects given a specific parentid |
|
40 | + * |
|
41 | + * @var int $parentid id of the parent which children we want to retreive |
|
42 | + * @return array of SmartObject |
|
43 | + */ |
|
44 | + public function getChildrenOf($parentid = 0) |
|
45 | + { |
|
46 | + return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param $object |
|
51 | + * @param int $level |
|
52 | + */ |
|
53 | + public function createTableRow($object, $level = 0) |
|
54 | + { |
|
55 | + $aObject = array(); |
|
56 | + |
|
57 | + $i = 0; |
|
58 | + |
|
59 | + $aColumns = array(); |
|
60 | + $doWeHaveActions = false; |
|
61 | + |
|
62 | + foreach ($this->_columns as $column) { |
|
63 | + $aColumn = array(); |
|
64 | + |
|
65 | + if ($i == 0) { |
|
66 | + $class = 'head'; |
|
67 | + } elseif ($i % 2 == 0) { |
|
68 | + $class = 'even'; |
|
69 | + } else { |
|
70 | + $class = 'odd'; |
|
71 | + } |
|
72 | + |
|
73 | + if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) { |
|
74 | + $method = $column->_customMethodForValue; |
|
75 | + $value = $object->$method(); |
|
76 | + } else { |
|
77 | + /** |
|
78 | + * If the column is the identifier, then put a link on it |
|
79 | + */ |
|
80 | + if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
81 | + $value = $object->getItemLink(); |
|
82 | + } else { |
|
83 | + $value = $object->getVar($column->getKeyName()); |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + $space = ''; |
|
88 | + if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
89 | + for ($i = 0; $i < $level; ++$i) { |
|
90 | + $space .= '--'; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + if ($space !== '') { |
|
95 | + $space .= ' '; |
|
96 | + } |
|
97 | + |
|
98 | + $aColumn['value'] = $space . $value; |
|
99 | + $aColumn['class'] = $class; |
|
100 | + $aColumn['width'] = $column->getWidth(); |
|
101 | + $aColumn['align'] = $column->getAlign(); |
|
102 | + $aColumn['key'] = $column->getKeyName(); |
|
103 | + |
|
104 | + $aColumns[] = $aColumn; |
|
105 | + ++$i; |
|
106 | + } |
|
107 | + |
|
108 | + $aObject['columns'] = $aColumns; |
|
109 | + |
|
110 | + $class = $class === 'even' ? 'odd' : 'even'; |
|
111 | + $aObject['class'] = $class; |
|
112 | + |
|
113 | + $actions = array(); |
|
114 | + |
|
115 | + // Adding the custom actions if any |
|
116 | + foreach ($this->_custom_actions as $action) { |
|
117 | + if (method_exists($object, $action)) { |
|
118 | + $actions[] = $object->$action(); |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
123 | + $controller = new SmartObjectController($this->_objectHandler); |
|
124 | + |
|
125 | + if (in_array('edit', $this->_actions)) { |
|
126 | + $actions[] = $controller->getEditItemLink($object, false, true); |
|
127 | + } |
|
128 | + if (in_array('delete', $this->_actions)) { |
|
129 | + $actions[] = $controller->getDeleteItemLink($object, false, true); |
|
130 | + } |
|
131 | + $aObject['actions'] = $actions; |
|
132 | + |
|
133 | + $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30); |
|
134 | + $aObject['id'] = $object->id(); |
|
135 | + $this->_aObjects[] = $aObject; |
|
136 | + |
|
137 | + $childrenObjects = $this->getChildrenOf($object->id()); |
|
138 | + |
|
139 | + $this->_hasActions = $this->_hasActions ? true : count($actions) > 0; |
|
140 | + |
|
141 | + if ($childrenObjects) { |
|
142 | + ++$level; |
|
143 | + foreach ($childrenObjects as $subObject) { |
|
144 | + $this->createTableRow($subObject, $level); |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + public function createTableRows() |
|
150 | + { |
|
151 | + $this->_aObjects = array(); |
|
152 | + |
|
153 | + if (count($this->_objects) > 0) { |
|
154 | + foreach ($this->getChildrenOf() as $object) { |
|
155 | + $this->createTableRow($object); |
|
156 | + } |
|
157 | + |
|
158 | + $this->_tpl->assign('smartobject_objects', $this->_aObjects); |
|
159 | + } else { |
|
160 | + $colspan = count($this->_columns) + 1; |
|
161 | + $this->_tpl->assign('smartobject_colspan', $colspan); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @return mixed |
|
167 | + */ |
|
168 | + public function fetchObjects() |
|
169 | + { |
|
170 | + $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid'); |
|
171 | + |
|
172 | + return $ret; |
|
173 | + } |
|
174 | 174 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @subpackage SmartObjectTable |
10 | 10 | */ |
11 | 11 | |
12 | -include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'); |
|
12 | +include_once(SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * SmartObjectTreeTable class |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $space .= ' '; |
96 | 96 | } |
97 | 97 | |
98 | - $aColumn['value'] = $space . $value; |
|
98 | + $aColumn['value'] = $space.$value; |
|
99 | 99 | $aColumn['class'] = $class; |
100 | 100 | $aColumn['width'] = $column->getWidth(); |
101 | 101 | $aColumn['align'] = $column->getAlign(); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
122 | + include_once SMARTOBJECT_ROOT_PATH.'class/smartobjectcontroller.php'; |
|
123 | 123 | $controller = new SmartObjectController($this->_objectHandler); |
124 | 124 | |
125 | 125 | if (in_array('edit', $this->_actions)) { |