[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 ----------------------------------------- |
---|
| 12 | if (!defined('DC_RC_PATH')) { return; } |
---|
| 13 | |
---|
| 14 | define('DC_AUTH_PAGE','auth.php'); |
---|
| 15 | |
---|
| 16 | class 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". |
---|
[3434] | 237 | '<div class="hidden-if-no-js collapser-box"><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; |
---|
| 264 | $res = ''; |
---|
| 265 | |
---|
| 266 | // return error messages if any |
---|
| 267 | if ($core->error->flag() && !$error_displayed) { |
---|
| 268 | $res .= '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong></p>'. |
---|
| 269 | $core->error->toHTML(). |
---|
| 270 | '</div>'; |
---|
| 271 | $error_displayed = true; |
---|
| 272 | } |
---|
| 273 | |
---|
[2199] | 274 | // return notices if any |
---|
[2181] | 275 | if (isset($_SESSION['notifications'])) { |
---|
[2328] | 276 | foreach ($_SESSION['notifications'] as $notification) { |
---|
| 277 | $res .= self::getNotification($notification); |
---|
[2181] | 278 | } |
---|
| 279 | unset($_SESSION['notifications']); |
---|
| 280 | } |
---|
[2199] | 281 | return $res; |
---|
[0] | 282 | } |
---|
[2191] | 283 | |
---|
[2328] | 284 | public static function addNotice($type,$message,$options=array()) |
---|
[2191] | 285 | { |
---|
[2328] | 286 | if (isset(self::$N_TYPES[$type])){ |
---|
| 287 | $class = self::$N_TYPES[$type]; |
---|
| 288 | } else { |
---|
| 289 | $class=$type; |
---|
| 290 | } |
---|
| 291 | if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) { |
---|
| 292 | $notifications = $_SESSION['notifications']; |
---|
| 293 | } else { |
---|
| 294 | $notifications = array(); |
---|
| 295 | } |
---|
[2503] | 296 | |
---|
[2328] | 297 | $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message)); |
---|
| 298 | if ($type != "static") { |
---|
| 299 | $notifications[] = $n; |
---|
| 300 | } else { |
---|
| 301 | array_unshift($notifications, $n); |
---|
| 302 | } |
---|
| 303 | $_SESSION['notifications'] = $notifications; |
---|
[2181] | 304 | } |
---|
[2191] | 305 | |
---|
[2328] | 306 | public static function addSuccessNotice($message,$options=array()) |
---|
[2191] | 307 | { |
---|
[2328] | 308 | self::addNotice("success",$message,$options); |
---|
[2181] | 309 | } |
---|
[2191] | 310 | |
---|
[2328] | 311 | public static function addWarningNotice($message,$options=array()) |
---|
[2191] | 312 | { |
---|
[2328] | 313 | self::addNotice("warning",$message,$options); |
---|
[2181] | 314 | } |
---|
[2191] | 315 | |
---|
[2328] | 316 | public static function addErrorNotice($message,$options=array()) |
---|
[2191] | 317 | { |
---|
[2328] | 318 | self::addNotice("error",$message,$options); |
---|
[2191] | 319 | } |
---|
| 320 | |
---|
[2328] | 321 | protected static function getNotification($n) |
---|
[2191] | 322 | { |
---|
[2181] | 323 | global $core; |
---|
[3340] | 324 | $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p'; |
---|
[2328] | 325 | $ts = ''; |
---|
| 326 | if (!isset($n['with_ts']) || ($n['with_ts'] == true)) { |
---|
| 327 | $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' '; |
---|
| 328 | } |
---|
[2787] | 329 | $res = '<'.$tag.' class="'.$n['class'].'" role="alert">'.$ts.$n['text'].'</'.$tag.'>'; |
---|
[2191] | 330 | return $res; |
---|
[2181] | 331 | } |
---|
[2191] | 332 | |
---|
[0] | 333 | public static function close() |
---|
| 334 | { |
---|
[942] | 335 | global $core; |
---|
| 336 | |
---|
[1933] | 337 | if (!$GLOBALS['__resources']['ctxhelp']) { |
---|
| 338 | echo |
---|
[2720] | 339 | '<p id="help-button"><a href="'.$core->adminurl->get("admin.help").'" class="outgoing" title="'. |
---|
[2306] | 340 | __('Global help').'">'.__('Global help').'</a></p>'; |
---|
[1933] | 341 | } |
---|
| 342 | |
---|
[0] | 343 | $menu =& $GLOBALS['_menu']; |
---|
[1187] | 344 | |
---|
[0] | 345 | echo |
---|
| 346 | "</div>\n". // End of #content |
---|
| 347 | "</div>\n". // End of #main |
---|
[1187] | 348 | |
---|
[2784] | 349 | '<div id="main-menu" role="navigation">'."\n". |
---|
[1311] | 350 | |
---|
[2769] | 351 | '<form id="search-menu" action="'.$core->adminurl->get("admin.search").'" method="get" role="search">'. |
---|
[1589] | 352 | '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,''). |
---|
[1311] | 353 | '<input type="submit" value="'.__('OK').'" /></p>'. |
---|
| 354 | '</form>'; |
---|
[1187] | 355 | |
---|
[0] | 356 | foreach ($menu as $k => $v) { |
---|
| 357 | echo $menu[$k]->draw(); |
---|
| 358 | } |
---|
[1187] | 359 | |
---|
[1140] | 360 | $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); |
---|
[942] | 361 | |
---|
| 362 | # --BEHAVIOR-- adminPageFooter |
---|
[946] | 363 | $textAlt = $core->callBehavior('adminPageFooter',$core,$text); |
---|
[1140] | 364 | if ($textAlt != '') { |
---|
| 365 | $text = $textAlt; |
---|
| 366 | } |
---|
[1142] | 367 | $text = html::escapeHTML($text); |
---|
[942] | 368 | |
---|
[0] | 369 | echo |
---|
| 370 | '</div>'."\n". // End of #main-menu |
---|
[1946] | 371 | "</div>\n"; // End of #wrapper |
---|
[1861] | 372 | |
---|
[3294] | 373 | echo '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n"; |
---|
| 374 | |
---|
[3060] | 375 | $figure = " |
---|
[3224] | 376 | /\_/\ |
---|
| 377 | (='.'=) |
---|
| 378 | (\")-(\") |
---|
| 379 | "; |
---|
[3060] | 380 | |
---|
[1946] | 381 | echo |
---|
[2784] | 382 | '<div id="footer" role="contentinfo">'. |
---|
[2296] | 383 | '<a href="http://dotclear.org/" title="'.$text.'">'. |
---|
| 384 | '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". |
---|
[2796] | 385 | "<!-- "."\n". |
---|
[3060] | 386 | $figure. |
---|
[2796] | 387 | " -->"."\n"; |
---|
[1187] | 388 | |
---|
[3294] | 389 | |
---|
| 390 | |
---|
[0] | 391 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 392 | echo self::debugInfo(); |
---|
| 393 | } |
---|
[1187] | 394 | |
---|
[0] | 395 | echo |
---|
| 396 | '</body></html>'; |
---|
| 397 | } |
---|
[1187] | 398 | |
---|
[1358] | 399 | public static function openPopup($title='',$head='',$breadcrumb='') |
---|
[0] | 400 | { |
---|
| 401 | global $core; |
---|
[1187] | 402 | |
---|
[0] | 403 | # Display |
---|
| 404 | header('Content-Type: text/html; charset=UTF-8'); |
---|
[2792] | 405 | |
---|
| 406 | // Prevents Clickjacking as far as possible |
---|
| 407 | header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
| 408 | |
---|
[0] | 409 | echo |
---|
[2760] | 410 | '<!DOCTYPE html>'. |
---|
| 411 | '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
[0] | 412 | "<head>\n". |
---|
[2760] | 413 | ' <meta charset="UTF-8" />'."\n". |
---|
[2513] | 414 | ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
[0] | 415 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
[1187] | 416 | |
---|
[0] | 417 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 418 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
[1187] | 419 | |
---|
[3021] | 420 | self::cssLoad('style/default.css'); |
---|
[0] | 421 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
[3021] | 422 | echo self::cssLoad('style/default-rtl.css'); |
---|
[0] | 423 | } |
---|
[1187] | 424 | |
---|
[3408] | 425 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 426 | if ($core->auth->user_prefs->interface->htmlfontsize) { |
---|
| 427 | echo |
---|
| 428 | '<script type="text/javascript">'."\n". |
---|
[3421] | 429 | self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize)."\n". |
---|
[3408] | 430 | "</script>\n"; |
---|
| 431 | } |
---|
| 432 | |
---|
[0] | 433 | echo |
---|
| 434 | self::jsCommon(). |
---|
[1699] | 435 | self::jsToggles(). |
---|
[0] | 436 | $head; |
---|
[1187] | 437 | |
---|
[3398] | 438 | if ($core->auth->user_prefs->interface->hidemoreinfo) { |
---|
| 439 | echo |
---|
| 440 | '<script type="text/javascript">'."\n". |
---|
[3421] | 441 | 'dotclear.hideMoreInfo = true;'."\n". |
---|
[3398] | 442 | "</script>\n"; |
---|
| 443 | } |
---|
| 444 | |
---|
[0] | 445 | # --BEHAVIOR-- adminPageHTMLHead |
---|
| 446 | $core->callBehavior('adminPageHTMLHead'); |
---|
[1187] | 447 | |
---|
[0] | 448 | echo |
---|
| 449 | "</head>\n". |
---|
| 450 | '<body id="dotclear-admin" class="popup">'."\n". |
---|
[1187] | 451 | |
---|
[2046] | 452 | '<h1>'.DC_VENDOR_NAME.'</h1>'."\n"; |
---|
[1187] | 453 | |
---|
[0] | 454 | echo |
---|
| 455 | '<div id="wrapper">'."\n". |
---|
[2784] | 456 | '<div id="main" role="main">'."\n". |
---|
[0] | 457 | '<div id="content">'."\n"; |
---|
[1187] | 458 | |
---|
[1358] | 459 | // display breadcrumb if given |
---|
| 460 | echo $breadcrumb; |
---|
| 461 | |
---|
[3076] | 462 | // Display notices and errors |
---|
| 463 | echo self::notices(); |
---|
[0] | 464 | } |
---|
[1187] | 465 | |
---|
[0] | 466 | public static function closePopup() |
---|
| 467 | { |
---|
| 468 | echo |
---|
| 469 | "</div>\n". // End of #content |
---|
| 470 | "</div>\n". // End of #main |
---|
[2046] | 471 | "</div>\n". // End of #wrapper |
---|
[3294] | 472 | |
---|
| 473 | '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n". |
---|
| 474 | |
---|
[2784] | 475 | '<div id="footer" role="contentinfo"><p> </p></div>'."\n". |
---|
[0] | 476 | '</body></html>'; |
---|
| 477 | } |
---|
[907] | 478 | |
---|
[2166] | 479 | public static function breadcrumb($elements=null,$options=array()) |
---|
[1328] | 480 | { |
---|
[2720] | 481 | global $core; |
---|
[3340] | 482 | $with_home_link = isset($options['home_link']) ? $options['home_link'] : true; |
---|
| 483 | $hl = isset($options['hl']) ? $options['hl'] : true; |
---|
| 484 | $hl_pos = isset($options['hl_pos']) ? $options['hl_pos'] : -1; |
---|
[1328] | 485 | // First item of array elements should be blog's name, System or Plugins |
---|
[1340] | 486 | $res = '<h2>'.($with_home_link ? |
---|
[2720] | 487 | '<a class="go_home" href="'.$core->adminurl->get("admin.home").'"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : |
---|
[1340] | 488 | '<img src="style/dashboard-alt.png" alt="" />'); |
---|
[1328] | 489 | $index = 0; |
---|
[2167] | 490 | if ($hl_pos < 0) { |
---|
| 491 | $hl_pos = count($elements)+$hl_pos; |
---|
[2166] | 492 | } |
---|
[1328] | 493 | foreach ($elements as $element => $url) { |
---|
[2167] | 494 | if ($hl && $index == $hl_pos) { |
---|
[2166] | 495 | $element = sprintf('<span class="page-title">%s</span>',$element); |
---|
| 496 | } |
---|
[1358] | 497 | $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')). |
---|
| 498 | ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); |
---|
[1328] | 499 | $index++; |
---|
| 500 | } |
---|
| 501 | $res .= '</h2>'; |
---|
| 502 | return $res; |
---|
| 503 | } |
---|
| 504 | |
---|
[1548] | 505 | public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message') |
---|
[907] | 506 | { |
---|
[910] | 507 | global $core; |
---|
[1187] | 508 | |
---|
[907] | 509 | $res = ''; |
---|
| 510 | if ($msg != '') { |
---|
[1548] | 511 | $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'. |
---|
[2191] | 512 | ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. |
---|
[1161] | 513 | '</p>'.($div ? '</div>' : ''); |
---|
[907] | 514 | if ($echo) { |
---|
| 515 | echo $res; |
---|
| 516 | } |
---|
| 517 | } |
---|
| 518 | return $res; |
---|
| 519 | } |
---|
[1187] | 520 | |
---|
[1548] | 521 | public static function success($msg,$timestamp=true,$div=false,$echo=true) |
---|
| 522 | { |
---|
[1927] | 523 | return self::message($msg,$timestamp,$div,$echo,"success"); |
---|
[1548] | 524 | } |
---|
| 525 | |
---|
[1725] | 526 | public static function warning($msg,$timestamp=true,$div=false,$echo=true) |
---|
| 527 | { |
---|
[1927] | 528 | return self::message($msg,$timestamp,$div,$echo,"warning-msg"); |
---|
[1725] | 529 | } |
---|
| 530 | |
---|
[0] | 531 | private static function debugInfo() |
---|
| 532 | { |
---|
| 533 | $global_vars = implode(', ',array_keys($GLOBALS)); |
---|
[1187] | 534 | |
---|
[0] | 535 | $res = |
---|
| 536 | '<div id="debug"><div>'. |
---|
| 537 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; |
---|
[1187] | 538 | |
---|
[0] | 539 | if (function_exists('xdebug_get_profiler_filename')) |
---|
| 540 | { |
---|
| 541 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; |
---|
[1187] | 542 | |
---|
[0] | 543 | $prof_file = xdebug_get_profiler_filename(); |
---|
| 544 | if ($prof_file) { |
---|
| 545 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; |
---|
| 546 | } else { |
---|
| 547 | $prof_url = http::getSelfURI(); |
---|
[321] | 548 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; |
---|
[0] | 549 | $prof_url .= 'XDEBUG_PROFILE'; |
---|
[321] | 550 | $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; |
---|
[0] | 551 | } |
---|
[1187] | 552 | |
---|
[0] | 553 | /* xdebug configuration: |
---|
| 554 | zend_extension = /.../xdebug.so |
---|
| 555 | xdebug.auto_trace = On |
---|
| 556 | xdebug.trace_format = 0 |
---|
| 557 | xdebug.trace_options = 1 |
---|
| 558 | xdebug.show_mem_delta = On |
---|
| 559 | xdebug.profiler_enable = 0 |
---|
| 560 | xdebug.profiler_enable_trigger = 1 |
---|
| 561 | xdebug.profiler_output_dir = /tmp |
---|
| 562 | xdebug.profiler_append = 0 |
---|
| 563 | xdebug.profiler_output_name = timestamp |
---|
| 564 | */ |
---|
| 565 | } |
---|
[1187] | 566 | |
---|
[0] | 567 | $res .= |
---|
| 568 | '<p>Global vars: '.$global_vars.'</p>'. |
---|
| 569 | '</div></div>'; |
---|
[1187] | 570 | |
---|
[0] | 571 | return $res; |
---|
| 572 | } |
---|
[1187] | 573 | |
---|
[0] | 574 | public static function help($page,$index='') |
---|
| 575 | { |
---|
| 576 | # Deprecated but we keep this for plugins. |
---|
| 577 | } |
---|
[1187] | 578 | |
---|
[0] | 579 | public static function helpBlock() |
---|
| 580 | { |
---|
[2720] | 581 | global $core; |
---|
[0] | 582 | $args = func_get_args(); |
---|
[1458] | 583 | |
---|
| 584 | $args = new ArrayObject($args); |
---|
| 585 | |
---|
| 586 | # --BEHAVIOR-- adminPageHelpBlock |
---|
| 587 | $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); |
---|
| 588 | |
---|
[0] | 589 | if (empty($args)) { |
---|
| 590 | return; |
---|
| 591 | }; |
---|
[1187] | 592 | |
---|
[0] | 593 | global $__resources; |
---|
| 594 | if (empty($__resources['help'])) { |
---|
| 595 | return; |
---|
| 596 | } |
---|
[1187] | 597 | |
---|
[0] | 598 | $content = ''; |
---|
| 599 | foreach ($args as $v) |
---|
| 600 | { |
---|
| 601 | if (is_object($v) && isset($v->content)) { |
---|
| 602 | $content .= $v->content; |
---|
| 603 | continue; |
---|
| 604 | } |
---|
[1187] | 605 | |
---|
[0] | 606 | if (!isset($__resources['help'][$v])) { |
---|
| 607 | continue; |
---|
| 608 | } |
---|
| 609 | $f = $__resources['help'][$v]; |
---|
| 610 | if (!file_exists($f) || !is_readable($f)) { |
---|
| 611 | continue; |
---|
| 612 | } |
---|
[1187] | 613 | |
---|
[0] | 614 | $fc = file_get_contents($f); |
---|
| 615 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
| 616 | $content .= $matches[1]; |
---|
| 617 | } else { |
---|
| 618 | $content .= $fc; |
---|
| 619 | } |
---|
| 620 | } |
---|
[1187] | 621 | |
---|
[0] | 622 | if (trim($content) == '') { |
---|
| 623 | return; |
---|
| 624 | } |
---|
[1187] | 625 | |
---|
[1933] | 626 | // Set contextual help global flag |
---|
| 627 | $GLOBALS['__resources']['ctxhelp'] = true; |
---|
| 628 | |
---|
[0] | 629 | echo |
---|
[1573] | 630 | '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'. |
---|
[0] | 631 | $content. |
---|
[494] | 632 | '</div>'. |
---|
| 633 | '<div id="helplink"><hr />'. |
---|
| 634 | '<p>'. |
---|
[2720] | 635 | sprintf(__('See also %s'),sprintf('<a href="'.$core->adminurl->get("admin.help").'">%s</a>',__('the global help'))). |
---|
[2011] | 636 | '.</p>'. |
---|
[0] | 637 | '</div></div>'; |
---|
| 638 | } |
---|
[1187] | 639 | |
---|
[3086] | 640 | public static function cssLoad($src,$media='screen',$v='') |
---|
[3021] | 641 | { |
---|
| 642 | $escaped_src = html::escapeHTML($src); |
---|
| 643 | if (!isset(self::$loaded_css[$escaped_src])) { |
---|
| 644 | self::$loaded_css[$escaped_src] = true; |
---|
[3086] | 645 | $escaped_src = self::appendVersion($escaped_src,$v); |
---|
[3021] | 646 | |
---|
| 647 | return '<link rel="stylesheet" href="'.$escaped_src.'" type="text/css" media="'.$media.'" />'."\n"; |
---|
| 648 | } |
---|
| 649 | } |
---|
| 650 | |
---|
[3086] | 651 | public static function jsLoad($src,$v='') |
---|
[0] | 652 | { |
---|
[342] | 653 | $escaped_src = html::escapeHTML($src); |
---|
| 654 | if (!isset(self::$loaded_js[$escaped_src])) { |
---|
[3020] | 655 | self::$loaded_js[$escaped_src] = true; |
---|
[3086] | 656 | $escaped_src = self::appendVersion($escaped_src,$v); |
---|
[342] | 657 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; |
---|
| 658 | } |
---|
[0] | 659 | } |
---|
[1187] | 660 | |
---|
[3086] | 661 | private static function appendVersion($src,$v='') |
---|
[3021] | 662 | { |
---|
[3129] | 663 | $src .= (strpos($src,'?') === false ? '?' : '&').'v='; |
---|
[3021] | 664 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 665 | $src .= md5(uniqid()); |
---|
| 666 | } else { |
---|
[3086] | 667 | $src .= ($v === '' ? DC_VERSION : $v); |
---|
[3021] | 668 | } |
---|
| 669 | return $src; |
---|
| 670 | } |
---|
| 671 | |
---|
[0] | 672 | public static function jsVar($n,$v) |
---|
| 673 | { |
---|
| 674 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
| 675 | } |
---|
[1187] | 676 | |
---|
[1699] | 677 | public static function jsToggles() |
---|
| 678 | { |
---|
| 679 | if($GLOBALS['core']->auth->user_prefs->toggles) { |
---|
| 680 | $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); |
---|
| 681 | foreach ($unfolded_sections as $k=>&$v) { |
---|
| 682 | if ($v == '') { |
---|
| 683 | unset($unfolded_sections[$k]); |
---|
| 684 | } else { |
---|
| 685 | $v = "'".html::escapeJS($v)."':true"; |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | } else { |
---|
| 689 | $unfolded_sections=array(); |
---|
| 690 | } |
---|
| 691 | return '<script type="text/javascript">'."\n". |
---|
[3421] | 692 | 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". |
---|
[1699] | 693 | "</script>\n"; |
---|
| 694 | } |
---|
[2503] | 695 | |
---|
[0] | 696 | public static function jsCommon() |
---|
| 697 | { |
---|
[1771] | 698 | $mute_or_no = ''; |
---|
[1841] | 699 | if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { |
---|
[1771] | 700 | $mute_or_no .= |
---|
| 701 | '<script type="text/javascript">'."\n". |
---|
[3421] | 702 | 'jQuery.migrateMute = true;'."\n". |
---|
[1771] | 703 | "</script>\n"; |
---|
| 704 | } |
---|
| 705 | |
---|
[0] | 706 | return |
---|
| 707 | self::jsLoad('js/jquery/jquery.js'). |
---|
[1771] | 708 | $mute_or_no. |
---|
[3178] | 709 | self::jsLoad('js/jquery/jquery-migrate.js'). |
---|
[0] | 710 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
| 711 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
| 712 | self::jsLoad('js/common.js'). |
---|
[447] | 713 | self::jsLoad('js/prelude.js'). |
---|
[1187] | 714 | |
---|
[0] | 715 | '<script type="text/javascript">'."\n". |
---|
[2614] | 716 | 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". |
---|
[0] | 717 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
[1019] | 718 | self::jsVar('dotclear.img_plus_src','images/expand.png'). |
---|
[0] | 719 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
[1019] | 720 | self::jsVar('dotclear.img_minus_src','images/hide.png'). |
---|
[0] | 721 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
| 722 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
| 723 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
[2503] | 724 | |
---|
[2195] | 725 | self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png'). |
---|
| 726 | self::jsVar('dotclear.img_plus_theme_alt',__('uncover')). |
---|
| 727 | self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png'). |
---|
| 728 | self::jsVar('dotclear.img_minus_theme_alt',__('hide')). |
---|
[1187] | 729 | |
---|
[0] | 730 | self::jsVar('dotclear.msg.help', |
---|
[1933] | 731 | __('Need help?')). |
---|
[2225] | 732 | self::jsVar('dotclear.msg.new_window', |
---|
| 733 | __('new window')). |
---|
[1302] | 734 | self::jsVar('dotclear.msg.help_hide', |
---|
| 735 | __('Hide')). |
---|
[1556] | 736 | self::jsVar('dotclear.msg.to_select', |
---|
| 737 | __('Select:')). |
---|
[0] | 738 | self::jsVar('dotclear.msg.no_selection', |
---|
| 739 | __('no selection')). |
---|
| 740 | self::jsVar('dotclear.msg.select_all', |
---|
| 741 | __('select all')). |
---|
| 742 | self::jsVar('dotclear.msg.invert_sel', |
---|
[1556] | 743 | __('Invert selection')). |
---|
[0] | 744 | self::jsVar('dotclear.msg.website', |
---|
| 745 | __('Web site:')). |
---|
| 746 | self::jsVar('dotclear.msg.email', |
---|
| 747 | __('Email:')). |
---|
| 748 | self::jsVar('dotclear.msg.ip_address', |
---|
| 749 | __('IP address:')). |
---|
| 750 | self::jsVar('dotclear.msg.error', |
---|
| 751 | __('Error:')). |
---|
| 752 | self::jsVar('dotclear.msg.entry_created', |
---|
| 753 | __('Entry has been successfully created.')). |
---|
| 754 | self::jsVar('dotclear.msg.edit_entry', |
---|
| 755 | __('Edit entry')). |
---|
| 756 | self::jsVar('dotclear.msg.view_entry', |
---|
| 757 | __('view entry')). |
---|
| 758 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
| 759 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
[2202] | 760 | self::jsVar('dotclear.msg.confirm_delete_medias', |
---|
| 761 | __("Are you sure you want to delete selected medias (%d)?")). |
---|
[1525] | 762 | self::jsVar('dotclear.msg.confirm_delete_categories', |
---|
| 763 | __("Are you sure you want to delete selected categories (%s)?")). |
---|
[0] | 764 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
| 765 | __("Are you sure you want to delete this entry?")). |
---|
[1395] | 766 | self::jsVar('dotclear.msg.click_to_unlock', |
---|
[1450] | 767 | __("Click here to unlock the field")). |
---|
[1049] | 768 | self::jsVar('dotclear.msg.confirm_spam_delete', |
---|
| 769 | __('Are you sure you want to delete all spams?')). |
---|
[0] | 770 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
| 771 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
| 772 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
| 773 | __('Are you sure you want to delete this comment?')). |
---|
| 774 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
| 775 | __('Users with posts cannot be deleted.')). |
---|
| 776 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
| 777 | __('Are you sure you want to delete selected users (%s)?')). |
---|
[3403] | 778 | self::jsVar('dotclear.msg.confirm_delete_blog', |
---|
| 779 | __('Are you sure you want to delete selected blogs (%s)?')). |
---|
[0] | 780 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
| 781 | __('Are you sure you want to delete category "%s"?')). |
---|
| 782 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
| 783 | __('Are you sure you want to reorder all categories?')). |
---|
| 784 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
| 785 | __('Are you sure you want to remove media "%s"?')). |
---|
[2512] | 786 | self::jsVar('dotclear.msg.confirm_delete_directory', |
---|
| 787 | __('Are you sure you want to remove directory "%s"?')). |
---|
[0] | 788 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
| 789 | __('Are you sure you want to extract archive in current directory?')). |
---|
| 790 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
| 791 | __('Are you sure you want to remove attachment "%s"?')). |
---|
| 792 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
| 793 | __('Are you sure you want to delete "%s" language?')). |
---|
| 794 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
| 795 | __('Are you sure you want to delete "%s" plugin?')). |
---|
[2487] | 796 | self::jsVar('dotclear.msg.confirm_delete_plugins', |
---|
| 797 | __('Are you sure you want to delete selected plugins?')). |
---|
[0] | 798 | self::jsVar('dotclear.msg.use_this_theme', |
---|
| 799 | __('Use this theme')). |
---|
| 800 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
| 801 | __('Remove this theme')). |
---|
| 802 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
| 803 | __('Are you sure you want to delete "%s" theme?')). |
---|
[2487] | 804 | self::jsVar('dotclear.msg.confirm_delete_themes', |
---|
| 805 | __('Are you sure you want to delete selected themes?')). |
---|
[1462] | 806 | self::jsVar('dotclear.msg.confirm_delete_backup', |
---|
| 807 | __('Are you sure you want to delete this backup?')). |
---|
[2503] | 808 | self::jsVar('dotclear.msg.confirm_revert_backup', |
---|
| 809 | __('Are you sure you want to revert to this backup?')). |
---|
[0] | 810 | self::jsVar('dotclear.msg.zip_file_content', |
---|
| 811 | __('Zip file content')). |
---|
| 812 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
| 813 | __('XHTML markup validator')). |
---|
| 814 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
| 815 | __('XHTML content is valid.')). |
---|
| 816 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
| 817 | __('There are XHTML markup errors.')). |
---|
[1861] | 818 | self::jsVar('dotclear.msg.warning_validate_no_save_content', |
---|
[1832] | 819 | __('Attention: an audit of a content not yet registered.')). |
---|
[0] | 820 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
| 821 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
[1256] | 822 | self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', |
---|
| 823 | __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). |
---|
[224] | 824 | self::jsVar('dotclear.msg.load_enhanced_uploader', |
---|
| 825 | __('Loading enhanced uploader, please wait.')). |
---|
[2156] | 826 | |
---|
| 827 | self::jsVar('dotclear.msg.module_author', |
---|
| 828 | __('Author:')). |
---|
| 829 | self::jsVar('dotclear.msg.module_details', |
---|
| 830 | __('Details')). |
---|
| 831 | self::jsVar('dotclear.msg.module_support', |
---|
[2157] | 832 | __('Support')). |
---|
[2156] | 833 | self::jsVar('dotclear.msg.module_help', |
---|
[2157] | 834 | __('Help:')). |
---|
[2156] | 835 | self::jsVar('dotclear.msg.module_section', |
---|
| 836 | __('Section:')). |
---|
| 837 | self::jsVar('dotclear.msg.module_tags', |
---|
| 838 | __('Tags:')). |
---|
[3421] | 839 | "\n". |
---|
[0] | 840 | "</script>\n"; |
---|
| 841 | } |
---|
[1187] | 842 | |
---|
[3418] | 843 | /** |
---|
| 844 | @deprecated since version 2.11 |
---|
| 845 | */ |
---|
[0] | 846 | public static function jsLoadIE7() |
---|
| 847 | { |
---|
[3418] | 848 | return ''; |
---|
[0] | 849 | } |
---|
[1187] | 850 | |
---|
[0] | 851 | public static function jsConfirmClose() |
---|
| 852 | { |
---|
| 853 | $args = func_get_args(); |
---|
| 854 | if (count($args) > 0) { |
---|
| 855 | foreach ($args as $k => $v) { |
---|
| 856 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
| 857 | } |
---|
| 858 | $args = implode(',',$args); |
---|
| 859 | } else { |
---|
| 860 | $args = ''; |
---|
| 861 | } |
---|
[1187] | 862 | |
---|
[0] | 863 | return |
---|
| 864 | self::jsLoad('js/confirm-close.js'). |
---|
| 865 | '<script type="text/javascript">'."\n". |
---|
| 866 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
| 867 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
| 868 | "</script>\n"; |
---|
| 869 | } |
---|
[1187] | 870 | |
---|
[0] | 871 | public static function jsPageTabs($default=null) |
---|
| 872 | { |
---|
| 873 | if ($default) { |
---|
| 874 | $default = "'".html::escapeJS($default)."'"; |
---|
| 875 | } |
---|
[2503] | 876 | |
---|
[0] | 877 | return |
---|
| 878 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
| 879 | '<script type="text/javascript">'."\n". |
---|
[2010] | 880 | '$(function() {'."\n". |
---|
[3421] | 881 | ' $.pageTabs('.$default.');'."\n". |
---|
[2113] | 882 | '});'. |
---|
[3418] | 883 | "</script>\n"; |
---|
[2010] | 884 | } |
---|
[1161] | 885 | |
---|
[2202] | 886 | public static function jsModal() |
---|
| 887 | { |
---|
| 888 | return |
---|
[3368] | 889 | self::jsLoad('js/jquery/jquery.magnific-popup.js'); |
---|
[0] | 890 | } |
---|
[1187] | 891 | |
---|
[2202] | 892 | public static function jsColorPicker() |
---|
| 893 | { |
---|
| 894 | return |
---|
[3021] | 895 | self::cssLoad('style/farbtastic/farbtastic.css'). |
---|
[2202] | 896 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
| 897 | self::jsLoad('js/color-picker.js'); |
---|
[0] | 898 | } |
---|
[1187] | 899 | |
---|
[2202] | 900 | public static function jsDatePicker() |
---|
| 901 | { |
---|
| 902 | return |
---|
[3021] | 903 | self::cssLoad('style/date-picker.css'). |
---|
[2202] | 904 | self::jsLoad('js/date-picker.js'). |
---|
| 905 | '<script type="text/javascript">'."\n". |
---|
[1187] | 906 | |
---|
[2202] | 907 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
| 908 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
| 909 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
| 910 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
| 911 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
| 912 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
| 913 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
| 914 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
| 915 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
| 916 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
| 917 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
| 918 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
[1161] | 919 | |
---|
[2202] | 920 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
| 921 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
| 922 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
| 923 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
| 924 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
| 925 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
| 926 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
| 927 | |
---|
| 928 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
[2788] | 929 | "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". |
---|
[2202] | 930 | |
---|
| 931 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
| 932 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
| 933 | |
---|
| 934 | "</script>\n"; |
---|
[0] | 935 | } |
---|
[1187] | 936 | |
---|
[2720] | 937 | |
---|
[2202] | 938 | public static function jsToolBar() |
---|
| 939 | { |
---|
[2614] | 940 | # Deprecated but we keep this for plugins. |
---|
[2202] | 941 | } |
---|
| 942 | |
---|
| 943 | public static function jsUpload($params=array(),$base_url=null) |
---|
| 944 | { |
---|
| 945 | if (!$base_url) { |
---|
| 946 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
| 947 | } |
---|
| 948 | |
---|
| 949 | $params = array_merge($params,array( |
---|
| 950 | 'sess_id='.session_id(), |
---|
| 951 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
| 952 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
[0] | 953 | )); |
---|
[1187] | 954 | |
---|
[2202] | 955 | return |
---|
| 956 | '<script type="text/javascript">'."\n". |
---|
| 957 | "dotclear.jsUpload = {};\n". |
---|
| 958 | "dotclear.jsUpload.msg = {};\n". |
---|
| 959 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). |
---|
| 960 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). |
---|
| 961 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). |
---|
| 962 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
| 963 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). |
---|
| 964 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). |
---|
| 965 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). |
---|
| 966 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). |
---|
| 967 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). |
---|
| 968 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). |
---|
| 969 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). |
---|
| 970 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). |
---|
| 971 | self::jsVar('dotclear.jsUpload.msg.send',__('Send')). |
---|
| 972 | self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). |
---|
| 973 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). |
---|
| 974 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). |
---|
| 975 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). |
---|
| 976 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). |
---|
| 977 | self::jsVar('dotclear.jsUpload.base_url',$base_url). |
---|
| 978 | "</script>\n". |
---|
[1461] | 979 | |
---|
[3218] | 980 | self::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
[2202] | 981 | self::jsLoad('js/jsUpload/tmpl.js'). |
---|
| 982 | self::jsLoad('js/jsUpload/template-upload.js'). |
---|
| 983 | self::jsLoad('js/jsUpload/template-download.js'). |
---|
| 984 | self::jsLoad('js/jsUpload/load-image.js'). |
---|
| 985 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). |
---|
| 986 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). |
---|
| 987 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). |
---|
| 988 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). |
---|
| 989 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); |
---|
| 990 | } |
---|
[1144] | 991 | |
---|
[2202] | 992 | public static function jsMetaEditor() |
---|
| 993 | { |
---|
[3021] | 994 | return self::jsLoad('js/meta-editor.js'); |
---|
[2202] | 995 | } |
---|
[2849] | 996 | |
---|
[3397] | 997 | public static function jsFilterControl($show=true) |
---|
| 998 | { |
---|
| 999 | return |
---|
| 1000 | self::jsLoad('js/filter-controls.js'). |
---|
| 1001 | '<script type="text/javascript">'."\n". |
---|
| 1002 | self::jsVar('dotclear.msg.show_filters', $show ? 'true':'false')."\n". |
---|
| 1003 | self::jsVar('dotclear.msg.filter_posts_list',__('Show filters and display options'))."\n". |
---|
| 1004 | self::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". |
---|
| 1005 | "</script>"; |
---|
| 1006 | } |
---|
| 1007 | |
---|
[3256] | 1008 | public static function jsLoadCodeMirror($theme = '',$multi = true,$modes = array('css','htmlmixed','javascript','php','xml')) |
---|
[3251] | 1009 | { |
---|
| 1010 | $ret = |
---|
| 1011 | self::cssLoad('js/codemirror/lib/codemirror.css'). |
---|
| 1012 | self::jsLoad('js/codemirror/lib/codemirror.js'); |
---|
| 1013 | if ($multi) { |
---|
| 1014 | $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js'); |
---|
| 1015 | } |
---|
| 1016 | foreach ($modes as $mode) { |
---|
| 1017 | $ret .= self::jsLoad('js/codemirror/mode/'.$mode.'/'.$mode.'.js'); |
---|
| 1018 | } |
---|
| 1019 | $ret .= |
---|
| 1020 | self::jsLoad('js/codemirror/addon/edit/closebrackets.js'). |
---|
[3253] | 1021 | self::jsLoad('js/codemirror/addon/edit/matchbrackets.js'). |
---|
| 1022 | self::cssLoad('js/codemirror/addon/display/fullscreen.css'). |
---|
| 1023 | self::jsLoad('js/codemirror/addon/display/fullscreen.js'); |
---|
[3251] | 1024 | if ($theme != '') { |
---|
| 1025 | $ret .= self::cssLoad('js/codemirror/theme/'.$theme.'.css'); |
---|
| 1026 | } |
---|
| 1027 | return $ret; |
---|
| 1028 | } |
---|
| 1029 | |
---|
[3256] | 1030 | public static function jsRunCodeMirror($name,$id,$mode,$theme = '') |
---|
| 1031 | { |
---|
| 1032 | $ret = |
---|
[3421] | 1033 | '<script type="text/javascript">'."\n". |
---|
[3256] | 1034 | 'var '.$name.' = CodeMirror.fromTextArea('.$id.',{'."\n". |
---|
| 1035 | ' mode: "'.$mode.'",'."\n". |
---|
| 1036 | ' tabMode: "indent",'."\n". |
---|
| 1037 | ' lineWrapping: "true",'."\n". |
---|
| 1038 | ' lineNumbers: "true",'."\n". |
---|
| 1039 | ' matchBrackets: "true",'."\n". |
---|
| 1040 | ' autoCloseBrackets: "true",'."\n". |
---|
| 1041 | ' extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}'; |
---|
[3421] | 1042 | if ($theme) { |
---|
| 1043 | $ret .= |
---|
| 1044 | ','."\n". |
---|
| 1045 | ' theme: "'.$theme.'"'; |
---|
| 1046 | } |
---|
| 1047 | $ret .= "\n". |
---|
| 1048 | '});'."\n". |
---|
[3256] | 1049 | '</script>'; |
---|
| 1050 | return $ret; |
---|
| 1051 | } |
---|
| 1052 | |
---|
[3251] | 1053 | public static function getCodeMirrorThemes() |
---|
| 1054 | { |
---|
| 1055 | $themes = array(); |
---|
| 1056 | $themes_root = dirname(__FILE__).'/../../admin'.'/js/codemirror/theme/'; |
---|
| 1057 | if (is_dir($themes_root) && is_readable($themes_root)) { |
---|
| 1058 | if (($d = @dir($themes_root)) !== false) { |
---|
| 1059 | while (($entry = $d->read()) !== false) { |
---|
| 1060 | if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root.'/'.$entry)) { |
---|
| 1061 | $themes[] = substr($entry,0,-4); // remove .css extension |
---|
| 1062 | } |
---|
| 1063 | } |
---|
[3313] | 1064 | sort($themes); |
---|
[3251] | 1065 | } |
---|
| 1066 | } |
---|
| 1067 | return $themes; |
---|
| 1068 | } |
---|
| 1069 | |
---|
[3080] | 1070 | public static function getPF($file) |
---|
| 1071 | { |
---|
[2852] | 1072 | return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); |
---|
[2849] | 1073 | } |
---|
[2909] | 1074 | |
---|
[3262] | 1075 | public static function getVF($file) |
---|
| 1076 | { |
---|
| 1077 | return $GLOBALS['core']->adminurl->get('load.var.file',array('vf' => $file)); |
---|
| 1078 | } |
---|
| 1079 | |
---|
[3279] | 1080 | public static function setXFrameOptions($headers,$origin = null) |
---|
[3080] | 1081 | { |
---|
[2909] | 1082 | if (self::$xframe_loaded) { |
---|
| 1083 | return; |
---|
| 1084 | } |
---|
| 1085 | if ($origin !== null) { |
---|
| 1086 | $url = parse_url($origin); |
---|
[3279] | 1087 | $headers['x-frame-options'] = sprintf('X-Frame-Options: %s',is_array($url) ? |
---|
[3080] | 1088 | ("ALLOW-FROM ".(isset($url['scheme']) ? $url['scheme'].':' : '' ).'//'.$url['host']) : |
---|
[3279] | 1089 | 'SAMEORIGIN'); |
---|
[2909] | 1090 | } else { |
---|
[3279] | 1091 | $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
[2909] | 1092 | } |
---|
| 1093 | self::$xframe_loaded = true; |
---|
| 1094 | } |
---|
[489] | 1095 | } |
---|