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