Dotclear

source: inc/admin/lib.dc.page.php @ 2304:2572fec6e42e

Revision 2304:2572fec6e42e, 32.2 KB checked in by Nicolas <nikrou77@…>, 12 years ago (diff)

Add link "go to help" in prelude. Remove onclick on help-button.
Closes #1755

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

Sites map