[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 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 | # Auth check |
---|
| 19 | public static function check($permissions) |
---|
| 20 | { |
---|
| 21 | global $core; |
---|
| 22 | |
---|
| 23 | if ($core->blog && $core->auth->check($permissions,$core->blog->id)) |
---|
| 24 | { |
---|
| 25 | return; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | if (session_id()) { |
---|
| 29 | $core->session->destroy(); |
---|
| 30 | } |
---|
| 31 | http::redirect(DC_AUTH_PAGE); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | # Check super admin |
---|
| 35 | public static function checkSuper() |
---|
| 36 | { |
---|
| 37 | global $core; |
---|
| 38 | |
---|
| 39 | if (!$core->auth->isSuperAdmin()) |
---|
| 40 | { |
---|
| 41 | if (session_id()) { |
---|
| 42 | $core->session->destroy(); |
---|
| 43 | } |
---|
| 44 | http::redirect(DC_AUTH_PAGE); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | # Top of admin page |
---|
| 49 | public static function open($title='', $head='') |
---|
| 50 | { |
---|
| 51 | global $core; |
---|
| 52 | |
---|
| 53 | # List of user's blogs |
---|
| 54 | if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) |
---|
| 55 | { |
---|
| 56 | $blog_box = |
---|
| 57 | __('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. |
---|
| 58 | html::escapeHTML($core->blog->name).'</strong>'; |
---|
| 59 | |
---|
| 60 | if ($core->auth->blog_count > 20) { |
---|
| 61 | $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
| 66 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); |
---|
| 67 | $blogs = array(); |
---|
| 68 | while ($rs_blogs->fetch()) { |
---|
| 69 | $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; |
---|
| 70 | } |
---|
| 71 | $blog_box = |
---|
| 72 | __('Blogs:').' '. |
---|
| 73 | $core->formNonce(). |
---|
| 74 | form::combo('switchblog',$blogs,$core->blog->id, '',1). |
---|
| 75 | '<noscript><div><input type="submit" value="'.__('ok').'" /></div></noscript>'; |
---|
| 76 | } |
---|
| 77 | |
---|
[36] | 78 | $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; |
---|
| 79 | |
---|
[0] | 80 | # Display |
---|
| 81 | header('Content-Type: text/html; charset=UTF-8'); |
---|
| 82 | echo |
---|
| 83 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
| 84 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
| 85 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
| 86 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
| 87 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
| 88 | "<head>\n". |
---|
| 89 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
| 90 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
| 91 | |
---|
| 92 | ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". |
---|
| 93 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 94 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
| 95 | |
---|
| 96 | self::jsLoadIE7(). |
---|
| 97 | ' <style type="text/css">'."\n". |
---|
| 98 | ' @import "style/default.css";'."\n". |
---|
| 99 | " </style>\n"; |
---|
| 100 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
| 101 | echo ' <style type="text/css">'."\n".' @import "style/default-rtl.css";'."\n"." </style>\n"; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | echo |
---|
| 105 | self::jsCommon(). |
---|
| 106 | $head; |
---|
| 107 | |
---|
| 108 | # --BEHAVIOR-- adminPageHTMLHead |
---|
| 109 | $core->callBehavior('adminPageHTMLHead'); |
---|
| 110 | |
---|
| 111 | echo |
---|
| 112 | "</head>\n". |
---|
[36] | 113 | '<body id="dotclear-admin'. |
---|
| 114 | ($safe_mode ? ' safe-mode' : ''). |
---|
| 115 | '">'."\n". |
---|
[0] | 116 | |
---|
| 117 | '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | echo |
---|
| 121 | '<div id="info-box">'. |
---|
| 122 | '<form action="index.php" method="post"><div>'. |
---|
| 123 | $blog_box. |
---|
[3] | 124 | '<a href="'.$core->blog->url.'"onclick="window.open(this.href);return false;" title="'.__('Go to site').' ('.__('new window').')'.'">'.__('Go to site').' <img src="images/outgoing.png" alt="" /></a>'. |
---|
| 125 | '</div></form>'. |
---|
| 126 | '</div>'. |
---|
| 127 | '<div id="info-box2"><form action="index.php" method="post><div>"'. |
---|
| 128 | ' '.__('User:').' <strong>'.$core->auth->userID().'</strong>'. |
---|
| 129 | ' - <a href="index.php?logout=1" class="logout">'.__('Logout').' <img src="images/logout.png" alt="" /></a>'. |
---|
[0] | 130 | '</div></form>'. |
---|
| 131 | '</div>'; |
---|
| 132 | |
---|
| 133 | echo |
---|
| 134 | '<div id="wrapper">'."\n". |
---|
| 135 | '<div id="main">'."\n". |
---|
| 136 | '<div id="content">'."\n"; |
---|
| 137 | |
---|
[36] | 138 | # Safe mode |
---|
| 139 | if ($safe_mode) |
---|
[0] | 140 | { |
---|
| 141 | echo |
---|
[36] | 142 | '<div class="error"><h3>'.__('Safe mode').'</h3>'. |
---|
[37] | 143 | '<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] | 144 | '</div>'; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | if ($core->error->flag()) { |
---|
| 148 | echo |
---|
| 149 | '<div class="error"><strong>'.__('Errors:').'</strong>'. |
---|
| 150 | $core->error->toHTML(). |
---|
| 151 | '</div>'; |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | public static function close() |
---|
| 156 | { |
---|
| 157 | $menu =& $GLOBALS['_menu']; |
---|
| 158 | |
---|
| 159 | echo |
---|
| 160 | "</div>\n". // End of #content |
---|
| 161 | "</div>\n". // End of #main |
---|
| 162 | |
---|
| 163 | '<div id="main-menu">'."\n"; |
---|
| 164 | |
---|
| 165 | foreach ($menu as $k => $v) { |
---|
| 166 | echo $menu[$k]->draw(); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | echo |
---|
| 170 | '</div>'."\n". // End of #main-menu |
---|
[3] | 171 | '<div id="footer"><p>'. |
---|
| 172 | sprintf(__('Thank you for using %s.'),'<a href="http://dotclear.org/">Dotclear '.DC_VERSION.'</a>'). |
---|
| 173 | ' <span class="credit"> (Icons by <a href="http://dryicons.com/">Dryicons</a>)</span>'. |
---|
[0] | 174 | '</p></div>'."\n". |
---|
| 175 | "</div>\n"; // End of #wrapper |
---|
| 176 | |
---|
| 177 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
| 178 | echo self::debugInfo(); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | echo |
---|
| 182 | '</body></html>'; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | public static function openPopup($title='', $head='') |
---|
| 186 | { |
---|
| 187 | global $core; |
---|
| 188 | |
---|
| 189 | # Display |
---|
| 190 | header('Content-Type: text/html; charset=UTF-8'); |
---|
| 191 | echo |
---|
| 192 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
| 193 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
| 194 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
| 195 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
| 196 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
| 197 | "<head>\n". |
---|
| 198 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
| 199 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
| 200 | |
---|
| 201 | ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". |
---|
| 202 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
| 203 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
| 204 | |
---|
| 205 | self::jsLoadIE7(). |
---|
| 206 | ' <style type="text/css">'."\n". |
---|
| 207 | ' @import "style/default.css";'."\n". |
---|
| 208 | " </style>\n"; |
---|
| 209 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
| 210 | echo ' <style type="text/css">'."\n".' @import "style/default-rtl.css";'."\n"." </style>\n"; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | echo |
---|
| 214 | self::jsCommon(). |
---|
| 215 | $head; |
---|
| 216 | |
---|
| 217 | # --BEHAVIOR-- adminPageHTMLHead |
---|
| 218 | $core->callBehavior('adminPageHTMLHead'); |
---|
| 219 | |
---|
| 220 | echo |
---|
| 221 | "</head>\n". |
---|
| 222 | '<body id="dotclear-admin" class="popup">'."\n". |
---|
| 223 | |
---|
| 224 | '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; |
---|
| 225 | |
---|
| 226 | echo |
---|
| 227 | '<div id="wrapper">'."\n". |
---|
| 228 | '<div id="main">'."\n". |
---|
| 229 | '<div id="content">'."\n"; |
---|
| 230 | |
---|
| 231 | if ($core->error->flag()) { |
---|
| 232 | echo |
---|
| 233 | '<div class="error"><strong>'.__('Errors:').'</strong>'. |
---|
| 234 | $core->error->toHTML(). |
---|
| 235 | '</div>'; |
---|
| 236 | } |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | public static function closePopup() |
---|
| 240 | { |
---|
| 241 | echo |
---|
| 242 | "</div>\n". // End of #content |
---|
| 243 | "</div>\n". // End of #main |
---|
| 244 | '<div id="footer"><p> </p></div>'."\n". |
---|
| 245 | "</div>\n". // End of #wrapper |
---|
| 246 | '</body></html>'; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | private static function debugInfo() |
---|
| 250 | { |
---|
| 251 | $global_vars = implode(', ',array_keys($GLOBALS)); |
---|
| 252 | |
---|
| 253 | $res = |
---|
| 254 | '<div id="debug"><div>'. |
---|
| 255 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; |
---|
| 256 | |
---|
| 257 | if (function_exists('xdebug_get_profiler_filename')) |
---|
| 258 | { |
---|
| 259 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; |
---|
| 260 | |
---|
| 261 | $prof_file = xdebug_get_profiler_filename(); |
---|
| 262 | if ($prof_file) { |
---|
| 263 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; |
---|
| 264 | } else { |
---|
| 265 | $prof_url = http::getSelfURI(); |
---|
| 266 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; |
---|
| 267 | $prof_url .= 'XDEBUG_PROFILE'; |
---|
| 268 | $res .= '<p><a href="'.$prof_url.'">Trigger profiler</a></p>'; |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | /* xdebug configuration: |
---|
| 272 | zend_extension = /.../xdebug.so |
---|
| 273 | xdebug.auto_trace = On |
---|
| 274 | xdebug.trace_format = 0 |
---|
| 275 | xdebug.trace_options = 1 |
---|
| 276 | xdebug.show_mem_delta = On |
---|
| 277 | xdebug.profiler_enable = 0 |
---|
| 278 | xdebug.profiler_enable_trigger = 1 |
---|
| 279 | xdebug.profiler_output_dir = /tmp |
---|
| 280 | xdebug.profiler_append = 0 |
---|
| 281 | xdebug.profiler_output_name = timestamp |
---|
| 282 | */ |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | $res .= |
---|
| 286 | '<p>Global vars: '.$global_vars.'</p>'. |
---|
| 287 | '</div></div>'; |
---|
| 288 | |
---|
| 289 | return $res; |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | public static function help($page,$index='') |
---|
| 293 | { |
---|
| 294 | # Deprecated but we keep this for plugins. |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | public static function helpBlock() |
---|
| 298 | { |
---|
| 299 | $args = func_get_args(); |
---|
| 300 | if (empty($args)) { |
---|
| 301 | return; |
---|
| 302 | }; |
---|
| 303 | |
---|
| 304 | global $__resources; |
---|
| 305 | if (empty($__resources['help'])) { |
---|
| 306 | return; |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | $content = ''; |
---|
| 310 | foreach ($args as $v) |
---|
| 311 | { |
---|
| 312 | if (is_object($v) && isset($v->content)) { |
---|
| 313 | $content .= $v->content; |
---|
| 314 | continue; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | if (!isset($__resources['help'][$v])) { |
---|
| 318 | continue; |
---|
| 319 | } |
---|
| 320 | $f = $__resources['help'][$v]; |
---|
| 321 | if (!file_exists($f) || !is_readable($f)) { |
---|
| 322 | continue; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | $fc = file_get_contents($f); |
---|
| 326 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
| 327 | $content .= $matches[1]; |
---|
| 328 | } else { |
---|
| 329 | $content .= $fc; |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | if (trim($content) == '') { |
---|
| 334 | return; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | echo |
---|
[3] | 338 | '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'. |
---|
[0] | 339 | $content. |
---|
| 340 | '</div></div>'; |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | public static function jsLoad($src) |
---|
| 344 | { |
---|
| 345 | return '<script type="text/javascript" src="'.html::escapeHTML($src).'"></script>'."\n"; |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | public static function jsVar($n,$v) |
---|
| 349 | { |
---|
| 350 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | public static function jsCommon() |
---|
| 354 | { |
---|
| 355 | return |
---|
| 356 | self::jsLoad('js/jquery/jquery.js'). |
---|
| 357 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
| 358 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
| 359 | self::jsLoad('js/common.js'). |
---|
| 360 | |
---|
| 361 | '<script type="text/javascript">'."\n". |
---|
| 362 | "//<![CDATA[\n". |
---|
| 363 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
| 364 | |
---|
| 365 | self::jsVar('dotclear.img_plus_src','images/plus.png'). |
---|
| 366 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
| 367 | self::jsVar('dotclear.img_minus_src','images/minus.png'). |
---|
| 368 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
| 369 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
| 370 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
| 371 | |
---|
| 372 | self::jsVar('dotclear.msg.help', |
---|
| 373 | __('help')). |
---|
| 374 | self::jsVar('dotclear.msg.no_selection', |
---|
| 375 | __('no selection')). |
---|
| 376 | self::jsVar('dotclear.msg.select_all', |
---|
| 377 | __('select all')). |
---|
| 378 | self::jsVar('dotclear.msg.invert_sel', |
---|
| 379 | __('invert selection')). |
---|
| 380 | self::jsVar('dotclear.msg.website', |
---|
| 381 | __('Web site:')). |
---|
| 382 | self::jsVar('dotclear.msg.email', |
---|
| 383 | __('Email:')). |
---|
| 384 | self::jsVar('dotclear.msg.ip_address', |
---|
| 385 | __('IP address:')). |
---|
| 386 | self::jsVar('dotclear.msg.error', |
---|
| 387 | __('Error:')). |
---|
| 388 | self::jsVar('dotclear.msg.entry_created', |
---|
| 389 | __('Entry has been successfully created.')). |
---|
| 390 | self::jsVar('dotclear.msg.edit_entry', |
---|
| 391 | __('Edit entry')). |
---|
| 392 | self::jsVar('dotclear.msg.view_entry', |
---|
| 393 | __('view entry')). |
---|
| 394 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
| 395 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
| 396 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
| 397 | __("Are you sure you want to delete this entry?")). |
---|
| 398 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
| 399 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
| 400 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
| 401 | __('Are you sure you want to delete this comment?')). |
---|
| 402 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
| 403 | __('Users with posts cannot be deleted.')). |
---|
| 404 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
| 405 | __('Are you sure you want to delete selected users (%s)?')). |
---|
| 406 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
| 407 | __('Are you sure you want to delete category "%s"?')). |
---|
| 408 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
| 409 | __('Are you sure you want to reorder all categories?')). |
---|
| 410 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
| 411 | __('Are you sure you want to remove media "%s"?')). |
---|
| 412 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
| 413 | __('Are you sure you want to extract archive in current directory?')). |
---|
| 414 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
| 415 | __('Are you sure you want to remove attachment "%s"?')). |
---|
| 416 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
| 417 | __('Are you sure you want to delete "%s" language?')). |
---|
| 418 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
| 419 | __('Are you sure you want to delete "%s" plugin?')). |
---|
| 420 | self::jsVar('dotclear.msg.use_this_theme', |
---|
| 421 | __('Use this theme')). |
---|
| 422 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
| 423 | __('Remove this theme')). |
---|
| 424 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
| 425 | __('Are you sure you want to delete "%s" theme?')). |
---|
| 426 | self::jsVar('dotclear.msg.zip_file_content', |
---|
| 427 | __('Zip file content')). |
---|
| 428 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
| 429 | __('XHTML markup validator')). |
---|
| 430 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
| 431 | __('XHTML content is valid.')). |
---|
| 432 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
| 433 | __('There are XHTML markup errors.')). |
---|
| 434 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
| 435 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
| 436 | "\n//]]>\n". |
---|
| 437 | "</script>\n"; |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | public static function jsLoadIE7() |
---|
| 441 | { |
---|
| 442 | return |
---|
| 443 | '<!--[if lt IE 8]>'."\n". |
---|
| 444 | self::jsLoad('js/ie7/IE8.js'). |
---|
| 445 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". |
---|
| 446 | '<![endif]-->'."\n"; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | public static function jsConfirmClose() |
---|
| 450 | { |
---|
| 451 | $args = func_get_args(); |
---|
| 452 | if (count($args) > 0) { |
---|
| 453 | foreach ($args as $k => $v) { |
---|
| 454 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
| 455 | } |
---|
| 456 | $args = implode(',',$args); |
---|
| 457 | } else { |
---|
| 458 | $args = ''; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | return |
---|
| 462 | self::jsLoad('js/confirm-close.js'). |
---|
| 463 | '<script type="text/javascript">'."\n". |
---|
| 464 | "//<![CDATA[\n". |
---|
| 465 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
| 466 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
| 467 | "\n//]]>\n". |
---|
| 468 | "</script>\n"; |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | public static function jsPageTabs($default=null) |
---|
| 472 | { |
---|
| 473 | if ($default) { |
---|
| 474 | $default = "'".html::escapeJS($default)."'"; |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | return |
---|
| 478 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
| 479 | '<script type="text/javascript">'."\n". |
---|
| 480 | "//<![CDATA[\n". |
---|
| 481 | "\$(function() {\n". |
---|
| 482 | " \$.pageTabs(".$default.");\n". |
---|
| 483 | "});\n". |
---|
| 484 | "\n//]]>\n". |
---|
| 485 | "</script>\n"; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | public static function jsModal() |
---|
| 489 | { |
---|
| 490 | return |
---|
| 491 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". |
---|
| 492 | self::jsLoad('js/jquery/jquery.modal.js'). |
---|
| 493 | '<script type="text/javascript">'."\n". |
---|
| 494 | "//<![CDATA[\n". |
---|
| 495 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). |
---|
| 496 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). |
---|
| 497 | "\n//]]>\n". |
---|
| 498 | "</script>\n"; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | public static function jsColorPicker() |
---|
| 502 | { |
---|
| 503 | return |
---|
| 504 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". |
---|
| 505 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
| 506 | self::jsLoad('js/color-picker.js'); |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | public static function jsDatePicker() |
---|
| 510 | { |
---|
| 511 | return |
---|
| 512 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". |
---|
| 513 | self::jsLoad('js/date-picker.js'). |
---|
| 514 | '<script type="text/javascript">'."\n". |
---|
| 515 | "//<![CDATA[\n". |
---|
| 516 | |
---|
| 517 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
| 518 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
| 519 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
| 520 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
| 521 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
| 522 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
| 523 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
| 524 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
| 525 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
| 526 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
| 527 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
| 528 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
| 529 | |
---|
| 530 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
| 531 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
| 532 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
| 533 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
| 534 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
| 535 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
| 536 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
| 537 | |
---|
| 538 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
| 539 | |
---|
| 540 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
| 541 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
| 542 | |
---|
| 543 | "\n//]]>\n". |
---|
| 544 | "</script>\n"; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | public static function jsToolBar() |
---|
| 548 | { |
---|
| 549 | $res = |
---|
| 550 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. |
---|
| 551 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; |
---|
| 552 | |
---|
| 553 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
| 554 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | $res .= |
---|
| 558 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. |
---|
| 559 | '<script type="text/javascript">'."\n". |
---|
| 560 | "//<![CDATA[\n". |
---|
| 561 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". |
---|
| 562 | "jsToolBar.prototype.iframe_css = '". |
---|
| 563 | 'body{'. |
---|
| 564 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
| 565 | 'color : #000;'. |
---|
| 566 | 'background: #f9f9f9;'. |
---|
| 567 | 'margin: 0;'. |
---|
| 568 | 'padding : 2px;'. |
---|
| 569 | 'border: none;'. |
---|
| 570 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
| 571 | '}'. |
---|
| 572 | 'pre, code, kbd, samp {'. |
---|
| 573 | 'font-family:"Courier New",Courier,monospace;'. |
---|
| 574 | 'font-size : 1.1em;'. |
---|
| 575 | '}'. |
---|
| 576 | 'code {'. |
---|
| 577 | 'color : #666;'. |
---|
| 578 | 'font-weight : bold;'. |
---|
| 579 | '}'. |
---|
| 580 | 'body > p:first-child {'. |
---|
| 581 | 'margin-top: 0;'. |
---|
| 582 | '}'. |
---|
| 583 | "'; ". |
---|
| 584 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". |
---|
| 585 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". |
---|
| 586 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". |
---|
| 587 | "jsToolBar.prototype.legend_msg = '". |
---|
| 588 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". |
---|
| 589 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". |
---|
| 590 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". |
---|
| 591 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". |
---|
| 592 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". |
---|
| 593 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". |
---|
| 594 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". |
---|
| 595 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". |
---|
| 596 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". |
---|
| 597 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". |
---|
| 598 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". |
---|
| 599 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". |
---|
| 600 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". |
---|
| 601 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". |
---|
| 602 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". |
---|
| 603 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". |
---|
| 604 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". |
---|
| 605 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". |
---|
| 606 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". |
---|
| 607 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". |
---|
| 608 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". |
---|
| 609 | |
---|
| 610 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". |
---|
| 611 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
| 612 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". |
---|
| 613 | |
---|
| 614 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". |
---|
| 615 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
| 616 | |
---|
| 617 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
| 618 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; |
---|
| 619 | |
---|
| 620 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
| 621 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | $res .= |
---|
| 625 | "\n//]]>\n". |
---|
| 626 | "</script>\n"; |
---|
| 627 | |
---|
| 628 | return $res; |
---|
| 629 | } |
---|
| 630 | |
---|
| 631 | public static function jsCandyUpload($params=array(),$base_url=null) |
---|
| 632 | { |
---|
| 633 | if (!$base_url) { |
---|
| 634 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | $params = array_merge($params,array( |
---|
| 638 | 'sess_id='.session_id(), |
---|
| 639 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
| 640 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
| 641 | )); |
---|
| 642 | |
---|
| 643 | return |
---|
| 644 | '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n". |
---|
| 645 | self::jsLoad('js/jquery/jquery.candyUpload.js'). |
---|
| 646 | |
---|
| 647 | '<script type="text/javascript">'."\n". |
---|
| 648 | "//<![CDATA[\n". |
---|
| 649 | "dotclear.candyUpload = {};\n". |
---|
| 650 | self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')). |
---|
| 651 | self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')). |
---|
| 652 | self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). |
---|
| 653 | self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). |
---|
| 654 | self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')). |
---|
| 655 | self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
| 656 | self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')). |
---|
| 657 | self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')). |
---|
| 658 | self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')). |
---|
| 659 | self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')). |
---|
| 660 | self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')). |
---|
| 661 | self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')). |
---|
| 662 | self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')). |
---|
| 663 | self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')). |
---|
| 664 | self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')). |
---|
| 665 | self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')). |
---|
| 666 | self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')). |
---|
| 667 | self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')). |
---|
| 668 | self::jsVar('dotclear.candyUpload.base_url',$base_url). |
---|
| 669 | self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf'). |
---|
| 670 | self::jsVar('dotclear.candyUpload.params',implode('&',$params)). |
---|
| 671 | "\n//]]>\n". |
---|
| 672 | "</script>\n"; |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | public static function jsToolMan() |
---|
| 676 | { |
---|
| 677 | return |
---|
| 678 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. |
---|
| 679 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. |
---|
| 680 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. |
---|
| 681 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. |
---|
| 682 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. |
---|
| 683 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. |
---|
| 684 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; |
---|
| 685 | } |
---|
| 686 | |
---|
| 687 | public static function jsMetaEditor() |
---|
| 688 | { |
---|
| 689 | return |
---|
| 690 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | ?> |
---|