@@ -248,7 +248,7 @@ |
||
| 248 | 248 | /** |
| 249 | 249 | * @param $field_id |
| 250 | 250 | * @param $options |
| 251 | - * @return mixed |
|
| 251 | + * @return string |
|
| 252 | 252 | */ |
| 253 | 253 | public function auto_complete_field($field_id, $options) |
| 254 | 254 | { |
@@ -15,322 +15,322 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Scriptaculous extends Prototype |
| 17 | 17 | { |
| 18 | - public $TOGGLE_EFFECTS = ['toggle_appear', 'toggle_slide', 'toggle_blind']; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Scriptaculous constructor. |
|
| 22 | - */ |
|
| 23 | - public function __construct() |
|
| 24 | - { |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param $element_id |
|
| 29 | - * @param null $options |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function dragable_element($element_id, $options = null) |
|
| 33 | - { |
|
| 34 | - return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param $element_id |
|
| 39 | - * @param null $options |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function drop_receiving_element($element_id, $options = null) |
|
| 43 | - { |
|
| 44 | - return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param $name |
|
| 49 | - * @param bool $element_id |
|
| 50 | - * @param null $js_options |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | - { |
|
| 55 | - $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | - |
|
| 57 | - $js_queue = ''; |
|
| 58 | - if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | - } elseif (isset($js_options)) { |
|
| 60 | - $js_queue = "'$js_options'"; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | - } else { |
|
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param $element_id |
|
| 72 | - * @param null $options |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function sortabe_element($element_id, $options = null) |
|
| 76 | - { |
|
| 77 | - return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | - // Private functions |
|
| 82 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @param $element_id |
|
| 86 | - * @param $options |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - |
|
| 90 | - public function _sortabe_element($element_id, $options) |
|
| 91 | - { |
|
| 92 | - //if (isset($options['with'])) |
|
| 93 | - { |
|
| 94 | - $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - //if (isset($option['onUpdate'])) |
|
| 98 | - { |
|
| 99 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - foreach ($options as $var => $val) { |
|
| 103 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 104 | - unset($options[$var]); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $arr = ['tag', 'overlap', 'contraint', 'handle']; |
|
| 109 | - |
|
| 110 | - foreach ($arr as $var) { |
|
| 111 | - if (isset($options[$var])) { |
|
| 112 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if (isset($options['containment'])) { |
|
| 117 | - $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if (isset($options['only'])) { |
|
| 121 | - $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param $element_id |
|
| 129 | - * @param $options |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public function _dragable_element_js($element_id, $options) |
|
| 133 | - { |
|
| 134 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param $element_id |
|
| 139 | - * @param $options |
|
| 140 | - * @return string |
|
| 141 | - */ |
|
| 142 | - public function _drop_receiving_element($element_id, $options) |
|
| 143 | - { |
|
| 144 | - |
|
| 145 | - //if (isset($options['with'])) |
|
| 146 | - { |
|
| 147 | - $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - //if (isset($option['onDrop'])) |
|
| 151 | - { |
|
| 152 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - if (is_array($options)) { |
|
| 156 | - foreach ($options as $var => $val) { |
|
| 157 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 158 | - unset($options[$var]); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (isset($options['accept'])) { |
|
| 164 | - $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if (isset($options['hoverclass'])) { |
|
| 168 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 175 | - // Merged Javascript macro |
|
| 176 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @param $field_id |
|
| 180 | - * @param $options |
|
| 181 | - * @param bool $tag |
|
| 182 | - * @return string |
|
| 183 | - */ |
|
| 184 | - public function in_place_editor($field_id, $options, $tag = true) |
|
| 185 | - { |
|
| 186 | - $function = 'new Ajax.InPlaceEditor('; |
|
| 187 | - $function .= "'$field_id', "; |
|
| 188 | - $function .= "'" . $options['url'] . "'"; |
|
| 189 | - |
|
| 190 | - $js_options = []; |
|
| 191 | - if (isset($options['cancel_text'])) { |
|
| 192 | - $js_options['cancelText'] = $options['cancel_text']; |
|
| 193 | - } |
|
| 194 | - if (isset($options['save_text'])) { |
|
| 195 | - $js_options['okText'] = $options['save_text']; |
|
| 196 | - } |
|
| 197 | - if (isset($options['loading_text'])) { |
|
| 198 | - $js_options['loadingText'] = $options['loading_text']; |
|
| 199 | - } |
|
| 200 | - if (isset($options['rows'])) { |
|
| 201 | - $js_options['rows'] = $options['rows']; |
|
| 202 | - } |
|
| 203 | - if (isset($options['cols'])) { |
|
| 204 | - $js_options['cols'] = $options['cols']; |
|
| 205 | - } |
|
| 206 | - if (isset($options['size'])) { |
|
| 207 | - $js_options['size'] = $options['size']; |
|
| 208 | - } |
|
| 209 | - if (isset($options['external_control'])) { |
|
| 210 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 211 | - } |
|
| 212 | - if (isset($options['load_text_url'])) { |
|
| 213 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 214 | - } |
|
| 215 | - if (isset($options['options'])) { |
|
| 216 | - $js_options['ajaxOptions'] = $options['options']; |
|
| 217 | - } |
|
| 218 | - if (isset($options['script'])) { |
|
| 219 | - $js_options['evalScripts'] = $options['script']; |
|
| 220 | - } |
|
| 221 | - if (isset($options['with'])) { |
|
| 222 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 226 | - if ($tag) { |
|
| 227 | - return $this->tag($function); |
|
| 228 | - } else { |
|
| 229 | - return $function; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @param $object |
|
| 235 | - * @param null $tag_options |
|
| 236 | - * @param null $in_place_editor_options |
|
| 237 | - * @return string |
|
| 238 | - */ |
|
| 239 | - public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 240 | - { |
|
| 241 | - $ret_val = ''; |
|
| 242 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 243 | - $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 244 | - |
|
| 245 | - return $ret_val; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param $field_id |
|
| 250 | - * @param $options |
|
| 251 | - * @return mixed |
|
| 252 | - */ |
|
| 253 | - public function auto_complete_field($field_id, $options) |
|
| 254 | - { |
|
| 255 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | - $function .= "'$field_id', "; |
|
| 257 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | - $function .= "'" . $options['url'] . "'"; |
|
| 259 | - |
|
| 260 | - $js_options = []; |
|
| 261 | - if (isset($options['tokens'])) { |
|
| 262 | - $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 263 | - } |
|
| 264 | - if (isset($options['with'])) { |
|
| 265 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 266 | - } |
|
| 267 | - if (isset($options['indicator'])) { |
|
| 268 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 269 | - } |
|
| 270 | - if (isset($options['select'])) { |
|
| 271 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
|
| 275 | - if (isset($options[$var])) { |
|
| 276 | - $js_options['$val'] = $options['var']; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 281 | - |
|
| 282 | - return $this->tag($function); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @param $entries |
|
| 287 | - * @param $field |
|
| 288 | - * @param null $phrase |
|
| 289 | - */ |
|
| 290 | - public function auto_complete_results($entries, $field, $phrase = null) |
|
| 291 | - { |
|
| 292 | - if (!is_array($entries)) { |
|
| 293 | - return; |
|
| 294 | - } |
|
| 295 | - $ret_val = '<ul>'; |
|
| 296 | - // Complete this function |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * @param $object |
|
| 301 | - * @param null $tag_options |
|
| 302 | - * @param null $completion_options |
|
| 303 | - * @return string |
|
| 304 | - */ |
|
| 305 | - public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 306 | - { |
|
| 307 | - $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 308 | - $ret_val .= '<input autocomplete="off" id="' |
|
| 309 | - . $object |
|
| 310 | - . '" name="' |
|
| 311 | - . $object |
|
| 312 | - . '" size="' |
|
| 313 | - . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 314 | - . '" type="text" value="' |
|
| 315 | - . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 316 | - . '" ' |
|
| 317 | - . (isset($tag_options['class']) ? 'class = "' |
|
| 318 | - . $tag_options['class'] |
|
| 319 | - . '" ' : '') |
|
| 320 | - . '>'; |
|
| 321 | - |
|
| 322 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 323 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 324 | - |
|
| 325 | - return $ret_val; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * @return string |
|
| 330 | - */ |
|
| 331 | - public function _auto_complete_stylesheet() |
|
| 332 | - { |
|
| 333 | - return '<style> div.auto_complete { |
|
| 18 | + public $TOGGLE_EFFECTS = ['toggle_appear', 'toggle_slide', 'toggle_blind']; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Scriptaculous constructor. |
|
| 22 | + */ |
|
| 23 | + public function __construct() |
|
| 24 | + { |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param $element_id |
|
| 29 | + * @param null $options |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function dragable_element($element_id, $options = null) |
|
| 33 | + { |
|
| 34 | + return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param $element_id |
|
| 39 | + * @param null $options |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function drop_receiving_element($element_id, $options = null) |
|
| 43 | + { |
|
| 44 | + return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param $name |
|
| 49 | + * @param bool $element_id |
|
| 50 | + * @param null $js_options |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | + { |
|
| 55 | + $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | + |
|
| 57 | + $js_queue = ''; |
|
| 58 | + if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | + } elseif (isset($js_options)) { |
|
| 60 | + $js_queue = "'$js_options'"; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | + return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | + } else { |
|
| 66 | + return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param $element_id |
|
| 72 | + * @param null $options |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function sortabe_element($element_id, $options = null) |
|
| 76 | + { |
|
| 77 | + return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | + // Private functions |
|
| 82 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param $element_id |
|
| 86 | + * @param $options |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + |
|
| 90 | + public function _sortabe_element($element_id, $options) |
|
| 91 | + { |
|
| 92 | + //if (isset($options['with'])) |
|
| 93 | + { |
|
| 94 | + $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + //if (isset($option['onUpdate'])) |
|
| 98 | + { |
|
| 99 | + $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + foreach ($options as $var => $val) { |
|
| 103 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 104 | + unset($options[$var]); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $arr = ['tag', 'overlap', 'contraint', 'handle']; |
|
| 109 | + |
|
| 110 | + foreach ($arr as $var) { |
|
| 111 | + if (isset($options[$var])) { |
|
| 112 | + $options[$var] = "'" . $options[$var] . "'"; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if (isset($options['containment'])) { |
|
| 117 | + $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if (isset($options['only'])) { |
|
| 121 | + $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param $element_id |
|
| 129 | + * @param $options |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public function _dragable_element_js($element_id, $options) |
|
| 133 | + { |
|
| 134 | + return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param $element_id |
|
| 139 | + * @param $options |
|
| 140 | + * @return string |
|
| 141 | + */ |
|
| 142 | + public function _drop_receiving_element($element_id, $options) |
|
| 143 | + { |
|
| 144 | + |
|
| 145 | + //if (isset($options['with'])) |
|
| 146 | + { |
|
| 147 | + $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + //if (isset($option['onDrop'])) |
|
| 151 | + { |
|
| 152 | + $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if (is_array($options)) { |
|
| 156 | + foreach ($options as $var => $val) { |
|
| 157 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 158 | + unset($options[$var]); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (isset($options['accept'])) { |
|
| 164 | + $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if (isset($options['hoverclass'])) { |
|
| 168 | + $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 175 | + // Merged Javascript macro |
|
| 176 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @param $field_id |
|
| 180 | + * @param $options |
|
| 181 | + * @param bool $tag |
|
| 182 | + * @return string |
|
| 183 | + */ |
|
| 184 | + public function in_place_editor($field_id, $options, $tag = true) |
|
| 185 | + { |
|
| 186 | + $function = 'new Ajax.InPlaceEditor('; |
|
| 187 | + $function .= "'$field_id', "; |
|
| 188 | + $function .= "'" . $options['url'] . "'"; |
|
| 189 | + |
|
| 190 | + $js_options = []; |
|
| 191 | + if (isset($options['cancel_text'])) { |
|
| 192 | + $js_options['cancelText'] = $options['cancel_text']; |
|
| 193 | + } |
|
| 194 | + if (isset($options['save_text'])) { |
|
| 195 | + $js_options['okText'] = $options['save_text']; |
|
| 196 | + } |
|
| 197 | + if (isset($options['loading_text'])) { |
|
| 198 | + $js_options['loadingText'] = $options['loading_text']; |
|
| 199 | + } |
|
| 200 | + if (isset($options['rows'])) { |
|
| 201 | + $js_options['rows'] = $options['rows']; |
|
| 202 | + } |
|
| 203 | + if (isset($options['cols'])) { |
|
| 204 | + $js_options['cols'] = $options['cols']; |
|
| 205 | + } |
|
| 206 | + if (isset($options['size'])) { |
|
| 207 | + $js_options['size'] = $options['size']; |
|
| 208 | + } |
|
| 209 | + if (isset($options['external_control'])) { |
|
| 210 | + $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 211 | + } |
|
| 212 | + if (isset($options['load_text_url'])) { |
|
| 213 | + $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 214 | + } |
|
| 215 | + if (isset($options['options'])) { |
|
| 216 | + $js_options['ajaxOptions'] = $options['options']; |
|
| 217 | + } |
|
| 218 | + if (isset($options['script'])) { |
|
| 219 | + $js_options['evalScripts'] = $options['script']; |
|
| 220 | + } |
|
| 221 | + if (isset($options['with'])) { |
|
| 222 | + $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 226 | + if ($tag) { |
|
| 227 | + return $this->tag($function); |
|
| 228 | + } else { |
|
| 229 | + return $function; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @param $object |
|
| 235 | + * @param null $tag_options |
|
| 236 | + * @param null $in_place_editor_options |
|
| 237 | + * @return string |
|
| 238 | + */ |
|
| 239 | + public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 240 | + { |
|
| 241 | + $ret_val = ''; |
|
| 242 | + $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 243 | + $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 244 | + |
|
| 245 | + return $ret_val; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param $field_id |
|
| 250 | + * @param $options |
|
| 251 | + * @return mixed |
|
| 252 | + */ |
|
| 253 | + public function auto_complete_field($field_id, $options) |
|
| 254 | + { |
|
| 255 | + $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | + $function .= "'$field_id', "; |
|
| 257 | + $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | + $function .= "'" . $options['url'] . "'"; |
|
| 259 | + |
|
| 260 | + $js_options = []; |
|
| 261 | + if (isset($options['tokens'])) { |
|
| 262 | + $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 263 | + } |
|
| 264 | + if (isset($options['with'])) { |
|
| 265 | + $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 266 | + } |
|
| 267 | + if (isset($options['indicator'])) { |
|
| 268 | + $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 269 | + } |
|
| 270 | + if (isset($options['select'])) { |
|
| 271 | + $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
|
| 275 | + if (isset($options[$var])) { |
|
| 276 | + $js_options['$val'] = $options['var']; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 281 | + |
|
| 282 | + return $this->tag($function); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @param $entries |
|
| 287 | + * @param $field |
|
| 288 | + * @param null $phrase |
|
| 289 | + */ |
|
| 290 | + public function auto_complete_results($entries, $field, $phrase = null) |
|
| 291 | + { |
|
| 292 | + if (!is_array($entries)) { |
|
| 293 | + return; |
|
| 294 | + } |
|
| 295 | + $ret_val = '<ul>'; |
|
| 296 | + // Complete this function |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * @param $object |
|
| 301 | + * @param null $tag_options |
|
| 302 | + * @param null $completion_options |
|
| 303 | + * @return string |
|
| 304 | + */ |
|
| 305 | + public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 306 | + { |
|
| 307 | + $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 308 | + $ret_val .= '<input autocomplete="off" id="' |
|
| 309 | + . $object |
|
| 310 | + . '" name="' |
|
| 311 | + . $object |
|
| 312 | + . '" size="' |
|
| 313 | + . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 314 | + . '" type="text" value="' |
|
| 315 | + . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 316 | + . '" ' |
|
| 317 | + . (isset($tag_options['class']) ? 'class = "' |
|
| 318 | + . $tag_options['class'] |
|
| 319 | + . '" ' : '') |
|
| 320 | + . '>'; |
|
| 321 | + |
|
| 322 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 323 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 324 | + |
|
| 325 | + return $ret_val; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * @return string |
|
| 330 | + */ |
|
| 331 | + public function _auto_complete_stylesheet() |
|
| 332 | + { |
|
| 333 | + return '<style> div.auto_complete { |
|
| 334 | 334 | width: 350px; |
| 335 | 335 | background: #fff; |
| 336 | 336 | } |
@@ -354,5 +354,5 @@ discard block |
||
| 354 | 354 | padding:0; |
| 355 | 355 | } |
| 356 | 356 | </style>'; |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (in_array($name, $this->TOGGLE_EFFECTS)) { |
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 64 | + return "Effect.toggle($element,'".str_replace('toggle_', '', $name)."',".$this->_options_for_javascript($js_options).')'; |
|
| 65 | 65 | } else { |
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 66 | + return 'new Effect.'.ucwords($name)."($element,".$this->_options_for_javascript($js_options).')'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | //if (isset($option['onUpdate'])) |
| 98 | 98 | { |
| 99 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 99 | + $options['onUpdate'] = 'function(){'.$this->remote_function($options).'}'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | foreach ($options as $var => $val) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | foreach ($arr as $var) { |
| 111 | 111 | if (isset($options[$var])) { |
| 112 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 112 | + $options[$var] = "'".$options[$var]."'"; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 124 | + return "Sortable.create('$element_id',".$this->_options_for_javascript($options).')'; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function _dragable_element_js($element_id, $options) |
| 133 | 133 | { |
| 134 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 134 | + return 'new Draggable(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | //if (isset($option['onDrop'])) |
| 151 | 151 | { |
| 152 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 152 | + $options['onDrop'] = 'function(element){'.$this->remote_function($options).'}'; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if (is_array($options)) { |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (isset($options['hoverclass'])) { |
| 168 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 168 | + $options['hoverclass'] = "'".$options['hoverclass']."'"; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 171 | + return 'Droppables.add(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | ///////////////////////////////////////////////////////////////////////////////////// |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $function = 'new Ajax.InPlaceEditor('; |
| 187 | 187 | $function .= "'$field_id', "; |
| 188 | - $function .= "'" . $options['url'] . "'"; |
|
| 188 | + $function .= "'".$options['url']."'"; |
|
| 189 | 189 | |
| 190 | 190 | $js_options = []; |
| 191 | 191 | if (isset($options['cancel_text'])) { |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | $js_options['size'] = $options['size']; |
| 208 | 208 | } |
| 209 | 209 | if (isset($options['external_control'])) { |
| 210 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 210 | + $js_options['externalControl'] = "'".$options['external_control']."'"; |
|
| 211 | 211 | } |
| 212 | 212 | if (isset($options['load_text_url'])) { |
| 213 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 213 | + $js_options['loadTextURL'] = "'".$options['load_text_url']."'"; |
|
| 214 | 214 | } |
| 215 | 215 | if (isset($options['options'])) { |
| 216 | 216 | $js_options['ajaxOptions'] = $options['options']; |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | $js_options['evalScripts'] = $options['script']; |
| 220 | 220 | } |
| 221 | 221 | if (isset($options['with'])) { |
| 222 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 222 | + $js_options['callback'] = 'function(form) { return '.$options['with'].' }'; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 225 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 226 | 226 | if ($tag) { |
| 227 | 227 | return $this->tag($function); |
| 228 | 228 | } else { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
| 240 | 240 | { |
| 241 | 241 | $ret_val = ''; |
| 242 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 242 | + $ret_val .= '<span id="'.$object.'" class="in_place_editor_field">'.(isset($tag_options['value']) ? $tag_options['value'] : '').'</span>'; |
|
| 243 | 243 | $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
| 244 | 244 | |
| 245 | 245 | return $ret_val; |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function auto_complete_field($field_id, $options) |
| 254 | 254 | { |
| 255 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 255 | + $function = "var $field_id".'_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | 256 | $function .= "'$field_id', "; |
| 257 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | - $function .= "'" . $options['url'] . "'"; |
|
| 257 | + $function .= "'".(isset($options['update']) ? $options['update'] : $field_id.'_auto_complete')."', "; |
|
| 258 | + $function .= "'".$options['url']."'"; |
|
| 259 | 259 | |
| 260 | 260 | $js_options = []; |
| 261 | 261 | if (isset($options['tokens'])) { |
| 262 | 262 | $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
| 263 | 263 | } |
| 264 | 264 | if (isset($options['with'])) { |
| 265 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 265 | + $js_options['callback'] = 'function(element, value) { return '.$options['with'].' }'; |
|
| 266 | 266 | } |
| 267 | 267 | if (isset($options['indicator'])) { |
| 268 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 268 | + $js_options['indicator'] = "'".$options['indicator']."'"; |
|
| 269 | 269 | } |
| 270 | 270 | if (isset($options['select'])) { |
| 271 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 271 | + $js_options['select'] = "'".$options['select']."'"; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 280 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 281 | 281 | |
| 282 | 282 | return $this->tag($function); |
| 283 | 283 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | . '" ' : '') |
| 320 | 320 | . '>'; |
| 321 | 321 | |
| 322 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 322 | + $ret_val .= '<div id="'.$object.'_auto_complete" class="auto_complete"></div>'; |
|
| 323 | 323 | $ret_val .= $this->auto_complete_field($object, $completion_options); |
| 324 | 324 | |
| 325 | 325 | return $ret_val; |
@@ -2,5 +2,5 @@ |
||
| 2 | 2 | |
| 3 | 3 | function smarthook_footer_start() |
| 4 | 4 | { |
| 5 | - // code... |
|
| 5 | + // code... |
|
| 6 | 6 | } |
@@ -14,22 +14,22 @@ |
||
| 14 | 14 | * SmartObject library path |
| 15 | 15 | */ |
| 16 | 16 | if (!defined('SMARTOBJECT_URL')) { |
| 17 | - define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 17 | + define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 18 | 18 | } |
| 19 | 19 | if (!defined('SMARTOBJECT_ROOT_PATH')) { |
| 20 | - define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 20 | + define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 21 | 21 | } |
| 22 | 22 | if (!defined('SMARTOBJECT_IMAGES_URL')) { |
| 23 | - define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 23 | + define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 24 | 24 | } |
| 25 | 25 | if (!defined('SMARTOBJECT_IMAGES_ROOT_PATH')) { |
| 26 | - define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 26 | + define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 27 | 27 | } |
| 28 | 28 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_URL')) { |
| 29 | - define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 29 | + define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 30 | 30 | } |
| 31 | 31 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH')) { |
| 32 | - define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 32 | + define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | * SmartObject library path |
| 15 | 15 | */ |
| 16 | 16 | if (!defined('SMARTOBJECT_URL')) { |
| 17 | - define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 17 | + define('SMARTOBJECT_URL', XOOPS_URL.'/modules/smartobject/'); |
|
| 18 | 18 | } |
| 19 | 19 | if (!defined('SMARTOBJECT_ROOT_PATH')) { |
| 20 | - define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 20 | + define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/smartobject/'); |
|
| 21 | 21 | } |
| 22 | 22 | if (!defined('SMARTOBJECT_IMAGES_URL')) { |
| 23 | - define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 23 | + define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL.'assets/images/'); |
|
| 24 | 24 | } |
| 25 | 25 | if (!defined('SMARTOBJECT_IMAGES_ROOT_PATH')) { |
| 26 | - define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 26 | + define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH.'assets/images/'); |
|
| 27 | 27 | } |
| 28 | 28 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_URL')) { |
| 29 | - define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 29 | + define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL.'assets/images/actions/'); |
|
| 30 | 30 | } |
| 31 | 31 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH')) { |
| 32 | - define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 32 | + define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH.'assets/images/actions/'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Version of the SmartObject Framework |
| 37 | 37 | */ |
| 38 | -require_once SMARTOBJECT_ROOT_PATH . 'include/version.php'; |
|
| 39 | -require_once SMARTOBJECT_ROOT_PATH . 'include/functions.php'; |
|
| 40 | -require_once SMARTOBJECT_ROOT_PATH . 'include/xoops_core_common_functions.php'; |
|
| 38 | +require_once SMARTOBJECT_ROOT_PATH.'include/version.php'; |
|
| 39 | +require_once SMARTOBJECT_ROOT_PATH.'include/functions.php'; |
|
| 40 | +require_once SMARTOBJECT_ROOT_PATH.'include/xoops_core_common_functions.php'; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Some constants used by the SmartObjects |
@@ -66,4 +66,4 @@ discard block |
||
| 66 | 66 | // get previous page |
| 67 | 67 | $smart_previous_page = smart_getenv('HTTP_REFERER'); |
| 68 | 68 | |
| 69 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartloader.php'; |
|
| 69 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartloader.php'; |
|
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | $smartobjectCurrencyHandler = xoops_getModuleHandler('currency', 'smartobject'); |
| 18 | 18 | |
| 19 | 19 | if (!$smartobjectCurrenciesObj) { |
| 20 | - $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
| 20 | + $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
| 21 | 21 | } |
| 22 | 22 | if (!$smartobjectCurrenciesArray) { |
| 23 | - foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
| 24 | - if ($currencyObj->getVar('default_currency', 'e')) { |
|
| 25 | - $smartobjectDefaultCurrency = $currencyObj; |
|
| 26 | - } |
|
| 27 | - $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
| 28 | - } |
|
| 23 | + foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
| 24 | + if ($currencyObj->getVar('default_currency', 'e')) { |
|
| 25 | + $smartobjectDefaultCurrency = $currencyObj; |
|
| 26 | + } |
|
| 27 | + $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | smart_loadCommonLanguageFile(); |
| 12 | 12 | |
| 13 | -require_once SMARTOBJECT_ROOT_PATH . 'class/currency.php'; |
|
| 13 | +require_once SMARTOBJECT_ROOT_PATH.'class/currency.php'; |
|
| 14 | 14 | |
| 15 | 15 | static $smartobjectCurrenciesObj, $smartobjectCurrenciesArray, $smartobjectDefaultCurrency; |
| 16 | 16 | |
@@ -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 | { |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | function smart_get_css_link($cssfile) |
| 20 | 20 | { |
| 21 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 21 | + $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 22 | 22 | |
| 23 | - return $ret; |
|
| 23 | + return $ret; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function smart_get_page_before_form() |
| 30 | 30 | { |
| 31 | - global $smart_previous_page; |
|
| 31 | + global $smart_previous_page; |
|
| 32 | 32 | |
| 33 | - return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 33 | + return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -41,29 +41,29 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function smart_userIsAdmin($module = false) |
| 43 | 43 | { |
| 44 | - global $xoopsUser; |
|
| 45 | - static $smart_isAdmin; |
|
| 46 | - if (!$module) { |
|
| 47 | - global $xoopsModule; |
|
| 48 | - $module = $xoopsModule->getVar('dirname'); |
|
| 49 | - } |
|
| 50 | - if (isset($smart_isAdmin[$module])) { |
|
| 51 | - return $smart_isAdmin[$module]; |
|
| 52 | - } |
|
| 53 | - if (!$xoopsUser) { |
|
| 54 | - $smart_isAdmin[$module] = false; |
|
| 55 | - |
|
| 56 | - return $smart_isAdmin[$module]; |
|
| 57 | - } |
|
| 58 | - $smart_isAdmin[$module] = false; |
|
| 59 | - $smartModule = smart_getModuleInfo($module); |
|
| 60 | - if (!is_object($smartModule)) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - $module_id = $smartModule->getVar('mid'); |
|
| 64 | - $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 65 | - |
|
| 66 | - return $smart_isAdmin[$module]; |
|
| 44 | + global $xoopsUser; |
|
| 45 | + static $smart_isAdmin; |
|
| 46 | + if (!$module) { |
|
| 47 | + global $xoopsModule; |
|
| 48 | + $module = $xoopsModule->getVar('dirname'); |
|
| 49 | + } |
|
| 50 | + if (isset($smart_isAdmin[$module])) { |
|
| 51 | + return $smart_isAdmin[$module]; |
|
| 52 | + } |
|
| 53 | + if (!$xoopsUser) { |
|
| 54 | + $smart_isAdmin[$module] = false; |
|
| 55 | + |
|
| 56 | + return $smart_isAdmin[$module]; |
|
| 57 | + } |
|
| 58 | + $smart_isAdmin[$module] = false; |
|
| 59 | + $smartModule = smart_getModuleInfo($module); |
|
| 60 | + if (!is_object($smartModule)) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + $module_id = $smartModule->getVar('mid'); |
|
| 64 | + $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 65 | + |
|
| 66 | + return $smart_isAdmin[$module]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | function smart_isXoops22() |
| 73 | 73 | { |
| 74 | - $xoops22 = false; |
|
| 75 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 76 | - if ('2' == substr($xv, 2, 1)) { |
|
| 77 | - $xoops22 = true; |
|
| 78 | - } |
|
| 74 | + $xoops22 = false; |
|
| 75 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 76 | + if ('2' == substr($xv, 2, 1)) { |
|
| 77 | + $xoops22 = true; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return $xoops22; |
|
| 80 | + return $xoops22; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -88,36 +88,36 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) |
| 90 | 90 | { |
| 91 | - if (!$moduleName) { |
|
| 92 | - global $xoopsModule; |
|
| 93 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 94 | - } |
|
| 95 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 96 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 97 | - if (!isset($smartModule)) { |
|
| 98 | - return ''; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - if ($forBreadCrumb |
|
| 102 | - && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 103 | - && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 104 | - return ''; |
|
| 105 | - } |
|
| 106 | - if (!$withLink) { |
|
| 107 | - return $smartModule->getVar('name'); |
|
| 108 | - } else { |
|
| 109 | - $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 110 | - if ('rewrite' === $seoMode) { |
|
| 111 | - $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 112 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 113 | - } elseif ('pathinfo' === $seoMode) { |
|
| 114 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 115 | - } else { |
|
| 116 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 120 | - } |
|
| 91 | + if (!$moduleName) { |
|
| 92 | + global $xoopsModule; |
|
| 93 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 94 | + } |
|
| 95 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 96 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 97 | + if (!isset($smartModule)) { |
|
| 98 | + return ''; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + if ($forBreadCrumb |
|
| 102 | + && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 103 | + && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 104 | + return ''; |
|
| 105 | + } |
|
| 106 | + if (!$withLink) { |
|
| 107 | + return $smartModule->getVar('name'); |
|
| 108 | + } else { |
|
| 109 | + $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 110 | + if ('rewrite' === $seoMode) { |
|
| 111 | + $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 112 | + $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 113 | + } elseif ('pathinfo' === $seoMode) { |
|
| 114 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 115 | + } else { |
|
| 116 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 120 | + } |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | function smart_getModuleNameForSEO($moduleName = false) |
| 128 | 128 | { |
| 129 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 130 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 131 | - if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 132 | - return $smartModuleConfig['seo_module_name']; |
|
| 133 | - } |
|
| 134 | - $ret = smart_getModuleName(false, false, $moduleName); |
|
| 135 | - |
|
| 136 | - return strtolower($ret); |
|
| 129 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 130 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 131 | + if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 132 | + return $smartModuleConfig['seo_module_name']; |
|
| 133 | + } |
|
| 134 | + $ret = smart_getModuleName(false, false, $moduleName); |
|
| 135 | + |
|
| 136 | + return strtolower($ret); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function smart_getModuleModeSEO($moduleName = false) |
| 144 | 144 | { |
| 145 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 146 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 145 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 146 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 147 | 147 | |
| 148 | - return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 148 | + return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -154,10 +154,10 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | function smart_getModuleIncludeIdSEO($moduleName = false) |
| 156 | 156 | { |
| 157 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 158 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 157 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 158 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 159 | 159 | |
| 160 | - return !empty($smartModuleConfig['seo_inc_id']); |
|
| 160 | + return !empty($smartModuleConfig['seo_inc_id']); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -166,22 +166,22 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function smart_getenv($key) |
| 168 | 168 | { |
| 169 | - $ret = ''; |
|
| 170 | - $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 169 | + $ret = ''; |
|
| 170 | + $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 171 | 171 | |
| 172 | - return $ret; |
|
| 172 | + return $ret; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | function smart_xoops_cp_header() |
| 176 | 176 | { |
| 177 | - xoops_cp_header(); |
|
| 178 | - global $xoopsModule, $xoopsConfig; |
|
| 179 | - /** |
|
| 180 | - * include SmartObject admin language file |
|
| 181 | - */ |
|
| 182 | - /** @var Smartobject\Helper $helper */ |
|
| 183 | - $helper = Smartobject\Helper::getInstance(); |
|
| 184 | - $helper->loadLanguage('admin'); ?> |
|
| 177 | + xoops_cp_header(); |
|
| 178 | + global $xoopsModule, $xoopsConfig; |
|
| 179 | + /** |
|
| 180 | + * include SmartObject admin language file |
|
| 181 | + */ |
|
| 182 | + /** @var Smartobject\Helper $helper */ |
|
| 183 | + $helper = Smartobject\Helper::getInstance(); |
|
| 184 | + $helper->loadLanguage('admin'); ?> |
|
| 185 | 185 | |
| 186 | 186 | <script type='text/javascript'> |
| 187 | 187 | <!-- |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script> |
| 196 | 196 | <?php |
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Include the admin language constants for the SmartObject Framework |
|
| 200 | - */ |
|
| 201 | - /** @var Smartobject\Helper $helper */ |
|
| 202 | - $helper = Smartobject\Helper::getInstance(); |
|
| 203 | - $helper->loadLanguage('admin'); |
|
| 198 | + /** |
|
| 199 | + * Include the admin language constants for the SmartObject Framework |
|
| 200 | + */ |
|
| 201 | + /** @var Smartobject\Helper $helper */ |
|
| 202 | + $helper = Smartobject\Helper::getInstance(); |
|
| 203 | + $helper->loadLanguage('admin'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -214,21 +214,21 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function smart_TableExists($table) |
| 216 | 216 | { |
| 217 | - $bRetVal = false; |
|
| 218 | - //Verifies that a MySQL table exists |
|
| 219 | - $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 220 | - $realname = $xoopsDB->prefix($table); |
|
| 221 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 222 | - $ret = $xoopsDB->queryF($sql); |
|
| 223 | - while (false !== (list($m_table) = $xoopsDB->fetchRow($ret))) { |
|
| 224 | - if ($m_table == $realname) { |
|
| 225 | - $bRetVal = true; |
|
| 226 | - break; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - $xoopsDB->freeRecordSet($ret); |
|
| 230 | - |
|
| 231 | - return $bRetVal; |
|
| 217 | + $bRetVal = false; |
|
| 218 | + //Verifies that a MySQL table exists |
|
| 219 | + $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 220 | + $realname = $xoopsDB->prefix($table); |
|
| 221 | + $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 222 | + $ret = $xoopsDB->queryF($sql); |
|
| 223 | + while (false !== (list($m_table) = $xoopsDB->fetchRow($ret))) { |
|
| 224 | + if ($m_table == $realname) { |
|
| 225 | + $bRetVal = true; |
|
| 226 | + break; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + $xoopsDB->freeRecordSet($ret); |
|
| 230 | + |
|
| 231 | + return $bRetVal; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -243,19 +243,19 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function smart_GetMeta($key, $moduleName = false) |
| 245 | 245 | { |
| 246 | - if (!$moduleName) { |
|
| 247 | - $moduleName = smart_getCurrentModuleName(); |
|
| 248 | - } |
|
| 249 | - $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 250 | - $sql = sprintf('SELECT metavalue FROM `%s` WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 251 | - $ret = $xoopsDB->query($sql); |
|
| 252 | - if (!$ret) { |
|
| 253 | - $value = false; |
|
| 254 | - } else { |
|
| 255 | - list($value) = $xoopsDB->fetchRow($ret); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return $value; |
|
| 246 | + if (!$moduleName) { |
|
| 247 | + $moduleName = smart_getCurrentModuleName(); |
|
| 248 | + } |
|
| 249 | + $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 250 | + $sql = sprintf('SELECT metavalue FROM `%s` WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 251 | + $ret = $xoopsDB->query($sql); |
|
| 252 | + if (!$ret) { |
|
| 253 | + $value = false; |
|
| 254 | + } else { |
|
| 255 | + list($value) = $xoopsDB->fetchRow($ret); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return $value; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | function smart_getCurrentModuleName() |
| 265 | 265 | { |
| 266 | - global $xoopsModule; |
|
| 267 | - if (is_object($xoopsModule)) { |
|
| 268 | - return $xoopsModule->getVar('dirname'); |
|
| 269 | - } else { |
|
| 270 | - return false; |
|
| 271 | - } |
|
| 266 | + global $xoopsModule; |
|
| 267 | + if (is_object($xoopsModule)) { |
|
| 268 | + return $xoopsModule->getVar('dirname'); |
|
| 269 | + } else { |
|
| 270 | + return false; |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -284,22 +284,22 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function smart_SetMeta($key, $value, $moduleName = false) |
| 286 | 286 | { |
| 287 | - if (!$moduleName) { |
|
| 288 | - $moduleName = smart_getCurrentModuleName(); |
|
| 289 | - } |
|
| 290 | - $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 291 | - $ret = smart_GetMeta($key, $moduleName); |
|
| 292 | - if ('0' === $ret || $ret > 0) { |
|
| 293 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 294 | - } else { |
|
| 295 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 296 | - } |
|
| 297 | - $ret = $xoopsDB->queryF($sql); |
|
| 298 | - if (!$ret) { |
|
| 299 | - return false; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - return true; |
|
| 287 | + if (!$moduleName) { |
|
| 288 | + $moduleName = smart_getCurrentModuleName(); |
|
| 289 | + } |
|
| 290 | + $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 291 | + $ret = smart_GetMeta($key, $moduleName); |
|
| 292 | + if ('0' === $ret || $ret > 0) { |
|
| 293 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 294 | + } else { |
|
| 295 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 296 | + } |
|
| 297 | + $ret = $xoopsDB->queryF($sql); |
|
| 298 | + if (!$ret) { |
|
| 299 | + return false; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + return true; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Thanks to Mithrandir:-) |
@@ -312,20 +312,20 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function smart_substr($str, $start, $length, $trimmarker = '...') |
| 314 | 314 | { |
| 315 | - // if the string is empty, let's get out ;-) |
|
| 316 | - if ('' === $str) { |
|
| 317 | - return $str; |
|
| 318 | - } |
|
| 319 | - // reverse a string that is shortened with '' as trimmarker |
|
| 320 | - $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 321 | - // find first space in reversed string |
|
| 322 | - $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 323 | - // truncate the original string to a length of $length |
|
| 324 | - // minus the position of the last space |
|
| 325 | - // plus the length of the $trimmarker |
|
| 326 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 327 | - |
|
| 328 | - return $truncated_string; |
|
| 315 | + // if the string is empty, let's get out ;-) |
|
| 316 | + if ('' === $str) { |
|
| 317 | + return $str; |
|
| 318 | + } |
|
| 319 | + // reverse a string that is shortened with '' as trimmarker |
|
| 320 | + $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 321 | + // find first space in reversed string |
|
| 322 | + $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 323 | + // truncate the original string to a length of $length |
|
| 324 | + // minus the position of the last space |
|
| 325 | + // plus the length of the $trimmarker |
|
| 326 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 327 | + |
|
| 328 | + return $truncated_string; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -336,19 +336,19 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') |
| 338 | 338 | { |
| 339 | - if (!$moduleName) { |
|
| 340 | - $moduleName = smart_getCurrentModuleName(); |
|
| 341 | - } |
|
| 342 | - $configs = smart_getModuleConfig($moduleName); |
|
| 343 | - if (isset($configs[$key])) { |
|
| 344 | - return $configs[$key]; |
|
| 345 | - } else { |
|
| 346 | - if ('default_is_undefined' === $default) { |
|
| 347 | - return null; |
|
| 348 | - } else { |
|
| 349 | - return $default; |
|
| 350 | - } |
|
| 351 | - } |
|
| 339 | + if (!$moduleName) { |
|
| 340 | + $moduleName = smart_getCurrentModuleName(); |
|
| 341 | + } |
|
| 342 | + $configs = smart_getModuleConfig($moduleName); |
|
| 343 | + if (isset($configs[$key])) { |
|
| 344 | + return $configs[$key]; |
|
| 345 | + } else { |
|
| 346 | + if ('default_is_undefined' === $default) { |
|
| 347 | + return null; |
|
| 348 | + } else { |
|
| 349 | + return $default; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -361,32 +361,32 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | function smart_copyr($source, $dest) |
| 363 | 363 | { |
| 364 | - // Simple copy for a file |
|
| 365 | - if (is_file($source)) { |
|
| 366 | - return copy($source, $dest); |
|
| 367 | - } |
|
| 368 | - // Make destination directory |
|
| 369 | - if (!is_dir($dest)) { |
|
| 370 | - mkdir($dest); |
|
| 371 | - } |
|
| 372 | - // Loop through the folder |
|
| 373 | - $dir = dir($source); |
|
| 374 | - while (false !== $entry = $dir->read()) { |
|
| 375 | - // Skip pointers |
|
| 376 | - if ('.' === $entry || '..' === $entry) { |
|
| 377 | - continue; |
|
| 378 | - } |
|
| 379 | - // Deep copy directories |
|
| 380 | - if (is_dir("$source/$entry") && ("$source/$entry" !== $dest)) { |
|
| 381 | - copyr("$source/$entry", "$dest/$entry"); |
|
| 382 | - } else { |
|
| 383 | - copy("$source/$entry", "$dest/$entry"); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - // Clean up |
|
| 387 | - $dir->close(); |
|
| 388 | - |
|
| 389 | - return true; |
|
| 364 | + // Simple copy for a file |
|
| 365 | + if (is_file($source)) { |
|
| 366 | + return copy($source, $dest); |
|
| 367 | + } |
|
| 368 | + // Make destination directory |
|
| 369 | + if (!is_dir($dest)) { |
|
| 370 | + mkdir($dest); |
|
| 371 | + } |
|
| 372 | + // Loop through the folder |
|
| 373 | + $dir = dir($source); |
|
| 374 | + while (false !== $entry = $dir->read()) { |
|
| 375 | + // Skip pointers |
|
| 376 | + if ('.' === $entry || '..' === $entry) { |
|
| 377 | + continue; |
|
| 378 | + } |
|
| 379 | + // Deep copy directories |
|
| 380 | + if (is_dir("$source/$entry") && ("$source/$entry" !== $dest)) { |
|
| 381 | + copyr("$source/$entry", "$dest/$entry"); |
|
| 382 | + } else { |
|
| 383 | + copy("$source/$entry", "$dest/$entry"); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + // Clean up |
|
| 387 | + $dir->close(); |
|
| 388 | + |
|
| 389 | + return true; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -396,26 +396,26 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | function smart_admin_mkdir($target) |
| 398 | 398 | { |
| 399 | - // http://www.php.net/manual/en/function.mkdir.php |
|
| 400 | - // saint at corenova.com |
|
| 401 | - // bart at cdasites dot com |
|
| 402 | - if (is_dir($target) || empty($target)) { |
|
| 403 | - return true; // best case check first |
|
| 404 | - } |
|
| 405 | - if (file_exists($target) && !is_dir($target)) { |
|
| 406 | - return false; |
|
| 407 | - } |
|
| 408 | - if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 409 | - if (!file_exists($target)) { |
|
| 410 | - $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 411 | - smart_admin_chmod($target); |
|
| 412 | - |
|
| 413 | - return $res; |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - $res = is_dir($target); |
|
| 417 | - |
|
| 418 | - return $res; |
|
| 399 | + // http://www.php.net/manual/en/function.mkdir.php |
|
| 400 | + // saint at corenova.com |
|
| 401 | + // bart at cdasites dot com |
|
| 402 | + if (is_dir($target) || empty($target)) { |
|
| 403 | + return true; // best case check first |
|
| 404 | + } |
|
| 405 | + if (file_exists($target) && !is_dir($target)) { |
|
| 406 | + return false; |
|
| 407 | + } |
|
| 408 | + if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 409 | + if (!file_exists($target)) { |
|
| 410 | + $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 411 | + smart_admin_chmod($target); |
|
| 412 | + |
|
| 413 | + return $res; |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + $res = is_dir($target); |
|
| 417 | + |
|
| 418 | + return $res; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | */ |
| 427 | 427 | function smart_admin_chmod($target, $mode = 0777) |
| 428 | 428 | { |
| 429 | - return @ chmod($target, $mode); |
|
| 429 | + return @ chmod($target, $mode); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -437,31 +437,31 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | function smart_imageResize($src, $maxWidth, $maxHeight) |
| 439 | 439 | { |
| 440 | - $width = ''; |
|
| 441 | - $height = ''; |
|
| 442 | - $type = ''; |
|
| 443 | - $attr = ''; |
|
| 444 | - if (file_exists($src)) { |
|
| 445 | - list($width, $height, $type, $attr) = getimagesize($src); |
|
| 446 | - if ($width > $maxWidth) { |
|
| 447 | - $originalWidth = $width; |
|
| 448 | - $width = $maxWidth; |
|
| 449 | - $height = $width * $height / $originalWidth; |
|
| 450 | - } |
|
| 451 | - if ($height > $maxHeight) { |
|
| 452 | - $originalHeight = $height; |
|
| 453 | - $height = $maxHeight; |
|
| 454 | - $width = $height * $width / $originalHeight; |
|
| 455 | - } |
|
| 456 | - $attr = " width='$width' height='$height'"; |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - return [ |
|
| 460 | - $width, |
|
| 461 | - $height, |
|
| 462 | - $type, |
|
| 463 | - $attr |
|
| 464 | - ]; |
|
| 440 | + $width = ''; |
|
| 441 | + $height = ''; |
|
| 442 | + $type = ''; |
|
| 443 | + $attr = ''; |
|
| 444 | + if (file_exists($src)) { |
|
| 445 | + list($width, $height, $type, $attr) = getimagesize($src); |
|
| 446 | + if ($width > $maxWidth) { |
|
| 447 | + $originalWidth = $width; |
|
| 448 | + $width = $maxWidth; |
|
| 449 | + $height = $width * $height / $originalWidth; |
|
| 450 | + } |
|
| 451 | + if ($height > $maxHeight) { |
|
| 452 | + $originalHeight = $height; |
|
| 453 | + $height = $maxHeight; |
|
| 454 | + $width = $height * $width / $originalHeight; |
|
| 455 | + } |
|
| 456 | + $attr = " width='$width' height='$height'"; |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + return [ |
|
| 460 | + $width, |
|
| 461 | + $height, |
|
| 462 | + $type, |
|
| 463 | + $attr |
|
| 464 | + ]; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -470,34 +470,34 @@ discard block |
||
| 470 | 470 | */ |
| 471 | 471 | function smart_getModuleInfo($moduleName = false) |
| 472 | 472 | { |
| 473 | - static $smartModules; |
|
| 474 | - if (isset($smartModules[$moduleName])) { |
|
| 475 | - $ret =& $smartModules[$moduleName]; |
|
| 476 | - |
|
| 477 | - return $ret; |
|
| 478 | - } |
|
| 479 | - global $xoopsModule; |
|
| 480 | - if (!$moduleName) { |
|
| 481 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 482 | - $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 483 | - |
|
| 484 | - return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - if (!isset($smartModules[$moduleName])) { |
|
| 488 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 489 | - $smartModules[$moduleName] = $xoopsModule; |
|
| 490 | - } else { |
|
| 491 | - $hModule = xoops_getHandler('module'); |
|
| 492 | - if ('xoops' !== $moduleName) { |
|
| 493 | - $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 494 | - } else { |
|
| 495 | - $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - return $smartModules[$moduleName]; |
|
| 473 | + static $smartModules; |
|
| 474 | + if (isset($smartModules[$moduleName])) { |
|
| 475 | + $ret =& $smartModules[$moduleName]; |
|
| 476 | + |
|
| 477 | + return $ret; |
|
| 478 | + } |
|
| 479 | + global $xoopsModule; |
|
| 480 | + if (!$moduleName) { |
|
| 481 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 482 | + $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 483 | + |
|
| 484 | + return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + if (!isset($smartModules[$moduleName])) { |
|
| 488 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 489 | + $smartModules[$moduleName] = $xoopsModule; |
|
| 490 | + } else { |
|
| 491 | + $hModule = xoops_getHandler('module'); |
|
| 492 | + if ('xoops' !== $moduleName) { |
|
| 493 | + $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 494 | + } else { |
|
| 495 | + $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + return $smartModules[$moduleName]; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -506,40 +506,40 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | function smart_getModuleConfig($moduleName = false) |
| 508 | 508 | { |
| 509 | - static $smartConfigs; |
|
| 510 | - if (isset($smartConfigs[$moduleName])) { |
|
| 511 | - $ret =& $smartConfigs[$moduleName]; |
|
| 512 | - |
|
| 513 | - return $ret; |
|
| 514 | - } |
|
| 515 | - global $xoopsModule, $xoopsModuleConfig; |
|
| 516 | - if (!$moduleName) { |
|
| 517 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 518 | - $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 519 | - |
|
| 520 | - return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - // if we still did not found the xoopsModule, this is because there is none |
|
| 524 | - if (!$moduleName) { |
|
| 525 | - $ret = false; |
|
| 526 | - |
|
| 527 | - return $ret; |
|
| 528 | - } |
|
| 529 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 530 | - $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 531 | - } else { |
|
| 532 | - $module = smart_getModuleInfo($moduleName); |
|
| 533 | - if (!is_object($module)) { |
|
| 534 | - $ret = false; |
|
| 535 | - |
|
| 536 | - return $ret; |
|
| 537 | - } |
|
| 538 | - $hModConfig = xoops_getHandler('config'); |
|
| 539 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - return $smartConfigs[$moduleName]; |
|
| 509 | + static $smartConfigs; |
|
| 510 | + if (isset($smartConfigs[$moduleName])) { |
|
| 511 | + $ret =& $smartConfigs[$moduleName]; |
|
| 512 | + |
|
| 513 | + return $ret; |
|
| 514 | + } |
|
| 515 | + global $xoopsModule, $xoopsModuleConfig; |
|
| 516 | + if (!$moduleName) { |
|
| 517 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 518 | + $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 519 | + |
|
| 520 | + return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + // if we still did not found the xoopsModule, this is because there is none |
|
| 524 | + if (!$moduleName) { |
|
| 525 | + $ret = false; |
|
| 526 | + |
|
| 527 | + return $ret; |
|
| 528 | + } |
|
| 529 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 530 | + $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 531 | + } else { |
|
| 532 | + $module = smart_getModuleInfo($moduleName); |
|
| 533 | + if (!is_object($module)) { |
|
| 534 | + $ret = false; |
|
| 535 | + |
|
| 536 | + return $ret; |
|
| 537 | + } |
|
| 538 | + $hModConfig = xoops_getHandler('config'); |
|
| 539 | + $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + return $smartConfigs[$moduleName]; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | function smart_deleteFile($dirname) |
| 550 | 550 | { |
| 551 | - // Simple delete for a file |
|
| 552 | - if (is_file($dirname)) { |
|
| 553 | - return unlink($dirname); |
|
| 554 | - } |
|
| 551 | + // Simple delete for a file |
|
| 552 | + if (is_file($dirname)) { |
|
| 553 | + return unlink($dirname); |
|
| 554 | + } |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |
@@ -560,12 +560,12 @@ discard block |
||
| 560 | 560 | */ |
| 561 | 561 | function smart_formatErrors($errors = []) |
| 562 | 562 | { |
| 563 | - $ret = ''; |
|
| 564 | - foreach ($errors as $key => $value) { |
|
| 565 | - $ret .= '<br> - ' . $value; |
|
| 566 | - } |
|
| 563 | + $ret = ''; |
|
| 564 | + foreach ($errors as $key => $value) { |
|
| 565 | + $ret .= '<br> - ' . $value; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - return $ret; |
|
| 568 | + return $ret; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -579,46 +579,46 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = [], $withContact = false) |
| 581 | 581 | { |
| 582 | - if (!is_numeric($userid)) { |
|
| 583 | - return $userid; |
|
| 584 | - } |
|
| 585 | - $userid = (int)$userid; |
|
| 586 | - if ($userid > 0) { |
|
| 587 | - if ($users == []) { |
|
| 588 | - //fetching users |
|
| 589 | - $memberHandler = xoops_getHandler('member'); |
|
| 590 | - $user =& $memberHandler->getUser($userid); |
|
| 591 | - } else { |
|
| 592 | - if (!isset($users[$userid])) { |
|
| 593 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 594 | - } |
|
| 595 | - $user =& $users[$userid]; |
|
| 596 | - } |
|
| 597 | - if (is_object($user)) { |
|
| 598 | - $ts = MyTextSanitizer:: getInstance(); |
|
| 599 | - $username = $user->getVar('uname'); |
|
| 600 | - $fullname = ''; |
|
| 601 | - $fullname2 = $user->getVar('name'); |
|
| 602 | - if ($name && !empty($fullname2)) { |
|
| 603 | - $fullname = $user->getVar('name'); |
|
| 604 | - } |
|
| 605 | - if (!empty($fullname)) { |
|
| 606 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 607 | - } else { |
|
| 608 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 609 | - } |
|
| 610 | - // add contact info: email + PM |
|
| 611 | - if ($withContact) { |
|
| 612 | - $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>'; |
|
| 613 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 614 | - $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>'; |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return $linkeduser; |
|
| 618 | - } |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 582 | + if (!is_numeric($userid)) { |
|
| 583 | + return $userid; |
|
| 584 | + } |
|
| 585 | + $userid = (int)$userid; |
|
| 586 | + if ($userid > 0) { |
|
| 587 | + if ($users == []) { |
|
| 588 | + //fetching users |
|
| 589 | + $memberHandler = xoops_getHandler('member'); |
|
| 590 | + $user =& $memberHandler->getUser($userid); |
|
| 591 | + } else { |
|
| 592 | + if (!isset($users[$userid])) { |
|
| 593 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 594 | + } |
|
| 595 | + $user =& $users[$userid]; |
|
| 596 | + } |
|
| 597 | + if (is_object($user)) { |
|
| 598 | + $ts = MyTextSanitizer:: getInstance(); |
|
| 599 | + $username = $user->getVar('uname'); |
|
| 600 | + $fullname = ''; |
|
| 601 | + $fullname2 = $user->getVar('name'); |
|
| 602 | + if ($name && !empty($fullname2)) { |
|
| 603 | + $fullname = $user->getVar('name'); |
|
| 604 | + } |
|
| 605 | + if (!empty($fullname)) { |
|
| 606 | + $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 607 | + } else { |
|
| 608 | + $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 609 | + } |
|
| 610 | + // add contact info: email + PM |
|
| 611 | + if ($withContact) { |
|
| 612 | + $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>'; |
|
| 613 | + $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 614 | + $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>'; |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return $linkeduser; |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
@@ -629,29 +629,29 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
| 631 | 631 | { |
| 632 | - global $xoopsModule, $xoopsConfig; |
|
| 633 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 634 | - |
|
| 635 | - |
|
| 636 | - /** @var Smartobject\Helper $helper */ |
|
| 637 | - $helper = Smartobject\Helper::getInstance(); |
|
| 638 | - $helper->loadLanguage('admin'); |
|
| 639 | - $helper->loadLanguage('modinfo'); |
|
| 640 | - $headermenu = []; |
|
| 641 | - $adminObject = []; |
|
| 642 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 643 | - $tpl = new \XoopsTpl(); |
|
| 644 | - $tpl->assign([ |
|
| 645 | - 'headermenu' => $headermenu, |
|
| 646 | - 'adminmenu' => $adminObject, |
|
| 647 | - 'current' => $currentoption, |
|
| 648 | - 'breadcrumb' => $breadcrumb, |
|
| 649 | - 'headermenucount' => count($headermenu), |
|
| 650 | - 'submenus' => $submenus, |
|
| 651 | - 'currentsub' => $currentsub, |
|
| 652 | - 'submenuscount' => count($submenus) |
|
| 653 | - ]); |
|
| 654 | - $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 632 | + global $xoopsModule, $xoopsConfig; |
|
| 633 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 634 | + |
|
| 635 | + |
|
| 636 | + /** @var Smartobject\Helper $helper */ |
|
| 637 | + $helper = Smartobject\Helper::getInstance(); |
|
| 638 | + $helper->loadLanguage('admin'); |
|
| 639 | + $helper->loadLanguage('modinfo'); |
|
| 640 | + $headermenu = []; |
|
| 641 | + $adminObject = []; |
|
| 642 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 643 | + $tpl = new \XoopsTpl(); |
|
| 644 | + $tpl->assign([ |
|
| 645 | + 'headermenu' => $headermenu, |
|
| 646 | + 'adminmenu' => $adminObject, |
|
| 647 | + 'current' => $currentoption, |
|
| 648 | + 'breadcrumb' => $breadcrumb, |
|
| 649 | + 'headermenucount' => count($headermenu), |
|
| 650 | + 'submenus' => $submenus, |
|
| 651 | + 'currentsub' => $currentsub, |
|
| 652 | + 'submenuscount' => count($submenus) |
|
| 653 | + ]); |
|
| 654 | + $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | */ |
| 662 | 662 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
| 663 | 663 | { |
| 664 | - global $xoopsModule; |
|
| 665 | - 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')\";>"; |
|
| 666 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 667 | - echo "<div id='" . $id . "'>"; |
|
| 668 | - if ('' !== $dsc) { |
|
| 669 | - echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 670 | - } |
|
| 664 | + global $xoopsModule; |
|
| 665 | + 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')\";>"; |
|
| 666 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 667 | + echo "<div id='" . $id . "'>"; |
|
| 668 | + if ('' !== $dsc) { |
|
| 669 | + echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 670 | + } |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
@@ -677,15 +677,15 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '') |
| 679 | 679 | { |
| 680 | - global $xoopsModule; |
|
| 681 | - $onClick = "ajaxtogglecollapse('$id')"; |
|
| 682 | - //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 683 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 684 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 685 | - echo "<div id='" . $id . "'>"; |
|
| 686 | - if ('' !== $dsc) { |
|
| 687 | - echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 688 | - } |
|
| 680 | + global $xoopsModule; |
|
| 681 | + $onClick = "ajaxtogglecollapse('$id')"; |
|
| 682 | + //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 683 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 684 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 685 | + echo "<div id='" . $id . "'>"; |
|
| 686 | + if ('' !== $dsc) { |
|
| 687 | + echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 688 | + } |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -712,20 +712,20 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | function smart_openclose_collapsable($name) |
| 714 | 714 | { |
| 715 | - $urls = smart_getCurrentUrls(); |
|
| 716 | - $path = $urls['phpself']; |
|
| 717 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 718 | - $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 719 | - $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 720 | - if ('none' === $cookie) { |
|
| 721 | - echo ' |
|
| 715 | + $urls = smart_getCurrentUrls(); |
|
| 716 | + $path = $urls['phpself']; |
|
| 717 | + $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 718 | + $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 719 | + $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 720 | + if ('none' === $cookie) { |
|
| 721 | + echo ' |
|
| 722 | 722 | <script type="text/javascript"><!-- |
| 723 | 723 | togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
| 724 | 724 | //--> |
| 725 | 725 | </script> |
| 726 | 726 | '; |
| 727 | - } |
|
| 728 | - /* if ($cookie == 'none') { |
|
| 727 | + } |
|
| 728 | + /* if ($cookie == 'none') { |
|
| 729 | 729 | echo ' |
| 730 | 730 | <script type="text/javascript"><!-- |
| 731 | 731 | hideElement("' . $name . '"); |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | */ |
| 742 | 742 | function smart_close_collapsable($name) |
| 743 | 743 | { |
| 744 | - echo '</div>'; |
|
| 745 | - smart_openclose_collapsable($name); |
|
| 746 | - echo '<br>'; |
|
| 744 | + echo '</div>'; |
|
| 745 | + smart_openclose_collapsable($name); |
|
| 746 | + echo '<br>'; |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -753,11 +753,11 @@ discard block |
||
| 753 | 753 | */ |
| 754 | 754 | function smart_setCookieVar($name, $value, $time = 0) |
| 755 | 755 | { |
| 756 | - if (0 == $time) { |
|
| 757 | - $time = time() + 3600 * 24 * 365; |
|
| 758 | - //$time = ''; |
|
| 759 | - } |
|
| 760 | - setcookie($name, $value, $time, '/'); |
|
| 756 | + if (0 == $time) { |
|
| 757 | + $time = time() + 3600 * 24 * 365; |
|
| 758 | + //$time = ''; |
|
| 759 | + } |
|
| 760 | + setcookie($name, $value, $time, '/'); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
@@ -767,12 +767,12 @@ discard block |
||
| 767 | 767 | */ |
| 768 | 768 | function smart_getCookieVar($name, $default = '') |
| 769 | 769 | { |
| 770 | - $name = str_replace('.', '_', $name); |
|
| 771 | - if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 772 | - return $_COOKIE[$name]; |
|
| 773 | - } else { |
|
| 774 | - return $default; |
|
| 775 | - } |
|
| 770 | + $name = str_replace('.', '_', $name); |
|
| 771 | + if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 772 | + return $_COOKIE[$name]; |
|
| 773 | + } else { |
|
| 774 | + return $default; |
|
| 775 | + } |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
@@ -780,25 +780,25 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | function smart_getCurrentUrls() |
| 782 | 782 | { |
| 783 | - $urls = []; |
|
| 784 | - $http = (false === strpos(XOOPS_URL, 'https://')) ? 'http://' : 'https://'; |
|
| 785 | - $phpself = $_SERVER['PHP_SELF']; |
|
| 786 | - $httphost = $_SERVER['HTTP_HOST']; |
|
| 787 | - $querystring = $_SERVER['QUERY_STRING']; |
|
| 788 | - if ('' !== $querystring) { |
|
| 789 | - $querystring = '?' . $querystring; |
|
| 790 | - } |
|
| 791 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 792 | - $urls = []; |
|
| 793 | - $urls['http'] = $http; |
|
| 794 | - $urls['httphost'] = $httphost; |
|
| 795 | - $urls['phpself'] = $phpself; |
|
| 796 | - $urls['querystring'] = $querystring; |
|
| 797 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 798 | - $urls['full'] = $currenturl; |
|
| 799 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 800 | - |
|
| 801 | - return $urls; |
|
| 783 | + $urls = []; |
|
| 784 | + $http = (false === strpos(XOOPS_URL, 'https://')) ? 'http://' : 'https://'; |
|
| 785 | + $phpself = $_SERVER['PHP_SELF']; |
|
| 786 | + $httphost = $_SERVER['HTTP_HOST']; |
|
| 787 | + $querystring = $_SERVER['QUERY_STRING']; |
|
| 788 | + if ('' !== $querystring) { |
|
| 789 | + $querystring = '?' . $querystring; |
|
| 790 | + } |
|
| 791 | + $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 792 | + $urls = []; |
|
| 793 | + $urls['http'] = $http; |
|
| 794 | + $urls['httphost'] = $httphost; |
|
| 795 | + $urls['phpself'] = $phpself; |
|
| 796 | + $urls['querystring'] = $querystring; |
|
| 797 | + $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 798 | + $urls['full'] = $currenturl; |
|
| 799 | + $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 800 | + |
|
| 801 | + return $urls; |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
@@ -806,9 +806,9 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | function smart_getCurrentPage() |
| 808 | 808 | { |
| 809 | - $urls = smart_getCurrentUrls(); |
|
| 809 | + $urls = smart_getCurrentUrls(); |
|
| 810 | 810 | |
| 811 | - return $urls['full']; |
|
| 811 | + return $urls['full']; |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | /** |
@@ -871,29 +871,29 @@ discard block |
||
| 871 | 871 | */ |
| 872 | 872 | function smart_modFooter() |
| 873 | 873 | { |
| 874 | - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 875 | - |
|
| 876 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 877 | - $tpl = new \XoopsTpl(); |
|
| 878 | - |
|
| 879 | - $hModule = xoops_getHandler('module'); |
|
| 880 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 881 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 882 | - $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>"; |
|
| 883 | - $tpl->assign('modfooter', $modfooter); |
|
| 884 | - |
|
| 885 | - if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 886 | - define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 887 | - } |
|
| 888 | - $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 889 | - $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 890 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 874 | + global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 875 | + |
|
| 876 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 877 | + $tpl = new \XoopsTpl(); |
|
| 878 | + |
|
| 879 | + $hModule = xoops_getHandler('module'); |
|
| 880 | + $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 881 | + $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 882 | + $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>"; |
|
| 883 | + $tpl->assign('modfooter', $modfooter); |
|
| 884 | + |
|
| 885 | + if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 886 | + define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 887 | + } |
|
| 888 | + $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 889 | + $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 890 | + $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | function smart_xoops_cp_footer() |
| 894 | 894 | { |
| 895 | - smart_modFooter(); |
|
| 896 | - xoops_cp_footer(); |
|
| 895 | + smart_modFooter(); |
|
| 896 | + xoops_cp_footer(); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | /** |
@@ -902,11 +902,11 @@ discard block |
||
| 902 | 902 | */ |
| 903 | 903 | function smart_sanitizeForCommonTags($text) |
| 904 | 904 | { |
| 905 | - global $xoopsConfig; |
|
| 906 | - $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 907 | - $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 905 | + global $xoopsConfig; |
|
| 906 | + $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 907 | + $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 908 | 908 | |
| 909 | - return $text; |
|
| 909 | + return $text; |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | function smart_addScript($src) |
| 916 | 916 | { |
| 917 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 917 | + echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -922,17 +922,17 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | function smart_addStyle($src) |
| 924 | 924 | { |
| 925 | - if ('smartobject' === $src) { |
|
| 926 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 927 | - } |
|
| 928 | - echo smart_get_css_link($src); |
|
| 925 | + if ('smartobject' === $src) { |
|
| 926 | + $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 927 | + } |
|
| 928 | + echo smart_get_css_link($src); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | function smart_addAdminAjaxSupport() |
| 932 | 932 | { |
| 933 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 934 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 935 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 933 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 934 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 935 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -941,11 +941,11 @@ discard block |
||
| 941 | 941 | */ |
| 942 | 942 | function smart_sanitizeForSmartpopupLink($text) |
| 943 | 943 | { |
| 944 | - $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 945 | - $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 946 | - $ret = preg_replace($patterns, $replacements, $text); |
|
| 944 | + $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 945 | + $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 946 | + $ret = preg_replace($patterns, $replacements, $text); |
|
| 947 | 947 | |
| 948 | - return $ret; |
|
| 948 | + return $ret; |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | /** |
@@ -960,25 +960,25 @@ discard block |
||
| 960 | 960 | */ |
| 961 | 961 | function smart_getImageSize($url, & $width, & $height) |
| 962 | 962 | { |
| 963 | - if (empty($width) || empty($height)) { |
|
| 964 | - if (!$dimension = @ getimagesize($url)) { |
|
| 965 | - return false; |
|
| 966 | - } |
|
| 967 | - if (!empty($width)) { |
|
| 968 | - $height = $dimension[1] * $width / $dimension[0]; |
|
| 969 | - } elseif (!empty($height)) { |
|
| 970 | - $width = $dimension[0] * $height / $dimension[1]; |
|
| 971 | - } else { |
|
| 972 | - list($width, $height) = [ |
|
| 973 | - $dimension[0], |
|
| 974 | - $dimension[1] |
|
| 975 | - ]; |
|
| 976 | - } |
|
| 977 | - |
|
| 978 | - return true; |
|
| 979 | - } else { |
|
| 980 | - return true; |
|
| 981 | - } |
|
| 963 | + if (empty($width) || empty($height)) { |
|
| 964 | + if (!$dimension = @ getimagesize($url)) { |
|
| 965 | + return false; |
|
| 966 | + } |
|
| 967 | + if (!empty($width)) { |
|
| 968 | + $height = $dimension[1] * $width / $dimension[0]; |
|
| 969 | + } elseif (!empty($height)) { |
|
| 970 | + $width = $dimension[0] * $height / $dimension[1]; |
|
| 971 | + } else { |
|
| 972 | + list($width, $height) = [ |
|
| 973 | + $dimension[0], |
|
| 974 | + $dimension[1] |
|
| 975 | + ]; |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + return true; |
|
| 979 | + } else { |
|
| 980 | + return true; |
|
| 981 | + } |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | /** |
@@ -991,10 +991,10 @@ discard block |
||
| 991 | 991 | */ |
| 992 | 992 | function smart_htmlnumericentities($str) |
| 993 | 993 | { |
| 994 | - // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 995 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 996 | - return '&#' . ord($m[0]) . chr(59); |
|
| 997 | - }, $str); |
|
| 994 | + // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 995 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 996 | + return '&#' . ord($m[0]) . chr(59); |
|
| 997 | + }, $str); |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /** |
@@ -1004,24 +1004,24 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | function smart_getcorehandler($name, $optional = false) |
| 1006 | 1006 | { |
| 1007 | - static $handlers; |
|
| 1008 | - $name = strtolower(trim($name)); |
|
| 1009 | - if (!isset($handlers[$name])) { |
|
| 1010 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1011 | - require_once $hnd_file; |
|
| 1012 | - } |
|
| 1013 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1014 | - if (class_exists($class)) { |
|
| 1015 | - $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - if (!isset($handlers[$name]) && !$optional) { |
|
| 1019 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1020 | - } |
|
| 1021 | - if (isset($handlers[$name])) { |
|
| 1022 | - return $handlers[$name]; |
|
| 1023 | - } |
|
| 1024 | - $inst = false; |
|
| 1007 | + static $handlers; |
|
| 1008 | + $name = strtolower(trim($name)); |
|
| 1009 | + if (!isset($handlers[$name])) { |
|
| 1010 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1011 | + require_once $hnd_file; |
|
| 1012 | + } |
|
| 1013 | + $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1014 | + if (class_exists($class)) { |
|
| 1015 | + $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + if (!isset($handlers[$name]) && !$optional) { |
|
| 1019 | + trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1020 | + } |
|
| 1021 | + if (isset($handlers[$name])) { |
|
| 1022 | + return $handlers[$name]; |
|
| 1023 | + } |
|
| 1024 | + $inst = false; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /** |
@@ -1030,15 +1030,15 @@ discard block |
||
| 1030 | 1030 | */ |
| 1031 | 1031 | function smart_sanitizeAdsenses_callback($matches) |
| 1032 | 1032 | { |
| 1033 | - global $smartobjectAdsenseHandler; |
|
| 1034 | - if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1035 | - $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1036 | - $ret = $adsenseObj->render(); |
|
| 1037 | - |
|
| 1038 | - return $ret; |
|
| 1039 | - } else { |
|
| 1040 | - return ''; |
|
| 1041 | - } |
|
| 1033 | + global $smartobjectAdsenseHandler; |
|
| 1034 | + if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1035 | + $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1036 | + $ret = $adsenseObj->render(); |
|
| 1037 | + |
|
| 1038 | + return $ret; |
|
| 1039 | + } else { |
|
| 1040 | + return ''; |
|
| 1041 | + } |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
@@ -1047,13 +1047,13 @@ discard block |
||
| 1047 | 1047 | */ |
| 1048 | 1048 | function smart_sanitizeAdsenses($text) |
| 1049 | 1049 | { |
| 1050 | - $patterns = []; |
|
| 1051 | - $replacements = []; |
|
| 1050 | + $patterns = []; |
|
| 1051 | + $replacements = []; |
|
| 1052 | 1052 | |
| 1053 | - $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1054 | - $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1053 | + $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1054 | + $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1055 | 1055 | |
| 1056 | - return $text; |
|
| 1056 | + return $text; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1062,15 +1062,15 @@ discard block |
||
| 1062 | 1062 | */ |
| 1063 | 1063 | function smart_sanitizeCustomtags_callback($matches) |
| 1064 | 1064 | { |
| 1065 | - global $smartobjectCustomtagHandler; |
|
| 1066 | - if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1067 | - $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1068 | - $ret = $customObj->renderWithPhp(); |
|
| 1069 | - |
|
| 1070 | - return $ret; |
|
| 1071 | - } else { |
|
| 1072 | - return ''; |
|
| 1073 | - } |
|
| 1065 | + global $smartobjectCustomtagHandler; |
|
| 1066 | + if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1067 | + $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1068 | + $ret = $customObj->renderWithPhp(); |
|
| 1069 | + |
|
| 1070 | + return $ret; |
|
| 1071 | + } else { |
|
| 1072 | + return ''; |
|
| 1073 | + } |
|
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | /** |
@@ -1079,13 +1079,13 @@ discard block |
||
| 1079 | 1079 | */ |
| 1080 | 1080 | function smart_sanitizeCustomtags($text) |
| 1081 | 1081 | { |
| 1082 | - $patterns = []; |
|
| 1083 | - $replacements = []; |
|
| 1082 | + $patterns = []; |
|
| 1083 | + $replacements = []; |
|
| 1084 | 1084 | |
| 1085 | - $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1086 | - $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1085 | + $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1086 | + $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1087 | 1087 | |
| 1088 | - return $text; |
|
| 1088 | + return $text; |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | /** |
@@ -1094,20 +1094,20 @@ discard block |
||
| 1094 | 1094 | */ |
| 1095 | 1095 | function smart_loadLanguageFile($module, $file) |
| 1096 | 1096 | { |
| 1097 | - global $xoopsConfig; |
|
| 1098 | - |
|
| 1099 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1100 | - if (!file_exists($filename)) { |
|
| 1101 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1102 | - } |
|
| 1103 | - if (file_exists($filename)) { |
|
| 1104 | - require_once $filename; |
|
| 1105 | - } |
|
| 1097 | + global $xoopsConfig; |
|
| 1098 | + |
|
| 1099 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1100 | + if (!file_exists($filename)) { |
|
| 1101 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1102 | + } |
|
| 1103 | + if (file_exists($filename)) { |
|
| 1104 | + require_once $filename; |
|
| 1105 | + } |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | function smart_loadCommonLanguageFile() |
| 1109 | 1109 | { |
| 1110 | - smart_loadLanguageFile('smartobject', 'common'); |
|
| 1110 | + smart_loadLanguageFile('smartobject', 'common'); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /** |
@@ -1117,35 +1117,35 @@ discard block |
||
| 1117 | 1117 | */ |
| 1118 | 1118 | function smart_purifyText($text, $keyword = false) |
| 1119 | 1119 | { |
| 1120 | - global $myts; |
|
| 1121 | - $text = str_replace(' ', ' ', $text); |
|
| 1122 | - $text = str_replace('<br>', ' ', $text); |
|
| 1123 | - $text = str_replace('<br>', ' ', $text); |
|
| 1124 | - $text = str_replace('<br', ' ', $text); |
|
| 1125 | - $text = strip_tags($text); |
|
| 1126 | - $text = html_entity_decode($text); |
|
| 1127 | - $text = $myts->undoHtmlSpecialChars($text); |
|
| 1128 | - $text = str_replace(')', ' ', $text); |
|
| 1129 | - $text = str_replace('(', ' ', $text); |
|
| 1130 | - $text = str_replace(':', ' ', $text); |
|
| 1131 | - $text = str_replace('&euro', ' euro ', $text); |
|
| 1132 | - $text = str_replace('&hellip', '...', $text); |
|
| 1133 | - $text = str_replace('&rsquo', ' ', $text); |
|
| 1134 | - $text = str_replace('!', ' ', $text); |
|
| 1135 | - $text = str_replace('?', ' ', $text); |
|
| 1136 | - $text = str_replace('"', ' ', $text); |
|
| 1137 | - $text = str_replace('-', ' ', $text); |
|
| 1138 | - $text = str_replace('\n', ' ', $text); |
|
| 1139 | - $text = str_replace('―', ' ', $text); |
|
| 1140 | - |
|
| 1141 | - if ($keyword) { |
|
| 1142 | - $text = str_replace('.', ' ', $text); |
|
| 1143 | - $text = str_replace(',', ' ', $text); |
|
| 1144 | - $text = str_replace('\'', ' ', $text); |
|
| 1145 | - } |
|
| 1146 | - $text = str_replace(';', ' ', $text); |
|
| 1147 | - |
|
| 1148 | - return $text; |
|
| 1120 | + global $myts; |
|
| 1121 | + $text = str_replace(' ', ' ', $text); |
|
| 1122 | + $text = str_replace('<br>', ' ', $text); |
|
| 1123 | + $text = str_replace('<br>', ' ', $text); |
|
| 1124 | + $text = str_replace('<br', ' ', $text); |
|
| 1125 | + $text = strip_tags($text); |
|
| 1126 | + $text = html_entity_decode($text); |
|
| 1127 | + $text = $myts->undoHtmlSpecialChars($text); |
|
| 1128 | + $text = str_replace(')', ' ', $text); |
|
| 1129 | + $text = str_replace('(', ' ', $text); |
|
| 1130 | + $text = str_replace(':', ' ', $text); |
|
| 1131 | + $text = str_replace('&euro', ' euro ', $text); |
|
| 1132 | + $text = str_replace('&hellip', '...', $text); |
|
| 1133 | + $text = str_replace('&rsquo', ' ', $text); |
|
| 1134 | + $text = str_replace('!', ' ', $text); |
|
| 1135 | + $text = str_replace('?', ' ', $text); |
|
| 1136 | + $text = str_replace('"', ' ', $text); |
|
| 1137 | + $text = str_replace('-', ' ', $text); |
|
| 1138 | + $text = str_replace('\n', ' ', $text); |
|
| 1139 | + $text = str_replace('―', ' ', $text); |
|
| 1140 | + |
|
| 1141 | + if ($keyword) { |
|
| 1142 | + $text = str_replace('.', ' ', $text); |
|
| 1143 | + $text = str_replace(',', ' ', $text); |
|
| 1144 | + $text = str_replace('\'', ' ', $text); |
|
| 1145 | + } |
|
| 1146 | + $text = str_replace(';', ' ', $text); |
|
| 1147 | + |
|
| 1148 | + return $text; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | /** |
@@ -1154,51 +1154,51 @@ discard block |
||
| 1154 | 1154 | */ |
| 1155 | 1155 | function smart_html2text($document) |
| 1156 | 1156 | { |
| 1157 | - // PHP Manual:: function preg_replace |
|
| 1158 | - // $document should contain an HTML document. |
|
| 1159 | - // This will remove HTML tags, javascript sections |
|
| 1160 | - // and white space. It will also convert some |
|
| 1161 | - // common HTML entities to their text equivalent. |
|
| 1162 | - // Credits: newbb2 |
|
| 1163 | - $search = [ |
|
| 1164 | - "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1165 | - "'<img.*?>'si", // Strip out img tags |
|
| 1166 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1167 | - "'([\r\n])[\s]+'", // Strip out white space |
|
| 1168 | - "'&(quot|#34);'i", // Replace HTML entities |
|
| 1169 | - "'&(amp|#38);'i", |
|
| 1170 | - "'&(lt|#60);'i", |
|
| 1171 | - "'&(gt|#62);'i", |
|
| 1172 | - "'&(nbsp|#160);'i", |
|
| 1173 | - "'&(iexcl|#161);'i", |
|
| 1174 | - "'&(cent|#162);'i", |
|
| 1175 | - "'&(pound|#163);'i", |
|
| 1176 | - "'&(copy|#169);'i" |
|
| 1177 | - ]; // evaluate as php |
|
| 1178 | - |
|
| 1179 | - $replace = [ |
|
| 1180 | - '', |
|
| 1181 | - '', |
|
| 1182 | - '', |
|
| 1183 | - "\\1", |
|
| 1184 | - '"', |
|
| 1185 | - '&', |
|
| 1186 | - '<', |
|
| 1187 | - '>', |
|
| 1188 | - ' ', |
|
| 1189 | - chr(161), |
|
| 1190 | - chr(162), |
|
| 1191 | - chr(163), |
|
| 1192 | - chr(169), |
|
| 1193 | - ]; |
|
| 1194 | - |
|
| 1195 | - $text = preg_replace($search, $replace, $document); |
|
| 1196 | - |
|
| 1197 | - preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1198 | - return chr($matches[1]); |
|
| 1199 | - }, $document); |
|
| 1200 | - |
|
| 1201 | - return $text; |
|
| 1157 | + // PHP Manual:: function preg_replace |
|
| 1158 | + // $document should contain an HTML document. |
|
| 1159 | + // This will remove HTML tags, javascript sections |
|
| 1160 | + // and white space. It will also convert some |
|
| 1161 | + // common HTML entities to their text equivalent. |
|
| 1162 | + // Credits: newbb2 |
|
| 1163 | + $search = [ |
|
| 1164 | + "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1165 | + "'<img.*?>'si", // Strip out img tags |
|
| 1166 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1167 | + "'([\r\n])[\s]+'", // Strip out white space |
|
| 1168 | + "'&(quot|#34);'i", // Replace HTML entities |
|
| 1169 | + "'&(amp|#38);'i", |
|
| 1170 | + "'&(lt|#60);'i", |
|
| 1171 | + "'&(gt|#62);'i", |
|
| 1172 | + "'&(nbsp|#160);'i", |
|
| 1173 | + "'&(iexcl|#161);'i", |
|
| 1174 | + "'&(cent|#162);'i", |
|
| 1175 | + "'&(pound|#163);'i", |
|
| 1176 | + "'&(copy|#169);'i" |
|
| 1177 | + ]; // evaluate as php |
|
| 1178 | + |
|
| 1179 | + $replace = [ |
|
| 1180 | + '', |
|
| 1181 | + '', |
|
| 1182 | + '', |
|
| 1183 | + "\\1", |
|
| 1184 | + '"', |
|
| 1185 | + '&', |
|
| 1186 | + '<', |
|
| 1187 | + '>', |
|
| 1188 | + ' ', |
|
| 1189 | + chr(161), |
|
| 1190 | + chr(162), |
|
| 1191 | + chr(163), |
|
| 1192 | + chr(169), |
|
| 1193 | + ]; |
|
| 1194 | + |
|
| 1195 | + $text = preg_replace($search, $replace, $document); |
|
| 1196 | + |
|
| 1197 | + preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1198 | + return chr($matches[1]); |
|
| 1199 | + }, $document); |
|
| 1200 | + |
|
| 1201 | + return $text; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1212,32 +1212,32 @@ discard block |
||
| 1212 | 1212 | */ |
| 1213 | 1213 | function smart_getfloat($str, $set = false) |
| 1214 | 1214 | { |
| 1215 | - if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1216 | - // Found number in $str, so set $str that number |
|
| 1217 | - $str = $match[0]; |
|
| 1218 | - if (false !== strpos($str, ',')) { |
|
| 1219 | - // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1220 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1221 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1222 | - |
|
| 1223 | - return (float)$str; |
|
| 1224 | - } else { |
|
| 1225 | - // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1226 | - if (true === preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) && true === $set['single_dot_as_decimal']) { |
|
| 1227 | - // Treat single dot as decimal separator |
|
| 1228 | - return (float)$str; |
|
| 1229 | - } else { |
|
| 1230 | - //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1231 | - // Else, treat all dots as thousand seps |
|
| 1232 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1233 | - |
|
| 1234 | - return (float)$str; |
|
| 1235 | - } |
|
| 1236 | - } |
|
| 1237 | - } else { |
|
| 1238 | - // No number found, return zero |
|
| 1239 | - return 0; |
|
| 1240 | - } |
|
| 1215 | + if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1216 | + // Found number in $str, so set $str that number |
|
| 1217 | + $str = $match[0]; |
|
| 1218 | + if (false !== strpos($str, ',')) { |
|
| 1219 | + // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1220 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1221 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1222 | + |
|
| 1223 | + return (float)$str; |
|
| 1224 | + } else { |
|
| 1225 | + // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1226 | + if (true === preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) && true === $set['single_dot_as_decimal']) { |
|
| 1227 | + // Treat single dot as decimal separator |
|
| 1228 | + return (float)$str; |
|
| 1229 | + } else { |
|
| 1230 | + //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1231 | + // Else, treat all dots as thousand seps |
|
| 1232 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1233 | + |
|
| 1234 | + return (float)$str; |
|
| 1235 | + } |
|
| 1236 | + } |
|
| 1237 | + } else { |
|
| 1238 | + // No number found, return zero |
|
| 1239 | + return 0; |
|
| 1240 | + } |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1247,26 +1247,26 @@ discard block |
||
| 1247 | 1247 | */ |
| 1248 | 1248 | function smart_currency($var, $currencyObj = false) |
| 1249 | 1249 | { |
| 1250 | - $ret = smart_getfloat($var, ['single_dot_as_decimal' => true]); |
|
| 1251 | - $ret = round($ret, 2); |
|
| 1252 | - // make sur we have at least .00 in the $var |
|
| 1253 | - $decimal_section_original = strstr($ret, '.'); |
|
| 1254 | - $decimal_section = $decimal_section_original; |
|
| 1255 | - if ($decimal_section) { |
|
| 1256 | - if (1 == strlen($decimal_section)) { |
|
| 1257 | - $decimal_section = '.00'; |
|
| 1258 | - } elseif (2 == strlen($decimal_section)) { |
|
| 1259 | - $decimal_section .= '0'; |
|
| 1260 | - } |
|
| 1261 | - $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1262 | - } else { |
|
| 1263 | - $ret .= '.00'; |
|
| 1264 | - } |
|
| 1265 | - if ($currencyObj) { |
|
| 1266 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1267 | - } |
|
| 1268 | - |
|
| 1269 | - return $ret; |
|
| 1250 | + $ret = smart_getfloat($var, ['single_dot_as_decimal' => true]); |
|
| 1251 | + $ret = round($ret, 2); |
|
| 1252 | + // make sur we have at least .00 in the $var |
|
| 1253 | + $decimal_section_original = strstr($ret, '.'); |
|
| 1254 | + $decimal_section = $decimal_section_original; |
|
| 1255 | + if ($decimal_section) { |
|
| 1256 | + if (1 == strlen($decimal_section)) { |
|
| 1257 | + $decimal_section = '.00'; |
|
| 1258 | + } elseif (2 == strlen($decimal_section)) { |
|
| 1259 | + $decimal_section .= '0'; |
|
| 1260 | + } |
|
| 1261 | + $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1262 | + } else { |
|
| 1263 | + $ret .= '.00'; |
|
| 1264 | + } |
|
| 1265 | + if ($currencyObj) { |
|
| 1266 | + $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1267 | + } |
|
| 1268 | + |
|
| 1269 | + return $ret; |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | /** |
@@ -1275,7 +1275,7 @@ discard block |
||
| 1275 | 1275 | */ |
| 1276 | 1276 | function smart_float($var) |
| 1277 | 1277 | { |
| 1278 | - return smart_currency($var); |
|
| 1278 | + return smart_currency($var); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | /** |
@@ -1284,16 +1284,16 @@ discard block |
||
| 1284 | 1284 | */ |
| 1285 | 1285 | function smart_getModuleAdminLink($moduleName = false) |
| 1286 | 1286 | { |
| 1287 | - global $xoopsModule; |
|
| 1288 | - if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1289 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1290 | - } |
|
| 1291 | - $ret = ''; |
|
| 1292 | - if ($moduleName) { |
|
| 1293 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1294 | - } |
|
| 1295 | - |
|
| 1296 | - return $ret; |
|
| 1287 | + global $xoopsModule; |
|
| 1288 | + if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1289 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1290 | + } |
|
| 1291 | + $ret = ''; |
|
| 1292 | + if ($moduleName) { |
|
| 1293 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + return $ret; |
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | /** |
@@ -1301,19 +1301,19 @@ discard block |
||
| 1301 | 1301 | */ |
| 1302 | 1302 | function smart_getEditors() |
| 1303 | 1303 | { |
| 1304 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1305 | - if (!file_exists($filename)) { |
|
| 1306 | - return false; |
|
| 1307 | - } |
|
| 1308 | - require_once $filename; |
|
| 1309 | - $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1310 | - $aList = $xoopseditorHandler->getList(); |
|
| 1311 | - $ret = []; |
|
| 1312 | - foreach ($aList as $k => $v) { |
|
| 1313 | - $ret[$v] = $k; |
|
| 1314 | - } |
|
| 1315 | - |
|
| 1316 | - return $ret; |
|
| 1304 | + $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1305 | + if (!file_exists($filename)) { |
|
| 1306 | + return false; |
|
| 1307 | + } |
|
| 1308 | + require_once $filename; |
|
| 1309 | + $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1310 | + $aList = $xoopseditorHandler->getList(); |
|
| 1311 | + $ret = []; |
|
| 1312 | + foreach ($aList as $k => $v) { |
|
| 1313 | + $ret[$v] = $k; |
|
| 1314 | + } |
|
| 1315 | + |
|
| 1316 | + return $ret; |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | /** |
@@ -1323,11 +1323,11 @@ discard block |
||
| 1323 | 1323 | */ |
| 1324 | 1324 | function smart_getTablesArray($moduleName, $items) |
| 1325 | 1325 | { |
| 1326 | - $ret = []; |
|
| 1327 | - foreach ($items as $item) { |
|
| 1328 | - $ret[] = $moduleName . '_' . $item; |
|
| 1329 | - } |
|
| 1330 | - $ret[] = $moduleName . '_meta'; |
|
| 1326 | + $ret = []; |
|
| 1327 | + foreach ($items as $item) { |
|
| 1328 | + $ret[] = $moduleName . '_' . $item; |
|
| 1329 | + } |
|
| 1330 | + $ret[] = $moduleName . '_meta'; |
|
| 1331 | 1331 | |
| 1332 | - return $ret; |
|
| 1332 | + return $ret; |
|
| 1333 | 1333 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | function smart_get_css_link($cssfile) |
| 20 | 20 | { |
| 21 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 21 | + $ret = '<link rel="stylesheet" type="text/css" href="'.$cssfile.'">'; |
|
| 22 | 22 | |
| 23 | 23 | return $ret; |
| 24 | 24 | } |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | $seoMode = smart_getModuleModeSEO($moduleName); |
| 110 | 110 | if ('rewrite' === $seoMode) { |
| 111 | 111 | $seoModuleName = smart_getModuleNameForSEO($moduleName); |
| 112 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 112 | + $ret = XOOPS_URL.'/'.$seoModuleName.'/'; |
|
| 113 | 113 | } elseif ('pathinfo' === $seoMode) { |
| 114 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 114 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/seo.php/'.$seoModuleName.'/'; |
|
| 115 | 115 | } else { |
| 116 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 116 | + $ret = XOOPS_URL.'/modules/'.$moduleName.'/'; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 119 | + return '<a href="'.$ret.'">'.$smartModule->getVar('name').'</a>'; |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | //Verifies that a MySQL table exists |
| 219 | 219 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
| 220 | 220 | $realname = $xoopsDB->prefix($table); |
| 221 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 221 | + $sql = 'SHOW TABLES FROM '.XOOPS_DB_NAME; |
|
| 222 | 222 | $ret = $xoopsDB->queryF($sql); |
| 223 | 223 | while (false !== (list($m_table) = $xoopsDB->fetchRow($ret))) { |
| 224 | 224 | if ($m_table == $realname) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $moduleName = smart_getCurrentModuleName(); |
| 248 | 248 | } |
| 249 | 249 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
| 250 | - $sql = sprintf('SELECT metavalue FROM `%s` WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 250 | + $sql = sprintf('SELECT metavalue FROM `%s` WHERE metakey=%s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key)); |
|
| 251 | 251 | $ret = $xoopsDB->query($sql); |
| 252 | 252 | if (!$ret) { |
| 253 | 253 | $value = false; |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
| 291 | 291 | $ret = smart_GetMeta($key, $moduleName); |
| 292 | 292 | if ('0' === $ret || $ret > 0) { |
| 293 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 293 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 294 | 294 | } else { |
| 295 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 295 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName.'_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 296 | 296 | } |
| 297 | 297 | $ret = $xoopsDB->queryF($sql); |
| 298 | 298 | if (!$ret) { |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | { |
| 473 | 473 | static $smartModules; |
| 474 | 474 | if (isset($smartModules[$moduleName])) { |
| 475 | - $ret =& $smartModules[$moduleName]; |
|
| 475 | + $ret = & $smartModules[$moduleName]; |
|
| 476 | 476 | |
| 477 | 477 | return $ret; |
| 478 | 478 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | { |
| 509 | 509 | static $smartConfigs; |
| 510 | 510 | if (isset($smartConfigs[$moduleName])) { |
| 511 | - $ret =& $smartConfigs[$moduleName]; |
|
| 511 | + $ret = & $smartConfigs[$moduleName]; |
|
| 512 | 512 | |
| 513 | 513 | return $ret; |
| 514 | 514 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | return $ret; |
| 537 | 537 | } |
| 538 | 538 | $hModConfig = xoops_getHandler('config'); |
| 539 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 539 | + $smartConfigs[$moduleName] = & $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | return $smartConfigs[$moduleName]; |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | { |
| 563 | 563 | $ret = ''; |
| 564 | 564 | foreach ($errors as $key => $value) { |
| 565 | - $ret .= '<br> - ' . $value; |
|
| 565 | + $ret .= '<br> - '.$value; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | return $ret; |
@@ -582,17 +582,17 @@ discard block |
||
| 582 | 582 | if (!is_numeric($userid)) { |
| 583 | 583 | return $userid; |
| 584 | 584 | } |
| 585 | - $userid = (int)$userid; |
|
| 585 | + $userid = (int) $userid; |
|
| 586 | 586 | if ($userid > 0) { |
| 587 | 587 | if ($users == []) { |
| 588 | 588 | //fetching users |
| 589 | 589 | $memberHandler = xoops_getHandler('member'); |
| 590 | - $user =& $memberHandler->getUser($userid); |
|
| 590 | + $user = & $memberHandler->getUser($userid); |
|
| 591 | 591 | } else { |
| 592 | 592 | if (!isset($users[$userid])) { |
| 593 | 593 | return $GLOBALS['xoopsConfig']['anonymous']; |
| 594 | 594 | } |
| 595 | - $user =& $users[$userid]; |
|
| 595 | + $user = & $users[$userid]; |
|
| 596 | 596 | } |
| 597 | 597 | if (is_object($user)) { |
| 598 | 598 | $ts = MyTextSanitizer:: getInstance(); |
@@ -603,15 +603,15 @@ discard block |
||
| 603 | 603 | $fullname = $user->getVar('name'); |
| 604 | 604 | } |
| 605 | 605 | if (!empty($fullname)) { |
| 606 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 606 | + $linkeduser = "$fullname [<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".$ts->htmlSpecialChars($username).'</a>]'; |
|
| 607 | 607 | } else { |
| 608 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 608 | + $linkeduser = "<a href='".XOOPS_URL.'/userinfo.php?uid='.$userid."'>".ucwords($ts->htmlSpecialChars($username)).'</a>'; |
|
| 609 | 609 | } |
| 610 | 610 | // add contact info: email + PM |
| 611 | 611 | if ($withContact) { |
| 612 | - $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>'; |
|
| 613 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 614 | - $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 | + $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>'; |
|
| 613 | + $js = "javascript:openWithSelfMain('".XOOPS_URL.'/pmlite.php?send2=1&to_userid='.$userid."', 'pmlite',450,370);"; |
|
| 614 | + $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>'; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | return $linkeduser; |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
| 631 | 631 | { |
| 632 | 632 | global $xoopsModule, $xoopsConfig; |
| 633 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 633 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | /** @var Smartobject\Helper $helper */ |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | $helper->loadLanguage('modinfo'); |
| 640 | 640 | $headermenu = []; |
| 641 | 641 | $adminObject = []; |
| 642 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 642 | + include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/admin/menu.php'; |
|
| 643 | 643 | $tpl = new \XoopsTpl(); |
| 644 | 644 | $tpl->assign([ |
| 645 | 645 | 'headermenu' => $headermenu, |
@@ -662,11 +662,11 @@ discard block |
||
| 662 | 662 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
| 663 | 663 | { |
| 664 | 664 | global $xoopsModule; |
| 665 | - 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')\";>"; |
|
| 666 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 667 | - echo "<div id='" . $id . "'>"; |
|
| 665 | + 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')\";>"; |
|
| 666 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt=''></a> ".$title.'</h3>'; |
|
| 667 | + echo "<div id='".$id."'>"; |
|
| 668 | 668 | if ('' !== $dsc) { |
| 669 | - echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 669 | + echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">'.$dsc.'</span>'; |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
@@ -680,11 +680,11 @@ discard block |
||
| 680 | 680 | global $xoopsModule; |
| 681 | 681 | $onClick = "ajaxtogglecollapse('$id')"; |
| 682 | 682 | //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
| 683 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 684 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 685 | - echo "<div id='" . $id . "'>"; |
|
| 683 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="'.$onClick.'">'; |
|
| 684 | + echo "<img id='".$id."_icon' src=".SMARTOBJECT_URL."assets/images/close12.gif alt=''></a> ".$title.'</h3>'; |
|
| 685 | + echo "<div id='".$id."'>"; |
|
| 686 | 686 | if ('' !== $dsc) { |
| 687 | - echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $dsc . '</span>'; |
|
| 687 | + echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">'.$dsc.'</span>'; |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | |
@@ -714,13 +714,13 @@ discard block |
||
| 714 | 714 | { |
| 715 | 715 | $urls = smart_getCurrentUrls(); |
| 716 | 716 | $path = $urls['phpself']; |
| 717 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 717 | + $cookie_name = $path.'_smart_collaps_'.$name; |
|
| 718 | 718 | $cookie_name = str_replace('.', '_', $cookie_name); |
| 719 | 719 | $cookie = smart_getCookieVar($cookie_name, ''); |
| 720 | 720 | if ('none' === $cookie) { |
| 721 | 721 | echo ' |
| 722 | 722 | <script type="text/javascript"><!-- |
| 723 | - togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
|
| 723 | + togglecollapse("' . $name.'"); toggleIcon("'.$name.'_icon"); |
|
| 724 | 724 | //--> |
| 725 | 725 | </script> |
| 726 | 726 | '; |
@@ -786,17 +786,17 @@ discard block |
||
| 786 | 786 | $httphost = $_SERVER['HTTP_HOST']; |
| 787 | 787 | $querystring = $_SERVER['QUERY_STRING']; |
| 788 | 788 | if ('' !== $querystring) { |
| 789 | - $querystring = '?' . $querystring; |
|
| 789 | + $querystring = '?'.$querystring; |
|
| 790 | 790 | } |
| 791 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 791 | + $currenturl = $http.$httphost.$phpself.$querystring; |
|
| 792 | 792 | $urls = []; |
| 793 | 793 | $urls['http'] = $http; |
| 794 | 794 | $urls['httphost'] = $httphost; |
| 795 | 795 | $urls['phpself'] = $phpself; |
| 796 | 796 | $urls['querystring'] = $querystring; |
| 797 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 797 | + $urls['full_phpself'] = $http.$httphost.$phpself; |
|
| 798 | 798 | $urls['full'] = $currenturl; |
| 799 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 799 | + $urls['isHomePage'] = (XOOPS_URL.'/index.php') == ($http.$httphost.$phpself); |
|
| 800 | 800 | |
| 801 | 801 | return $urls; |
| 802 | 802 | } |
@@ -873,13 +873,13 @@ discard block |
||
| 873 | 873 | { |
| 874 | 874 | global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
| 875 | 875 | |
| 876 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 876 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
| 877 | 877 | $tpl = new \XoopsTpl(); |
| 878 | 878 | |
| 879 | 879 | $hModule = xoops_getHandler('module'); |
| 880 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 881 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 882 | - $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>"; |
|
| 880 | + $versioninfo = & $hModule->get($xoopsModule->getVar('mid')); |
|
| 881 | + $modfootertxt = 'Module '.$versioninfo->getInfo('name').' - Version '.$versioninfo->getInfo('version').''; |
|
| 882 | + $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>"; |
|
| 883 | 883 | $tpl->assign('modfooter', $modfooter); |
| 884 | 884 | |
| 885 | 885 | if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | } |
| 888 | 888 | $smartobjectConfig = smart_getModuleConfig('smartobject'); |
| 889 | 889 | $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
| 890 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 890 | + $tpl->display(SMARTOBJECT_ROOT_PATH.'templates/smartobject_admin_footer.tpl'); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | function smart_xoops_cp_footer() |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | function smart_addScript($src) |
| 916 | 916 | { |
| 917 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 917 | + echo '<script src="'.$src.'" type="text/javascript"></script>'; |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -923,16 +923,16 @@ discard block |
||
| 923 | 923 | function smart_addStyle($src) |
| 924 | 924 | { |
| 925 | 925 | if ('smartobject' === $src) { |
| 926 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 926 | + $src = SMARTOBJECT_URL.'assets/css/module.css'; |
|
| 927 | 927 | } |
| 928 | 928 | echo smart_get_css_link($src); |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | function smart_addAdminAjaxSupport() |
| 932 | 932 | { |
| 933 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 934 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 935 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 933 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/lib/prototype.js'); |
|
| 934 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/scriptaculous.js'); |
|
| 935 | + smart_addScript(SMARTOBJECT_URL.'include/scriptaculous/src/smart.js'); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -992,8 +992,8 @@ discard block |
||
| 992 | 992 | function smart_htmlnumericentities($str) |
| 993 | 993 | { |
| 994 | 994 | // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
| 995 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 996 | - return '&#' . ord($m[0]) . chr(59); |
|
| 995 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function($m) { |
|
| 996 | + return '&#'.ord($m[0]).chr(59); |
|
| 997 | 997 | }, $str); |
| 998 | 998 | } |
| 999 | 999 | |
@@ -1007,16 +1007,16 @@ discard block |
||
| 1007 | 1007 | static $handlers; |
| 1008 | 1008 | $name = strtolower(trim($name)); |
| 1009 | 1009 | if (!isset($handlers[$name])) { |
| 1010 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1010 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH.'/kernel/'.$name.'.php')) { |
|
| 1011 | 1011 | require_once $hnd_file; |
| 1012 | 1012 | } |
| 1013 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1013 | + $class = 'Xoops'.ucfirst($name).'Handler'; |
|
| 1014 | 1014 | if (class_exists($class)) { |
| 1015 | 1015 | $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
| 1016 | 1016 | } |
| 1017 | 1017 | } |
| 1018 | 1018 | if (!isset($handlers[$name]) && !$optional) { |
| 1019 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1019 | + trigger_error('Class <b>'.$class.'</b> does not exist<br>Handler Name: '.$name, E_USER_ERROR); |
|
| 1020 | 1020 | } |
| 1021 | 1021 | if (isset($handlers[$name])) { |
| 1022 | 1022 | return $handlers[$name]; |
@@ -1096,9 +1096,9 @@ discard block |
||
| 1096 | 1096 | { |
| 1097 | 1097 | global $xoopsConfig; |
| 1098 | 1098 | |
| 1099 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1099 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/'.$xoopsConfig['language'].'/'.$file.'.php'; |
|
| 1100 | 1100 | if (!file_exists($filename)) { |
| 1101 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1101 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$module.'/language/english/'.$file.'.php'; |
|
| 1102 | 1102 | } |
| 1103 | 1103 | if (file_exists($filename)) { |
| 1104 | 1104 | require_once $filename; |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | |
| 1195 | 1195 | $text = preg_replace($search, $replace, $document); |
| 1196 | 1196 | |
| 1197 | - preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1197 | + preg_replace_callback('/&#(\d+);/', function($matches) { |
|
| 1198 | 1198 | return chr($matches[1]); |
| 1199 | 1199 | }, $document); |
| 1200 | 1200 | |
@@ -1217,21 +1217,21 @@ discard block |
||
| 1217 | 1217 | $str = $match[0]; |
| 1218 | 1218 | if (false !== strpos($str, ',')) { |
| 1219 | 1219 | // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
| 1220 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1221 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1220 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1221 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1222 | 1222 | |
| 1223 | - return (float)$str; |
|
| 1223 | + return (float) $str; |
|
| 1224 | 1224 | } else { |
| 1225 | 1225 | // No comma exists, so we have to decide, how a single dot shall be treated |
| 1226 | 1226 | if (true === preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) && true === $set['single_dot_as_decimal']) { |
| 1227 | 1227 | // Treat single dot as decimal separator |
| 1228 | - return (float)$str; |
|
| 1228 | + return (float) $str; |
|
| 1229 | 1229 | } else { |
| 1230 | 1230 | //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
| 1231 | 1231 | // Else, treat all dots as thousand seps |
| 1232 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1232 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1233 | 1233 | |
| 1234 | - return (float)$str; |
|
| 1234 | + return (float) $str; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | } |
| 1237 | 1237 | } else { |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | $ret .= '.00'; |
| 1264 | 1264 | } |
| 1265 | 1265 | if ($currencyObj) { |
| 1266 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1266 | + $ret = $ret.' '.$currencyObj->getCode(); |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | return $ret; |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | } |
| 1291 | 1291 | $ret = ''; |
| 1292 | 1292 | if ($moduleName) { |
| 1293 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1293 | + $ret = "<a href='".XOOPS_URL."/modules/$moduleName/admin/index.php'>"._CO_SOBJECT_ADMIN_PAGE.'</a>'; |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | return $ret; |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | */ |
| 1302 | 1302 | function smart_getEditors() |
| 1303 | 1303 | { |
| 1304 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1304 | + $filename = XOOPS_ROOT_PATH.'/class/xoopseditor/xoopseditor.php'; |
|
| 1305 | 1305 | if (!file_exists($filename)) { |
| 1306 | 1306 | return false; |
| 1307 | 1307 | } |
@@ -1325,9 +1325,9 @@ discard block |
||
| 1325 | 1325 | { |
| 1326 | 1326 | $ret = []; |
| 1327 | 1327 | foreach ($items as $item) { |
| 1328 | - $ret[] = $moduleName . '_' . $item; |
|
| 1328 | + $ret[] = $moduleName.'_'.$item; |
|
| 1329 | 1329 | } |
| 1330 | - $ret[] = $moduleName . '_meta'; |
|
| 1330 | + $ret[] = $moduleName.'_meta'; |
|
| 1331 | 1331 | |
| 1332 | 1332 | return $ret; |
| 1333 | 1333 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | function xoops_debug_dumbQuery($msg = '') |
| 16 | 16 | { |
| 17 | 17 | global $xoopsDB; |
| 18 | - $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2'); |
|
| 18 | + $xoopsDB->query('SELECT * '.$msg.' FROM dudewhereismycar2'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function xoops_debug_initiateQueryCount() |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function xoops_debug_dumbQuery($msg = '') |
| 16 | 16 | { |
| 17 | - global $xoopsDB; |
|
| 18 | - $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2'); |
|
| 17 | + global $xoopsDB; |
|
| 18 | + $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function xoops_debug_initiateQueryCount() |
| 22 | 22 | { |
| 23 | - global $smartfactory_query_count_activated, $smartfactory_query_count; |
|
| 24 | - $smartfactory_query_count_activated = true; |
|
| 25 | - $smartfactory_query_count = 0; |
|
| 23 | + global $smartfactory_query_count_activated, $smartfactory_query_count; |
|
| 24 | + $smartfactory_query_count_activated = true; |
|
| 25 | + $smartfactory_query_count = 0; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function xoops_debug_getQueryCount($msg = '') |
| 32 | 32 | { |
| 33 | - global $smartfactory_query_count; |
|
| 33 | + global $smartfactory_query_count; |
|
| 34 | 34 | |
| 35 | - return xoops_debug("xoops debug Query count ($msg): $smartfactory_query_count"); |
|
| 35 | + return xoops_debug("xoops debug Query count ($msg): $smartfactory_query_count"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function xoops_debug($msg, $exit = false) |
| 43 | 43 | { |
| 44 | - echo "<div style='padding: 5px; color: red; font-weight: bold;'>debug:: $msg</div>"; |
|
| 45 | - if ($exit) { |
|
| 46 | - die(); |
|
| 47 | - } |
|
| 44 | + echo "<div style='padding: 5px; color: red; font-weight: bold;'>debug:: $msg</div>"; |
|
| 45 | + if ($exit) { |
|
| 46 | + die(); |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function xoops_comment($msg) |
| 54 | 54 | { |
| 55 | - echo "<div style='padding: 5px; color: green; font-weight: bold;'>=> $msg</div>"; |
|
| 55 | + echo "<div style='padding: 5px; color: green; font-weight: bold;'>=> $msg</div>"; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function xoops_debug_vardump($var) |
| 62 | 62 | { |
| 63 | - if (class_exists('MyTextSanitizer')) { |
|
| 64 | - $myts = \MyTextSanitizer::getInstance(); |
|
| 65 | - xoops_debug($myts->displayTarea(var_export($var, true))); |
|
| 66 | - } else { |
|
| 67 | - xoops_debug(var_export($var, true)); |
|
| 68 | - } |
|
| 63 | + if (class_exists('MyTextSanitizer')) { |
|
| 64 | + $myts = \MyTextSanitizer::getInstance(); |
|
| 65 | + xoops_debug($myts->displayTarea(var_export($var, true))); |
|
| 66 | + } else { |
|
| 67 | + xoops_debug(var_export($var, true)); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -178,7 +178,7 @@ |
||
| 178 | 178 | define('_CO_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2', 'Vertical with icons'); |
| 179 | 179 | define('_CO_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3', 'Vertical no icon'); |
| 180 | 180 | define('_CO_SOBJECT_CURRENT_FILE', 'Current file: '); |
| 181 | -define('_CO_SOBJECT_URL_FILE_DSC', "Alternatively, you can use an URL. If you select a file via 'Browse' button, URL will be ignored. You can use the tag {XOOPS_URL} to print " . XOOPS_URL); |
|
| 181 | +define('_CO_SOBJECT_URL_FILE_DSC', "Alternatively, you can use an URL. If you select a file via 'Browse' button, URL will be ignored. You can use the tag {XOOPS_URL} to print ".XOOPS_URL); |
|
| 182 | 182 | define('_CO_SOBJECT_URL_FILE', 'URL: '); |
| 183 | 183 | define('_CO_SOBJECT_UPLOAD', 'Select a file to upload: '); |
| 184 | 184 | |
@@ -152,16 +152,16 @@ |
||
| 152 | 152 | define('_CO_SOBJECT_UPLOAD_IMAGE', 'Upload a new image:'); |
| 153 | 153 | define('_CO_SOBJECT_VERSION_HISTORY', 'Version History'); |
| 154 | 154 | define( |
| 155 | - '_CO_SOBJECT_WARNING_BETA', |
|
| 156 | - 'This module comes as is, without any guarantees whatsoever. This module is BETA, meaning it is still under active development. This release is meant for <b>testing purposes only</b> and we <b>strongly</b> recommend that you do not use it on a live website or in a production environment.' |
|
| 155 | + '_CO_SOBJECT_WARNING_BETA', |
|
| 156 | + 'This module comes as is, without any guarantees whatsoever. This module is BETA, meaning it is still under active development. This release is meant for <b>testing purposes only</b> and we <b>strongly</b> recommend that you do not use it on a live website or in a production environment.' |
|
| 157 | 157 | ); |
| 158 | 158 | define( |
| 159 | - '_CO_SOBJECT_WARNING_FINAL', |
|
| 160 | - 'This module comes as is, without any guarantees whatsoever. Although this module is not beta, it is still under active development. This release can be used in a live website or a production environment, but its use is under your own responsibility, which means the author is not responsible.' |
|
| 159 | + '_CO_SOBJECT_WARNING_FINAL', |
|
| 160 | + 'This module comes as is, without any guarantees whatsoever. Although this module is not beta, it is still under active development. This release can be used in a live website or a production environment, but its use is under your own responsibility, which means the author is not responsible.' |
|
| 161 | 161 | ); |
| 162 | 162 | define( |
| 163 | - '_CO_SOBJECT_WARNING_RC', |
|
| 164 | - 'This module comes as is, without any guarantees whatsoever. This module is a Release Candidate and should not be used on a production web site. The module is still under active development and its use is under your own responsibility, which means the author is not responsible.' |
|
| 163 | + '_CO_SOBJECT_WARNING_RC', |
|
| 164 | + 'This module comes as is, without any guarantees whatsoever. This module is a Release Candidate and should not be used on a production web site. The module is still under active development and its use is under your own responsibility, which means the author is not responsible.' |
|
| 165 | 165 | ); |
| 166 | 166 | define('_CO_SOBJECT_WEIGHT_FORM_CAPTION', 'Weight'); |
| 167 | 167 | define('_CO_SOBJECT_WEIGHT_FORM_DSC', ''); |
@@ -248,7 +248,7 @@ |
||
| 248 | 248 | /** |
| 249 | 249 | * @param $field_id |
| 250 | 250 | * @param $options |
| 251 | - * @return mixed |
|
| 251 | + * @return string |
|
| 252 | 252 | */ |
| 253 | 253 | public function auto_complete_field($field_id, $options) |
| 254 | 254 | { |
@@ -15,319 +15,319 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Scriptaculous extends Prototype |
| 17 | 17 | { |
| 18 | - public $TOGGLE_EFFECTS = ['toggle_appear', 'toggle_slide', 'toggle_blind']; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Scriptaculous constructor. |
|
| 22 | - */ |
|
| 23 | - public function __construct() |
|
| 24 | - { |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param $element_id |
|
| 29 | - * @param null $options |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function dragable_element($element_id, $options = null) |
|
| 33 | - { |
|
| 34 | - return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param $element_id |
|
| 39 | - * @param null $options |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function drop_receiving_element($element_id, $options = null) |
|
| 43 | - { |
|
| 44 | - return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param $name |
|
| 49 | - * @param bool $element_id |
|
| 50 | - * @param null $js_options |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | - { |
|
| 55 | - $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | - |
|
| 57 | - $js_queue = ''; |
|
| 58 | - if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | - } elseif (isset($js_options)) { |
|
| 60 | - $js_queue = "'$js_options'"; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | - } else { |
|
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param $element_id |
|
| 72 | - * @param null $options |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function sortabe_element($element_id, $options = null) |
|
| 76 | - { |
|
| 77 | - return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | - // Private functions |
|
| 82 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @param $element_id |
|
| 86 | - * @param $options |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function _sortabe_element($element_id, $options) |
|
| 90 | - { |
|
| 91 | - //if (isset($options['with'])) { |
|
| 92 | - $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 93 | - // } |
|
| 94 | - |
|
| 95 | - //if (isset($option['onUpdate'])) { |
|
| 96 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 97 | - //} |
|
| 98 | - |
|
| 99 | - foreach ($options as $var => $val) { |
|
| 100 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 101 | - unset($options[$var]); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $arr = ['tag', 'overlap', 'contraint', 'handle']; |
|
| 106 | - |
|
| 107 | - foreach ($arr as $var) { |
|
| 108 | - if (isset($options[$var])) { |
|
| 109 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - if (isset($options['containment'])) { |
|
| 114 | - $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if (isset($options['only'])) { |
|
| 118 | - $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @param $element_id |
|
| 126 | - * @param $options |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function _dragable_element_js($element_id, $options) |
|
| 130 | - { |
|
| 131 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @param $element_id |
|
| 136 | - * @param $options |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function _drop_receiving_element($element_id, $options) |
|
| 140 | - { |
|
| 141 | - |
|
| 142 | - //if (isset($options['with'])) { |
|
| 143 | - $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 144 | - // } |
|
| 145 | - |
|
| 146 | - //if (isset($option['onDrop'])) |
|
| 147 | - |
|
| 148 | - { |
|
| 149 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (is_array($options)) { |
|
| 153 | - foreach ($options as $var => $val) { |
|
| 154 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 155 | - unset($options[$var]); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if (isset($options['accept'])) { |
|
| 161 | - $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if (isset($options['hoverclass'])) { |
|
| 165 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 172 | - // Merged Javascript macro |
|
| 173 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @param $field_id |
|
| 177 | - * @param $options |
|
| 178 | - * @param bool $tag |
|
| 179 | - * @return string |
|
| 180 | - */ |
|
| 181 | - public function in_place_editor($field_id, $options, $tag = true) |
|
| 182 | - { |
|
| 183 | - $function = 'new Ajax.InPlaceEditor('; |
|
| 184 | - $function .= "'$field_id', "; |
|
| 185 | - $function .= "'" . $options['url'] . "'"; |
|
| 186 | - |
|
| 187 | - $js_options = []; |
|
| 188 | - if (isset($options['cancel_text'])) { |
|
| 189 | - $js_options['cancelText'] = $options['cancel_text']; |
|
| 190 | - } |
|
| 191 | - if (isset($options['save_text'])) { |
|
| 192 | - $js_options['okText'] = $options['save_text']; |
|
| 193 | - } |
|
| 194 | - if (isset($options['loading_text'])) { |
|
| 195 | - $js_options['loadingText'] = $options['loading_text']; |
|
| 196 | - } |
|
| 197 | - if (isset($options['rows'])) { |
|
| 198 | - $js_options['rows'] = $options['rows']; |
|
| 199 | - } |
|
| 200 | - if (isset($options['cols'])) { |
|
| 201 | - $js_options['cols'] = $options['cols']; |
|
| 202 | - } |
|
| 203 | - if (isset($options['size'])) { |
|
| 204 | - $js_options['size'] = $options['size']; |
|
| 205 | - } |
|
| 206 | - if (isset($options['external_control'])) { |
|
| 207 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 208 | - } |
|
| 209 | - if (isset($options['load_text_url'])) { |
|
| 210 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 211 | - } |
|
| 212 | - if (isset($options['options'])) { |
|
| 213 | - $js_options['ajaxOptions'] = $options['options']; |
|
| 214 | - } |
|
| 215 | - if (isset($options['script'])) { |
|
| 216 | - $js_options['evalScripts'] = $options['script']; |
|
| 217 | - } |
|
| 218 | - if (isset($options['with'])) { |
|
| 219 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 223 | - if ($tag) { |
|
| 224 | - return $this->tag($function); |
|
| 225 | - } else { |
|
| 226 | - return $function; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param $object |
|
| 232 | - * @param null $tag_options |
|
| 233 | - * @param null $in_place_editor_options |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 237 | - { |
|
| 238 | - $ret_val = ''; |
|
| 239 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 240 | - $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 241 | - |
|
| 242 | - return $ret_val; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param $field_id |
|
| 247 | - * @param $options |
|
| 248 | - * @return mixed |
|
| 249 | - */ |
|
| 250 | - public function auto_complete_field($field_id, $options) |
|
| 251 | - { |
|
| 252 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 253 | - $function .= "'$field_id', "; |
|
| 254 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 255 | - $function .= "'" . $options['url'] . "'"; |
|
| 256 | - |
|
| 257 | - $js_options = []; |
|
| 258 | - if (isset($options['tokens'])) { |
|
| 259 | - $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 260 | - } |
|
| 261 | - if (isset($options['with'])) { |
|
| 262 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 263 | - } |
|
| 264 | - if (isset($options['indicator'])) { |
|
| 265 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 266 | - } |
|
| 267 | - if (isset($options['select'])) { |
|
| 268 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
|
| 272 | - if (isset($options[$var])) { |
|
| 273 | - $js_options['$val'] = $options['var']; |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 278 | - |
|
| 279 | - return $this->tag($function); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * @param $entries |
|
| 284 | - * @param $field |
|
| 285 | - * @param null $phrase |
|
| 286 | - */ |
|
| 287 | - public function auto_complete_results($entries, $field, $phrase = null) |
|
| 288 | - { |
|
| 289 | - if (!is_array($entries)) { |
|
| 290 | - return; |
|
| 291 | - } |
|
| 292 | - $ret_val = '<ul>'; |
|
| 293 | - // Complete this function |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @param $object |
|
| 298 | - * @param null $tag_options |
|
| 299 | - * @param null $completion_options |
|
| 300 | - * @return string |
|
| 301 | - */ |
|
| 302 | - public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 303 | - { |
|
| 304 | - $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 305 | - $ret_val .= '<input autocomplete="off" id="' |
|
| 306 | - . $object |
|
| 307 | - . '" name="' |
|
| 308 | - . $object |
|
| 309 | - . '" size="' |
|
| 310 | - . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 311 | - . '" type="text" value="' |
|
| 312 | - . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 313 | - . '" ' |
|
| 314 | - . (isset($tag_options['class']) ? 'class = "' |
|
| 315 | - . $tag_options['class'] |
|
| 316 | - . '" ' : '') |
|
| 317 | - . '>'; |
|
| 318 | - |
|
| 319 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 320 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 321 | - |
|
| 322 | - return $ret_val; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * @return string |
|
| 327 | - */ |
|
| 328 | - public function _auto_complete_stylesheet() |
|
| 329 | - { |
|
| 330 | - return '<style> div.auto_complete { |
|
| 18 | + public $TOGGLE_EFFECTS = ['toggle_appear', 'toggle_slide', 'toggle_blind']; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Scriptaculous constructor. |
|
| 22 | + */ |
|
| 23 | + public function __construct() |
|
| 24 | + { |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param $element_id |
|
| 29 | + * @param null $options |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function dragable_element($element_id, $options = null) |
|
| 33 | + { |
|
| 34 | + return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param $element_id |
|
| 39 | + * @param null $options |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function drop_receiving_element($element_id, $options = null) |
|
| 43 | + { |
|
| 44 | + return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param $name |
|
| 49 | + * @param bool $element_id |
|
| 50 | + * @param null $js_options |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | + { |
|
| 55 | + $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | + |
|
| 57 | + $js_queue = ''; |
|
| 58 | + if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | + } elseif (isset($js_options)) { |
|
| 60 | + $js_queue = "'$js_options'"; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | + return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | + } else { |
|
| 66 | + return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param $element_id |
|
| 72 | + * @param null $options |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function sortabe_element($element_id, $options = null) |
|
| 76 | + { |
|
| 77 | + return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | + // Private functions |
|
| 82 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param $element_id |
|
| 86 | + * @param $options |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function _sortabe_element($element_id, $options) |
|
| 90 | + { |
|
| 91 | + //if (isset($options['with'])) { |
|
| 92 | + $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 93 | + // } |
|
| 94 | + |
|
| 95 | + //if (isset($option['onUpdate'])) { |
|
| 96 | + $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 97 | + //} |
|
| 98 | + |
|
| 99 | + foreach ($options as $var => $val) { |
|
| 100 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 101 | + unset($options[$var]); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $arr = ['tag', 'overlap', 'contraint', 'handle']; |
|
| 106 | + |
|
| 107 | + foreach ($arr as $var) { |
|
| 108 | + if (isset($options[$var])) { |
|
| 109 | + $options[$var] = "'" . $options[$var] . "'"; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + if (isset($options['containment'])) { |
|
| 114 | + $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if (isset($options['only'])) { |
|
| 118 | + $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @param $element_id |
|
| 126 | + * @param $options |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function _dragable_element_js($element_id, $options) |
|
| 130 | + { |
|
| 131 | + return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @param $element_id |
|
| 136 | + * @param $options |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function _drop_receiving_element($element_id, $options) |
|
| 140 | + { |
|
| 141 | + |
|
| 142 | + //if (isset($options['with'])) { |
|
| 143 | + $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 144 | + // } |
|
| 145 | + |
|
| 146 | + //if (isset($option['onDrop'])) |
|
| 147 | + |
|
| 148 | + { |
|
| 149 | + $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (is_array($options)) { |
|
| 153 | + foreach ($options as $var => $val) { |
|
| 154 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 155 | + unset($options[$var]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if (isset($options['accept'])) { |
|
| 161 | + $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if (isset($options['hoverclass'])) { |
|
| 165 | + $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 172 | + // Merged Javascript macro |
|
| 173 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param $field_id |
|
| 177 | + * @param $options |
|
| 178 | + * @param bool $tag |
|
| 179 | + * @return string |
|
| 180 | + */ |
|
| 181 | + public function in_place_editor($field_id, $options, $tag = true) |
|
| 182 | + { |
|
| 183 | + $function = 'new Ajax.InPlaceEditor('; |
|
| 184 | + $function .= "'$field_id', "; |
|
| 185 | + $function .= "'" . $options['url'] . "'"; |
|
| 186 | + |
|
| 187 | + $js_options = []; |
|
| 188 | + if (isset($options['cancel_text'])) { |
|
| 189 | + $js_options['cancelText'] = $options['cancel_text']; |
|
| 190 | + } |
|
| 191 | + if (isset($options['save_text'])) { |
|
| 192 | + $js_options['okText'] = $options['save_text']; |
|
| 193 | + } |
|
| 194 | + if (isset($options['loading_text'])) { |
|
| 195 | + $js_options['loadingText'] = $options['loading_text']; |
|
| 196 | + } |
|
| 197 | + if (isset($options['rows'])) { |
|
| 198 | + $js_options['rows'] = $options['rows']; |
|
| 199 | + } |
|
| 200 | + if (isset($options['cols'])) { |
|
| 201 | + $js_options['cols'] = $options['cols']; |
|
| 202 | + } |
|
| 203 | + if (isset($options['size'])) { |
|
| 204 | + $js_options['size'] = $options['size']; |
|
| 205 | + } |
|
| 206 | + if (isset($options['external_control'])) { |
|
| 207 | + $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 208 | + } |
|
| 209 | + if (isset($options['load_text_url'])) { |
|
| 210 | + $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 211 | + } |
|
| 212 | + if (isset($options['options'])) { |
|
| 213 | + $js_options['ajaxOptions'] = $options['options']; |
|
| 214 | + } |
|
| 215 | + if (isset($options['script'])) { |
|
| 216 | + $js_options['evalScripts'] = $options['script']; |
|
| 217 | + } |
|
| 218 | + if (isset($options['with'])) { |
|
| 219 | + $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 223 | + if ($tag) { |
|
| 224 | + return $this->tag($function); |
|
| 225 | + } else { |
|
| 226 | + return $function; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param $object |
|
| 232 | + * @param null $tag_options |
|
| 233 | + * @param null $in_place_editor_options |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 237 | + { |
|
| 238 | + $ret_val = ''; |
|
| 239 | + $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 240 | + $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 241 | + |
|
| 242 | + return $ret_val; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param $field_id |
|
| 247 | + * @param $options |
|
| 248 | + * @return mixed |
|
| 249 | + */ |
|
| 250 | + public function auto_complete_field($field_id, $options) |
|
| 251 | + { |
|
| 252 | + $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 253 | + $function .= "'$field_id', "; |
|
| 254 | + $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 255 | + $function .= "'" . $options['url'] . "'"; |
|
| 256 | + |
|
| 257 | + $js_options = []; |
|
| 258 | + if (isset($options['tokens'])) { |
|
| 259 | + $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 260 | + } |
|
| 261 | + if (isset($options['with'])) { |
|
| 262 | + $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 263 | + } |
|
| 264 | + if (isset($options['indicator'])) { |
|
| 265 | + $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 266 | + } |
|
| 267 | + if (isset($options['select'])) { |
|
| 268 | + $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
|
| 272 | + if (isset($options[$var])) { |
|
| 273 | + $js_options['$val'] = $options['var']; |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 278 | + |
|
| 279 | + return $this->tag($function); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * @param $entries |
|
| 284 | + * @param $field |
|
| 285 | + * @param null $phrase |
|
| 286 | + */ |
|
| 287 | + public function auto_complete_results($entries, $field, $phrase = null) |
|
| 288 | + { |
|
| 289 | + if (!is_array($entries)) { |
|
| 290 | + return; |
|
| 291 | + } |
|
| 292 | + $ret_val = '<ul>'; |
|
| 293 | + // Complete this function |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @param $object |
|
| 298 | + * @param null $tag_options |
|
| 299 | + * @param null $completion_options |
|
| 300 | + * @return string |
|
| 301 | + */ |
|
| 302 | + public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 303 | + { |
|
| 304 | + $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 305 | + $ret_val .= '<input autocomplete="off" id="' |
|
| 306 | + . $object |
|
| 307 | + . '" name="' |
|
| 308 | + . $object |
|
| 309 | + . '" size="' |
|
| 310 | + . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 311 | + . '" type="text" value="' |
|
| 312 | + . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 313 | + . '" ' |
|
| 314 | + . (isset($tag_options['class']) ? 'class = "' |
|
| 315 | + . $tag_options['class'] |
|
| 316 | + . '" ' : '') |
|
| 317 | + . '>'; |
|
| 318 | + |
|
| 319 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 320 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 321 | + |
|
| 322 | + return $ret_val; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * @return string |
|
| 327 | + */ |
|
| 328 | + public function _auto_complete_stylesheet() |
|
| 329 | + { |
|
| 330 | + return '<style> div.auto_complete { |
|
| 331 | 331 | width: 350px; |
| 332 | 332 | background: #fff; |
| 333 | 333 | } |
@@ -351,5 +351,5 @@ discard block |
||
| 351 | 351 | padding:0; |
| 352 | 352 | } |
| 353 | 353 | </style>'; |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (in_array($name, $this->TOGGLE_EFFECTS)) { |
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 64 | + return "Effect.toggle($element,'".str_replace('toggle_', '', $name)."',".$this->_options_for_javascript($js_options).')'; |
|
| 65 | 65 | } else { |
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 66 | + return 'new Effect.'.ucwords($name)."($element,".$this->_options_for_javascript($js_options).')'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | // } |
| 94 | 94 | |
| 95 | 95 | //if (isset($option['onUpdate'])) { |
| 96 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 96 | + $options['onUpdate'] = 'function(){'.$this->remote_function($options).'}'; |
|
| 97 | 97 | //} |
| 98 | 98 | |
| 99 | 99 | foreach ($options as $var => $val) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | foreach ($arr as $var) { |
| 108 | 108 | if (isset($options[$var])) { |
| 109 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 109 | + $options[$var] = "'".$options[$var]."'"; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 121 | + return "Sortable.create('$element_id',".$this->_options_for_javascript($options).')'; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function _dragable_element_js($element_id, $options) |
| 130 | 130 | { |
| 131 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 131 | + return 'new Draggable(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | //if (isset($option['onDrop'])) |
| 147 | 147 | |
| 148 | 148 | { |
| 149 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 149 | + $options['onDrop'] = 'function(element){'.$this->remote_function($options).'}'; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if (is_array($options)) { |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (isset($options['hoverclass'])) { |
| 165 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 165 | + $options['hoverclass'] = "'".$options['hoverclass']."'"; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 168 | + return 'Droppables.add(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | ///////////////////////////////////////////////////////////////////////////////////// |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $function = 'new Ajax.InPlaceEditor('; |
| 184 | 184 | $function .= "'$field_id', "; |
| 185 | - $function .= "'" . $options['url'] . "'"; |
|
| 185 | + $function .= "'".$options['url']."'"; |
|
| 186 | 186 | |
| 187 | 187 | $js_options = []; |
| 188 | 188 | if (isset($options['cancel_text'])) { |
@@ -204,10 +204,10 @@ discard block |
||
| 204 | 204 | $js_options['size'] = $options['size']; |
| 205 | 205 | } |
| 206 | 206 | if (isset($options['external_control'])) { |
| 207 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 207 | + $js_options['externalControl'] = "'".$options['external_control']."'"; |
|
| 208 | 208 | } |
| 209 | 209 | if (isset($options['load_text_url'])) { |
| 210 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 210 | + $js_options['loadTextURL'] = "'".$options['load_text_url']."'"; |
|
| 211 | 211 | } |
| 212 | 212 | if (isset($options['options'])) { |
| 213 | 213 | $js_options['ajaxOptions'] = $options['options']; |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | $js_options['evalScripts'] = $options['script']; |
| 217 | 217 | } |
| 218 | 218 | if (isset($options['with'])) { |
| 219 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 219 | + $js_options['callback'] = 'function(form) { return '.$options['with'].' }'; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 222 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 223 | 223 | if ($tag) { |
| 224 | 224 | return $this->tag($function); |
| 225 | 225 | } else { |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
| 237 | 237 | { |
| 238 | 238 | $ret_val = ''; |
| 239 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 239 | + $ret_val .= '<span id="'.$object.'" class="in_place_editor_field">'.(isset($tag_options['value']) ? $tag_options['value'] : '').'</span>'; |
|
| 240 | 240 | $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
| 241 | 241 | |
| 242 | 242 | return $ret_val; |
@@ -249,23 +249,23 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function auto_complete_field($field_id, $options) |
| 251 | 251 | { |
| 252 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 252 | + $function = "var $field_id".'_auto_completer = new Ajax.Autocompleter('; |
|
| 253 | 253 | $function .= "'$field_id', "; |
| 254 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 255 | - $function .= "'" . $options['url'] . "'"; |
|
| 254 | + $function .= "'".(isset($options['update']) ? $options['update'] : $field_id.'_auto_complete')."', "; |
|
| 255 | + $function .= "'".$options['url']."'"; |
|
| 256 | 256 | |
| 257 | 257 | $js_options = []; |
| 258 | 258 | if (isset($options['tokens'])) { |
| 259 | 259 | $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
| 260 | 260 | } |
| 261 | 261 | if (isset($options['with'])) { |
| 262 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 262 | + $js_options['callback'] = 'function(element, value) { return '.$options['with'].' }'; |
|
| 263 | 263 | } |
| 264 | 264 | if (isset($options['indicator'])) { |
| 265 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 265 | + $js_options['indicator'] = "'".$options['indicator']."'"; |
|
| 266 | 266 | } |
| 267 | 267 | if (isset($options['select'])) { |
| 268 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 268 | + $js_options['select'] = "'".$options['select']."'"; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | foreach (['on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars'] as $var => $val) { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 277 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 278 | 278 | |
| 279 | 279 | return $this->tag($function); |
| 280 | 280 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | . '" ' : '') |
| 317 | 317 | . '>'; |
| 318 | 318 | |
| 319 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 319 | + $ret_val .= '<div id="'.$object.'_auto_complete" class="auto_complete"></div>'; |
|
| 320 | 320 | $ret_val .= $this->auto_complete_field($object, $completion_options); |
| 321 | 321 | |
| 322 | 322 | return $ret_val; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @param $javascript |
| 30 | - * @return mixed|string |
|
| 30 | + * @return string |
|
| 31 | 31 | */ |
| 32 | 32 | public function escape($javascript) |
| 33 | 33 | { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param $name |
| 51 | - * @param $function |
|
| 51 | + * @param string $function |
|
| 52 | 52 | * @param null $html_options |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function button_to_function($name, $function = null) |
| 24 | 24 | { |
| 25 | - return '<input type="button" value="' . $name . '" onclick="' . $function . '">'; |
|
| 25 | + return '<input type="button" value="'.$name.'" onclick="'.$function.'">'; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function tag($content) |
| 45 | 45 | { |
| 46 | - return '<script type="text/javascript">' . $content . '</script>'; |
|
| 46 | + return '<script type="text/javascript">'.$content.'</script>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function link_to_function($name, $function, $html_options = null) |
| 56 | 56 | { |
| 57 | - return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>'; |
|
| 57 | + return '<a href="'.(isset($html_options['href']) ? $html_options['href'] : '#').'" onclick="'.(isset($html_options['onclick']) ? $html_options['onclick'].';' : '').$function.'; return false;">'.$name.'</a>'; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | ///////////////////////////////////////////////////////////////////////////////////// |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $return_val .= $value; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return '[' . $return_val . ']'; |
|
| 79 | + return '['.$return_val.']'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return "'$option'"; |
@@ -99,6 +99,6 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - return '{' . $return_val . '}'; |
|
| 102 | + return '{'.$return_val.'}'; |
|
| 103 | 103 | } |
| 104 | 104 | } |
@@ -15,90 +15,90 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class JavaScript |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @param $name |
|
| 20 | - * @param null $function |
|
| 21 | - * @return string |
|
| 22 | - */ |
|
| 23 | - public function button_to_function($name, $function = null) |
|
| 24 | - { |
|
| 25 | - return '<input type="button" value="' . $name . '" onclick="' . $function . '">'; |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * @param $name |
|
| 20 | + * @param null $function |
|
| 21 | + * @return string |
|
| 22 | + */ |
|
| 23 | + public function button_to_function($name, $function = null) |
|
| 24 | + { |
|
| 25 | + return '<input type="button" value="' . $name . '" onclick="' . $function . '">'; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param $javascript |
|
| 30 | - * @return mixed|string |
|
| 31 | - */ |
|
| 32 | - public function escape($javascript) |
|
| 33 | - { |
|
| 34 | - $javascript = addslashes($javascript); |
|
| 35 | - $javascript = str_replace(["\r\n", "\n", "\r"], ["\n"], $javascript); |
|
| 28 | + /** |
|
| 29 | + * @param $javascript |
|
| 30 | + * @return mixed|string |
|
| 31 | + */ |
|
| 32 | + public function escape($javascript) |
|
| 33 | + { |
|
| 34 | + $javascript = addslashes($javascript); |
|
| 35 | + $javascript = str_replace(["\r\n", "\n", "\r"], ["\n"], $javascript); |
|
| 36 | 36 | |
| 37 | - return $javascript; |
|
| 38 | - } |
|
| 37 | + return $javascript; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param $content |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function tag($content) |
|
| 45 | - { |
|
| 46 | - return '<script type="text/javascript">' . $content . '</script>'; |
|
| 47 | - } |
|
| 40 | + /** |
|
| 41 | + * @param $content |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function tag($content) |
|
| 45 | + { |
|
| 46 | + return '<script type="text/javascript">' . $content . '</script>'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param $name |
|
| 51 | - * @param $function |
|
| 52 | - * @param null $html_options |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function link_to_function($name, $function, $html_options = null) |
|
| 56 | - { |
|
| 57 | - return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>'; |
|
| 58 | - } |
|
| 49 | + /** |
|
| 50 | + * @param $name |
|
| 51 | + * @param $function |
|
| 52 | + * @param null $html_options |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function link_to_function($name, $function, $html_options = null) |
|
| 56 | + { |
|
| 57 | + return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>'; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 61 | - // Private functions |
|
| 62 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 60 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 61 | + // Private functions |
|
| 62 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @param $option |
|
| 66 | - * @return string |
|
| 67 | - */ |
|
| 68 | - public function _array_or_string_for_javascript($option) |
|
| 69 | - { |
|
| 70 | - $return_val = ''; |
|
| 71 | - if (is_array($option)) { |
|
| 72 | - foreach ($option as $value) { |
|
| 73 | - if (!empty($return_val)) { |
|
| 74 | - $ret_val .= ', '; |
|
| 75 | - } |
|
| 76 | - $return_val .= $value; |
|
| 77 | - } |
|
| 64 | + /** |
|
| 65 | + * @param $option |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | + public function _array_or_string_for_javascript($option) |
|
| 69 | + { |
|
| 70 | + $return_val = ''; |
|
| 71 | + if (is_array($option)) { |
|
| 72 | + foreach ($option as $value) { |
|
| 73 | + if (!empty($return_val)) { |
|
| 74 | + $ret_val .= ', '; |
|
| 75 | + } |
|
| 76 | + $return_val .= $value; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return '[' . $return_val . ']'; |
|
| 80 | - } |
|
| 79 | + return '[' . $return_val . ']'; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - return "'$option'"; |
|
| 83 | - } |
|
| 82 | + return "'$option'"; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param $options |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function _options_for_javascript($options) |
|
| 90 | - { |
|
| 91 | - $return_val = ''; |
|
| 85 | + /** |
|
| 86 | + * @param $options |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function _options_for_javascript($options) |
|
| 90 | + { |
|
| 91 | + $return_val = ''; |
|
| 92 | 92 | |
| 93 | - if (is_array($options)) { |
|
| 94 | - foreach ($options as $var => $val) { |
|
| 95 | - if (!empty($return_val)) { |
|
| 96 | - $return_val .= ', '; |
|
| 97 | - } |
|
| 98 | - $return_val .= "$var:$val"; |
|
| 99 | - } |
|
| 100 | - } |
|
| 93 | + if (is_array($options)) { |
|
| 94 | + foreach ($options as $var => $val) { |
|
| 95 | + if (!empty($return_val)) { |
|
| 96 | + $return_val .= ', '; |
|
| 97 | + } |
|
| 98 | + $return_val .= "$var:$val"; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return '{' . $return_val . '}'; |
|
| 103 | - } |
|
| 102 | + return '{' . $return_val . '}'; |
|
| 103 | + } |
|
| 104 | 104 | } |