[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()); |
---|
[3340] | 108 | $csp['default-src'] = $core->blog->settings->system->csp_admin_default ?: "'self'"; |
---|
| 109 | $csp['script-src'] = $core->blog->settings->system->csp_admin_script ?: "'self' 'unsafe-inline' 'unsafe-eval'"; |
---|
| 110 | $csp['style-src'] = $core->blog->settings->system->csp_admin_style ?: "'self' 'unsafe-inline'"; |
---|
[3401] | 111 | $csp['img-src'] = $core->blog->settings->system->csp_admin_img ?: "'self' data: media.dotaddict.org blob:"; |
---|
[3292] | 112 | |
---|
[3307] | 113 | # Cope with blog post preview (via public URL in iframe) |
---|
| 114 | if (!is_null($core->blog->host)) { |
---|
| 115 | $csp['default-src'] .= ' '.parse_url($core->blog->host,PHP_URL_HOST); |
---|
| 116 | } |
---|
| 117 | # Cope with media display in media manager (via public URL) |
---|
| 118 | if (!is_null($core->media)) { |
---|
| 119 | $csp['img-src'] .= ' '.parse_url($core->media->root_url,PHP_URL_HOST); |
---|
| 120 | } |
---|
[3319] | 121 | # Allow everything in iframe (used by editors to preview public content) |
---|
| 122 | $csp['child-src'] = "*"; |
---|
[3307] | 123 | |
---|
[3292] | 124 | # --BEHAVIOR-- adminPageHTTPHeaderCSP |
---|
| 125 | $core->callBehavior('adminPageHTTPHeaderCSP',$csp); |
---|
| 126 | |
---|
| 127 | // Construct CSP header |
---|
| 128 | $directives = array(); |
---|
| 129 | foreach ($csp as $key => $value) { |
---|
| 130 | if ($value) { |
---|
| 131 | $directives[] = $key.' '.$value; |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | if (count($directives)) { |
---|
| 135 | if (version_compare(phpversion(),'5.4','>=')) { |
---|
| 136 | // csp_report.php needs PHP ≥ 5.4 |
---|
| 137 | $directives[] = "report-uri ".DC_ADMIN_URL."csp_report.php"; |
---|
| 138 | } |
---|
[3326] | 139 | $report_only = ($core->blog->settings->system->csp_admin_report_only) ? '-Report-Only' : ''; |
---|
| 140 | $headers['csp'] = "Content-Security-Policy".$report_only.": ".implode(" ; ",$directives); |
---|
[3292] | 141 | } |
---|
[3291] | 142 | } |
---|
[3279] | 143 | |
---|
| 144 | # --BEHAVIOR-- adminPageHTTPHeaders |
---|
| 145 | $core->callBehavior('adminPageHTTPHeaders',$headers); |
---|
| 146 | foreach ($headers as $key => $value) { |
---|
| 147 | header($value); |
---|
| 148 | } |
---|
[3276] | 149 | |
---|
[0] | 150 | echo |
---|
[2760] | 151 | '<!DOCTYPE html>'. |
---|
| 152 | '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
[0] | 153 | "<head>\n". |
---|
[2760] | 154 | ' <meta charset="UTF-8" />'."\n". |
---|
[0] | 155 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 156 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
[1310] | 157 | ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
[489] | 158 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
[1187] | 159 | |
---|
| 160 | |
---|
[0] | 161 | self::jsLoadIE7(). |
---|
[3021] | 162 | self::cssLoad('style/default.css'); |
---|
[0] | 163 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
[3021] | 164 | echo self::cssLoad('style/default-rtl.css'); |
---|
[0] | 165 | } |
---|
[237] | 166 | |
---|
[244] | 167 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 168 | $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; |
---|
| 169 | if (!$user_ui_hide_std_favicon) { |
---|
[2503] | 170 | echo |
---|
[3021] | 171 | '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'."\n". |
---|
| 172 | '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'."\n"; |
---|
[244] | 173 | } |
---|
[3408] | 174 | |
---|
| 175 | if ($core->auth->user_prefs->interface->htmlfontsize) { |
---|
| 176 | echo |
---|
| 177 | '<script type="text/javascript">'."\n". |
---|
| 178 | "//<![CDATA[\n". |
---|
| 179 | self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize). |
---|
| 180 | "\n//]]>\n". |
---|
| 181 | "</script>\n"; |
---|
| 182 | } |
---|
| 183 | |
---|
[0] | 184 | echo |
---|
| 185 | self::jsCommon(). |
---|
[1699] | 186 | self::jsToggles(). |
---|
[0] | 187 | $head; |
---|
[1187] | 188 | |
---|
[3398] | 189 | if ($core->auth->user_prefs->interface->hidemoreinfo) { |
---|
| 190 | echo |
---|
| 191 | '<script type="text/javascript">'."\n". |
---|
| 192 | "//<![CDATA[\n". |
---|
| 193 | 'dotclear.hideMoreInfo = true;'. |
---|
| 194 | "\n//]]>\n". |
---|
| 195 | "</script>\n"; |
---|
| 196 | } |
---|
| 197 | |
---|
[0] | 198 | # --BEHAVIOR-- adminPageHTMLHead |
---|
| 199 | $core->callBehavior('adminPageHTMLHead'); |
---|
[1187] | 200 | |
---|
[0] | 201 | echo |
---|
| 202 | "</head>\n". |
---|
[36] | 203 | '<body id="dotclear-admin'. |
---|
[1586] | 204 | ($safe_mode ? ' safe-mode' : '').'" class="no-js">'."\n". |
---|
[1187] | 205 | |
---|
[1590] | 206 | '<ul id="prelude">'. |
---|
| 207 | '<li><a href="#content">'.__('Go to the content').'</a></li>'. |
---|
| 208 | '<li><a href="#main-menu">'.__('Go to the menu').'</a></li>'. |
---|
| 209 | '<li><a href="#qx">'.__('Go to search').'</a></li>'. |
---|
[2304] | 210 | '<li><a href="#help">'.__('Go to help').'</a></li>'. |
---|
[1590] | 211 | '</ul>'."\n". |
---|
[2784] | 212 | '<div id="header" role="banner">'. |
---|
[2720] | 213 | '<h1><a href="'.$core->adminurl->get("admin.home").'"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n"; |
---|
[1187] | 214 | |
---|
[0] | 215 | echo |
---|
[2720] | 216 | '<form action="'.$core->adminurl->get("admin.home").'" method="post" id="top-info-blog">'. |
---|
[0] | 217 | $blog_box. |
---|
[2225] | 218 | '<p><a href="'.$core->blog->url.'" class="outgoing" title="'.__('Go to site'). |
---|
| 219 | '">'.__('Go to site').'<img src="images/outgoing.png" alt="" /></a>'. |
---|
[999] | 220 | '</p></form>'. |
---|
[2005] | 221 | '<ul id="top-info-user">'. |
---|
[2817] | 222 | '<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>'. |
---|
| 223 | '<li><a class="smallscreen'.(preg_match('/'.preg_quote($core->adminurl->get('admin.user.preferences')).'(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : ''). |
---|
[2720] | 224 | '" href="'.$core->adminurl->get("admin.user.preferences").'">'.__('My preferences').'</a></li>'. |
---|
| 225 | '<li><a href="'.$core->adminurl->get("admin.home",array('logout' => 1)).'" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()). |
---|
[2034] | 226 | '</span><img src="images/logout.png" alt="" /></a></li>'. |
---|
[2005] | 227 | '</ul>'. |
---|
| 228 | '</div>'; // end header |
---|
[1187] | 229 | |
---|
[0] | 230 | echo |
---|
[1741] | 231 | '<div id="wrapper" class="clearfix">'."\n". |
---|
[1946] | 232 | '<div class="hidden-if-no-js collapser-box"><a href="#" id="collapser">'. |
---|
[3355] | 233 | '<img class="collapse-mm visually-hidden" src="images/collapser-hide.png" alt="'.__('Hide main menu').'" />'. |
---|
| 234 | '<img class="expand-mm visually-hidden" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'. |
---|
[1867] | 235 | '</a></div>'. |
---|
[2784] | 236 | '<div id="main" role="main">'."\n". |
---|
[1741] | 237 | '<div id="content" class="clearfix">'."\n"; |
---|
[1187] | 238 | |
---|
[36] | 239 | # Safe mode |
---|
| 240 | if ($safe_mode) |
---|
[0] | 241 | { |
---|
| 242 | echo |
---|
[2787] | 243 | '<div class="warning" role="alert"><h3>'.__('Safe mode').'</h3>'. |
---|
[37] | 244 | '<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] | 245 | '</div>'; |
---|
| 246 | } |
---|
[1187] | 247 | |
---|
[3076] | 248 | // Display breadcrumb (if given) before any error messages |
---|
[1357] | 249 | echo $breadcrumb; |
---|
[1355] | 250 | |
---|
[3076] | 251 | // Display notices and errors |
---|
[2199] | 252 | echo self::notices(); |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | public static function notices() |
---|
| 256 | { |
---|
[3076] | 257 | global $core; |
---|
| 258 | static $error_displayed = false; |
---|
| 259 | $res = ''; |
---|
| 260 | |
---|
| 261 | // return error messages if any |
---|
| 262 | if ($core->error->flag() && !$error_displayed) { |
---|
| 263 | $res .= '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong></p>'. |
---|
| 264 | $core->error->toHTML(). |
---|
| 265 | '</div>'; |
---|
| 266 | $error_displayed = true; |
---|
| 267 | } |
---|
| 268 | |
---|
[2199] | 269 | // return notices if any |
---|
[2181] | 270 | if (isset($_SESSION['notifications'])) { |
---|
[2328] | 271 | foreach ($_SESSION['notifications'] as $notification) { |
---|
| 272 | $res .= self::getNotification($notification); |
---|
[2181] | 273 | } |
---|
| 274 | unset($_SESSION['notifications']); |
---|
| 275 | } |
---|
[2199] | 276 | return $res; |
---|
[0] | 277 | } |
---|
[2191] | 278 | |
---|
[2328] | 279 | public static function addNotice($type,$message,$options=array()) |
---|
[2191] | 280 | { |
---|
[2328] | 281 | if (isset(self::$N_TYPES[$type])){ |
---|
| 282 | $class = self::$N_TYPES[$type]; |
---|
| 283 | } else { |
---|
| 284 | $class=$type; |
---|
| 285 | } |
---|
| 286 | if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) { |
---|
| 287 | $notifications = $_SESSION['notifications']; |
---|
| 288 | } else { |
---|
| 289 | $notifications = array(); |
---|
| 290 | } |
---|
[2503] | 291 | |
---|
[2328] | 292 | $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message)); |
---|
| 293 | if ($type != "static") { |
---|
| 294 | $notifications[] = $n; |
---|
| 295 | } else { |
---|
| 296 | array_unshift($notifications, $n); |
---|
| 297 | } |
---|
| 298 | $_SESSION['notifications'] = $notifications; |
---|
[2181] | 299 | } |
---|
[2191] | 300 | |
---|
[2328] | 301 | public static function addSuccessNotice($message,$options=array()) |
---|
[2191] | 302 | { |
---|
[2328] | 303 | self::addNotice("success",$message,$options); |
---|
[2181] | 304 | } |
---|
[2191] | 305 | |
---|
[2328] | 306 | public static function addWarningNotice($message,$options=array()) |
---|
[2191] | 307 | { |
---|
[2328] | 308 | self::addNotice("warning",$message,$options); |
---|
[2181] | 309 | } |
---|
[2191] | 310 | |
---|
[2328] | 311 | public static function addErrorNotice($message,$options=array()) |
---|
[2191] | 312 | { |
---|
[2328] | 313 | self::addNotice("error",$message,$options); |
---|
[2191] | 314 | } |
---|
| 315 | |
---|
[2328] | 316 | protected static function getNotification($n) |
---|
[2191] | 317 | { |
---|
[2181] | 318 | global $core; |
---|
[3340] | 319 | $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p'; |
---|
[2328] | 320 | $ts = ''; |
---|
| 321 | if (!isset($n['with_ts']) || ($n['with_ts'] == true)) { |
---|
| 322 | $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' '; |
---|
| 323 | } |
---|
[2787] | 324 | $res = '<'.$tag.' class="'.$n['class'].'" role="alert">'.$ts.$n['text'].'</'.$tag.'>'; |
---|
[2191] | 325 | return $res; |
---|
[2181] | 326 | } |
---|
[2191] | 327 | |
---|
[0] | 328 | public static function close() |
---|
| 329 | { |
---|
[942] | 330 | global $core; |
---|
| 331 | |
---|
[1933] | 332 | if (!$GLOBALS['__resources']['ctxhelp']) { |
---|
| 333 | echo |
---|
[2720] | 334 | '<p id="help-button"><a href="'.$core->adminurl->get("admin.help").'" class="outgoing" title="'. |
---|
[2306] | 335 | __('Global help').'">'.__('Global help').'</a></p>'; |
---|
[1933] | 336 | } |
---|
| 337 | |
---|
[0] | 338 | $menu =& $GLOBALS['_menu']; |
---|
[1187] | 339 | |
---|
[0] | 340 | echo |
---|
| 341 | "</div>\n". // End of #content |
---|
| 342 | "</div>\n". // End of #main |
---|
[1187] | 343 | |
---|
[2784] | 344 | '<div id="main-menu" role="navigation">'."\n". |
---|
[1311] | 345 | |
---|
[2769] | 346 | '<form id="search-menu" action="'.$core->adminurl->get("admin.search").'" method="get" role="search">'. |
---|
[1589] | 347 | '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,''). |
---|
[1311] | 348 | '<input type="submit" value="'.__('OK').'" /></p>'. |
---|
| 349 | '</form>'; |
---|
[1187] | 350 | |
---|
[0] | 351 | foreach ($menu as $k => $v) { |
---|
| 352 | echo $menu[$k]->draw(); |
---|
| 353 | } |
---|
[1187] | 354 | |
---|
[1140] | 355 | $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); |
---|
[942] | 356 | |
---|
| 357 | # --BEHAVIOR-- adminPageFooter |
---|
[946] | 358 | $textAlt = $core->callBehavior('adminPageFooter',$core,$text); |
---|
[1140] | 359 | if ($textAlt != '') { |
---|
| 360 | $text = $textAlt; |
---|
| 361 | } |
---|
[1142] | 362 | $text = html::escapeHTML($text); |
---|
[942] | 363 | |
---|
[0] | 364 | echo |
---|
| 365 | '</div>'."\n". // End of #main-menu |
---|
[1946] | 366 | "</div>\n"; // End of #wrapper |
---|
[1861] | 367 | |
---|
[3294] | 368 | echo '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n"; |
---|
| 369 | |
---|
[3060] | 370 | $figure = " |
---|
[3224] | 371 | /\_/\ |
---|
| 372 | (='.'=) |
---|
| 373 | (\")-(\") |
---|
| 374 | "; |
---|
[3060] | 375 | |
---|
[1946] | 376 | echo |
---|
[2784] | 377 | '<div id="footer" role="contentinfo">'. |
---|
[2296] | 378 | '<a href="http://dotclear.org/" title="'.$text.'">'. |
---|
| 379 | '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". |
---|
[2796] | 380 | "<!-- "."\n". |
---|
[3060] | 381 | $figure. |
---|
[2796] | 382 | " -->"."\n"; |
---|
[1187] | 383 | |
---|
[3294] | 384 | |
---|
| 385 | |
---|
[0] | 386 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 387 | echo self::debugInfo(); |
---|
| 388 | } |
---|
[1187] | 389 | |
---|
[0] | 390 | echo |
---|
| 391 | '</body></html>'; |
---|
| 392 | } |
---|
[1187] | 393 | |
---|
[1358] | 394 | public static function openPopup($title='',$head='',$breadcrumb='') |
---|
[0] | 395 | { |
---|
| 396 | global $core; |
---|
[1187] | 397 | |
---|
[0] | 398 | # Display |
---|
| 399 | header('Content-Type: text/html; charset=UTF-8'); |
---|
[2792] | 400 | |
---|
| 401 | // Prevents Clickjacking as far as possible |
---|
| 402 | header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
| 403 | |
---|
[0] | 404 | echo |
---|
[2760] | 405 | '<!DOCTYPE html>'. |
---|
| 406 | '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
[0] | 407 | "<head>\n". |
---|
[2760] | 408 | ' <meta charset="UTF-8" />'."\n". |
---|
[2513] | 409 | ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
[0] | 410 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
[1187] | 411 | |
---|
[0] | 412 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 413 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
[1187] | 414 | |
---|
[0] | 415 | self::jsLoadIE7(). |
---|
[3021] | 416 | self::cssLoad('style/default.css'); |
---|
[0] | 417 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
[3021] | 418 | echo self::cssLoad('style/default-rtl.css'); |
---|
[0] | 419 | } |
---|
[1187] | 420 | |
---|
[3408] | 421 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 422 | if ($core->auth->user_prefs->interface->htmlfontsize) { |
---|
| 423 | echo |
---|
| 424 | '<script type="text/javascript">'."\n". |
---|
| 425 | "//<![CDATA[\n". |
---|
| 426 | self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize). |
---|
| 427 | "\n//]]>\n". |
---|
| 428 | "</script>\n"; |
---|
| 429 | } |
---|
| 430 | |
---|
[0] | 431 | echo |
---|
| 432 | self::jsCommon(). |
---|
[1699] | 433 | self::jsToggles(). |
---|
[0] | 434 | $head; |
---|
[1187] | 435 | |
---|
[3398] | 436 | if ($core->auth->user_prefs->interface->hidemoreinfo) { |
---|
| 437 | echo |
---|
| 438 | '<script type="text/javascript">'."\n". |
---|
| 439 | "//<![CDATA[\n". |
---|
| 440 | 'dotclear.hideMoreInfo = true;'. |
---|
| 441 | "\n//]]>\n". |
---|
| 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". |
---|
| 692 | "//<![CDATA[\n". |
---|
| 693 | 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". |
---|
| 694 | "\n//]]>\n". |
---|
| 695 | "</script>\n"; |
---|
| 696 | } |
---|
[2503] | 697 | |
---|
[0] | 698 | public static function jsCommon() |
---|
| 699 | { |
---|
[1771] | 700 | $mute_or_no = ''; |
---|
[1841] | 701 | if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { |
---|
[1771] | 702 | $mute_or_no .= |
---|
| 703 | '<script type="text/javascript">'."\n". |
---|
| 704 | "//<![CDATA[\n". |
---|
| 705 | 'jQuery.migrateMute = true;'. |
---|
| 706 | "\n//]]>\n". |
---|
| 707 | "</script>\n"; |
---|
| 708 | } |
---|
| 709 | |
---|
[0] | 710 | return |
---|
| 711 | self::jsLoad('js/jquery/jquery.js'). |
---|
[1771] | 712 | $mute_or_no. |
---|
[3178] | 713 | self::jsLoad('js/jquery/jquery-migrate.js'). |
---|
[0] | 714 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
| 715 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
| 716 | self::jsLoad('js/common.js'). |
---|
[447] | 717 | self::jsLoad('js/prelude.js'). |
---|
[1187] | 718 | |
---|
[0] | 719 | '<script type="text/javascript">'."\n". |
---|
| 720 | "//<![CDATA[\n". |
---|
[2614] | 721 | 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". |
---|
[0] | 722 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
[1019] | 723 | self::jsVar('dotclear.img_plus_src','images/expand.png'). |
---|
[0] | 724 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
[1019] | 725 | self::jsVar('dotclear.img_minus_src','images/hide.png'). |
---|
[0] | 726 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
| 727 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
| 728 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
[2503] | 729 | |
---|
[2195] | 730 | self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png'). |
---|
| 731 | self::jsVar('dotclear.img_plus_theme_alt',__('uncover')). |
---|
| 732 | self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png'). |
---|
| 733 | self::jsVar('dotclear.img_minus_theme_alt',__('hide')). |
---|
[1187] | 734 | |
---|
[0] | 735 | self::jsVar('dotclear.msg.help', |
---|
[1933] | 736 | __('Need help?')). |
---|
[2225] | 737 | self::jsVar('dotclear.msg.new_window', |
---|
| 738 | __('new window')). |
---|
[1302] | 739 | self::jsVar('dotclear.msg.help_hide', |
---|
| 740 | __('Hide')). |
---|
[1556] | 741 | self::jsVar('dotclear.msg.to_select', |
---|
| 742 | __('Select:')). |
---|
[0] | 743 | self::jsVar('dotclear.msg.no_selection', |
---|
| 744 | __('no selection')). |
---|
| 745 | self::jsVar('dotclear.msg.select_all', |
---|
| 746 | __('select all')). |
---|
| 747 | self::jsVar('dotclear.msg.invert_sel', |
---|
[1556] | 748 | __('Invert selection')). |
---|
[0] | 749 | self::jsVar('dotclear.msg.website', |
---|
| 750 | __('Web site:')). |
---|
| 751 | self::jsVar('dotclear.msg.email', |
---|
| 752 | __('Email:')). |
---|
| 753 | self::jsVar('dotclear.msg.ip_address', |
---|
| 754 | __('IP address:')). |
---|
| 755 | self::jsVar('dotclear.msg.error', |
---|
| 756 | __('Error:')). |
---|
| 757 | self::jsVar('dotclear.msg.entry_created', |
---|
| 758 | __('Entry has been successfully created.')). |
---|
| 759 | self::jsVar('dotclear.msg.edit_entry', |
---|
| 760 | __('Edit entry')). |
---|
| 761 | self::jsVar('dotclear.msg.view_entry', |
---|
| 762 | __('view entry')). |
---|
| 763 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
| 764 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
[2202] | 765 | self::jsVar('dotclear.msg.confirm_delete_medias', |
---|
| 766 | __("Are you sure you want to delete selected medias (%d)?")). |
---|
[1525] | 767 | self::jsVar('dotclear.msg.confirm_delete_categories', |
---|
| 768 | __("Are you sure you want to delete selected categories (%s)?")). |
---|
[0] | 769 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
| 770 | __("Are you sure you want to delete this entry?")). |
---|
[1395] | 771 | self::jsVar('dotclear.msg.click_to_unlock', |
---|
[1450] | 772 | __("Click here to unlock the field")). |
---|
[1049] | 773 | self::jsVar('dotclear.msg.confirm_spam_delete', |
---|
| 774 | __('Are you sure you want to delete all spams?')). |
---|
[0] | 775 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
| 776 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
| 777 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
| 778 | __('Are you sure you want to delete this comment?')). |
---|
| 779 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
| 780 | __('Users with posts cannot be deleted.')). |
---|
| 781 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
| 782 | __('Are you sure you want to delete selected users (%s)?')). |
---|
[3403] | 783 | self::jsVar('dotclear.msg.confirm_delete_blog', |
---|
| 784 | __('Are you sure you want to delete selected blogs (%s)?')). |
---|
[0] | 785 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
| 786 | __('Are you sure you want to delete category "%s"?')). |
---|
| 787 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
| 788 | __('Are you sure you want to reorder all categories?')). |
---|
| 789 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
| 790 | __('Are you sure you want to remove media "%s"?')). |
---|
[2512] | 791 | self::jsVar('dotclear.msg.confirm_delete_directory', |
---|
| 792 | __('Are you sure you want to remove directory "%s"?')). |
---|
[0] | 793 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
| 794 | __('Are you sure you want to extract archive in current directory?')). |
---|
| 795 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
| 796 | __('Are you sure you want to remove attachment "%s"?')). |
---|
| 797 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
| 798 | __('Are you sure you want to delete "%s" language?')). |
---|
| 799 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
| 800 | __('Are you sure you want to delete "%s" plugin?')). |
---|
[2487] | 801 | self::jsVar('dotclear.msg.confirm_delete_plugins', |
---|
| 802 | __('Are you sure you want to delete selected plugins?')). |
---|
[0] | 803 | self::jsVar('dotclear.msg.use_this_theme', |
---|
| 804 | __('Use this theme')). |
---|
| 805 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
| 806 | __('Remove this theme')). |
---|
| 807 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
| 808 | __('Are you sure you want to delete "%s" theme?')). |
---|
[2487] | 809 | self::jsVar('dotclear.msg.confirm_delete_themes', |
---|
| 810 | __('Are you sure you want to delete selected themes?')). |
---|
[1462] | 811 | self::jsVar('dotclear.msg.confirm_delete_backup', |
---|
| 812 | __('Are you sure you want to delete this backup?')). |
---|
[2503] | 813 | self::jsVar('dotclear.msg.confirm_revert_backup', |
---|
| 814 | __('Are you sure you want to revert to this backup?')). |
---|
[0] | 815 | self::jsVar('dotclear.msg.zip_file_content', |
---|
| 816 | __('Zip file content')). |
---|
| 817 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
| 818 | __('XHTML markup validator')). |
---|
| 819 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
| 820 | __('XHTML content is valid.')). |
---|
| 821 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
| 822 | __('There are XHTML markup errors.')). |
---|
[1861] | 823 | self::jsVar('dotclear.msg.warning_validate_no_save_content', |
---|
[1832] | 824 | __('Attention: an audit of a content not yet registered.')). |
---|
[0] | 825 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
| 826 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
[1256] | 827 | self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', |
---|
| 828 | __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). |
---|
[224] | 829 | self::jsVar('dotclear.msg.load_enhanced_uploader', |
---|
| 830 | __('Loading enhanced uploader, please wait.')). |
---|
[2156] | 831 | |
---|
| 832 | self::jsVar('dotclear.msg.module_author', |
---|
| 833 | __('Author:')). |
---|
| 834 | self::jsVar('dotclear.msg.module_details', |
---|
| 835 | __('Details')). |
---|
| 836 | self::jsVar('dotclear.msg.module_support', |
---|
[2157] | 837 | __('Support')). |
---|
[2156] | 838 | self::jsVar('dotclear.msg.module_help', |
---|
[2157] | 839 | __('Help:')). |
---|
[2156] | 840 | self::jsVar('dotclear.msg.module_section', |
---|
| 841 | __('Section:')). |
---|
| 842 | self::jsVar('dotclear.msg.module_tags', |
---|
| 843 | __('Tags:')). |
---|
[1699] | 844 | "\n//]]>\n". |
---|
[0] | 845 | "</script>\n"; |
---|
| 846 | } |
---|
[1187] | 847 | |
---|
[0] | 848 | public static function jsLoadIE7() |
---|
| 849 | { |
---|
| 850 | return |
---|
[1456] | 851 | '<!--[if lt IE 9]>'."\n". |
---|
| 852 | self::jsLoad('js/ie7/IE9.js'). |
---|
[3021] | 853 | self::cssLoad('style/iesucks.css'). |
---|
[0] | 854 | '<![endif]-->'."\n"; |
---|
| 855 | } |
---|
[1187] | 856 | |
---|
[0] | 857 | public static function jsConfirmClose() |
---|
| 858 | { |
---|
| 859 | $args = func_get_args(); |
---|
| 860 | if (count($args) > 0) { |
---|
| 861 | foreach ($args as $k => $v) { |
---|
| 862 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
| 863 | } |
---|
| 864 | $args = implode(',',$args); |
---|
| 865 | } else { |
---|
| 866 | $args = ''; |
---|
| 867 | } |
---|
[1187] | 868 | |
---|
[0] | 869 | return |
---|
| 870 | self::jsLoad('js/confirm-close.js'). |
---|
| 871 | '<script type="text/javascript">'."\n". |
---|
| 872 | "//<![CDATA[\n". |
---|
| 873 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
| 874 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
| 875 | "\n//]]>\n". |
---|
| 876 | "</script>\n"; |
---|
| 877 | } |
---|
[1187] | 878 | |
---|
[0] | 879 | public static function jsPageTabs($default=null) |
---|
| 880 | { |
---|
| 881 | if ($default) { |
---|
| 882 | $default = "'".html::escapeJS($default)."'"; |
---|
| 883 | } |
---|
[2503] | 884 | |
---|
[0] | 885 | return |
---|
| 886 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
| 887 | '<script type="text/javascript">'."\n". |
---|
| 888 | "//<![CDATA[\n". |
---|
[2010] | 889 | '$(function() {'."\n". |
---|
[2054] | 890 | '$.pageTabs('.$default.');'."\n". |
---|
[2113] | 891 | '});'. |
---|
[0] | 892 | "\n//]]>\n". |
---|
[2113] | 893 | "</script>\n". |
---|
| 894 | '<!--[if lt IE 8]>'."\n". |
---|
| 895 | self::jsLoad('js/ie7/ie7-hashchange.js'). |
---|
| 896 | '<script type="text/javascript">'."\n". |
---|
| 897 | "//<![CDATA[\n". |
---|
| 898 | '$(window).hashchange();'. |
---|
| 899 | "\n//]]>\n". |
---|
| 900 | "</script>\n". |
---|
| 901 | '<![endif]-->'."\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". |
---|
| 924 | "//<![CDATA[\n". |
---|
[1187] | 925 | |
---|
[2202] | 926 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
| 927 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
| 928 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
| 929 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
| 930 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
| 931 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
| 932 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
| 933 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
| 934 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
| 935 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
| 936 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
| 937 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
[1161] | 938 | |
---|
[2202] | 939 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
| 940 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
| 941 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
| 942 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
| 943 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
| 944 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
| 945 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
| 946 | |
---|
| 947 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
[2788] | 948 | "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". |
---|
[2202] | 949 | |
---|
| 950 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
| 951 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
| 952 | |
---|
| 953 | "\n//]]>\n". |
---|
| 954 | "</script>\n"; |
---|
[0] | 955 | } |
---|
[1187] | 956 | |
---|
[2720] | 957 | |
---|
[2202] | 958 | public static function jsToolBar() |
---|
| 959 | { |
---|
[2614] | 960 | # Deprecated but we keep this for plugins. |
---|
[2202] | 961 | } |
---|
| 962 | |
---|
| 963 | public static function jsUpload($params=array(),$base_url=null) |
---|
| 964 | { |
---|
| 965 | if (!$base_url) { |
---|
| 966 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
| 967 | } |
---|
| 968 | |
---|
| 969 | $params = array_merge($params,array( |
---|
| 970 | 'sess_id='.session_id(), |
---|
| 971 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
| 972 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
[0] | 973 | )); |
---|
[1187] | 974 | |
---|
[2202] | 975 | return |
---|
| 976 | '<script type="text/javascript">'."\n". |
---|
| 977 | "//<![CDATA[\n". |
---|
| 978 | "dotclear.jsUpload = {};\n". |
---|
| 979 | "dotclear.jsUpload.msg = {};\n". |
---|
| 980 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). |
---|
| 981 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). |
---|
| 982 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). |
---|
| 983 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
| 984 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). |
---|
| 985 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). |
---|
| 986 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). |
---|
| 987 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). |
---|
| 988 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). |
---|
| 989 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). |
---|
| 990 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). |
---|
| 991 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). |
---|
| 992 | self::jsVar('dotclear.jsUpload.msg.send',__('Send')). |
---|
| 993 | self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). |
---|
| 994 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). |
---|
| 995 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). |
---|
| 996 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). |
---|
| 997 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). |
---|
| 998 | self::jsVar('dotclear.jsUpload.base_url',$base_url). |
---|
| 999 | "\n//]]>\n". |
---|
| 1000 | "</script>\n". |
---|
[1461] | 1001 | |
---|
[3218] | 1002 | self::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
[2202] | 1003 | self::jsLoad('js/jsUpload/tmpl.js'). |
---|
| 1004 | self::jsLoad('js/jsUpload/template-upload.js'). |
---|
| 1005 | self::jsLoad('js/jsUpload/template-download.js'). |
---|
| 1006 | self::jsLoad('js/jsUpload/load-image.js'). |
---|
| 1007 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). |
---|
| 1008 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). |
---|
| 1009 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). |
---|
| 1010 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). |
---|
| 1011 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); |
---|
| 1012 | } |
---|
[1144] | 1013 | |
---|
[2202] | 1014 | public static function jsMetaEditor() |
---|
| 1015 | { |
---|
[3021] | 1016 | return self::jsLoad('js/meta-editor.js'); |
---|
[2202] | 1017 | } |
---|
[2849] | 1018 | |
---|
[3397] | 1019 | public static function jsFilterControl($show=true) |
---|
| 1020 | { |
---|
| 1021 | return |
---|
| 1022 | self::jsLoad('js/filter-controls.js'). |
---|
| 1023 | '<script type="text/javascript">'."\n". |
---|
| 1024 | "//<![CDATA["."\n". |
---|
| 1025 | self::jsVar('dotclear.msg.show_filters', $show ? 'true':'false')."\n". |
---|
| 1026 | self::jsVar('dotclear.msg.filter_posts_list',__('Show filters and display options'))."\n". |
---|
| 1027 | self::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". |
---|
| 1028 | "//]]>". |
---|
| 1029 | "</script>"; |
---|
| 1030 | } |
---|
| 1031 | |
---|
[3256] | 1032 | public static function jsLoadCodeMirror($theme = '',$multi = true,$modes = array('css','htmlmixed','javascript','php','xml')) |
---|
[3251] | 1033 | { |
---|
| 1034 | $ret = |
---|
| 1035 | self::cssLoad('js/codemirror/lib/codemirror.css'). |
---|
| 1036 | self::jsLoad('js/codemirror/lib/codemirror.js'); |
---|
| 1037 | if ($multi) { |
---|
| 1038 | $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js'); |
---|
| 1039 | } |
---|
| 1040 | foreach ($modes as $mode) { |
---|
| 1041 | $ret .= self::jsLoad('js/codemirror/mode/'.$mode.'/'.$mode.'.js'); |
---|
| 1042 | } |
---|
| 1043 | $ret .= |
---|
| 1044 | self::jsLoad('js/codemirror/addon/edit/closebrackets.js'). |
---|
[3253] | 1045 | self::jsLoad('js/codemirror/addon/edit/matchbrackets.js'). |
---|
| 1046 | self::cssLoad('js/codemirror/addon/display/fullscreen.css'). |
---|
| 1047 | self::jsLoad('js/codemirror/addon/display/fullscreen.js'); |
---|
[3251] | 1048 | if ($theme != '') { |
---|
| 1049 | $ret .= self::cssLoad('js/codemirror/theme/'.$theme.'.css'); |
---|
| 1050 | } |
---|
| 1051 | return $ret; |
---|
| 1052 | } |
---|
| 1053 | |
---|
[3256] | 1054 | public static function jsRunCodeMirror($name,$id,$mode,$theme = '') |
---|
| 1055 | { |
---|
| 1056 | $ret = |
---|
| 1057 | '<script type="text/javascript">'. |
---|
| 1058 | '//<![CDATA['."\n". |
---|
| 1059 | 'var '.$name.' = CodeMirror.fromTextArea('.$id.',{'."\n". |
---|
| 1060 | ' mode: "'.$mode.'",'."\n". |
---|
| 1061 | ' tabMode: "indent",'."\n". |
---|
| 1062 | ' lineWrapping: "true",'."\n". |
---|
| 1063 | ' lineNumbers: "true",'."\n". |
---|
| 1064 | ' matchBrackets: "true",'."\n". |
---|
| 1065 | ' autoCloseBrackets: "true",'."\n". |
---|
| 1066 | ' extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}'; |
---|
| 1067 | if ($theme) { |
---|
| 1068 | $ret .= |
---|
| 1069 | ','."\n". |
---|
| 1070 | ' theme: "'.$theme.'"'; |
---|
| 1071 | } |
---|
| 1072 | $ret .= |
---|
| 1073 | "\n".'});'."\n". |
---|
| 1074 | '//]]>'. |
---|
| 1075 | '</script>'; |
---|
| 1076 | return $ret; |
---|
| 1077 | } |
---|
| 1078 | |
---|
[3251] | 1079 | public static function getCodeMirrorThemes() |
---|
| 1080 | { |
---|
| 1081 | $themes = array(); |
---|
| 1082 | $themes_root = dirname(__FILE__).'/../../admin'.'/js/codemirror/theme/'; |
---|
| 1083 | if (is_dir($themes_root) && is_readable($themes_root)) { |
---|
| 1084 | if (($d = @dir($themes_root)) !== false) { |
---|
| 1085 | while (($entry = $d->read()) !== false) { |
---|
| 1086 | if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root.'/'.$entry)) { |
---|
| 1087 | $themes[] = substr($entry,0,-4); // remove .css extension |
---|
| 1088 | } |
---|
| 1089 | } |
---|
[3313] | 1090 | sort($themes); |
---|
[3251] | 1091 | } |
---|
| 1092 | } |
---|
| 1093 | return $themes; |
---|
| 1094 | } |
---|
| 1095 | |
---|
[3080] | 1096 | public static function getPF($file) |
---|
| 1097 | { |
---|
[2852] | 1098 | return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); |
---|
[2849] | 1099 | } |
---|
[2909] | 1100 | |
---|
[3262] | 1101 | public static function getVF($file) |
---|
| 1102 | { |
---|
| 1103 | return $GLOBALS['core']->adminurl->get('load.var.file',array('vf' => $file)); |
---|
| 1104 | } |
---|
| 1105 | |
---|
[3279] | 1106 | public static function setXFrameOptions($headers,$origin = null) |
---|
[3080] | 1107 | { |
---|
[2909] | 1108 | if (self::$xframe_loaded) { |
---|
| 1109 | return; |
---|
| 1110 | } |
---|
| 1111 | if ($origin !== null) { |
---|
| 1112 | $url = parse_url($origin); |
---|
[3279] | 1113 | $headers['x-frame-options'] = sprintf('X-Frame-Options: %s',is_array($url) ? |
---|
[3080] | 1114 | ("ALLOW-FROM ".(isset($url['scheme']) ? $url['scheme'].':' : '' ).'//'.$url['host']) : |
---|
[3279] | 1115 | 'SAMEORIGIN'); |
---|
[2909] | 1116 | } else { |
---|
[3279] | 1117 | $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
[2909] | 1118 | } |
---|
| 1119 | self::$xframe_loaded = true; |
---|
| 1120 | } |
---|
[489] | 1121 | } |
---|