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