@@ -12,18 +12,18 @@ discard block |
||
12 | 12 | |
13 | 13 | class SmartobjectPermissionHandler extends XoopsObjectHandler |
14 | 14 | { |
15 | - public $handler; |
|
16 | - |
|
17 | - /** |
|
18 | - * SmartobjectPermissionHandler constructor. |
|
19 | - * @param XoopsDatabase $handler |
|
20 | - */ |
|
21 | - public function __construct($handler) |
|
22 | - { |
|
23 | - $this->handler = $handler; |
|
24 | - } |
|
25 | - |
|
26 | - /* |
|
15 | + public $handler; |
|
16 | + |
|
17 | + /** |
|
18 | + * SmartobjectPermissionHandler constructor. |
|
19 | + * @param XoopsDatabase $handler |
|
20 | + */ |
|
21 | + public function __construct($handler) |
|
22 | + { |
|
23 | + $this->handler = $handler; |
|
24 | + } |
|
25 | + |
|
26 | + /* |
|
27 | 27 | * Returns permissions for a certain type |
28 | 28 | * |
29 | 29 | * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know) |
@@ -31,74 +31,74 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - /** |
|
35 | - * @param $gperm_name |
|
36 | - * @param null $id |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function getGrantedGroups($gperm_name, $id = null) |
|
40 | - { |
|
41 | - static $groups; |
|
42 | - |
|
43 | - if (!isset($groups[$gperm_name]) || ($id !== null && !isset($groups[$gperm_name][$id]))) { |
|
44 | - $smartModule = $this->handler->getModuleInfo(); |
|
45 | - //Get group permissions handler |
|
46 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
47 | - |
|
48 | - //Get groups allowed for an item id |
|
49 | - $allowedgroups = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid')); |
|
50 | - $groups[$gperm_name][$id] = $allowedgroups; |
|
51 | - } |
|
52 | - |
|
53 | - //Return the permission array |
|
54 | - return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : array(); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param $item_ids_array |
|
59 | - * @param bool $gperm_name |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) |
|
63 | - { |
|
64 | - static $groups; |
|
65 | - |
|
66 | - if ($gperm_name) { |
|
67 | - if (isset($groups[$gperm_name])) { |
|
68 | - return $groups[$gperm_name]; |
|
69 | - } |
|
70 | - } else { |
|
71 | - // if !$gperm_name then we will fetch all permissions in the module so we don't need them again |
|
72 | - return $groups; |
|
73 | - } |
|
74 | - |
|
75 | - $smartModule = $this->handler->getModuleInfo(); |
|
76 | - |
|
77 | - $criteria = new CriteriaCompo(); |
|
78 | - $criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid'))); |
|
79 | - |
|
80 | - if ($gperm_name) { |
|
81 | - $criteria->add(new Criteria('gperm_name', $gperm_name)); |
|
82 | - } |
|
83 | - |
|
84 | - //Get group permissions handler |
|
85 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
86 | - |
|
87 | - $permissionsObj = $gpermHandler->getObjects($criteria); |
|
88 | - |
|
89 | - foreach ($permissionsObj as $permissionObj) { |
|
90 | - $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); |
|
91 | - } |
|
92 | - |
|
93 | - //Return the permission array |
|
94 | - if ($gperm_name) { |
|
95 | - return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array(); |
|
96 | - } else { |
|
97 | - return isset($groups) ? $groups : array(); |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - /* |
|
34 | + /** |
|
35 | + * @param $gperm_name |
|
36 | + * @param null $id |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function getGrantedGroups($gperm_name, $id = null) |
|
40 | + { |
|
41 | + static $groups; |
|
42 | + |
|
43 | + if (!isset($groups[$gperm_name]) || ($id !== null && !isset($groups[$gperm_name][$id]))) { |
|
44 | + $smartModule = $this->handler->getModuleInfo(); |
|
45 | + //Get group permissions handler |
|
46 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
47 | + |
|
48 | + //Get groups allowed for an item id |
|
49 | + $allowedgroups = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid')); |
|
50 | + $groups[$gperm_name][$id] = $allowedgroups; |
|
51 | + } |
|
52 | + |
|
53 | + //Return the permission array |
|
54 | + return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : array(); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param $item_ids_array |
|
59 | + * @param bool $gperm_name |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) |
|
63 | + { |
|
64 | + static $groups; |
|
65 | + |
|
66 | + if ($gperm_name) { |
|
67 | + if (isset($groups[$gperm_name])) { |
|
68 | + return $groups[$gperm_name]; |
|
69 | + } |
|
70 | + } else { |
|
71 | + // if !$gperm_name then we will fetch all permissions in the module so we don't need them again |
|
72 | + return $groups; |
|
73 | + } |
|
74 | + |
|
75 | + $smartModule = $this->handler->getModuleInfo(); |
|
76 | + |
|
77 | + $criteria = new CriteriaCompo(); |
|
78 | + $criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid'))); |
|
79 | + |
|
80 | + if ($gperm_name) { |
|
81 | + $criteria->add(new Criteria('gperm_name', $gperm_name)); |
|
82 | + } |
|
83 | + |
|
84 | + //Get group permissions handler |
|
85 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
86 | + |
|
87 | + $permissionsObj = $gpermHandler->getObjects($criteria); |
|
88 | + |
|
89 | + foreach ($permissionsObj as $permissionObj) { |
|
90 | + $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); |
|
91 | + } |
|
92 | + |
|
93 | + //Return the permission array |
|
94 | + if ($gperm_name) { |
|
95 | + return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array(); |
|
96 | + } else { |
|
97 | + return isset($groups) ? $groups : array(); |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + /* |
|
102 | 102 | * Returns permissions for a certain type |
103 | 103 | * |
104 | 104 | * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know) |
@@ -106,123 +106,123 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return array |
108 | 108 | */ |
109 | - /** |
|
110 | - * @param $gperm_name |
|
111 | - * @param null $id |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public function getGrantedItems($gperm_name, $id = null) |
|
115 | - { |
|
116 | - global $xoopsUser; |
|
117 | - static $permissions; |
|
118 | - |
|
119 | - if (!isset($permissions[$gperm_name]) || ($id !== null && !isset($permissions[$gperm_name][$id]))) { |
|
120 | - $smartModule = $this->handler->getModuleInfo(); |
|
121 | - |
|
122 | - if (is_object($smartModule)) { |
|
123 | - |
|
124 | - //Get group permissions handler |
|
125 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
126 | - |
|
127 | - //Get user's groups |
|
128 | - $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); |
|
129 | - |
|
130 | - //Get all allowed item ids in this module and for this user's groups |
|
131 | - $userpermissions = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid')); |
|
132 | - $permissions[$gperm_name] = $userpermissions; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - //Return the permission array |
|
137 | - return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : array(); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param $id |
|
142 | - */ |
|
143 | - public function storeAllPermissionsForId($id) |
|
144 | - { |
|
145 | - foreach ($this->handler->getPermissions() as $permission) { |
|
146 | - $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Saves permissions for the selected item |
|
152 | - * |
|
153 | - * saveItem_Permissions() |
|
154 | - * |
|
155 | - * @param array $groups : group with granted permission |
|
156 | - * @param int $itemid categoryID on which we are setting permissions for Categories and Forums |
|
157 | - * @param string $perm_name : name of the permission |
|
158 | - * @return bool : TRUE if the no errors occured |
|
159 | - */ |
|
160 | - |
|
161 | - public function saveItem_Permissions($groups, $itemid, $perm_name) |
|
162 | - { |
|
163 | - $smartModule = $this->handler->getModuleInfo(); |
|
164 | - |
|
165 | - $result = true; |
|
166 | - $module_id = $smartModule->getVar('mid'); |
|
167 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
168 | - |
|
169 | - // First, if the permissions are already there, delete them |
|
170 | - $gpermHandler->deleteByModule($module_id, $perm_name, $itemid); |
|
171 | - //echo "itemid: $itemid - perm: $perm_name - modid: $module_id"; |
|
172 | - //exit; |
|
173 | - // Save the new permissions |
|
174 | - |
|
175 | - if (count($groups) > 0) { |
|
176 | - foreach ($groups as $group_id) { |
|
177 | - $gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id); |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - return $result; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Delete all permission for a specific item |
|
186 | - * |
|
187 | - * deletePermissions() |
|
188 | - * |
|
189 | - * @param integer $itemid : id of the item for which to delete the permissions |
|
190 | - * @param $gperm_name |
|
191 | - * @return bool: TRUE if the no errors occured |
|
192 | - */ |
|
193 | - public function deletePermissions($itemid, $gperm_name) |
|
194 | - { |
|
195 | - global $xoopsModule; |
|
196 | - |
|
197 | - $smartModule =& smartsection_getModuleInfo(); |
|
198 | - |
|
199 | - $result = true; |
|
200 | - $module_id = $smartModule->getVar('mid'); |
|
201 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
202 | - |
|
203 | - $gpermHandler->deleteByModule($module_id, $gperm_name, $itemid); |
|
204 | - |
|
205 | - return $result; |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Checks if the user has access to a specific permission on a given object |
|
210 | - * |
|
211 | - * @param string $gperm_name name of the permission to test |
|
212 | - * @param int $gperm_itemid id of the object to check |
|
213 | - * @return boolean: TRUE if user has access, FALSE if not |
|
214 | - **/ |
|
215 | - public function accessGranted($gperm_name, $gperm_itemid) |
|
216 | - { |
|
217 | - global $xoopsUser; |
|
218 | - |
|
219 | - $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); |
|
220 | - $smartModule = $this->handler->getModuleInfo(); |
|
221 | - $gperm_modid = $smartModule->getVar('mid'); |
|
222 | - |
|
223 | - //Get group permissions handler |
|
224 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
225 | - |
|
226 | - return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid); |
|
227 | - } |
|
109 | + /** |
|
110 | + * @param $gperm_name |
|
111 | + * @param null $id |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public function getGrantedItems($gperm_name, $id = null) |
|
115 | + { |
|
116 | + global $xoopsUser; |
|
117 | + static $permissions; |
|
118 | + |
|
119 | + if (!isset($permissions[$gperm_name]) || ($id !== null && !isset($permissions[$gperm_name][$id]))) { |
|
120 | + $smartModule = $this->handler->getModuleInfo(); |
|
121 | + |
|
122 | + if (is_object($smartModule)) { |
|
123 | + |
|
124 | + //Get group permissions handler |
|
125 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
126 | + |
|
127 | + //Get user's groups |
|
128 | + $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); |
|
129 | + |
|
130 | + //Get all allowed item ids in this module and for this user's groups |
|
131 | + $userpermissions = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid')); |
|
132 | + $permissions[$gperm_name] = $userpermissions; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + //Return the permission array |
|
137 | + return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : array(); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param $id |
|
142 | + */ |
|
143 | + public function storeAllPermissionsForId($id) |
|
144 | + { |
|
145 | + foreach ($this->handler->getPermissions() as $permission) { |
|
146 | + $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Saves permissions for the selected item |
|
152 | + * |
|
153 | + * saveItem_Permissions() |
|
154 | + * |
|
155 | + * @param array $groups : group with granted permission |
|
156 | + * @param int $itemid categoryID on which we are setting permissions for Categories and Forums |
|
157 | + * @param string $perm_name : name of the permission |
|
158 | + * @return bool : TRUE if the no errors occured |
|
159 | + */ |
|
160 | + |
|
161 | + public function saveItem_Permissions($groups, $itemid, $perm_name) |
|
162 | + { |
|
163 | + $smartModule = $this->handler->getModuleInfo(); |
|
164 | + |
|
165 | + $result = true; |
|
166 | + $module_id = $smartModule->getVar('mid'); |
|
167 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
168 | + |
|
169 | + // First, if the permissions are already there, delete them |
|
170 | + $gpermHandler->deleteByModule($module_id, $perm_name, $itemid); |
|
171 | + //echo "itemid: $itemid - perm: $perm_name - modid: $module_id"; |
|
172 | + //exit; |
|
173 | + // Save the new permissions |
|
174 | + |
|
175 | + if (count($groups) > 0) { |
|
176 | + foreach ($groups as $group_id) { |
|
177 | + $gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id); |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + return $result; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Delete all permission for a specific item |
|
186 | + * |
|
187 | + * deletePermissions() |
|
188 | + * |
|
189 | + * @param integer $itemid : id of the item for which to delete the permissions |
|
190 | + * @param $gperm_name |
|
191 | + * @return bool: TRUE if the no errors occured |
|
192 | + */ |
|
193 | + public function deletePermissions($itemid, $gperm_name) |
|
194 | + { |
|
195 | + global $xoopsModule; |
|
196 | + |
|
197 | + $smartModule =& smartsection_getModuleInfo(); |
|
198 | + |
|
199 | + $result = true; |
|
200 | + $module_id = $smartModule->getVar('mid'); |
|
201 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
202 | + |
|
203 | + $gpermHandler->deleteByModule($module_id, $gperm_name, $itemid); |
|
204 | + |
|
205 | + return $result; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Checks if the user has access to a specific permission on a given object |
|
210 | + * |
|
211 | + * @param string $gperm_name name of the permission to test |
|
212 | + * @param int $gperm_itemid id of the object to check |
|
213 | + * @return boolean: TRUE if user has access, FALSE if not |
|
214 | + **/ |
|
215 | + public function accessGranted($gperm_name, $gperm_itemid) |
|
216 | + { |
|
217 | + global $xoopsUser; |
|
218 | + |
|
219 | + $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); |
|
220 | + $smartModule = $this->handler->getModuleInfo(); |
|
221 | + $gperm_modid = $smartModule->getVar('mid'); |
|
222 | + |
|
223 | + //Get group permissions handler |
|
224 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
225 | + |
|
226 | + return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid); |
|
227 | + } |
|
228 | 228 | } |
@@ -15,65 +15,65 @@ |
||
15 | 15 | */ |
16 | 16 | class SmartPrinterFriendly |
17 | 17 | { |
18 | - public $_title; |
|
19 | - public $_dsc; |
|
20 | - public $_content; |
|
21 | - public $_tpl; |
|
22 | - public $_pageTitle = false; |
|
23 | - public $_width = 680; |
|
18 | + public $_title; |
|
19 | + public $_dsc; |
|
20 | + public $_content; |
|
21 | + public $_tpl; |
|
22 | + public $_pageTitle = false; |
|
23 | + public $_width = 680; |
|
24 | 24 | |
25 | - /** |
|
26 | - * SmartPrinterFriendly constructor. |
|
27 | - * @param $content |
|
28 | - * @param bool $title |
|
29 | - * @param bool $dsc |
|
30 | - */ |
|
31 | - public function __construct($content, $title = false, $dsc = false) |
|
32 | - { |
|
33 | - $this->_title = $title; |
|
34 | - $this->_dsc = $dsc; |
|
35 | - $this->_content = $content; |
|
36 | - } |
|
25 | + /** |
|
26 | + * SmartPrinterFriendly constructor. |
|
27 | + * @param $content |
|
28 | + * @param bool $title |
|
29 | + * @param bool $dsc |
|
30 | + */ |
|
31 | + public function __construct($content, $title = false, $dsc = false) |
|
32 | + { |
|
33 | + $this->_title = $title; |
|
34 | + $this->_dsc = $dsc; |
|
35 | + $this->_content = $content; |
|
36 | + } |
|
37 | 37 | |
38 | - public function render() |
|
39 | - { |
|
40 | - /** |
|
41 | - * @todo move the output to a template |
|
42 | - * @todo make the output XHTML compliant |
|
43 | - */ |
|
38 | + public function render() |
|
39 | + { |
|
40 | + /** |
|
41 | + * @todo move the output to a template |
|
42 | + * @todo make the output XHTML compliant |
|
43 | + */ |
|
44 | 44 | |
45 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
45 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
46 | 46 | |
47 | - $this->_tpl = new XoopsTpl(); |
|
47 | + $this->_tpl = new XoopsTpl(); |
|
48 | 48 | |
49 | - $this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title); |
|
50 | - $this->_tpl->assign('smartobject_print_title', $this->_title); |
|
51 | - $this->_tpl->assign('smartobject_print_dsc', $this->_dsc); |
|
52 | - $this->_tpl->assign('smartobject_print_content', $this->_content); |
|
53 | - $this->_tpl->assign('smartobject_print_width', $this->_width); |
|
49 | + $this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title); |
|
50 | + $this->_tpl->assign('smartobject_print_title', $this->_title); |
|
51 | + $this->_tpl->assign('smartobject_print_dsc', $this->_dsc); |
|
52 | + $this->_tpl->assign('smartobject_print_content', $this->_content); |
|
53 | + $this->_tpl->assign('smartobject_print_width', $this->_width); |
|
54 | 54 | |
55 | - $current_urls = smart_getCurrentUrls(); |
|
56 | - $current_url = $current_urls['full']; |
|
55 | + $current_urls = smart_getCurrentUrls(); |
|
56 | + $current_url = $current_urls['full']; |
|
57 | 57 | |
58 | - $this->_tpl->assign('smartobject_print_currenturl', $current_url); |
|
59 | - $this->_tpl->assign('smartobject_print_url', $this->url); |
|
58 | + $this->_tpl->assign('smartobject_print_currenturl', $current_url); |
|
59 | + $this->_tpl->assign('smartobject_print_url', $this->url); |
|
60 | 60 | |
61 | - $this->_tpl->display('db:smartobject_print.tpl'); |
|
62 | - } |
|
61 | + $this->_tpl->display('db:smartobject_print.tpl'); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param $text |
|
66 | - */ |
|
67 | - public function setPageTitle($text) |
|
68 | - { |
|
69 | - $this->_pageTitle = $text; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @param $text |
|
66 | + */ |
|
67 | + public function setPageTitle($text) |
|
68 | + { |
|
69 | + $this->_pageTitle = $text; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param $width |
|
74 | - */ |
|
75 | - public function setWidth($width) |
|
76 | - { |
|
77 | - $this->_width = $width; |
|
78 | - } |
|
72 | + /** |
|
73 | + * @param $width |
|
74 | + */ |
|
75 | + public function setWidth($width) |
|
76 | + { |
|
77 | + $this->_width = $width; |
|
78 | + } |
|
79 | 79 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @todo make the output XHTML compliant |
43 | 43 | */ |
44 | 44 | |
45 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
45 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
46 | 46 | |
47 | 47 | $this->_tpl = new XoopsTpl(); |
48 | 48 |
@@ -18,350 +18,350 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class SmartMetaGen |
20 | 20 | { |
21 | - public $_myts; |
|
22 | - |
|
23 | - public $_title; |
|
24 | - public $_original_title; |
|
25 | - public $_keywords; |
|
26 | - public $_meta_description; |
|
27 | - public $_categoryPath; |
|
28 | - public $_description; |
|
29 | - public $_minChar = 4; |
|
30 | - |
|
31 | - /** |
|
32 | - * SmartMetaGen constructor. |
|
33 | - * @param $title |
|
34 | - * @param bool $keywords |
|
35 | - * @param bool $description |
|
36 | - * @param bool $categoryPath |
|
37 | - */ |
|
38 | - public function __construct($title, $keywords = false, $description = false, $categoryPath = false) |
|
39 | - { |
|
40 | - $this->_myts = MyTextSanitizer::getInstance(); |
|
41 | - $this->setCategoryPath($categoryPath); |
|
42 | - $this->setTitle($title); |
|
43 | - $this->setDescription($description); |
|
44 | - |
|
45 | - if (!$keywords) { |
|
46 | - $keywords = $this->createMetaKeywords(); |
|
47 | - } |
|
48 | - |
|
49 | - /* $myts = MyTextSanitizer::getInstance(); |
|
21 | + public $_myts; |
|
22 | + |
|
23 | + public $_title; |
|
24 | + public $_original_title; |
|
25 | + public $_keywords; |
|
26 | + public $_meta_description; |
|
27 | + public $_categoryPath; |
|
28 | + public $_description; |
|
29 | + public $_minChar = 4; |
|
30 | + |
|
31 | + /** |
|
32 | + * SmartMetaGen constructor. |
|
33 | + * @param $title |
|
34 | + * @param bool $keywords |
|
35 | + * @param bool $description |
|
36 | + * @param bool $categoryPath |
|
37 | + */ |
|
38 | + public function __construct($title, $keywords = false, $description = false, $categoryPath = false) |
|
39 | + { |
|
40 | + $this->_myts = MyTextSanitizer::getInstance(); |
|
41 | + $this->setCategoryPath($categoryPath); |
|
42 | + $this->setTitle($title); |
|
43 | + $this->setDescription($description); |
|
44 | + |
|
45 | + if (!$keywords) { |
|
46 | + $keywords = $this->createMetaKeywords(); |
|
47 | + } |
|
48 | + |
|
49 | + /* $myts = MyTextSanitizer::getInstance(); |
|
50 | 50 | if (method_exists($myts, 'formatForML')) { |
51 | 51 | $keywords = $myts->formatForML($keywords); |
52 | 52 | $description = $myts->formatForML($description); |
53 | 53 | } |
54 | 54 | */ |
55 | - $this->setKeywords($keywords); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Return true if the string is length > 0 |
|
60 | - * |
|
61 | - * @credit psylove |
|
62 | - * |
|
63 | - * @var string $string Chaine de caract�re |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function emptyString($var) |
|
67 | - { |
|
68 | - return (strlen($var) > 0); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Create a title for the short_url field of an article |
|
73 | - * |
|
74 | - * @credit psylove |
|
75 | - * |
|
76 | - * @var string $title title of the article |
|
77 | - * @param bool|string $withExt |
|
78 | - * @return string sort_url for the article |
|
79 | - */ |
|
80 | - public function generateSeoTitle($title = '', $withExt = true) |
|
81 | - { |
|
82 | - // Transformation de la chaine en minuscule |
|
83 | - // Codage de la chaine afin d'éviter les erreurs 500 en cas de caractères imprévus |
|
84 | - $title = rawurlencode(strtolower($title)); |
|
85 | - |
|
86 | - // Transformation des ponctuations |
|
87 | - $pattern = array( |
|
88 | - '/%09/', // Tab |
|
89 | - '/%20/', // Space |
|
90 | - '/%21/', // ! |
|
91 | - '/%22/', // " |
|
92 | - '/%23/', // # |
|
93 | - '/%25/', // % |
|
94 | - '/%26/', // & |
|
95 | - '/%27/', // ' |
|
96 | - '/%28/', // ( |
|
97 | - '/%29/', // ) |
|
98 | - '/%2C/', // , |
|
99 | - '/%2F/', // / |
|
100 | - '/%3A/', // : |
|
101 | - '/%3B/', // ; |
|
102 | - '/%3C/', // < |
|
103 | - '/%3D/', // = |
|
104 | - '/%3E/', // > |
|
105 | - '/%3F/', // ? |
|
106 | - '/%40/', // @ |
|
107 | - '/%5B/', // [ |
|
108 | - '/%5C/', // \ |
|
109 | - '/%5D/', // ] |
|
110 | - '/%5E/', // ^ |
|
111 | - '/%7B/', // { |
|
112 | - '/%7C/', // | |
|
113 | - '/%7D/', // } |
|
114 | - '/%7E/', // ~ |
|
115 | - "/\./" // . |
|
116 | - ); |
|
117 | - $rep_pat = array( |
|
118 | - '-', |
|
119 | - '-', |
|
120 | - '-', |
|
121 | - '-', |
|
122 | - '-', |
|
123 | - '-100', |
|
124 | - '-', |
|
125 | - '-', |
|
126 | - '-', |
|
127 | - '-', |
|
128 | - '-', |
|
129 | - '-', |
|
130 | - '-', |
|
131 | - '-', |
|
132 | - '-', |
|
133 | - '-', |
|
134 | - '-', |
|
135 | - '-', |
|
136 | - '-at-', |
|
137 | - '-', |
|
138 | - '-', |
|
139 | - '-', |
|
140 | - '-', |
|
141 | - '-', |
|
142 | - '-', |
|
143 | - '-', |
|
144 | - '-', |
|
145 | - '-' |
|
146 | - ); |
|
147 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
148 | - |
|
149 | - // Transformation des caractères accentués |
|
150 | - $pattern = array( |
|
151 | - '/%B0/', // ° |
|
152 | - '/%E8/', // è |
|
153 | - '/%E9/', // é |
|
154 | - '/%EA/', // ê |
|
155 | - '/%EB/', // ë |
|
156 | - '/%E7/', // ç |
|
157 | - '/%E0/', // à |
|
158 | - '/%E2/', // â |
|
159 | - '/%E4/', // ä |
|
160 | - '/%EE/', // î |
|
161 | - '/%EF/', // ï |
|
162 | - '/%F9/', // ù |
|
163 | - '/%FC/', // ü |
|
164 | - '/%FB/', // û |
|
165 | - '/%F4/', // ô |
|
166 | - '/%F6/', // ö |
|
167 | - ); |
|
168 | - $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'); |
|
169 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
170 | - |
|
171 | - $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
172 | - $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau |
|
173 | - $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
174 | - |
|
175 | - if (count($title) > 0) { |
|
176 | - if ($withExt) { |
|
177 | - $title .= '.html'; |
|
178 | - } |
|
179 | - |
|
180 | - return $title; |
|
181 | - } else { |
|
182 | - return ''; |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * @param $document |
|
188 | - * @return mixed |
|
189 | - */ |
|
190 | - public function html2text($document) |
|
191 | - { |
|
192 | - return smart_html2text($document); |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * @param $title |
|
197 | - */ |
|
198 | - public function setTitle($title) |
|
199 | - { |
|
200 | - global $xoopsModule, $xoopsModuleConfig; |
|
201 | - $this->_title = $this->html2text($title); |
|
202 | - $this->_title = $this->purifyText($this->_title); |
|
203 | - $this->_original_title = $this->_title; |
|
204 | - |
|
205 | - $moduleName = $xoopsModule->getVar('name'); |
|
206 | - |
|
207 | - $titleTag = array(); |
|
208 | - |
|
209 | - $show_mod_name_breadcrumb = isset($xoopsModuleConfig['show_mod_name_breadcrumb']) ? $xoopsModuleConfig['show_mod_name_breadcrumb'] : true; |
|
210 | - |
|
211 | - if ($moduleName && $show_mod_name_breadcrumb) { |
|
212 | - $titleTag['module'] = $moduleName; |
|
213 | - } |
|
214 | - |
|
215 | - if (isset($this->_title) && ($this->_title !== '') && (strtoupper($this->_title) != strtoupper($moduleName))) { |
|
216 | - $titleTag['title'] = $this->_title; |
|
217 | - } |
|
218 | - |
|
219 | - if (isset($this->_categoryPath) && ($this->_categoryPath !== '')) { |
|
220 | - $titleTag['category'] = $this->_categoryPath; |
|
221 | - } |
|
222 | - |
|
223 | - $ret = isset($titleTag['title']) ? $titleTag['title'] : ''; |
|
224 | - |
|
225 | - if (isset($titleTag['category']) && $titleTag['category'] !== '') { |
|
226 | - if ($ret !== '') { |
|
227 | - $ret .= ' - '; |
|
228 | - } |
|
229 | - $ret .= $titleTag['category']; |
|
230 | - } |
|
231 | - if (isset($titleTag['module']) && $titleTag['module'] !== '') { |
|
232 | - if ($ret !== '') { |
|
233 | - $ret .= ' - '; |
|
234 | - } |
|
235 | - $ret .= $titleTag['module']; |
|
236 | - } |
|
237 | - $this->_title = $ret; |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @param $keywords |
|
242 | - */ |
|
243 | - public function setKeywords($keywords) |
|
244 | - { |
|
245 | - $this->_keywords = $keywords; |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * @param $categoryPath |
|
250 | - */ |
|
251 | - public function setCategoryPath($categoryPath) |
|
252 | - { |
|
253 | - $categoryPath = $this->html2text($categoryPath); |
|
254 | - $this->_categoryPath = $categoryPath; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * @param $description |
|
259 | - */ |
|
260 | - public function setDescription($description) |
|
261 | - { |
|
262 | - if (!$description) { |
|
263 | - global $xoopsModuleConfig; |
|
264 | - if (isset($xoopsModuleConfig['module_meta_description'])) { |
|
265 | - $description = $xoopsModuleConfig['module_meta_description']; |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - $description = $this->html2text($description); |
|
270 | - $description = $this->purifyText($description); |
|
271 | - |
|
272 | - $description = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $description); |
|
273 | - $description = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $description); |
|
274 | - $description = preg_replace('/[ ]* [ ]*/', ' ', $description); |
|
275 | - $description = stripslashes($description); |
|
276 | - |
|
277 | - $this->_description = $description; |
|
278 | - $this->_meta_description = $this->createMetaDescription(); |
|
279 | - } |
|
280 | - |
|
281 | - public function createTitleTag() |
|
282 | - { |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * @param $text |
|
287 | - * @param bool $keyword |
|
288 | - * @return mixed|string |
|
289 | - */ |
|
290 | - public function purifyText($text, $keyword = false) |
|
291 | - { |
|
292 | - return smart_purifyText($text, $keyword); |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * @param int $maxWords |
|
297 | - * @return string |
|
298 | - */ |
|
299 | - public function createMetaDescription($maxWords = 100) |
|
300 | - { |
|
301 | - $words = array(); |
|
302 | - $words = explode(' ', $this->_description); |
|
303 | - |
|
304 | - // Only keep $maxWords words |
|
305 | - $newWords = array(); |
|
306 | - $i = 0; |
|
307 | - |
|
308 | - while ($i < $maxWords - 1 && $i < count($words)) { |
|
309 | - $newWords[] = $words[$i]; |
|
310 | - ++$i; |
|
311 | - } |
|
312 | - $ret = implode(' ', $newWords); |
|
313 | - |
|
314 | - return $ret; |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @param $text |
|
319 | - * @param $minChar |
|
320 | - * @return array |
|
321 | - */ |
|
322 | - public function findMetaKeywords($text, $minChar) |
|
323 | - { |
|
324 | - $keywords = array(); |
|
325 | - |
|
326 | - $text = $this->purifyText($text); |
|
327 | - $text = $this->html2text($text); |
|
328 | - |
|
329 | - $text = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $text); |
|
330 | - $text = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $text); |
|
331 | - $text = preg_replace('/[ ]* [ ]*/', ' ', $text); |
|
332 | - $text = stripslashes($text); |
|
333 | - $text = |
|
334 | - |
|
335 | - $originalKeywords = preg_split('/[^a-zA-Z\'"-]+/', $text, -1, PREG_SPLIT_NO_EMPTY); |
|
336 | - |
|
337 | - foreach ($originalKeywords as $originalKeyword) { |
|
338 | - $secondRoundKeywords = explode("'", $originalKeyword); |
|
339 | - foreach ($secondRoundKeywords as $secondRoundKeyword) { |
|
340 | - if (strlen($secondRoundKeyword) >= $minChar) { |
|
341 | - if (!in_array($secondRoundKeyword, $keywords)) { |
|
342 | - $keywords[] = trim($secondRoundKeyword); |
|
343 | - } |
|
344 | - } |
|
345 | - } |
|
346 | - } |
|
347 | - |
|
348 | - return $keywords; |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * @return string |
|
353 | - */ |
|
354 | - public function createMetaKeywords() |
|
355 | - { |
|
356 | - global $xoopsModuleConfig; |
|
357 | - $keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar); |
|
358 | - if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) |
|
359 | - && $xoopsModuleConfig['moduleMetaKeywords'] !== '') { |
|
360 | - $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']); |
|
361 | - $keywords = array_merge($keywords, $moduleKeywords); |
|
362 | - } |
|
363 | - |
|
364 | - /* Commenting this out as it may cause problem on XOOPS ML websites |
|
55 | + $this->setKeywords($keywords); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Return true if the string is length > 0 |
|
60 | + * |
|
61 | + * @credit psylove |
|
62 | + * |
|
63 | + * @var string $string Chaine de caract�re |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function emptyString($var) |
|
67 | + { |
|
68 | + return (strlen($var) > 0); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Create a title for the short_url field of an article |
|
73 | + * |
|
74 | + * @credit psylove |
|
75 | + * |
|
76 | + * @var string $title title of the article |
|
77 | + * @param bool|string $withExt |
|
78 | + * @return string sort_url for the article |
|
79 | + */ |
|
80 | + public function generateSeoTitle($title = '', $withExt = true) |
|
81 | + { |
|
82 | + // Transformation de la chaine en minuscule |
|
83 | + // Codage de la chaine afin d'éviter les erreurs 500 en cas de caractères imprévus |
|
84 | + $title = rawurlencode(strtolower($title)); |
|
85 | + |
|
86 | + // Transformation des ponctuations |
|
87 | + $pattern = array( |
|
88 | + '/%09/', // Tab |
|
89 | + '/%20/', // Space |
|
90 | + '/%21/', // ! |
|
91 | + '/%22/', // " |
|
92 | + '/%23/', // # |
|
93 | + '/%25/', // % |
|
94 | + '/%26/', // & |
|
95 | + '/%27/', // ' |
|
96 | + '/%28/', // ( |
|
97 | + '/%29/', // ) |
|
98 | + '/%2C/', // , |
|
99 | + '/%2F/', // / |
|
100 | + '/%3A/', // : |
|
101 | + '/%3B/', // ; |
|
102 | + '/%3C/', // < |
|
103 | + '/%3D/', // = |
|
104 | + '/%3E/', // > |
|
105 | + '/%3F/', // ? |
|
106 | + '/%40/', // @ |
|
107 | + '/%5B/', // [ |
|
108 | + '/%5C/', // \ |
|
109 | + '/%5D/', // ] |
|
110 | + '/%5E/', // ^ |
|
111 | + '/%7B/', // { |
|
112 | + '/%7C/', // | |
|
113 | + '/%7D/', // } |
|
114 | + '/%7E/', // ~ |
|
115 | + "/\./" // . |
|
116 | + ); |
|
117 | + $rep_pat = array( |
|
118 | + '-', |
|
119 | + '-', |
|
120 | + '-', |
|
121 | + '-', |
|
122 | + '-', |
|
123 | + '-100', |
|
124 | + '-', |
|
125 | + '-', |
|
126 | + '-', |
|
127 | + '-', |
|
128 | + '-', |
|
129 | + '-', |
|
130 | + '-', |
|
131 | + '-', |
|
132 | + '-', |
|
133 | + '-', |
|
134 | + '-', |
|
135 | + '-', |
|
136 | + '-at-', |
|
137 | + '-', |
|
138 | + '-', |
|
139 | + '-', |
|
140 | + '-', |
|
141 | + '-', |
|
142 | + '-', |
|
143 | + '-', |
|
144 | + '-', |
|
145 | + '-' |
|
146 | + ); |
|
147 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
148 | + |
|
149 | + // Transformation des caractères accentués |
|
150 | + $pattern = array( |
|
151 | + '/%B0/', // ° |
|
152 | + '/%E8/', // è |
|
153 | + '/%E9/', // é |
|
154 | + '/%EA/', // ê |
|
155 | + '/%EB/', // ë |
|
156 | + '/%E7/', // ç |
|
157 | + '/%E0/', // à |
|
158 | + '/%E2/', // â |
|
159 | + '/%E4/', // ä |
|
160 | + '/%EE/', // î |
|
161 | + '/%EF/', // ï |
|
162 | + '/%F9/', // ù |
|
163 | + '/%FC/', // ü |
|
164 | + '/%FB/', // û |
|
165 | + '/%F4/', // ô |
|
166 | + '/%F6/', // ö |
|
167 | + ); |
|
168 | + $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'); |
|
169 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
170 | + |
|
171 | + $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
172 | + $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau |
|
173 | + $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
174 | + |
|
175 | + if (count($title) > 0) { |
|
176 | + if ($withExt) { |
|
177 | + $title .= '.html'; |
|
178 | + } |
|
179 | + |
|
180 | + return $title; |
|
181 | + } else { |
|
182 | + return ''; |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * @param $document |
|
188 | + * @return mixed |
|
189 | + */ |
|
190 | + public function html2text($document) |
|
191 | + { |
|
192 | + return smart_html2text($document); |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * @param $title |
|
197 | + */ |
|
198 | + public function setTitle($title) |
|
199 | + { |
|
200 | + global $xoopsModule, $xoopsModuleConfig; |
|
201 | + $this->_title = $this->html2text($title); |
|
202 | + $this->_title = $this->purifyText($this->_title); |
|
203 | + $this->_original_title = $this->_title; |
|
204 | + |
|
205 | + $moduleName = $xoopsModule->getVar('name'); |
|
206 | + |
|
207 | + $titleTag = array(); |
|
208 | + |
|
209 | + $show_mod_name_breadcrumb = isset($xoopsModuleConfig['show_mod_name_breadcrumb']) ? $xoopsModuleConfig['show_mod_name_breadcrumb'] : true; |
|
210 | + |
|
211 | + if ($moduleName && $show_mod_name_breadcrumb) { |
|
212 | + $titleTag['module'] = $moduleName; |
|
213 | + } |
|
214 | + |
|
215 | + if (isset($this->_title) && ($this->_title !== '') && (strtoupper($this->_title) != strtoupper($moduleName))) { |
|
216 | + $titleTag['title'] = $this->_title; |
|
217 | + } |
|
218 | + |
|
219 | + if (isset($this->_categoryPath) && ($this->_categoryPath !== '')) { |
|
220 | + $titleTag['category'] = $this->_categoryPath; |
|
221 | + } |
|
222 | + |
|
223 | + $ret = isset($titleTag['title']) ? $titleTag['title'] : ''; |
|
224 | + |
|
225 | + if (isset($titleTag['category']) && $titleTag['category'] !== '') { |
|
226 | + if ($ret !== '') { |
|
227 | + $ret .= ' - '; |
|
228 | + } |
|
229 | + $ret .= $titleTag['category']; |
|
230 | + } |
|
231 | + if (isset($titleTag['module']) && $titleTag['module'] !== '') { |
|
232 | + if ($ret !== '') { |
|
233 | + $ret .= ' - '; |
|
234 | + } |
|
235 | + $ret .= $titleTag['module']; |
|
236 | + } |
|
237 | + $this->_title = $ret; |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @param $keywords |
|
242 | + */ |
|
243 | + public function setKeywords($keywords) |
|
244 | + { |
|
245 | + $this->_keywords = $keywords; |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * @param $categoryPath |
|
250 | + */ |
|
251 | + public function setCategoryPath($categoryPath) |
|
252 | + { |
|
253 | + $categoryPath = $this->html2text($categoryPath); |
|
254 | + $this->_categoryPath = $categoryPath; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * @param $description |
|
259 | + */ |
|
260 | + public function setDescription($description) |
|
261 | + { |
|
262 | + if (!$description) { |
|
263 | + global $xoopsModuleConfig; |
|
264 | + if (isset($xoopsModuleConfig['module_meta_description'])) { |
|
265 | + $description = $xoopsModuleConfig['module_meta_description']; |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + $description = $this->html2text($description); |
|
270 | + $description = $this->purifyText($description); |
|
271 | + |
|
272 | + $description = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $description); |
|
273 | + $description = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $description); |
|
274 | + $description = preg_replace('/[ ]* [ ]*/', ' ', $description); |
|
275 | + $description = stripslashes($description); |
|
276 | + |
|
277 | + $this->_description = $description; |
|
278 | + $this->_meta_description = $this->createMetaDescription(); |
|
279 | + } |
|
280 | + |
|
281 | + public function createTitleTag() |
|
282 | + { |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * @param $text |
|
287 | + * @param bool $keyword |
|
288 | + * @return mixed|string |
|
289 | + */ |
|
290 | + public function purifyText($text, $keyword = false) |
|
291 | + { |
|
292 | + return smart_purifyText($text, $keyword); |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * @param int $maxWords |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + public function createMetaDescription($maxWords = 100) |
|
300 | + { |
|
301 | + $words = array(); |
|
302 | + $words = explode(' ', $this->_description); |
|
303 | + |
|
304 | + // Only keep $maxWords words |
|
305 | + $newWords = array(); |
|
306 | + $i = 0; |
|
307 | + |
|
308 | + while ($i < $maxWords - 1 && $i < count($words)) { |
|
309 | + $newWords[] = $words[$i]; |
|
310 | + ++$i; |
|
311 | + } |
|
312 | + $ret = implode(' ', $newWords); |
|
313 | + |
|
314 | + return $ret; |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @param $text |
|
319 | + * @param $minChar |
|
320 | + * @return array |
|
321 | + */ |
|
322 | + public function findMetaKeywords($text, $minChar) |
|
323 | + { |
|
324 | + $keywords = array(); |
|
325 | + |
|
326 | + $text = $this->purifyText($text); |
|
327 | + $text = $this->html2text($text); |
|
328 | + |
|
329 | + $text = preg_replace("/([^\r\n])\r\n([^\r\n])/", "\\1 \\2", $text); |
|
330 | + $text = preg_replace("/[\r\n]*\r\n[\r\n]*/", "\r\n\r\n", $text); |
|
331 | + $text = preg_replace('/[ ]* [ ]*/', ' ', $text); |
|
332 | + $text = stripslashes($text); |
|
333 | + $text = |
|
334 | + |
|
335 | + $originalKeywords = preg_split('/[^a-zA-Z\'"-]+/', $text, -1, PREG_SPLIT_NO_EMPTY); |
|
336 | + |
|
337 | + foreach ($originalKeywords as $originalKeyword) { |
|
338 | + $secondRoundKeywords = explode("'", $originalKeyword); |
|
339 | + foreach ($secondRoundKeywords as $secondRoundKeyword) { |
|
340 | + if (strlen($secondRoundKeyword) >= $minChar) { |
|
341 | + if (!in_array($secondRoundKeyword, $keywords)) { |
|
342 | + $keywords[] = trim($secondRoundKeyword); |
|
343 | + } |
|
344 | + } |
|
345 | + } |
|
346 | + } |
|
347 | + |
|
348 | + return $keywords; |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * @return string |
|
353 | + */ |
|
354 | + public function createMetaKeywords() |
|
355 | + { |
|
356 | + global $xoopsModuleConfig; |
|
357 | + $keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar); |
|
358 | + if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) |
|
359 | + && $xoopsModuleConfig['moduleMetaKeywords'] !== '') { |
|
360 | + $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']); |
|
361 | + $keywords = array_merge($keywords, $moduleKeywords); |
|
362 | + } |
|
363 | + |
|
364 | + /* Commenting this out as it may cause problem on XOOPS ML websites |
|
365 | 365 | $return_keywords = array(); |
366 | 366 | |
367 | 367 | // Cleaning for duplicate keywords |
@@ -371,43 +371,43 @@ discard block |
||
371 | 371 | } |
372 | 372 | }*/ |
373 | 373 | |
374 | - // Only take the first 90 keywords |
|
375 | - $newKeywords = array(); |
|
376 | - $i = 0; |
|
377 | - while ($i < 90 - 1 && isset($keywords[$i])) { |
|
378 | - $newKeywords[] = $keywords[$i]; |
|
379 | - ++$i; |
|
380 | - } |
|
381 | - $ret = implode(', ', $newKeywords); |
|
382 | - |
|
383 | - return $ret; |
|
384 | - } |
|
385 | - |
|
386 | - public function autoBuildMeta_keywords() |
|
387 | - { |
|
388 | - } |
|
389 | - |
|
390 | - public function buildAutoMetaTags() |
|
391 | - { |
|
392 | - global $xoopsModule, $xoopsModuleConfig; |
|
393 | - |
|
394 | - $this->_keywords = $this->createMetaKeywords(); |
|
395 | - $this->_meta_description = $this->createMetaDescription(); |
|
396 | - $this->_title = $this->createTitleTag(); |
|
397 | - } |
|
398 | - |
|
399 | - public function createMetaTags() |
|
400 | - { |
|
401 | - global $xoopsTpl, $xoTheme; |
|
402 | - |
|
403 | - if (is_object($xoTheme)) { |
|
404 | - $xoTheme->addMeta('meta', 'keywords', $this->_keywords); |
|
405 | - $xoTheme->addMeta('meta', 'description', $this->_description); |
|
406 | - $xoTheme->addMeta('meta', 'title', $this->_title); |
|
407 | - } else { |
|
408 | - $xoopsTpl->assign('xoops_meta_keywords', $this->_keywords); |
|
409 | - $xoopsTpl->assign('xoops_meta_description', $this->_description); |
|
410 | - } |
|
411 | - $xoopsTpl->assign('xoops_pagetitle', $this->_title); |
|
412 | - } |
|
374 | + // Only take the first 90 keywords |
|
375 | + $newKeywords = array(); |
|
376 | + $i = 0; |
|
377 | + while ($i < 90 - 1 && isset($keywords[$i])) { |
|
378 | + $newKeywords[] = $keywords[$i]; |
|
379 | + ++$i; |
|
380 | + } |
|
381 | + $ret = implode(', ', $newKeywords); |
|
382 | + |
|
383 | + return $ret; |
|
384 | + } |
|
385 | + |
|
386 | + public function autoBuildMeta_keywords() |
|
387 | + { |
|
388 | + } |
|
389 | + |
|
390 | + public function buildAutoMetaTags() |
|
391 | + { |
|
392 | + global $xoopsModule, $xoopsModuleConfig; |
|
393 | + |
|
394 | + $this->_keywords = $this->createMetaKeywords(); |
|
395 | + $this->_meta_description = $this->createMetaDescription(); |
|
396 | + $this->_title = $this->createTitleTag(); |
|
397 | + } |
|
398 | + |
|
399 | + public function createMetaTags() |
|
400 | + { |
|
401 | + global $xoopsTpl, $xoTheme; |
|
402 | + |
|
403 | + if (is_object($xoTheme)) { |
|
404 | + $xoTheme->addMeta('meta', 'keywords', $this->_keywords); |
|
405 | + $xoTheme->addMeta('meta', 'description', $this->_description); |
|
406 | + $xoTheme->addMeta('meta', 'title', $this->_title); |
|
407 | + } else { |
|
408 | + $xoopsTpl->assign('xoops_meta_keywords', $this->_keywords); |
|
409 | + $xoopsTpl->assign('xoops_meta_description', $this->_description); |
|
410 | + } |
|
411 | + $xoopsTpl->assign('xoops_pagetitle', $this->_title); |
|
412 | + } |
|
413 | 413 | } |
@@ -354,7 +354,7 @@ |
||
354 | 354 | public function createMetaKeywords() |
355 | 355 | { |
356 | 356 | global $xoopsModuleConfig; |
357 | - $keywords = $this->findMetaKeywords($this->_original_title . ' ' . $this->_description, $this->_minChar); |
|
357 | + $keywords = $this->findMetaKeywords($this->_original_title.' '.$this->_description, $this->_minChar); |
|
358 | 358 | if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) |
359 | 359 | && $xoopsModuleConfig['moduleMetaKeywords'] !== '') { |
360 | 360 | $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']); |
@@ -30,6 +30,6 @@ |
||
30 | 30 | $smarthookHandler = SmartHookHandler::getInstance(); |
31 | 31 | |
32 | 32 | if (!class_exists('smartmetagen')) { |
33 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php'; |
|
33 | + require_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 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'; |
|
16 | +require_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 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecthandler.php'; |
|
22 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartobject.php'; |
|
23 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectsregistry.php'; |
|
21 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecthandler.php'; |
|
22 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartobject.php'; |
|
23 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectsregistry.php'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Including SmartHook feature |
27 | 27 | */ |
28 | 28 | |
29 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smarthookhandler.php'; |
|
29 | +require_once SMARTOBJECT_ROOT_PATH.'class/smarthookhandler.php'; |
|
30 | 30 | $smarthookHandler = SmartHookHandler::getInstance(); |
31 | 31 | |
32 | 32 | if (!class_exists('smartmetagen')) { |
33 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartmetagen.php'; |
|
33 | + require_once SMARTOBJECT_ROOT_PATH.'class/smartmetagen.php'; |
|
34 | 34 | } |
35 | 35 | //$smartobjectConfig = smart_getModuleConfig('smartobject'); |
@@ -31,513 +31,513 @@ |
||
31 | 31 | */ |
32 | 32 | class SmartObjectController |
33 | 33 | { |
34 | - public $handler; |
|
35 | - |
|
36 | - /** |
|
37 | - * SmartObjectController constructor. |
|
38 | - * @param $handler |
|
39 | - */ |
|
40 | - public function __construct($handler) |
|
41 | - { |
|
42 | - $this->handler = $handler; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @param $smartObj |
|
47 | - */ |
|
48 | - public function postDataToObject(&$smartObj) |
|
49 | - { |
|
50 | - foreach (array_keys($smartObj->vars) as $key) { |
|
51 | - switch ($smartObj->vars[$key]['data_type']) { |
|
52 | - case XOBJ_DTYPE_IMAGE: |
|
53 | - if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') { |
|
54 | - $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
55 | - $smartObj->setVar($key, $_POST['url_' . $key]); |
|
56 | - if (file_exists($oldFile)) { |
|
57 | - unlink($oldFile); |
|
58 | - } |
|
59 | - } |
|
60 | - if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') { |
|
61 | - $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
62 | - $smartObj->setVar($key, ''); |
|
63 | - if (file_exists($oldFile)) { |
|
64 | - unlink($oldFile); |
|
65 | - } |
|
66 | - } |
|
67 | - break; |
|
68 | - |
|
69 | - case XOBJ_DTYPE_URLLINK: |
|
70 | - $linkObj = $smartObj->getUrlLinkObj($key); |
|
71 | - $linkObj->setVar('caption', $_POST['caption_' . $key]); |
|
72 | - $linkObj->setVar('description', $_POST['desc_' . $key]); |
|
73 | - $linkObj->setVar('target', $_POST['target_' . $key]); |
|
74 | - $linkObj->setVar('url', $_POST['url_' . $key]); |
|
75 | - if ($linkObj->getVar('url') !== '') { |
|
76 | - $smartObj->storeUrlLinkObj($linkObj); |
|
77 | - } |
|
78 | - //todo: catch errors |
|
79 | - $smartObj->setVar($key, $linkObj->getVar('urllinkid')); |
|
80 | - break; |
|
81 | - |
|
82 | - case XOBJ_DTYPE_FILE: |
|
83 | - if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') { |
|
84 | - $fileObj = $smartObj->getFileObj($key); |
|
85 | - $fileObj->setVar('caption', $_POST['caption_' . $key]); |
|
86 | - $fileObj->setVar('description', $_POST['desc_' . $key]); |
|
87 | - $fileObj->setVar('url', $_POST['url_' . $key]); |
|
88 | - if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' |
|
89 | - && $fileObj->getVar('url') === '')) { |
|
90 | - $res = $smartObj->storeFileObj($fileObj); |
|
91 | - if ($res) { |
|
92 | - $smartObj->setVar($key, $fileObj->getVar('fileid')); |
|
93 | - } else { |
|
94 | - //error setted, but no error message (to be improved) |
|
95 | - $smartObj->setErrors($fileObj->getErrors()); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - break; |
|
100 | - |
|
101 | - case XOBJ_DTYPE_STIME: |
|
102 | - case XOBJ_DTYPE_MTIME: |
|
103 | - case XOBJ_DTYPE_LTIME: |
|
104 | - // check if this field's value is available in the POST array |
|
105 | - if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) { |
|
106 | - $value = strtotime($_POST[$key]['date']) + $_POST[$key]['time']; |
|
107 | - } else { |
|
108 | - $value = strtotime($_POST[$key]); |
|
109 | - //if strtotime returns false, the value is already a time stamp |
|
110 | - if (!$value) { |
|
111 | - $value = (int)$_POST[$key]; |
|
112 | - } |
|
113 | - } |
|
114 | - $smartObj->setVar($key, $value); |
|
115 | - |
|
116 | - break; |
|
117 | - |
|
118 | - default: |
|
119 | - $smartObj->setVar($key, $_POST[$key]); |
|
120 | - break; |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param $smartObj |
|
127 | - * @param $objectid |
|
128 | - * @param $created_success_msg |
|
129 | - * @param $modified_success_msg |
|
130 | - * @param bool $redirect_page |
|
131 | - * @param bool $debug |
|
132 | - * @return mixed |
|
133 | - */ |
|
134 | - public function doStoreFromDefaultForm( |
|
135 | - &$smartObj, |
|
136 | - $objectid, |
|
137 | - $created_success_msg, |
|
138 | - $modified_success_msg, |
|
139 | - $redirect_page = false, |
|
140 | - $debug = false |
|
141 | - ) { |
|
142 | - global $smart_previous_page; |
|
143 | - |
|
144 | - $this->postDataToObject($smartObj); |
|
145 | - |
|
146 | - if ($smartObj->isNew()) { |
|
147 | - $redirect_msg = $created_success_msg; |
|
148 | - } else { |
|
149 | - $redirect_msg = $modified_success_msg; |
|
150 | - } |
|
151 | - |
|
152 | - // Check if there were uploaded files |
|
153 | - if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) { |
|
154 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php'; |
|
155 | - $uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight); |
|
156 | - foreach ($_FILES as $name => $file_array) { |
|
157 | - if (isset($file_array['name']) && $file_array['name'] !== '' |
|
158 | - && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) { |
|
159 | - if ($uploaderObj->fetchMedia($name)) { |
|
160 | - $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName()); |
|
161 | - if ($uploaderObj->upload()) { |
|
162 | - // Find the related field in the SmartObject |
|
163 | - $related_field = str_replace('upload_', '', $name); |
|
164 | - $uploadedArray[] = $related_field; |
|
165 | - //si c'est un fichier Rich |
|
166 | - if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) { |
|
167 | - $object_fileurl = $smartObj->getUploadDir(); |
|
168 | - $fileObj = $smartObj->getFileObj($related_field); |
|
169 | - $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName()); |
|
170 | - $fileObj->setVar('caption', $_POST['caption_' . $related_field]); |
|
171 | - $fileObj->setVar('description', $_POST['desc_' . $related_field]); |
|
172 | - $smartObj->storeFileObj($fileObj); |
|
173 | - //todo: catch errors |
|
174 | - $smartObj->setVar($related_field, $fileObj->getVar('fileid')); |
|
175 | - } else { |
|
176 | - $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field); |
|
177 | - unlink($old_file); |
|
178 | - $smartObj->setVar($related_field, $uploaderObj->getSavedFileName()); |
|
179 | - } |
|
180 | - } else { |
|
181 | - $smartObj->setErrors($uploaderObj->getErrors(false)); |
|
182 | - } |
|
183 | - } else { |
|
184 | - $smartObj->setErrors($uploaderObj->getErrors(false)); |
|
185 | - } |
|
186 | - } |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - if ($debug) { |
|
191 | - $storeResult = $this->handler->insertD($smartObj); |
|
192 | - } else { |
|
193 | - $storeResult = $this->handler->insert($smartObj); |
|
194 | - } |
|
195 | - |
|
196 | - if ($storeResult) { |
|
197 | - if ($this->handler->getPermissions()) { |
|
198 | - $smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler); |
|
199 | - $smartPermissionsHandler->storeAllPermissionsForId($smartObj->id()); |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - if ($redirect_page === null) { |
|
204 | - return $smartObj; |
|
205 | - } else { |
|
206 | - if (!$storeResult) { |
|
207 | - redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors()); |
|
208 | - } |
|
209 | - |
|
210 | - $redirect_page = $redirect_page ?: smart_get_page_before_form(); |
|
211 | - |
|
212 | - redirect_header($redirect_page, 2, $redirect_msg); |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Store the object in the database autmatically from a form sending POST data |
|
218 | - * |
|
219 | - * @param string $created_success_msg message to display if new object was created |
|
220 | - * @param string $modified_success_msg message to display if object was successfully edited |
|
221 | - * @param bool|string $redirect_page redirect page, if not set, then we backup once |
|
222 | - * @param bool $debug |
|
223 | - * @param bool $x_param |
|
224 | - * @return bool |
|
225 | - * @internal param string $created_redir_page redirect page after creating the object |
|
226 | - * @internal param string $modified_redir_page redirect page after editing the object |
|
227 | - * @internal param bool $exit if set to TRUE then the script ends |
|
228 | - */ |
|
229 | - public function storeFromDefaultForm( |
|
230 | - $created_success_msg, |
|
231 | - $modified_success_msg, |
|
232 | - $redirect_page = false, |
|
233 | - $debug = false, |
|
234 | - $x_param = false |
|
235 | - ) { |
|
236 | - $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0; |
|
237 | - if ($debug) { |
|
238 | - if ($x_param) { |
|
239 | - $smartObj = $this->handler->getD($objectid, true, $x_param); |
|
240 | - } else { |
|
241 | - $smartObj = $this->handler->getD($objectid); |
|
242 | - } |
|
243 | - } else { |
|
244 | - if ($x_param) { |
|
245 | - $smartObj = $this->handler->get($objectid, true, false, false, $x_param); |
|
246 | - } else { |
|
247 | - $smartObj = $this->handler->get($objectid); |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - // if handler is the Multilanguage handler, we will need to treat this for multilanguage |
|
252 | - if (is_subclass_of($this->handler, 'smartpersistablemlobjecthandler')) { |
|
253 | - if ($smartObj->isNew()) { |
|
254 | - // This is a new object. We need to store the meta data and then the language data |
|
255 | - // First, we will get rid of the multilanguage data to only store the meta data |
|
256 | - $smartObj->stripMultilanguageFields(); |
|
257 | - $newObject = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
258 | - /** |
|
259 | - * @todo we need to trap potential errors here |
|
260 | - */ |
|
261 | - |
|
262 | - // ok, the meta daa is stored. Let's recreate the object and then |
|
263 | - // get rid of anything not multilanguage |
|
264 | - unset($smartObj); |
|
265 | - $smartObj = $this->handler->get($objectid); |
|
266 | - $smartObj->stripNonMultilanguageFields(); |
|
267 | - |
|
268 | - $smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName)); |
|
269 | - $this->handler->changeTableNameForML(); |
|
270 | - $ret = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
271 | - |
|
272 | - return $ret; |
|
273 | - } |
|
274 | - } else { |
|
275 | - return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
276 | - } |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * @return bool |
|
281 | - */ |
|
282 | - public function storeSmartObjectD() |
|
283 | - { |
|
284 | - return $this->storeSmartObject(true); |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * @param bool $debug |
|
289 | - * @param bool $xparam |
|
290 | - * @return bool |
|
291 | - */ |
|
292 | - public function storeSmartObject($debug = false, $xparam = false) |
|
293 | - { |
|
294 | - $ret = $this->storeFromDefaultForm('', '', null, $debug, $xparam); |
|
295 | - |
|
296 | - return $ret; |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * Handles deletion of an object which keyid is passed as a GET param |
|
301 | - * |
|
302 | - * @param bool $confirm_msg |
|
303 | - * @param string $op |
|
304 | - * @param bool $userSide |
|
305 | - * @return bool |
|
306 | - * @internal param string $redir_page redirect page after deleting the object |
|
307 | - */ |
|
308 | - public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false) |
|
309 | - { |
|
310 | - global $smart_previous_page; |
|
311 | - |
|
312 | - $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
313 | - $smartObj = $this->handler->get($objectid); |
|
314 | - |
|
315 | - if ($smartObj->isNew()) { |
|
316 | - redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); |
|
317 | - } |
|
318 | - |
|
319 | - $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
|
320 | - if ($confirm) { |
|
321 | - if (!$this->handler->delete($smartObj)) { |
|
322 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
323 | - exit; |
|
324 | - } |
|
325 | - |
|
326 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); |
|
327 | - } else { |
|
328 | - // no confirm: show deletion condition |
|
329 | - |
|
330 | - xoops_cp_header(); |
|
331 | - |
|
332 | - if (!$confirm_msg) { |
|
333 | - $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; |
|
334 | - } |
|
335 | - |
|
336 | - xoops_confirm(array( |
|
337 | - 'op' => $op, |
|
338 | - $this->handler->keyName => $smartObj->getVar($this->handler->keyName), |
|
339 | - 'confirm' => 1, |
|
340 | - 'redirect_page' => $smart_previous_page |
|
341 | - ), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); |
|
342 | - |
|
343 | - xoops_cp_footer(); |
|
344 | - } |
|
345 | - exit(); |
|
346 | - } |
|
347 | - |
|
348 | - /** |
|
349 | - * @param bool $confirm_msg |
|
350 | - * @param string $op |
|
351 | - */ |
|
352 | - public function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del') |
|
353 | - { |
|
354 | - global $smart_previous_page, $xoopsTpl; |
|
355 | - |
|
356 | - $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
357 | - $smartObj = $this->handler->get($objectid); |
|
358 | - |
|
359 | - if ($smartObj->isNew()) { |
|
360 | - redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); |
|
361 | - } |
|
362 | - |
|
363 | - $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
|
364 | - if ($confirm) { |
|
365 | - if (!$this->handler->delete($smartObj)) { |
|
366 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
367 | - exit; |
|
368 | - } |
|
369 | - |
|
370 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); |
|
371 | - } else { |
|
372 | - // no confirm: show deletion condition |
|
373 | - if (!$confirm_msg) { |
|
374 | - $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; |
|
375 | - } |
|
376 | - |
|
377 | - ob_start(); |
|
378 | - xoops_confirm(array( |
|
379 | - 'op' => $op, |
|
380 | - $this->handler->keyName => $smartObj->getVar($this->handler->keyName), |
|
381 | - 'confirm' => 1, |
|
382 | - 'redirect_page' => $smart_previous_page |
|
383 | - ), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); |
|
384 | - $smartobjectDeleteConfirm = ob_get_clean(); |
|
385 | - $xoopsTpl->assign('smartobject_delete_confirm', $smartobjectDeleteConfirm); |
|
386 | - } |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Retreive the object admin side link for a {@link SmartObjectSingleView} page |
|
391 | - * |
|
392 | - * @param SmartObject $smartObj reference to the object from which we want the user side link |
|
393 | - * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link |
|
394 | - * @param bool $withimage |
|
395 | - * @return string admin side link to the object |
|
396 | - */ |
|
397 | - public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false) |
|
398 | - { |
|
399 | - $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
400 | - if ($onlyUrl) { |
|
401 | - return $ret; |
|
402 | - } elseif ($withimage) { |
|
403 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "viewmag.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_ADMIN_VIEW . "' title='" . _CO_SOBJECT_ADMIN_VIEW . "'></a>"; |
|
404 | - } |
|
405 | - |
|
406 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * Retreive the object user side link |
|
411 | - * |
|
412 | - * @param SmartObject $smartObj reference to the object from which we want the user side link |
|
413 | - * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link |
|
414 | - * @return string user side link to the object |
|
415 | - */ |
|
416 | - public function getItemLink(SmartObject $smartObj, $onlyUrl = false) |
|
417 | - { |
|
418 | - $seoMode = smart_getModuleModeSEO($this->handler->_moduleName); |
|
419 | - $seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName); |
|
420 | - |
|
421 | - /** |
|
422 | - * $seoIncludeId feature is not finished yet, so let's put it always to true |
|
423 | - */ |
|
424 | - //$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName); |
|
425 | - $seoIncludeId = true; |
|
426 | - |
|
427 | - if ($seoMode === 'rewrite') { |
|
428 | - $ret = XOOPS_URL . '/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
429 | - } elseif ($seoMode === 'pathinfo') { |
|
430 | - $ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
431 | - } else { |
|
432 | - $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
433 | - } |
|
434 | - |
|
435 | - if (!$onlyUrl) { |
|
436 | - $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
437 | - } |
|
438 | - |
|
439 | - return $ret; |
|
440 | - } |
|
441 | - |
|
442 | - /** |
|
443 | - * @param $smartObj |
|
444 | - * @param bool $onlyUrl |
|
445 | - * @param bool $withimage |
|
446 | - * @return string |
|
447 | - */ |
|
448 | - public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true) |
|
449 | - { |
|
450 | - $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName) . '&language=' . $smartObj->getVar('language'); |
|
451 | - if ($onlyUrl) { |
|
452 | - return $ret; |
|
453 | - } elseif ($withimage) { |
|
454 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "wizard.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_LANGUAGE_MODIFY . "' title='" . _CO_SOBJECT_LANGUAGE_MODIFY . "'></a>"; |
|
455 | - } |
|
456 | - |
|
457 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * @param $smartObj |
|
462 | - * @param bool $onlyUrl |
|
463 | - * @param bool $withimage |
|
464 | - * @param bool $userSide |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
|
468 | - { |
|
469 | - $admin_side = $userSide ? '' : 'admin/'; |
|
470 | - $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
471 | - if ($onlyUrl) { |
|
472 | - return $ret; |
|
473 | - } elseif ($withimage) { |
|
474 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "edit.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_MODIFY . "' title='" . _CO_SOBJECT_MODIFY . "'></a>"; |
|
475 | - } |
|
476 | - |
|
477 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
478 | - } |
|
479 | - |
|
480 | - /** |
|
481 | - * @param $smartObj |
|
482 | - * @param bool $onlyUrl |
|
483 | - * @param bool $withimage |
|
484 | - * @param bool $userSide |
|
485 | - * @return string |
|
486 | - */ |
|
487 | - public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
|
488 | - { |
|
489 | - $admin_side = $userSide ? '' : 'admin/'; |
|
490 | - $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
491 | - if ($onlyUrl) { |
|
492 | - return $ret; |
|
493 | - } elseif ($withimage) { |
|
494 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "editdelete.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_DELETE . "' title='" . _CO_SOBJECT_DELETE . "'></a>"; |
|
495 | - } |
|
496 | - |
|
497 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * @param $smartObj |
|
502 | - * @return string |
|
503 | - */ |
|
504 | - public function getPrintAndMailLink($smartObj) |
|
505 | - { |
|
506 | - global $xoopsConfig; |
|
507 | - |
|
508 | - $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
509 | - $js = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);"; |
|
510 | - $printlink = '<a href="' . $js . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"></a>'; |
|
511 | - |
|
512 | - $smartModule = smart_getModuleInfo($smartObj->handler->_moduleName); |
|
513 | - $link = smart_getCurrentPage(); |
|
514 | - $mid = $smartModule->getVar('mid'); |
|
515 | - $friendlink = "<a href=\"javascript:openWithSelfMain('" |
|
516 | - . SMARTOBJECT_URL |
|
517 | - . 'sendlink.php?link=' |
|
518 | - . $link |
|
519 | - . '&mid=' |
|
520 | - . $mid |
|
521 | - . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" |
|
522 | - . SMARTOBJECT_IMAGES_ACTIONS_URL |
|
523 | - . "mail_send.png\" alt=\"" |
|
524 | - . _CO_SOBJECT_EMAIL |
|
525 | - . "\" title=\"" |
|
526 | - . _CO_SOBJECT_EMAIL |
|
527 | - . "\" style=\"vertical-align: middle;\"></a>"; |
|
528 | - |
|
529 | - $ret = '<span id="smartobject_print_button">' . $printlink . ' </span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>'; |
|
530 | - |
|
531 | - return $ret; |
|
532 | - } |
|
533 | - |
|
534 | - /** |
|
535 | - * @return string |
|
536 | - */ |
|
537 | - public function getModuleItemString() |
|
538 | - { |
|
539 | - $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname; |
|
540 | - |
|
541 | - return $ret; |
|
542 | - } |
|
34 | + public $handler; |
|
35 | + |
|
36 | + /** |
|
37 | + * SmartObjectController constructor. |
|
38 | + * @param $handler |
|
39 | + */ |
|
40 | + public function __construct($handler) |
|
41 | + { |
|
42 | + $this->handler = $handler; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @param $smartObj |
|
47 | + */ |
|
48 | + public function postDataToObject(&$smartObj) |
|
49 | + { |
|
50 | + foreach (array_keys($smartObj->vars) as $key) { |
|
51 | + switch ($smartObj->vars[$key]['data_type']) { |
|
52 | + case XOBJ_DTYPE_IMAGE: |
|
53 | + if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') { |
|
54 | + $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
55 | + $smartObj->setVar($key, $_POST['url_' . $key]); |
|
56 | + if (file_exists($oldFile)) { |
|
57 | + unlink($oldFile); |
|
58 | + } |
|
59 | + } |
|
60 | + if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') { |
|
61 | + $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
62 | + $smartObj->setVar($key, ''); |
|
63 | + if (file_exists($oldFile)) { |
|
64 | + unlink($oldFile); |
|
65 | + } |
|
66 | + } |
|
67 | + break; |
|
68 | + |
|
69 | + case XOBJ_DTYPE_URLLINK: |
|
70 | + $linkObj = $smartObj->getUrlLinkObj($key); |
|
71 | + $linkObj->setVar('caption', $_POST['caption_' . $key]); |
|
72 | + $linkObj->setVar('description', $_POST['desc_' . $key]); |
|
73 | + $linkObj->setVar('target', $_POST['target_' . $key]); |
|
74 | + $linkObj->setVar('url', $_POST['url_' . $key]); |
|
75 | + if ($linkObj->getVar('url') !== '') { |
|
76 | + $smartObj->storeUrlLinkObj($linkObj); |
|
77 | + } |
|
78 | + //todo: catch errors |
|
79 | + $smartObj->setVar($key, $linkObj->getVar('urllinkid')); |
|
80 | + break; |
|
81 | + |
|
82 | + case XOBJ_DTYPE_FILE: |
|
83 | + if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') { |
|
84 | + $fileObj = $smartObj->getFileObj($key); |
|
85 | + $fileObj->setVar('caption', $_POST['caption_' . $key]); |
|
86 | + $fileObj->setVar('description', $_POST['desc_' . $key]); |
|
87 | + $fileObj->setVar('url', $_POST['url_' . $key]); |
|
88 | + if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' |
|
89 | + && $fileObj->getVar('url') === '')) { |
|
90 | + $res = $smartObj->storeFileObj($fileObj); |
|
91 | + if ($res) { |
|
92 | + $smartObj->setVar($key, $fileObj->getVar('fileid')); |
|
93 | + } else { |
|
94 | + //error setted, but no error message (to be improved) |
|
95 | + $smartObj->setErrors($fileObj->getErrors()); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + break; |
|
100 | + |
|
101 | + case XOBJ_DTYPE_STIME: |
|
102 | + case XOBJ_DTYPE_MTIME: |
|
103 | + case XOBJ_DTYPE_LTIME: |
|
104 | + // check if this field's value is available in the POST array |
|
105 | + if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) { |
|
106 | + $value = strtotime($_POST[$key]['date']) + $_POST[$key]['time']; |
|
107 | + } else { |
|
108 | + $value = strtotime($_POST[$key]); |
|
109 | + //if strtotime returns false, the value is already a time stamp |
|
110 | + if (!$value) { |
|
111 | + $value = (int)$_POST[$key]; |
|
112 | + } |
|
113 | + } |
|
114 | + $smartObj->setVar($key, $value); |
|
115 | + |
|
116 | + break; |
|
117 | + |
|
118 | + default: |
|
119 | + $smartObj->setVar($key, $_POST[$key]); |
|
120 | + break; |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param $smartObj |
|
127 | + * @param $objectid |
|
128 | + * @param $created_success_msg |
|
129 | + * @param $modified_success_msg |
|
130 | + * @param bool $redirect_page |
|
131 | + * @param bool $debug |
|
132 | + * @return mixed |
|
133 | + */ |
|
134 | + public function doStoreFromDefaultForm( |
|
135 | + &$smartObj, |
|
136 | + $objectid, |
|
137 | + $created_success_msg, |
|
138 | + $modified_success_msg, |
|
139 | + $redirect_page = false, |
|
140 | + $debug = false |
|
141 | + ) { |
|
142 | + global $smart_previous_page; |
|
143 | + |
|
144 | + $this->postDataToObject($smartObj); |
|
145 | + |
|
146 | + if ($smartObj->isNew()) { |
|
147 | + $redirect_msg = $created_success_msg; |
|
148 | + } else { |
|
149 | + $redirect_msg = $modified_success_msg; |
|
150 | + } |
|
151 | + |
|
152 | + // Check if there were uploaded files |
|
153 | + if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) { |
|
154 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php'; |
|
155 | + $uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight); |
|
156 | + foreach ($_FILES as $name => $file_array) { |
|
157 | + if (isset($file_array['name']) && $file_array['name'] !== '' |
|
158 | + && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) { |
|
159 | + if ($uploaderObj->fetchMedia($name)) { |
|
160 | + $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName()); |
|
161 | + if ($uploaderObj->upload()) { |
|
162 | + // Find the related field in the SmartObject |
|
163 | + $related_field = str_replace('upload_', '', $name); |
|
164 | + $uploadedArray[] = $related_field; |
|
165 | + //si c'est un fichier Rich |
|
166 | + if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) { |
|
167 | + $object_fileurl = $smartObj->getUploadDir(); |
|
168 | + $fileObj = $smartObj->getFileObj($related_field); |
|
169 | + $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName()); |
|
170 | + $fileObj->setVar('caption', $_POST['caption_' . $related_field]); |
|
171 | + $fileObj->setVar('description', $_POST['desc_' . $related_field]); |
|
172 | + $smartObj->storeFileObj($fileObj); |
|
173 | + //todo: catch errors |
|
174 | + $smartObj->setVar($related_field, $fileObj->getVar('fileid')); |
|
175 | + } else { |
|
176 | + $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field); |
|
177 | + unlink($old_file); |
|
178 | + $smartObj->setVar($related_field, $uploaderObj->getSavedFileName()); |
|
179 | + } |
|
180 | + } else { |
|
181 | + $smartObj->setErrors($uploaderObj->getErrors(false)); |
|
182 | + } |
|
183 | + } else { |
|
184 | + $smartObj->setErrors($uploaderObj->getErrors(false)); |
|
185 | + } |
|
186 | + } |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + if ($debug) { |
|
191 | + $storeResult = $this->handler->insertD($smartObj); |
|
192 | + } else { |
|
193 | + $storeResult = $this->handler->insert($smartObj); |
|
194 | + } |
|
195 | + |
|
196 | + if ($storeResult) { |
|
197 | + if ($this->handler->getPermissions()) { |
|
198 | + $smartPermissionsHandler = new SmartobjectPermissionHandler($this->handler); |
|
199 | + $smartPermissionsHandler->storeAllPermissionsForId($smartObj->id()); |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + if ($redirect_page === null) { |
|
204 | + return $smartObj; |
|
205 | + } else { |
|
206 | + if (!$storeResult) { |
|
207 | + redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors()); |
|
208 | + } |
|
209 | + |
|
210 | + $redirect_page = $redirect_page ?: smart_get_page_before_form(); |
|
211 | + |
|
212 | + redirect_header($redirect_page, 2, $redirect_msg); |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Store the object in the database autmatically from a form sending POST data |
|
218 | + * |
|
219 | + * @param string $created_success_msg message to display if new object was created |
|
220 | + * @param string $modified_success_msg message to display if object was successfully edited |
|
221 | + * @param bool|string $redirect_page redirect page, if not set, then we backup once |
|
222 | + * @param bool $debug |
|
223 | + * @param bool $x_param |
|
224 | + * @return bool |
|
225 | + * @internal param string $created_redir_page redirect page after creating the object |
|
226 | + * @internal param string $modified_redir_page redirect page after editing the object |
|
227 | + * @internal param bool $exit if set to TRUE then the script ends |
|
228 | + */ |
|
229 | + public function storeFromDefaultForm( |
|
230 | + $created_success_msg, |
|
231 | + $modified_success_msg, |
|
232 | + $redirect_page = false, |
|
233 | + $debug = false, |
|
234 | + $x_param = false |
|
235 | + ) { |
|
236 | + $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0; |
|
237 | + if ($debug) { |
|
238 | + if ($x_param) { |
|
239 | + $smartObj = $this->handler->getD($objectid, true, $x_param); |
|
240 | + } else { |
|
241 | + $smartObj = $this->handler->getD($objectid); |
|
242 | + } |
|
243 | + } else { |
|
244 | + if ($x_param) { |
|
245 | + $smartObj = $this->handler->get($objectid, true, false, false, $x_param); |
|
246 | + } else { |
|
247 | + $smartObj = $this->handler->get($objectid); |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + // if handler is the Multilanguage handler, we will need to treat this for multilanguage |
|
252 | + if (is_subclass_of($this->handler, 'smartpersistablemlobjecthandler')) { |
|
253 | + if ($smartObj->isNew()) { |
|
254 | + // This is a new object. We need to store the meta data and then the language data |
|
255 | + // First, we will get rid of the multilanguage data to only store the meta data |
|
256 | + $smartObj->stripMultilanguageFields(); |
|
257 | + $newObject = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
258 | + /** |
|
259 | + * @todo we need to trap potential errors here |
|
260 | + */ |
|
261 | + |
|
262 | + // ok, the meta daa is stored. Let's recreate the object and then |
|
263 | + // get rid of anything not multilanguage |
|
264 | + unset($smartObj); |
|
265 | + $smartObj = $this->handler->get($objectid); |
|
266 | + $smartObj->stripNonMultilanguageFields(); |
|
267 | + |
|
268 | + $smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName)); |
|
269 | + $this->handler->changeTableNameForML(); |
|
270 | + $ret = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
271 | + |
|
272 | + return $ret; |
|
273 | + } |
|
274 | + } else { |
|
275 | + return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); |
|
276 | + } |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * @return bool |
|
281 | + */ |
|
282 | + public function storeSmartObjectD() |
|
283 | + { |
|
284 | + return $this->storeSmartObject(true); |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * @param bool $debug |
|
289 | + * @param bool $xparam |
|
290 | + * @return bool |
|
291 | + */ |
|
292 | + public function storeSmartObject($debug = false, $xparam = false) |
|
293 | + { |
|
294 | + $ret = $this->storeFromDefaultForm('', '', null, $debug, $xparam); |
|
295 | + |
|
296 | + return $ret; |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * Handles deletion of an object which keyid is passed as a GET param |
|
301 | + * |
|
302 | + * @param bool $confirm_msg |
|
303 | + * @param string $op |
|
304 | + * @param bool $userSide |
|
305 | + * @return bool |
|
306 | + * @internal param string $redir_page redirect page after deleting the object |
|
307 | + */ |
|
308 | + public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false) |
|
309 | + { |
|
310 | + global $smart_previous_page; |
|
311 | + |
|
312 | + $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
313 | + $smartObj = $this->handler->get($objectid); |
|
314 | + |
|
315 | + if ($smartObj->isNew()) { |
|
316 | + redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); |
|
317 | + } |
|
318 | + |
|
319 | + $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
|
320 | + if ($confirm) { |
|
321 | + if (!$this->handler->delete($smartObj)) { |
|
322 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
323 | + exit; |
|
324 | + } |
|
325 | + |
|
326 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); |
|
327 | + } else { |
|
328 | + // no confirm: show deletion condition |
|
329 | + |
|
330 | + xoops_cp_header(); |
|
331 | + |
|
332 | + if (!$confirm_msg) { |
|
333 | + $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; |
|
334 | + } |
|
335 | + |
|
336 | + xoops_confirm(array( |
|
337 | + 'op' => $op, |
|
338 | + $this->handler->keyName => $smartObj->getVar($this->handler->keyName), |
|
339 | + 'confirm' => 1, |
|
340 | + 'redirect_page' => $smart_previous_page |
|
341 | + ), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); |
|
342 | + |
|
343 | + xoops_cp_footer(); |
|
344 | + } |
|
345 | + exit(); |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * @param bool $confirm_msg |
|
350 | + * @param string $op |
|
351 | + */ |
|
352 | + public function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del') |
|
353 | + { |
|
354 | + global $smart_previous_page, $xoopsTpl; |
|
355 | + |
|
356 | + $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
357 | + $smartObj = $this->handler->get($objectid); |
|
358 | + |
|
359 | + if ($smartObj->isNew()) { |
|
360 | + redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); |
|
361 | + } |
|
362 | + |
|
363 | + $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
|
364 | + if ($confirm) { |
|
365 | + if (!$this->handler->delete($smartObj)) { |
|
366 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
367 | + exit; |
|
368 | + } |
|
369 | + |
|
370 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); |
|
371 | + } else { |
|
372 | + // no confirm: show deletion condition |
|
373 | + if (!$confirm_msg) { |
|
374 | + $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; |
|
375 | + } |
|
376 | + |
|
377 | + ob_start(); |
|
378 | + xoops_confirm(array( |
|
379 | + 'op' => $op, |
|
380 | + $this->handler->keyName => $smartObj->getVar($this->handler->keyName), |
|
381 | + 'confirm' => 1, |
|
382 | + 'redirect_page' => $smart_previous_page |
|
383 | + ), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); |
|
384 | + $smartobjectDeleteConfirm = ob_get_clean(); |
|
385 | + $xoopsTpl->assign('smartobject_delete_confirm', $smartobjectDeleteConfirm); |
|
386 | + } |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * Retreive the object admin side link for a {@link SmartObjectSingleView} page |
|
391 | + * |
|
392 | + * @param SmartObject $smartObj reference to the object from which we want the user side link |
|
393 | + * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link |
|
394 | + * @param bool $withimage |
|
395 | + * @return string admin side link to the object |
|
396 | + */ |
|
397 | + public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false) |
|
398 | + { |
|
399 | + $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
400 | + if ($onlyUrl) { |
|
401 | + return $ret; |
|
402 | + } elseif ($withimage) { |
|
403 | + return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "viewmag.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_ADMIN_VIEW . "' title='" . _CO_SOBJECT_ADMIN_VIEW . "'></a>"; |
|
404 | + } |
|
405 | + |
|
406 | + return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * Retreive the object user side link |
|
411 | + * |
|
412 | + * @param SmartObject $smartObj reference to the object from which we want the user side link |
|
413 | + * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link |
|
414 | + * @return string user side link to the object |
|
415 | + */ |
|
416 | + public function getItemLink(SmartObject $smartObj, $onlyUrl = false) |
|
417 | + { |
|
418 | + $seoMode = smart_getModuleModeSEO($this->handler->_moduleName); |
|
419 | + $seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName); |
|
420 | + |
|
421 | + /** |
|
422 | + * $seoIncludeId feature is not finished yet, so let's put it always to true |
|
423 | + */ |
|
424 | + //$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName); |
|
425 | + $seoIncludeId = true; |
|
426 | + |
|
427 | + if ($seoMode === 'rewrite') { |
|
428 | + $ret = XOOPS_URL . '/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
429 | + } elseif ($seoMode === 'pathinfo') { |
|
430 | + $ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
431 | + } else { |
|
432 | + $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
433 | + } |
|
434 | + |
|
435 | + if (!$onlyUrl) { |
|
436 | + $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
437 | + } |
|
438 | + |
|
439 | + return $ret; |
|
440 | + } |
|
441 | + |
|
442 | + /** |
|
443 | + * @param $smartObj |
|
444 | + * @param bool $onlyUrl |
|
445 | + * @param bool $withimage |
|
446 | + * @return string |
|
447 | + */ |
|
448 | + public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true) |
|
449 | + { |
|
450 | + $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName) . '&language=' . $smartObj->getVar('language'); |
|
451 | + if ($onlyUrl) { |
|
452 | + return $ret; |
|
453 | + } elseif ($withimage) { |
|
454 | + return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "wizard.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_LANGUAGE_MODIFY . "' title='" . _CO_SOBJECT_LANGUAGE_MODIFY . "'></a>"; |
|
455 | + } |
|
456 | + |
|
457 | + return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * @param $smartObj |
|
462 | + * @param bool $onlyUrl |
|
463 | + * @param bool $withimage |
|
464 | + * @param bool $userSide |
|
465 | + * @return string |
|
466 | + */ |
|
467 | + public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
|
468 | + { |
|
469 | + $admin_side = $userSide ? '' : 'admin/'; |
|
470 | + $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
471 | + if ($onlyUrl) { |
|
472 | + return $ret; |
|
473 | + } elseif ($withimage) { |
|
474 | + return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "edit.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_MODIFY . "' title='" . _CO_SOBJECT_MODIFY . "'></a>"; |
|
475 | + } |
|
476 | + |
|
477 | + return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
478 | + } |
|
479 | + |
|
480 | + /** |
|
481 | + * @param $smartObj |
|
482 | + * @param bool $onlyUrl |
|
483 | + * @param bool $withimage |
|
484 | + * @param bool $userSide |
|
485 | + * @return string |
|
486 | + */ |
|
487 | + public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
|
488 | + { |
|
489 | + $admin_side = $userSide ? '' : 'admin/'; |
|
490 | + $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
491 | + if ($onlyUrl) { |
|
492 | + return $ret; |
|
493 | + } elseif ($withimage) { |
|
494 | + return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "editdelete.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_DELETE . "' title='" . _CO_SOBJECT_DELETE . "'></a>"; |
|
495 | + } |
|
496 | + |
|
497 | + return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * @param $smartObj |
|
502 | + * @return string |
|
503 | + */ |
|
504 | + public function getPrintAndMailLink($smartObj) |
|
505 | + { |
|
506 | + global $xoopsConfig; |
|
507 | + |
|
508 | + $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
509 | + $js = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);"; |
|
510 | + $printlink = '<a href="' . $js . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"></a>'; |
|
511 | + |
|
512 | + $smartModule = smart_getModuleInfo($smartObj->handler->_moduleName); |
|
513 | + $link = smart_getCurrentPage(); |
|
514 | + $mid = $smartModule->getVar('mid'); |
|
515 | + $friendlink = "<a href=\"javascript:openWithSelfMain('" |
|
516 | + . SMARTOBJECT_URL |
|
517 | + . 'sendlink.php?link=' |
|
518 | + . $link |
|
519 | + . '&mid=' |
|
520 | + . $mid |
|
521 | + . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" |
|
522 | + . SMARTOBJECT_IMAGES_ACTIONS_URL |
|
523 | + . "mail_send.png\" alt=\"" |
|
524 | + . _CO_SOBJECT_EMAIL |
|
525 | + . "\" title=\"" |
|
526 | + . _CO_SOBJECT_EMAIL |
|
527 | + . "\" style=\"vertical-align: middle;\"></a>"; |
|
528 | + |
|
529 | + $ret = '<span id="smartobject_print_button">' . $printlink . ' </span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>'; |
|
530 | + |
|
531 | + return $ret; |
|
532 | + } |
|
533 | + |
|
534 | + /** |
|
535 | + * @return string |
|
536 | + */ |
|
537 | + public function getModuleItemString() |
|
538 | + { |
|
539 | + $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname; |
|
540 | + |
|
541 | + return $ret; |
|
542 | + } |
|
543 | 543 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @credit Jan Keller Pedersen <[email protected]> - IDG Danmark A/S <www.idg.dk> |
24 | 24 | * @link http://smartfactory.ca The SmartFactory |
25 | 25 | */ |
26 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
27 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecthandler.php'; |
|
26 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
27 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjecthandler.php'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Class SmartObjectController |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | foreach (array_keys($smartObj->vars) as $key) { |
51 | 51 | switch ($smartObj->vars[$key]['data_type']) { |
52 | 52 | case XOBJ_DTYPE_IMAGE: |
53 | - if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] !== '') { |
|
54 | - $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
55 | - $smartObj->setVar($key, $_POST['url_' . $key]); |
|
53 | + if (isset($_POST['url_'.$key]) && $_POST['url_'.$key] !== '') { |
|
54 | + $oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e'); |
|
55 | + $smartObj->setVar($key, $_POST['url_'.$key]); |
|
56 | 56 | if (file_exists($oldFile)) { |
57 | 57 | unlink($oldFile); |
58 | 58 | } |
59 | 59 | } |
60 | - if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') { |
|
61 | - $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); |
|
60 | + if (isset($_POST['delete_'.$key]) && $_POST['delete_'.$key] == '1') { |
|
61 | + $oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e'); |
|
62 | 62 | $smartObj->setVar($key, ''); |
63 | 63 | if (file_exists($oldFile)) { |
64 | 64 | unlink($oldFile); |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | |
69 | 69 | case XOBJ_DTYPE_URLLINK: |
70 | 70 | $linkObj = $smartObj->getUrlLinkObj($key); |
71 | - $linkObj->setVar('caption', $_POST['caption_' . $key]); |
|
72 | - $linkObj->setVar('description', $_POST['desc_' . $key]); |
|
73 | - $linkObj->setVar('target', $_POST['target_' . $key]); |
|
74 | - $linkObj->setVar('url', $_POST['url_' . $key]); |
|
71 | + $linkObj->setVar('caption', $_POST['caption_'.$key]); |
|
72 | + $linkObj->setVar('description', $_POST['desc_'.$key]); |
|
73 | + $linkObj->setVar('target', $_POST['target_'.$key]); |
|
74 | + $linkObj->setVar('url', $_POST['url_'.$key]); |
|
75 | 75 | if ($linkObj->getVar('url') !== '') { |
76 | 76 | $smartObj->storeUrlLinkObj($linkObj); |
77 | 77 | } |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | break; |
81 | 81 | |
82 | 82 | case XOBJ_DTYPE_FILE: |
83 | - if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] === '') { |
|
83 | + if (!isset($_FILES['upload_'.$key]['name']) || $_FILES['upload_'.$key]['name'] === '') { |
|
84 | 84 | $fileObj = $smartObj->getFileObj($key); |
85 | - $fileObj->setVar('caption', $_POST['caption_' . $key]); |
|
86 | - $fileObj->setVar('description', $_POST['desc_' . $key]); |
|
87 | - $fileObj->setVar('url', $_POST['url_' . $key]); |
|
85 | + $fileObj->setVar('caption', $_POST['caption_'.$key]); |
|
86 | + $fileObj->setVar('description', $_POST['desc_'.$key]); |
|
87 | + $fileObj->setVar('url', $_POST['url_'.$key]); |
|
88 | 88 | if (!($fileObj->getVar('url') === '' && $fileObj->getVar('url') === '' |
89 | 89 | && $fileObj->getVar('url') === '')) { |
90 | 90 | $res = $smartObj->storeFileObj($fileObj); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $value = strtotime($_POST[$key]); |
109 | 109 | //if strtotime returns false, the value is already a time stamp |
110 | 110 | if (!$value) { |
111 | - $value = (int)$_POST[$key]; |
|
111 | + $value = (int) $_POST[$key]; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | $smartObj->setVar($key, $value); |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | |
152 | 152 | // Check if there were uploaded files |
153 | 153 | if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) { |
154 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php'; |
|
154 | + require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartuploader.php'; |
|
155 | 155 | $uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight); |
156 | 156 | foreach ($_FILES as $name => $file_array) { |
157 | 157 | if (isset($file_array['name']) && $file_array['name'] !== '' |
158 | 158 | && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) { |
159 | 159 | if ($uploaderObj->fetchMedia($name)) { |
160 | - $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName()); |
|
160 | + $uploaderObj->setTargetFileName(time().'_'.$uploaderObj->getMediaName()); |
|
161 | 161 | if ($uploaderObj->upload()) { |
162 | 162 | // Find the related field in the SmartObject |
163 | 163 | $related_field = str_replace('upload_', '', $name); |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | if ($smartObj->vars[$related_field]['data_type'] === XOBJ_DTYPE_FILE) { |
167 | 167 | $object_fileurl = $smartObj->getUploadDir(); |
168 | 168 | $fileObj = $smartObj->getFileObj($related_field); |
169 | - $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName()); |
|
170 | - $fileObj->setVar('caption', $_POST['caption_' . $related_field]); |
|
171 | - $fileObj->setVar('description', $_POST['desc_' . $related_field]); |
|
169 | + $fileObj->setVar('url', $object_fileurl.$uploaderObj->getSavedFileName()); |
|
170 | + $fileObj->setVar('caption', $_POST['caption_'.$related_field]); |
|
171 | + $fileObj->setVar('description', $_POST['desc_'.$related_field]); |
|
172 | 172 | $smartObj->storeFileObj($fileObj); |
173 | 173 | //todo: catch errors |
174 | 174 | $smartObj->setVar($related_field, $fileObj->getVar('fileid')); |
175 | 175 | } else { |
176 | - $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field); |
|
176 | + $old_file = $smartObj->getUploadDir(true).$smartObj->getVar($related_field); |
|
177 | 177 | unlink($old_file); |
178 | 178 | $smartObj->setVar($related_field, $uploaderObj->getSavedFileName()); |
179 | 179 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | return $smartObj; |
205 | 205 | } else { |
206 | 206 | if (!$storeResult) { |
207 | - redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors()); |
|
207 | + redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR.$smartObj->getHtmlErrors()); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $redirect_page = $redirect_page ?: smart_get_page_before_form(); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $debug = false, |
234 | 234 | $x_param = false |
235 | 235 | ) { |
236 | - $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0; |
|
236 | + $objectid = isset($_POST[$this->handler->keyName]) ? (int) $_POST[$this->handler->keyName] : 0; |
|
237 | 237 | if ($debug) { |
238 | 238 | if ($x_param) { |
239 | 239 | $smartObj = $this->handler->getD($objectid, true, $x_param); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | { |
310 | 310 | global $smart_previous_page; |
311 | 311 | |
312 | - $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
312 | + $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int) $_REQUEST[$this->handler->keyName] : 0; |
|
313 | 313 | $smartObj = $this->handler->get($objectid); |
314 | 314 | |
315 | 315 | if ($smartObj->isNew()) { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
320 | 320 | if ($confirm) { |
321 | 321 | if (!$this->handler->delete($smartObj)) { |
322 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
322 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR.$smartObj->getHtmlErrors()); |
|
323 | 323 | exit; |
324 | 324 | } |
325 | 325 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | { |
354 | 354 | global $smart_previous_page, $xoopsTpl; |
355 | 355 | |
356 | - $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; |
|
356 | + $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int) $_REQUEST[$this->handler->keyName] : 0; |
|
357 | 357 | $smartObj = $this->handler->get($objectid); |
358 | 358 | |
359 | 359 | if ($smartObj->isNew()) { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
364 | 364 | if ($confirm) { |
365 | 365 | if (!$this->handler->delete($smartObj)) { |
366 | - redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); |
|
366 | + redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR.$smartObj->getHtmlErrors()); |
|
367 | 367 | exit; |
368 | 368 | } |
369 | 369 | |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false) |
398 | 398 | { |
399 | - $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
399 | + $ret = $this->handler->_moduleUrl.'admin/'.$this->handler->_page.'?op=view&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName); |
|
400 | 400 | if ($onlyUrl) { |
401 | 401 | return $ret; |
402 | 402 | } elseif ($withimage) { |
403 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "viewmag.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_ADMIN_VIEW . "' title='" . _CO_SOBJECT_ADMIN_VIEW . "'></a>"; |
|
403 | + return "<a href='".$ret."'><img src='".SMARTOBJECT_IMAGES_ACTIONS_URL."viewmag.png' style='vertical-align: middle;' alt='"._CO_SOBJECT_ADMIN_VIEW."' title='"._CO_SOBJECT_ADMIN_VIEW."'></a>"; |
|
404 | 404 | } |
405 | 405 | |
406 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
406 | + return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>'; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -425,15 +425,15 @@ discard block |
||
425 | 425 | $seoIncludeId = true; |
426 | 426 | |
427 | 427 | if ($seoMode === 'rewrite') { |
428 | - $ret = XOOPS_URL . '/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
428 | + $ret = XOOPS_URL.'/'.$seoModuleName.'.'.$this->handler->_itemname.($seoIncludeId ? '.'.$smartObj->getVar($this->handler->keyName) : '').'/'.$smartObj->getVar('short_url').'.html'; |
|
429 | 429 | } elseif ($seoMode === 'pathinfo') { |
430 | - $ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; |
|
430 | + $ret = SMARTOBJECT_URL.'seo.php/'.$seoModuleName.'.'.$this->handler->_itemname.($seoIncludeId ? '.'.$smartObj->getVar($this->handler->keyName) : '').'/'.$smartObj->getVar('short_url').'.html'; |
|
431 | 431 | } else { |
432 | - $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
432 | + $ret = $this->handler->_moduleUrl.$this->handler->_page.'?'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | if (!$onlyUrl) { |
436 | - $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
436 | + $ret = "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>'; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $ret; |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true) |
449 | 449 | { |
450 | - $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName) . '&language=' . $smartObj->getVar('language'); |
|
450 | + $ret = $this->handler->_moduleUrl.'admin/'.$this->handler->_page.'?op=mod&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName).'&language='.$smartObj->getVar('language'); |
|
451 | 451 | if ($onlyUrl) { |
452 | 452 | return $ret; |
453 | 453 | } elseif ($withimage) { |
454 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "wizard.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_LANGUAGE_MODIFY . "' title='" . _CO_SOBJECT_LANGUAGE_MODIFY . "'></a>"; |
|
454 | + return "<a href='".$ret."'><img src='".SMARTOBJECT_IMAGES_ACTIONS_URL."wizard.png' style='vertical-align: middle;' alt='"._CO_SOBJECT_LANGUAGE_MODIFY."' title='"._CO_SOBJECT_LANGUAGE_MODIFY."'></a>"; |
|
455 | 455 | } |
456 | 456 | |
457 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
457 | + return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>'; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
468 | 468 | { |
469 | 469 | $admin_side = $userSide ? '' : 'admin/'; |
470 | - $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
470 | + $ret = $this->handler->_moduleUrl.$admin_side.$this->handler->_page.'?op=mod&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName); |
|
471 | 471 | if ($onlyUrl) { |
472 | 472 | return $ret; |
473 | 473 | } elseif ($withimage) { |
474 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "edit.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_MODIFY . "' title='" . _CO_SOBJECT_MODIFY . "'></a>"; |
|
474 | + return "<a href='".$ret."'><img src='".SMARTOBJECT_IMAGES_ACTIONS_URL."edit.png' style='vertical-align: middle;' alt='"._CO_SOBJECT_MODIFY."' title='"._CO_SOBJECT_MODIFY."'></a>"; |
|
475 | 475 | } |
476 | 476 | |
477 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
477 | + return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>'; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -487,14 +487,14 @@ discard block |
||
487 | 487 | public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) |
488 | 488 | { |
489 | 489 | $admin_side = $userSide ? '' : 'admin/'; |
490 | - $ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
490 | + $ret = $this->handler->_moduleUrl.$admin_side.$this->handler->_page.'?op=del&'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName); |
|
491 | 491 | if ($onlyUrl) { |
492 | 492 | return $ret; |
493 | 493 | } elseif ($withimage) { |
494 | - return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "editdelete.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_DELETE . "' title='" . _CO_SOBJECT_DELETE . "'></a>"; |
|
494 | + return "<a href='".$ret."'><img src='".SMARTOBJECT_IMAGES_ACTIONS_URL."editdelete.png' style='vertical-align: middle;' alt='"._CO_SOBJECT_DELETE."' title='"._CO_SOBJECT_DELETE."'></a>"; |
|
495 | 495 | } |
496 | 496 | |
497 | - return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; |
|
497 | + return "<a href='".$ret."'>".$smartObj->getVar($this->handler->identifierName).'</a>'; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | { |
506 | 506 | global $xoopsConfig; |
507 | 507 | |
508 | - $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); |
|
509 | - $js = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);"; |
|
510 | - $printlink = '<a href="' . $js . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"></a>'; |
|
508 | + $printlink = $this->handler->_moduleUrl.'print.php?'.$this->handler->keyName.'='.$smartObj->getVar($this->handler->keyName); |
|
509 | + $js = "javascript:openWithSelfMain('".$printlink."', 'smartpopup', 700, 519);"; |
|
510 | + $printlink = '<a href="'.$js.'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'fileprint.png" alt="" style="vertical-align: middle;"></a>'; |
|
511 | 511 | |
512 | 512 | $smartModule = smart_getModuleInfo($smartObj->handler->_moduleName); |
513 | 513 | $link = smart_getCurrentPage(); |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | . _CO_SOBJECT_EMAIL |
527 | 527 | . "\" style=\"vertical-align: middle;\"></a>"; |
528 | 528 | |
529 | - $ret = '<span id="smartobject_print_button">' . $printlink . ' </span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>'; |
|
529 | + $ret = '<span id="smartobject_print_button">'.$printlink.' </span>'.'<span id="smartobject_mail_button">'.$friendlink.'</span>'; |
|
530 | 530 | |
531 | 531 | return $ret; |
532 | 532 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | */ |
537 | 537 | public function getModuleItemString() |
538 | 538 | { |
539 | - $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname; |
|
539 | + $ret = $this->handler->_moduleName.'_'.$this->handler->_itemname; |
|
540 | 540 | |
541 | 541 | return $ret; |
542 | 542 | } |
@@ -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 | } |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function smartobject_addto_show($options) |
10 | 10 | { |
11 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'; |
|
12 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php'; |
|
13 | - $smartaddto = new SmartAddTo($options[0]); |
|
14 | - $block = $smartaddto->renderForBlock(); |
|
11 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'; |
|
12 | + require_once SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php'; |
|
13 | + $smartaddto = new SmartAddTo($options[0]); |
|
14 | + $block = $smartaddto->renderForBlock(); |
|
15 | 15 | |
16 | - return $block; |
|
16 | + return $block; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function smartobject_addto_edit($options) |
24 | 24 | { |
25 | - require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
25 | + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
26 | 26 | |
27 | - $form = ''; |
|
27 | + $form = ''; |
|
28 | 28 | |
29 | - $layout_select = new XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]); |
|
30 | - $layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0); |
|
31 | - $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1); |
|
32 | - $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2); |
|
33 | - $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3); |
|
34 | - $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br>'; |
|
29 | + $layout_select = new XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]); |
|
30 | + $layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0); |
|
31 | + $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1); |
|
32 | + $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2); |
|
33 | + $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3); |
|
34 | + $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br>'; |
|
35 | 35 | |
36 | - return $form; |
|
36 | + return $form; |
|
37 | 37 | } |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function smartobject_addto_show($options) |
10 | 10 | { |
11 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'; |
|
12 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php'; |
|
11 | + require_once XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php'; |
|
12 | + require_once SMARTOBJECT_ROOT_PATH.'class/smartaddto.php'; |
|
13 | 13 | $smartaddto = new SmartAddTo($options[0]); |
14 | 14 | $block = $smartaddto->renderForBlock(); |
15 | 15 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function smartobject_addto_edit($options) |
24 | 24 | { |
25 | - require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
25 | + require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
26 | 26 | |
27 | 27 | $form = ''; |
28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1); |
32 | 32 | $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2); |
33 | 33 | $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3); |
34 | - $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br>'; |
|
34 | + $form .= $layout_select->getCaption().' '.$layout_select->render().'<br>'; |
|
35 | 35 | |
36 | 36 | return $form; |
37 | 37 | } |
@@ -26,82 +26,82 @@ |
||
26 | 26 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
27 | 27 | |
28 | 28 | switch ($op) { |
29 | - case 'sendlink': |
|
30 | - |
|
31 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
32 | - $controller = new SmartObjectController($smartobjectLinkHandler); |
|
33 | - |
|
34 | - $linkObj = $controller->storeSmartObject(); |
|
35 | - if ($linkObj->hasError()) { |
|
36 | - /** |
|
37 | - * @todo inform user and propose to close the window if a problem occured when saving the link |
|
38 | - */ |
|
39 | - } |
|
40 | - |
|
41 | - $xoopsMailer = xoops_getMailer(); |
|
42 | - $xoopsMailer->useMail(); |
|
43 | - $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
44 | - |
|
45 | - $xoopsMailer->setTemplate('sendlink.tpl'); |
|
46 | - $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
47 | - $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
48 | - $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
49 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
50 | - $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
51 | - $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
52 | - $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
53 | - $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
54 | - $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
55 | - $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
56 | - |
|
57 | - if (!$xoopsMailer->send(true)) { |
|
58 | - $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
59 | - } else { |
|
60 | - $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
61 | - } |
|
62 | - |
|
63 | - break; |
|
64 | - |
|
65 | - default: |
|
66 | - if (isset($_GET['mid'])) { |
|
67 | - $mid = $_GET['mid']; |
|
68 | - } else { |
|
69 | - /** |
|
70 | - * @todo close the window if no mid is passed as GET |
|
71 | - */ |
|
72 | - } |
|
73 | - |
|
74 | - $hModule = xoops_getHandler('module'); |
|
75 | - $module = $hModule->get($mid); |
|
76 | - $linkObj->setVar('mid', $module->getVar('mid')); |
|
77 | - $linkObj->setVar('mid_name', $module->getVar('name')); |
|
78 | - |
|
79 | - if (isset($_GET['link'])) { |
|
80 | - $link = $_GET['link']; |
|
81 | - } else { |
|
82 | - /** |
|
83 | - * @todo close the window if no link is passed as GET |
|
84 | - */ |
|
85 | - } |
|
86 | - $linkObj->setVar('link', $link); |
|
87 | - |
|
88 | - if (is_object($xoopsUser)) { |
|
89 | - $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
90 | - $linkObj->setVar('from_name', $xoopsUser->getVar('name') !== '' ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
91 | - $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
92 | - } |
|
93 | - |
|
94 | - $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
95 | - $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
96 | - $linkObj->setVar('date', time()); |
|
97 | - $linkObj->hideFieldFromForm(array('from_uid', 'to_uid', 'link', 'mid', 'mid_name')); |
|
98 | - |
|
99 | - $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
100 | - |
|
101 | - $form->assign($xoopsTpl); |
|
102 | - |
|
103 | - $xoopsTpl->assign('showform', true); |
|
104 | - break; |
|
29 | + case 'sendlink': |
|
30 | + |
|
31 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
32 | + $controller = new SmartObjectController($smartobjectLinkHandler); |
|
33 | + |
|
34 | + $linkObj = $controller->storeSmartObject(); |
|
35 | + if ($linkObj->hasError()) { |
|
36 | + /** |
|
37 | + * @todo inform user and propose to close the window if a problem occured when saving the link |
|
38 | + */ |
|
39 | + } |
|
40 | + |
|
41 | + $xoopsMailer = xoops_getMailer(); |
|
42 | + $xoopsMailer->useMail(); |
|
43 | + $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
44 | + |
|
45 | + $xoopsMailer->setTemplate('sendlink.tpl'); |
|
46 | + $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
47 | + $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
48 | + $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
49 | + $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
50 | + $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
51 | + $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
52 | + $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
53 | + $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
54 | + $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
55 | + $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
56 | + |
|
57 | + if (!$xoopsMailer->send(true)) { |
|
58 | + $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
59 | + } else { |
|
60 | + $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
61 | + } |
|
62 | + |
|
63 | + break; |
|
64 | + |
|
65 | + default: |
|
66 | + if (isset($_GET['mid'])) { |
|
67 | + $mid = $_GET['mid']; |
|
68 | + } else { |
|
69 | + /** |
|
70 | + * @todo close the window if no mid is passed as GET |
|
71 | + */ |
|
72 | + } |
|
73 | + |
|
74 | + $hModule = xoops_getHandler('module'); |
|
75 | + $module = $hModule->get($mid); |
|
76 | + $linkObj->setVar('mid', $module->getVar('mid')); |
|
77 | + $linkObj->setVar('mid_name', $module->getVar('name')); |
|
78 | + |
|
79 | + if (isset($_GET['link'])) { |
|
80 | + $link = $_GET['link']; |
|
81 | + } else { |
|
82 | + /** |
|
83 | + * @todo close the window if no link is passed as GET |
|
84 | + */ |
|
85 | + } |
|
86 | + $linkObj->setVar('link', $link); |
|
87 | + |
|
88 | + if (is_object($xoopsUser)) { |
|
89 | + $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
90 | + $linkObj->setVar('from_name', $xoopsUser->getVar('name') !== '' ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
91 | + $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
92 | + } |
|
93 | + |
|
94 | + $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
95 | + $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
96 | + $linkObj->setVar('date', time()); |
|
97 | + $linkObj->hideFieldFromForm(array('from_uid', 'to_uid', 'link', 'mid', 'mid_name')); |
|
98 | + |
|
99 | + $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
100 | + |
|
101 | + $form->assign($xoopsTpl); |
|
102 | + |
|
103 | + $xoopsTpl->assign('showform', true); |
|
104 | + break; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $xoopsTpl->display('db:smartobject_sendlink.tpl'); |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * Licence: GNU |
8 | 8 | */ |
9 | 9 | |
10 | -require_once __DIR__ . '/header.php'; |
|
11 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartloader.php'; |
|
12 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectlink.php'; |
|
13 | -require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
10 | +require_once __DIR__.'/header.php'; |
|
11 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartloader.php'; |
|
12 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectlink.php'; |
|
13 | +require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
14 | 14 | |
15 | 15 | $xoopsTpl = new XoopsTpl(); |
16 | 16 | $myts = MyTextSanitizer::getInstance(); |
17 | 17 | $xoopsConfig['sitename'] = $myts->displayTarea($xoopsConfig['sitename']); |
18 | 18 | |
19 | 19 | xoops_header(false); |
20 | -echo smart_get_css_link(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
20 | +echo smart_get_css_link(SMARTOBJECT_URL.'assets/css/module.css'); |
|
21 | 21 | echo '</head><body>'; |
22 | 22 | |
23 | 23 | $smartobjectLinkHandler = xoops_getModuleHandler('link', 'smartobject'); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | switch ($op) { |
29 | 29 | case 'sendlink': |
30 | 30 | |
31 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
31 | + require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php'; |
|
32 | 32 | $controller = new SmartObjectController($smartobjectLinkHandler); |
33 | 33 | |
34 | 34 | $linkObj = $controller->storeSmartObject(); |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | $xoopsMailer = xoops_getMailer(); |
42 | 42 | $xoopsMailer->useMail(); |
43 | - $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
43 | + $xoopsMailer->setTemplateDir('language/'.$xoopsConfig['language'].'/mail_template'); |
|
44 | 44 | |
45 | 45 | $xoopsMailer->setTemplate('sendlink.tpl'); |
46 | 46 | $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
47 | 47 | $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
48 | 48 | $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
49 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
49 | + $xoopsMailer->assign('SITEURL', XOOPS_URL.'/'); |
|
50 | 50 | $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
51 | 51 | $xoopsMailer->assign('MESSAGE', $_POST['body']); |
52 | 52 | $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
56 | 56 | |
57 | 57 | if (!$xoopsMailer->send(true)) { |
58 | - $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
58 | + $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']).'<br>'.$xoopsMailer->getErrors(true)); |
|
59 | 59 | } else { |
60 | 60 | $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
61 | 61 | } |
@@ -12,32 +12,32 @@ discard block |
||
12 | 12 | |
13 | 13 | function editclass($showmenu = false, $adsenseid = 0, $clone = false) |
14 | 14 | { |
15 | - global $smartobjectAdsenseHandler; |
|
16 | - |
|
17 | - $adsenseObj = $smartobjectAdsenseHandler->get($adsenseid); |
|
18 | - |
|
19 | - if (!$clone && !$adsenseObj->isNew()) { |
|
20 | - if ($showmenu) { |
|
21 | - //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING); |
|
22 | - } |
|
23 | - smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO); |
|
24 | - |
|
25 | - $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense'); |
|
26 | - $sform->display(); |
|
27 | - smart_close_collapsable('adsenseedit'); |
|
28 | - } else { |
|
29 | - $adsenseObj->setVar('adsenseid', 0); |
|
30 | - $adsenseObj->setVar('tag', ''); |
|
31 | - |
|
32 | - if ($showmenu) { |
|
33 | - //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW); |
|
34 | - } |
|
35 | - |
|
36 | - smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO); |
|
37 | - $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true); |
|
38 | - $sform->display(); |
|
39 | - smart_close_collapsable('adsensecreate'); |
|
40 | - } |
|
15 | + global $smartobjectAdsenseHandler; |
|
16 | + |
|
17 | + $adsenseObj = $smartobjectAdsenseHandler->get($adsenseid); |
|
18 | + |
|
19 | + if (!$clone && !$adsenseObj->isNew()) { |
|
20 | + if ($showmenu) { |
|
21 | + //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING); |
|
22 | + } |
|
23 | + smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO); |
|
24 | + |
|
25 | + $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense'); |
|
26 | + $sform->display(); |
|
27 | + smart_close_collapsable('adsenseedit'); |
|
28 | + } else { |
|
29 | + $adsenseObj->setVar('adsenseid', 0); |
|
30 | + $adsenseObj->setVar('tag', ''); |
|
31 | + |
|
32 | + if ($showmenu) { |
|
33 | + //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW); |
|
34 | + } |
|
35 | + |
|
36 | + smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO); |
|
37 | + $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true); |
|
38 | + $sform->display(); |
|
39 | + smart_close_collapsable('adsensecreate'); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | require_once __DIR__ . '/admin_header.php'; |
@@ -50,73 +50,73 @@ discard block |
||
50 | 50 | $op = ''; |
51 | 51 | |
52 | 52 | if (isset($_GET['op'])) { |
53 | - $op = $_GET['op']; |
|
53 | + $op = $_GET['op']; |
|
54 | 54 | } |
55 | 55 | if (isset($_POST['op'])) { |
56 | - $op = $_POST['op']; |
|
56 | + $op = $_POST['op']; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | switch ($op) { |
60 | - case 'mod': |
|
60 | + case 'mod': |
|
61 | 61 | |
62 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
62 | + $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
63 | 63 | |
64 | - smart_xoops_cp_header(); |
|
65 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
64 | + smart_xoops_cp_header(); |
|
65 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
66 | 66 | |
67 | - editclass(true, $adsenseid); |
|
68 | - break; |
|
67 | + editclass(true, $adsenseid); |
|
68 | + break; |
|
69 | 69 | |
70 | - case 'clone': |
|
70 | + case 'clone': |
|
71 | 71 | |
72 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
72 | + $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
73 | 73 | |
74 | - smart_xoops_cp_header(); |
|
75 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
74 | + smart_xoops_cp_header(); |
|
75 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
76 | 76 | |
77 | - editclass(true, $adsenseid, true); |
|
78 | - break; |
|
77 | + editclass(true, $adsenseid, true); |
|
78 | + break; |
|
79 | 79 | |
80 | - case 'addadsense': |
|
81 | - if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') { |
|
82 | - $xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
83 | - if (!$xoopsCaptcha->verify()) { |
|
84 | - redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage()); |
|
85 | - exit; |
|
86 | - } |
|
87 | - } |
|
88 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
89 | - $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
90 | - $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED); |
|
91 | - break; |
|
80 | + case 'addadsense': |
|
81 | + if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') { |
|
82 | + $xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
83 | + if (!$xoopsCaptcha->verify()) { |
|
84 | + redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage()); |
|
85 | + exit; |
|
86 | + } |
|
87 | + } |
|
88 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
89 | + $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
90 | + $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED); |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'del': |
|
93 | + case 'del': |
|
94 | 94 | |
95 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
96 | - $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
97 | - $controller->handleObjectDeletion(); |
|
95 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
96 | + $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
97 | + $controller->handleObjectDeletion(); |
|
98 | 98 | |
99 | - break; |
|
99 | + break; |
|
100 | 100 | |
101 | - default: |
|
101 | + default: |
|
102 | 102 | |
103 | - smart_xoops_cp_header(); |
|
104 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
103 | + smart_xoops_cp_header(); |
|
104 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
105 | 105 | |
106 | - //smart_adminMenu(3, _AM_SOBJECT_ADSENSES); |
|
106 | + //smart_adminMenu(3, _AM_SOBJECT_ADSENSES); |
|
107 | 107 | |
108 | - smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC); |
|
108 | + smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC); |
|
109 | 109 | |
110 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
111 | - $objectTable = new SmartObjectTable($smartobjectAdsenseHandler); |
|
112 | - $objectTable->addColumn(new SmartObjectColumn('description', 'left')); |
|
113 | - $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode')); |
|
110 | + require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
111 | + $objectTable = new SmartObjectTable($smartobjectAdsenseHandler); |
|
112 | + $objectTable->addColumn(new SmartObjectColumn('description', 'left')); |
|
113 | + $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode')); |
|
114 | 114 | |
115 | - // $objectTable->addCustomAction('getCreateItemLink'); |
|
116 | - // $objectTable->addCustomAction('getCreateAttributLink'); |
|
115 | + // $objectTable->addCustomAction('getCreateItemLink'); |
|
116 | + // $objectTable->addCustomAction('getCreateAttributLink'); |
|
117 | 117 | |
118 | - $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE); |
|
119 | - /* |
|
118 | + $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE); |
|
119 | + /* |
|
120 | 120 | $criteria_upcoming = new CriteriaCompo(); |
121 | 121 | $criteria_upcoming->add(new Criteria('start_date', time(), '>')); |
122 | 122 | $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array( |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | 'criteria' => $criteria_last30days |
141 | 141 | )); |
142 | 142 | */ |
143 | - $objectTable->addQuickSearch(array('title', 'summary', 'description')); |
|
144 | - $objectTable->addCustomAction('getCloneLink'); |
|
143 | + $objectTable->addQuickSearch(array('title', 'summary', 'description')); |
|
144 | + $objectTable->addCustomAction('getCloneLink'); |
|
145 | 145 | |
146 | - $objectTable->render(); |
|
146 | + $objectTable->render(); |
|
147 | 147 | |
148 | - echo '<br>'; |
|
149 | - smart_close_collapsable('createdadsenses'); |
|
150 | - echo '<br>'; |
|
148 | + echo '<br>'; |
|
149 | + smart_close_collapsable('createdadsenses'); |
|
150 | + echo '<br>'; |
|
151 | 151 | |
152 | - break; |
|
152 | + break; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | //smart_modFooter(); |
@@ -57,66 +57,66 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | switch ($op) { |
60 | - case 'mod': |
|
60 | + case 'mod': |
|
61 | 61 | |
62 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
62 | + $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
63 | 63 | |
64 | - smart_xoops_cp_header(); |
|
65 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
64 | + smart_xoops_cp_header(); |
|
65 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
66 | 66 | |
67 | - editclass(true, $adsenseid); |
|
68 | - break; |
|
67 | + editclass(true, $adsenseid); |
|
68 | + break; |
|
69 | 69 | |
70 | - case 'clone': |
|
70 | + case 'clone': |
|
71 | 71 | |
72 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
72 | + $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
73 | 73 | |
74 | - smart_xoops_cp_header(); |
|
75 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
74 | + smart_xoops_cp_header(); |
|
75 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
76 | 76 | |
77 | - editclass(true, $adsenseid, true); |
|
78 | - break; |
|
77 | + editclass(true, $adsenseid, true); |
|
78 | + break; |
|
79 | 79 | |
80 | - case 'addadsense': |
|
81 | - if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') { |
|
82 | - $xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
83 | - if (!$xoopsCaptcha->verify()) { |
|
84 | - redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage()); |
|
85 | - exit; |
|
86 | - } |
|
87 | - } |
|
88 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
89 | - $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
90 | - $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED); |
|
91 | - break; |
|
80 | + case 'addadsense': |
|
81 | + if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') { |
|
82 | + $xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
83 | + if (!$xoopsCaptcha->verify()) { |
|
84 | + redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage()); |
|
85 | + exit; |
|
86 | + } |
|
87 | + } |
|
88 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
89 | + $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
90 | + $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED); |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'del': |
|
93 | + case 'del': |
|
94 | 94 | |
95 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
96 | - $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
97 | - $controller->handleObjectDeletion(); |
|
95 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
96 | + $controller = new SmartObjectController($smartobjectAdsenseHandler); |
|
97 | + $controller->handleObjectDeletion(); |
|
98 | 98 | |
99 | - break; |
|
99 | + break; |
|
100 | 100 | |
101 | - default: |
|
101 | + default: |
|
102 | 102 | |
103 | - smart_xoops_cp_header(); |
|
104 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
103 | + smart_xoops_cp_header(); |
|
104 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
105 | 105 | |
106 | - //smart_adminMenu(3, _AM_SOBJECT_ADSENSES); |
|
106 | + //smart_adminMenu(3, _AM_SOBJECT_ADSENSES); |
|
107 | 107 | |
108 | - smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC); |
|
108 | + smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC); |
|
109 | 109 | |
110 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
111 | - $objectTable = new SmartObjectTable($smartobjectAdsenseHandler); |
|
112 | - $objectTable->addColumn(new SmartObjectColumn('description', 'left')); |
|
113 | - $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode')); |
|
110 | + require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
111 | + $objectTable = new SmartObjectTable($smartobjectAdsenseHandler); |
|
112 | + $objectTable->addColumn(new SmartObjectColumn('description', 'left')); |
|
113 | + $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode')); |
|
114 | 114 | |
115 | - // $objectTable->addCustomAction('getCreateItemLink'); |
|
116 | - // $objectTable->addCustomAction('getCreateAttributLink'); |
|
115 | + // $objectTable->addCustomAction('getCreateItemLink'); |
|
116 | + // $objectTable->addCustomAction('getCreateAttributLink'); |
|
117 | 117 | |
118 | - $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE); |
|
119 | - /* |
|
118 | + $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE); |
|
119 | + /* |
|
120 | 120 | $criteria_upcoming = new CriteriaCompo(); |
121 | 121 | $criteria_upcoming->add(new Criteria('start_date', time(), '>')); |
122 | 122 | $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array( |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | 'criteria' => $criteria_last30days |
141 | 141 | )); |
142 | 142 | */ |
143 | - $objectTable->addQuickSearch(array('title', 'summary', 'description')); |
|
144 | - $objectTable->addCustomAction('getCloneLink'); |
|
143 | + $objectTable->addQuickSearch(array('title', 'summary', 'description')); |
|
144 | + $objectTable->addCustomAction('getCloneLink'); |
|
145 | 145 | |
146 | - $objectTable->render(); |
|
146 | + $objectTable->render(); |
|
147 | 147 | |
148 | - echo '<br>'; |
|
149 | - smart_close_collapsable('createdadsenses'); |
|
150 | - echo '<br>'; |
|
148 | + echo '<br>'; |
|
149 | + smart_close_collapsable('createdadsenses'); |
|
150 | + echo '<br>'; |
|
151 | 151 | |
152 | - break; |
|
152 | + break; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | //smart_modFooter(); |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -require_once __DIR__ . '/admin_header.php'; |
|
44 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
45 | -require_once SMARTOBJECT_ROOT_PATH . 'class/adsense.php'; |
|
43 | +require_once __DIR__.'/admin_header.php'; |
|
44 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php'; |
|
45 | +require_once SMARTOBJECT_ROOT_PATH.'class/adsense.php'; |
|
46 | 46 | $smartobjectAdsenseHandler = xoops_getModuleHandler('adsense'); |
47 | 47 | smart_loadLanguageFile('smartobject', 'adsense'); |
48 | 48 | $adminObject = \Xmf\Module\Admin::getInstance(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | switch ($op) { |
60 | 60 | case 'mod': |
61 | 61 | |
62 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
62 | + $adsenseid = isset($_GET['adsenseid']) ? (int) $_GET['adsenseid'] : 0; |
|
63 | 63 | |
64 | 64 | smart_xoops_cp_header(); |
65 | 65 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | case 'clone': |
71 | 71 | |
72 | - $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0; |
|
72 | + $adsenseid = isset($_GET['adsenseid']) ? (int) $_GET['adsenseid'] : 0; |
|
73 | 73 | |
74 | 74 | smart_xoops_cp_header(); |
75 | 75 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | break; |
79 | 79 | |
80 | 80 | case 'addadsense': |
81 | - if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') { |
|
81 | + if (@require_once SMARTOBJECT_ROOT_PATH.'include/captcha/captcha.php') { |
|
82 | 82 | $xoopsCaptcha = XoopsCaptcha::getInstance(); |
83 | 83 | if (!$xoopsCaptcha->verify()) { |
84 | 84 | redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage()); |
85 | 85 | exit; |
86 | 86 | } |
87 | 87 | } |
88 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
88 | + require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php'; |
|
89 | 89 | $controller = new SmartObjectController($smartobjectAdsenseHandler); |
90 | 90 | $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED); |
91 | 91 | break; |
92 | 92 | |
93 | 93 | case 'del': |
94 | 94 | |
95 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
95 | + require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobjectcontroller.php'; |
|
96 | 96 | $controller = new SmartObjectController($smartobjectAdsenseHandler); |
97 | 97 | $controller->handleObjectDeletion(); |
98 | 98 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC); |
109 | 109 | |
110 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php'; |
|
110 | + require_once SMARTOBJECT_ROOT_PATH.'class/smartobjecttable.php'; |
|
111 | 111 | $objectTable = new SmartObjectTable($smartobjectAdsenseHandler); |
112 | 112 | $objectTable->addColumn(new SmartObjectColumn('description', 'left')); |
113 | 113 | $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode')); |
@@ -154,4 +154,4 @@ discard block |
||
154 | 154 | |
155 | 155 | //smart_modFooter(); |
156 | 156 | //xoops_cp_footer(); |
157 | -require_once __DIR__ . '/admin_footer.php'; |
|
157 | +require_once __DIR__.'/admin_footer.php'; |