@@ -15,307 +15,307 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Scriptaculous extends Prototype |
| 17 | 17 | { |
| 18 | - public $TOGGLE_EFFECTS = array('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 = array('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 = array(); |
|
| 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 = array(); |
|
| 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 (array('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="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
| 306 | - |
|
| 307 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 308 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 309 | - |
|
| 310 | - return $ret_val; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * @return string |
|
| 315 | - */ |
|
| 316 | - public function _auto_complete_stylesheet() |
|
| 317 | - { |
|
| 318 | - return '<style> div.auto_complete { |
|
| 18 | + public $TOGGLE_EFFECTS = array('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 = array('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 = array(); |
|
| 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 = array(); |
|
| 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 (array('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="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
| 306 | + |
|
| 307 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 308 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 309 | + |
|
| 310 | + return $ret_val; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * @return string |
|
| 315 | + */ |
|
| 316 | + public function _auto_complete_stylesheet() |
|
| 317 | + { |
|
| 318 | + return '<style> div.auto_complete { |
|
| 319 | 319 | width: 350px; |
| 320 | 320 | background: #fff; |
| 321 | 321 | } |
@@ -339,5 +339,5 @@ discard block |
||
| 339 | 339 | padding:0; |
| 340 | 340 | } |
| 341 | 341 | </style>'; |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 10 | 10 | |
| 11 | 11 | if (!defined('SMARTOBJECT_URL')) { |
| 12 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
| 12 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
| 13 | 13 | } |
| 14 | 14 | include_once(SMARTOBJECT_ROOT_PATH . 'class/rating.php'); |
| 15 | 15 | include_once(SMARTOBJECT_ROOT_PATH . 'include/functions.php'); |
@@ -23,53 +23,53 @@ discard block |
||
| 23 | 23 | $smartobjectPluginHandler = new SmartPluginHandler(); |
| 24 | 24 | $pluginObj = $smartobjectPluginHandler->getPlugin($module_dirname); |
| 25 | 25 | if ($pluginObj) { |
| 26 | - $rating_item = $pluginObj->getItem(); |
|
| 27 | - if ($rating_item) { |
|
| 28 | - $rating_itemid = $pluginObj->getItemIdForItem($rating_item); |
|
| 29 | - $stats = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item); |
|
| 30 | - $xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']); |
|
| 31 | - $xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']); |
|
| 32 | - $xoopsTpl->assign('smartobject_rating_item', $rating_item); |
|
| 33 | - if (is_object($xoopsUser)) { |
|
| 34 | - $ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid')); |
|
| 35 | - $xoopsTpl->assign('smartobject_user_can_rate', true); |
|
| 36 | - } |
|
| 37 | - if (isset($ratingObj) && is_object($ratingObj)) { |
|
| 38 | - $xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate')); |
|
| 39 | - $xoopsTpl->assign('smartobject_rated', true); |
|
| 40 | - } else { |
|
| 41 | - $xoopsTpl->assign('smartobject_rating_dirname', $module_dirname); |
|
| 42 | - $xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid); |
|
| 43 | - $urls = smart_getCurrentUrls(); |
|
| 44 | - $xoopsTpl->assign('smartobject_rating_current_page', $urls['full']); |
|
| 45 | - if (isset($xoTheme) && is_object($xoTheme)) { |
|
| 46 | - $xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
| 47 | - } else { |
|
| 48 | - //probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme |
|
| 49 | - //$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css' />"); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 26 | + $rating_item = $pluginObj->getItem(); |
|
| 27 | + if ($rating_item) { |
|
| 28 | + $rating_itemid = $pluginObj->getItemIdForItem($rating_item); |
|
| 29 | + $stats = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item); |
|
| 30 | + $xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']); |
|
| 31 | + $xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']); |
|
| 32 | + $xoopsTpl->assign('smartobject_rating_item', $rating_item); |
|
| 33 | + if (is_object($xoopsUser)) { |
|
| 34 | + $ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid')); |
|
| 35 | + $xoopsTpl->assign('smartobject_user_can_rate', true); |
|
| 36 | + } |
|
| 37 | + if (isset($ratingObj) && is_object($ratingObj)) { |
|
| 38 | + $xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate')); |
|
| 39 | + $xoopsTpl->assign('smartobject_rated', true); |
|
| 40 | + } else { |
|
| 41 | + $xoopsTpl->assign('smartobject_rating_dirname', $module_dirname); |
|
| 42 | + $xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid); |
|
| 43 | + $urls = smart_getCurrentUrls(); |
|
| 44 | + $xoopsTpl->assign('smartobject_rating_current_page', $urls['full']); |
|
| 45 | + if (isset($xoTheme) && is_object($xoTheme)) { |
|
| 46 | + $xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
| 47 | + } else { |
|
| 48 | + //probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme |
|
| 49 | + //$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css' />"); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if (isset($_POST['smartobject_rating_submit'])) { |
| 56 | - // The rating form has just been posted. Let's save the info |
|
| 57 | - $ratingObj = $smartobjectRatingHandler->create(); |
|
| 58 | - $ratingObj->setVar('dirname', $module_dirname); |
|
| 59 | - $ratingObj->setVar('item', $rating_item); |
|
| 60 | - $ratingObj->setVar('itemid', $rating_itemid); |
|
| 61 | - $ratingObj->setVar('uid', $xoopsUser->getVar('uid')); |
|
| 62 | - $ratingObj->setVar('date', time()); |
|
| 63 | - $ratingObj->setVar('rate', $_POST['smartobject_rating_value']); |
|
| 64 | - if (!$smartobjectRatingHandler->insert($ratingObj)) { |
|
| 65 | - if ($xoopsDB->errno() == 1062) { |
|
| 66 | - $message = _SOBJECT_RATING_DUPLICATE_ENTRY; |
|
| 67 | - } else { |
|
| 68 | - $message = _SOBJECT_RATING_ERROR; |
|
| 69 | - } |
|
| 70 | - } else { |
|
| 71 | - $message = _SOBJECT_RATING_SUCCESS; |
|
| 72 | - } |
|
| 73 | - redirect_header('', 3, $message); |
|
| 74 | - exit; |
|
| 56 | + // The rating form has just been posted. Let's save the info |
|
| 57 | + $ratingObj = $smartobjectRatingHandler->create(); |
|
| 58 | + $ratingObj->setVar('dirname', $module_dirname); |
|
| 59 | + $ratingObj->setVar('item', $rating_item); |
|
| 60 | + $ratingObj->setVar('itemid', $rating_itemid); |
|
| 61 | + $ratingObj->setVar('uid', $xoopsUser->getVar('uid')); |
|
| 62 | + $ratingObj->setVar('date', time()); |
|
| 63 | + $ratingObj->setVar('rate', $_POST['smartobject_rating_value']); |
|
| 64 | + if (!$smartobjectRatingHandler->insert($ratingObj)) { |
|
| 65 | + if ($xoopsDB->errno() == 1062) { |
|
| 66 | + $message = _SOBJECT_RATING_DUPLICATE_ENTRY; |
|
| 67 | + } else { |
|
| 68 | + $message = _SOBJECT_RATING_ERROR; |
|
| 69 | + } |
|
| 70 | + } else { |
|
| 71 | + $message = _SOBJECT_RATING_SUCCESS; |
|
| 72 | + } |
|
| 73 | + redirect_header('', 3, $message); |
|
| 74 | + exit; |
|
| 75 | 75 | } |
@@ -10,16 +10,16 @@ |
||
| 10 | 10 | |
| 11 | 11 | function smart_customtag_initiate() |
| 12 | 12 | { |
| 13 | - global $xoopsTpl, $smartobjectCustomtagHandler; |
|
| 14 | - if (is_object($xoopsTpl)) { |
|
| 15 | - foreach ($smartobjectCustomtagHandler->objects as $k => $v) { |
|
| 16 | - $xoopsTpl->assign($k, $v->render()); |
|
| 17 | - } |
|
| 18 | - } |
|
| 13 | + global $xoopsTpl, $smartobjectCustomtagHandler; |
|
| 14 | + if (is_object($xoopsTpl)) { |
|
| 15 | + foreach ($smartobjectCustomtagHandler->objects as $k => $v) { |
|
| 16 | + $xoopsTpl->assign($k, $v->render()); |
|
| 17 | + } |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if (!defined('SMARTOBJECT_URL')) { |
| 22 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
| 22 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | smart_loadLanguageFile('smartobject', 'customtag'); |
@@ -14,15 +14,15 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | if (!class_exists('Projax')) { |
| 17 | - include __DIR__ . '/classes/JavaScript.php'; |
|
| 18 | - include 'classes/Prototype.php'; |
|
| 19 | - include 'classes/Scriptaculous.php'; |
|
| 17 | + include __DIR__ . '/classes/JavaScript.php'; |
|
| 18 | + include 'classes/Prototype.php'; |
|
| 19 | + include 'classes/Scriptaculous.php'; |
|
| 20 | 20 | |
| 21 | - // For $projax = new Projax(); |
|
| 22 | - /** |
|
| 23 | - * Class projax |
|
| 24 | - */ |
|
| 25 | - class projax extends Scriptaculous |
|
| 26 | - { |
|
| 27 | - } |
|
| 21 | + // For $projax = new Projax(); |
|
| 22 | + /** |
|
| 23 | + * Class projax |
|
| 24 | + */ |
|
| 25 | + class projax extends Scriptaculous |
|
| 26 | + { |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -15,310 +15,310 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Scriptaculous extends Prototype |
| 17 | 17 | { |
| 18 | - public $TOGGLE_EFFECTS = array('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 = array('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 = array(); |
|
| 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 = array(); |
|
| 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 (array('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="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
| 309 | - |
|
| 310 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 311 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 312 | - |
|
| 313 | - return $ret_val; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * @return string |
|
| 318 | - */ |
|
| 319 | - public function _auto_complete_stylesheet() |
|
| 320 | - { |
|
| 321 | - return '<style> div.auto_complete { |
|
| 18 | + public $TOGGLE_EFFECTS = array('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 = array('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 = array(); |
|
| 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 = array(); |
|
| 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 (array('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="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
| 309 | + |
|
| 310 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 311 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 312 | + |
|
| 313 | + return $ret_val; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * @return string |
|
| 318 | + */ |
|
| 319 | + public function _auto_complete_stylesheet() |
|
| 320 | + { |
|
| 321 | + return '<style> div.auto_complete { |
|
| 322 | 322 | width: 350px; |
| 323 | 323 | background: #fff; |
| 324 | 324 | } |
@@ -342,5 +342,5 @@ discard block |
||
| 342 | 342 | padding:0; |
| 343 | 343 | } |
| 344 | 344 | </style>'; |
| 345 | - } |
|
| 345 | + } |
|
| 346 | 346 | } |
@@ -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 | } |
@@ -9,66 +9,66 @@ |
||
| 9 | 9 | |
| 10 | 10 | class SmartAddto |
| 11 | 11 | { |
| 12 | - public $_layout; |
|
| 13 | - public $_method; |
|
| 12 | + public $_layout; |
|
| 13 | + public $_method; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Constructor of SmartAddTo |
|
| 17 | - * |
|
| 18 | - * @param int $layout 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical with icons, 3=Vertical no icons |
|
| 19 | - * @param int $method 0=directpage, 1=popup |
|
| 20 | - */ |
|
| 21 | - public function __construct($layout = 0, $method = 1) |
|
| 22 | - { |
|
| 23 | - $layout = (int)$layout; |
|
| 24 | - if ($layout < 0 || $layout > 3) { |
|
| 25 | - $layout = 0; |
|
| 26 | - } |
|
| 27 | - $this->_layout = $layout; |
|
| 15 | + /** |
|
| 16 | + * Constructor of SmartAddTo |
|
| 17 | + * |
|
| 18 | + * @param int $layout 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical with icons, 3=Vertical no icons |
|
| 19 | + * @param int $method 0=directpage, 1=popup |
|
| 20 | + */ |
|
| 21 | + public function __construct($layout = 0, $method = 1) |
|
| 22 | + { |
|
| 23 | + $layout = (int)$layout; |
|
| 24 | + if ($layout < 0 || $layout > 3) { |
|
| 25 | + $layout = 0; |
|
| 26 | + } |
|
| 27 | + $this->_layout = $layout; |
|
| 28 | 28 | |
| 29 | - $method = (int)$method; |
|
| 30 | - if ($method < 0 || $method > 1) { |
|
| 31 | - $method = 1; |
|
| 32 | - } |
|
| 33 | - $this->_method = $method; |
|
| 34 | - } |
|
| 29 | + $method = (int)$method; |
|
| 30 | + if ($method < 0 || $method > 1) { |
|
| 31 | + $method = 1; |
|
| 32 | + } |
|
| 33 | + $this->_method = $method; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param bool $fetchOnly |
|
| 38 | - * @return mixed|string|void |
|
| 39 | - */ |
|
| 40 | - public function render($fetchOnly = false) |
|
| 41 | - { |
|
| 42 | - global $xoTheme, $xoopsTpl; |
|
| 36 | + /** |
|
| 37 | + * @param bool $fetchOnly |
|
| 38 | + * @return mixed|string|void |
|
| 39 | + */ |
|
| 40 | + public function render($fetchOnly = false) |
|
| 41 | + { |
|
| 42 | + global $xoTheme, $xoopsTpl; |
|
| 43 | 43 | |
| 44 | - $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css'); |
|
| 44 | + $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css'); |
|
| 45 | 45 | |
| 46 | - $xoopsTpl->assign('smartobject_addto_method', $this->_method); |
|
| 47 | - $xoopsTpl->assign('smartobject_addto_layout', $this->_layout); |
|
| 46 | + $xoopsTpl->assign('smartobject_addto_method', $this->_method); |
|
| 47 | + $xoopsTpl->assign('smartobject_addto_layout', $this->_layout); |
|
| 48 | 48 | |
| 49 | - $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/'); |
|
| 49 | + $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/'); |
|
| 50 | 50 | |
| 51 | - if ($fetchOnly) { |
|
| 52 | - return $xoopsTpl->fetch('db:smartobject_addto.tpl'); |
|
| 53 | - } else { |
|
| 54 | - $xoopsTpl->display('db:smartobject_addto.tpl'); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($fetchOnly) { |
|
| 52 | + return $xoopsTpl->fetch('db:smartobject_addto.tpl'); |
|
| 53 | + } else { |
|
| 54 | + $xoopsTpl->display('db:smartobject_addto.tpl'); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @return array |
|
| 60 | - */ |
|
| 61 | - public function renderForBlock() |
|
| 62 | - { |
|
| 63 | - global $xoTheme; |
|
| 58 | + /** |
|
| 59 | + * @return array |
|
| 60 | + */ |
|
| 61 | + public function renderForBlock() |
|
| 62 | + { |
|
| 63 | + global $xoTheme; |
|
| 64 | 64 | |
| 65 | - $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css'); |
|
| 65 | + $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css'); |
|
| 66 | 66 | |
| 67 | - $block = array(); |
|
| 68 | - $block['smartobject_addto_method'] = $this->_method; |
|
| 69 | - $block['smartobject_addto_layout'] = $this->_layout; |
|
| 70 | - $block['smartobject_addto_url'] = SMARTOBJECT_URL . 'include/addto/'; |
|
| 67 | + $block = array(); |
|
| 68 | + $block['smartobject_addto_method'] = $this->_method; |
|
| 69 | + $block['smartobject_addto_layout'] = $this->_layout; |
|
| 70 | + $block['smartobject_addto_url'] = SMARTOBJECT_URL . 'include/addto/'; |
|
| 71 | 71 | |
| 72 | - return $block; |
|
| 73 | - } |
|
| 72 | + return $block; |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -10,45 +10,45 @@ |
||
| 10 | 10 | |
| 11 | 11 | class SmartTip |
| 12 | 12 | { |
| 13 | - public $id; |
|
| 14 | - public $caption; |
|
| 15 | - public $message; |
|
| 16 | - public $visible; |
|
| 17 | - public $_tpl; |
|
| 13 | + public $id; |
|
| 14 | + public $caption; |
|
| 15 | + public $message; |
|
| 16 | + public $visible; |
|
| 17 | + public $_tpl; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * SmartTip constructor. |
|
| 21 | - * @param $id |
|
| 22 | - * @param $caption |
|
| 23 | - * @param $message |
|
| 24 | - * @param bool $visible |
|
| 25 | - */ |
|
| 26 | - public function __construct($id, $caption, $message, $visible = false) |
|
| 27 | - { |
|
| 28 | - $this->id = $id; |
|
| 29 | - $this->caption = $caption; |
|
| 30 | - $this->message = $message; |
|
| 31 | - $this->visible = $visible; |
|
| 32 | - $this->_tpl = new XoopsTpl(); |
|
| 33 | - } |
|
| 19 | + /** |
|
| 20 | + * SmartTip constructor. |
|
| 21 | + * @param $id |
|
| 22 | + * @param $caption |
|
| 23 | + * @param $message |
|
| 24 | + * @param bool $visible |
|
| 25 | + */ |
|
| 26 | + public function __construct($id, $caption, $message, $visible = false) |
|
| 27 | + { |
|
| 28 | + $this->id = $id; |
|
| 29 | + $this->caption = $caption; |
|
| 30 | + $this->message = $message; |
|
| 31 | + $this->visible = $visible; |
|
| 32 | + $this->_tpl = new XoopsTpl(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param bool $outputNow |
|
| 37 | - * @return mixed|string|void |
|
| 38 | - */ |
|
| 39 | - public function render($outputNow = true) |
|
| 40 | - { |
|
| 41 | - $aTip = array( |
|
| 42 | - 'id' => $this->id, |
|
| 43 | - 'caption' => $this->caption, |
|
| 44 | - 'message' => $this->message, |
|
| 45 | - 'visible' => $this->visible ? 'block' : 'none' |
|
| 46 | - ); |
|
| 47 | - $this->_tpl->assign('tip', $aTip); |
|
| 48 | - if ($outputNow) { |
|
| 49 | - $this->_tpl->display('db:smartobject_tip.tpl'); |
|
| 50 | - } else { |
|
| 51 | - return $this->_tpl->fetch('db:smartobject_tip.tpl'); |
|
| 52 | - } |
|
| 53 | - } |
|
| 35 | + /** |
|
| 36 | + * @param bool $outputNow |
|
| 37 | + * @return mixed|string|void |
|
| 38 | + */ |
|
| 39 | + public function render($outputNow = true) |
|
| 40 | + { |
|
| 41 | + $aTip = array( |
|
| 42 | + 'id' => $this->id, |
|
| 43 | + 'caption' => $this->caption, |
|
| 44 | + 'message' => $this->message, |
|
| 45 | + 'visible' => $this->visible ? 'block' : 'none' |
|
| 46 | + ); |
|
| 47 | + $this->_tpl->assign('tip', $aTip); |
|
| 48 | + if ($outputNow) { |
|
| 49 | + $this->_tpl->display('db:smartobject_tip.tpl'); |
|
| 50 | + } else { |
|
| 51 | + return $this->_tpl->fetch('db:smartobject_tip.tpl'); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -9,17 +9,17 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class SmartObjectTree extends XoopsObjectTree |
| 11 | 11 | { |
| 12 | - public function _initialize() |
|
| 13 | - { |
|
| 14 | - foreach (array_keys($this->_objects) as $i) { |
|
| 15 | - $key1 = $this->_objects[$i]->getVar($this->_myId); |
|
| 16 | - $this->_tree[$key1]['obj'] = $this->_objects[$i]; |
|
| 17 | - $key2 = $this->_objects[$i]->getVar($this->_parentId, 'e'); |
|
| 18 | - $this->_tree[$key1]['parent'] = $key2; |
|
| 19 | - $this->_tree[$key2]['child'][] = $key1; |
|
| 20 | - if (isset($this->_rootId)) { |
|
| 21 | - $this->_tree[$key1]['root'] = $this->_objects[$i]->getVar($this->_rootId); |
|
| 22 | - } |
|
| 23 | - } |
|
| 24 | - } |
|
| 12 | + public function _initialize() |
|
| 13 | + { |
|
| 14 | + foreach (array_keys($this->_objects) as $i) { |
|
| 15 | + $key1 = $this->_objects[$i]->getVar($this->_myId); |
|
| 16 | + $this->_tree[$key1]['obj'] = $this->_objects[$i]; |
|
| 17 | + $key2 = $this->_objects[$i]->getVar($this->_parentId, 'e'); |
|
| 18 | + $this->_tree[$key1]['parent'] = $key2; |
|
| 19 | + $this->_tree[$key2]['child'][] = $key1; |
|
| 20 | + if (isset($this->_rootId)) { |
|
| 21 | + $this->_tree[$key1]['root'] = $this->_objects[$i]->getVar($this->_rootId); |
|
| 22 | + } |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | } |