| 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 | { | 
|---|
| 33 | return; | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | if (session_id()) { | 
|---|
| 37 | $core->session->destroy(); | 
|---|
| 38 | } | 
|---|
| 39 | http::redirect(DC_AUTH_PAGE); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | # Check super admin | 
|---|
| 43 | public static function checkSuper() | 
|---|
| 44 | { | 
|---|
| 45 | global $core; | 
|---|
| 46 |  | 
|---|
| 47 | if (!$core->auth->isSuperAdmin()) | 
|---|
| 48 | { | 
|---|
| 49 | if (session_id()) { | 
|---|
| 50 | $core->session->destroy(); | 
|---|
| 51 | } | 
|---|
| 52 | http::redirect(DC_AUTH_PAGE); | 
|---|
| 53 | } | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | # Top of admin page | 
|---|
| 57 | public static function open($title='',$head='',$breadcrumb='') | 
|---|
| 58 | { | 
|---|
| 59 | global $core; | 
|---|
| 60 |  | 
|---|
| 61 | # List of user's blogs | 
|---|
| 62 | if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20) | 
|---|
| 63 | { | 
|---|
| 64 | $blog_box = | 
|---|
| 65 | '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. | 
|---|
| 66 | html::escapeHTML($core->blog->name).'</strong>'; | 
|---|
| 67 |  | 
|---|
| 68 | if ($core->auth->getBlogCount() > 20) { | 
|---|
| 69 | $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; | 
|---|
| 70 | } | 
|---|
| 71 | $blog_box .= '</p>'; | 
|---|
| 72 | } | 
|---|
| 73 | else | 
|---|
| 74 | { | 
|---|
| 75 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); | 
|---|
| 76 | $blogs = array(); | 
|---|
| 77 | while ($rs_blogs->fetch()) { | 
|---|
| 78 | $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; | 
|---|
| 79 | } | 
|---|
| 80 | $blog_box = | 
|---|
| 81 | '<p><label for="switchblog" class="classic">'. | 
|---|
| 82 | __('Blogs:').'</label> '. | 
|---|
| 83 | $core->formNonce(). | 
|---|
| 84 | form::combo('switchblog',$blogs,$core->blog->id). | 
|---|
| 85 | '<input type="submit" value="'.__('ok').'" class="hidden-if-js" /></p>'; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; | 
|---|
| 89 |  | 
|---|
| 90 | # Display | 
|---|
| 91 | header('Content-Type: text/html; charset=UTF-8'); | 
|---|
| 92 | echo | 
|---|
| 93 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. | 
|---|
| 94 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". | 
|---|
| 95 | '<html xmlns="http://www.w3.org/1999/xhtml" '. | 
|---|
| 96 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. | 
|---|
| 97 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". | 
|---|
| 98 | "<head>\n". | 
|---|
| 99 | '  <meta http-equiv="Content-Type" content="text/html; 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">'. | 
|---|
| 140 | '<h1><a href="index.php"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n"; | 
|---|
| 141 |  | 
|---|
| 142 | echo | 
|---|
| 143 | '<form action="index.php" 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="index.php">'.__('My dashboard').'</a></li>'. | 
|---|
| 150 | '<li><a class="smallscreen'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : ''). | 
|---|
| 151 | '" href="preferences.php">'.__('My preferences').'</a></li>'. | 
|---|
| 152 | '<li><a href="index.php?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">'."\n". | 
|---|
| 164 | '<div id="content" class="clearfix">'."\n"; | 
|---|
| 165 |  | 
|---|
| 166 | # Safe mode | 
|---|
| 167 | if ($safe_mode) | 
|---|
| 168 | { | 
|---|
| 169 | echo | 
|---|
| 170 | '<div class="warning"><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'].'">'.$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="help.php" 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">'."\n". | 
|---|
| 269 |  | 
|---|
| 270 | '<form id="search-menu" action="search.php" method="get">'. | 
|---|
| 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">'. | 
|---|
| 294 | '<a href="http://dotclear.org/" title="'.$text.'">'. | 
|---|
| 295 | '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". | 
|---|
| 296 | "<!-- \n                  \n               ,;:'`'::\n". | 
|---|
| 297 | "            __||\n      _____/LLLL\_\n      \__________\"|\n". | 
|---|
| 298 | "    ~^~^~^~^~^~^~^~^~^~\n -->\n"; | 
|---|
| 299 |  | 
|---|
| 300 | if (defined('DC_DEV') && DC_DEV === true) { | 
|---|
| 301 | echo self::debugInfo(); | 
|---|
| 302 | } | 
|---|
| 303 |  | 
|---|
| 304 | echo | 
|---|
| 305 | '</body></html>'; | 
|---|
| 306 | } | 
|---|
| 307 |  | 
|---|
| 308 | public static function openPopup($title='',$head='',$breadcrumb='') | 
|---|
| 309 | { | 
|---|
| 310 | global $core; | 
|---|
| 311 |  | 
|---|
| 312 | # Display | 
|---|
| 313 | header('Content-Type: text/html; charset=UTF-8'); | 
|---|
| 314 | echo | 
|---|
| 315 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. | 
|---|
| 316 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". | 
|---|
| 317 | '<html xmlns="http://www.w3.org/1999/xhtml" '. | 
|---|
| 318 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. | 
|---|
| 319 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". | 
|---|
| 320 | '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". | 
|---|
| 321 | "<head>\n". | 
|---|
| 322 | '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". | 
|---|
| 323 | '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". | 
|---|
| 324 |  | 
|---|
| 325 | '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". | 
|---|
| 326 | '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". | 
|---|
| 327 |  | 
|---|
| 328 | self::jsLoadIE7(). | 
|---|
| 329 | '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; | 
|---|
| 330 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { | 
|---|
| 331 | echo | 
|---|
| 332 | '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; | 
|---|
| 333 | } | 
|---|
| 334 |  | 
|---|
| 335 | echo | 
|---|
| 336 | self::jsCommon(). | 
|---|
| 337 | self::jsToggles(). | 
|---|
| 338 | $head; | 
|---|
| 339 |  | 
|---|
| 340 | # --BEHAVIOR-- adminPageHTMLHead | 
|---|
| 341 | $core->callBehavior('adminPageHTMLHead'); | 
|---|
| 342 |  | 
|---|
| 343 | echo | 
|---|
| 344 | "</head>\n". | 
|---|
| 345 | '<body id="dotclear-admin" class="popup">'."\n". | 
|---|
| 346 |  | 
|---|
| 347 | '<h1>'.DC_VENDOR_NAME.'</h1>'."\n"; | 
|---|
| 348 |  | 
|---|
| 349 | echo | 
|---|
| 350 | '<div id="wrapper">'."\n". | 
|---|
| 351 | '<div id="main">'."\n". | 
|---|
| 352 | '<div id="content">'."\n"; | 
|---|
| 353 |  | 
|---|
| 354 | // display breadcrumb if given | 
|---|
| 355 | echo $breadcrumb; | 
|---|
| 356 |  | 
|---|
| 357 | if ($core->error->flag()) { | 
|---|
| 358 | echo | 
|---|
| 359 | '<div class="error"><strong>'.__('Errors:').'</strong>'. | 
|---|
| 360 | $core->error->toHTML(). | 
|---|
| 361 | '</div>'; | 
|---|
| 362 | } | 
|---|
| 363 | } | 
|---|
| 364 |  | 
|---|
| 365 | public static function closePopup() | 
|---|
| 366 | { | 
|---|
| 367 | echo | 
|---|
| 368 | "</div>\n".         // End of #content | 
|---|
| 369 | "</div>\n".         // End of #main | 
|---|
| 370 | "</div>\n".         // End of #wrapper | 
|---|
| 371 | '<div id="footer"><p> </p></div>'."\n". | 
|---|
| 372 | '</body></html>'; | 
|---|
| 373 | } | 
|---|
| 374 |  | 
|---|
| 375 | public static function breadcrumb($elements=null,$options=array()) | 
|---|
| 376 | { | 
|---|
| 377 | $with_home_link = isset($options['home_link'])?$options['home_link']:true; | 
|---|
| 378 | $hl = isset($options['hl'])?$options['hl']:true; | 
|---|
| 379 | $hl_pos = isset($options['hl_pos'])?$options['hl_pos']:-1; | 
|---|
| 380 | // First item of array elements should be blog's name, System or Plugins | 
|---|
| 381 | $res = '<h2>'.($with_home_link ? | 
|---|
| 382 | '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : | 
|---|
| 383 | '<img src="style/dashboard-alt.png" alt="" />'); | 
|---|
| 384 | $index = 0; | 
|---|
| 385 | if ($hl_pos < 0) { | 
|---|
| 386 | $hl_pos = count($elements)+$hl_pos; | 
|---|
| 387 | } | 
|---|
| 388 | foreach ($elements as $element => $url) { | 
|---|
| 389 | if ($hl && $index == $hl_pos) { | 
|---|
| 390 | $element = sprintf('<span class="page-title">%s</span>',$element); | 
|---|
| 391 | } | 
|---|
| 392 | $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')). | 
|---|
| 393 | ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); | 
|---|
| 394 | $index++; | 
|---|
| 395 | } | 
|---|
| 396 | $res .= '</h2>'; | 
|---|
| 397 | return $res; | 
|---|
| 398 | } | 
|---|
| 399 |  | 
|---|
| 400 | public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message') | 
|---|
| 401 | { | 
|---|
| 402 | global $core; | 
|---|
| 403 |  | 
|---|
| 404 | $res = ''; | 
|---|
| 405 | if ($msg != '') { | 
|---|
| 406 | $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'. | 
|---|
| 407 | ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. | 
|---|
| 408 | '</p>'.($div ? '</div>' : ''); | 
|---|
| 409 | if ($echo) { | 
|---|
| 410 | echo $res; | 
|---|
| 411 | } | 
|---|
| 412 | } | 
|---|
| 413 | return $res; | 
|---|
| 414 | } | 
|---|
| 415 |  | 
|---|
| 416 | public static function success($msg,$timestamp=true,$div=false,$echo=true) | 
|---|
| 417 | { | 
|---|
| 418 | return self::message($msg,$timestamp,$div,$echo,"success"); | 
|---|
| 419 | } | 
|---|
| 420 |  | 
|---|
| 421 | public static function warning($msg,$timestamp=true,$div=false,$echo=true) | 
|---|
| 422 | { | 
|---|
| 423 | return self::message($msg,$timestamp,$div,$echo,"warning-msg"); | 
|---|
| 424 | } | 
|---|
| 425 |  | 
|---|
| 426 | private static function debugInfo() | 
|---|
| 427 | { | 
|---|
| 428 | $global_vars = implode(', ',array_keys($GLOBALS)); | 
|---|
| 429 |  | 
|---|
| 430 | $res = | 
|---|
| 431 | '<div id="debug"><div>'. | 
|---|
| 432 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; | 
|---|
| 433 |  | 
|---|
| 434 | if (function_exists('xdebug_get_profiler_filename')) | 
|---|
| 435 | { | 
|---|
| 436 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; | 
|---|
| 437 |  | 
|---|
| 438 | $prof_file = xdebug_get_profiler_filename(); | 
|---|
| 439 | if ($prof_file) { | 
|---|
| 440 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; | 
|---|
| 441 | } else { | 
|---|
| 442 | $prof_url = http::getSelfURI(); | 
|---|
| 443 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; | 
|---|
| 444 | $prof_url .= 'XDEBUG_PROFILE'; | 
|---|
| 445 | $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; | 
|---|
| 446 | } | 
|---|
| 447 |  | 
|---|
| 448 | /* xdebug configuration: | 
|---|
| 449 | zend_extension = /.../xdebug.so | 
|---|
| 450 | xdebug.auto_trace = On | 
|---|
| 451 | xdebug.trace_format = 0 | 
|---|
| 452 | xdebug.trace_options = 1 | 
|---|
| 453 | xdebug.show_mem_delta = On | 
|---|
| 454 | xdebug.profiler_enable = 0 | 
|---|
| 455 | xdebug.profiler_enable_trigger = 1 | 
|---|
| 456 | xdebug.profiler_output_dir = /tmp | 
|---|
| 457 | xdebug.profiler_append = 0 | 
|---|
| 458 | xdebug.profiler_output_name = timestamp | 
|---|
| 459 | */ | 
|---|
| 460 | } | 
|---|
| 461 |  | 
|---|
| 462 | $res .= | 
|---|
| 463 | '<p>Global vars: '.$global_vars.'</p>'. | 
|---|
| 464 | '</div></div>'; | 
|---|
| 465 |  | 
|---|
| 466 | return $res; | 
|---|
| 467 | } | 
|---|
| 468 |  | 
|---|
| 469 | public static function help($page,$index='') | 
|---|
| 470 | { | 
|---|
| 471 | # Deprecated but we keep this for plugins. | 
|---|
| 472 | } | 
|---|
| 473 |  | 
|---|
| 474 | public static function helpBlock() | 
|---|
| 475 | { | 
|---|
| 476 | $args = func_get_args(); | 
|---|
| 477 |  | 
|---|
| 478 | $args = new ArrayObject($args); | 
|---|
| 479 |  | 
|---|
| 480 | # --BEHAVIOR-- adminPageHelpBlock | 
|---|
| 481 | $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); | 
|---|
| 482 |  | 
|---|
| 483 | if (empty($args)) { | 
|---|
| 484 | return; | 
|---|
| 485 | }; | 
|---|
| 486 |  | 
|---|
| 487 | global $__resources; | 
|---|
| 488 | if (empty($__resources['help'])) { | 
|---|
| 489 | return; | 
|---|
| 490 | } | 
|---|
| 491 |  | 
|---|
| 492 | $content = ''; | 
|---|
| 493 | foreach ($args as $v) | 
|---|
| 494 | { | 
|---|
| 495 | if (is_object($v) && isset($v->content)) { | 
|---|
| 496 | $content .= $v->content; | 
|---|
| 497 | continue; | 
|---|
| 498 | } | 
|---|
| 499 |  | 
|---|
| 500 | if (!isset($__resources['help'][$v])) { | 
|---|
| 501 | continue; | 
|---|
| 502 | } | 
|---|
| 503 | $f = $__resources['help'][$v]; | 
|---|
| 504 | if (!file_exists($f) || !is_readable($f)) { | 
|---|
| 505 | continue; | 
|---|
| 506 | } | 
|---|
| 507 |  | 
|---|
| 508 | $fc = file_get_contents($f); | 
|---|
| 509 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { | 
|---|
| 510 | $content .= $matches[1]; | 
|---|
| 511 | } else { | 
|---|
| 512 | $content .= $fc; | 
|---|
| 513 | } | 
|---|
| 514 | } | 
|---|
| 515 |  | 
|---|
| 516 | if (trim($content) == '') { | 
|---|
| 517 | return; | 
|---|
| 518 | } | 
|---|
| 519 |  | 
|---|
| 520 | // Set contextual help global flag | 
|---|
| 521 | $GLOBALS['__resources']['ctxhelp'] = true; | 
|---|
| 522 |  | 
|---|
| 523 | echo | 
|---|
| 524 | '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'. | 
|---|
| 525 | $content. | 
|---|
| 526 | '</div>'. | 
|---|
| 527 | '<div id="helplink"><hr />'. | 
|---|
| 528 | '<p>'. | 
|---|
| 529 | sprintf(__('See also %s'),sprintf('<a href="help.php">%s</a>',__('the global help'))). | 
|---|
| 530 | '.</p>'. | 
|---|
| 531 | '</div></div>'; | 
|---|
| 532 | } | 
|---|
| 533 |  | 
|---|
| 534 | public static function jsLoad($src) | 
|---|
| 535 | { | 
|---|
| 536 | $escaped_src = html::escapeHTML($src); | 
|---|
| 537 | if (!isset(self::$loaded_js[$escaped_src])) { | 
|---|
| 538 | self::$loaded_js[$escaped_src]=true; | 
|---|
| 539 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; | 
|---|
| 540 | } | 
|---|
| 541 | } | 
|---|
| 542 |  | 
|---|
| 543 | public static function jsVar($n,$v) | 
|---|
| 544 | { | 
|---|
| 545 | return $n." = '".html::escapeJS($v)."';\n"; | 
|---|
| 546 | } | 
|---|
| 547 |  | 
|---|
| 548 | public static function jsToggles() | 
|---|
| 549 | { | 
|---|
| 550 | if($GLOBALS['core']->auth->user_prefs->toggles) { | 
|---|
| 551 | $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); | 
|---|
| 552 | foreach ($unfolded_sections as $k=>&$v) { | 
|---|
| 553 | if ($v == '') { | 
|---|
| 554 | unset($unfolded_sections[$k]); | 
|---|
| 555 | } else { | 
|---|
| 556 | $v = "'".html::escapeJS($v)."':true"; | 
|---|
| 557 | } | 
|---|
| 558 | } | 
|---|
| 559 | } else { | 
|---|
| 560 | $unfolded_sections=array(); | 
|---|
| 561 | } | 
|---|
| 562 | return '<script type="text/javascript">'."\n". | 
|---|
| 563 | "//<![CDATA[\n". | 
|---|
| 564 | 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". | 
|---|
| 565 | "\n//]]>\n". | 
|---|
| 566 | "</script>\n"; | 
|---|
| 567 | } | 
|---|
| 568 |  | 
|---|
| 569 | public static function jsCommon() | 
|---|
| 570 | { | 
|---|
| 571 | $mute_or_no = ''; | 
|---|
| 572 | if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { | 
|---|
| 573 | $mute_or_no .= | 
|---|
| 574 | '<script type="text/javascript">'."\n". | 
|---|
| 575 | "//<![CDATA[\n". | 
|---|
| 576 | 'jQuery.migrateMute = true;'. | 
|---|
| 577 | "\n//]]>\n". | 
|---|
| 578 | "</script>\n"; | 
|---|
| 579 | } | 
|---|
| 580 |  | 
|---|
| 581 | return | 
|---|
| 582 | self::jsLoad('js/jquery/jquery.js'). | 
|---|
| 583 | $mute_or_no. | 
|---|
| 584 | self::jsLoad('js/jquery/jquery-migrate-1.2.1.js'). | 
|---|
| 585 | self::jsLoad('js/jquery/jquery.biscuit.js'). | 
|---|
| 586 | self::jsLoad('js/jquery/jquery.bgFade.js'). | 
|---|
| 587 | self::jsLoad('js/common.js'). | 
|---|
| 588 | self::jsLoad('js/prelude.js'). | 
|---|
| 589 |  | 
|---|
| 590 | '<script type="text/javascript">'."\n". | 
|---|
| 591 | "//<![CDATA[\n". | 
|---|
| 592 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). | 
|---|
| 593 | self::jsVar('dotclear.img_plus_src','images/expand.png'). | 
|---|
| 594 | self::jsVar('dotclear.img_plus_alt',__('uncover')). | 
|---|
| 595 | self::jsVar('dotclear.img_minus_src','images/hide.png'). | 
|---|
| 596 | self::jsVar('dotclear.img_minus_alt',__('hide')). | 
|---|
| 597 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). | 
|---|
| 598 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). | 
|---|
| 599 |  | 
|---|
| 600 | self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png'). | 
|---|
| 601 | self::jsVar('dotclear.img_plus_theme_alt',__('uncover')). | 
|---|
| 602 | self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png'). | 
|---|
| 603 | self::jsVar('dotclear.img_minus_theme_alt',__('hide')). | 
|---|
| 604 |  | 
|---|
| 605 | self::jsVar('dotclear.msg.help', | 
|---|
| 606 | __('Need help?')). | 
|---|
| 607 | self::jsVar('dotclear.msg.new_window', | 
|---|
| 608 | __('new window')). | 
|---|
| 609 | self::jsVar('dotclear.msg.help_hide', | 
|---|
| 610 | __('Hide')). | 
|---|
| 611 | self::jsVar('dotclear.msg.to_select', | 
|---|
| 612 | __('Select:')). | 
|---|
| 613 | self::jsVar('dotclear.msg.no_selection', | 
|---|
| 614 | __('no selection')). | 
|---|
| 615 | self::jsVar('dotclear.msg.select_all', | 
|---|
| 616 | __('select all')). | 
|---|
| 617 | self::jsVar('dotclear.msg.invert_sel', | 
|---|
| 618 | __('Invert selection')). | 
|---|
| 619 | self::jsVar('dotclear.msg.website', | 
|---|
| 620 | __('Web site:')). | 
|---|
| 621 | self::jsVar('dotclear.msg.email', | 
|---|
| 622 | __('Email:')). | 
|---|
| 623 | self::jsVar('dotclear.msg.ip_address', | 
|---|
| 624 | __('IP address:')). | 
|---|
| 625 | self::jsVar('dotclear.msg.error', | 
|---|
| 626 | __('Error:')). | 
|---|
| 627 | self::jsVar('dotclear.msg.entry_created', | 
|---|
| 628 | __('Entry has been successfully created.')). | 
|---|
| 629 | self::jsVar('dotclear.msg.edit_entry', | 
|---|
| 630 | __('Edit entry')). | 
|---|
| 631 | self::jsVar('dotclear.msg.view_entry', | 
|---|
| 632 | __('view entry')). | 
|---|
| 633 | self::jsVar('dotclear.msg.confirm_delete_posts', | 
|---|
| 634 | __("Are you sure you want to delete selected entries (%s)?")). | 
|---|
| 635 | self::jsVar('dotclear.msg.confirm_delete_medias', | 
|---|
| 636 | __("Are you sure you want to delete selected medias (%d)?")). | 
|---|
| 637 | self::jsVar('dotclear.msg.confirm_delete_categories', | 
|---|
| 638 | __("Are you sure you want to delete selected categories (%s)?")). | 
|---|
| 639 | self::jsVar('dotclear.msg.confirm_delete_post', | 
|---|
| 640 | __("Are you sure you want to delete this entry?")). | 
|---|
| 641 | self::jsVar('dotclear.msg.click_to_unlock', | 
|---|
| 642 | __("Click here to unlock the field")). | 
|---|
| 643 | self::jsVar('dotclear.msg.confirm_spam_delete', | 
|---|
| 644 | __('Are you sure you want to delete all spams?')). | 
|---|
| 645 | self::jsVar('dotclear.msg.confirm_delete_comments', | 
|---|
| 646 | __('Are you sure you want to delete selected comments (%s)?')). | 
|---|
| 647 | self::jsVar('dotclear.msg.confirm_delete_comment', | 
|---|
| 648 | __('Are you sure you want to delete this comment?')). | 
|---|
| 649 | self::jsVar('dotclear.msg.cannot_delete_users', | 
|---|
| 650 | __('Users with posts cannot be deleted.')). | 
|---|
| 651 | self::jsVar('dotclear.msg.confirm_delete_user', | 
|---|
| 652 | __('Are you sure you want to delete selected users (%s)?')). | 
|---|
| 653 | self::jsVar('dotclear.msg.confirm_delete_category', | 
|---|
| 654 | __('Are you sure you want to delete category "%s"?')). | 
|---|
| 655 | self::jsVar('dotclear.msg.confirm_reorder_categories', | 
|---|
| 656 | __('Are you sure you want to reorder all categories?')). | 
|---|
| 657 | self::jsVar('dotclear.msg.confirm_delete_media', | 
|---|
| 658 | __('Are you sure you want to remove media "%s"?')). | 
|---|
| 659 | self::jsVar('dotclear.msg.confirm_extract_current', | 
|---|
| 660 | __('Are you sure you want to extract archive in current directory?')). | 
|---|
| 661 | self::jsVar('dotclear.msg.confirm_remove_attachment', | 
|---|
| 662 | __('Are you sure you want to remove attachment "%s"?')). | 
|---|
| 663 | self::jsVar('dotclear.msg.confirm_delete_lang', | 
|---|
| 664 | __('Are you sure you want to delete "%s" language?')). | 
|---|
| 665 | self::jsVar('dotclear.msg.confirm_delete_plugin', | 
|---|
| 666 | __('Are you sure you want to delete "%s" plugin?')). | 
|---|
| 667 | self::jsVar('dotclear.msg.use_this_theme', | 
|---|
| 668 | __('Use this theme')). | 
|---|
| 669 | self::jsVar('dotclear.msg.remove_this_theme', | 
|---|
| 670 | __('Remove this theme')). | 
|---|
| 671 | self::jsVar('dotclear.msg.confirm_delete_theme', | 
|---|
| 672 | __('Are you sure you want to delete "%s" theme?')). | 
|---|
| 673 | self::jsVar('dotclear.msg.confirm_delete_backup', | 
|---|
| 674 | __('Are you sure you want to delete this backup?')). | 
|---|
| 675 | self::jsVar('dotclear.msg.zip_file_content', | 
|---|
| 676 | __('Zip file content')). | 
|---|
| 677 | self::jsVar('dotclear.msg.xhtml_validator', | 
|---|
| 678 | __('XHTML markup validator')). | 
|---|
| 679 | self::jsVar('dotclear.msg.xhtml_valid', | 
|---|
| 680 | __('XHTML content is valid.')). | 
|---|
| 681 | self::jsVar('dotclear.msg.xhtml_not_valid', | 
|---|
| 682 | __('There are XHTML markup errors.')). | 
|---|
| 683 | self::jsVar('dotclear.msg.warning_validate_no_save_content', | 
|---|
| 684 | __('Attention: an audit of a content not yet registered.')). | 
|---|
| 685 | self::jsVar('dotclear.msg.confirm_change_post_format', | 
|---|
| 686 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). | 
|---|
| 687 | self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', | 
|---|
| 688 | __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). | 
|---|
| 689 | self::jsVar('dotclear.msg.load_enhanced_uploader', | 
|---|
| 690 | __('Loading enhanced uploader, please wait.')). | 
|---|
| 691 |  | 
|---|
| 692 | self::jsVar('dotclear.msg.module_author', | 
|---|
| 693 | __('Author:')). | 
|---|
| 694 | self::jsVar('dotclear.msg.module_details', | 
|---|
| 695 | __('Details')). | 
|---|
| 696 | self::jsVar('dotclear.msg.module_support', | 
|---|
| 697 | __('Support')). | 
|---|
| 698 | self::jsVar('dotclear.msg.module_help', | 
|---|
| 699 | __('Help:')). | 
|---|
| 700 | self::jsVar('dotclear.msg.module_section', | 
|---|
| 701 | __('Section:')). | 
|---|
| 702 | self::jsVar('dotclear.msg.module_tags', | 
|---|
| 703 | __('Tags:')). | 
|---|
| 704 | "\n//]]>\n". | 
|---|
| 705 | "</script>\n"; | 
|---|
| 706 | } | 
|---|
| 707 |  | 
|---|
| 708 | public static function jsLoadIE7() | 
|---|
| 709 | { | 
|---|
| 710 | return | 
|---|
| 711 | '<!--[if lt IE 9]>'."\n". | 
|---|
| 712 | self::jsLoad('js/ie7/IE9.js'). | 
|---|
| 713 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". | 
|---|
| 714 | '<![endif]-->'."\n"; | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | public static function jsConfirmClose() | 
|---|
| 718 | { | 
|---|
| 719 | $args = func_get_args(); | 
|---|
| 720 | if (count($args) > 0) { | 
|---|
| 721 | foreach ($args as $k => $v) { | 
|---|
| 722 | $args[$k] = "'".html::escapeJS($v)."'"; | 
|---|
| 723 | } | 
|---|
| 724 | $args = implode(',',$args); | 
|---|
| 725 | } else { | 
|---|
| 726 | $args = ''; | 
|---|
| 727 | } | 
|---|
| 728 |  | 
|---|
| 729 | return | 
|---|
| 730 | self::jsLoad('js/confirm-close.js'). | 
|---|
| 731 | '<script type="text/javascript">'."\n". | 
|---|
| 732 | "//<![CDATA[\n". | 
|---|
| 733 | "confirmClosePage = new confirmClose(".$args."); ". | 
|---|
| 734 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". | 
|---|
| 735 | "\n//]]>\n". | 
|---|
| 736 | "</script>\n"; | 
|---|
| 737 | } | 
|---|
| 738 |  | 
|---|
| 739 | public static function jsPageTabs($default=null) | 
|---|
| 740 | { | 
|---|
| 741 | if ($default) { | 
|---|
| 742 | $default = "'".html::escapeJS($default)."'"; | 
|---|
| 743 | } | 
|---|
| 744 |  | 
|---|
| 745 | return | 
|---|
| 746 | self::jsLoad('js/jquery/jquery.pageTabs.js'). | 
|---|
| 747 | '<script type="text/javascript">'."\n". | 
|---|
| 748 | "//<![CDATA[\n". | 
|---|
| 749 | '$(function() {'."\n". | 
|---|
| 750 | '$.pageTabs('.$default.');'."\n". | 
|---|
| 751 | '});'. | 
|---|
| 752 | "\n//]]>\n". | 
|---|
| 753 | "</script>\n". | 
|---|
| 754 | '<!--[if lt IE 8]>'."\n". | 
|---|
| 755 | self::jsLoad('js/ie7/ie7-hashchange.js'). | 
|---|
| 756 | '<script type="text/javascript">'."\n". | 
|---|
| 757 | "//<![CDATA[\n". | 
|---|
| 758 | '$(window).hashchange();'. | 
|---|
| 759 | "\n//]]>\n". | 
|---|
| 760 | "</script>\n". | 
|---|
| 761 | '<![endif]-->'."\n"; | 
|---|
| 762 | } | 
|---|
| 763 |  | 
|---|
| 764 | public static function jsModal() | 
|---|
| 765 | { | 
|---|
| 766 | return | 
|---|
| 767 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". | 
|---|
| 768 | self::jsLoad('js/jquery/jquery.modal.js'). | 
|---|
| 769 | '<script type="text/javascript">'."\n". | 
|---|
| 770 | "//<![CDATA[\n". | 
|---|
| 771 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). | 
|---|
| 772 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). | 
|---|
| 773 | "\n//]]>\n". | 
|---|
| 774 | "</script>\n"; | 
|---|
| 775 | } | 
|---|
| 776 |  | 
|---|
| 777 | public static function jsColorPicker() | 
|---|
| 778 | { | 
|---|
| 779 | return | 
|---|
| 780 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". | 
|---|
| 781 | self::jsLoad('js/jquery/jquery.farbtastic.js'). | 
|---|
| 782 | self::jsLoad('js/color-picker.js'); | 
|---|
| 783 | } | 
|---|
| 784 |  | 
|---|
| 785 | public static function jsDatePicker() | 
|---|
| 786 | { | 
|---|
| 787 | return | 
|---|
| 788 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". | 
|---|
| 789 | self::jsLoad('js/date-picker.js'). | 
|---|
| 790 | '<script type="text/javascript">'."\n". | 
|---|
| 791 | "//<![CDATA[\n". | 
|---|
| 792 |  | 
|---|
| 793 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". | 
|---|
| 794 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". | 
|---|
| 795 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". | 
|---|
| 796 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". | 
|---|
| 797 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". | 
|---|
| 798 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". | 
|---|
| 799 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". | 
|---|
| 800 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". | 
|---|
| 801 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". | 
|---|
| 802 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". | 
|---|
| 803 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". | 
|---|
| 804 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". | 
|---|
| 805 |  | 
|---|
| 806 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". | 
|---|
| 807 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". | 
|---|
| 808 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". | 
|---|
| 809 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". | 
|---|
| 810 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". | 
|---|
| 811 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". | 
|---|
| 812 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". | 
|---|
| 813 |  | 
|---|
| 814 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". | 
|---|
| 815 |  | 
|---|
| 816 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". | 
|---|
| 817 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". | 
|---|
| 818 |  | 
|---|
| 819 | "\n//]]>\n". | 
|---|
| 820 | "</script>\n"; | 
|---|
| 821 | } | 
|---|
| 822 |  | 
|---|
| 823 | public static function jsToolBar() | 
|---|
| 824 | { | 
|---|
| 825 | $res = | 
|---|
| 826 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. | 
|---|
| 827 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; | 
|---|
| 828 |  | 
|---|
| 829 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { | 
|---|
| 830 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; | 
|---|
| 831 | } | 
|---|
| 832 |  | 
|---|
| 833 | $res .= | 
|---|
| 834 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. | 
|---|
| 835 | '<script type="text/javascript">'."\n". | 
|---|
| 836 | "//<![CDATA[\n". | 
|---|
| 837 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". | 
|---|
| 838 | "jsToolBar.prototype.iframe_css = '". | 
|---|
| 839 | 'body{'. | 
|---|
| 840 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. | 
|---|
| 841 | 'color : #000;'. | 
|---|
| 842 | 'background: #f9f9f9;'. | 
|---|
| 843 | 'margin: 0;'. | 
|---|
| 844 | 'padding : 2px;'. | 
|---|
| 845 | 'border: none;'. | 
|---|
| 846 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). | 
|---|
| 847 | '}'. | 
|---|
| 848 | 'pre, code, kbd, samp {'. | 
|---|
| 849 | 'font-family:"Courier New",Courier,monospace;'. | 
|---|
| 850 | 'font-size : 1.1em;'. | 
|---|
| 851 | '}'. | 
|---|
| 852 | 'code {'. | 
|---|
| 853 | 'color : #666;'. | 
|---|
| 854 | 'font-weight : bold;'. | 
|---|
| 855 | '}'. | 
|---|
| 856 | 'body > p:first-child {'. | 
|---|
| 857 | 'margin-top: 0;'. | 
|---|
| 858 | '}'. | 
|---|
| 859 | "'; ". | 
|---|
| 860 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". | 
|---|
| 861 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". | 
|---|
| 862 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". | 
|---|
| 863 | "jsToolBar.prototype.legend_msg = '". | 
|---|
| 864 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". | 
|---|
| 865 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". | 
|---|
| 866 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". | 
|---|
| 867 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". | 
|---|
| 868 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". | 
|---|
| 869 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". | 
|---|
| 870 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". | 
|---|
| 871 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". | 
|---|
| 872 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". | 
|---|
| 873 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". | 
|---|
| 874 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". | 
|---|
| 875 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". | 
|---|
| 876 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". | 
|---|
| 877 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". | 
|---|
| 878 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". | 
|---|
| 879 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". | 
|---|
| 880 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". | 
|---|
| 881 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". | 
|---|
| 882 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". | 
|---|
| 883 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". | 
|---|
| 884 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". | 
|---|
| 885 |  | 
|---|
| 886 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". | 
|---|
| 887 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". | 
|---|
| 888 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". | 
|---|
| 889 |  | 
|---|
| 890 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". | 
|---|
| 891 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". | 
|---|
| 892 |  | 
|---|
| 893 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". | 
|---|
| 894 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; | 
|---|
| 895 |  | 
|---|
| 896 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { | 
|---|
| 897 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; | 
|---|
| 898 | } | 
|---|
| 899 |  | 
|---|
| 900 | $res .= | 
|---|
| 901 | "\n//]]>\n". | 
|---|
| 902 | "</script>\n"; | 
|---|
| 903 |  | 
|---|
| 904 | return $res; | 
|---|
| 905 | } | 
|---|
| 906 |  | 
|---|
| 907 | public static function jsUpload($params=array(),$base_url=null) | 
|---|
| 908 | { | 
|---|
| 909 | if (!$base_url) { | 
|---|
| 910 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; | 
|---|
| 911 | } | 
|---|
| 912 |  | 
|---|
| 913 | $params = array_merge($params,array( | 
|---|
| 914 | 'sess_id='.session_id(), | 
|---|
| 915 | 'sess_uid='.$_SESSION['sess_browser_uid'], | 
|---|
| 916 | 'xd_check='.$GLOBALS['core']->getNonce() | 
|---|
| 917 | )); | 
|---|
| 918 |  | 
|---|
| 919 | return | 
|---|
| 920 | '<script type="text/javascript">'."\n". | 
|---|
| 921 | "//<![CDATA[\n". | 
|---|
| 922 | "dotclear.jsUpload = {};\n". | 
|---|
| 923 | "dotclear.jsUpload.msg = {};\n". | 
|---|
| 924 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). | 
|---|
| 925 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). | 
|---|
| 926 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). | 
|---|
| 927 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). | 
|---|
| 928 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). | 
|---|
| 929 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). | 
|---|
| 930 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). | 
|---|
| 931 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). | 
|---|
| 932 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). | 
|---|
| 933 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). | 
|---|
| 934 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). | 
|---|
| 935 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). | 
|---|
| 936 | self::jsVar('dotclear.jsUpload.msg.send',__('Send')). | 
|---|
| 937 | self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). | 
|---|
| 938 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). | 
|---|
| 939 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). | 
|---|
| 940 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). | 
|---|
| 941 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). | 
|---|
| 942 | self::jsVar('dotclear.jsUpload.base_url',$base_url). | 
|---|
| 943 | "\n//]]>\n". | 
|---|
| 944 | "</script>\n". | 
|---|
| 945 |  | 
|---|
| 946 | self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). | 
|---|
| 947 | self::jsLoad('js/jsUpload/tmpl.js'). | 
|---|
| 948 | self::jsLoad('js/jsUpload/template-upload.js'). | 
|---|
| 949 | self::jsLoad('js/jsUpload/template-download.js'). | 
|---|
| 950 | self::jsLoad('js/jsUpload/load-image.js'). | 
|---|
| 951 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). | 
|---|
| 952 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). | 
|---|
| 953 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). | 
|---|
| 954 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). | 
|---|
| 955 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); | 
|---|
| 956 | } | 
|---|
| 957 |  | 
|---|
| 958 | public static function jsToolMan() | 
|---|
| 959 | { | 
|---|
| 960 | return | 
|---|
| 961 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. | 
|---|
| 962 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. | 
|---|
| 963 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. | 
|---|
| 964 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. | 
|---|
| 965 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. | 
|---|
| 966 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. | 
|---|
| 967 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; | 
|---|
| 968 | } | 
|---|
| 969 |  | 
|---|
| 970 | public static function jsMetaEditor() | 
|---|
| 971 | { | 
|---|
| 972 | return | 
|---|
| 973 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; | 
|---|
| 974 | } | 
|---|
| 975 | } | 
|---|