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