1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 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 | # Auth check |
---|
19 | public static function check($permissions) |
---|
20 | { |
---|
21 | global $core; |
---|
22 | |
---|
23 | if ($core->blog && $core->auth->check($permissions,$core->blog->id)) |
---|
24 | { |
---|
25 | return; |
---|
26 | } |
---|
27 | |
---|
28 | if (session_id()) { |
---|
29 | $core->session->destroy(); |
---|
30 | } |
---|
31 | http::redirect(DC_AUTH_PAGE); |
---|
32 | } |
---|
33 | |
---|
34 | # Check super admin |
---|
35 | public static function checkSuper() |
---|
36 | { |
---|
37 | global $core; |
---|
38 | |
---|
39 | if (!$core->auth->isSuperAdmin()) |
---|
40 | { |
---|
41 | if (session_id()) { |
---|
42 | $core->session->destroy(); |
---|
43 | } |
---|
44 | http::redirect(DC_AUTH_PAGE); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | # Top of admin page |
---|
49 | public static function open($title='', $head='') |
---|
50 | { |
---|
51 | global $core; |
---|
52 | |
---|
53 | # List of user's blogs |
---|
54 | if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) |
---|
55 | { |
---|
56 | $blog_box = |
---|
57 | __('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. |
---|
58 | html::escapeHTML($core->blog->name).'</strong>'; |
---|
59 | |
---|
60 | if ($core->auth->blog_count > 20) { |
---|
61 | $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; |
---|
62 | } |
---|
63 | } |
---|
64 | else |
---|
65 | { |
---|
66 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); |
---|
67 | $blogs = array(); |
---|
68 | while ($rs_blogs->fetch()) { |
---|
69 | $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; |
---|
70 | } |
---|
71 | $blog_box = |
---|
72 | __('Blogs:').' '. |
---|
73 | $core->formNonce(). |
---|
74 | form::combo('switchblog',$blogs,$core->blog->id, '',1). |
---|
75 | '<noscript><div><input type="submit" value="'.__('ok').'" /></div></noscript>'; |
---|
76 | } |
---|
77 | |
---|
78 | # Display |
---|
79 | header('Content-Type: text/html; charset=UTF-8'); |
---|
80 | echo |
---|
81 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
82 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
83 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
84 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
85 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
86 | "<head>\n". |
---|
87 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
88 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
89 | |
---|
90 | ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". |
---|
91 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
92 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
93 | |
---|
94 | self::jsLoadIE7(). |
---|
95 | ' <style type="text/css">'."\n". |
---|
96 | ' @import "style/default.css";'."\n". |
---|
97 | " </style>\n"; |
---|
98 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
99 | echo ' <style type="text/css">'."\n".' @import "style/default-rtl.css";'."\n"." </style>\n"; |
---|
100 | } |
---|
101 | |
---|
102 | echo |
---|
103 | self::jsCommon(). |
---|
104 | $head; |
---|
105 | |
---|
106 | # --BEHAVIOR-- adminPageHTMLHead |
---|
107 | $core->callBehavior('adminPageHTMLHead'); |
---|
108 | |
---|
109 | echo |
---|
110 | "</head>\n". |
---|
111 | '<body id="dotclear-admin">'."\n". |
---|
112 | |
---|
113 | '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; |
---|
114 | |
---|
115 | |
---|
116 | echo |
---|
117 | '<div id="info-box">'. |
---|
118 | '<form action="index.php" method="post"><div>'. |
---|
119 | $blog_box. |
---|
120 | '<a href="'.$core->blog->url.'"onclick="window.open(this.href);return false;" title="'.__('Go to site').' ('.__('new window').')'.'">'.__('Go to site').' <img src="images/outgoing.png" alt="" /></a>'. |
---|
121 | '</div></form>'. |
---|
122 | '</div>'. |
---|
123 | '<div id="info-box2"><form action="index.php" method="post><div>"'. |
---|
124 | ' '.__('User:').' <strong>'.$core->auth->userID().'</strong>'. |
---|
125 | ' - <a href="index.php?logout=1" class="logout">'.__('Logout').' <img src="images/logout.png" alt="" /></a>'. |
---|
126 | '</div></form>'. |
---|
127 | '</div>'; |
---|
128 | |
---|
129 | echo |
---|
130 | '<div id="wrapper">'."\n". |
---|
131 | '<div id="main">'."\n". |
---|
132 | '<div id="content">'."\n"; |
---|
133 | |
---|
134 | if ($core->error->flag()) { |
---|
135 | echo |
---|
136 | '<div class="error"><strong>'.__('Errors:').'</strong>'. |
---|
137 | $core->error->toHTML(). |
---|
138 | '</div>'; |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | public static function close() |
---|
143 | { |
---|
144 | $menu =& $GLOBALS['_menu']; |
---|
145 | |
---|
146 | echo |
---|
147 | "</div>\n". // End of #content |
---|
148 | "</div>\n". // End of #main |
---|
149 | |
---|
150 | '<div id="main-menu">'."\n"; |
---|
151 | |
---|
152 | foreach ($menu as $k => $v) { |
---|
153 | echo $menu[$k]->draw(); |
---|
154 | } |
---|
155 | |
---|
156 | echo |
---|
157 | '</div>'."\n". // End of #main-menu |
---|
158 | '<div id="footer"><p>'. |
---|
159 | sprintf(__('Thank you for using %s.'),'<a href="http://dotclear.org/">Dotclear '.DC_VERSION.'</a>'). |
---|
160 | ' <span class="credit"> (Icons by <a href="http://dryicons.com/">Dryicons</a>)</span>'. |
---|
161 | '</p></div>'."\n". |
---|
162 | "</div>\n"; // End of #wrapper |
---|
163 | |
---|
164 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
165 | echo self::debugInfo(); |
---|
166 | } |
---|
167 | |
---|
168 | echo |
---|
169 | '</body></html>'; |
---|
170 | } |
---|
171 | |
---|
172 | public static function openPopup($title='', $head='') |
---|
173 | { |
---|
174 | global $core; |
---|
175 | |
---|
176 | # Display |
---|
177 | header('Content-Type: text/html; charset=UTF-8'); |
---|
178 | echo |
---|
179 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
180 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
181 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
182 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
183 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
184 | "<head>\n". |
---|
185 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
186 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
187 | |
---|
188 | ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". |
---|
189 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
190 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
191 | |
---|
192 | self::jsLoadIE7(). |
---|
193 | ' <style type="text/css">'."\n". |
---|
194 | ' @import "style/default.css";'."\n". |
---|
195 | " </style>\n"; |
---|
196 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
197 | echo ' <style type="text/css">'."\n".' @import "style/default-rtl.css";'."\n"." </style>\n"; |
---|
198 | } |
---|
199 | |
---|
200 | echo |
---|
201 | self::jsCommon(). |
---|
202 | $head; |
---|
203 | |
---|
204 | # --BEHAVIOR-- adminPageHTMLHead |
---|
205 | $core->callBehavior('adminPageHTMLHead'); |
---|
206 | |
---|
207 | echo |
---|
208 | "</head>\n". |
---|
209 | '<body id="dotclear-admin" class="popup">'."\n". |
---|
210 | |
---|
211 | '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; |
---|
212 | |
---|
213 | echo |
---|
214 | '<div id="wrapper">'."\n". |
---|
215 | '<div id="main">'."\n". |
---|
216 | '<div id="content">'."\n"; |
---|
217 | |
---|
218 | if ($core->error->flag()) { |
---|
219 | echo |
---|
220 | '<div class="error"><strong>'.__('Errors:').'</strong>'. |
---|
221 | $core->error->toHTML(). |
---|
222 | '</div>'; |
---|
223 | } |
---|
224 | } |
---|
225 | |
---|
226 | public static function closePopup() |
---|
227 | { |
---|
228 | echo |
---|
229 | "</div>\n". // End of #content |
---|
230 | "</div>\n". // End of #main |
---|
231 | '<div id="footer"><p> </p></div>'."\n". |
---|
232 | "</div>\n". // End of #wrapper |
---|
233 | '</body></html>'; |
---|
234 | } |
---|
235 | |
---|
236 | private static function debugInfo() |
---|
237 | { |
---|
238 | $global_vars = implode(', ',array_keys($GLOBALS)); |
---|
239 | |
---|
240 | $res = |
---|
241 | '<div id="debug"><div>'. |
---|
242 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; |
---|
243 | |
---|
244 | if (function_exists('xdebug_get_profiler_filename')) |
---|
245 | { |
---|
246 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; |
---|
247 | |
---|
248 | $prof_file = xdebug_get_profiler_filename(); |
---|
249 | if ($prof_file) { |
---|
250 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; |
---|
251 | } else { |
---|
252 | $prof_url = http::getSelfURI(); |
---|
253 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; |
---|
254 | $prof_url .= 'XDEBUG_PROFILE'; |
---|
255 | $res .= '<p><a href="'.$prof_url.'">Trigger profiler</a></p>'; |
---|
256 | } |
---|
257 | |
---|
258 | /* xdebug configuration: |
---|
259 | zend_extension = /.../xdebug.so |
---|
260 | xdebug.auto_trace = On |
---|
261 | xdebug.trace_format = 0 |
---|
262 | xdebug.trace_options = 1 |
---|
263 | xdebug.show_mem_delta = On |
---|
264 | xdebug.profiler_enable = 0 |
---|
265 | xdebug.profiler_enable_trigger = 1 |
---|
266 | xdebug.profiler_output_dir = /tmp |
---|
267 | xdebug.profiler_append = 0 |
---|
268 | xdebug.profiler_output_name = timestamp |
---|
269 | */ |
---|
270 | } |
---|
271 | |
---|
272 | $res .= |
---|
273 | '<p>Global vars: '.$global_vars.'</p>'. |
---|
274 | '</div></div>'; |
---|
275 | |
---|
276 | return $res; |
---|
277 | } |
---|
278 | |
---|
279 | public static function help($page,$index='') |
---|
280 | { |
---|
281 | # Deprecated but we keep this for plugins. |
---|
282 | } |
---|
283 | |
---|
284 | public static function helpBlock() |
---|
285 | { |
---|
286 | $args = func_get_args(); |
---|
287 | if (empty($args)) { |
---|
288 | return; |
---|
289 | }; |
---|
290 | |
---|
291 | global $__resources; |
---|
292 | if (empty($__resources['help'])) { |
---|
293 | return; |
---|
294 | } |
---|
295 | |
---|
296 | $content = ''; |
---|
297 | foreach ($args as $v) |
---|
298 | { |
---|
299 | if (is_object($v) && isset($v->content)) { |
---|
300 | $content .= $v->content; |
---|
301 | continue; |
---|
302 | } |
---|
303 | |
---|
304 | if (!isset($__resources['help'][$v])) { |
---|
305 | continue; |
---|
306 | } |
---|
307 | $f = $__resources['help'][$v]; |
---|
308 | if (!file_exists($f) || !is_readable($f)) { |
---|
309 | continue; |
---|
310 | } |
---|
311 | |
---|
312 | $fc = file_get_contents($f); |
---|
313 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
314 | $content .= $matches[1]; |
---|
315 | } else { |
---|
316 | $content .= $fc; |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | if (trim($content) == '') { |
---|
321 | return; |
---|
322 | } |
---|
323 | |
---|
324 | echo |
---|
325 | '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'. |
---|
326 | $content. |
---|
327 | '</div></div>'; |
---|
328 | } |
---|
329 | |
---|
330 | public static function jsLoad($src) |
---|
331 | { |
---|
332 | return '<script type="text/javascript" src="'.html::escapeHTML($src).'"></script>'."\n"; |
---|
333 | } |
---|
334 | |
---|
335 | public static function jsVar($n,$v) |
---|
336 | { |
---|
337 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
338 | } |
---|
339 | |
---|
340 | public static function jsCommon() |
---|
341 | { |
---|
342 | return |
---|
343 | self::jsLoad('js/jquery/jquery.js'). |
---|
344 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
345 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
346 | self::jsLoad('js/common.js'). |
---|
347 | |
---|
348 | '<script type="text/javascript">'."\n". |
---|
349 | "//<![CDATA[\n". |
---|
350 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
351 | |
---|
352 | self::jsVar('dotclear.img_plus_src','images/plus.png'). |
---|
353 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
354 | self::jsVar('dotclear.img_minus_src','images/minus.png'). |
---|
355 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
356 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
357 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
358 | |
---|
359 | self::jsVar('dotclear.msg.help', |
---|
360 | __('help')). |
---|
361 | self::jsVar('dotclear.msg.no_selection', |
---|
362 | __('no selection')). |
---|
363 | self::jsVar('dotclear.msg.select_all', |
---|
364 | __('select all')). |
---|
365 | self::jsVar('dotclear.msg.invert_sel', |
---|
366 | __('invert selection')). |
---|
367 | self::jsVar('dotclear.msg.website', |
---|
368 | __('Web site:')). |
---|
369 | self::jsVar('dotclear.msg.email', |
---|
370 | __('Email:')). |
---|
371 | self::jsVar('dotclear.msg.ip_address', |
---|
372 | __('IP address:')). |
---|
373 | self::jsVar('dotclear.msg.error', |
---|
374 | __('Error:')). |
---|
375 | self::jsVar('dotclear.msg.entry_created', |
---|
376 | __('Entry has been successfully created.')). |
---|
377 | self::jsVar('dotclear.msg.edit_entry', |
---|
378 | __('Edit entry')). |
---|
379 | self::jsVar('dotclear.msg.view_entry', |
---|
380 | __('view entry')). |
---|
381 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
382 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
383 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
384 | __("Are you sure you want to delete this entry?")). |
---|
385 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
386 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
387 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
388 | __('Are you sure you want to delete this comment?')). |
---|
389 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
390 | __('Users with posts cannot be deleted.')). |
---|
391 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
392 | __('Are you sure you want to delete selected users (%s)?')). |
---|
393 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
394 | __('Are you sure you want to delete category "%s"?')). |
---|
395 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
396 | __('Are you sure you want to reorder all categories?')). |
---|
397 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
398 | __('Are you sure you want to remove media "%s"?')). |
---|
399 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
400 | __('Are you sure you want to extract archive in current directory?')). |
---|
401 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
402 | __('Are you sure you want to remove attachment "%s"?')). |
---|
403 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
404 | __('Are you sure you want to delete "%s" language?')). |
---|
405 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
406 | __('Are you sure you want to delete "%s" plugin?')). |
---|
407 | self::jsVar('dotclear.msg.use_this_theme', |
---|
408 | __('Use this theme')). |
---|
409 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
410 | __('Remove this theme')). |
---|
411 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
412 | __('Are you sure you want to delete "%s" theme?')). |
---|
413 | self::jsVar('dotclear.msg.zip_file_content', |
---|
414 | __('Zip file content')). |
---|
415 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
416 | __('XHTML markup validator')). |
---|
417 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
418 | __('XHTML content is valid.')). |
---|
419 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
420 | __('There are XHTML markup errors.')). |
---|
421 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
422 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
423 | "\n//]]>\n". |
---|
424 | "</script>\n"; |
---|
425 | } |
---|
426 | |
---|
427 | public static function jsLoadIE7() |
---|
428 | { |
---|
429 | return |
---|
430 | '<!--[if lt IE 8]>'."\n". |
---|
431 | self::jsLoad('js/ie7/IE8.js'). |
---|
432 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". |
---|
433 | '<![endif]-->'."\n"; |
---|
434 | } |
---|
435 | |
---|
436 | public static function jsConfirmClose() |
---|
437 | { |
---|
438 | $args = func_get_args(); |
---|
439 | if (count($args) > 0) { |
---|
440 | foreach ($args as $k => $v) { |
---|
441 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
442 | } |
---|
443 | $args = implode(',',$args); |
---|
444 | } else { |
---|
445 | $args = ''; |
---|
446 | } |
---|
447 | |
---|
448 | return |
---|
449 | self::jsLoad('js/confirm-close.js'). |
---|
450 | '<script type="text/javascript">'."\n". |
---|
451 | "//<![CDATA[\n". |
---|
452 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
453 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
454 | "\n//]]>\n". |
---|
455 | "</script>\n"; |
---|
456 | } |
---|
457 | |
---|
458 | public static function jsPageTabs($default=null) |
---|
459 | { |
---|
460 | if ($default) { |
---|
461 | $default = "'".html::escapeJS($default)."'"; |
---|
462 | } |
---|
463 | |
---|
464 | return |
---|
465 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
466 | '<script type="text/javascript">'."\n". |
---|
467 | "//<![CDATA[\n". |
---|
468 | "\$(function() {\n". |
---|
469 | " \$.pageTabs(".$default.");\n". |
---|
470 | "});\n". |
---|
471 | "\n//]]>\n". |
---|
472 | "</script>\n"; |
---|
473 | } |
---|
474 | |
---|
475 | public static function jsModal() |
---|
476 | { |
---|
477 | return |
---|
478 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". |
---|
479 | self::jsLoad('js/jquery/jquery.modal.js'). |
---|
480 | '<script type="text/javascript">'."\n". |
---|
481 | "//<![CDATA[\n". |
---|
482 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). |
---|
483 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). |
---|
484 | "\n//]]>\n". |
---|
485 | "</script>\n"; |
---|
486 | } |
---|
487 | |
---|
488 | public static function jsColorPicker() |
---|
489 | { |
---|
490 | return |
---|
491 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". |
---|
492 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
493 | self::jsLoad('js/color-picker.js'); |
---|
494 | } |
---|
495 | |
---|
496 | public static function jsDatePicker() |
---|
497 | { |
---|
498 | return |
---|
499 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". |
---|
500 | self::jsLoad('js/date-picker.js'). |
---|
501 | '<script type="text/javascript">'."\n". |
---|
502 | "//<![CDATA[\n". |
---|
503 | |
---|
504 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
505 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
506 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
507 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
508 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
509 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
510 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
511 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
512 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
513 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
514 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
515 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
516 | |
---|
517 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
518 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
519 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
520 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
521 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
522 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
523 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
524 | |
---|
525 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
526 | |
---|
527 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
528 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
529 | |
---|
530 | "\n//]]>\n". |
---|
531 | "</script>\n"; |
---|
532 | } |
---|
533 | |
---|
534 | public static function jsToolBar() |
---|
535 | { |
---|
536 | $res = |
---|
537 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. |
---|
538 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; |
---|
539 | |
---|
540 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
541 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; |
---|
542 | } |
---|
543 | |
---|
544 | $res .= |
---|
545 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. |
---|
546 | '<script type="text/javascript">'."\n". |
---|
547 | "//<![CDATA[\n". |
---|
548 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". |
---|
549 | "jsToolBar.prototype.iframe_css = '". |
---|
550 | 'body{'. |
---|
551 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
552 | 'color : #000;'. |
---|
553 | 'background: #f9f9f9;'. |
---|
554 | 'margin: 0;'. |
---|
555 | 'padding : 2px;'. |
---|
556 | 'border: none;'. |
---|
557 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
558 | '}'. |
---|
559 | 'pre, code, kbd, samp {'. |
---|
560 | 'font-family:"Courier New",Courier,monospace;'. |
---|
561 | 'font-size : 1.1em;'. |
---|
562 | '}'. |
---|
563 | 'code {'. |
---|
564 | 'color : #666;'. |
---|
565 | 'font-weight : bold;'. |
---|
566 | '}'. |
---|
567 | 'body > p:first-child {'. |
---|
568 | 'margin-top: 0;'. |
---|
569 | '}'. |
---|
570 | "'; ". |
---|
571 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". |
---|
572 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". |
---|
573 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". |
---|
574 | "jsToolBar.prototype.legend_msg = '". |
---|
575 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". |
---|
576 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". |
---|
577 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". |
---|
578 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". |
---|
579 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". |
---|
580 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". |
---|
581 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". |
---|
582 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". |
---|
583 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". |
---|
584 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". |
---|
585 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". |
---|
586 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". |
---|
587 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". |
---|
588 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". |
---|
589 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". |
---|
590 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". |
---|
591 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". |
---|
592 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". |
---|
593 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". |
---|
594 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". |
---|
595 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". |
---|
596 | |
---|
597 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". |
---|
598 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
599 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". |
---|
600 | |
---|
601 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". |
---|
602 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
603 | |
---|
604 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
605 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; |
---|
606 | |
---|
607 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
608 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; |
---|
609 | } |
---|
610 | |
---|
611 | $res .= |
---|
612 | "\n//]]>\n". |
---|
613 | "</script>\n"; |
---|
614 | |
---|
615 | return $res; |
---|
616 | } |
---|
617 | |
---|
618 | public static function jsCandyUpload($params=array(),$base_url=null) |
---|
619 | { |
---|
620 | if (!$base_url) { |
---|
621 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
622 | } |
---|
623 | |
---|
624 | $params = array_merge($params,array( |
---|
625 | 'sess_id='.session_id(), |
---|
626 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
627 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
628 | )); |
---|
629 | |
---|
630 | return |
---|
631 | '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n". |
---|
632 | self::jsLoad('js/jquery/jquery.candyUpload.js'). |
---|
633 | |
---|
634 | '<script type="text/javascript">'."\n". |
---|
635 | "//<![CDATA[\n". |
---|
636 | "dotclear.candyUpload = {};\n". |
---|
637 | self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')). |
---|
638 | self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')). |
---|
639 | self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). |
---|
640 | self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). |
---|
641 | self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')). |
---|
642 | self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
643 | self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')). |
---|
644 | self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')). |
---|
645 | self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')). |
---|
646 | self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')). |
---|
647 | self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')). |
---|
648 | self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')). |
---|
649 | self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')). |
---|
650 | self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')). |
---|
651 | self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')). |
---|
652 | self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')). |
---|
653 | self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')). |
---|
654 | self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')). |
---|
655 | self::jsVar('dotclear.candyUpload.base_url',$base_url). |
---|
656 | self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf'). |
---|
657 | self::jsVar('dotclear.candyUpload.params',implode('&',$params)). |
---|
658 | "\n//]]>\n". |
---|
659 | "</script>\n"; |
---|
660 | } |
---|
661 | |
---|
662 | public static function jsToolMan() |
---|
663 | { |
---|
664 | return |
---|
665 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. |
---|
666 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. |
---|
667 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. |
---|
668 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. |
---|
669 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. |
---|
670 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. |
---|
671 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; |
---|
672 | } |
---|
673 | |
---|
674 | public static function jsMetaEditor() |
---|
675 | { |
---|
676 | return |
---|
677 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; |
---|
678 | } |
---|
679 | } |
---|
680 | ?> |
---|