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