Dotclear

source: inc/admin/lib.dc.page.php @ 2614:db6f6a1f4f25

Revision 2614:db6f6a1f4f25, 29.1 KB checked in by Nicolas <nikrou77@…>, 12 years ago (diff)

Move legacy editor to a plugin. First step for alternate editors.
Addresses #1896

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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     private static $N_TYPES = array(
20          "success" => "success",
21          "warning" => "warning-msg",
22          "error" => "error",
23          "message" => "message",
24          "static" => "static-msg");
25
26     # Auth check
27     public static function check($permissions)
28     {
29          global $core;
30
31          if ($core->blog && $core->auth->check($permissions,$core->blog->id)) {
32               return;
33          }
34
35          if (session_id()) {
36               $core->session->destroy();
37          }
38          http::redirect(DC_AUTH_PAGE);
39     }
40
41     # Check super admin
42     public static function checkSuper()
43     {
44          global $core;
45
46          if (!$core->auth->isSuperAdmin())
47          {
48               if (session_id()) {
49                    $core->session->destroy();
50               }
51               http::redirect(DC_AUTH_PAGE);
52          }
53     }
54
55     # Top of admin page
56     public static function open($title='',$head='',$breadcrumb='')
57     {
58          global $core;
59
60          # List of user's blogs
61          if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20)
62          {
63               $blog_box =
64               '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'.
65               html::escapeHTML($core->blog->name).'</strong>';
66
67               if ($core->auth->getBlogCount() > 20) {
68                    $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>';
69               }
70               $blog_box .= '</p>';
71          }
72          else
73          {
74               $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20));
75               $blogs = array();
76               while ($rs_blogs->fetch()) {
77                    $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id;
78               }
79               $blog_box =
80               '<p><label for="switchblog" class="classic">'.
81               __('Blogs:').'</label> '.
82               $core->formNonce().
83               form::combo('switchblog',$blogs,$core->blog->id).
84               '<input type="submit" value="'.__('ok').'" class="hidden-if-js" /></p>';
85          }
86
87          $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'];
88
89          # Display
90          header('Content-Type: text/html; charset=UTF-8');
91          echo
92          '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '.
93          ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".
94          '<html xmlns="http://www.w3.org/1999/xhtml" '.
95          'xml:lang="'.$core->auth->getInfo('user_lang').'" '.
96          'lang="'.$core->auth->getInfo('user_lang').'">'."\n".
97          "<head>\n".
98          '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".
99          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
100          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
101          '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n".
102          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
103
104
105          self::jsLoadIE7().
106          '  <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";
107          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
108               echo
109               '  <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";
110          }
111
112          $core->auth->user_prefs->addWorkspace('interface');
113          $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
114          if (!$user_ui_hide_std_favicon) {
115               echo
116               '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'.
117               '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />';
118          }
119          echo
120          self::jsCommon().
121          self::jsToggles().
122          $head;
123
124          # --BEHAVIOR-- adminPageHTMLHead
125          $core->callBehavior('adminPageHTMLHead');
126
127          echo
128          "</head>\n".
129          '<body id="dotclear-admin'.
130          ($safe_mode ? ' safe-mode' : '').'" class="no-js">'."\n".
131
132          '<ul id="prelude">'.
133          '<li><a href="#content">'.__('Go to the content').'</a></li>'.
134          '<li><a href="#main-menu">'.__('Go to the menu').'</a></li>'.
135          '<li><a href="#qx">'.__('Go to search').'</a></li>'.
136          '<li><a href="#help">'.__('Go to help').'</a></li>'.
137          '</ul>'."\n".
138          '<div id="header">'.
139          '<h1><a href="index.php"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n";
140
141          echo
142          '<form action="index.php" method="post" id="top-info-blog">'.
143          $blog_box.
144          '<p><a href="'.$core->blog->url.'" class="outgoing" title="'.__('Go to site').
145          '">'.__('Go to site').'<img src="images/outgoing.png" alt="" /></a>'.
146          '</p></form>'.
147          '<ul id="top-info-user">'.
148          '<li><a class="'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="index.php">'.__('My dashboard').'</a></li>'.
149          '<li><a class="smallscreen'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : '').
150          '" href="preferences.php">'.__('My preferences').'</a></li>'.
151          '<li><a href="index.php?logout=1" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()).
152          '</span><img src="images/logout.png" alt="" /></a></li>'.
153          '</ul>'.
154          '</div>'; // end header
155
156          echo
157          '<div id="wrapper" class="clearfix">'."\n".
158          '<div class="hidden-if-no-js collapser-box"><a href="#" id="collapser">'.
159          '<img class="collapse-mm" src="images/collapser-hide.png" alt="'.__('Hide main menu').'" />'.
160          '<img class="expand-mm" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'.
161          '</a></div>'.
162          '<div id="main">'."\n".
163          '<div id="content" class="clearfix">'."\n";
164
165          # Safe mode
166          if ($safe_mode)
167          {
168               echo
169               '<div class="warning"><h3>'.__('Safe mode').'</h3>'.
170               '<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>'.
171               '</div>';
172          }
173
174          // Display breadcrumb (if given) before any error message
175          echo $breadcrumb;
176
177          if ($core->error->flag()) {
178               echo
179               '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong></p>'.
180               $core->error->toHTML().
181               '</div>';
182          }
183
184          // Display notices
185          echo self::notices();
186     }
187
188     public static function notices()
189     {
190          // return notices if any
191          $res = '';
192          if (isset($_SESSION['notifications'])) {
193               $notifications = $_SESSION['notifications'];
194               foreach ($_SESSION['notifications'] as $notification) {
195                    $res .= self::getNotification($notification);
196               }
197               unset($_SESSION['notifications']);
198          }
199          return $res;
200     }
201
202     public static function addNotice($type,$message,$options=array())
203     {
204          if (isset(self::$N_TYPES[$type])){
205               $class = self::$N_TYPES[$type];
206          } else {
207               $class=$type;
208          }
209          if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) {
210               $notifications = $_SESSION['notifications'];
211          } else {
212               $notifications = array();
213          }
214
215          $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message));
216          if ($type != "static") {
217               $notifications[] = $n;
218          } else {
219               array_unshift($notifications, $n);
220          }
221          $_SESSION['notifications'] = $notifications;
222     }
223
224     public static function addSuccessNotice($message,$options=array())
225     {
226          self::addNotice("success",$message,$options);
227     }
228
229     public static function addWarningNotice($message,$options=array())
230     {
231          self::addNotice("warning",$message,$options);
232     }
233
234     public static function addErrorNotice($message,$options=array())
235     {
236          self::addNotice("error",$message,$options);
237     }
238
239     protected static function getNotification($n)
240     {
241          global $core;
242          $tag = (isset($n['divtag'])&& $n['divtag'])?'div':'p';
243          $ts = '';
244          if (!isset($n['with_ts']) || ($n['with_ts'] == true)) {
245               $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' ';
246          }
247          $res = '<'.$tag.' class="'.$n['class'].'">'.$ts.$n['text'].'</'.$tag.'>';
248          return $res;
249     }
250
251     public static function close()
252     {
253          global $core;
254
255          if (!$GLOBALS['__resources']['ctxhelp']) {
256               echo
257               '<p id="help-button"><a href="help.php" class="outgoing" title="'.
258               __('Global help').'">'.__('Global help').'</a></p>';
259          }
260
261          $menu =& $GLOBALS['_menu'];
262
263          echo
264          "</div>\n".         // End of #content
265          "</div>\n".         // End of #main
266
267          '<div id="main-menu">'."\n".
268
269          '<form id="search-menu" action="search.php" method="get">'.
270          '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,'').
271          '<input type="submit" value="'.__('OK').'" /></p>'.
272          '</form>';
273
274          foreach ($menu as $k => $v) {
275               echo $menu[$k]->draw();
276          }
277
278          $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION);
279
280          # --BEHAVIOR-- adminPageFooter
281          $textAlt = $core->callBehavior('adminPageFooter',$core,$text);
282          if ($textAlt != '') {
283               $text = $textAlt;
284          }
285          $text = html::escapeHTML($text);
286
287          echo
288          '</div>'."\n".      // End of #main-menu
289          "</div>\n";         // End of #wrapper
290
291          echo
292          '<div id="footer">'.
293          '<a href="http://dotclear.org/" title="'.$text.'">'.
294          '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n".
295        "<!-- \n                  \n               ,;:'`'::\n".
296          "            __||\n      _____/LLLL\_\n      \__________\"|\n".
297        "    ~^~^~^~^~^~^~^~^~^~\n -->\n";
298
299          if (defined('DC_DEV') && DC_DEV === true) {
300               echo self::debugInfo();
301          }
302
303          echo
304          '</body></html>';
305     }
306
307     public static function openPopup($title='',$head='',$breadcrumb='')
308     {
309          global $core;
310
311          # Display
312          header('Content-Type: text/html; charset=UTF-8');
313          echo
314          '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '.
315          ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".
316          '<html xmlns="http://www.w3.org/1999/xhtml" '.
317          'xml:lang="'.$core->auth->getInfo('user_lang').'" '.
318          'lang="'.$core->auth->getInfo('user_lang').'">'."\n".
319          "<head>\n".
320          '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n".
321          '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".
322          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
323
324          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
325          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
326
327          self::jsLoadIE7().
328          '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";
329          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
330               echo
331               '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";
332          }
333
334          echo
335          self::jsCommon().
336          self::jsToggles().
337          $head;
338
339          # --BEHAVIOR-- adminPageHTMLHead
340          $core->callBehavior('adminPageHTMLHead');
341
342          echo
343          "</head>\n".
344          '<body id="dotclear-admin" class="popup">'."\n".
345
346          '<h1>'.DC_VENDOR_NAME.'</h1>'."\n";
347
348          echo
349          '<div id="wrapper">'."\n".
350          '<div id="main">'."\n".
351          '<div id="content">'."\n";
352
353          // display breadcrumb if given
354          echo $breadcrumb;
355
356          if ($core->error->flag()) {
357               echo
358               '<div class="error"><strong>'.__('Errors:').'</strong>'.
359               $core->error->toHTML().
360               '</div>';
361          }
362     }
363
364     public static function closePopup()
365     {
366          echo
367          "</div>\n".         // End of #content
368          "</div>\n".         // End of #main
369          "</div>\n".         // End of #wrapper
370          '<div id="footer"><p>&nbsp;</p></div>'."\n".
371          '</body></html>';
372     }
373
374     public static function breadcrumb($elements=null,$options=array())
375     {
376          $with_home_link = isset($options['home_link'])?$options['home_link']:true;
377          $hl = isset($options['hl'])?$options['hl']:true;
378          $hl_pos = isset($options['hl_pos'])?$options['hl_pos']:-1;
379          // First item of array elements should be blog's name, System or Plugins
380          $res = '<h2>'.($with_home_link ?
381               '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' :
382               '<img src="style/dashboard-alt.png" alt="" />');
383          $index = 0;
384          if ($hl_pos < 0) {
385               $hl_pos = count($elements)+$hl_pos;
386          }
387          foreach ($elements as $element => $url) {
388               if ($hl && $index == $hl_pos) {
389                    $element = sprintf('<span class="page-title">%s</span>',$element);
390               }
391               $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' &rsaquo; ') : ($index == 0 ? ' ' : ' &rsaquo; ')).
392                    ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : '');
393               $index++;
394          }
395          $res .= '</h2>';
396          return $res;
397     }
398
399     public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message')
400     {
401          global $core;
402
403          $res = '';
404          if ($msg != '') {
405               $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'.
406               ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg.
407               '</p>'.($div ? '</div>' : '');
408               if ($echo) {
409                    echo $res;
410               }
411          }
412          return $res;
413     }
414
415     public static function success($msg,$timestamp=true,$div=false,$echo=true)
416     {
417          return self::message($msg,$timestamp,$div,$echo,"success");
418     }
419
420     public static function warning($msg,$timestamp=true,$div=false,$echo=true)
421     {
422          return self::message($msg,$timestamp,$div,$echo,"warning-msg");
423     }
424
425     private static function debugInfo()
426     {
427          $global_vars = implode(', ',array_keys($GLOBALS));
428
429          $res =
430          '<div id="debug"><div>'.
431          '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>';
432
433          if (function_exists('xdebug_get_profiler_filename'))
434          {
435               $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>';
436
437               $prof_file = xdebug_get_profiler_filename();
438               if ($prof_file) {
439                    $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>';
440               } else {
441                    $prof_url = http::getSelfURI();
442                    $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&';
443                    $prof_url .= 'XDEBUG_PROFILE';
444                    $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>';
445               }
446
447               /* xdebug configuration:
448               zend_extension = /.../xdebug.so
449               xdebug.auto_trace = On
450               xdebug.trace_format = 0
451               xdebug.trace_options = 1
452               xdebug.show_mem_delta = On
453               xdebug.profiler_enable = 0
454               xdebug.profiler_enable_trigger = 1
455               xdebug.profiler_output_dir = /tmp
456               xdebug.profiler_append = 0
457               xdebug.profiler_output_name = timestamp
458               */
459          }
460
461          $res .=
462          '<p>Global vars: '.$global_vars.'</p>'.
463          '</div></div>';
464
465          return $res;
466     }
467
468     public static function help($page,$index='')
469     {
470          # Deprecated but we keep this for plugins.
471     }
472
473     public static function helpBlock()
474     {
475          $args = func_get_args();
476
477          $args = new ArrayObject($args);
478
479          # --BEHAVIOR-- adminPageHelpBlock
480          $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args);
481
482          if (empty($args)) {
483               return;
484          };
485
486          global $__resources;
487          if (empty($__resources['help'])) {
488               return;
489          }
490
491          $content = '';
492          foreach ($args as $v)
493          {
494               if (is_object($v) && isset($v->content)) {
495                    $content .= $v->content;
496                    continue;
497               }
498
499               if (!isset($__resources['help'][$v])) {
500                    continue;
501               }
502               $f = $__resources['help'][$v];
503               if (!file_exists($f) || !is_readable($f)) {
504                    continue;
505               }
506
507               $fc = file_get_contents($f);
508               if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) {
509                    $content .= $matches[1];
510               } else {
511                    $content .= $fc;
512               }
513          }
514
515          if (trim($content) == '') {
516               return;
517          }
518
519          // Set contextual help global flag
520          $GLOBALS['__resources']['ctxhelp'] = true;
521
522          echo
523          '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'.
524          $content.
525          '</div>'.
526          '<div id="helplink"><hr />'.
527          '<p>'.
528          sprintf(__('See also %s'),sprintf('<a href="help.php">%s</a>',__('the global help'))).
529          '.</p>'.
530          '</div></div>';
531     }
532
533     public static function jsLoad($src)
534     {
535          $escaped_src = html::escapeHTML($src);
536          if (!isset(self::$loaded_js[$escaped_src])) {
537               self::$loaded_js[$escaped_src]=true;
538               return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n";
539          }
540     }
541
542     public static function jsVar($n,$v)
543     {
544          return $n." = '".html::escapeJS($v)."';\n";
545     }
546
547     public static function jsToggles()
548     {
549          if($GLOBALS['core']->auth->user_prefs->toggles) {
550               $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections);
551               foreach ($unfolded_sections as $k=>&$v) {
552                    if ($v == '') {
553                         unset($unfolded_sections[$k]);
554                    } else {
555                         $v = "'".html::escapeJS($v)."':true";
556                    }
557               }
558          } else {
559               $unfolded_sections=array();
560          }
561          return '<script type="text/javascript">'."\n".
562                         "//<![CDATA[\n".
563                         'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n".
564                         "\n//]]>\n".
565                    "</script>\n";
566     }
567
568     public static function jsCommon()
569     {
570          $mute_or_no = '';
571          if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) {
572               $mute_or_no .=
573                    '<script type="text/javascript">'."\n".
574                    "//<![CDATA[\n".
575                    'jQuery.migrateMute = true;'.
576                    "\n//]]>\n".
577                    "</script>\n";
578          }
579
580          return
581          self::jsLoad('js/jquery/jquery.js').
582          $mute_or_no.
583          self::jsLoad('js/jquery/jquery-migrate-1.2.1.js').
584          self::jsLoad('js/jquery/jquery.biscuit.js').
585          self::jsLoad('js/jquery/jquery.bgFade.js').
586          self::jsLoad('js/common.js').
587          self::jsLoad('js/prelude.js').
588
589          '<script type="text/javascript">'."\n".
590          "//<![CDATA[\n".
591          'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n".
592          self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()).
593          self::jsVar('dotclear.img_plus_src','images/expand.png').
594          self::jsVar('dotclear.img_plus_alt',__('uncover')).
595          self::jsVar('dotclear.img_minus_src','images/hide.png').
596          self::jsVar('dotclear.img_minus_alt',__('hide')).
597          self::jsVar('dotclear.img_menu_on','images/menu_on.png').
598          self::jsVar('dotclear.img_menu_off','images/menu_off.png').
599
600          self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png').
601          self::jsVar('dotclear.img_plus_theme_alt',__('uncover')).
602          self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png').
603          self::jsVar('dotclear.img_minus_theme_alt',__('hide')).
604
605          self::jsVar('dotclear.msg.help',
606               __('Need help?')).
607          self::jsVar('dotclear.msg.new_window',
608               __('new window')).
609          self::jsVar('dotclear.msg.help_hide',
610               __('Hide')).
611          self::jsVar('dotclear.msg.to_select',
612               __('Select:')).
613          self::jsVar('dotclear.msg.no_selection',
614               __('no selection')).
615          self::jsVar('dotclear.msg.select_all',
616               __('select all')).
617          self::jsVar('dotclear.msg.invert_sel',
618               __('Invert selection')).
619          self::jsVar('dotclear.msg.website',
620               __('Web site:')).
621          self::jsVar('dotclear.msg.email',
622               __('Email:')).
623          self::jsVar('dotclear.msg.ip_address',
624               __('IP address:')).
625          self::jsVar('dotclear.msg.error',
626               __('Error:')).
627          self::jsVar('dotclear.msg.entry_created',
628               __('Entry has been successfully created.')).
629          self::jsVar('dotclear.msg.edit_entry',
630               __('Edit entry')).
631          self::jsVar('dotclear.msg.view_entry',
632               __('view entry')).
633          self::jsVar('dotclear.msg.confirm_delete_posts',
634               __("Are you sure you want to delete selected entries (%s)?")).
635          self::jsVar('dotclear.msg.confirm_delete_medias',
636               __("Are you sure you want to delete selected medias (%d)?")).
637          self::jsVar('dotclear.msg.confirm_delete_categories',
638               __("Are you sure you want to delete selected categories (%s)?")).
639          self::jsVar('dotclear.msg.confirm_delete_post',
640               __("Are you sure you want to delete this entry?")).
641          self::jsVar('dotclear.msg.click_to_unlock',
642               __("Click here to unlock the field")).
643          self::jsVar('dotclear.msg.confirm_spam_delete',
644               __('Are you sure you want to delete all spams?')).
645          self::jsVar('dotclear.msg.confirm_delete_comments',
646               __('Are you sure you want to delete selected comments (%s)?')).
647          self::jsVar('dotclear.msg.confirm_delete_comment',
648               __('Are you sure you want to delete this comment?')).
649          self::jsVar('dotclear.msg.cannot_delete_users',
650               __('Users with posts cannot be deleted.')).
651          self::jsVar('dotclear.msg.confirm_delete_user',
652               __('Are you sure you want to delete selected users (%s)?')).
653          self::jsVar('dotclear.msg.confirm_delete_category',
654               __('Are you sure you want to delete category "%s"?')).
655          self::jsVar('dotclear.msg.confirm_reorder_categories',
656               __('Are you sure you want to reorder all categories?')).
657          self::jsVar('dotclear.msg.confirm_delete_media',
658               __('Are you sure you want to remove media "%s"?')).
659          self::jsVar('dotclear.msg.confirm_delete_directory',
660               __('Are you sure you want to remove directory "%s"?')).
661          self::jsVar('dotclear.msg.confirm_extract_current',
662               __('Are you sure you want to extract archive in current directory?')).
663          self::jsVar('dotclear.msg.confirm_remove_attachment',
664               __('Are you sure you want to remove attachment "%s"?')).
665          self::jsVar('dotclear.msg.confirm_delete_lang',
666               __('Are you sure you want to delete "%s" language?')).
667          self::jsVar('dotclear.msg.confirm_delete_plugin',
668               __('Are you sure you want to delete "%s" plugin?')).
669          self::jsVar('dotclear.msg.confirm_delete_plugins',
670               __('Are you sure you want to delete selected plugins?')).
671          self::jsVar('dotclear.msg.use_this_theme',
672               __('Use this theme')).
673          self::jsVar('dotclear.msg.remove_this_theme',
674               __('Remove this theme')).
675          self::jsVar('dotclear.msg.confirm_delete_theme',
676               __('Are you sure you want to delete "%s" theme?')).
677          self::jsVar('dotclear.msg.confirm_delete_themes',
678               __('Are you sure you want to delete selected themes?')).
679          self::jsVar('dotclear.msg.confirm_delete_backup',
680               __('Are you sure you want to delete this backup?')).
681          self::jsVar('dotclear.msg.confirm_revert_backup',
682               __('Are you sure you want to revert to this backup?')).
683          self::jsVar('dotclear.msg.zip_file_content',
684               __('Zip file content')).
685          self::jsVar('dotclear.msg.xhtml_validator',
686               __('XHTML markup validator')).
687          self::jsVar('dotclear.msg.xhtml_valid',
688               __('XHTML content is valid.')).
689          self::jsVar('dotclear.msg.xhtml_not_valid',
690               __('There are XHTML markup errors.')).
691          self::jsVar('dotclear.msg.warning_validate_no_save_content',
692               __('Attention: an audit of a content not yet registered.')).
693          self::jsVar('dotclear.msg.confirm_change_post_format',
694               __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')).
695          self::jsVar('dotclear.msg.confirm_change_post_format_noconvert',
696               __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")).
697          self::jsVar('dotclear.msg.load_enhanced_uploader',
698               __('Loading enhanced uploader, please wait.')).
699
700          self::jsVar('dotclear.msg.module_author',
701               __('Author:')).
702          self::jsVar('dotclear.msg.module_details',
703               __('Details')).
704          self::jsVar('dotclear.msg.module_support',
705               __('Support')).
706          self::jsVar('dotclear.msg.module_help',
707               __('Help:')).
708          self::jsVar('dotclear.msg.module_section',
709               __('Section:')).
710          self::jsVar('dotclear.msg.module_tags',
711               __('Tags:')).
712               "\n//]]>\n".
713          "</script>\n";
714     }
715
716     public static function jsLoadIE7()
717     {
718          return
719          '<!--[if lt IE 9]>'."\n".
720          self::jsLoad('js/ie7/IE9.js').
721          '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n".
722          '<![endif]-->'."\n";
723     }
724
725     public static function jsConfirmClose()
726     {
727          $args = func_get_args();
728          if (count($args) > 0) {
729               foreach ($args as $k => $v) {
730                    $args[$k] = "'".html::escapeJS($v)."'";
731               }
732               $args = implode(',',$args);
733          } else {
734               $args = '';
735          }
736
737          return
738          self::jsLoad('js/confirm-close.js').
739          '<script type="text/javascript">'."\n".
740          "//<![CDATA[\n".
741          "confirmClosePage = new confirmClose(".$args."); ".
742          "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ".
743          "\n//]]>\n".
744          "</script>\n";
745     }
746
747     public static function jsPageTabs($default=null)
748     {
749          if ($default) {
750               $default = "'".html::escapeJS($default)."'";
751          }
752
753          return
754          self::jsLoad('js/jquery/jquery.pageTabs.js').
755          '<script type="text/javascript">'."\n".
756          "//<![CDATA[\n".
757          '$(function() {'."\n".
758          '$.pageTabs('.$default.');'."\n".
759          '});'.
760          "\n//]]>\n".
761          "</script>\n".
762          '<!--[if lt IE 8]>'."\n".
763          self::jsLoad('js/ie7/ie7-hashchange.js').
764          '<script type="text/javascript">'."\n".
765          "//<![CDATA[\n".
766          '$(window).hashchange();'.
767          "\n//]]>\n".
768          "</script>\n".
769          '<![endif]-->'."\n";
770     }
771
772     public static function jsModal()
773     {
774          return
775          '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n".
776          self::jsLoad('js/jquery/jquery.modal.js').
777          '<script type="text/javascript">'."\n".
778          "//<![CDATA[\n".
779          self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif').
780          self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png').
781          "\n//]]>\n".
782          "</script>\n";
783     }
784
785     public static function jsColorPicker()
786     {
787          return
788          '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n".
789          self::jsLoad('js/jquery/jquery.farbtastic.js').
790          self::jsLoad('js/color-picker.js');
791     }
792
793     public static function jsDatePicker()
794     {
795          return
796          '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n".
797          self::jsLoad('js/date-picker.js').
798          '<script type="text/javascript">'."\n".
799          "//<![CDATA[\n".
800
801          "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ".
802          "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ".
803          "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ".
804          "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ".
805          "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ".
806          "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ".
807          "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ".
808          "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ".
809          "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ".
810          "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ".
811          "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ".
812          "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ".
813
814          "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ".
815          "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ".
816          "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ".
817          "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ".
818          "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ".
819          "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ".
820          "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ".
821
822          "datePicker.prototype.img_src = 'images/date-picker.png'; ".
823
824          "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ".
825          "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ".
826
827          "\n//]]>\n".
828          "</script>\n";
829     }
830
831     
832     public static function jsToolBar()
833     {
834          # Deprecated but we keep this for plugins.
835     }
836
837     public static function jsUpload($params=array(),$base_url=null)
838     {
839          if (!$base_url) {
840               $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';
841          }
842
843          $params = array_merge($params,array(
844               'sess_id='.session_id(),
845               'sess_uid='.$_SESSION['sess_browser_uid'],
846               'xd_check='.$GLOBALS['core']->getNonce()
847          ));
848
849          return
850          '<script type="text/javascript">'."\n".
851          "//<![CDATA[\n".
852          "dotclear.jsUpload = {};\n".
853          "dotclear.jsUpload.msg = {};\n".
854          self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')).
855          self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')).
856          self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')).
857          self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')).
858          self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')).
859          self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')).
860          self::jsVar('dotclear.jsUpload.msg.error',__('Error:')).
861          self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')).
862          self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')).
863          self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')).
864          self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')).
865          self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')).
866          self::jsVar('dotclear.jsUpload.msg.send',__('Send')).
867          self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')).
868          self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')).
869          self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')).
870          self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')).
871          self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')).
872          self::jsVar('dotclear.jsUpload.base_url',$base_url).
873          "\n//]]>\n".
874          "</script>\n".
875
876          self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js').
877          self::jsLoad('js/jsUpload/tmpl.js').
878          self::jsLoad('js/jsUpload/template-upload.js').
879          self::jsLoad('js/jsUpload/template-download.js').
880          self::jsLoad('js/jsUpload/load-image.js').
881          self::jsLoad('js/jsUpload/jquery.iframe-transport.js').
882          self::jsLoad('js/jsUpload/jquery.fileupload.js').
883          self::jsLoad('js/jsUpload/jquery.fileupload-process.js').
884          self::jsLoad('js/jsUpload/jquery.fileupload-resize.js').
885          self::jsLoad('js/jsUpload/jquery.fileupload-ui.js');
886     }
887
888     public static function jsToolMan()
889     {
890          return
891          '<script type="text/javascript" src="js/tool-man/core.js"></script>'.
892          '<script type="text/javascript" src="js/tool-man/events.js"></script>'.
893          '<script type="text/javascript" src="js/tool-man/css.js"></script>'.
894          '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'.
895          '<script type="text/javascript" src="js/tool-man/drag.js"></script>'.
896          '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'.
897          '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>';
898     }
899
900     public static function jsMetaEditor()
901     {
902          return
903          '<script type="text/javascript" src="js/meta-editor.js"></script>';
904     }
905}
Note: See TracBrowser for help on using the repository browser.

Sites map