Dotclear

source: inc/admin/lib.dc.page.php @ 343:f9fcb964c910

Revision 343:f9fcb964c910, 24.0 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

Merged with 2.3 latest bugfixes

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

Sites map