Dotclear

source: inc/admin/lib.dc.page.php @ 1142:0a3d1f6c4281

Revision 1142:0a3d1f6c4281, 25.2 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Caution with XHTML attributes content

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

Sites map