1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | define('DC_AUTH_PAGE','auth.php'); |
---|
15 | |
---|
16 | class dcPage |
---|
17 | { |
---|
18 | private static $loaded_js=array(); |
---|
19 | |
---|
20 | # Auth check |
---|
21 | public static function check($permissions) |
---|
22 | { |
---|
23 | global $core; |
---|
24 | |
---|
25 | if ($core->blog && $core->auth->check($permissions,$core->blog->id)) |
---|
26 | { |
---|
27 | return; |
---|
28 | } |
---|
29 | |
---|
30 | if (session_id()) { |
---|
31 | $core->session->destroy(); |
---|
32 | } |
---|
33 | http::redirect(DC_AUTH_PAGE); |
---|
34 | } |
---|
35 | |
---|
36 | # Check super admin |
---|
37 | public static function checkSuper() |
---|
38 | { |
---|
39 | global $core; |
---|
40 | |
---|
41 | if (!$core->auth->isSuperAdmin()) |
---|
42 | { |
---|
43 | if (session_id()) { |
---|
44 | $core->session->destroy(); |
---|
45 | } |
---|
46 | http::redirect(DC_AUTH_PAGE); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | # Top of admin page |
---|
51 | public static function open($title='',$head='',$popup=false) |
---|
52 | { |
---|
53 | global $core, $_ctx; |
---|
54 | |
---|
55 | $_ctx->popup = (boolean) $popup; |
---|
56 | $_ctx->page_header = $head; |
---|
57 | $_ctx->fillPageTitle($title); |
---|
58 | |
---|
59 | ob_start(); |
---|
60 | } |
---|
61 | |
---|
62 | public static function close() |
---|
63 | { |
---|
64 | $res = ob_get_contents(); |
---|
65 | ob_end_clean(); |
---|
66 | |
---|
67 | global $core, $_ctx; |
---|
68 | |
---|
69 | if ($core->error->flag()) { |
---|
70 | foreach($core->error->getErrors() as $e) { |
---|
71 | $_ctx->addError($e); |
---|
72 | } |
---|
73 | } |
---|
74 | $_ctx->page_content = $res; |
---|
75 | $core->tpl->display('page_layout.html.twig'); |
---|
76 | } |
---|
77 | |
---|
78 | public static function openPopup($title='',$head='') |
---|
79 | { |
---|
80 | self::open($title,$head,true); |
---|
81 | } |
---|
82 | |
---|
83 | public static function closePopup() |
---|
84 | { |
---|
85 | self::close(); |
---|
86 | } |
---|
87 | |
---|
88 | public static function message($msg,$timestamp=true,$div=false,$echo=true) |
---|
89 | { |
---|
90 | global $core; |
---|
91 | |
---|
92 | $res = ''; |
---|
93 | if ($msg != '') { |
---|
94 | $res = ($div ? '<div class="message">' : '').'<p'.($div ? '' : ' class="message"').'>'. |
---|
95 | ($timestamp ? dt::str(__('%H:%M:%S:'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. |
---|
96 | '</p>'.($div ? '</div>' : ''); |
---|
97 | if ($echo) { |
---|
98 | echo $res; |
---|
99 | } |
---|
100 | } |
---|
101 | return $res; |
---|
102 | } |
---|
103 | |
---|
104 | public static function help($page,$index='') |
---|
105 | { |
---|
106 | # Deprecated but we keep this for plugins. |
---|
107 | } |
---|
108 | |
---|
109 | public static function helpBlock() |
---|
110 | { |
---|
111 | $args = func_get_args(); |
---|
112 | if (empty($args)) { |
---|
113 | return; |
---|
114 | }; |
---|
115 | |
---|
116 | global $__resources; |
---|
117 | if (empty($__resources['help'])) { |
---|
118 | return; |
---|
119 | } |
---|
120 | |
---|
121 | $content = ''; |
---|
122 | foreach ($args as $v) |
---|
123 | { |
---|
124 | if (is_object($v) && isset($v->content)) { |
---|
125 | $content .= $v->content; |
---|
126 | continue; |
---|
127 | } |
---|
128 | |
---|
129 | if (!isset($__resources['help'][$v])) { |
---|
130 | continue; |
---|
131 | } |
---|
132 | $f = $__resources['help'][$v]; |
---|
133 | if (!file_exists($f) || !is_readable($f)) { |
---|
134 | continue; |
---|
135 | } |
---|
136 | |
---|
137 | $fc = file_get_contents($f); |
---|
138 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
139 | $content .= $matches[1]; |
---|
140 | } else { |
---|
141 | $content .= $fc; |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | if (trim($content) == '') { |
---|
146 | return; |
---|
147 | } |
---|
148 | |
---|
149 | echo |
---|
150 | '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'. |
---|
151 | $content. |
---|
152 | '</div></div>'; |
---|
153 | } |
---|
154 | |
---|
155 | public static function jsLoad($src) |
---|
156 | { |
---|
157 | $escaped_src = html::escapeHTML($src); |
---|
158 | if (!isset(self::$loaded_js[$escaped_src])) { |
---|
159 | self::$loaded_js[$escaped_src]=true; |
---|
160 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | public static function jsVar($n,$v) |
---|
165 | { |
---|
166 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
167 | } |
---|
168 | |
---|
169 | public static function jsCommon() |
---|
170 | { |
---|
171 | return |
---|
172 | self::jsLoad('js/jquery/jquery.js'). |
---|
173 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
174 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
175 | self::jsLoad('js/jquery/jquery.constantfooter.js'). |
---|
176 | self::jsLoad('js/common.js'). |
---|
177 | self::jsLoad('js/prelude.js'). |
---|
178 | |
---|
179 | '<script type="text/javascript">'."\n". |
---|
180 | "//<![CDATA[\n". |
---|
181 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
182 | |
---|
183 | self::jsVar('dotclear.img_plus_src','images/expand.png'). |
---|
184 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
185 | self::jsVar('dotclear.img_minus_src','images/hide.png'). |
---|
186 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
187 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
188 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
189 | |
---|
190 | self::jsVar('dotclear.msg.help', |
---|
191 | __('help')). |
---|
192 | self::jsVar('dotclear.msg.no_selection', |
---|
193 | __('no selection')). |
---|
194 | self::jsVar('dotclear.msg.select_all', |
---|
195 | __('select all')). |
---|
196 | self::jsVar('dotclear.msg.invert_sel', |
---|
197 | __('invert selection')). |
---|
198 | self::jsVar('dotclear.msg.website', |
---|
199 | __('Web site:')). |
---|
200 | self::jsVar('dotclear.msg.email', |
---|
201 | __('Email:')). |
---|
202 | self::jsVar('dotclear.msg.ip_address', |
---|
203 | __('IP address:')). |
---|
204 | self::jsVar('dotclear.msg.error', |
---|
205 | __('Error:')). |
---|
206 | self::jsVar('dotclear.msg.entry_created', |
---|
207 | __('Entry has been successfully created.')). |
---|
208 | self::jsVar('dotclear.msg.edit_entry', |
---|
209 | __('Edit entry')). |
---|
210 | self::jsVar('dotclear.msg.view_entry', |
---|
211 | __('view entry')). |
---|
212 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
213 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
214 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
215 | __("Are you sure you want to delete this entry?")). |
---|
216 | self::jsVar('dotclear.msg.confirm_spam_delete', |
---|
217 | __('Are you sure you want to delete all spams?')). |
---|
218 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
219 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
220 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
221 | __('Are you sure you want to delete this comment?')). |
---|
222 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
223 | __('Users with posts cannot be deleted.')). |
---|
224 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
225 | __('Are you sure you want to delete selected users (%s)?')). |
---|
226 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
227 | __('Are you sure you want to delete category "%s"?')). |
---|
228 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
229 | __('Are you sure you want to reorder all categories?')). |
---|
230 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
231 | __('Are you sure you want to remove media "%s"?')). |
---|
232 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
233 | __('Are you sure you want to extract archive in current directory?')). |
---|
234 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
235 | __('Are you sure you want to remove attachment "%s"?')). |
---|
236 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
237 | __('Are you sure you want to delete "%s" language?')). |
---|
238 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
239 | __('Are you sure you want to delete "%s" plugin?')). |
---|
240 | self::jsVar('dotclear.msg.use_this_theme', |
---|
241 | __('Use this theme')). |
---|
242 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
243 | __('Remove this theme')). |
---|
244 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
245 | __('Are you sure you want to delete "%s" theme?')). |
---|
246 | self::jsVar('dotclear.msg.zip_file_content', |
---|
247 | __('Zip file content')). |
---|
248 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
249 | __('XHTML markup validator')). |
---|
250 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
251 | __('XHTML content is valid.')). |
---|
252 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
253 | __('There are XHTML markup errors.')). |
---|
254 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
255 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
256 | self::jsVar('dotclear.msg.load_enhanced_uploader', |
---|
257 | __('Loading enhanced uploader, please wait.')). |
---|
258 | "\n//]]>\n". |
---|
259 | "</script>\n"; |
---|
260 | } |
---|
261 | |
---|
262 | public static function jsLoadIE7() |
---|
263 | { |
---|
264 | return |
---|
265 | '<!--[if lt IE 8]>'."\n". |
---|
266 | self::jsLoad('js/ie7/IE8.js'). |
---|
267 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". |
---|
268 | '<![endif]-->'."\n"; |
---|
269 | } |
---|
270 | |
---|
271 | public static function jsConfirmClose() |
---|
272 | { |
---|
273 | $args = func_get_args(); |
---|
274 | if (count($args) > 0) { |
---|
275 | foreach ($args as $k => $v) { |
---|
276 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
277 | } |
---|
278 | $args = implode(',',$args); |
---|
279 | } else { |
---|
280 | $args = ''; |
---|
281 | } |
---|
282 | |
---|
283 | return |
---|
284 | self::jsLoad('js/confirm-close.js'). |
---|
285 | '<script type="text/javascript">'."\n". |
---|
286 | "//<![CDATA[\n". |
---|
287 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
288 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
289 | "\n//]]>\n". |
---|
290 | "</script>\n"; |
---|
291 | } |
---|
292 | |
---|
293 | public static function jsPageTabs($default=null) |
---|
294 | { |
---|
295 | if ($default) { |
---|
296 | $default = "'".html::escapeJS($default)."'"; |
---|
297 | } |
---|
298 | |
---|
299 | return |
---|
300 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
301 | '<script type="text/javascript">'."\n". |
---|
302 | "//<![CDATA[\n". |
---|
303 | "\$(function() {\n". |
---|
304 | " \$.pageTabs(".$default.");\n". |
---|
305 | "});\n". |
---|
306 | "\n//]]>\n". |
---|
307 | "</script>\n"; |
---|
308 | } |
---|
309 | |
---|
310 | public static function jsModal() |
---|
311 | { |
---|
312 | return |
---|
313 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". |
---|
314 | self::jsLoad('js/jquery/jquery.modal.js'). |
---|
315 | '<script type="text/javascript">'."\n". |
---|
316 | "//<![CDATA[\n". |
---|
317 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). |
---|
318 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). |
---|
319 | "\n//]]>\n". |
---|
320 | "</script>\n"; |
---|
321 | } |
---|
322 | |
---|
323 | public static function jsColorPicker() |
---|
324 | { |
---|
325 | return |
---|
326 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". |
---|
327 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
328 | self::jsLoad('js/color-picker.js'); |
---|
329 | } |
---|
330 | |
---|
331 | public static function jsDatePicker() |
---|
332 | { |
---|
333 | return |
---|
334 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". |
---|
335 | self::jsLoad('js/date-picker.js'). |
---|
336 | '<script type="text/javascript">'."\n". |
---|
337 | "//<![CDATA[\n". |
---|
338 | |
---|
339 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
340 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
341 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
342 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
343 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
344 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
345 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
346 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
347 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
348 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
349 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
350 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
351 | |
---|
352 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
353 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
354 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
355 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
356 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
357 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
358 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
359 | |
---|
360 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
361 | |
---|
362 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
363 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
364 | |
---|
365 | "\n//]]>\n". |
---|
366 | "</script>\n"; |
---|
367 | } |
---|
368 | |
---|
369 | public static function jsToolBar() |
---|
370 | { |
---|
371 | $res = |
---|
372 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. |
---|
373 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; |
---|
374 | |
---|
375 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
376 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; |
---|
377 | } |
---|
378 | |
---|
379 | $res .= |
---|
380 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. |
---|
381 | '<script type="text/javascript">'."\n". |
---|
382 | "//<![CDATA[\n". |
---|
383 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". |
---|
384 | "jsToolBar.prototype.iframe_css = '". |
---|
385 | 'body{'. |
---|
386 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
387 | 'color : #000;'. |
---|
388 | 'background: #f9f9f9;'. |
---|
389 | 'margin: 0;'. |
---|
390 | 'padding : 2px;'. |
---|
391 | 'border: none;'. |
---|
392 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
393 | '}'. |
---|
394 | 'pre, code, kbd, samp {'. |
---|
395 | 'font-family:"Courier New",Courier,monospace;'. |
---|
396 | 'font-size : 1.1em;'. |
---|
397 | '}'. |
---|
398 | 'code {'. |
---|
399 | 'color : #666;'. |
---|
400 | 'font-weight : bold;'. |
---|
401 | '}'. |
---|
402 | 'body > p:first-child {'. |
---|
403 | 'margin-top: 0;'. |
---|
404 | '}'. |
---|
405 | "'; ". |
---|
406 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". |
---|
407 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". |
---|
408 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". |
---|
409 | "jsToolBar.prototype.legend_msg = '". |
---|
410 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". |
---|
411 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". |
---|
412 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". |
---|
413 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". |
---|
414 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". |
---|
415 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". |
---|
416 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". |
---|
417 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". |
---|
418 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". |
---|
419 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". |
---|
420 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". |
---|
421 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". |
---|
422 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". |
---|
423 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". |
---|
424 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". |
---|
425 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". |
---|
426 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". |
---|
427 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". |
---|
428 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". |
---|
429 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". |
---|
430 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". |
---|
431 | |
---|
432 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". |
---|
433 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
434 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". |
---|
435 | |
---|
436 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". |
---|
437 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
438 | |
---|
439 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
440 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; |
---|
441 | |
---|
442 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
443 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; |
---|
444 | } |
---|
445 | |
---|
446 | $res .= |
---|
447 | "\n//]]>\n". |
---|
448 | "</script>\n"; |
---|
449 | |
---|
450 | return $res; |
---|
451 | } |
---|
452 | |
---|
453 | public static function jsCandyUpload($params=array(),$base_url=null) |
---|
454 | { |
---|
455 | if (!$base_url) { |
---|
456 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
457 | } |
---|
458 | |
---|
459 | $params = array_merge($params,array( |
---|
460 | 'sess_id='.session_id(), |
---|
461 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
462 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
463 | )); |
---|
464 | |
---|
465 | return |
---|
466 | '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n". |
---|
467 | self::jsLoad('js/jquery/jquery.candyUpload.js'). |
---|
468 | |
---|
469 | '<script type="text/javascript">'."\n". |
---|
470 | "//<![CDATA[\n". |
---|
471 | "dotclear.candyUpload = {};\n". |
---|
472 | self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Temporarily activate enhanced uploader')). |
---|
473 | self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Temporarily disable enhanced uploader')). |
---|
474 | self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). |
---|
475 | self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). |
---|
476 | self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')). |
---|
477 | self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
478 | self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')). |
---|
479 | self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')). |
---|
480 | self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')). |
---|
481 | self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')). |
---|
482 | self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')). |
---|
483 | self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')). |
---|
484 | self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')). |
---|
485 | self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')). |
---|
486 | self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')). |
---|
487 | self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')). |
---|
488 | self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')). |
---|
489 | self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')). |
---|
490 | self::jsVar('dotclear.candyUpload.base_url',$base_url). |
---|
491 | self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf'). |
---|
492 | self::jsVar('dotclear.candyUpload.params',implode('&',$params)). |
---|
493 | "\n//]]>\n". |
---|
494 | "</script>\n"; |
---|
495 | } |
---|
496 | |
---|
497 | public static function jsToolMan() |
---|
498 | { |
---|
499 | return |
---|
500 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. |
---|
501 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. |
---|
502 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. |
---|
503 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. |
---|
504 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. |
---|
505 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. |
---|
506 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; |
---|
507 | } |
---|
508 | |
---|
509 | public static function jsMetaEditor() |
---|
510 | { |
---|
511 | return |
---|
512 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; |
---|
513 | } |
---|
514 | } |
---|
515 | ?> |
---|