Dotclear

source: inc/admin/lib.dc.page.php @ 3460:ab90fe0bd783

Revision 3460:ab90fe0bd783, 35.6 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Add a javascript button to hide dotclear notice

RevLine 
[0]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[1179]6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]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{
[2503]18     private static $loaded_js = array();
[3021]19     private static $loaded_css = array();
[2909]20     private static $xframe_loaded = false;
[2328]21     private static $N_TYPES = array(
[2503]22          "success" => "success",
23          "warning" => "warning-msg",
24          "error" => "error",
25          "message" => "message",
[2328]26          "static" => "static-msg");
[342]27
[0]28     # Auth check
29     public static function check($permissions)
30     {
31          global $core;
[1187]32
[2503]33          if ($core->blog && $core->auth->check($permissions,$core->blog->id)) {
[0]34               return;
35          }
[1187]36
[0]37          if (session_id()) {
38               $core->session->destroy();
39          }
40          http::redirect(DC_AUTH_PAGE);
41     }
[1187]42
[0]43     # Check super admin
44     public static function checkSuper()
45     {
46          global $core;
[1187]47
[0]48          if (!$core->auth->isSuperAdmin())
49          {
50               if (session_id()) {
51                    $core->session->destroy();
52               }
53               http::redirect(DC_AUTH_PAGE);
54          }
55     }
[1187]56
[0]57     # Top of admin page
[2907]58     public static function open($title='',$head='',$breadcrumb='',$options=array())
[0]59     {
60          global $core;
[1144]61
[0]62          # List of user's blogs
[2159]63          if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20)
[0]64          {
65               $blog_box =
[999]66               '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'.
[0]67               html::escapeHTML($core->blog->name).'</strong>';
[1187]68
[2159]69               if ($core->auth->getBlogCount() > 20) {
[2720]70                    $blog_box .= ' - <a href="'.$core->adminurl->get("admin.blogs").'">'.__('Change blog').'</a>';
[0]71               }
[999]72               $blog_box .= '</p>';
[0]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 =
[2005]82               '<p><label for="switchblog" class="classic">'.
[1309]83               __('Blogs:').'</label> '.
[0]84               $core->formNonce().
[454]85               form::combo('switchblog',$blogs,$core->blog->id).
[2005]86               '<input type="submit" value="'.__('ok').'" class="hidden-if-js" /></p>';
[0]87          }
[1187]88
[36]89          $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'];
[1187]90
[0]91          # Display
[3292]92          $headers = new ArrayObject(array());
[2792]93
[3279]94          # Content-Type
95          $headers['content-type'] = 'Content-Type: text/html; charset=UTF-8';
96
97          # Prevents Clickjacking as far as possible
[2907]98          if (isset($options['x-frame-allow'])) {
[3279]99               self::setXFrameOptions($headers,$options['x-frame-allow']);
[2907]100          } else {
[3279]101               self::setXFrameOptions($headers);
[2907]102          }
[3276]103
[3291]104          # Content-Security-Policy
105          if ($core->blog->settings->system->csp_admin_on) {
[3292]106               // Get directives from settings if exist, else set defaults
107               $csp = new ArrayObject(array());
[3432]108
109               // SQlite Clearbricks driver does not allow using single quote at beginning or end of a field value
110               // so we have to use neutral values (localhost and 127.0.0.1) for some CSP directives
111               $csp_prefix = $core->con->driver() == 'sqlite' ? 'localhost ' : '';   // Hack for SQlite Clearbricks driver
112               $csp_suffix = $core->con->driver() == 'sqlite' ? ' 127.0.0.1' : '';   // Hack for SQlite Clearbricks driver
113
114               $csp['default-src'] = $core->blog->settings->system->csp_admin_default ?:
115                    $csp_prefix."'self'".$csp_suffix;
116               $csp['script-src'] = $core->blog->settings->system->csp_admin_script ?:
117                    $csp_prefix."'self' 'unsafe-inline' 'unsafe-eval'".$csp_suffix;
118               $csp['style-src'] = $core->blog->settings->system->csp_admin_style ?:
119                    $csp_prefix."'self' 'unsafe-inline'".$csp_suffix;
120               $csp['img-src'] = $core->blog->settings->system->csp_admin_img ?:
121                    $csp_prefix."'self' data: media.dotaddict.org blob:";
[3292]122
[3307]123               # Cope with blog post preview (via public URL in iframe)
124               if (!is_null($core->blog->host)) {
125                    $csp['default-src'] .= ' '.parse_url($core->blog->host,PHP_URL_HOST);
126               }
127               # Cope with media display in media manager (via public URL)
128               if (!is_null($core->media)) {
129                    $csp['img-src'] .= ' '.parse_url($core->media->root_url,PHP_URL_HOST);
130               }
[3319]131               # Allow everything in iframe (used by editors to preview public content)
132               $csp['child-src'] = "*";
[3307]133
[3292]134               # --BEHAVIOR-- adminPageHTTPHeaderCSP
135               $core->callBehavior('adminPageHTTPHeaderCSP',$csp);
136
137               // Construct CSP header
138               $directives = array();
139               foreach ($csp as $key => $value) {
140                    if ($value) {
141                         $directives[] = $key.' '.$value;
142                    }
143               }
144               if (count($directives)) {
145                    if (version_compare(phpversion(),'5.4','>=')) {
146                         // csp_report.php needs PHP ≥ 5.4
147                         $directives[] = "report-uri ".DC_ADMIN_URL."csp_report.php";
148                    }
[3326]149                    $report_only = ($core->blog->settings->system->csp_admin_report_only) ? '-Report-Only' : '';
150                    $headers['csp'] = "Content-Security-Policy".$report_only.": ".implode(" ; ",$directives);
[3292]151               }
[3291]152          }
[3279]153
154          # --BEHAVIOR-- adminPageHTTPHeaders
155          $core->callBehavior('adminPageHTTPHeaders',$headers);
156          foreach ($headers as $key => $value) {
157               header($value);
158          }
[3276]159
[0]160          echo
[2760]161          '<!DOCTYPE html>'.
162          '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n".
[0]163          "<head>\n".
[2760]164          '  <meta charset="UTF-8" />'."\n".
[0]165          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
166          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
[1310]167          '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n".
[489]168          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
[1187]169
170
[3021]171          self::cssLoad('style/default.css');
[0]172          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
[3021]173               echo self::cssLoad('style/default-rtl.css');
[0]174          }
[237]175
[244]176          $core->auth->user_prefs->addWorkspace('interface');
177          $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
178          if (!$user_ui_hide_std_favicon) {
[2503]179               echo
[3021]180               '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'."\n".
181               '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'."\n";
[244]182          }
[3408]183
184          if ($core->auth->user_prefs->interface->htmlfontsize) {
185               echo
186               '<script type="text/javascript">'."\n".
[3421]187               self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize)."\n".
[3408]188               "</script>\n";
189          }
190
[0]191          echo
192          self::jsCommon().
[1699]193          self::jsToggles().
[0]194          $head;
[1187]195
[3398]196          if ($core->auth->user_prefs->interface->hidemoreinfo) {
197               echo
198               '<script type="text/javascript">'."\n".
[3421]199               'dotclear.hideMoreInfo = true;'."\n".
[3398]200               "</script>\n";
201          }
202
[0]203          # --BEHAVIOR-- adminPageHTMLHead
204          $core->callBehavior('adminPageHTMLHead');
[1187]205
[0]206          echo
207          "</head>\n".
[36]208          '<body id="dotclear-admin'.
[1586]209          ($safe_mode ? ' safe-mode' : '').'" class="no-js">'."\n".
[1187]210
[1590]211          '<ul id="prelude">'.
212          '<li><a href="#content">'.__('Go to the content').'</a></li>'.
213          '<li><a href="#main-menu">'.__('Go to the menu').'</a></li>'.
214          '<li><a href="#qx">'.__('Go to search').'</a></li>'.
[2304]215          '<li><a href="#help">'.__('Go to help').'</a></li>'.
[1590]216          '</ul>'."\n".
[2784]217          '<div id="header" role="banner">'.
[2720]218          '<h1><a href="'.$core->adminurl->get("admin.home").'"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n";
[1187]219
[0]220          echo
[2720]221          '<form action="'.$core->adminurl->get("admin.home").'" method="post" id="top-info-blog">'.
[0]222          $blog_box.
[2225]223          '<p><a href="'.$core->blog->url.'" class="outgoing" title="'.__('Go to site').
224          '">'.__('Go to site').'<img src="images/outgoing.png" alt="" /></a>'.
[999]225          '</p></form>'.
[2005]226          '<ul id="top-info-user">'.
[2817]227          '<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>'.
228          '<li><a class="smallscreen'.(preg_match('/'.preg_quote($core->adminurl->get('admin.user.preferences')).'(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : '').
[2720]229          '" href="'.$core->adminurl->get("admin.user.preferences").'">'.__('My preferences').'</a></li>'.
230          '<li><a href="'.$core->adminurl->get("admin.home",array('logout' => 1)).'" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()).
[2034]231          '</span><img src="images/logout.png" alt="" /></a></li>'.
[2005]232          '</ul>'.
233          '</div>'; // end header
[1187]234
[0]235          echo
[1741]236          '<div id="wrapper" class="clearfix">'."\n".
[3445]237          '<div class="hidden-if-no-js collapser-box"><button type="button" id="collapser" class="void-btn">'.
[3355]238          '<img class="collapse-mm visually-hidden" src="images/collapser-hide.png" alt="'.__('Hide main menu').'" />'.
239          '<img class="expand-mm visually-hidden" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'.
[3434]240          '</button></div>'.
[2784]241          '<div id="main" role="main">'."\n".
[1741]242          '<div id="content" class="clearfix">'."\n";
[1187]243
[36]244          # Safe mode
245          if ($safe_mode)
[0]246          {
247               echo
[2787]248               '<div class="warning" role="alert"><h3>'.__('Safe mode').'</h3>'.
[37]249               '<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>'.
[0]250               '</div>';
251          }
[1187]252
[3076]253          // Display breadcrumb (if given) before any error messages
[1357]254          echo $breadcrumb;
[1355]255
[3076]256          // Display notices and errors
[2199]257          echo self::notices();
258     }
259
260     public static function notices()
261     {
[3076]262          global $core;
263          static $error_displayed = false;
[3457]264
[3076]265          $res = '';
266
267          // return error messages if any
268          if ($core->error->flag() && !$error_displayed) {
[3457]269
270               # --BEHAVIOR-- adminPageNotificationError
[3459]271               $notice_error = $core->callBehavior('adminPageNotificationError',$core,$core->error);
[3457]272
[3458]273               if (isset($notice_error) && !empty($notice_error)) {
[3457]274                    $res .= $notice_error;
275               } else {
276                    $res .= '<div class="error"><p>'.
277                         '<strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong>'.
278                         '</p>'.$core->error->toHTML().'</div>';
279               }
[3076]280               $error_displayed = true;
281          }
282
[2199]283          // return notices if any
[2181]284          if (isset($_SESSION['notifications'])) {
[2328]285               foreach ($_SESSION['notifications'] as $notification) {
[3457]286
287                    # --BEHAVIOR-- adminPageNotification
[3459]288                    $notice = $core->callBehavior('adminPageNotification',$core,$notification);
[3457]289
[3458]290                    $res .= (isset($notice) && !empty($notice) ? $notice : self::getNotification($notification));
[2181]291               }
292               unset($_SESSION['notifications']);
293          }
[2199]294          return $res;
[0]295     }
[2191]296
[2328]297     public static function addNotice($type,$message,$options=array())
[2191]298     {
[2328]299          if (isset(self::$N_TYPES[$type])){
300               $class = self::$N_TYPES[$type];
301          } else {
302               $class=$type;
303          }
304          if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) {
305               $notifications = $_SESSION['notifications'];
306          } else {
307               $notifications = array();
308          }
[2503]309
[2328]310          $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message));
311          if ($type != "static") {
312               $notifications[] = $n;
313          } else {
314               array_unshift($notifications, $n);
315          }
316          $_SESSION['notifications'] = $notifications;
[2181]317     }
[2191]318
[2328]319     public static function addSuccessNotice($message,$options=array())
[2191]320     {
[2328]321          self::addNotice("success",$message,$options);
[2181]322     }
[2191]323
[2328]324     public static function addWarningNotice($message,$options=array())
[2191]325     {
[2328]326          self::addNotice("warning",$message,$options);
[2181]327     }
[2191]328
[2328]329     public static function addErrorNotice($message,$options=array())
[2191]330     {
[2328]331          self::addNotice("error",$message,$options);
[2191]332     }
333
[2328]334     protected static function getNotification($n)
[2191]335     {
[2181]336          global $core;
[3340]337          $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p';
[2328]338          $ts = '';
339          if (!isset($n['with_ts']) || ($n['with_ts'] == true)) {
340               $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' ';
341          }
[2787]342          $res = '<'.$tag.' class="'.$n['class'].'" role="alert">'.$ts.$n['text'].'</'.$tag.'>';
[2191]343          return $res;
[2181]344     }
[2191]345
[0]346     public static function close()
347     {
[942]348          global $core;
349
[1933]350          if (!$GLOBALS['__resources']['ctxhelp']) {
351               echo
[2720]352               '<p id="help-button"><a href="'.$core->adminurl->get("admin.help").'" class="outgoing" title="'.
[2306]353               __('Global help').'">'.__('Global help').'</a></p>';
[1933]354          }
355
[0]356          $menu =& $GLOBALS['_menu'];
[1187]357
[0]358          echo
359          "</div>\n".         // End of #content
360          "</div>\n".         // End of #main
[1187]361
[2784]362          '<div id="main-menu" role="navigation">'."\n".
[1311]363
[2769]364          '<form id="search-menu" action="'.$core->adminurl->get("admin.search").'" method="get" role="search">'.
[1589]365          '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,'').
[1311]366          '<input type="submit" value="'.__('OK').'" /></p>'.
367          '</form>';
[1187]368
[0]369          foreach ($menu as $k => $v) {
370               echo $menu[$k]->draw();
371          }
[1187]372
[1140]373          $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION);
[942]374
375          # --BEHAVIOR-- adminPageFooter
[946]376          $textAlt = $core->callBehavior('adminPageFooter',$core,$text);
[1140]377          if ($textAlt != '') {
378               $text = $textAlt;
379          }
[1142]380          $text = html::escapeHTML($text);
[942]381
[0]382          echo
383          '</div>'."\n".      // End of #main-menu
[1946]384          "</div>\n";         // End of #wrapper
[1861]385
[3294]386          echo '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n";
387
[3060]388          $figure = "
[3224]389   /\_/\
390  (='.'=)
[3454]391  (\")-(\")";
[3060]392
[1946]393          echo
[2784]394          '<div id="footer" role="contentinfo">'.
[2296]395          '<a href="http://dotclear.org/" title="'.$text.'">'.
396          '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n".
[2796]397          "<!-- "."\n".
[3060]398          $figure.
[2796]399          " -->"."\n";
[1187]400
[3294]401
402
[0]403          if (defined('DC_DEV') && DC_DEV === true) {
404               echo self::debugInfo();
405          }
[1187]406
[0]407          echo
408          '</body></html>';
409     }
[1187]410
[1358]411     public static function openPopup($title='',$head='',$breadcrumb='')
[0]412     {
413          global $core;
[1187]414
[0]415          # Display
416          header('Content-Type: text/html; charset=UTF-8');
[2792]417
418          // Prevents Clickjacking as far as possible
419          header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
420
[0]421          echo
[2760]422          '<!DOCTYPE html>'.
423          '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n".
[0]424          "<head>\n".
[2760]425          '  <meta charset="UTF-8" />'."\n".
[2513]426          '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n".
[0]427          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
[1187]428
[0]429          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
430          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
[1187]431
[3021]432          self::cssLoad('style/default.css');
[0]433          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
[3021]434               echo self::cssLoad('style/default-rtl.css');
[0]435          }
[1187]436
[3408]437          $core->auth->user_prefs->addWorkspace('interface');
438          if ($core->auth->user_prefs->interface->htmlfontsize) {
439               echo
440               '<script type="text/javascript">'."\n".
[3421]441               self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize)."\n".
[3408]442               "</script>\n";
443          }
444
[0]445          echo
446          self::jsCommon().
[1699]447          self::jsToggles().
[0]448          $head;
[1187]449
[3398]450          if ($core->auth->user_prefs->interface->hidemoreinfo) {
451               echo
452               '<script type="text/javascript">'."\n".
[3421]453               'dotclear.hideMoreInfo = true;'."\n".
[3398]454               "</script>\n";
455          }
456
[0]457          # --BEHAVIOR-- adminPageHTMLHead
458          $core->callBehavior('adminPageHTMLHead');
[1187]459
[0]460          echo
461          "</head>\n".
462          '<body id="dotclear-admin" class="popup">'."\n".
[1187]463
[2046]464          '<h1>'.DC_VENDOR_NAME.'</h1>'."\n";
[1187]465
[0]466          echo
467          '<div id="wrapper">'."\n".
[2784]468          '<div id="main" role="main">'."\n".
[0]469          '<div id="content">'."\n";
[1187]470
[1358]471          // display breadcrumb if given
472          echo $breadcrumb;
473
[3076]474          // Display notices and errors
475          echo self::notices();
[0]476     }
[1187]477
[0]478     public static function closePopup()
479     {
480          echo
481          "</div>\n".         // End of #content
482          "</div>\n".         // End of #main
[2046]483          "</div>\n".         // End of #wrapper
[3294]484
485          '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n".
486
[2784]487          '<div id="footer" role="contentinfo"><p>&nbsp;</p></div>'."\n".
[0]488          '</body></html>';
489     }
[907]490
[2166]491     public static function breadcrumb($elements=null,$options=array())
[1328]492     {
[2720]493          global $core;
[3340]494          $with_home_link = isset($options['home_link']) ? $options['home_link'] : true;
495          $hl = isset($options['hl']) ? $options['hl'] : true;
496          $hl_pos = isset($options['hl_pos']) ? $options['hl_pos'] : -1;
[1328]497          // First item of array elements should be blog's name, System or Plugins
[1340]498          $res = '<h2>'.($with_home_link ?
[2720]499               '<a class="go_home" href="'.$core->adminurl->get("admin.home").'"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' :
[1340]500               '<img src="style/dashboard-alt.png" alt="" />');
[1328]501          $index = 0;
[2167]502          if ($hl_pos < 0) {
503               $hl_pos = count($elements)+$hl_pos;
[2166]504          }
[1328]505          foreach ($elements as $element => $url) {
[2167]506               if ($hl && $index == $hl_pos) {
[2166]507                    $element = sprintf('<span class="page-title">%s</span>',$element);
508               }
[1358]509               $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' &rsaquo; ') : ($index == 0 ? ' ' : ' &rsaquo; ')).
510                    ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : '');
[1328]511               $index++;
512          }
513          $res .= '</h2>';
514          return $res;
515     }
516
[1548]517     public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message')
[907]518     {
[910]519          global $core;
[1187]520
[907]521          $res = '';
522          if ($msg != '') {
[1548]523               $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'.
[2191]524               ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg.
[1161]525               '</p>'.($div ? '</div>' : '');
[907]526               if ($echo) {
527                    echo $res;
528               }
529          }
530          return $res;
531     }
[1187]532
[1548]533     public static function success($msg,$timestamp=true,$div=false,$echo=true)
534     {
[1927]535          return self::message($msg,$timestamp,$div,$echo,"success");
[1548]536     }
537
[1725]538     public static function warning($msg,$timestamp=true,$div=false,$echo=true)
539     {
[1927]540          return self::message($msg,$timestamp,$div,$echo,"warning-msg");
[1725]541     }
542
[0]543     private static function debugInfo()
544     {
545          $global_vars = implode(', ',array_keys($GLOBALS));
[1187]546
[0]547          $res =
548          '<div id="debug"><div>'.
549          '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>';
[1187]550
[0]551          if (function_exists('xdebug_get_profiler_filename'))
552          {
553               $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>';
[1187]554
[0]555               $prof_file = xdebug_get_profiler_filename();
556               if ($prof_file) {
557                    $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>';
558               } else {
559                    $prof_url = http::getSelfURI();
[321]560                    $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&';
[0]561                    $prof_url .= 'XDEBUG_PROFILE';
[321]562                    $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>';
[0]563               }
[1187]564
[0]565               /* xdebug configuration:
566               zend_extension = /.../xdebug.so
567               xdebug.auto_trace = On
568               xdebug.trace_format = 0
569               xdebug.trace_options = 1
570               xdebug.show_mem_delta = On
571               xdebug.profiler_enable = 0
572               xdebug.profiler_enable_trigger = 1
573               xdebug.profiler_output_dir = /tmp
574               xdebug.profiler_append = 0
575               xdebug.profiler_output_name = timestamp
576               */
577          }
[1187]578
[0]579          $res .=
580          '<p>Global vars: '.$global_vars.'</p>'.
581          '</div></div>';
[1187]582
[0]583          return $res;
584     }
[1187]585
[0]586     public static function help($page,$index='')
587     {
588          # Deprecated but we keep this for plugins.
589     }
[1187]590
[0]591     public static function helpBlock()
592     {
[2720]593          global $core;
[0]594          $args = func_get_args();
[1458]595
596          $args = new ArrayObject($args);
597
598          # --BEHAVIOR-- adminPageHelpBlock
599          $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args);
600
[0]601          if (empty($args)) {
602               return;
603          };
[1187]604
[0]605          global $__resources;
606          if (empty($__resources['help'])) {
607               return;
608          }
[1187]609
[0]610          $content = '';
611          foreach ($args as $v)
612          {
613               if (is_object($v) && isset($v->content)) {
614                    $content .= $v->content;
615                    continue;
616               }
[1187]617
[0]618               if (!isset($__resources['help'][$v])) {
619                    continue;
620               }
621               $f = $__resources['help'][$v];
622               if (!file_exists($f) || !is_readable($f)) {
623                    continue;
624               }
[1187]625
[0]626               $fc = file_get_contents($f);
627               if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) {
628                    $content .= $matches[1];
629               } else {
630                    $content .= $fc;
631               }
632          }
[1187]633
[0]634          if (trim($content) == '') {
635               return;
636          }
[1187]637
[1933]638          // Set contextual help global flag
639          $GLOBALS['__resources']['ctxhelp'] = true;
640
[0]641          echo
[1573]642          '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'.
[0]643          $content.
[494]644          '</div>'.
645          '<div id="helplink"><hr />'.
646          '<p>'.
[2720]647          sprintf(__('See also %s'),sprintf('<a href="'.$core->adminurl->get("admin.help").'">%s</a>',__('the global help'))).
[2011]648          '.</p>'.
[0]649          '</div></div>';
650     }
[1187]651
[3086]652     public static function cssLoad($src,$media='screen',$v='')
[3021]653     {
654          $escaped_src = html::escapeHTML($src);
655          if (!isset(self::$loaded_css[$escaped_src])) {
656               self::$loaded_css[$escaped_src] = true;
[3086]657               $escaped_src = self::appendVersion($escaped_src,$v);
[3021]658
659               return '<link rel="stylesheet" href="'.$escaped_src.'" type="text/css" media="'.$media.'" />'."\n";
660          }
661     }
662
[3086]663     public static function jsLoad($src,$v='')
[0]664     {
[342]665          $escaped_src = html::escapeHTML($src);
666          if (!isset(self::$loaded_js[$escaped_src])) {
[3020]667               self::$loaded_js[$escaped_src] = true;
[3086]668               $escaped_src = self::appendVersion($escaped_src,$v);
[342]669               return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n";
670          }
[0]671     }
[1187]672
[3086]673     private static function appendVersion($src,$v='')
[3021]674     {
[3129]675          $src .= (strpos($src,'?') === false ? '?' : '&amp;').'v=';
[3021]676          if (defined('DC_DEV') && DC_DEV === true) {
677               $src .= md5(uniqid());
678          } else {
[3086]679               $src .= ($v === '' ? DC_VERSION : $v);
[3021]680          }
681          return $src;
682     }
683
[0]684     public static function jsVar($n,$v)
685     {
686          return $n." = '".html::escapeJS($v)."';\n";
687     }
[1187]688
[1699]689     public static function jsToggles()
690     {
691          if($GLOBALS['core']->auth->user_prefs->toggles) {
692               $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections);
693               foreach ($unfolded_sections as $k=>&$v) {
694                    if ($v == '') {
695                         unset($unfolded_sections[$k]);
696                    } else {
697                         $v = "'".html::escapeJS($v)."':true";
698                    }
699               }
700          } else {
701               $unfolded_sections=array();
702          }
703          return '<script type="text/javascript">'."\n".
[3421]704                    'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n".
[1699]705                    "</script>\n";
706     }
[2503]707
[0]708     public static function jsCommon()
709     {
[1771]710          $mute_or_no = '';
[1841]711          if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) {
[1771]712               $mute_or_no .=
713                    '<script type="text/javascript">'."\n".
[3421]714                    'jQuery.migrateMute = true;'."\n".
[1771]715                    "</script>\n";
716          }
717
[0]718          return
719          self::jsLoad('js/jquery/jquery.js').
[1771]720          $mute_or_no.
[3178]721          self::jsLoad('js/jquery/jquery-migrate.js').
[0]722          self::jsLoad('js/jquery/jquery.biscuit.js').
723          self::jsLoad('js/jquery/jquery.bgFade.js').
724          self::jsLoad('js/common.js').
[447]725          self::jsLoad('js/prelude.js').
[1187]726
[0]727          '<script type="text/javascript">'."\n".
[2614]728          'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n".
[3460]729
[0]730          self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()).
[3460]731
[1019]732          self::jsVar('dotclear.img_plus_src','images/expand.png').
[0]733          self::jsVar('dotclear.img_plus_alt',__('uncover')).
[1019]734          self::jsVar('dotclear.img_minus_src','images/hide.png').
[0]735          self::jsVar('dotclear.img_minus_alt',__('hide')).
736          self::jsVar('dotclear.img_menu_on','images/menu_on.png').
737          self::jsVar('dotclear.img_menu_off','images/menu_off.png').
[2503]738
[2195]739          self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png').
740          self::jsVar('dotclear.img_plus_theme_alt',__('uncover')).
741          self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png').
742          self::jsVar('dotclear.img_minus_theme_alt',__('hide')).
[1187]743
[0]744          self::jsVar('dotclear.msg.help',
[1933]745               __('Need help?')).
[2225]746          self::jsVar('dotclear.msg.new_window',
747               __('new window')).
[1302]748          self::jsVar('dotclear.msg.help_hide',
749               __('Hide')).
[1556]750          self::jsVar('dotclear.msg.to_select',
751               __('Select:')).
[0]752          self::jsVar('dotclear.msg.no_selection',
753               __('no selection')).
754          self::jsVar('dotclear.msg.select_all',
755               __('select all')).
756          self::jsVar('dotclear.msg.invert_sel',
[1556]757               __('Invert selection')).
[0]758          self::jsVar('dotclear.msg.website',
759               __('Web site:')).
760          self::jsVar('dotclear.msg.email',
761               __('Email:')).
762          self::jsVar('dotclear.msg.ip_address',
763               __('IP address:')).
764          self::jsVar('dotclear.msg.error',
765               __('Error:')).
766          self::jsVar('dotclear.msg.entry_created',
767               __('Entry has been successfully created.')).
768          self::jsVar('dotclear.msg.edit_entry',
769               __('Edit entry')).
770          self::jsVar('dotclear.msg.view_entry',
771               __('view entry')).
772          self::jsVar('dotclear.msg.confirm_delete_posts',
773               __("Are you sure you want to delete selected entries (%s)?")).
[2202]774          self::jsVar('dotclear.msg.confirm_delete_medias',
775               __("Are you sure you want to delete selected medias (%d)?")).
[1525]776          self::jsVar('dotclear.msg.confirm_delete_categories',
777               __("Are you sure you want to delete selected categories (%s)?")).
[0]778          self::jsVar('dotclear.msg.confirm_delete_post',
779               __("Are you sure you want to delete this entry?")).
[1395]780          self::jsVar('dotclear.msg.click_to_unlock',
[1450]781               __("Click here to unlock the field")).
[1049]782          self::jsVar('dotclear.msg.confirm_spam_delete',
783               __('Are you sure you want to delete all spams?')).
[0]784          self::jsVar('dotclear.msg.confirm_delete_comments',
785               __('Are you sure you want to delete selected comments (%s)?')).
786          self::jsVar('dotclear.msg.confirm_delete_comment',
787               __('Are you sure you want to delete this comment?')).
788          self::jsVar('dotclear.msg.cannot_delete_users',
789               __('Users with posts cannot be deleted.')).
790          self::jsVar('dotclear.msg.confirm_delete_user',
791               __('Are you sure you want to delete selected users (%s)?')).
[3403]792          self::jsVar('dotclear.msg.confirm_delete_blog',
793               __('Are you sure you want to delete selected blogs (%s)?')).
[0]794          self::jsVar('dotclear.msg.confirm_delete_category',
795               __('Are you sure you want to delete category "%s"?')).
796          self::jsVar('dotclear.msg.confirm_reorder_categories',
797               __('Are you sure you want to reorder all categories?')).
798          self::jsVar('dotclear.msg.confirm_delete_media',
799               __('Are you sure you want to remove media "%s"?')).
[2512]800          self::jsVar('dotclear.msg.confirm_delete_directory',
801               __('Are you sure you want to remove directory "%s"?')).
[0]802          self::jsVar('dotclear.msg.confirm_extract_current',
803               __('Are you sure you want to extract archive in current directory?')).
804          self::jsVar('dotclear.msg.confirm_remove_attachment',
805               __('Are you sure you want to remove attachment "%s"?')).
806          self::jsVar('dotclear.msg.confirm_delete_lang',
807               __('Are you sure you want to delete "%s" language?')).
808          self::jsVar('dotclear.msg.confirm_delete_plugin',
809               __('Are you sure you want to delete "%s" plugin?')).
[2487]810          self::jsVar('dotclear.msg.confirm_delete_plugins',
811               __('Are you sure you want to delete selected plugins?')).
[0]812          self::jsVar('dotclear.msg.use_this_theme',
813               __('Use this theme')).
814          self::jsVar('dotclear.msg.remove_this_theme',
815               __('Remove this theme')).
816          self::jsVar('dotclear.msg.confirm_delete_theme',
817               __('Are you sure you want to delete "%s" theme?')).
[2487]818          self::jsVar('dotclear.msg.confirm_delete_themes',
819               __('Are you sure you want to delete selected themes?')).
[1462]820          self::jsVar('dotclear.msg.confirm_delete_backup',
821               __('Are you sure you want to delete this backup?')).
[2503]822          self::jsVar('dotclear.msg.confirm_revert_backup',
823               __('Are you sure you want to revert to this backup?')).
[0]824          self::jsVar('dotclear.msg.zip_file_content',
825               __('Zip file content')).
826          self::jsVar('dotclear.msg.xhtml_validator',
827               __('XHTML markup validator')).
828          self::jsVar('dotclear.msg.xhtml_valid',
829               __('XHTML content is valid.')).
830          self::jsVar('dotclear.msg.xhtml_not_valid',
831               __('There are XHTML markup errors.')).
[1861]832          self::jsVar('dotclear.msg.warning_validate_no_save_content',
[1832]833               __('Attention: an audit of a content not yet registered.')).
[0]834          self::jsVar('dotclear.msg.confirm_change_post_format',
835               __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')).
[1256]836          self::jsVar('dotclear.msg.confirm_change_post_format_noconvert',
837               __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")).
[224]838          self::jsVar('dotclear.msg.load_enhanced_uploader',
839               __('Loading enhanced uploader, please wait.')).
[2156]840
841          self::jsVar('dotclear.msg.module_author',
842               __('Author:')).
843          self::jsVar('dotclear.msg.module_details',
844               __('Details')).
845          self::jsVar('dotclear.msg.module_support',
[2157]846               __('Support')).
[2156]847          self::jsVar('dotclear.msg.module_help',
[2157]848               __('Help:')).
[2156]849          self::jsVar('dotclear.msg.module_section',
850               __('Section:')).
851          self::jsVar('dotclear.msg.module_tags',
852               __('Tags:')).
[3460]853
854          self::jsVar('dotclear.msg.close_notice',
855               __('Hide this notice')).
856
[3421]857               "\n".
[0]858          "</script>\n";
859     }
[1187]860
[3418]861     /**
862     @deprecated since version 2.11
863     */
[0]864     public static function jsLoadIE7()
865     {
[3418]866          return '';
[0]867     }
[1187]868
[0]869     public static function jsConfirmClose()
870     {
871          $args = func_get_args();
872          if (count($args) > 0) {
873               foreach ($args as $k => $v) {
874                    $args[$k] = "'".html::escapeJS($v)."'";
875               }
876               $args = implode(',',$args);
877          } else {
878               $args = '';
879          }
[1187]880
[0]881          return
882          self::jsLoad('js/confirm-close.js').
883          '<script type="text/javascript">'."\n".
884          "confirmClosePage = new confirmClose(".$args."); ".
885          "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ".
886          "</script>\n";
887     }
[1187]888
[0]889     public static function jsPageTabs($default=null)
890     {
891          if ($default) {
892               $default = "'".html::escapeJS($default)."'";
893          }
[2503]894
[0]895          return
896          self::jsLoad('js/jquery/jquery.pageTabs.js').
897          '<script type="text/javascript">'."\n".
[2010]898          '$(function() {'."\n".
[3421]899          '    $.pageTabs('.$default.');'."\n".
[2113]900          '});'.
[3418]901          "</script>\n";
[2010]902     }
[1161]903
[2202]904     public static function jsModal()
905     {
906          return
[3368]907          self::jsLoad('js/jquery/jquery.magnific-popup.js');
[0]908     }
[1187]909
[2202]910     public static function jsColorPicker()
911     {
912          return
[3021]913          self::cssLoad('style/farbtastic/farbtastic.css').
[2202]914          self::jsLoad('js/jquery/jquery.farbtastic.js').
915          self::jsLoad('js/color-picker.js');
[0]916     }
[1187]917
[2202]918     public static function jsDatePicker()
919     {
920          return
[3021]921          self::cssLoad('style/date-picker.css').
[2202]922          self::jsLoad('js/date-picker.js').
923          '<script type="text/javascript">'."\n".
[1187]924
[2202]925          "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ".
926          "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ".
927          "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ".
928          "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ".
929          "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ".
930          "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ".
931          "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ".
932          "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ".
933          "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ".
934          "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ".
935          "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ".
936          "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ".
[1161]937
[2202]938          "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ".
939          "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ".
940          "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ".
941          "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ".
942          "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ".
943          "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ".
944          "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ".
945
946          "datePicker.prototype.img_src = 'images/date-picker.png'; ".
[2788]947          "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ".
[2202]948
949          "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ".
950          "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ".
951
952          "</script>\n";
[0]953     }
[1187]954
[2720]955
[2202]956     public static function jsToolBar()
957     {
[2614]958          # Deprecated but we keep this for plugins.
[2202]959     }
960
961     public static function jsUpload($params=array(),$base_url=null)
962     {
963          if (!$base_url) {
964               $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';
965          }
966
967          $params = array_merge($params,array(
968               'sess_id='.session_id(),
969               'sess_uid='.$_SESSION['sess_browser_uid'],
970               'xd_check='.$GLOBALS['core']->getNonce()
[0]971          ));
[1187]972
[2202]973          return
974          '<script type="text/javascript">'."\n".
975          "dotclear.jsUpload = {};\n".
976          "dotclear.jsUpload.msg = {};\n".
977          self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')).
978          self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')).
979          self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')).
980          self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')).
981          self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')).
982          self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')).
983          self::jsVar('dotclear.jsUpload.msg.error',__('Error:')).
984          self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')).
985          self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')).
986          self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')).
987          self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')).
988          self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')).
989          self::jsVar('dotclear.jsUpload.msg.send',__('Send')).
990          self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')).
991          self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')).
992          self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')).
993          self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')).
994          self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')).
995          self::jsVar('dotclear.jsUpload.base_url',$base_url).
996          "</script>\n".
[1461]997
[3218]998          self::jsLoad('js/jquery/jquery-ui.custom.js').
[2202]999          self::jsLoad('js/jsUpload/tmpl.js').
1000          self::jsLoad('js/jsUpload/template-upload.js').
1001          self::jsLoad('js/jsUpload/template-download.js').
1002          self::jsLoad('js/jsUpload/load-image.js').
1003          self::jsLoad('js/jsUpload/jquery.iframe-transport.js').
1004          self::jsLoad('js/jsUpload/jquery.fileupload.js').
1005          self::jsLoad('js/jsUpload/jquery.fileupload-process.js').
1006          self::jsLoad('js/jsUpload/jquery.fileupload-resize.js').
1007          self::jsLoad('js/jsUpload/jquery.fileupload-ui.js');
1008     }
[1144]1009
[2202]1010     public static function jsMetaEditor()
1011     {
[3021]1012          return self::jsLoad('js/meta-editor.js');
[2202]1013     }
[2849]1014
[3397]1015     public static function jsFilterControl($show=true)
1016     {
1017          return
1018          self::jsLoad('js/filter-controls.js').
1019          '<script type="text/javascript">'."\n".
1020          self::jsVar('dotclear.msg.show_filters', $show ? 'true':'false')."\n".
1021          self::jsVar('dotclear.msg.filter_posts_list',__('Show filters and display options'))."\n".
1022          self::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n".
1023          "</script>";
1024     }
1025
[3256]1026     public static function jsLoadCodeMirror($theme = '',$multi = true,$modes = array('css','htmlmixed','javascript','php','xml'))
[3251]1027     {
1028          $ret =
1029               self::cssLoad('js/codemirror/lib/codemirror.css').
1030               self::jsLoad('js/codemirror/lib/codemirror.js');
1031          if ($multi) {
1032               $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js');
1033          }
1034          foreach ($modes as $mode) {
1035               $ret .= self::jsLoad('js/codemirror/mode/'.$mode.'/'.$mode.'.js');
1036          }
1037          $ret .=
1038               self::jsLoad('js/codemirror/addon/edit/closebrackets.js').
[3253]1039               self::jsLoad('js/codemirror/addon/edit/matchbrackets.js').
1040               self::cssLoad('js/codemirror/addon/display/fullscreen.css').
1041               self::jsLoad('js/codemirror/addon/display/fullscreen.js');
[3251]1042          if ($theme != '') {
1043               $ret .= self::cssLoad('js/codemirror/theme/'.$theme.'.css');
1044          }
1045          return $ret;
1046     }
1047
[3256]1048     public static function jsRunCodeMirror($name,$id,$mode,$theme = '')
1049     {
1050          $ret =
[3421]1051               '<script type="text/javascript">'."\n".
[3256]1052               'var '.$name.' = CodeMirror.fromTextArea('.$id.',{'."\n".
1053               '    mode: "'.$mode.'",'."\n".
1054               '    tabMode: "indent",'."\n".
1055               '    lineWrapping: "true",'."\n".
1056               '    lineNumbers: "true",'."\n".
1057               '    matchBrackets: "true",'."\n".
1058               '    autoCloseBrackets: "true",'."\n".
1059               '    extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}';
[3421]1060          if ($theme) {
1061               $ret .=
1062                    ','."\n".
1063                    '    theme: "'.$theme.'"';
1064          }
1065          $ret .= "\n".
1066               '});'."\n".
[3256]1067               '</script>';
1068          return $ret;
1069     }
1070
[3251]1071     public static function getCodeMirrorThemes()
1072     {
1073          $themes = array();
1074          $themes_root = dirname(__FILE__).'/../../admin'.'/js/codemirror/theme/';
1075          if (is_dir($themes_root) && is_readable($themes_root)) {
1076               if (($d = @dir($themes_root)) !== false) {
1077                    while (($entry = $d->read()) !== false) {
1078                         if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root.'/'.$entry)) {
1079                              $themes[] = substr($entry,0,-4); // remove .css extension
1080                         }
1081                    }
[3313]1082                    sort($themes);
[3251]1083               }
1084          }
1085          return $themes;
1086     }
1087
[3080]1088     public static function getPF($file)
1089     {
[2852]1090          return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file));
[2849]1091     }
[2909]1092
[3262]1093     public static function getVF($file)
1094     {
1095          return $GLOBALS['core']->adminurl->get('load.var.file',array('vf' => $file));
1096     }
1097
[3279]1098     public static function setXFrameOptions($headers,$origin = null)
[3080]1099     {
[2909]1100          if (self::$xframe_loaded) {
1101               return;
1102          }
1103          if ($origin !== null) {
1104               $url = parse_url($origin);
[3279]1105               $headers['x-frame-options'] = sprintf('X-Frame-Options: %s',is_array($url) ?
[3080]1106                    ("ALLOW-FROM ".(isset($url['scheme']) ? $url['scheme'].':' : '' ).'//'.$url['host']) :
[3279]1107                    'SAMEORIGIN');
[2909]1108          } else {
[3279]1109               $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
[2909]1110          }
1111          self::$xframe_loaded = true;
1112     }
[489]1113}
Note: See TracBrowser for help on using the repository browser.

Sites map