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