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