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