Dotclear

source: inc/admin/lib.dc.page.php @ 973:6c89a6e8f2b4

Revision 973:6c89a6e8f2b4, 25.0 KB checked in by franck <carnet.franck.paul@…>, 13 years ago (diff)

Fixes invalid xhtml output for errors

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

Sites map