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