Dotclear

source: inc/admin/lib.dc.page.php @ 3129:6f41108168cf

Revision 3129:6f41108168cf, 30.3 KB checked in by Gvx <gvx@…>, 10 years ago (diff)

Replace "&" with "&amp;" in the appendVersion function

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

Sites map