@@ -11,18 +11,18 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormAutocompleteElement extends SmartAutocompleteElement |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * SmartFormAutocompleteElement constructor. |
|
| 16 | - * @param string $object |
|
| 17 | - * @param string $key |
|
| 18 | - */ |
|
| 19 | - public function __construct($object, $key) |
|
| 20 | - { |
|
| 21 | - $var = $object->vars[$key]; |
|
| 22 | - $control = $object->controls[$key]; |
|
| 23 | - $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255); |
|
| 14 | + /** |
|
| 15 | + * SmartFormAutocompleteElement constructor. |
|
| 16 | + * @param string $object |
|
| 17 | + * @param string $key |
|
| 18 | + */ |
|
| 19 | + public function __construct($object, $key) |
|
| 20 | + { |
|
| 21 | + $var = $object->vars[$key]; |
|
| 22 | + $control = $object->controls[$key]; |
|
| 23 | + $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255); |
|
| 24 | 24 | |
| 25 | - $form_size = isset($control['size']) ? $control['size'] : 50; |
|
| 26 | - parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e')); |
|
| 27 | - } |
|
| 25 | + $form_size = isset($control['size']) ? $control['size'] : 50; |
|
| 26 | + parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e')); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormYesnoElement extends XoopsFormRadioYN |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * SmartFormYesnoElement constructor. |
|
| 16 | - * @param string $object |
|
| 17 | - * @param string $key |
|
| 18 | - */ |
|
| 19 | - public function __construct($object, $key) |
|
| 20 | - { |
|
| 21 | - parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 22 | - } |
|
| 14 | + /** |
|
| 15 | + * SmartFormYesnoElement constructor. |
|
| 16 | + * @param string $object |
|
| 17 | + * @param string $key |
|
| 18 | + */ |
|
| 19 | + public function __construct($object, $key) |
|
| 20 | + { |
|
| 21 | + parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -36,29 +36,29 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class SmartobjectBasedUrl extends SmartObject |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * SmartobjectBasedUrl constructor. |
|
| 41 | - */ |
|
| 42 | - public function __construct() |
|
| 43 | - { |
|
| 44 | - $this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false); |
|
| 45 | - $this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false); |
|
| 46 | - $this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false); |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * SmartobjectBasedUrl constructor. |
|
| 41 | + */ |
|
| 42 | + public function __construct() |
|
| 43 | + { |
|
| 44 | + $this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false); |
|
| 45 | + $this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false); |
|
| 46 | + $this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param string $key |
|
| 51 | - * @param string $format |
|
| 52 | - * @return mixed |
|
| 53 | - */ |
|
| 54 | - public function getVar($key, $format = 'e') |
|
| 55 | - { |
|
| 56 | - if (0 === strpos($key, 'url_')) { |
|
| 57 | - return parent::getVar('url', $format); |
|
| 58 | - } elseif (0 === strpos($key, 'caption_')) { |
|
| 59 | - return parent::getVar('caption', $format); |
|
| 60 | - } else { |
|
| 61 | - return parent::getVar($key, $format); |
|
| 62 | - } |
|
| 63 | - } |
|
| 49 | + /** |
|
| 50 | + * @param string $key |
|
| 51 | + * @param string $format |
|
| 52 | + * @return mixed |
|
| 53 | + */ |
|
| 54 | + public function getVar($key, $format = 'e') |
|
| 55 | + { |
|
| 56 | + if (0 === strpos($key, 'url_')) { |
|
| 57 | + return parent::getVar('url', $format); |
|
| 58 | + } elseif (0 === strpos($key, 'caption_')) { |
|
| 59 | + return parent::getVar('caption', $format); |
|
| 60 | + } else { |
|
| 61 | + return parent::getVar($key, $format); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 31 | 31 | |
| 32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
| 32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Class SmartobjectBasedUrl |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * @param $smartObj |
| 126 | - * @param $objectid |
|
| 127 | - * @param $created_success_msg |
|
| 128 | - * @param $modified_success_msg |
|
| 126 | + * @param integer $objectid |
|
| 127 | + * @param string $created_success_msg |
|
| 128 | + * @param string $modified_success_msg |
|
| 129 | 129 | * @param bool $redirect_page |
| 130 | 130 | * @param bool $debug |
| 131 | 131 | * @return mixed |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param bool $confirm_msg |
| 290 | 290 | * @param string $op |
| 291 | 291 | * @param bool $userSide |
| 292 | - * @return bool |
|
| 292 | + * @return boolean|null |
|
| 293 | 293 | * @internal param string $redir_page redirect page after deleting the object |
| 294 | 294 | */ |
| 295 | 295 | public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false) |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | - * @param $smartObj |
|
| 446 | + * @param SmartMlObject $smartObj |
|
| 447 | 447 | * @param bool $onlyUrl |
| 448 | 448 | * @param bool $withimage |
| 449 | 449 | * @return string |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | - * @param $smartObj |
|
| 536 | + * @param SmartObject $smartObj |
|
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | public function getPrintAndMailLink($smartObj) |
@@ -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 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | /** |
| 34 | 34 | * @param $gperm_name |
| 35 | - * @param null $id |
|
| 35 | + * @param integer $id |
|
| 36 | 36 | * @return array |
| 37 | 37 | */ |
| 38 | 38 | public function getGrantedGroups($gperm_name, $id = null) |
@@ -192,7 +192,7 @@ |
||
| 192 | 192 | { |
| 193 | 193 | global $xoopsModule; |
| 194 | 194 | |
| 195 | - $smartModule =& smartsection_getModuleInfo(); |
|
| 195 | + $smartModule = & smartsection_getModuleInfo(); |
|
| 196 | 196 | |
| 197 | 197 | $result = true; |
| 198 | 198 | $module_id = $smartModule->getVar('mid'); |
@@ -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 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Access the only instance of this class |
| 20 | 20 | * |
| 21 | - * @return XoopsObject |
|
| 21 | + * @return SmartObjectsRegistry |
|
| 22 | 22 | * |
| 23 | 23 | * @static |
| 24 | 24 | * @staticvar object |
@@ -13,169 +13,169 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class SmartObjectsRegistry |
| 15 | 15 | { |
| 16 | - public $_registryArray; |
|
| 16 | + public $_registryArray; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Access the only instance of this class |
|
| 20 | - * |
|
| 21 | - * @return XoopsObject |
|
| 22 | - * |
|
| 23 | - * @static |
|
| 24 | - * @staticvar object |
|
| 25 | - */ |
|
| 26 | - public static function getInstance() |
|
| 27 | - { |
|
| 28 | - static $instance; |
|
| 29 | - if (null === $instance) { |
|
| 30 | - $instance = new static(); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Access the only instance of this class |
|
| 20 | + * |
|
| 21 | + * @return XoopsObject |
|
| 22 | + * |
|
| 23 | + * @static |
|
| 24 | + * @staticvar object |
|
| 25 | + */ |
|
| 26 | + public static function getInstance() |
|
| 27 | + { |
|
| 28 | + static $instance; |
|
| 29 | + if (null === $instance) { |
|
| 30 | + $instance = new static(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - return $instance; |
|
| 34 | - } |
|
| 33 | + return $instance; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Adding objects to the registry |
|
| 38 | - * |
|
| 39 | - * @param SmartPersistableObjectHandler $handler of the objects to add |
|
| 40 | - * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
| 41 | - * @return FALSE if an error occured |
|
| 42 | - */ |
|
| 43 | - public function addObjectsFromHandler(&$handler, $criteria = false) |
|
| 44 | - { |
|
| 45 | - if (method_exists($handler, 'getObjects')) { |
|
| 46 | - $objects = $handler->getObjects($criteria, true); |
|
| 47 | - $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects; |
|
| 36 | + /** |
|
| 37 | + * Adding objects to the registry |
|
| 38 | + * |
|
| 39 | + * @param SmartPersistableObjectHandler $handler of the objects to add |
|
| 40 | + * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
| 41 | + * @return FALSE if an error occured |
|
| 42 | + */ |
|
| 43 | + public function addObjectsFromHandler(&$handler, $criteria = false) |
|
| 44 | + { |
|
| 45 | + if (method_exists($handler, 'getObjects')) { |
|
| 46 | + $objects = $handler->getObjects($criteria, true); |
|
| 47 | + $this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects; |
|
| 48 | 48 | |
| 49 | - return $objects; |
|
| 50 | - } else { |
|
| 51 | - return false; |
|
| 52 | - } |
|
| 53 | - } |
|
| 49 | + return $objects; |
|
| 50 | + } else { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Adding objects to the registry from an item name |
|
| 57 | - * This method will fetch the handler of the item / module and call the addObjectsFromHandler |
|
| 58 | - * |
|
| 59 | - * @param string $item name of the item |
|
| 60 | - * @param bool|string $modulename name of the module |
|
| 61 | - * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
| 62 | - * @return FALSE if an error occured |
|
| 63 | - */ |
|
| 64 | - public function addObjectsFromItemName($item, $modulename = false, $criteria = false) |
|
| 65 | - { |
|
| 66 | - if (!$modulename) { |
|
| 67 | - global $xoopsModule; |
|
| 68 | - if (!is_object($xoopsModule)) { |
|
| 69 | - return false; |
|
| 70 | - } else { |
|
| 71 | - $modulename = $xoopsModule->dirname(); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - $objectHandler = xoops_getModuleHandler($item, $modulename); |
|
| 55 | + /** |
|
| 56 | + * Adding objects to the registry from an item name |
|
| 57 | + * This method will fetch the handler of the item / module and call the addObjectsFromHandler |
|
| 58 | + * |
|
| 59 | + * @param string $item name of the item |
|
| 60 | + * @param bool|string $modulename name of the module |
|
| 61 | + * @param bool|CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key) |
|
| 62 | + * @return FALSE if an error occured |
|
| 63 | + */ |
|
| 64 | + public function addObjectsFromItemName($item, $modulename = false, $criteria = false) |
|
| 65 | + { |
|
| 66 | + if (!$modulename) { |
|
| 67 | + global $xoopsModule; |
|
| 68 | + if (!is_object($xoopsModule)) { |
|
| 69 | + return false; |
|
| 70 | + } else { |
|
| 71 | + $modulename = $xoopsModule->dirname(); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + $objectHandler = xoops_getModuleHandler($item, $modulename); |
|
| 75 | 75 | |
| 76 | - if (method_exists($objectHandler, 'getObjects')) { |
|
| 77 | - $objects = $objectHandler->getObjects($criteria, true); |
|
| 78 | - $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects; |
|
| 76 | + if (method_exists($objectHandler, 'getObjects')) { |
|
| 77 | + $objects = $objectHandler->getObjects($criteria, true); |
|
| 78 | + $this->_registryArray['objects'][$objectHandler->_moduleName][$objectHandler->_itemname] = $objects; |
|
| 79 | 79 | |
| 80 | - return $objects; |
|
| 81 | - } else { |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - } |
|
| 80 | + return $objects; |
|
| 81 | + } else { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Fetching objects from the registry |
|
| 88 | - * |
|
| 89 | - * @param string $itemname |
|
| 90 | - * @param string $modulename |
|
| 91 | - * |
|
| 92 | - * @return the requested objects or FALSE if they don't exists in the registry |
|
| 93 | - */ |
|
| 94 | - public function getObjects($itemname, $modulename) |
|
| 95 | - { |
|
| 96 | - if (!$modulename) { |
|
| 97 | - global $xoopsModule; |
|
| 98 | - if (!is_object($xoopsModule)) { |
|
| 99 | - return false; |
|
| 100 | - } else { |
|
| 101 | - $modulename = $xoopsModule->dirname(); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - if (isset($this->_registryArray['objects'][$modulename][$itemname])) { |
|
| 105 | - return $this->_registryArray['objects'][$modulename][$itemname]; |
|
| 106 | - } else { |
|
| 107 | - // if they were not in registry, let's fetch them and add them to the reigistry |
|
| 108 | - $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 109 | - if (method_exists($moduleHandler, 'getObjects')) { |
|
| 110 | - $objects = $moduleHandler->getObjects(); |
|
| 111 | - } |
|
| 112 | - $this->_registryArray['objects'][$modulename][$itemname] = $objects; |
|
| 86 | + /** |
|
| 87 | + * Fetching objects from the registry |
|
| 88 | + * |
|
| 89 | + * @param string $itemname |
|
| 90 | + * @param string $modulename |
|
| 91 | + * |
|
| 92 | + * @return the requested objects or FALSE if they don't exists in the registry |
|
| 93 | + */ |
|
| 94 | + public function getObjects($itemname, $modulename) |
|
| 95 | + { |
|
| 96 | + if (!$modulename) { |
|
| 97 | + global $xoopsModule; |
|
| 98 | + if (!is_object($xoopsModule)) { |
|
| 99 | + return false; |
|
| 100 | + } else { |
|
| 101 | + $modulename = $xoopsModule->dirname(); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + if (isset($this->_registryArray['objects'][$modulename][$itemname])) { |
|
| 105 | + return $this->_registryArray['objects'][$modulename][$itemname]; |
|
| 106 | + } else { |
|
| 107 | + // if they were not in registry, let's fetch them and add them to the reigistry |
|
| 108 | + $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 109 | + if (method_exists($moduleHandler, 'getObjects')) { |
|
| 110 | + $objects = $moduleHandler->getObjects(); |
|
| 111 | + } |
|
| 112 | + $this->_registryArray['objects'][$modulename][$itemname] = $objects; |
|
| 113 | 113 | |
| 114 | - return $objects; |
|
| 115 | - } |
|
| 116 | - } |
|
| 114 | + return $objects; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Fetching objects from the registry, as a list: objectid => identifier |
|
| 120 | - * |
|
| 121 | - * @param string $itemname |
|
| 122 | - * @param string $modulename |
|
| 123 | - * |
|
| 124 | - * @return the requested objects or FALSE if they don't exists in the registry |
|
| 125 | - */ |
|
| 126 | - public function getList($itemname, $modulename) |
|
| 127 | - { |
|
| 128 | - if (!$modulename) { |
|
| 129 | - global $xoopsModule; |
|
| 130 | - if (!is_object($xoopsModule)) { |
|
| 131 | - return false; |
|
| 132 | - } else { |
|
| 133 | - $modulename = $xoopsModule->dirname(); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - if (isset($this->_registryArray['list'][$modulename][$itemname])) { |
|
| 137 | - return $this->_registryArray['list'][$modulename][$itemname]; |
|
| 138 | - } else { |
|
| 139 | - // if they were not in registry, let's fetch them and add them to the reigistry |
|
| 140 | - $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 141 | - if (method_exists($moduleHandler, 'getList')) { |
|
| 142 | - $objects = $moduleHandler->getList(); |
|
| 143 | - } |
|
| 144 | - $this->_registryArray['list'][$modulename][$itemname] = $objects; |
|
| 118 | + /** |
|
| 119 | + * Fetching objects from the registry, as a list: objectid => identifier |
|
| 120 | + * |
|
| 121 | + * @param string $itemname |
|
| 122 | + * @param string $modulename |
|
| 123 | + * |
|
| 124 | + * @return the requested objects or FALSE if they don't exists in the registry |
|
| 125 | + */ |
|
| 126 | + public function getList($itemname, $modulename) |
|
| 127 | + { |
|
| 128 | + if (!$modulename) { |
|
| 129 | + global $xoopsModule; |
|
| 130 | + if (!is_object($xoopsModule)) { |
|
| 131 | + return false; |
|
| 132 | + } else { |
|
| 133 | + $modulename = $xoopsModule->dirname(); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + if (isset($this->_registryArray['list'][$modulename][$itemname])) { |
|
| 137 | + return $this->_registryArray['list'][$modulename][$itemname]; |
|
| 138 | + } else { |
|
| 139 | + // if they were not in registry, let's fetch them and add them to the reigistry |
|
| 140 | + $moduleHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 141 | + if (method_exists($moduleHandler, 'getList')) { |
|
| 142 | + $objects = $moduleHandler->getList(); |
|
| 143 | + } |
|
| 144 | + $this->_registryArray['list'][$modulename][$itemname] = $objects; |
|
| 145 | 145 | |
| 146 | - return $objects; |
|
| 147 | - } |
|
| 148 | - } |
|
| 146 | + return $objects; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Retreive a single object |
|
| 152 | - * |
|
| 153 | - * @param string $itemname |
|
| 154 | - * @param string $key |
|
| 155 | - * |
|
| 156 | - * @param bool $modulename |
|
| 157 | - * @return the requestd object or FALSE if they don't exists in the registry |
|
| 158 | - */ |
|
| 159 | - public function getSingleObject($itemname, $key, $modulename = false) |
|
| 160 | - { |
|
| 161 | - if (!$modulename) { |
|
| 162 | - global $xoopsModule; |
|
| 163 | - if (!is_object($xoopsModule)) { |
|
| 164 | - return false; |
|
| 165 | - } else { |
|
| 166 | - $modulename = $xoopsModule->dirname(); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) { |
|
| 170 | - return $this->_registryArray['objects'][$modulename][$itemname][$key]; |
|
| 171 | - } else { |
|
| 172 | - $objectHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 173 | - $object = $objectHandler->get($key); |
|
| 174 | - if (!$object->isNew()) { |
|
| 175 | - return $object; |
|
| 176 | - } else { |
|
| 177 | - return false; |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - } |
|
| 150 | + /** |
|
| 151 | + * Retreive a single object |
|
| 152 | + * |
|
| 153 | + * @param string $itemname |
|
| 154 | + * @param string $key |
|
| 155 | + * |
|
| 156 | + * @param bool $modulename |
|
| 157 | + * @return the requestd object or FALSE if they don't exists in the registry |
|
| 158 | + */ |
|
| 159 | + public function getSingleObject($itemname, $key, $modulename = false) |
|
| 160 | + { |
|
| 161 | + if (!$modulename) { |
|
| 162 | + global $xoopsModule; |
|
| 163 | + if (!is_object($xoopsModule)) { |
|
| 164 | + return false; |
|
| 165 | + } else { |
|
| 166 | + $modulename = $xoopsModule->dirname(); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) { |
|
| 170 | + return $this->_registryArray['objects'][$modulename][$itemname][$key]; |
|
| 171 | + } else { |
|
| 172 | + $objectHandler = xoops_getModuleHandler($itemname, $modulename); |
|
| 173 | + $object = $objectHandler->get($key); |
|
| 174 | + if (!$object->isNew()) { |
|
| 175 | + return $object; |
|
| 176 | + } else { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | 181 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | - * @param $key |
|
| 328 | + * @param string $key |
|
| 329 | 329 | * @param bool $moduleName |
| 330 | 330 | * @param string $default |
| 331 | 331 | * @return null|string |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | 389 | * Thanks to the NewBB2 Development Team |
| 390 | - * @param $target |
|
| 390 | + * @param string $target |
|
| 391 | 391 | * @return bool |
| 392 | 392 | */ |
| 393 | 393 | function smart_admin_mkdir($target) |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | /** |
| 542 | 542 | * @param $dirname |
| 543 | - * @return bool |
|
| 543 | + * @return boolean|null |
|
| 544 | 544 | */ |
| 545 | 545 | function smart_deleteFile($dirname) |
| 546 | 546 | { |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | - * @param $name |
|
| 758 | + * @param string $name |
|
| 759 | 759 | */ |
| 760 | 760 | function smart_close_collapsable($name) |
| 761 | 761 | { |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
| 768 | - * @param $name |
|
| 768 | + * @param string $name |
|
| 769 | 769 | * @param $value |
| 770 | 770 | * @param int $time |
| 771 | 771 | */ |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
| 782 | - * @param $name |
|
| 782 | + * @param string $name |
|
| 783 | 783 | * @param string $default |
| 784 | 784 | * @return string |
| 785 | 785 | */ |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | /** |
| 941 | - * @param $src |
|
| 941 | + * @param string $src |
|
| 942 | 942 | */ |
| 943 | 943 | function smart_addScript($src) |
| 944 | 944 | { |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | /** |
| 1118 | - * @param $module |
|
| 1119 | - * @param $file |
|
| 1118 | + * @param string $module |
|
| 1119 | + * @param string $file |
|
| 1120 | 1120 | */ |
| 1121 | 1121 | function smart_loadLanguageFile($module, $file) |
| 1122 | 1122 | { |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | * This function should be able to cover almost all floats that appear in an european environment. |
| 1233 | 1233 | * @param $str |
| 1234 | 1234 | * @param bool $set |
| 1235 | - * @return float|int |
|
| 1235 | + * @return double |
|
| 1236 | 1236 | */ |
| 1237 | 1237 | function smart_getfloat($str, $set = false) |
| 1238 | 1238 | { |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | /** |
| 1268 | 1268 | * @param $var |
| 1269 | 1269 | * @param bool $currencyObj |
| 1270 | - * @return float|int|mixed|string |
|
| 1270 | + * @return string |
|
| 1271 | 1271 | */ |
| 1272 | 1272 | function smart_currency($var, $currencyObj = false) |
| 1273 | 1273 | { |
@@ -1295,7 +1295,7 @@ discard block |
||
| 1295 | 1295 | |
| 1296 | 1296 | /** |
| 1297 | 1297 | * @param $var |
| 1298 | - * @return float|int|mixed|string |
|
| 1298 | + * @return string |
|
| 1299 | 1299 | */ |
| 1300 | 1300 | function smart_float($var) |
| 1301 | 1301 | { |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | /** |
| 1344 | 1344 | * @param $moduleName |
| 1345 | 1345 | * @param $items |
| 1346 | - * @return array |
|
| 1346 | + * @return string[] |
|
| 1347 | 1347 | */ |
| 1348 | 1348 | function smart_getTablesArray($moduleName, $items) |
| 1349 | 1349 | { |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function smart_get_css_link($cssfile) |
| 13 | 13 | { |
| 14 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 14 | + $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 15 | 15 | |
| 16 | - return $ret; |
|
| 16 | + return $ret; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function smart_get_page_before_form() |
| 23 | 23 | { |
| 24 | - global $smart_previous_page; |
|
| 24 | + global $smart_previous_page; |
|
| 25 | 25 | |
| 26 | - return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 26 | + return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -34,29 +34,29 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function smart_userIsAdmin($module = false) |
| 36 | 36 | { |
| 37 | - global $xoopsUser; |
|
| 38 | - static $smart_isAdmin; |
|
| 39 | - if (!$module) { |
|
| 40 | - global $xoopsModule; |
|
| 41 | - $module = $xoopsModule->getVar('dirname'); |
|
| 42 | - } |
|
| 43 | - if (isset($smart_isAdmin[$module])) { |
|
| 44 | - return $smart_isAdmin[$module]; |
|
| 45 | - } |
|
| 46 | - if (!$xoopsUser) { |
|
| 47 | - $smart_isAdmin[$module] = false; |
|
| 48 | - |
|
| 49 | - return $smart_isAdmin[$module]; |
|
| 50 | - } |
|
| 51 | - $smart_isAdmin[$module] = false; |
|
| 52 | - $smartModule = smart_getModuleInfo($module); |
|
| 53 | - if (!is_object($smartModule)) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - $module_id = $smartModule->getVar('mid'); |
|
| 57 | - $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 58 | - |
|
| 59 | - return $smart_isAdmin[$module]; |
|
| 37 | + global $xoopsUser; |
|
| 38 | + static $smart_isAdmin; |
|
| 39 | + if (!$module) { |
|
| 40 | + global $xoopsModule; |
|
| 41 | + $module = $xoopsModule->getVar('dirname'); |
|
| 42 | + } |
|
| 43 | + if (isset($smart_isAdmin[$module])) { |
|
| 44 | + return $smart_isAdmin[$module]; |
|
| 45 | + } |
|
| 46 | + if (!$xoopsUser) { |
|
| 47 | + $smart_isAdmin[$module] = false; |
|
| 48 | + |
|
| 49 | + return $smart_isAdmin[$module]; |
|
| 50 | + } |
|
| 51 | + $smart_isAdmin[$module] = false; |
|
| 52 | + $smartModule = smart_getModuleInfo($module); |
|
| 53 | + if (!is_object($smartModule)) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + $module_id = $smartModule->getVar('mid'); |
|
| 57 | + $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 58 | + |
|
| 59 | + return $smart_isAdmin[$module]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function smart_isXoops22() |
| 66 | 66 | { |
| 67 | - $xoops22 = false; |
|
| 68 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 69 | - if (substr($xv, 2, 1) == '2') { |
|
| 70 | - $xoops22 = true; |
|
| 71 | - } |
|
| 67 | + $xoops22 = false; |
|
| 68 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 69 | + if (substr($xv, 2, 1) == '2') { |
|
| 70 | + $xoops22 = true; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $xoops22; |
|
| 73 | + return $xoops22; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -81,36 +81,36 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) |
| 83 | 83 | { |
| 84 | - if (!$moduleName) { |
|
| 85 | - global $xoopsModule; |
|
| 86 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 87 | - } |
|
| 88 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 89 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 90 | - if (!isset($smartModule)) { |
|
| 91 | - return ''; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if ($forBreadCrumb |
|
| 95 | - && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 96 | - && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!$withLink) { |
|
| 100 | - return $smartModule->getVar('name'); |
|
| 101 | - } else { |
|
| 102 | - $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 103 | - if ($seoMode === 'rewrite') { |
|
| 104 | - $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 105 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 106 | - } elseif ($seoMode === 'pathinfo') { |
|
| 107 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 108 | - } else { |
|
| 109 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 113 | - } |
|
| 84 | + if (!$moduleName) { |
|
| 85 | + global $xoopsModule; |
|
| 86 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 87 | + } |
|
| 88 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 89 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 90 | + if (!isset($smartModule)) { |
|
| 91 | + return ''; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if ($forBreadCrumb |
|
| 95 | + && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 96 | + && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!$withLink) { |
|
| 100 | + return $smartModule->getVar('name'); |
|
| 101 | + } else { |
|
| 102 | + $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 103 | + if ($seoMode === 'rewrite') { |
|
| 104 | + $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 105 | + $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 106 | + } elseif ($seoMode === 'pathinfo') { |
|
| 107 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 108 | + } else { |
|
| 109 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function smart_getModuleNameForSEO($moduleName = false) |
| 121 | 121 | { |
| 122 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 123 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 124 | - if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 125 | - return $smartModuleConfig['seo_module_name']; |
|
| 126 | - } |
|
| 127 | - $ret = smart_getModuleName(false, false, $moduleName); |
|
| 128 | - |
|
| 129 | - return strtolower($ret); |
|
| 122 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 123 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 124 | + if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 125 | + return $smartModuleConfig['seo_module_name']; |
|
| 126 | + } |
|
| 127 | + $ret = smart_getModuleName(false, false, $moduleName); |
|
| 128 | + |
|
| 129 | + return strtolower($ret); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | function smart_getModuleModeSEO($moduleName = false) |
| 137 | 137 | { |
| 138 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 139 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 138 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 139 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 140 | 140 | |
| 141 | - return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 141 | + return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function smart_getModuleIncludeIdSEO($moduleName = false) |
| 149 | 149 | { |
| 150 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 151 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 150 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 151 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 152 | 152 | |
| 153 | - return !empty($smartModuleConfig['seo_inc_id']); |
|
| 153 | + return !empty($smartModuleConfig['seo_inc_id']); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -159,25 +159,25 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function smart_getenv($key) |
| 161 | 161 | { |
| 162 | - $ret = ''; |
|
| 163 | - $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 162 | + $ret = ''; |
|
| 163 | + $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 164 | 164 | |
| 165 | - return $ret; |
|
| 165 | + return $ret; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | function smart_xoops_cp_header() |
| 169 | 169 | { |
| 170 | - xoops_cp_header(); |
|
| 171 | - global $xoopsModule, $xoopsConfig; |
|
| 172 | - /** |
|
| 173 | - * include SmartObject admin language file |
|
| 174 | - */ |
|
| 175 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 176 | - if (file_exists($fileName)) { |
|
| 177 | - require_once $fileName; |
|
| 178 | - } else { |
|
| 179 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 180 | - } ?> |
|
| 170 | + xoops_cp_header(); |
|
| 171 | + global $xoopsModule, $xoopsConfig; |
|
| 172 | + /** |
|
| 173 | + * include SmartObject admin language file |
|
| 174 | + */ |
|
| 175 | + $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 176 | + if (file_exists($fileName)) { |
|
| 177 | + require_once $fileName; |
|
| 178 | + } else { |
|
| 179 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 180 | + } ?> |
|
| 181 | 181 | <script type='text/javascript'> |
| 182 | 182 | <!-- |
| 183 | 183 | var smart_url = '<?php echo SMARTOBJECT_URL ?>'; |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script> |
| 191 | 191 | <?php |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Include the admin language constants for the SmartObject Framework |
|
| 195 | - */ |
|
| 196 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 197 | - if (!file_exists($admin_file)) { |
|
| 198 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
| 199 | - } |
|
| 200 | - require_once $admin_file; |
|
| 193 | + /** |
|
| 194 | + * Include the admin language constants for the SmartObject Framework |
|
| 195 | + */ |
|
| 196 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 197 | + if (!file_exists($admin_file)) { |
|
| 198 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
| 199 | + } |
|
| 200 | + require_once $admin_file; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function smart_TableExists($table) |
| 213 | 213 | { |
| 214 | - $bRetVal = false; |
|
| 215 | - //Verifies that a MySQL table exists |
|
| 216 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 217 | - $realname = $xoopsDB->prefix($table); |
|
| 218 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 219 | - $ret = $xoopsDB->queryF($sql); |
|
| 220 | - while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 221 | - if ($m_table == $realname) { |
|
| 222 | - $bRetVal = true; |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - $xoopsDB->freeRecordSet($ret); |
|
| 227 | - |
|
| 228 | - return $bRetVal; |
|
| 214 | + $bRetVal = false; |
|
| 215 | + //Verifies that a MySQL table exists |
|
| 216 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 217 | + $realname = $xoopsDB->prefix($table); |
|
| 218 | + $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 219 | + $ret = $xoopsDB->queryF($sql); |
|
| 220 | + while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 221 | + if ($m_table == $realname) { |
|
| 222 | + $bRetVal = true; |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + $xoopsDB->freeRecordSet($ret); |
|
| 227 | + |
|
| 228 | + return $bRetVal; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -240,19 +240,19 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | function smart_GetMeta($key, $moduleName = false) |
| 242 | 242 | { |
| 243 | - if (!$moduleName) { |
|
| 244 | - $moduleName = smart_getCurrentModuleName(); |
|
| 245 | - } |
|
| 246 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 247 | - $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 248 | - $ret = $xoopsDB->query($sql); |
|
| 249 | - if (!$ret) { |
|
| 250 | - $value = false; |
|
| 251 | - } else { |
|
| 252 | - list($value) = $xoopsDB->fetchRow($ret); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $value; |
|
| 243 | + if (!$moduleName) { |
|
| 244 | + $moduleName = smart_getCurrentModuleName(); |
|
| 245 | + } |
|
| 246 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 247 | + $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 248 | + $ret = $xoopsDB->query($sql); |
|
| 249 | + if (!$ret) { |
|
| 250 | + $value = false; |
|
| 251 | + } else { |
|
| 252 | + list($value) = $xoopsDB->fetchRow($ret); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $value; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | function smart_getCurrentModuleName() |
| 262 | 262 | { |
| 263 | - global $xoopsModule; |
|
| 264 | - if (is_object($xoopsModule)) { |
|
| 265 | - return $xoopsModule->getVar('dirname'); |
|
| 266 | - } else { |
|
| 267 | - return false; |
|
| 268 | - } |
|
| 263 | + global $xoopsModule; |
|
| 264 | + if (is_object($xoopsModule)) { |
|
| 265 | + return $xoopsModule->getVar('dirname'); |
|
| 266 | + } else { |
|
| 267 | + return false; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -281,22 +281,22 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function smart_SetMeta($key, $value, $moduleName = false) |
| 283 | 283 | { |
| 284 | - if (!$moduleName) { |
|
| 285 | - $moduleName = smart_getCurrentModuleName(); |
|
| 286 | - } |
|
| 287 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 288 | - $ret = smart_GetMeta($key, $moduleName); |
|
| 289 | - if ($ret === '0' || $ret > 0) { |
|
| 290 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 291 | - } else { |
|
| 292 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 293 | - } |
|
| 294 | - $ret = $xoopsDB->queryF($sql); |
|
| 295 | - if (!$ret) { |
|
| 296 | - return false; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - return true; |
|
| 284 | + if (!$moduleName) { |
|
| 285 | + $moduleName = smart_getCurrentModuleName(); |
|
| 286 | + } |
|
| 287 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 288 | + $ret = smart_GetMeta($key, $moduleName); |
|
| 289 | + if ($ret === '0' || $ret > 0) { |
|
| 290 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 291 | + } else { |
|
| 292 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 293 | + } |
|
| 294 | + $ret = $xoopsDB->queryF($sql); |
|
| 295 | + if (!$ret) { |
|
| 296 | + return false; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + return true; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Thanks to Mithrandir:-) |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | function smart_substr($str, $start, $length, $trimmarker = '...') |
| 311 | 311 | { |
| 312 | - // if the string is empty, let's get out ;-) |
|
| 313 | - if ($str === '') { |
|
| 314 | - return $str; |
|
| 315 | - } |
|
| 316 | - // reverse a string that is shortened with '' as trimmarker |
|
| 317 | - $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 318 | - // find first space in reversed string |
|
| 319 | - $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 320 | - // truncate the original string to a length of $length |
|
| 321 | - // minus the position of the last space |
|
| 322 | - // plus the length of the $trimmarker |
|
| 323 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 324 | - |
|
| 325 | - return $truncated_string; |
|
| 312 | + // if the string is empty, let's get out ;-) |
|
| 313 | + if ($str === '') { |
|
| 314 | + return $str; |
|
| 315 | + } |
|
| 316 | + // reverse a string that is shortened with '' as trimmarker |
|
| 317 | + $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 318 | + // find first space in reversed string |
|
| 319 | + $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 320 | + // truncate the original string to a length of $length |
|
| 321 | + // minus the position of the last space |
|
| 322 | + // plus the length of the $trimmarker |
|
| 323 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 324 | + |
|
| 325 | + return $truncated_string; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -333,19 +333,19 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') |
| 335 | 335 | { |
| 336 | - if (!$moduleName) { |
|
| 337 | - $moduleName = smart_getCurrentModuleName(); |
|
| 338 | - } |
|
| 339 | - $configs = smart_getModuleConfig($moduleName); |
|
| 340 | - if (isset($configs[$key])) { |
|
| 341 | - return $configs[$key]; |
|
| 342 | - } else { |
|
| 343 | - if ($default === 'default_is_undefined') { |
|
| 344 | - return null; |
|
| 345 | - } else { |
|
| 346 | - return $default; |
|
| 347 | - } |
|
| 348 | - } |
|
| 336 | + if (!$moduleName) { |
|
| 337 | + $moduleName = smart_getCurrentModuleName(); |
|
| 338 | + } |
|
| 339 | + $configs = smart_getModuleConfig($moduleName); |
|
| 340 | + if (isset($configs[$key])) { |
|
| 341 | + return $configs[$key]; |
|
| 342 | + } else { |
|
| 343 | + if ($default === 'default_is_undefined') { |
|
| 344 | + return null; |
|
| 345 | + } else { |
|
| 346 | + return $default; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -358,32 +358,32 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function smart_copyr($source, $dest) |
| 360 | 360 | { |
| 361 | - // Simple copy for a file |
|
| 362 | - if (is_file($source)) { |
|
| 363 | - return copy($source, $dest); |
|
| 364 | - } |
|
| 365 | - // Make destination directory |
|
| 366 | - if (!is_dir($dest)) { |
|
| 367 | - mkdir($dest); |
|
| 368 | - } |
|
| 369 | - // Loop through the folder |
|
| 370 | - $dir = dir($source); |
|
| 371 | - while (false !== $entry = $dir->read()) { |
|
| 372 | - // Skip pointers |
|
| 373 | - if ($entry === '.' || $entry === '..') { |
|
| 374 | - continue; |
|
| 375 | - } |
|
| 376 | - // Deep copy directories |
|
| 377 | - if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 378 | - copyr("$source/$entry", "$dest/$entry"); |
|
| 379 | - } else { |
|
| 380 | - copy("$source/$entry", "$dest/$entry"); |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - // Clean up |
|
| 384 | - $dir->close(); |
|
| 385 | - |
|
| 386 | - return true; |
|
| 361 | + // Simple copy for a file |
|
| 362 | + if (is_file($source)) { |
|
| 363 | + return copy($source, $dest); |
|
| 364 | + } |
|
| 365 | + // Make destination directory |
|
| 366 | + if (!is_dir($dest)) { |
|
| 367 | + mkdir($dest); |
|
| 368 | + } |
|
| 369 | + // Loop through the folder |
|
| 370 | + $dir = dir($source); |
|
| 371 | + while (false !== $entry = $dir->read()) { |
|
| 372 | + // Skip pointers |
|
| 373 | + if ($entry === '.' || $entry === '..') { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 376 | + // Deep copy directories |
|
| 377 | + if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 378 | + copyr("$source/$entry", "$dest/$entry"); |
|
| 379 | + } else { |
|
| 380 | + copy("$source/$entry", "$dest/$entry"); |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + // Clean up |
|
| 384 | + $dir->close(); |
|
| 385 | + |
|
| 386 | + return true; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,26 +393,26 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function smart_admin_mkdir($target) |
| 395 | 395 | { |
| 396 | - // http://www.php.net/manual/en/function.mkdir.php |
|
| 397 | - // saint at corenova.com |
|
| 398 | - // bart at cdasites dot com |
|
| 399 | - if (is_dir($target) || empty($target)) { |
|
| 400 | - return true; // best case check first |
|
| 401 | - } |
|
| 402 | - if (file_exists($target) && !is_dir($target)) { |
|
| 403 | - return false; |
|
| 404 | - } |
|
| 405 | - if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 406 | - if (!file_exists($target)) { |
|
| 407 | - $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 408 | - smart_admin_chmod($target); |
|
| 409 | - |
|
| 410 | - return $res; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - $res = is_dir($target); |
|
| 414 | - |
|
| 415 | - return $res; |
|
| 396 | + // http://www.php.net/manual/en/function.mkdir.php |
|
| 397 | + // saint at corenova.com |
|
| 398 | + // bart at cdasites dot com |
|
| 399 | + if (is_dir($target) || empty($target)) { |
|
| 400 | + return true; // best case check first |
|
| 401 | + } |
|
| 402 | + if (file_exists($target) && !is_dir($target)) { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 405 | + if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 406 | + if (!file_exists($target)) { |
|
| 407 | + $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 408 | + smart_admin_chmod($target); |
|
| 409 | + |
|
| 410 | + return $res; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + $res = is_dir($target); |
|
| 414 | + |
|
| 415 | + return $res; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | function smart_admin_chmod($target, $mode = 0777) |
| 425 | 425 | { |
| 426 | - return @ chmod($target, $mode); |
|
| 426 | + return @ chmod($target, $mode); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -434,31 +434,31 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | function smart_imageResize($src, $maxWidth, $maxHeight) |
| 436 | 436 | { |
| 437 | - $width = ''; |
|
| 438 | - $height = ''; |
|
| 439 | - $type = ''; |
|
| 440 | - $attr = ''; |
|
| 441 | - if (file_exists($src)) { |
|
| 442 | - list($width, $height, $type, $attr) = getimagesize($src); |
|
| 443 | - if ($width > $maxWidth) { |
|
| 444 | - $originalWidth = $width; |
|
| 445 | - $width = $maxWidth; |
|
| 446 | - $height = $width * $height / $originalWidth; |
|
| 447 | - } |
|
| 448 | - if ($height > $maxHeight) { |
|
| 449 | - $originalHeight = $height; |
|
| 450 | - $height = $maxHeight; |
|
| 451 | - $width = $height * $width / $originalHeight; |
|
| 452 | - } |
|
| 453 | - $attr = " width='$width' height='$height'"; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - return array( |
|
| 457 | - $width, |
|
| 458 | - $height, |
|
| 459 | - $type, |
|
| 460 | - $attr |
|
| 461 | - ); |
|
| 437 | + $width = ''; |
|
| 438 | + $height = ''; |
|
| 439 | + $type = ''; |
|
| 440 | + $attr = ''; |
|
| 441 | + if (file_exists($src)) { |
|
| 442 | + list($width, $height, $type, $attr) = getimagesize($src); |
|
| 443 | + if ($width > $maxWidth) { |
|
| 444 | + $originalWidth = $width; |
|
| 445 | + $width = $maxWidth; |
|
| 446 | + $height = $width * $height / $originalWidth; |
|
| 447 | + } |
|
| 448 | + if ($height > $maxHeight) { |
|
| 449 | + $originalHeight = $height; |
|
| 450 | + $height = $maxHeight; |
|
| 451 | + $width = $height * $width / $originalHeight; |
|
| 452 | + } |
|
| 453 | + $attr = " width='$width' height='$height'"; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + return array( |
|
| 457 | + $width, |
|
| 458 | + $height, |
|
| 459 | + $type, |
|
| 460 | + $attr |
|
| 461 | + ); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -467,34 +467,34 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | function smart_getModuleInfo($moduleName = false) |
| 469 | 469 | { |
| 470 | - static $smartModules; |
|
| 471 | - if (isset($smartModules[$moduleName])) { |
|
| 472 | - $ret =& $smartModules[$moduleName]; |
|
| 473 | - |
|
| 474 | - return $ret; |
|
| 475 | - } |
|
| 476 | - global $xoopsModule; |
|
| 477 | - if (!$moduleName) { |
|
| 478 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 479 | - $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 480 | - |
|
| 481 | - return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 482 | - } |
|
| 483 | - } |
|
| 484 | - if (!isset($smartModules[$moduleName])) { |
|
| 485 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 486 | - $smartModules[$moduleName] = $xoopsModule; |
|
| 487 | - } else { |
|
| 488 | - $hModule = xoops_getHandler('module'); |
|
| 489 | - if ($moduleName !== 'xoops') { |
|
| 490 | - $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 491 | - } else { |
|
| 492 | - $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 493 | - } |
|
| 494 | - } |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - return $smartModules[$moduleName]; |
|
| 470 | + static $smartModules; |
|
| 471 | + if (isset($smartModules[$moduleName])) { |
|
| 472 | + $ret =& $smartModules[$moduleName]; |
|
| 473 | + |
|
| 474 | + return $ret; |
|
| 475 | + } |
|
| 476 | + global $xoopsModule; |
|
| 477 | + if (!$moduleName) { |
|
| 478 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 479 | + $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 480 | + |
|
| 481 | + return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | + if (!isset($smartModules[$moduleName])) { |
|
| 485 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 486 | + $smartModules[$moduleName] = $xoopsModule; |
|
| 487 | + } else { |
|
| 488 | + $hModule = xoops_getHandler('module'); |
|
| 489 | + if ($moduleName !== 'xoops') { |
|
| 490 | + $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 491 | + } else { |
|
| 492 | + $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return $smartModules[$moduleName]; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -503,40 +503,40 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | function smart_getModuleConfig($moduleName = false) |
| 505 | 505 | { |
| 506 | - static $smartConfigs; |
|
| 507 | - if (isset($smartConfigs[$moduleName])) { |
|
| 508 | - $ret =& $smartConfigs[$moduleName]; |
|
| 509 | - |
|
| 510 | - return $ret; |
|
| 511 | - } |
|
| 512 | - global $xoopsModule, $xoopsModuleConfig; |
|
| 513 | - if (!$moduleName) { |
|
| 514 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 515 | - $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 516 | - |
|
| 517 | - return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - // if we still did not found the xoopsModule, this is because there is none |
|
| 521 | - if (!$moduleName) { |
|
| 522 | - $ret = false; |
|
| 523 | - |
|
| 524 | - return $ret; |
|
| 525 | - } |
|
| 526 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 527 | - $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 528 | - } else { |
|
| 529 | - $module = smart_getModuleInfo($moduleName); |
|
| 530 | - if (!is_object($module)) { |
|
| 531 | - $ret = false; |
|
| 532 | - |
|
| 533 | - return $ret; |
|
| 534 | - } |
|
| 535 | - $hModConfig = xoops_getHandler('config'); |
|
| 536 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - return $smartConfigs[$moduleName]; |
|
| 506 | + static $smartConfigs; |
|
| 507 | + if (isset($smartConfigs[$moduleName])) { |
|
| 508 | + $ret =& $smartConfigs[$moduleName]; |
|
| 509 | + |
|
| 510 | + return $ret; |
|
| 511 | + } |
|
| 512 | + global $xoopsModule, $xoopsModuleConfig; |
|
| 513 | + if (!$moduleName) { |
|
| 514 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 515 | + $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 516 | + |
|
| 517 | + return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + // if we still did not found the xoopsModule, this is because there is none |
|
| 521 | + if (!$moduleName) { |
|
| 522 | + $ret = false; |
|
| 523 | + |
|
| 524 | + return $ret; |
|
| 525 | + } |
|
| 526 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 527 | + $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 528 | + } else { |
|
| 529 | + $module = smart_getModuleInfo($moduleName); |
|
| 530 | + if (!is_object($module)) { |
|
| 531 | + $ret = false; |
|
| 532 | + |
|
| 533 | + return $ret; |
|
| 534 | + } |
|
| 535 | + $hModConfig = xoops_getHandler('config'); |
|
| 536 | + $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + return $smartConfigs[$moduleName]; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -545,10 +545,10 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | function smart_deleteFile($dirname) |
| 547 | 547 | { |
| 548 | - // Simple delete for a file |
|
| 549 | - if (is_file($dirname)) { |
|
| 550 | - return unlink($dirname); |
|
| 551 | - } |
|
| 548 | + // Simple delete for a file |
|
| 549 | + if (is_file($dirname)) { |
|
| 550 | + return unlink($dirname); |
|
| 551 | + } |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -557,12 +557,12 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | function smart_formatErrors($errors = array()) |
| 559 | 559 | { |
| 560 | - $ret = ''; |
|
| 561 | - foreach ($errors as $key => $value) { |
|
| 562 | - $ret .= '<br> - ' . $value; |
|
| 563 | - } |
|
| 560 | + $ret = ''; |
|
| 561 | + foreach ($errors as $key => $value) { |
|
| 562 | + $ret .= '<br> - ' . $value; |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - return $ret; |
|
| 565 | + return $ret; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -576,46 +576,46 @@ discard block |
||
| 576 | 576 | */ |
| 577 | 577 | function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false) |
| 578 | 578 | { |
| 579 | - if (!is_numeric($userid)) { |
|
| 580 | - return $userid; |
|
| 581 | - } |
|
| 582 | - $userid = (int)$userid; |
|
| 583 | - if ($userid > 0) { |
|
| 584 | - if ($users == array()) { |
|
| 585 | - //fetching users |
|
| 586 | - $memberHandler = xoops_getHandler('member'); |
|
| 587 | - $user =& $memberHandler->getUser($userid); |
|
| 588 | - } else { |
|
| 589 | - if (!isset($users[$userid])) { |
|
| 590 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 591 | - } |
|
| 592 | - $user =& $users[$userid]; |
|
| 593 | - } |
|
| 594 | - if (is_object($user)) { |
|
| 595 | - $ts = MyTextSanitizer:: getInstance(); |
|
| 596 | - $username = $user->getVar('uname'); |
|
| 597 | - $fullname = ''; |
|
| 598 | - $fullname2 = $user->getVar('name'); |
|
| 599 | - if ($name && !empty($fullname2)) { |
|
| 600 | - $fullname = $user->getVar('name'); |
|
| 601 | - } |
|
| 602 | - if (!empty($fullname)) { |
|
| 603 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 604 | - } else { |
|
| 605 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 606 | - } |
|
| 607 | - // add contact info: email + PM |
|
| 608 | - if ($withContact) { |
|
| 609 | - $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"></a>'; |
|
| 610 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 611 | - $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"></a>'; |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - return $linkeduser; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 579 | + if (!is_numeric($userid)) { |
|
| 580 | + return $userid; |
|
| 581 | + } |
|
| 582 | + $userid = (int)$userid; |
|
| 583 | + if ($userid > 0) { |
|
| 584 | + if ($users == array()) { |
|
| 585 | + //fetching users |
|
| 586 | + $memberHandler = xoops_getHandler('member'); |
|
| 587 | + $user =& $memberHandler->getUser($userid); |
|
| 588 | + } else { |
|
| 589 | + if (!isset($users[$userid])) { |
|
| 590 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 591 | + } |
|
| 592 | + $user =& $users[$userid]; |
|
| 593 | + } |
|
| 594 | + if (is_object($user)) { |
|
| 595 | + $ts = MyTextSanitizer:: getInstance(); |
|
| 596 | + $username = $user->getVar('uname'); |
|
| 597 | + $fullname = ''; |
|
| 598 | + $fullname2 = $user->getVar('name'); |
|
| 599 | + if ($name && !empty($fullname2)) { |
|
| 600 | + $fullname = $user->getVar('name'); |
|
| 601 | + } |
|
| 602 | + if (!empty($fullname)) { |
|
| 603 | + $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 604 | + } else { |
|
| 605 | + $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 606 | + } |
|
| 607 | + // add contact info: email + PM |
|
| 608 | + if ($withContact) { |
|
| 609 | + $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"></a>'; |
|
| 610 | + $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 611 | + $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"></a>'; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + return $linkeduser; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -626,33 +626,33 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
| 628 | 628 | { |
| 629 | - global $xoopsModule, $xoopsConfig; |
|
| 630 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 631 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 632 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 633 | - } else { |
|
| 634 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 635 | - } |
|
| 636 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 637 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 638 | - } else { |
|
| 639 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 640 | - } |
|
| 641 | - $headermenu = array(); |
|
| 642 | - $adminObject = array(); |
|
| 643 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 644 | - $tpl = new XoopsTpl(); |
|
| 645 | - $tpl->assign(array( |
|
| 646 | - 'headermenu' => $headermenu, |
|
| 647 | - 'adminmenu' => $adminObject, |
|
| 648 | - 'current' => $currentoption, |
|
| 649 | - 'breadcrumb' => $breadcrumb, |
|
| 650 | - 'headermenucount' => count($headermenu), |
|
| 651 | - 'submenus' => $submenus, |
|
| 652 | - 'currentsub' => $currentsub, |
|
| 653 | - 'submenuscount' => count($submenus) |
|
| 654 | - )); |
|
| 655 | - $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 629 | + global $xoopsModule, $xoopsConfig; |
|
| 630 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 631 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 632 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 633 | + } else { |
|
| 634 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 635 | + } |
|
| 636 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 637 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 638 | + } else { |
|
| 639 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 640 | + } |
|
| 641 | + $headermenu = array(); |
|
| 642 | + $adminObject = array(); |
|
| 643 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 644 | + $tpl = new XoopsTpl(); |
|
| 645 | + $tpl->assign(array( |
|
| 646 | + 'headermenu' => $headermenu, |
|
| 647 | + 'adminmenu' => $adminObject, |
|
| 648 | + 'current' => $currentoption, |
|
| 649 | + 'breadcrumb' => $breadcrumb, |
|
| 650 | + 'headermenucount' => count($headermenu), |
|
| 651 | + 'submenus' => $submenus, |
|
| 652 | + 'currentsub' => $currentsub, |
|
| 653 | + 'submenuscount' => count($submenus) |
|
| 654 | + )); |
|
| 655 | + $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
| 664 | 664 | { |
| 665 | - global $xoopsModule; |
|
| 666 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 667 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 668 | - echo "<div id='" . $id . "'>"; |
|
| 669 | - if ($dsc !== '') { |
|
| 670 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 671 | - } |
|
| 665 | + global $xoopsModule; |
|
| 666 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 667 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 668 | + echo "<div id='" . $id . "'>"; |
|
| 669 | + if ($dsc !== '') { |
|
| 670 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 671 | + } |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -678,15 +678,15 @@ discard block |
||
| 678 | 678 | */ |
| 679 | 679 | function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '') |
| 680 | 680 | { |
| 681 | - global $xoopsModule; |
|
| 682 | - $onClick = "ajaxtogglecollapse('$id')"; |
|
| 683 | - //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 684 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 685 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 686 | - echo "<div id='" . $id . "'>"; |
|
| 687 | - if ($dsc !== '') { |
|
| 688 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 689 | - } |
|
| 681 | + global $xoopsModule; |
|
| 682 | + $onClick = "ajaxtogglecollapse('$id')"; |
|
| 683 | + //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 684 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 685 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 686 | + echo "<div id='" . $id . "'>"; |
|
| 687 | + if ($dsc !== '') { |
|
| 688 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -713,20 +713,20 @@ discard block |
||
| 713 | 713 | */ |
| 714 | 714 | function smart_openclose_collapsable($name) |
| 715 | 715 | { |
| 716 | - $urls = smart_getCurrentUrls(); |
|
| 717 | - $path = $urls['phpself']; |
|
| 718 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 719 | - $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 720 | - $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 721 | - if ($cookie === 'none') { |
|
| 722 | - echo ' |
|
| 716 | + $urls = smart_getCurrentUrls(); |
|
| 717 | + $path = $urls['phpself']; |
|
| 718 | + $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 719 | + $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 720 | + $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 721 | + if ($cookie === 'none') { |
|
| 722 | + echo ' |
|
| 723 | 723 | <script type="text/javascript"><!-- |
| 724 | 724 | togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
| 725 | 725 | //--> |
| 726 | 726 | </script> |
| 727 | 727 | '; |
| 728 | - } |
|
| 729 | - /* if ($cookie == 'none') { |
|
| 728 | + } |
|
| 729 | + /* if ($cookie == 'none') { |
|
| 730 | 730 | echo ' |
| 731 | 731 | <script type="text/javascript"><!-- |
| 732 | 732 | hideElement("' . $name . '"); |
@@ -742,9 +742,9 @@ discard block |
||
| 742 | 742 | */ |
| 743 | 743 | function smart_close_collapsable($name) |
| 744 | 744 | { |
| 745 | - echo '</div>'; |
|
| 746 | - smart_openclose_collapsable($name); |
|
| 747 | - echo '<br>'; |
|
| 745 | + echo '</div>'; |
|
| 746 | + smart_openclose_collapsable($name); |
|
| 747 | + echo '<br>'; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | */ |
| 755 | 755 | function smart_setCookieVar($name, $value, $time = 0) |
| 756 | 756 | { |
| 757 | - if ($time == 0) { |
|
| 758 | - $time = time() + 3600 * 24 * 365; |
|
| 759 | - //$time = ''; |
|
| 760 | - } |
|
| 761 | - setcookie($name, $value, $time, '/'); |
|
| 757 | + if ($time == 0) { |
|
| 758 | + $time = time() + 3600 * 24 * 365; |
|
| 759 | + //$time = ''; |
|
| 760 | + } |
|
| 761 | + setcookie($name, $value, $time, '/'); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | /** |
@@ -768,12 +768,12 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | function smart_getCookieVar($name, $default = '') |
| 770 | 770 | { |
| 771 | - $name = str_replace('.', '_', $name); |
|
| 772 | - if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 773 | - return $_COOKIE[$name]; |
|
| 774 | - } else { |
|
| 775 | - return $default; |
|
| 776 | - } |
|
| 771 | + $name = str_replace('.', '_', $name); |
|
| 772 | + if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 773 | + return $_COOKIE[$name]; |
|
| 774 | + } else { |
|
| 775 | + return $default; |
|
| 776 | + } |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
@@ -781,25 +781,25 @@ discard block |
||
| 781 | 781 | */ |
| 782 | 782 | function smart_getCurrentUrls() |
| 783 | 783 | { |
| 784 | - $urls = array(); |
|
| 785 | - $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
| 786 | - $phpself = $_SERVER['PHP_SELF']; |
|
| 787 | - $httphost = $_SERVER['HTTP_HOST']; |
|
| 788 | - $querystring = $_SERVER['QUERY_STRING']; |
|
| 789 | - if ($querystring !== '') { |
|
| 790 | - $querystring = '?' . $querystring; |
|
| 791 | - } |
|
| 792 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 793 | - $urls = array(); |
|
| 794 | - $urls['http'] = $http; |
|
| 795 | - $urls['httphost'] = $httphost; |
|
| 796 | - $urls['phpself'] = $phpself; |
|
| 797 | - $urls['querystring'] = $querystring; |
|
| 798 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 799 | - $urls['full'] = $currenturl; |
|
| 800 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 801 | - |
|
| 802 | - return $urls; |
|
| 784 | + $urls = array(); |
|
| 785 | + $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
| 786 | + $phpself = $_SERVER['PHP_SELF']; |
|
| 787 | + $httphost = $_SERVER['HTTP_HOST']; |
|
| 788 | + $querystring = $_SERVER['QUERY_STRING']; |
|
| 789 | + if ($querystring !== '') { |
|
| 790 | + $querystring = '?' . $querystring; |
|
| 791 | + } |
|
| 792 | + $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 793 | + $urls = array(); |
|
| 794 | + $urls['http'] = $http; |
|
| 795 | + $urls['httphost'] = $httphost; |
|
| 796 | + $urls['phpself'] = $phpself; |
|
| 797 | + $urls['querystring'] = $querystring; |
|
| 798 | + $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 799 | + $urls['full'] = $currenturl; |
|
| 800 | + $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 801 | + |
|
| 802 | + return $urls; |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | /** |
@@ -807,9 +807,9 @@ discard block |
||
| 807 | 807 | */ |
| 808 | 808 | function smart_getCurrentPage() |
| 809 | 809 | { |
| 810 | - $urls = smart_getCurrentUrls(); |
|
| 810 | + $urls = smart_getCurrentUrls(); |
|
| 811 | 811 | |
| 812 | - return $urls['full']; |
|
| 812 | + return $urls['full']; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -872,29 +872,29 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | function smart_modFooter() |
| 874 | 874 | { |
| 875 | - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 876 | - |
|
| 877 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 878 | - $tpl = new XoopsTpl(); |
|
| 879 | - |
|
| 880 | - $hModule = xoops_getHandler('module'); |
|
| 881 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 883 | - $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'></a>"; |
|
| 884 | - $tpl->assign('modfooter', $modfooter); |
|
| 885 | - |
|
| 886 | - if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 887 | - define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 888 | - } |
|
| 889 | - $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 890 | - $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 891 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 875 | + global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 876 | + |
|
| 877 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 878 | + $tpl = new XoopsTpl(); |
|
| 879 | + |
|
| 880 | + $hModule = xoops_getHandler('module'); |
|
| 881 | + $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | + $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 883 | + $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'></a>"; |
|
| 884 | + $tpl->assign('modfooter', $modfooter); |
|
| 885 | + |
|
| 886 | + if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 887 | + define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 888 | + } |
|
| 889 | + $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 890 | + $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 891 | + $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | function smart_xoops_cp_footer() |
| 895 | 895 | { |
| 896 | - smart_modFooter(); |
|
| 897 | - xoops_cp_footer(); |
|
| 896 | + smart_modFooter(); |
|
| 897 | + xoops_cp_footer(); |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | /** |
@@ -903,11 +903,11 @@ discard block |
||
| 903 | 903 | */ |
| 904 | 904 | function smart_sanitizeForCommonTags($text) |
| 905 | 905 | { |
| 906 | - global $xoopsConfig; |
|
| 907 | - $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 908 | - $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 906 | + global $xoopsConfig; |
|
| 907 | + $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 908 | + $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 909 | 909 | |
| 910 | - return $text; |
|
| 910 | + return $text; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | function smart_addScript($src) |
| 917 | 917 | { |
| 918 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 918 | + echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | */ |
| 924 | 924 | function smart_addStyle($src) |
| 925 | 925 | { |
| 926 | - if ($src === 'smartobject') { |
|
| 927 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 928 | - } |
|
| 929 | - echo smart_get_css_link($src); |
|
| 926 | + if ($src === 'smartobject') { |
|
| 927 | + $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 928 | + } |
|
| 929 | + echo smart_get_css_link($src); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | function smart_addAdminAjaxSupport() |
| 933 | 933 | { |
| 934 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 935 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 934 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 935 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | /** |
@@ -942,11 +942,11 @@ discard block |
||
| 942 | 942 | */ |
| 943 | 943 | function smart_sanitizeForSmartpopupLink($text) |
| 944 | 944 | { |
| 945 | - $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 946 | - $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 947 | - $ret = preg_replace($patterns, $replacements, $text); |
|
| 945 | + $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 946 | + $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 947 | + $ret = preg_replace($patterns, $replacements, $text); |
|
| 948 | 948 | |
| 949 | - return $ret; |
|
| 949 | + return $ret; |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | /** |
@@ -961,25 +961,25 @@ discard block |
||
| 961 | 961 | */ |
| 962 | 962 | function smart_getImageSize($url, & $width, & $height) |
| 963 | 963 | { |
| 964 | - if (empty($width) || empty($height)) { |
|
| 965 | - if (!$dimension = @ getimagesize($url)) { |
|
| 966 | - return false; |
|
| 967 | - } |
|
| 968 | - if (!empty($width)) { |
|
| 969 | - $height = $dimension[1] * $width / $dimension[0]; |
|
| 970 | - } elseif (!empty($height)) { |
|
| 971 | - $width = $dimension[0] * $height / $dimension[1]; |
|
| 972 | - } else { |
|
| 973 | - list($width, $height) = array( |
|
| 974 | - $dimension[0], |
|
| 975 | - $dimension[1] |
|
| 976 | - ); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - return true; |
|
| 980 | - } else { |
|
| 981 | - return true; |
|
| 982 | - } |
|
| 964 | + if (empty($width) || empty($height)) { |
|
| 965 | + if (!$dimension = @ getimagesize($url)) { |
|
| 966 | + return false; |
|
| 967 | + } |
|
| 968 | + if (!empty($width)) { |
|
| 969 | + $height = $dimension[1] * $width / $dimension[0]; |
|
| 970 | + } elseif (!empty($height)) { |
|
| 971 | + $width = $dimension[0] * $height / $dimension[1]; |
|
| 972 | + } else { |
|
| 973 | + list($width, $height) = array( |
|
| 974 | + $dimension[0], |
|
| 975 | + $dimension[1] |
|
| 976 | + ); |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + return true; |
|
| 980 | + } else { |
|
| 981 | + return true; |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -992,10 +992,10 @@ discard block |
||
| 992 | 992 | */ |
| 993 | 993 | function smart_htmlnumericentities($str) |
| 994 | 994 | { |
| 995 | - // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 996 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 997 | - return '&#' . ord($m[0]) . chr(59); |
|
| 998 | - }, $str); |
|
| 995 | + // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 996 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 997 | + return '&#' . ord($m[0]) . chr(59); |
|
| 998 | + }, $str); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
@@ -1005,24 +1005,24 @@ discard block |
||
| 1005 | 1005 | */ |
| 1006 | 1006 | function smart_getcorehandler($name, $optional = false) |
| 1007 | 1007 | { |
| 1008 | - static $handlers; |
|
| 1009 | - $name = strtolower(trim($name)); |
|
| 1010 | - if (!isset($handlers[$name])) { |
|
| 1011 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1012 | - require_once $hnd_file; |
|
| 1013 | - } |
|
| 1014 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1015 | - if (class_exists($class)) { |
|
| 1016 | - $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1019 | - if (!isset($handlers[$name]) && !$optional) { |
|
| 1020 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1021 | - } |
|
| 1022 | - if (isset($handlers[$name])) { |
|
| 1023 | - return $handlers[$name]; |
|
| 1024 | - } |
|
| 1025 | - $inst = false; |
|
| 1008 | + static $handlers; |
|
| 1009 | + $name = strtolower(trim($name)); |
|
| 1010 | + if (!isset($handlers[$name])) { |
|
| 1011 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1012 | + require_once $hnd_file; |
|
| 1013 | + } |
|
| 1014 | + $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1015 | + if (class_exists($class)) { |
|
| 1016 | + $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | + if (!isset($handlers[$name]) && !$optional) { |
|
| 1020 | + trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1021 | + } |
|
| 1022 | + if (isset($handlers[$name])) { |
|
| 1023 | + return $handlers[$name]; |
|
| 1024 | + } |
|
| 1025 | + $inst = false; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1031,15 +1031,15 @@ discard block |
||
| 1031 | 1031 | */ |
| 1032 | 1032 | function smart_sanitizeAdsenses_callback($matches) |
| 1033 | 1033 | { |
| 1034 | - global $smartobjectAdsenseHandler; |
|
| 1035 | - if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1036 | - $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1037 | - $ret = $adsenseObj->render(); |
|
| 1038 | - |
|
| 1039 | - return $ret; |
|
| 1040 | - } else { |
|
| 1041 | - return ''; |
|
| 1042 | - } |
|
| 1034 | + global $smartobjectAdsenseHandler; |
|
| 1035 | + if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1036 | + $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1037 | + $ret = $adsenseObj->render(); |
|
| 1038 | + |
|
| 1039 | + return $ret; |
|
| 1040 | + } else { |
|
| 1041 | + return ''; |
|
| 1042 | + } |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
@@ -1048,13 +1048,13 @@ discard block |
||
| 1048 | 1048 | */ |
| 1049 | 1049 | function smart_sanitizeAdsenses($text) |
| 1050 | 1050 | { |
| 1051 | - $patterns = array(); |
|
| 1052 | - $replacements = array(); |
|
| 1051 | + $patterns = array(); |
|
| 1052 | + $replacements = array(); |
|
| 1053 | 1053 | |
| 1054 | - $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1055 | - $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1054 | + $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1055 | + $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1056 | 1056 | |
| 1057 | - return $text; |
|
| 1057 | + return $text; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /** |
@@ -1063,15 +1063,15 @@ discard block |
||
| 1063 | 1063 | */ |
| 1064 | 1064 | function smart_sanitizeCustomtags_callback($matches) |
| 1065 | 1065 | { |
| 1066 | - global $smartobjectCustomtagHandler; |
|
| 1067 | - if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1068 | - $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1069 | - $ret = $customObj->renderWithPhp(); |
|
| 1070 | - |
|
| 1071 | - return $ret; |
|
| 1072 | - } else { |
|
| 1073 | - return ''; |
|
| 1074 | - } |
|
| 1066 | + global $smartobjectCustomtagHandler; |
|
| 1067 | + if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1068 | + $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1069 | + $ret = $customObj->renderWithPhp(); |
|
| 1070 | + |
|
| 1071 | + return $ret; |
|
| 1072 | + } else { |
|
| 1073 | + return ''; |
|
| 1074 | + } |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1080,13 +1080,13 @@ discard block |
||
| 1080 | 1080 | */ |
| 1081 | 1081 | function smart_sanitizeCustomtags($text) |
| 1082 | 1082 | { |
| 1083 | - $patterns = array(); |
|
| 1084 | - $replacements = array(); |
|
| 1083 | + $patterns = array(); |
|
| 1084 | + $replacements = array(); |
|
| 1085 | 1085 | |
| 1086 | - $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1087 | - $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1086 | + $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1087 | + $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1088 | 1088 | |
| 1089 | - return $text; |
|
| 1089 | + return $text; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
@@ -1095,20 +1095,20 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | function smart_loadLanguageFile($module, $file) |
| 1097 | 1097 | { |
| 1098 | - global $xoopsConfig; |
|
| 1099 | - |
|
| 1100 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1101 | - if (!file_exists($filename)) { |
|
| 1102 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1103 | - } |
|
| 1104 | - if (file_exists($filename)) { |
|
| 1105 | - require_once $filename; |
|
| 1106 | - } |
|
| 1098 | + global $xoopsConfig; |
|
| 1099 | + |
|
| 1100 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1101 | + if (!file_exists($filename)) { |
|
| 1102 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1103 | + } |
|
| 1104 | + if (file_exists($filename)) { |
|
| 1105 | + require_once $filename; |
|
| 1106 | + } |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | function smart_loadCommonLanguageFile() |
| 1110 | 1110 | { |
| 1111 | - smart_loadLanguageFile('smartobject', 'common'); |
|
| 1111 | + smart_loadLanguageFile('smartobject', 'common'); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1118,35 +1118,35 @@ discard block |
||
| 1118 | 1118 | */ |
| 1119 | 1119 | function smart_purifyText($text, $keyword = false) |
| 1120 | 1120 | { |
| 1121 | - global $myts; |
|
| 1122 | - $text = str_replace(' ', ' ', $text); |
|
| 1123 | - $text = str_replace('<br>', ' ', $text); |
|
| 1124 | - $text = str_replace('<br>', ' ', $text); |
|
| 1125 | - $text = str_replace('<br', ' ', $text); |
|
| 1126 | - $text = strip_tags($text); |
|
| 1127 | - $text = html_entity_decode($text); |
|
| 1128 | - $text = $myts->undoHtmlSpecialChars($text); |
|
| 1129 | - $text = str_replace(')', ' ', $text); |
|
| 1130 | - $text = str_replace('(', ' ', $text); |
|
| 1131 | - $text = str_replace(':', ' ', $text); |
|
| 1132 | - $text = str_replace('&euro', ' euro ', $text); |
|
| 1133 | - $text = str_replace('&hellip', '...', $text); |
|
| 1134 | - $text = str_replace('&rsquo', ' ', $text); |
|
| 1135 | - $text = str_replace('!', ' ', $text); |
|
| 1136 | - $text = str_replace('?', ' ', $text); |
|
| 1137 | - $text = str_replace('"', ' ', $text); |
|
| 1138 | - $text = str_replace('-', ' ', $text); |
|
| 1139 | - $text = str_replace('\n', ' ', $text); |
|
| 1140 | - $text = str_replace('―', ' ', $text); |
|
| 1141 | - |
|
| 1142 | - if ($keyword) { |
|
| 1143 | - $text = str_replace('.', ' ', $text); |
|
| 1144 | - $text = str_replace(',', ' ', $text); |
|
| 1145 | - $text = str_replace('\'', ' ', $text); |
|
| 1146 | - } |
|
| 1147 | - $text = str_replace(';', ' ', $text); |
|
| 1148 | - |
|
| 1149 | - return $text; |
|
| 1121 | + global $myts; |
|
| 1122 | + $text = str_replace(' ', ' ', $text); |
|
| 1123 | + $text = str_replace('<br>', ' ', $text); |
|
| 1124 | + $text = str_replace('<br>', ' ', $text); |
|
| 1125 | + $text = str_replace('<br', ' ', $text); |
|
| 1126 | + $text = strip_tags($text); |
|
| 1127 | + $text = html_entity_decode($text); |
|
| 1128 | + $text = $myts->undoHtmlSpecialChars($text); |
|
| 1129 | + $text = str_replace(')', ' ', $text); |
|
| 1130 | + $text = str_replace('(', ' ', $text); |
|
| 1131 | + $text = str_replace(':', ' ', $text); |
|
| 1132 | + $text = str_replace('&euro', ' euro ', $text); |
|
| 1133 | + $text = str_replace('&hellip', '...', $text); |
|
| 1134 | + $text = str_replace('&rsquo', ' ', $text); |
|
| 1135 | + $text = str_replace('!', ' ', $text); |
|
| 1136 | + $text = str_replace('?', ' ', $text); |
|
| 1137 | + $text = str_replace('"', ' ', $text); |
|
| 1138 | + $text = str_replace('-', ' ', $text); |
|
| 1139 | + $text = str_replace('\n', ' ', $text); |
|
| 1140 | + $text = str_replace('―', ' ', $text); |
|
| 1141 | + |
|
| 1142 | + if ($keyword) { |
|
| 1143 | + $text = str_replace('.', ' ', $text); |
|
| 1144 | + $text = str_replace(',', ' ', $text); |
|
| 1145 | + $text = str_replace('\'', ' ', $text); |
|
| 1146 | + } |
|
| 1147 | + $text = str_replace(';', ' ', $text); |
|
| 1148 | + |
|
| 1149 | + return $text; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
@@ -1155,51 +1155,51 @@ discard block |
||
| 1155 | 1155 | */ |
| 1156 | 1156 | function smart_html2text($document) |
| 1157 | 1157 | { |
| 1158 | - // PHP Manual:: function preg_replace |
|
| 1159 | - // $document should contain an HTML document. |
|
| 1160 | - // This will remove HTML tags, javascript sections |
|
| 1161 | - // and white space. It will also convert some |
|
| 1162 | - // common HTML entities to their text equivalent. |
|
| 1163 | - // Credits: newbb2 |
|
| 1164 | - $search = array( |
|
| 1165 | - "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1166 | - "'<img.*?>'si", // Strip out img tags |
|
| 1167 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1168 | - "'([\r\n])[\s]+'", // Strip out white space |
|
| 1169 | - "'&(quot|#34);'i", // Replace HTML entities |
|
| 1170 | - "'&(amp|#38);'i", |
|
| 1171 | - "'&(lt|#60);'i", |
|
| 1172 | - "'&(gt|#62);'i", |
|
| 1173 | - "'&(nbsp|#160);'i", |
|
| 1174 | - "'&(iexcl|#161);'i", |
|
| 1175 | - "'&(cent|#162);'i", |
|
| 1176 | - "'&(pound|#163);'i", |
|
| 1177 | - "'&(copy|#169);'i" |
|
| 1178 | - ); // evaluate as php |
|
| 1179 | - |
|
| 1180 | - $replace = array( |
|
| 1181 | - '', |
|
| 1182 | - '', |
|
| 1183 | - '', |
|
| 1184 | - "\\1", |
|
| 1185 | - "\"", |
|
| 1186 | - '&', |
|
| 1187 | - '<', |
|
| 1188 | - '>', |
|
| 1189 | - ' ', |
|
| 1190 | - chr(161), |
|
| 1191 | - chr(162), |
|
| 1192 | - chr(163), |
|
| 1193 | - chr(169), |
|
| 1194 | - ); |
|
| 1195 | - |
|
| 1196 | - $text = preg_replace($search, $replace, $document); |
|
| 1197 | - |
|
| 1198 | - preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1199 | - return chr($matches[1]); |
|
| 1200 | - }, $document); |
|
| 1201 | - |
|
| 1202 | - return $text; |
|
| 1158 | + // PHP Manual:: function preg_replace |
|
| 1159 | + // $document should contain an HTML document. |
|
| 1160 | + // This will remove HTML tags, javascript sections |
|
| 1161 | + // and white space. It will also convert some |
|
| 1162 | + // common HTML entities to their text equivalent. |
|
| 1163 | + // Credits: newbb2 |
|
| 1164 | + $search = array( |
|
| 1165 | + "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1166 | + "'<img.*?>'si", // Strip out img tags |
|
| 1167 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1168 | + "'([\r\n])[\s]+'", // Strip out white space |
|
| 1169 | + "'&(quot|#34);'i", // Replace HTML entities |
|
| 1170 | + "'&(amp|#38);'i", |
|
| 1171 | + "'&(lt|#60);'i", |
|
| 1172 | + "'&(gt|#62);'i", |
|
| 1173 | + "'&(nbsp|#160);'i", |
|
| 1174 | + "'&(iexcl|#161);'i", |
|
| 1175 | + "'&(cent|#162);'i", |
|
| 1176 | + "'&(pound|#163);'i", |
|
| 1177 | + "'&(copy|#169);'i" |
|
| 1178 | + ); // evaluate as php |
|
| 1179 | + |
|
| 1180 | + $replace = array( |
|
| 1181 | + '', |
|
| 1182 | + '', |
|
| 1183 | + '', |
|
| 1184 | + "\\1", |
|
| 1185 | + "\"", |
|
| 1186 | + '&', |
|
| 1187 | + '<', |
|
| 1188 | + '>', |
|
| 1189 | + ' ', |
|
| 1190 | + chr(161), |
|
| 1191 | + chr(162), |
|
| 1192 | + chr(163), |
|
| 1193 | + chr(169), |
|
| 1194 | + ); |
|
| 1195 | + |
|
| 1196 | + $text = preg_replace($search, $replace, $document); |
|
| 1197 | + |
|
| 1198 | + preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1199 | + return chr($matches[1]); |
|
| 1200 | + }, $document); |
|
| 1201 | + |
|
| 1202 | + return $text; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /** |
@@ -1213,32 +1213,32 @@ discard block |
||
| 1213 | 1213 | */ |
| 1214 | 1214 | function smart_getfloat($str, $set = false) |
| 1215 | 1215 | { |
| 1216 | - if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1217 | - // Found number in $str, so set $str that number |
|
| 1218 | - $str = $match[0]; |
|
| 1219 | - if (false !== strpos($str, ',')) { |
|
| 1220 | - // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1221 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1223 | - |
|
| 1224 | - return (float)$str; |
|
| 1225 | - } else { |
|
| 1226 | - // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1227 | - if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) === true && $set['single_dot_as_decimal'] === true) { |
|
| 1228 | - // Treat single dot as decimal separator |
|
| 1229 | - return (float)$str; |
|
| 1230 | - } else { |
|
| 1231 | - //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1232 | - // Else, treat all dots as thousand seps |
|
| 1233 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1234 | - |
|
| 1235 | - return (float)$str; |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - } else { |
|
| 1239 | - // No number found, return zero |
|
| 1240 | - return 0; |
|
| 1241 | - } |
|
| 1216 | + if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1217 | + // Found number in $str, so set $str that number |
|
| 1218 | + $str = $match[0]; |
|
| 1219 | + if (false !== strpos($str, ',')) { |
|
| 1220 | + // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1221 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1223 | + |
|
| 1224 | + return (float)$str; |
|
| 1225 | + } else { |
|
| 1226 | + // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1227 | + if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) === true && $set['single_dot_as_decimal'] === true) { |
|
| 1228 | + // Treat single dot as decimal separator |
|
| 1229 | + return (float)$str; |
|
| 1230 | + } else { |
|
| 1231 | + //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1232 | + // Else, treat all dots as thousand seps |
|
| 1233 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1234 | + |
|
| 1235 | + return (float)$str; |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + } else { |
|
| 1239 | + // No number found, return zero |
|
| 1240 | + return 0; |
|
| 1241 | + } |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | /** |
@@ -1248,26 +1248,26 @@ discard block |
||
| 1248 | 1248 | */ |
| 1249 | 1249 | function smart_currency($var, $currencyObj = false) |
| 1250 | 1250 | { |
| 1251 | - $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
| 1252 | - $ret = round($ret, 2); |
|
| 1253 | - // make sur we have at least .00 in the $var |
|
| 1254 | - $decimal_section_original = strstr($ret, '.'); |
|
| 1255 | - $decimal_section = $decimal_section_original; |
|
| 1256 | - if ($decimal_section) { |
|
| 1257 | - if (strlen($decimal_section) == 1) { |
|
| 1258 | - $decimal_section = '.00'; |
|
| 1259 | - } elseif (strlen($decimal_section) == 2) { |
|
| 1260 | - $decimal_section .= '0'; |
|
| 1261 | - } |
|
| 1262 | - $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1263 | - } else { |
|
| 1264 | - $ret .= '.00'; |
|
| 1265 | - } |
|
| 1266 | - if ($currencyObj) { |
|
| 1267 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - return $ret; |
|
| 1251 | + $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
| 1252 | + $ret = round($ret, 2); |
|
| 1253 | + // make sur we have at least .00 in the $var |
|
| 1254 | + $decimal_section_original = strstr($ret, '.'); |
|
| 1255 | + $decimal_section = $decimal_section_original; |
|
| 1256 | + if ($decimal_section) { |
|
| 1257 | + if (strlen($decimal_section) == 1) { |
|
| 1258 | + $decimal_section = '.00'; |
|
| 1259 | + } elseif (strlen($decimal_section) == 2) { |
|
| 1260 | + $decimal_section .= '0'; |
|
| 1261 | + } |
|
| 1262 | + $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1263 | + } else { |
|
| 1264 | + $ret .= '.00'; |
|
| 1265 | + } |
|
| 1266 | + if ($currencyObj) { |
|
| 1267 | + $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + return $ret; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | */ |
| 1277 | 1277 | function smart_float($var) |
| 1278 | 1278 | { |
| 1279 | - return smart_currency($var); |
|
| 1279 | + return smart_currency($var); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
@@ -1285,16 +1285,16 @@ discard block |
||
| 1285 | 1285 | */ |
| 1286 | 1286 | function smart_getModuleAdminLink($moduleName = false) |
| 1287 | 1287 | { |
| 1288 | - global $xoopsModule; |
|
| 1289 | - if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1290 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1291 | - } |
|
| 1292 | - $ret = ''; |
|
| 1293 | - if ($moduleName) { |
|
| 1294 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - return $ret; |
|
| 1288 | + global $xoopsModule; |
|
| 1289 | + if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1290 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1291 | + } |
|
| 1292 | + $ret = ''; |
|
| 1293 | + if ($moduleName) { |
|
| 1294 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1295 | + } |
|
| 1296 | + |
|
| 1297 | + return $ret; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | 1300 | /** |
@@ -1302,19 +1302,19 @@ discard block |
||
| 1302 | 1302 | */ |
| 1303 | 1303 | function smart_getEditors() |
| 1304 | 1304 | { |
| 1305 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1306 | - if (!file_exists($filename)) { |
|
| 1307 | - return false; |
|
| 1308 | - } |
|
| 1309 | - require_once $filename; |
|
| 1310 | - $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1311 | - $aList = $xoopseditorHandler->getList(); |
|
| 1312 | - $ret = array(); |
|
| 1313 | - foreach ($aList as $k => $v) { |
|
| 1314 | - $ret[$v] = $k; |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - return $ret; |
|
| 1305 | + $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1306 | + if (!file_exists($filename)) { |
|
| 1307 | + return false; |
|
| 1308 | + } |
|
| 1309 | + require_once $filename; |
|
| 1310 | + $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1311 | + $aList = $xoopseditorHandler->getList(); |
|
| 1312 | + $ret = array(); |
|
| 1313 | + foreach ($aList as $k => $v) { |
|
| 1314 | + $ret[$v] = $k; |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + return $ret; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | /** |
@@ -1324,11 +1324,11 @@ discard block |
||
| 1324 | 1324 | */ |
| 1325 | 1325 | function smart_getTablesArray($moduleName, $items) |
| 1326 | 1326 | { |
| 1327 | - $ret = array(); |
|
| 1328 | - foreach ($items as $item) { |
|
| 1329 | - $ret[] = $moduleName . '_' . $item; |
|
| 1330 | - } |
|
| 1331 | - $ret[] = $moduleName . '_meta'; |
|
| 1327 | + $ret = array(); |
|
| 1328 | + foreach ($items as $item) { |
|
| 1329 | + $ret[] = $moduleName . '_' . $item; |
|
| 1330 | + } |
|
| 1331 | + $ret[] = $moduleName . '_meta'; |
|
| 1332 | 1332 | |
| 1333 | - return $ret; |
|
| 1333 | + return $ret; |
|
| 1334 | 1334 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function smart_get_css_link($cssfile) |
| 13 | 13 | { |
| 14 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 14 | + $ret = '<link rel="stylesheet" type="text/css" href="'.$cssfile.'">'; |
|
| 15 | 15 | |
| 16 | 16 | return $ret; |
| 17 | 17 | } |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $seoMode = smart_getModuleModeSEO($moduleName); |
| 103 | 103 | if ($seoMode === 'rewrite') { |
| 104 | 104 | $seoModuleName = smart_getModuleNameForSEO($moduleName); |
| 105 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 105 | + $ret = XOOPS_URL.'/'.$seoModuleName.'/'; |
|
| 106 | 106 | } elseif ($seoMode === 'pathinfo') { |
| 107 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 107 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/seo.php/'.$seoModuleName.'/'; |
|
| 108 | 108 | } else { |
| 109 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 109 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 112 | + return '<a href="'.$ret.'">'.$smartModule->getVar('name').'</a>'; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | /** |
| 173 | 173 | * include SmartObject admin language file |
| 174 | 174 | */ |
| 175 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 175 | + $fileName = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php'; |
|
| 176 | 176 | if (file_exists($fileName)) { |
| 177 | 177 | require_once $fileName; |
| 178 | 178 | } else { |
| 179 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 179 | + require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php'; |
|
| 180 | 180 | } ?> |
| 181 | 181 | <script type='text/javascript'> |
| 182 | 182 | <!-- |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | /** |
| 194 | 194 | * Include the admin language constants for the SmartObject Framework |
| 195 | 195 | */ |
| 196 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 196 | + $admin_file = SMARTOBJECT_ROOT_PATH.'language/'.$xoopsConfig['language'].'/admin.php'; |
|
| 197 | 197 | if (!file_exists($admin_file)) { |
| 198 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
| 198 | + $admin_file = SMARTOBJECT_ROOT_PATH.'language/english/admin.php'; |
|
| 199 | 199 | } |
| 200 | 200 | require_once $admin_file; |
| 201 | 201 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | //Verifies that a MySQL table exists |
| 216 | 216 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
| 217 | 217 | $realname = $xoopsDB->prefix($table); |
| 218 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 218 | + $sql = 'SHOW TABLES FROM '.XOOPS_DB_NAME; |
|
| 219 | 219 | $ret = $xoopsDB->queryF($sql); |
| 220 | 220 | while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
| 221 | 221 | if ($m_table == $realname) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $moduleName = smart_getCurrentModuleName(); |
| 245 | 245 | } |
| 246 | 246 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
| 247 | - $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 247 | + $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key)); |
|
| 248 | 248 | $ret = $xoopsDB->query($sql); |
| 249 | 249 | if (!$ret) { |
| 250 | 250 | $value = false; |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
| 288 | 288 | $ret = smart_GetMeta($key, $moduleName); |
| 289 | 289 | if ($ret === '0' || $ret > 0) { |
| 290 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 290 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 291 | 291 | } else { |
| 292 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 292 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 293 | 293 | } |
| 294 | 294 | $ret = $xoopsDB->queryF($sql); |
| 295 | 295 | if (!$ret) { |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | { |
| 470 | 470 | static $smartModules; |
| 471 | 471 | if (isset($smartModules[$moduleName])) { |
| 472 | - $ret =& $smartModules[$moduleName]; |
|
| 472 | + $ret = & $smartModules[$moduleName]; |
|
| 473 | 473 | |
| 474 | 474 | return $ret; |
| 475 | 475 | } |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | { |
| 506 | 506 | static $smartConfigs; |
| 507 | 507 | if (isset($smartConfigs[$moduleName])) { |
| 508 | - $ret =& $smartConfigs[$moduleName]; |
|
| 508 | + $ret = & $smartConfigs[$moduleName]; |
|
| 509 | 509 | |
| 510 | 510 | return $ret; |
| 511 | 511 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | return $ret; |
| 534 | 534 | } |
| 535 | 535 | $hModConfig = xoops_getHandler('config'); |
| 536 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 536 | + $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | return $smartConfigs[$moduleName]; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | { |
| 560 | 560 | $ret = ''; |
| 561 | 561 | foreach ($errors as $key => $value) { |
| 562 | - $ret .= '<br> - ' . $value; |
|
| 562 | + $ret .= '<br> - '.$value; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | return $ret; |
@@ -579,17 +579,17 @@ discard block |
||
| 579 | 579 | if (!is_numeric($userid)) { |
| 580 | 580 | return $userid; |
| 581 | 581 | } |
| 582 | - $userid = (int)$userid; |
|
| 582 | + $userid = (int) $userid; |
|
| 583 | 583 | if ($userid > 0) { |
| 584 | 584 | if ($users == array()) { |
| 585 | 585 | //fetching users |
| 586 | 586 | $memberHandler = xoops_getHandler('member'); |
| 587 | - $user =& $memberHandler->getUser($userid); |
|
| 587 | + $user = & $memberHandler->getUser($userid); |
|
| 588 | 588 | } else { |
| 589 | 589 | if (!isset($users[$userid])) { |
| 590 | 590 | return $GLOBALS['xoopsConfig']['anonymous']; |
| 591 | 591 | } |
| 592 | - $user =& $users[$userid]; |
|
| 592 | + $user = & $users[$userid]; |
|
| 593 | 593 | } |
| 594 | 594 | if (is_object($user)) { |
| 595 | 595 | $ts = MyTextSanitizer:: getInstance(); |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | $fullname = $user->getVar('name'); |
| 601 | 601 | } |
| 602 | 602 | if (!empty($fullname)) { |
| 603 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 603 | + $linkeduser = "$fullname [<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".$ts->htmlSpecialChars($username).'</a>]'; |
|
| 604 | 604 | } else { |
| 605 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 605 | + $linkeduser = "<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".ucwords($ts->htmlSpecialChars($username)).'</a>'; |
|
| 606 | 606 | } |
| 607 | 607 | // add contact info: email + PM |
| 608 | 608 | if ($withContact) { |
| 609 | - $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"></a>'; |
|
| 610 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 611 | - $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"></a>'; |
|
| 609 | + $linkeduser .= ' <a href="mailto:'.$user->getVar('email').'"><img style="vertical-align: middle;" src="'.XOOPS_URL.'/images/icons/email.gif'.'" alt="'._CO_SOBJECT_SEND_EMAIL.'" title="'._CO_SOBJECT_SEND_EMAIL.'"></a>'; |
|
| 610 | + $js = "javascript:openWithSelfMain('".XOOPS_URL.'/pmlite.php?send2=1&to_userid='.$userid."', 'pmlite',450,370);"; |
|
| 611 | + $linkeduser .= ' <a href="'.$js.'"><img style="vertical-align: middle;" src="'.XOOPS_URL.'/images/icons/pm.gif'.'" alt="'._CO_SOBJECT_SEND_PM.'" title="'._CO_SOBJECT_SEND_PM.'"></a>'; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | return $linkeduser; |
@@ -627,20 +627,20 @@ discard block |
||
| 627 | 627 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
| 628 | 628 | { |
| 629 | 629 | global $xoopsModule, $xoopsConfig; |
| 630 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 631 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 632 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 630 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
| 631 | + if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) { |
|
| 632 | + require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php'; |
|
| 633 | 633 | } else { |
| 634 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 634 | + require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/modinfo.php'; |
|
| 635 | 635 | } |
| 636 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 637 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 636 | + if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php')) { |
|
| 637 | + require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php'; |
|
| 638 | 638 | } else { |
| 639 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 639 | + require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/admin.php'; |
|
| 640 | 640 | } |
| 641 | 641 | $headermenu = array(); |
| 642 | 642 | $adminObject = array(); |
| 643 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 643 | + include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/admin/menu.php'; |
|
| 644 | 644 | $tpl = new XoopsTpl(); |
| 645 | 645 | $tpl->assign(array( |
| 646 | 646 | 'headermenu' => $headermenu, |
@@ -663,11 +663,11 @@ discard block |
||
| 663 | 663 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
| 664 | 664 | { |
| 665 | 665 | global $xoopsModule; |
| 666 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 667 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 668 | - echo "<div id='" . $id . "'>"; |
|
| 666 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('".$id."'); toggleIcon('".$id."_icon')\";>"; |
|
| 667 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt=''></a> ".$title.'</h3>'; |
|
| 668 | + echo "<div id='".$id."'>"; |
|
| 669 | 669 | if ($dsc !== '') { |
| 670 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 670 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>'; |
|
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
@@ -681,11 +681,11 @@ discard block |
||
| 681 | 681 | global $xoopsModule; |
| 682 | 682 | $onClick = "ajaxtogglecollapse('$id')"; |
| 683 | 683 | //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
| 684 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 685 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 686 | - echo "<div id='" . $id . "'>"; |
|
| 684 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="'.$onClick.'">'; |
|
| 685 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt=''></a> ".$title.'</h3>'; |
|
| 686 | + echo "<div id='".$id."'>"; |
|
| 687 | 687 | if ($dsc !== '') { |
| 688 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 688 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">".$dsc.'</span>'; |
|
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
@@ -715,13 +715,13 @@ discard block |
||
| 715 | 715 | { |
| 716 | 716 | $urls = smart_getCurrentUrls(); |
| 717 | 717 | $path = $urls['phpself']; |
| 718 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 718 | + $cookie_name = $path.'_smart_collaps_'.$name; |
|
| 719 | 719 | $cookie_name = str_replace('.', '_', $cookie_name); |
| 720 | 720 | $cookie = smart_getCookieVar($cookie_name, ''); |
| 721 | 721 | if ($cookie === 'none') { |
| 722 | 722 | echo ' |
| 723 | 723 | <script type="text/javascript"><!-- |
| 724 | - togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
|
| 724 | + togglecollapse("' . $name.'"); toggleIcon("'.$name.'_icon"); |
|
| 725 | 725 | //--> |
| 726 | 726 | </script> |
| 727 | 727 | '; |
@@ -787,17 +787,17 @@ discard block |
||
| 787 | 787 | $httphost = $_SERVER['HTTP_HOST']; |
| 788 | 788 | $querystring = $_SERVER['QUERY_STRING']; |
| 789 | 789 | if ($querystring !== '') { |
| 790 | - $querystring = '?' . $querystring; |
|
| 790 | + $querystring = '?'.$querystring; |
|
| 791 | 791 | } |
| 792 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 792 | + $currenturl = $http.$httphost.$phpself.$querystring; |
|
| 793 | 793 | $urls = array(); |
| 794 | 794 | $urls['http'] = $http; |
| 795 | 795 | $urls['httphost'] = $httphost; |
| 796 | 796 | $urls['phpself'] = $phpself; |
| 797 | 797 | $urls['querystring'] = $querystring; |
| 798 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 798 | + $urls['full_phpself'] = $http.$httphost.$phpself; |
|
| 799 | 799 | $urls['full'] = $currenturl; |
| 800 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 800 | + $urls['isHomePage'] = (XOOPS_URL.'/index.php') == ($http.$httphost.$phpself); |
|
| 801 | 801 | |
| 802 | 802 | return $urls; |
| 803 | 803 | } |
@@ -874,13 +874,13 @@ discard block |
||
| 874 | 874 | { |
| 875 | 875 | global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
| 876 | 876 | |
| 877 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 877 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
| 878 | 878 | $tpl = new XoopsTpl(); |
| 879 | 879 | |
| 880 | 880 | $hModule = xoops_getHandler('module'); |
| 881 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 883 | - $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'></a>"; |
|
| 881 | + $versioninfo = & $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | + $modfootertxt = 'Module '.$versioninfo->getInfo('name').' - Version '.$versioninfo->getInfo('version').''; |
|
| 883 | + $modfooter = "<a href='".$versioninfo->getInfo('support_site_url')."' target='_blank'><img src='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/assets/images/cssbutton.gif' title='".$modfootertxt."' alt='".$modfootertxt."'></a>"; |
|
| 884 | 884 | $tpl->assign('modfooter', $modfooter); |
| 885 | 885 | |
| 886 | 886 | if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | } |
| 889 | 889 | $smartobjectConfig = smart_getModuleConfig('smartobject'); |
| 890 | 890 | $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
| 891 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 891 | + $tpl->display(SMARTOBJECT_ROOT_PATH.'templates/smartobject_admin_footer.tpl'); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | function smart_xoops_cp_footer() |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | function smart_addScript($src) |
| 917 | 917 | { |
| 918 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 918 | + echo '<script src="'.$src.'" type="text/javascript"></script>'; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -924,16 +924,16 @@ discard block |
||
| 924 | 924 | function smart_addStyle($src) |
| 925 | 925 | { |
| 926 | 926 | if ($src === 'smartobject') { |
| 927 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 927 | + $src = SMARTOBJECT_URL.'assets/css/module.css'; |
|
| 928 | 928 | } |
| 929 | 929 | echo smart_get_css_link($src); |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | function smart_addAdminAjaxSupport() |
| 933 | 933 | { |
| 934 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 935 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 934 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/lib/prototype.js'); |
|
| 935 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/smart.js'); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | /** |
@@ -993,8 +993,8 @@ discard block |
||
| 993 | 993 | function smart_htmlnumericentities($str) |
| 994 | 994 | { |
| 995 | 995 | // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
| 996 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 997 | - return '&#' . ord($m[0]) . chr(59); |
|
| 996 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function($m) { |
|
| 997 | + return '&#'.ord($m[0]).chr(59); |
|
| 998 | 998 | }, $str); |
| 999 | 999 | } |
| 1000 | 1000 | |
@@ -1008,16 +1008,16 @@ discard block |
||
| 1008 | 1008 | static $handlers; |
| 1009 | 1009 | $name = strtolower(trim($name)); |
| 1010 | 1010 | if (!isset($handlers[$name])) { |
| 1011 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1011 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH.'/kernel/'.$name.'.php')) { |
|
| 1012 | 1012 | require_once $hnd_file; |
| 1013 | 1013 | } |
| 1014 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1014 | + $class = 'Xoops'.ucfirst($name).'Handler'; |
|
| 1015 | 1015 | if (class_exists($class)) { |
| 1016 | 1016 | $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | 1019 | if (!isset($handlers[$name]) && !$optional) { |
| 1020 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1020 | + trigger_error('Class <b>'.$class.'</b> does not exist<br>Handler Name: '.$name, E_USER_ERROR); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | if (isset($handlers[$name])) { |
| 1023 | 1023 | return $handlers[$name]; |
@@ -1097,9 +1097,9 @@ discard block |
||
| 1097 | 1097 | { |
| 1098 | 1098 | global $xoopsConfig; |
| 1099 | 1099 | |
| 1100 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1100 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/'.$xoopsConfig['language'].'/'.$file.'.php'; |
|
| 1101 | 1101 | if (!file_exists($filename)) { |
| 1102 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1102 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/english/'.$file.'.php'; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | if (file_exists($filename)) { |
| 1105 | 1105 | require_once $filename; |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | $text = preg_replace($search, $replace, $document); |
| 1197 | 1197 | |
| 1198 | - preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1198 | + preg_replace_callback('/&#(\d+);/', function($matches) { |
|
| 1199 | 1199 | return chr($matches[1]); |
| 1200 | 1200 | }, $document); |
| 1201 | 1201 | |
@@ -1218,21 +1218,21 @@ discard block |
||
| 1218 | 1218 | $str = $match[0]; |
| 1219 | 1219 | if (false !== strpos($str, ',')) { |
| 1220 | 1220 | // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
| 1221 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1221 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1223 | 1223 | |
| 1224 | - return (float)$str; |
|
| 1224 | + return (float) $str; |
|
| 1225 | 1225 | } else { |
| 1226 | 1226 | // No comma exists, so we have to decide, how a single dot shall be treated |
| 1227 | 1227 | if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) === true && $set['single_dot_as_decimal'] === true) { |
| 1228 | 1228 | // Treat single dot as decimal separator |
| 1229 | - return (float)$str; |
|
| 1229 | + return (float) $str; |
|
| 1230 | 1230 | } else { |
| 1231 | 1231 | //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
| 1232 | 1232 | // Else, treat all dots as thousand seps |
| 1233 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1233 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1234 | 1234 | |
| 1235 | - return (float)$str; |
|
| 1235 | + return (float) $str; |
|
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | } else { |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | $ret .= '.00'; |
| 1265 | 1265 | } |
| 1266 | 1266 | if ($currencyObj) { |
| 1267 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1267 | + $ret = $ret.' '.$currencyObj->getCode(); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | return $ret; |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | } |
| 1292 | 1292 | $ret = ''; |
| 1293 | 1293 | if ($moduleName) { |
| 1294 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1294 | + $ret = "<a href='".XOOPS_URL."/modules/$moduleName/admin/index.php'>"._CO_SOBJECT_ADMIN_PAGE.'</a>'; |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | return $ret; |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | */ |
| 1303 | 1303 | function smart_getEditors() |
| 1304 | 1304 | { |
| 1305 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1305 | + $filename = XOOPS_ROOT_PATH.'/class/xoopseditor/xoopseditor.php'; |
|
| 1306 | 1306 | if (!file_exists($filename)) { |
| 1307 | 1307 | return false; |
| 1308 | 1308 | } |
@@ -1326,9 +1326,9 @@ discard block |
||
| 1326 | 1326 | { |
| 1327 | 1327 | $ret = array(); |
| 1328 | 1328 | foreach ($items as $item) { |
| 1329 | - $ret[] = $moduleName . '_' . $item; |
|
| 1329 | + $ret[] = $moduleName.'_'.$item; |
|
| 1330 | 1330 | } |
| 1331 | - $ret[] = $moduleName . '_meta'; |
|
| 1331 | + $ret[] = $moduleName.'_meta'; |
|
| 1332 | 1332 | |
| 1333 | 1333 | return $ret; |
| 1334 | 1334 | } |
@@ -8,14 +8,14 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | class SmartobjectFile extends SmartobjectBasedUrl |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * SmartobjectFile constructor. |
|
| 13 | - */ |
|
| 14 | - public function __construct() |
|
| 15 | - { |
|
| 16 | - parent::__construct(); |
|
| 17 | - $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 18 | - } |
|
| 11 | + /** |
|
| 12 | + * SmartobjectFile constructor. |
|
| 13 | + */ |
|
| 14 | + public function __construct() |
|
| 15 | + { |
|
| 16 | + parent::__construct(); |
|
| 17 | + $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class SmartobjectFileHandler extends SmartPersistableObjectHandler |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * SmartobjectFileHandler constructor. |
|
| 28 | - * @param XoopsDatabase $db |
|
| 29 | - */ |
|
| 30 | - public function __construct(XoopsDatabase $db) |
|
| 31 | - { |
|
| 32 | - parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject'); |
|
| 33 | - } |
|
| 26 | + /** |
|
| 27 | + * SmartobjectFileHandler constructor. |
|
| 28 | + * @param XoopsDatabase $db |
|
| 29 | + */ |
|
| 30 | + public function __construct(XoopsDatabase $db) |
|
| 31 | + { |
|
| 32 | + parent::__construct($db, 'file', 'fileid', 'caption', 'desc', 'smartobject'); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 3 | 3 | |
| 4 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/basedurl.php'; |
|
| 4 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/basedurl.php'; |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * Class SmartobjectFile |
@@ -37,125 +37,125 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | class SmartobjectRating extends SmartObject |
| 39 | 39 | { |
| 40 | - public $_modulePlugin = false; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * SmartobjectRating constructor. |
|
| 44 | - */ |
|
| 45 | - public function __construct() |
|
| 46 | - { |
|
| 47 | - $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
| 48 | - $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 49 | - $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
| 50 | - $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
| 51 | - $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
| 52 | - $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
| 53 | - $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
| 54 | - |
|
| 55 | - $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
| 56 | - |
|
| 57 | - $this->setControl('dirname', array( |
|
| 58 | - 'handler' => 'rating', |
|
| 59 | - 'method' => 'getModuleList', |
|
| 60 | - 'onSelect' => 'submit' |
|
| 61 | - )); |
|
| 62 | - |
|
| 63 | - $this->setControl('item', array( |
|
| 64 | - 'object' => &$this, |
|
| 65 | - 'method' => 'getItemList' |
|
| 66 | - )); |
|
| 67 | - |
|
| 68 | - $this->setControl('uid', 'user'); |
|
| 69 | - |
|
| 70 | - $this->setControl('rate', array( |
|
| 71 | - 'handler' => 'rating', |
|
| 72 | - 'method' => 'getRateList' |
|
| 73 | - )); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param string $key |
|
| 78 | - * @param string $format |
|
| 79 | - * @return mixed |
|
| 80 | - */ |
|
| 81 | - public function getVar($key, $format = 's') |
|
| 82 | - { |
|
| 83 | - if ($format === 's' && in_array($key, array('name', 'dirname'))) { |
|
| 84 | - // return call_user_func(array($this, $key)); |
|
| 85 | - return $this->{$key}(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return parent::getVar($key, $format); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function name() |
|
| 95 | - { |
|
| 96 | - $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, array()); |
|
| 97 | - |
|
| 98 | - return $ret; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @return mixed |
|
| 103 | - */ |
|
| 104 | - public function dirname() |
|
| 105 | - { |
|
| 106 | - global $smartobjectRatingHandler; |
|
| 107 | - $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
| 108 | - |
|
| 109 | - return $moduleArray[$this->getVar('dirname', 'n')]; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @return mixed |
|
| 114 | - */ |
|
| 115 | - public function getItemList() |
|
| 116 | - { |
|
| 117 | - $plugin = $this->getModulePlugin(); |
|
| 118 | - |
|
| 119 | - return $plugin->getItemList(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - public function getItemValue() |
|
| 126 | - { |
|
| 127 | - $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
| 128 | - $plugin = $this->getModulePlugin(); |
|
| 129 | - $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
| 130 | - if (!$pluginItemInfo) { |
|
| 131 | - return ''; |
|
| 132 | - } |
|
| 133 | - $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
| 134 | - $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
| 135 | - |
|
| 136 | - return $ret; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return mixed |
|
| 141 | - */ |
|
| 142 | - public function getRateValue() |
|
| 143 | - { |
|
| 144 | - return $this->getVar('rate'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @return bool |
|
| 149 | - */ |
|
| 150 | - public function getModulePlugin() |
|
| 151 | - { |
|
| 152 | - if (!$this->_modulePlugin) { |
|
| 153 | - global $smartobjectRatingHandler; |
|
| 154 | - $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $this->_modulePlugin; |
|
| 158 | - } |
|
| 40 | + public $_modulePlugin = false; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * SmartobjectRating constructor. |
|
| 44 | + */ |
|
| 45 | + public function __construct() |
|
| 46 | + { |
|
| 47 | + $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
| 48 | + $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 49 | + $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
| 50 | + $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
| 51 | + $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
| 52 | + $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
| 53 | + $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
| 54 | + |
|
| 55 | + $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
| 56 | + |
|
| 57 | + $this->setControl('dirname', array( |
|
| 58 | + 'handler' => 'rating', |
|
| 59 | + 'method' => 'getModuleList', |
|
| 60 | + 'onSelect' => 'submit' |
|
| 61 | + )); |
|
| 62 | + |
|
| 63 | + $this->setControl('item', array( |
|
| 64 | + 'object' => &$this, |
|
| 65 | + 'method' => 'getItemList' |
|
| 66 | + )); |
|
| 67 | + |
|
| 68 | + $this->setControl('uid', 'user'); |
|
| 69 | + |
|
| 70 | + $this->setControl('rate', array( |
|
| 71 | + 'handler' => 'rating', |
|
| 72 | + 'method' => 'getRateList' |
|
| 73 | + )); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param string $key |
|
| 78 | + * @param string $format |
|
| 79 | + * @return mixed |
|
| 80 | + */ |
|
| 81 | + public function getVar($key, $format = 's') |
|
| 82 | + { |
|
| 83 | + if ($format === 's' && in_array($key, array('name', 'dirname'))) { |
|
| 84 | + // return call_user_func(array($this, $key)); |
|
| 85 | + return $this->{$key}(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return parent::getVar($key, $format); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function name() |
|
| 95 | + { |
|
| 96 | + $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, array()); |
|
| 97 | + |
|
| 98 | + return $ret; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @return mixed |
|
| 103 | + */ |
|
| 104 | + public function dirname() |
|
| 105 | + { |
|
| 106 | + global $smartobjectRatingHandler; |
|
| 107 | + $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
| 108 | + |
|
| 109 | + return $moduleArray[$this->getVar('dirname', 'n')]; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @return mixed |
|
| 114 | + */ |
|
| 115 | + public function getItemList() |
|
| 116 | + { |
|
| 117 | + $plugin = $this->getModulePlugin(); |
|
| 118 | + |
|
| 119 | + return $plugin->getItemList(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + public function getItemValue() |
|
| 126 | + { |
|
| 127 | + $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
| 128 | + $plugin = $this->getModulePlugin(); |
|
| 129 | + $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
| 130 | + if (!$pluginItemInfo) { |
|
| 131 | + return ''; |
|
| 132 | + } |
|
| 133 | + $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
| 134 | + $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
| 135 | + |
|
| 136 | + return $ret; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return mixed |
|
| 141 | + */ |
|
| 142 | + public function getRateValue() |
|
| 143 | + { |
|
| 144 | + return $this->getVar('rate'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @return bool |
|
| 149 | + */ |
|
| 150 | + public function getModulePlugin() |
|
| 151 | + { |
|
| 152 | + if (!$this->_modulePlugin) { |
|
| 153 | + global $smartobjectRatingHandler; |
|
| 154 | + $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $this->_modulePlugin; |
|
| 158 | + } |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -163,93 +163,93 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | class SmartobjectRatingHandler extends SmartPersistableObjectHandler |
| 165 | 165 | { |
| 166 | - public $_rateOptions = array(); |
|
| 167 | - public $_moduleList = false; |
|
| 168 | - public $pluginsObject; |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * SmartobjectRatingHandler constructor. |
|
| 172 | - * @param XoopsDatabase $db |
|
| 173 | - */ |
|
| 174 | - public function __construct(XoopsDatabase $db) |
|
| 175 | - { |
|
| 176 | - parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
| 177 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 178 | - |
|
| 179 | - $this->_rateOptions[1] = 1; |
|
| 180 | - $this->_rateOptions[2] = 2; |
|
| 181 | - $this->_rateOptions[3] = 3; |
|
| 182 | - $this->_rateOptions[4] = 4; |
|
| 183 | - $this->_rateOptions[5] = 5; |
|
| 184 | - |
|
| 185 | - $this->pluginsObject = new SmartPluginHandler(); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return bool |
|
| 190 | - */ |
|
| 191 | - public function getModuleList() |
|
| 192 | - { |
|
| 193 | - if (!$this->_moduleList) { |
|
| 194 | - $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
| 195 | - $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
| 196 | - foreach ($moduleArray as $k => $v) { |
|
| 197 | - $this->_moduleList[$k] = $v; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - return $this->_moduleList; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * @return array |
|
| 206 | - */ |
|
| 207 | - public function getRateList() |
|
| 208 | - { |
|
| 209 | - return $this->_rateOptions; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @param $itemid |
|
| 214 | - * @param $dirname |
|
| 215 | - * @param $item |
|
| 216 | - * @return int |
|
| 217 | - */ |
|
| 218 | - public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
| 219 | - { |
|
| 220 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 221 | - $result = $this->db->query($sql); |
|
| 222 | - if (!$result) { |
|
| 223 | - return 0; |
|
| 224 | - } |
|
| 225 | - list($average, $sum) = $this->db->fetchRow($result); |
|
| 226 | - $ret['average'] = isset($average) ? $average : 0; |
|
| 227 | - $ret['sum'] = isset($sum) ? $sum : 0; |
|
| 228 | - |
|
| 229 | - return $ret; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * @param $item |
|
| 234 | - * @param $itemid |
|
| 235 | - * @param $dirname |
|
| 236 | - * @param $uid |
|
| 237 | - * @return bool |
|
| 238 | - */ |
|
| 239 | - public function already_rated($item, $itemid, $dirname, $uid) |
|
| 240 | - { |
|
| 241 | - $criteria = new CriteriaCompo(); |
|
| 242 | - $criteria->add(new Criteria('item', $item)); |
|
| 243 | - $criteria->add(new Criteria('itemid', $itemid)); |
|
| 244 | - $criteria->add(new Criteria('dirname', $dirname)); |
|
| 245 | - $criteria->add(new Criteria('user.uid', $uid)); |
|
| 246 | - |
|
| 247 | - $ret = $this->getObjects($criteria); |
|
| 248 | - |
|
| 249 | - if (!$ret) { |
|
| 250 | - return false; |
|
| 251 | - } else { |
|
| 252 | - return $ret[0]; |
|
| 253 | - } |
|
| 254 | - } |
|
| 166 | + public $_rateOptions = array(); |
|
| 167 | + public $_moduleList = false; |
|
| 168 | + public $pluginsObject; |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * SmartobjectRatingHandler constructor. |
|
| 172 | + * @param XoopsDatabase $db |
|
| 173 | + */ |
|
| 174 | + public function __construct(XoopsDatabase $db) |
|
| 175 | + { |
|
| 176 | + parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
| 177 | + $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 178 | + |
|
| 179 | + $this->_rateOptions[1] = 1; |
|
| 180 | + $this->_rateOptions[2] = 2; |
|
| 181 | + $this->_rateOptions[3] = 3; |
|
| 182 | + $this->_rateOptions[4] = 4; |
|
| 183 | + $this->_rateOptions[5] = 5; |
|
| 184 | + |
|
| 185 | + $this->pluginsObject = new SmartPluginHandler(); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * @return bool |
|
| 190 | + */ |
|
| 191 | + public function getModuleList() |
|
| 192 | + { |
|
| 193 | + if (!$this->_moduleList) { |
|
| 194 | + $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
| 195 | + $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
| 196 | + foreach ($moduleArray as $k => $v) { |
|
| 197 | + $this->_moduleList[$k] = $v; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + return $this->_moduleList; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * @return array |
|
| 206 | + */ |
|
| 207 | + public function getRateList() |
|
| 208 | + { |
|
| 209 | + return $this->_rateOptions; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @param $itemid |
|
| 214 | + * @param $dirname |
|
| 215 | + * @param $item |
|
| 216 | + * @return int |
|
| 217 | + */ |
|
| 218 | + public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
| 219 | + { |
|
| 220 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 221 | + $result = $this->db->query($sql); |
|
| 222 | + if (!$result) { |
|
| 223 | + return 0; |
|
| 224 | + } |
|
| 225 | + list($average, $sum) = $this->db->fetchRow($result); |
|
| 226 | + $ret['average'] = isset($average) ? $average : 0; |
|
| 227 | + $ret['sum'] = isset($sum) ? $sum : 0; |
|
| 228 | + |
|
| 229 | + return $ret; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * @param $item |
|
| 234 | + * @param $itemid |
|
| 235 | + * @param $dirname |
|
| 236 | + * @param $uid |
|
| 237 | + * @return bool |
|
| 238 | + */ |
|
| 239 | + public function already_rated($item, $itemid, $dirname, $uid) |
|
| 240 | + { |
|
| 241 | + $criteria = new CriteriaCompo(); |
|
| 242 | + $criteria->add(new Criteria('item', $item)); |
|
| 243 | + $criteria->add(new Criteria('itemid', $itemid)); |
|
| 244 | + $criteria->add(new Criteria('dirname', $dirname)); |
|
| 245 | + $criteria->add(new Criteria('user.uid', $uid)); |
|
| 246 | + |
|
| 247 | + $ret = $this->getObjects($criteria); |
|
| 248 | + |
|
| 249 | + if (!$ret) { |
|
| 250 | + return false; |
|
| 251 | + } else { |
|
| 252 | + return $ret[0]; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | 255 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 31 | 31 | |
| 32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
| 33 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartplugins.php'; |
|
| 32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
| 33 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartplugins.php'; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Class SmartobjectRating |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function getItemValue() |
| 126 | 126 | { |
| 127 | - $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
| 127 | + $moduleUrl = XOOPS_URL.'/modules/'.$this->getVar('dirname', 'n').'/'; |
|
| 128 | 128 | $plugin = $this->getModulePlugin(); |
| 129 | 129 | $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
| 130 | 130 | if (!$pluginItemInfo) { |
| 131 | 131 | return ''; |
| 132 | 132 | } |
| 133 | 133 | $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
| 134 | - $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
| 134 | + $ret = '<a href="'.$moduleUrl.$itemPath.'">'.$pluginItemInfo['caption'].'</a>'; |
|
| 135 | 135 | |
| 136 | 136 | return $ret; |
| 137 | 137 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | public function __construct(XoopsDatabase $db) |
| 175 | 175 | { |
| 176 | 176 | parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
| 177 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 177 | + $this->generalSQL = 'SELECT * FROM '.$this->table.' AS '.$this->_itemname.' INNER JOIN '.$this->db->prefix('users').' AS user ON '.$this->_itemname.'.uid=user.uid'; |
|
| 178 | 178 | |
| 179 | 179 | $this->_rateOptions[1] = 1; |
| 180 | 180 | $this->_rateOptions[2] = 2; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function getRatingAverageByItemId($itemid, $dirname, $item) |
| 219 | 219 | { |
| 220 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 220 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM '.$this->table." WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 221 | 221 | $result = $this->db->query($sql); |
| 222 | 222 | if (!$result) { |
| 223 | 223 | return 0; |