[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 = " |
---|
[3224] | 300 | /\_/\ |
---|
| 301 | (='.'=) |
---|
| 302 | (\")-(\") |
---|
| 303 | "; |
---|
[3060] | 304 | |
---|
[1946] | 305 | echo |
---|
[2784] | 306 | '<div id="footer" role="contentinfo">'. |
---|
[2296] | 307 | '<a href="http://dotclear.org/" title="'.$text.'">'. |
---|
| 308 | '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". |
---|
[2796] | 309 | "<!-- "."\n". |
---|
[3060] | 310 | $figure. |
---|
[2796] | 311 | " -->"."\n"; |
---|
[1187] | 312 | |
---|
[0] | 313 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 314 | echo self::debugInfo(); |
---|
| 315 | } |
---|
[1187] | 316 | |
---|
[0] | 317 | echo |
---|
| 318 | '</body></html>'; |
---|
| 319 | } |
---|
[1187] | 320 | |
---|
[1358] | 321 | public static function openPopup($title='',$head='',$breadcrumb='') |
---|
[0] | 322 | { |
---|
| 323 | global $core; |
---|
[1187] | 324 | |
---|
[0] | 325 | # Display |
---|
| 326 | header('Content-Type: text/html; charset=UTF-8'); |
---|
[2792] | 327 | |
---|
| 328 | // Prevents Clickjacking as far as possible |
---|
| 329 | header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
| 330 | |
---|
[0] | 331 | echo |
---|
[2760] | 332 | '<!DOCTYPE html>'. |
---|
| 333 | '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
[0] | 334 | "<head>\n". |
---|
[2760] | 335 | ' <meta charset="UTF-8" />'."\n". |
---|
[2513] | 336 | ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
[0] | 337 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
[1187] | 338 | |
---|
[0] | 339 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 340 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
[1187] | 341 | |
---|
[0] | 342 | self::jsLoadIE7(). |
---|
[3021] | 343 | self::cssLoad('style/default.css'); |
---|
[0] | 344 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
[3021] | 345 | echo self::cssLoad('style/default-rtl.css'); |
---|
[0] | 346 | } |
---|
[1187] | 347 | |
---|
[0] | 348 | echo |
---|
| 349 | self::jsCommon(). |
---|
[1699] | 350 | self::jsToggles(). |
---|
[0] | 351 | $head; |
---|
[1187] | 352 | |
---|
[0] | 353 | # --BEHAVIOR-- adminPageHTMLHead |
---|
| 354 | $core->callBehavior('adminPageHTMLHead'); |
---|
[1187] | 355 | |
---|
[0] | 356 | echo |
---|
| 357 | "</head>\n". |
---|
| 358 | '<body id="dotclear-admin" class="popup">'."\n". |
---|
[1187] | 359 | |
---|
[2046] | 360 | '<h1>'.DC_VENDOR_NAME.'</h1>'."\n"; |
---|
[1187] | 361 | |
---|
[0] | 362 | echo |
---|
| 363 | '<div id="wrapper">'."\n". |
---|
[2784] | 364 | '<div id="main" role="main">'."\n". |
---|
[0] | 365 | '<div id="content">'."\n"; |
---|
[1187] | 366 | |
---|
[1358] | 367 | // display breadcrumb if given |
---|
| 368 | echo $breadcrumb; |
---|
| 369 | |
---|
[3076] | 370 | // Display notices and errors |
---|
| 371 | echo self::notices(); |
---|
[0] | 372 | } |
---|
[1187] | 373 | |
---|
[0] | 374 | public static function closePopup() |
---|
| 375 | { |
---|
| 376 | echo |
---|
| 377 | "</div>\n". // End of #content |
---|
| 378 | "</div>\n". // End of #main |
---|
[2046] | 379 | "</div>\n". // End of #wrapper |
---|
[2784] | 380 | '<div id="footer" role="contentinfo"><p> </p></div>'."\n". |
---|
[0] | 381 | '</body></html>'; |
---|
| 382 | } |
---|
[907] | 383 | |
---|
[2166] | 384 | public static function breadcrumb($elements=null,$options=array()) |
---|
[1328] | 385 | { |
---|
[2720] | 386 | global $core; |
---|
[2166] | 387 | $with_home_link = isset($options['home_link'])?$options['home_link']:true; |
---|
[2167] | 388 | $hl = isset($options['hl'])?$options['hl']:true; |
---|
| 389 | $hl_pos = isset($options['hl_pos'])?$options['hl_pos']:-1; |
---|
[1328] | 390 | // First item of array elements should be blog's name, System or Plugins |
---|
[1340] | 391 | $res = '<h2>'.($with_home_link ? |
---|
[2720] | 392 | '<a class="go_home" href="'.$core->adminurl->get("admin.home").'"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : |
---|
[1340] | 393 | '<img src="style/dashboard-alt.png" alt="" />'); |
---|
[1328] | 394 | $index = 0; |
---|
[2167] | 395 | if ($hl_pos < 0) { |
---|
| 396 | $hl_pos = count($elements)+$hl_pos; |
---|
[2166] | 397 | } |
---|
[1328] | 398 | foreach ($elements as $element => $url) { |
---|
[2167] | 399 | if ($hl && $index == $hl_pos) { |
---|
[2166] | 400 | $element = sprintf('<span class="page-title">%s</span>',$element); |
---|
| 401 | } |
---|
[1358] | 402 | $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')). |
---|
| 403 | ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); |
---|
[1328] | 404 | $index++; |
---|
| 405 | } |
---|
| 406 | $res .= '</h2>'; |
---|
| 407 | return $res; |
---|
| 408 | } |
---|
| 409 | |
---|
[1548] | 410 | public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message') |
---|
[907] | 411 | { |
---|
[910] | 412 | global $core; |
---|
[1187] | 413 | |
---|
[907] | 414 | $res = ''; |
---|
| 415 | if ($msg != '') { |
---|
[1548] | 416 | $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'. |
---|
[2191] | 417 | ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. |
---|
[1161] | 418 | '</p>'.($div ? '</div>' : ''); |
---|
[907] | 419 | if ($echo) { |
---|
| 420 | echo $res; |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | return $res; |
---|
| 424 | } |
---|
[1187] | 425 | |
---|
[1548] | 426 | public static function success($msg,$timestamp=true,$div=false,$echo=true) |
---|
| 427 | { |
---|
[1927] | 428 | return self::message($msg,$timestamp,$div,$echo,"success"); |
---|
[1548] | 429 | } |
---|
| 430 | |
---|
[1725] | 431 | public static function warning($msg,$timestamp=true,$div=false,$echo=true) |
---|
| 432 | { |
---|
[1927] | 433 | return self::message($msg,$timestamp,$div,$echo,"warning-msg"); |
---|
[1725] | 434 | } |
---|
| 435 | |
---|
[0] | 436 | private static function debugInfo() |
---|
| 437 | { |
---|
| 438 | $global_vars = implode(', ',array_keys($GLOBALS)); |
---|
[1187] | 439 | |
---|
[0] | 440 | $res = |
---|
| 441 | '<div id="debug"><div>'. |
---|
| 442 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; |
---|
[1187] | 443 | |
---|
[0] | 444 | if (function_exists('xdebug_get_profiler_filename')) |
---|
| 445 | { |
---|
| 446 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; |
---|
[1187] | 447 | |
---|
[0] | 448 | $prof_file = xdebug_get_profiler_filename(); |
---|
| 449 | if ($prof_file) { |
---|
| 450 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; |
---|
| 451 | } else { |
---|
| 452 | $prof_url = http::getSelfURI(); |
---|
[321] | 453 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; |
---|
[0] | 454 | $prof_url .= 'XDEBUG_PROFILE'; |
---|
[321] | 455 | $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; |
---|
[0] | 456 | } |
---|
[1187] | 457 | |
---|
[0] | 458 | /* xdebug configuration: |
---|
| 459 | zend_extension = /.../xdebug.so |
---|
| 460 | xdebug.auto_trace = On |
---|
| 461 | xdebug.trace_format = 0 |
---|
| 462 | xdebug.trace_options = 1 |
---|
| 463 | xdebug.show_mem_delta = On |
---|
| 464 | xdebug.profiler_enable = 0 |
---|
| 465 | xdebug.profiler_enable_trigger = 1 |
---|
| 466 | xdebug.profiler_output_dir = /tmp |
---|
| 467 | xdebug.profiler_append = 0 |
---|
| 468 | xdebug.profiler_output_name = timestamp |
---|
| 469 | */ |
---|
| 470 | } |
---|
[1187] | 471 | |
---|
[0] | 472 | $res .= |
---|
| 473 | '<p>Global vars: '.$global_vars.'</p>'. |
---|
| 474 | '</div></div>'; |
---|
[1187] | 475 | |
---|
[0] | 476 | return $res; |
---|
| 477 | } |
---|
[1187] | 478 | |
---|
[0] | 479 | public static function help($page,$index='') |
---|
| 480 | { |
---|
| 481 | # Deprecated but we keep this for plugins. |
---|
| 482 | } |
---|
[1187] | 483 | |
---|
[0] | 484 | public static function helpBlock() |
---|
| 485 | { |
---|
[2720] | 486 | global $core; |
---|
[0] | 487 | $args = func_get_args(); |
---|
[1458] | 488 | |
---|
| 489 | $args = new ArrayObject($args); |
---|
| 490 | |
---|
| 491 | # --BEHAVIOR-- adminPageHelpBlock |
---|
| 492 | $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); |
---|
| 493 | |
---|
[0] | 494 | if (empty($args)) { |
---|
| 495 | return; |
---|
| 496 | }; |
---|
[1187] | 497 | |
---|
[0] | 498 | global $__resources; |
---|
| 499 | if (empty($__resources['help'])) { |
---|
| 500 | return; |
---|
| 501 | } |
---|
[1187] | 502 | |
---|
[0] | 503 | $content = ''; |
---|
| 504 | foreach ($args as $v) |
---|
| 505 | { |
---|
| 506 | if (is_object($v) && isset($v->content)) { |
---|
| 507 | $content .= $v->content; |
---|
| 508 | continue; |
---|
| 509 | } |
---|
[1187] | 510 | |
---|
[0] | 511 | if (!isset($__resources['help'][$v])) { |
---|
| 512 | continue; |
---|
| 513 | } |
---|
| 514 | $f = $__resources['help'][$v]; |
---|
| 515 | if (!file_exists($f) || !is_readable($f)) { |
---|
| 516 | continue; |
---|
| 517 | } |
---|
[1187] | 518 | |
---|
[0] | 519 | $fc = file_get_contents($f); |
---|
| 520 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
| 521 | $content .= $matches[1]; |
---|
| 522 | } else { |
---|
| 523 | $content .= $fc; |
---|
| 524 | } |
---|
| 525 | } |
---|
[1187] | 526 | |
---|
[0] | 527 | if (trim($content) == '') { |
---|
| 528 | return; |
---|
| 529 | } |
---|
[1187] | 530 | |
---|
[1933] | 531 | // Set contextual help global flag |
---|
| 532 | $GLOBALS['__resources']['ctxhelp'] = true; |
---|
| 533 | |
---|
[0] | 534 | echo |
---|
[1573] | 535 | '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'. |
---|
[0] | 536 | $content. |
---|
[494] | 537 | '</div>'. |
---|
| 538 | '<div id="helplink"><hr />'. |
---|
| 539 | '<p>'. |
---|
[2720] | 540 | sprintf(__('See also %s'),sprintf('<a href="'.$core->adminurl->get("admin.help").'">%s</a>',__('the global help'))). |
---|
[2011] | 541 | '.</p>'. |
---|
[0] | 542 | '</div></div>'; |
---|
| 543 | } |
---|
[1187] | 544 | |
---|
[3086] | 545 | public static function cssLoad($src,$media='screen',$v='') |
---|
[3021] | 546 | { |
---|
| 547 | $escaped_src = html::escapeHTML($src); |
---|
| 548 | if (!isset(self::$loaded_css[$escaped_src])) { |
---|
| 549 | self::$loaded_css[$escaped_src] = true; |
---|
[3086] | 550 | $escaped_src = self::appendVersion($escaped_src,$v); |
---|
[3021] | 551 | |
---|
| 552 | return '<link rel="stylesheet" href="'.$escaped_src.'" type="text/css" media="'.$media.'" />'."\n"; |
---|
| 553 | } |
---|
| 554 | } |
---|
| 555 | |
---|
[3086] | 556 | public static function jsLoad($src,$v='') |
---|
[0] | 557 | { |
---|
[342] | 558 | $escaped_src = html::escapeHTML($src); |
---|
| 559 | if (!isset(self::$loaded_js[$escaped_src])) { |
---|
[3020] | 560 | self::$loaded_js[$escaped_src] = true; |
---|
[3086] | 561 | $escaped_src = self::appendVersion($escaped_src,$v); |
---|
[342] | 562 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; |
---|
| 563 | } |
---|
[0] | 564 | } |
---|
[1187] | 565 | |
---|
[3086] | 566 | private static function appendVersion($src,$v='') |
---|
[3021] | 567 | { |
---|
[3129] | 568 | $src .= (strpos($src,'?') === false ? '?' : '&').'v='; |
---|
[3021] | 569 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 570 | $src .= md5(uniqid()); |
---|
| 571 | } else { |
---|
[3086] | 572 | $src .= ($v === '' ? DC_VERSION : $v); |
---|
[3021] | 573 | } |
---|
| 574 | return $src; |
---|
| 575 | } |
---|
| 576 | |
---|
[0] | 577 | public static function jsVar($n,$v) |
---|
| 578 | { |
---|
| 579 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
| 580 | } |
---|
[1187] | 581 | |
---|
[1699] | 582 | public static function jsToggles() |
---|
| 583 | { |
---|
| 584 | if($GLOBALS['core']->auth->user_prefs->toggles) { |
---|
| 585 | $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); |
---|
| 586 | foreach ($unfolded_sections as $k=>&$v) { |
---|
| 587 | if ($v == '') { |
---|
| 588 | unset($unfolded_sections[$k]); |
---|
| 589 | } else { |
---|
| 590 | $v = "'".html::escapeJS($v)."':true"; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | } else { |
---|
| 594 | $unfolded_sections=array(); |
---|
| 595 | } |
---|
| 596 | return '<script type="text/javascript">'."\n". |
---|
| 597 | "//<![CDATA[\n". |
---|
| 598 | 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". |
---|
| 599 | "\n//]]>\n". |
---|
| 600 | "</script>\n"; |
---|
| 601 | } |
---|
[2503] | 602 | |
---|
[0] | 603 | public static function jsCommon() |
---|
| 604 | { |
---|
[1771] | 605 | $mute_or_no = ''; |
---|
[1841] | 606 | if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { |
---|
[1771] | 607 | $mute_or_no .= |
---|
| 608 | '<script type="text/javascript">'."\n". |
---|
| 609 | "//<![CDATA[\n". |
---|
| 610 | 'jQuery.migrateMute = true;'. |
---|
| 611 | "\n//]]>\n". |
---|
| 612 | "</script>\n"; |
---|
| 613 | } |
---|
| 614 | |
---|
[0] | 615 | return |
---|
| 616 | self::jsLoad('js/jquery/jquery.js'). |
---|
[1771] | 617 | $mute_or_no. |
---|
[3178] | 618 | self::jsLoad('js/jquery/jquery-migrate.js'). |
---|
[0] | 619 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
| 620 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
| 621 | self::jsLoad('js/common.js'). |
---|
[447] | 622 | self::jsLoad('js/prelude.js'). |
---|
[1187] | 623 | |
---|
[0] | 624 | '<script type="text/javascript">'."\n". |
---|
| 625 | "//<![CDATA[\n". |
---|
[2614] | 626 | 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". |
---|
[0] | 627 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
[1019] | 628 | self::jsVar('dotclear.img_plus_src','images/expand.png'). |
---|
[0] | 629 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
[1019] | 630 | self::jsVar('dotclear.img_minus_src','images/hide.png'). |
---|
[0] | 631 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
| 632 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
| 633 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
[2503] | 634 | |
---|
[2195] | 635 | self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png'). |
---|
| 636 | self::jsVar('dotclear.img_plus_theme_alt',__('uncover')). |
---|
| 637 | self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png'). |
---|
| 638 | self::jsVar('dotclear.img_minus_theme_alt',__('hide')). |
---|
[1187] | 639 | |
---|
[0] | 640 | self::jsVar('dotclear.msg.help', |
---|
[1933] | 641 | __('Need help?')). |
---|
[2225] | 642 | self::jsVar('dotclear.msg.new_window', |
---|
| 643 | __('new window')). |
---|
[1302] | 644 | self::jsVar('dotclear.msg.help_hide', |
---|
| 645 | __('Hide')). |
---|
[1556] | 646 | self::jsVar('dotclear.msg.to_select', |
---|
| 647 | __('Select:')). |
---|
[0] | 648 | self::jsVar('dotclear.msg.no_selection', |
---|
| 649 | __('no selection')). |
---|
| 650 | self::jsVar('dotclear.msg.select_all', |
---|
| 651 | __('select all')). |
---|
| 652 | self::jsVar('dotclear.msg.invert_sel', |
---|
[1556] | 653 | __('Invert selection')). |
---|
[0] | 654 | self::jsVar('dotclear.msg.website', |
---|
| 655 | __('Web site:')). |
---|
| 656 | self::jsVar('dotclear.msg.email', |
---|
| 657 | __('Email:')). |
---|
| 658 | self::jsVar('dotclear.msg.ip_address', |
---|
| 659 | __('IP address:')). |
---|
| 660 | self::jsVar('dotclear.msg.error', |
---|
| 661 | __('Error:')). |
---|
| 662 | self::jsVar('dotclear.msg.entry_created', |
---|
| 663 | __('Entry has been successfully created.')). |
---|
| 664 | self::jsVar('dotclear.msg.edit_entry', |
---|
| 665 | __('Edit entry')). |
---|
| 666 | self::jsVar('dotclear.msg.view_entry', |
---|
| 667 | __('view entry')). |
---|
| 668 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
| 669 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
[2202] | 670 | self::jsVar('dotclear.msg.confirm_delete_medias', |
---|
| 671 | __("Are you sure you want to delete selected medias (%d)?")). |
---|
[1525] | 672 | self::jsVar('dotclear.msg.confirm_delete_categories', |
---|
| 673 | __("Are you sure you want to delete selected categories (%s)?")). |
---|
[0] | 674 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
| 675 | __("Are you sure you want to delete this entry?")). |
---|
[1395] | 676 | self::jsVar('dotclear.msg.click_to_unlock', |
---|
[1450] | 677 | __("Click here to unlock the field")). |
---|
[1049] | 678 | self::jsVar('dotclear.msg.confirm_spam_delete', |
---|
| 679 | __('Are you sure you want to delete all spams?')). |
---|
[0] | 680 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
| 681 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
| 682 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
| 683 | __('Are you sure you want to delete this comment?')). |
---|
| 684 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
| 685 | __('Users with posts cannot be deleted.')). |
---|
| 686 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
| 687 | __('Are you sure you want to delete selected users (%s)?')). |
---|
| 688 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
| 689 | __('Are you sure you want to delete category "%s"?')). |
---|
| 690 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
| 691 | __('Are you sure you want to reorder all categories?')). |
---|
| 692 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
| 693 | __('Are you sure you want to remove media "%s"?')). |
---|
[2512] | 694 | self::jsVar('dotclear.msg.confirm_delete_directory', |
---|
| 695 | __('Are you sure you want to remove directory "%s"?')). |
---|
[0] | 696 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
| 697 | __('Are you sure you want to extract archive in current directory?')). |
---|
| 698 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
| 699 | __('Are you sure you want to remove attachment "%s"?')). |
---|
| 700 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
| 701 | __('Are you sure you want to delete "%s" language?')). |
---|
| 702 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
| 703 | __('Are you sure you want to delete "%s" plugin?')). |
---|
[2487] | 704 | self::jsVar('dotclear.msg.confirm_delete_plugins', |
---|
| 705 | __('Are you sure you want to delete selected plugins?')). |
---|
[0] | 706 | self::jsVar('dotclear.msg.use_this_theme', |
---|
| 707 | __('Use this theme')). |
---|
| 708 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
| 709 | __('Remove this theme')). |
---|
| 710 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
| 711 | __('Are you sure you want to delete "%s" theme?')). |
---|
[2487] | 712 | self::jsVar('dotclear.msg.confirm_delete_themes', |
---|
| 713 | __('Are you sure you want to delete selected themes?')). |
---|
[1462] | 714 | self::jsVar('dotclear.msg.confirm_delete_backup', |
---|
| 715 | __('Are you sure you want to delete this backup?')). |
---|
[2503] | 716 | self::jsVar('dotclear.msg.confirm_revert_backup', |
---|
| 717 | __('Are you sure you want to revert to this backup?')). |
---|
[0] | 718 | self::jsVar('dotclear.msg.zip_file_content', |
---|
| 719 | __('Zip file content')). |
---|
| 720 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
| 721 | __('XHTML markup validator')). |
---|
| 722 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
| 723 | __('XHTML content is valid.')). |
---|
| 724 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
| 725 | __('There are XHTML markup errors.')). |
---|
[1861] | 726 | self::jsVar('dotclear.msg.warning_validate_no_save_content', |
---|
[1832] | 727 | __('Attention: an audit of a content not yet registered.')). |
---|
[0] | 728 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
| 729 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
[1256] | 730 | self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', |
---|
| 731 | __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). |
---|
[224] | 732 | self::jsVar('dotclear.msg.load_enhanced_uploader', |
---|
| 733 | __('Loading enhanced uploader, please wait.')). |
---|
[2156] | 734 | |
---|
| 735 | self::jsVar('dotclear.msg.module_author', |
---|
| 736 | __('Author:')). |
---|
| 737 | self::jsVar('dotclear.msg.module_details', |
---|
| 738 | __('Details')). |
---|
| 739 | self::jsVar('dotclear.msg.module_support', |
---|
[2157] | 740 | __('Support')). |
---|
[2156] | 741 | self::jsVar('dotclear.msg.module_help', |
---|
[2157] | 742 | __('Help:')). |
---|
[2156] | 743 | self::jsVar('dotclear.msg.module_section', |
---|
| 744 | __('Section:')). |
---|
| 745 | self::jsVar('dotclear.msg.module_tags', |
---|
| 746 | __('Tags:')). |
---|
[1699] | 747 | "\n//]]>\n". |
---|
[0] | 748 | "</script>\n"; |
---|
| 749 | } |
---|
[1187] | 750 | |
---|
[0] | 751 | public static function jsLoadIE7() |
---|
| 752 | { |
---|
| 753 | return |
---|
[1456] | 754 | '<!--[if lt IE 9]>'."\n". |
---|
| 755 | self::jsLoad('js/ie7/IE9.js'). |
---|
[3021] | 756 | self::cssLoad('style/iesucks.css'). |
---|
[0] | 757 | '<![endif]-->'."\n"; |
---|
| 758 | } |
---|
[1187] | 759 | |
---|
[0] | 760 | public static function jsConfirmClose() |
---|
| 761 | { |
---|
| 762 | $args = func_get_args(); |
---|
| 763 | if (count($args) > 0) { |
---|
| 764 | foreach ($args as $k => $v) { |
---|
| 765 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
| 766 | } |
---|
| 767 | $args = implode(',',$args); |
---|
| 768 | } else { |
---|
| 769 | $args = ''; |
---|
| 770 | } |
---|
[1187] | 771 | |
---|
[0] | 772 | return |
---|
| 773 | self::jsLoad('js/confirm-close.js'). |
---|
| 774 | '<script type="text/javascript">'."\n". |
---|
| 775 | "//<![CDATA[\n". |
---|
| 776 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
| 777 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
| 778 | "\n//]]>\n". |
---|
| 779 | "</script>\n"; |
---|
| 780 | } |
---|
[1187] | 781 | |
---|
[0] | 782 | public static function jsPageTabs($default=null) |
---|
| 783 | { |
---|
| 784 | if ($default) { |
---|
| 785 | $default = "'".html::escapeJS($default)."'"; |
---|
| 786 | } |
---|
[2503] | 787 | |
---|
[0] | 788 | return |
---|
| 789 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
| 790 | '<script type="text/javascript">'."\n". |
---|
| 791 | "//<![CDATA[\n". |
---|
[2010] | 792 | '$(function() {'."\n". |
---|
[2054] | 793 | '$.pageTabs('.$default.');'."\n". |
---|
[2113] | 794 | '});'. |
---|
[0] | 795 | "\n//]]>\n". |
---|
[2113] | 796 | "</script>\n". |
---|
| 797 | '<!--[if lt IE 8]>'."\n". |
---|
| 798 | self::jsLoad('js/ie7/ie7-hashchange.js'). |
---|
| 799 | '<script type="text/javascript">'."\n". |
---|
| 800 | "//<![CDATA[\n". |
---|
| 801 | '$(window).hashchange();'. |
---|
| 802 | "\n//]]>\n". |
---|
| 803 | "</script>\n". |
---|
| 804 | '<![endif]-->'."\n"; |
---|
[2010] | 805 | } |
---|
[1161] | 806 | |
---|
[2202] | 807 | public static function jsModal() |
---|
| 808 | { |
---|
| 809 | return |
---|
[3021] | 810 | self::cssLoad('style/modal/modal.css'). |
---|
[2202] | 811 | self::jsLoad('js/jquery/jquery.modal.js'). |
---|
| 812 | '<script type="text/javascript">'."\n". |
---|
| 813 | "//<![CDATA[\n". |
---|
| 814 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). |
---|
| 815 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). |
---|
| 816 | "\n//]]>\n". |
---|
| 817 | "</script>\n"; |
---|
[0] | 818 | } |
---|
[1187] | 819 | |
---|
[2202] | 820 | public static function jsColorPicker() |
---|
| 821 | { |
---|
| 822 | return |
---|
[3021] | 823 | self::cssLoad('style/farbtastic/farbtastic.css'). |
---|
[2202] | 824 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
| 825 | self::jsLoad('js/color-picker.js'); |
---|
[0] | 826 | } |
---|
[1187] | 827 | |
---|
[2202] | 828 | public static function jsDatePicker() |
---|
| 829 | { |
---|
| 830 | return |
---|
[3021] | 831 | self::cssLoad('style/date-picker.css'). |
---|
[2202] | 832 | self::jsLoad('js/date-picker.js'). |
---|
| 833 | '<script type="text/javascript">'."\n". |
---|
| 834 | "//<![CDATA[\n". |
---|
[1187] | 835 | |
---|
[2202] | 836 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
| 837 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
| 838 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
| 839 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
| 840 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
| 841 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
| 842 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
| 843 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
| 844 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
| 845 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
| 846 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
| 847 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
[1161] | 848 | |
---|
[2202] | 849 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
| 850 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
| 851 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
| 852 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
| 853 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
| 854 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
| 855 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
| 856 | |
---|
| 857 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
[2788] | 858 | "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". |
---|
[2202] | 859 | |
---|
| 860 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
| 861 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
| 862 | |
---|
| 863 | "\n//]]>\n". |
---|
| 864 | "</script>\n"; |
---|
[0] | 865 | } |
---|
[1187] | 866 | |
---|
[2720] | 867 | |
---|
[2202] | 868 | public static function jsToolBar() |
---|
| 869 | { |
---|
[2614] | 870 | # Deprecated but we keep this for plugins. |
---|
[2202] | 871 | } |
---|
| 872 | |
---|
| 873 | public static function jsUpload($params=array(),$base_url=null) |
---|
| 874 | { |
---|
| 875 | if (!$base_url) { |
---|
| 876 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
| 877 | } |
---|
| 878 | |
---|
| 879 | $params = array_merge($params,array( |
---|
| 880 | 'sess_id='.session_id(), |
---|
| 881 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
| 882 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
[0] | 883 | )); |
---|
[1187] | 884 | |
---|
[2202] | 885 | return |
---|
| 886 | '<script type="text/javascript">'."\n". |
---|
| 887 | "//<![CDATA[\n". |
---|
| 888 | "dotclear.jsUpload = {};\n". |
---|
| 889 | "dotclear.jsUpload.msg = {};\n". |
---|
| 890 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). |
---|
| 891 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). |
---|
| 892 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). |
---|
| 893 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
| 894 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). |
---|
| 895 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). |
---|
| 896 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). |
---|
| 897 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). |
---|
| 898 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). |
---|
| 899 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). |
---|
| 900 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). |
---|
| 901 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). |
---|
| 902 | self::jsVar('dotclear.jsUpload.msg.send',__('Send')). |
---|
| 903 | self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). |
---|
| 904 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). |
---|
| 905 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). |
---|
| 906 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). |
---|
| 907 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). |
---|
| 908 | self::jsVar('dotclear.jsUpload.base_url',$base_url). |
---|
| 909 | "\n//]]>\n". |
---|
| 910 | "</script>\n". |
---|
[1461] | 911 | |
---|
[3218] | 912 | self::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
[2202] | 913 | self::jsLoad('js/jsUpload/tmpl.js'). |
---|
| 914 | self::jsLoad('js/jsUpload/template-upload.js'). |
---|
| 915 | self::jsLoad('js/jsUpload/template-download.js'). |
---|
| 916 | self::jsLoad('js/jsUpload/load-image.js'). |
---|
| 917 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). |
---|
| 918 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). |
---|
| 919 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). |
---|
| 920 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). |
---|
| 921 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); |
---|
| 922 | } |
---|
[1144] | 923 | |
---|
[2202] | 924 | public static function jsToolMan() |
---|
| 925 | { |
---|
| 926 | return |
---|
[3021] | 927 | self::jsLoad('js/tool-man/core.js'). |
---|
| 928 | self::jsLoad('js/tool-man/events.js'). |
---|
| 929 | self::jsLoad('js/tool-man/css.js'). |
---|
| 930 | self::jsLoad('js/tool-man/coordinates.js'). |
---|
| 931 | self::jsLoad('js/tool-man/drag.js'). |
---|
| 932 | self::jsLoad('js/tool-man/dragsort.js'). |
---|
| 933 | self::jsLoad('js/dragsort-tablerows.js'); |
---|
[2202] | 934 | } |
---|
[1144] | 935 | |
---|
[2202] | 936 | public static function jsMetaEditor() |
---|
| 937 | { |
---|
[3021] | 938 | return self::jsLoad('js/meta-editor.js'); |
---|
[2202] | 939 | } |
---|
[2849] | 940 | |
---|
[3256] | 941 | public static function jsLoadCodeMirror($theme = '',$multi = true,$modes = array('css','htmlmixed','javascript','php','xml')) |
---|
[3251] | 942 | { |
---|
| 943 | $ret = |
---|
| 944 | self::cssLoad('js/codemirror/lib/codemirror.css'). |
---|
| 945 | self::jsLoad('js/codemirror/lib/codemirror.js'); |
---|
| 946 | if ($multi) { |
---|
| 947 | $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js'); |
---|
| 948 | } |
---|
| 949 | foreach ($modes as $mode) { |
---|
| 950 | $ret .= self::jsLoad('js/codemirror/mode/'.$mode.'/'.$mode.'.js'); |
---|
| 951 | } |
---|
| 952 | $ret .= |
---|
| 953 | self::jsLoad('js/codemirror/addon/edit/closebrackets.js'). |
---|
[3253] | 954 | self::jsLoad('js/codemirror/addon/edit/matchbrackets.js'). |
---|
| 955 | self::cssLoad('js/codemirror/addon/display/fullscreen.css'). |
---|
| 956 | self::jsLoad('js/codemirror/addon/display/fullscreen.js'); |
---|
[3251] | 957 | if ($theme != '') { |
---|
| 958 | $ret .= self::cssLoad('js/codemirror/theme/'.$theme.'.css'); |
---|
| 959 | } |
---|
| 960 | return $ret; |
---|
| 961 | } |
---|
| 962 | |
---|
[3256] | 963 | public static function jsRunCodeMirror($name,$id,$mode,$theme = '') |
---|
| 964 | { |
---|
| 965 | $ret = |
---|
| 966 | '<script type="text/javascript">'. |
---|
| 967 | '//<![CDATA['."\n". |
---|
| 968 | 'var '.$name.' = CodeMirror.fromTextArea('.$id.',{'."\n". |
---|
| 969 | ' mode: "'.$mode.'",'."\n". |
---|
| 970 | ' tabMode: "indent",'."\n". |
---|
| 971 | ' lineWrapping: "true",'."\n". |
---|
| 972 | ' lineNumbers: "true",'."\n". |
---|
| 973 | ' matchBrackets: "true",'."\n". |
---|
| 974 | ' autoCloseBrackets: "true",'."\n". |
---|
| 975 | ' extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}'; |
---|
| 976 | if ($theme) { |
---|
| 977 | $ret .= |
---|
| 978 | ','."\n". |
---|
| 979 | ' theme: "'.$theme.'"'; |
---|
| 980 | } |
---|
| 981 | $ret .= |
---|
| 982 | "\n".'});'."\n". |
---|
| 983 | '//]]>'. |
---|
| 984 | '</script>'; |
---|
| 985 | return $ret; |
---|
| 986 | } |
---|
| 987 | |
---|
[3251] | 988 | public static function getCodeMirrorThemes() |
---|
| 989 | { |
---|
| 990 | $themes = array(); |
---|
| 991 | $themes_root = dirname(__FILE__).'/../../admin'.'/js/codemirror/theme/'; |
---|
| 992 | if (is_dir($themes_root) && is_readable($themes_root)) { |
---|
| 993 | if (($d = @dir($themes_root)) !== false) { |
---|
| 994 | while (($entry = $d->read()) !== false) { |
---|
| 995 | if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root.'/'.$entry)) { |
---|
| 996 | $themes[] = substr($entry,0,-4); // remove .css extension |
---|
| 997 | } |
---|
| 998 | } |
---|
| 999 | } |
---|
| 1000 | } |
---|
| 1001 | return $themes; |
---|
| 1002 | } |
---|
| 1003 | |
---|
[3080] | 1004 | public static function getPF($file) |
---|
| 1005 | { |
---|
[2852] | 1006 | return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); |
---|
[2849] | 1007 | } |
---|
[2909] | 1008 | |
---|
[3080] | 1009 | public static function setXFrameOptions($origin = null) |
---|
| 1010 | { |
---|
[2909] | 1011 | if (self::$xframe_loaded) { |
---|
| 1012 | return; |
---|
| 1013 | } |
---|
| 1014 | if ($origin !== null) { |
---|
| 1015 | $url = parse_url($origin); |
---|
[3080] | 1016 | header(sprintf('X-Frame-Options: %s',is_array($url) ? |
---|
| 1017 | ("ALLOW-FROM ".(isset($url['scheme']) ? $url['scheme'].':' : '' ).'//'.$url['host']) : |
---|
| 1018 | 'SAMEORIGIN')); |
---|
[2909] | 1019 | } else { |
---|
| 1020 | header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ |
---|
| 1021 | } |
---|
| 1022 | self::$xframe_loaded = true; |
---|
| 1023 | } |
---|
[489] | 1024 | } |
---|