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