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