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