Dotclear

source: inc/admin/lib.dc.page.php @ 907:da55072f8b87

Revision 907:da55072f8b87, 24.7 KB checked in by franck <carnet.franck.paul@…>, 13 years ago (diff)

Add timestamp on information message, fixes #1189

Line 
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 -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14define('DC_AUTH_PAGE','auth.php');
15
16class 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>&nbsp;</p></div>'."\n".
254          "</div>\n".         // End of #wrapper
255          '</body></html>';
256     }
257
258     public static function message($msg,$timestamp=true,$div=false,$echo=true)
259     {
260          $res = '';
261          if ($msg != '') {
262               $res = ($div ? '<div class="message">' : '').'<p'.($div ? '' : ' class="message"').'>'.
263                    ($timestamp ? dt::str(__('%H:%M:%S:')).' ' : '').$msg.
264                    '</p>'.($div ? '</div>' : '');
265               if ($echo) {
266                    echo $res;
267               }
268          }
269          return $res;
270     }
271     
272     private static function debugInfo()
273     {
274          $global_vars = implode(', ',array_keys($GLOBALS));
275         
276          $res =
277          '<div id="debug"><div>'.
278          '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>';
279         
280          if (function_exists('xdebug_get_profiler_filename'))
281          {
282               $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>';
283               
284               $prof_file = xdebug_get_profiler_filename();
285               if ($prof_file) {
286                    $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>';
287               } else {
288                    $prof_url = http::getSelfURI();
289                    $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&';
290                    $prof_url .= 'XDEBUG_PROFILE';
291                    $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>';
292               }
293               
294               /* xdebug configuration:
295               zend_extension = /.../xdebug.so
296               xdebug.auto_trace = On
297               xdebug.trace_format = 0
298               xdebug.trace_options = 1
299               xdebug.show_mem_delta = On
300               xdebug.profiler_enable = 0
301               xdebug.profiler_enable_trigger = 1
302               xdebug.profiler_output_dir = /tmp
303               xdebug.profiler_append = 0
304               xdebug.profiler_output_name = timestamp
305               */
306          }
307         
308          $res .=
309          '<p>Global vars: '.$global_vars.'</p>'.
310          '</div></div>';
311         
312          return $res;
313     }
314     
315     public static function help($page,$index='')
316     {
317          # Deprecated but we keep this for plugins.
318     }
319     
320     public static function helpBlock()
321     {
322          $args = func_get_args();
323          if (empty($args)) {
324               return;
325          };
326         
327          global $__resources;
328          if (empty($__resources['help'])) {
329               return;
330          }
331         
332          $content = '';
333          foreach ($args as $v)
334          {
335               if (is_object($v) && isset($v->content)) {
336                    $content .= $v->content;
337                    continue;
338               }
339               
340               if (!isset($__resources['help'][$v])) {
341                    continue;
342               }
343               $f = $__resources['help'][$v];
344               if (!file_exists($f) || !is_readable($f)) {
345                    continue;
346               }
347               
348               $fc = file_get_contents($f);
349               if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) {
350                    $content .= $matches[1];
351               } else {
352                    $content .= $fc;
353               }
354          }
355         
356          if (trim($content) == '') {
357               return;
358          }
359         
360          echo
361          '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'.
362          $content.
363          '</div></div>';
364     }
365     
366     public static function jsLoad($src)
367     {
368          $escaped_src = html::escapeHTML($src);
369          if (!isset(self::$loaded_js[$escaped_src])) {
370               self::$loaded_js[$escaped_src]=true;
371               return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n";
372          }
373     }
374     
375     public static function jsVar($n,$v)
376     {
377          return $n." = '".html::escapeJS($v)."';\n";
378     }
379     
380     public static function jsCommon()
381     {
382          return
383          self::jsLoad('js/jquery/jquery.js').
384          self::jsLoad('js/jquery/jquery.biscuit.js').
385          self::jsLoad('js/jquery/jquery.bgFade.js').
386          self::jsLoad('js/jquery/jquery.constantfooter.js').
387          self::jsLoad('js/common.js').
388          self::jsLoad('js/prelude.js').
389         
390          '<script type="text/javascript">'."\n".
391          "//<![CDATA[\n".
392          self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()).
393         
394          self::jsVar('dotclear.img_plus_src','images/plus.png').
395          self::jsVar('dotclear.img_plus_alt',__('uncover')).
396          self::jsVar('dotclear.img_minus_src','images/minus.png').
397          self::jsVar('dotclear.img_minus_alt',__('hide')).
398          self::jsVar('dotclear.img_menu_on','images/menu_on.png').
399          self::jsVar('dotclear.img_menu_off','images/menu_off.png').
400         
401          self::jsVar('dotclear.msg.help',
402               __('help')).
403          self::jsVar('dotclear.msg.no_selection',
404               __('no selection')).
405          self::jsVar('dotclear.msg.select_all',
406               __('select all')).
407          self::jsVar('dotclear.msg.invert_sel',
408               __('invert selection')).
409          self::jsVar('dotclear.msg.website',
410               __('Web site:')).
411          self::jsVar('dotclear.msg.email',
412               __('Email:')).
413          self::jsVar('dotclear.msg.ip_address',
414               __('IP address:')).
415          self::jsVar('dotclear.msg.error',
416               __('Error:')).
417          self::jsVar('dotclear.msg.entry_created',
418               __('Entry has been successfully created.')).
419          self::jsVar('dotclear.msg.edit_entry',
420               __('Edit entry')).
421          self::jsVar('dotclear.msg.view_entry',
422               __('view entry')).
423          self::jsVar('dotclear.msg.confirm_delete_posts',
424               __("Are you sure you want to delete selected entries (%s)?")).
425          self::jsVar('dotclear.msg.confirm_delete_post',
426               __("Are you sure you want to delete this entry?")).
427          self::jsVar('dotclear.msg.confirm_delete_comments',
428               __('Are you sure you want to delete selected comments (%s)?')).
429          self::jsVar('dotclear.msg.confirm_delete_comment',
430               __('Are you sure you want to delete this comment?')).
431          self::jsVar('dotclear.msg.cannot_delete_users',
432               __('Users with posts cannot be deleted.')).
433          self::jsVar('dotclear.msg.confirm_delete_user',
434               __('Are you sure you want to delete selected users (%s)?')).
435          self::jsVar('dotclear.msg.confirm_delete_category',
436               __('Are you sure you want to delete category "%s"?')).
437          self::jsVar('dotclear.msg.confirm_reorder_categories',
438               __('Are you sure you want to reorder all categories?')).
439          self::jsVar('dotclear.msg.confirm_delete_media',
440               __('Are you sure you want to remove media "%s"?')).
441          self::jsVar('dotclear.msg.confirm_extract_current',
442               __('Are you sure you want to extract archive in current directory?')).
443          self::jsVar('dotclear.msg.confirm_remove_attachment',
444               __('Are you sure you want to remove attachment "%s"?')).
445          self::jsVar('dotclear.msg.confirm_delete_lang',
446               __('Are you sure you want to delete "%s" language?')).
447          self::jsVar('dotclear.msg.confirm_delete_plugin',
448               __('Are you sure you want to delete "%s" plugin?')).
449          self::jsVar('dotclear.msg.use_this_theme',
450               __('Use this theme')).
451          self::jsVar('dotclear.msg.remove_this_theme',
452               __('Remove this theme')).
453          self::jsVar('dotclear.msg.confirm_delete_theme',
454               __('Are you sure you want to delete "%s" theme?')).
455          self::jsVar('dotclear.msg.zip_file_content',
456               __('Zip file content')).
457          self::jsVar('dotclear.msg.xhtml_validator',
458               __('XHTML markup validator')).
459          self::jsVar('dotclear.msg.xhtml_valid',
460               __('XHTML content is valid.')).
461          self::jsVar('dotclear.msg.xhtml_not_valid',
462               __('There are XHTML markup errors.')).
463          self::jsVar('dotclear.msg.confirm_change_post_format',
464               __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')).
465          self::jsVar('dotclear.msg.load_enhanced_uploader',
466               __('Loading enhanced uploader, please wait.')).
467          "\n//]]>\n".
468          "</script>\n";
469     }
470     
471     public static function jsLoadIE7()
472     {
473          return
474          '<!--[if lt IE 8]>'."\n".
475          self::jsLoad('js/ie7/IE8.js').
476          '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n".
477          '<![endif]-->'."\n";
478     }
479     
480     public static function jsConfirmClose()
481     {
482          $args = func_get_args();
483          if (count($args) > 0) {
484               foreach ($args as $k => $v) {
485                    $args[$k] = "'".html::escapeJS($v)."'";
486               }
487               $args = implode(',',$args);
488          } else {
489               $args = '';
490          }
491         
492          return
493          self::jsLoad('js/confirm-close.js').
494          '<script type="text/javascript">'."\n".
495          "//<![CDATA[\n".
496          "confirmClosePage = new confirmClose(".$args."); ".
497          "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ".
498          "\n//]]>\n".
499          "</script>\n";
500     }
501     
502     public static function jsPageTabs($default=null)
503     {
504          if ($default) {
505               $default = "'".html::escapeJS($default)."'";
506          }
507         
508          return
509          self::jsLoad('js/jquery/jquery.pageTabs.js').
510          '<script type="text/javascript">'."\n".
511          "//<![CDATA[\n".
512          "\$(function() {\n".
513          "    \$.pageTabs(".$default.");\n".
514          "});\n".
515          "\n//]]>\n".
516          "</script>\n";
517     }
518     
519     public static function jsModal()
520     {
521          return
522          '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n".
523          self::jsLoad('js/jquery/jquery.modal.js').
524          '<script type="text/javascript">'."\n".
525          "//<![CDATA[\n".
526          self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif').
527          self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png').
528          "\n//]]>\n".
529          "</script>\n";
530     }
531     
532     public static function jsColorPicker()
533     {
534          return
535          '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n".
536          self::jsLoad('js/jquery/jquery.farbtastic.js').
537          self::jsLoad('js/color-picker.js');
538     }
539     
540     public static function jsDatePicker()
541     {
542          return
543          '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n".
544          self::jsLoad('js/date-picker.js').
545          '<script type="text/javascript">'."\n".
546          "//<![CDATA[\n".
547         
548          "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ".
549          "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ".
550          "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ".
551          "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ".
552          "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ".
553          "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ".
554          "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ".
555          "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ".
556          "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ".
557          "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ".
558          "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ".
559          "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ".
560         
561          "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ".
562          "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ".
563          "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ".
564          "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ".
565          "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ".
566          "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ".
567          "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ".
568         
569          "datePicker.prototype.img_src = 'images/date-picker.png'; ".
570         
571          "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ".
572          "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ".
573         
574          "\n//]]>\n".
575          "</script>\n";
576     }
577     
578     public static function jsToolBar()
579     {
580          $res =
581          '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'.
582          '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>';
583         
584          if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) {
585               $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>';
586          }
587         
588          $res .=
589          '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'.
590          '<script type="text/javascript">'."\n".
591          "//<![CDATA[\n".
592          "jsToolBar.prototype.dialog_url = 'popup.php'; ".
593          "jsToolBar.prototype.iframe_css = '".
594               'body{'.
595                    'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'.
596                    'color : #000;'.
597                    'background: #f9f9f9;'.
598                    'margin: 0;'.
599                    'padding : 2px;'.
600                    'border: none;'.
601                    (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : '').
602               '}'.
603               'pre, code, kbd, samp {'.
604                    'font-family:"Courier New",Courier,monospace;'.
605                    'font-size : 1.1em;'.
606               '}'.
607               'code {'.
608                    'color : #666;'.
609                    'font-weight : bold;'.
610               '}'.
611               'body > p:first-child {'.
612                    'margin-top: 0;'.
613               '}'.
614          "'; ".
615          "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ".
616          "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ".
617          "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ".
618          "jsToolBar.prototype.legend_msg = '".
619          html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ".
620          "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ".
621          "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ".
622          "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ".
623          "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ".
624          "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ".
625          "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ".
626          "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ".
627          "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ".
628          "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ".
629          "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ".
630          "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ".
631          "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ".
632          "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ".
633          "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ".
634          "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ".
635          "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ".
636          "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ".
637          "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ".
638          "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ".
639          "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ".
640         
641          "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ".
642          "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ".
643          "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ".
644         
645          "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ".
646          "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ".
647         
648          "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ".
649          "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; ";
650         
651          if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) {
652               $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n";
653          }
654         
655          $res .=
656          "\n//]]>\n".
657          "</script>\n";
658         
659          return $res;
660     }
661     
662     public static function jsCandyUpload($params=array(),$base_url=null)
663     {
664          if (!$base_url) {
665               $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';
666          }
667         
668          $params = array_merge($params,array(
669               'sess_id='.session_id(),
670               'sess_uid='.$_SESSION['sess_browser_uid'],
671               'xd_check='.$GLOBALS['core']->getNonce()
672          ));
673         
674          return
675          '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n".
676          self::jsLoad('js/jquery/jquery.candyUpload.js').
677         
678          '<script type="text/javascript">'."\n".
679          "//<![CDATA[\n".
680          "dotclear.candyUpload = {};\n".
681          self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')).
682          self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')).
683          self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')).
684          self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')).
685          self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')).
686          self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')).
687          self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')).
688          self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')).
689          self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')).
690          self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')).
691          self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')).
692          self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')).
693          self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')).
694          self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')).
695          self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')).
696          self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')).
697          self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')).
698          self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')).
699          self::jsVar('dotclear.candyUpload.base_url',$base_url).
700          self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf').
701          self::jsVar('dotclear.candyUpload.params',implode('&',$params)).
702          "\n//]]>\n".
703          "</script>\n";
704     }
705     
706     public static function jsToolMan()
707     {
708          return
709          '<script type="text/javascript" src="js/tool-man/core.js"></script>'.
710          '<script type="text/javascript" src="js/tool-man/events.js"></script>'.
711          '<script type="text/javascript" src="js/tool-man/css.js"></script>'.
712          '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'.
713          '<script type="text/javascript" src="js/tool-man/drag.js"></script>'.
714          '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'.
715          '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>';
716     }
717     
718     public static function jsMetaEditor()
719     {
720          return
721          '<script type="text/javascript" src="js/meta-editor.js"></script>';
722     }
723}
724?>
Note: See TracBrowser for help on using the repository browser.

Sites map