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