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