Dotclear

source: inc/admin/lib.dc.page.php @ 0:54703be25dd6

Revision 0:54703be25dd6, 23.1 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

2.3 branch (trunk) first checkin

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

Sites map