Dotclear

source: inc/admin/lib.dc.page.php @ 1140:ab9eefc96744

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

Footer reloaded, fixes #1394

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

Sites map