@@ -245,7 +245,7 @@ |
||
245 | 245 | /** |
246 | 246 | * @param $field_id |
247 | 247 | * @param $options |
248 | - * @return mixed |
|
248 | + * @return string |
|
249 | 249 | */ |
250 | 250 | public function auto_complete_field($field_id, $options) |
251 | 251 | { |
@@ -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,15 +9,15 @@ |
||
9 | 9 | |
10 | 10 | function smartobject_plugin_smartpartner() |
11 | 11 | { |
12 | - $pluginInfo = array(); |
|
12 | + $pluginInfo = array(); |
|
13 | 13 | |
14 | - $pluginInfo['items']['partner']['caption'] = 'Partner'; |
|
15 | - $pluginInfo['items']['partner']['url'] = 'partner.php?partnerid=%u'; |
|
16 | - $pluginInfo['items']['partner']['request'] = 'partnerid'; |
|
14 | + $pluginInfo['items']['partner']['caption'] = 'Partner'; |
|
15 | + $pluginInfo['items']['partner']['url'] = 'partner.php?partnerid=%u'; |
|
16 | + $pluginInfo['items']['partner']['request'] = 'partnerid'; |
|
17 | 17 | |
18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | - $pluginInfo['items']['category']['url'] = 'index.php?view_category_id=%u'; |
|
20 | - $pluginInfo['items']['category']['request'] = 'view_category_id'; |
|
18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | + $pluginInfo['items']['category']['url'] = 'index.php?view_category_id=%u'; |
|
20 | + $pluginInfo['items']['category']['request'] = 'view_category_id'; |
|
21 | 21 | |
22 | - return $pluginInfo; |
|
22 | + return $pluginInfo; |
|
23 | 23 | } |
@@ -9,15 +9,15 @@ |
||
9 | 9 | |
10 | 10 | function smartobject_plugin_smartsection() |
11 | 11 | { |
12 | - $pluginInfo = array(); |
|
12 | + $pluginInfo = array(); |
|
13 | 13 | |
14 | - $pluginInfo['items']['item']['caption'] = 'Article'; |
|
15 | - $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
16 | - $pluginInfo['items']['item']['request'] = 'itemid'; |
|
14 | + $pluginInfo['items']['item']['caption'] = 'Article'; |
|
15 | + $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
16 | + $pluginInfo['items']['item']['request'] = 'itemid'; |
|
17 | 17 | |
18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | - $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
20 | - $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | + $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
20 | + $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
21 | 21 | |
22 | - return $pluginInfo; |
|
22 | + return $pluginInfo; |
|
23 | 23 | } |
@@ -9,12 +9,12 @@ |
||
9 | 9 | |
10 | 10 | function smartobject_plugin_xcgal() |
11 | 11 | { |
12 | - global $xoopsConfig; |
|
12 | + global $xoopsConfig; |
|
13 | 13 | |
14 | - $pluginInfo = array(); |
|
15 | - $pluginInfo['items']['album']['caption'] = 'Album'; |
|
16 | - $pluginInfo['items']['item']['url'] = 'thumbnails.php?album=%u'; |
|
17 | - $pluginInfo['items']['item']['request'] = 'album'; |
|
14 | + $pluginInfo = array(); |
|
15 | + $pluginInfo['items']['album']['caption'] = 'Album'; |
|
16 | + $pluginInfo['items']['item']['url'] = 'thumbnails.php?album=%u'; |
|
17 | + $pluginInfo['items']['item']['request'] = 'album'; |
|
18 | 18 | |
19 | - return $pluginInfo; |
|
19 | + return $pluginInfo; |
|
20 | 20 | } |
@@ -9,15 +9,15 @@ |
||
9 | 9 | |
10 | 10 | function smartobject_plugin_smartshop() |
11 | 11 | { |
12 | - $pluginInfo = array(); |
|
12 | + $pluginInfo = array(); |
|
13 | 13 | |
14 | - $pluginInfo['items']['item']['caption'] = 'Item'; |
|
15 | - $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
16 | - $pluginInfo['items']['item']['request'] = 'itemid'; |
|
14 | + $pluginInfo['items']['item']['caption'] = 'Item'; |
|
15 | + $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
16 | + $pluginInfo['items']['item']['request'] = 'itemid'; |
|
17 | 17 | |
18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | - $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
20 | - $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
19 | + $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
20 | + $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
21 | 21 | |
22 | - return $pluginInfo; |
|
22 | + return $pluginInfo; |
|
23 | 23 | } |
@@ -9,17 +9,17 @@ |
||
9 | 9 | |
10 | 10 | function smartobject_plugin_smartband() |
11 | 11 | { |
12 | - global $xoopsConfig; |
|
13 | - include_once(XOOPS_ROOT_PATH . '/modules/smartband/language/' . $xoopsConfig['language'] . '/main.php'); |
|
12 | + global $xoopsConfig; |
|
13 | + include_once(XOOPS_ROOT_PATH . '/modules/smartband/language/' . $xoopsConfig['language'] . '/main.php'); |
|
14 | 14 | |
15 | - $pluginInfo = array(); |
|
16 | - $pluginInfo['items']['item']['caption'] = _MD_ARTALBUM_ITEM_CAP; |
|
17 | - $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
18 | - $pluginInfo['items']['item']['request'] = 'itemid'; |
|
15 | + $pluginInfo = array(); |
|
16 | + $pluginInfo['items']['item']['caption'] = _MD_ARTALBUM_ITEM_CAP; |
|
17 | + $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
18 | + $pluginInfo['items']['item']['request'] = 'itemid'; |
|
19 | 19 | |
20 | - $pluginInfo['items']['category']['caption'] = _MD_ARTALBUM_CATEGORY; |
|
21 | - $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
22 | - $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
20 | + $pluginInfo['items']['category']['caption'] = _MD_ARTALBUM_CATEGORY; |
|
21 | + $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
22 | + $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
23 | 23 | |
24 | - return $pluginInfo; |
|
24 | + return $pluginInfo; |
|
25 | 25 | } |
@@ -26,82 +26,82 @@ |
||
26 | 26 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
27 | 27 | |
28 | 28 | switch ($op) { |
29 | - case 'sendlink': |
|
30 | - |
|
31 | - include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
32 | - $controller = new SmartObjectController($smartobjectLinkHandler); |
|
33 | - |
|
34 | - $linkObj = $controller->storeSmartObject(); |
|
35 | - if ($linkObj->hasError()) { |
|
36 | - /** |
|
37 | - * @todo inform user and propose to close the window if a problem occured when saving the link |
|
38 | - */ |
|
39 | - } |
|
40 | - |
|
41 | - $xoopsMailer =& getMailer(); |
|
42 | - $xoopsMailer->useMail(); |
|
43 | - $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
44 | - |
|
45 | - $xoopsMailer->setTemplate('sendlink.tpl'); |
|
46 | - $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
47 | - $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
48 | - $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
49 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
50 | - $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
51 | - $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
52 | - $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
53 | - $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
54 | - $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
55 | - $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
56 | - |
|
57 | - if (!$xoopsMailer->send(true)) { |
|
58 | - $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br />' . $xoopsMailer->getErrors(true)); |
|
59 | - } else { |
|
60 | - $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
61 | - } |
|
62 | - |
|
63 | - break; |
|
64 | - |
|
65 | - default: |
|
66 | - if (isset($_GET['mid'])) { |
|
67 | - $mid = $_GET['mid']; |
|
68 | - } else { |
|
69 | - /** |
|
70 | - * @todo close the window if no mid is passed as GET |
|
71 | - */ |
|
72 | - } |
|
73 | - |
|
74 | - $hModule = xoops_getHandler('module'); |
|
75 | - $module = $hModule->get($mid); |
|
76 | - $linkObj->setVar('mid', $module->getVar('mid')); |
|
77 | - $linkObj->setVar('mid_name', $module->getVar('name')); |
|
78 | - |
|
79 | - if (isset($_GET['link'])) { |
|
80 | - $link = $_GET['link']; |
|
81 | - } else { |
|
82 | - /** |
|
83 | - * @todo close the window if no link is passed as GET |
|
84 | - */ |
|
85 | - } |
|
86 | - $linkObj->setVar('link', $link); |
|
87 | - |
|
88 | - if (is_object($xoopsUser)) { |
|
89 | - $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
90 | - $linkObj->setVar('from_name', $xoopsUser->getVar('name') != '' ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
91 | - $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
92 | - } |
|
93 | - |
|
94 | - $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
95 | - $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
96 | - $linkObj->setVar('date', time()); |
|
97 | - $linkObj->hideFieldFromForm(array('from_uid', 'to_uid', 'link', 'mid', 'mid_name')); |
|
98 | - |
|
99 | - $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
100 | - |
|
101 | - $form->assign($xoopsTpl); |
|
102 | - |
|
103 | - $xoopsTpl->assign('showform', true); |
|
104 | - break; |
|
29 | + case 'sendlink': |
|
30 | + |
|
31 | + include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
32 | + $controller = new SmartObjectController($smartobjectLinkHandler); |
|
33 | + |
|
34 | + $linkObj = $controller->storeSmartObject(); |
|
35 | + if ($linkObj->hasError()) { |
|
36 | + /** |
|
37 | + * @todo inform user and propose to close the window if a problem occured when saving the link |
|
38 | + */ |
|
39 | + } |
|
40 | + |
|
41 | + $xoopsMailer =& getMailer(); |
|
42 | + $xoopsMailer->useMail(); |
|
43 | + $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
44 | + |
|
45 | + $xoopsMailer->setTemplate('sendlink.tpl'); |
|
46 | + $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
47 | + $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
48 | + $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
49 | + $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
50 | + $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
51 | + $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
52 | + $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
53 | + $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
54 | + $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
55 | + $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
56 | + |
|
57 | + if (!$xoopsMailer->send(true)) { |
|
58 | + $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br />' . $xoopsMailer->getErrors(true)); |
|
59 | + } else { |
|
60 | + $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
61 | + } |
|
62 | + |
|
63 | + break; |
|
64 | + |
|
65 | + default: |
|
66 | + if (isset($_GET['mid'])) { |
|
67 | + $mid = $_GET['mid']; |
|
68 | + } else { |
|
69 | + /** |
|
70 | + * @todo close the window if no mid is passed as GET |
|
71 | + */ |
|
72 | + } |
|
73 | + |
|
74 | + $hModule = xoops_getHandler('module'); |
|
75 | + $module = $hModule->get($mid); |
|
76 | + $linkObj->setVar('mid', $module->getVar('mid')); |
|
77 | + $linkObj->setVar('mid_name', $module->getVar('name')); |
|
78 | + |
|
79 | + if (isset($_GET['link'])) { |
|
80 | + $link = $_GET['link']; |
|
81 | + } else { |
|
82 | + /** |
|
83 | + * @todo close the window if no link is passed as GET |
|
84 | + */ |
|
85 | + } |
|
86 | + $linkObj->setVar('link', $link); |
|
87 | + |
|
88 | + if (is_object($xoopsUser)) { |
|
89 | + $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
90 | + $linkObj->setVar('from_name', $xoopsUser->getVar('name') != '' ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
91 | + $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
92 | + } |
|
93 | + |
|
94 | + $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
95 | + $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
96 | + $linkObj->setVar('date', time()); |
|
97 | + $linkObj->hideFieldFromForm(array('from_uid', 'to_uid', 'link', 'mid', 'mid_name')); |
|
98 | + |
|
99 | + $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
100 | + |
|
101 | + $form->assign($xoopsTpl); |
|
102 | + |
|
103 | + $xoopsTpl->assign('showform', true); |
|
104 | + break; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $xoopsTpl->display('db:smartobject_sendlink.html'); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | echo '</head><body>'; |
22 | 22 | |
23 | 23 | $smartobjectLinkHandler = xoops_getModuleHandler('link', 'smartobject'); |
24 | -$linkObj = $smartobjectLinkHandler->create(); |
|
24 | +$linkObj = $smartobjectLinkHandler->create(); |
|
25 | 25 | |
26 | 26 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
27 | 27 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | } |
40 | 40 | |
41 | - $xoopsMailer =& getMailer(); |
|
41 | + $xoopsMailer = & getMailer(); |
|
42 | 42 | $xoopsMailer->useMail(); |
43 | 43 | $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
44 | 44 |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function smartobject_addto_show($options) |
10 | 10 | { |
11 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
12 | - include_once(SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php'); |
|
13 | - $smartaddto = new SmartAddTo($options[0]); |
|
14 | - $block = $smartaddto->renderForBlock(); |
|
11 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
12 | + include_once(SMARTOBJECT_ROOT_PATH . 'class/smartaddto.php'); |
|
13 | + $smartaddto = new SmartAddTo($options[0]); |
|
14 | + $block = $smartaddto->renderForBlock(); |
|
15 | 15 | |
16 | - return $block; |
|
16 | + return $block; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function smartobject_addto_edit($options) |
24 | 24 | { |
25 | - include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
25 | + include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
26 | 26 | |
27 | - $form = ''; |
|
27 | + $form = ''; |
|
28 | 28 | |
29 | - $layout_select = new XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]); |
|
30 | - $layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0); |
|
31 | - $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1); |
|
32 | - $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2); |
|
33 | - $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3); |
|
34 | - $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br />'; |
|
29 | + $layout_select = new XoopsFormSelect(_MB_SOBJECT_BLOCKS_ADDTO_LAYOUT, 'options[]', $options[0]); |
|
30 | + $layout_select->addOption(0, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION0); |
|
31 | + $layout_select->addOption(1, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION1); |
|
32 | + $layout_select->addOption(2, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION2); |
|
33 | + $layout_select->addOption(3, _MB_SOBJECT_BLOCKS_ADDTO_LAYOUT_OPTION3); |
|
34 | + $form .= $layout_select->getCaption() . ' ' . $layout_select->render() . '<br />'; |
|
35 | 35 | |
36 | - return $form; |
|
36 | + return $form; |
|
37 | 37 | } |
@@ -2,5 +2,5 @@ |
||
2 | 2 | |
3 | 3 | function smarthook_footer_start() |
4 | 4 | { |
5 | - // code... |
|
5 | + // code... |
|
6 | 6 | } |