Dotclear

source: inc/admin/lib.dc.page.php @ 999:4dca015ee09f

Revision 999:4dca015ee09f, 25.1 KB checked in by franck <carnet.franck.paul@…>, 13 years ago (diff)

Fix XHTML validation on admin header

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

Sites map