[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 define('DC_AUTH_PAGE','auth.php'); 24 25 class dcPage 26 { 27 # Auth check 28 public static function check($permissions) 29 { 30 global $core; 31 32 if ($core->blog && $core->auth->check($permissions,$core->blog->id)) 33 { 34 return; 35 } 36 37 if (session_id()) { 38 $core->session->destroy(); 39 } 40 http::redirect(DC_AUTH_PAGE); 41 } 42 43 # Check super admin 44 public static function checkSuper() 45 { 46 global $core; 47 48 if (!$core->auth->isSuperAdmin()) 49 { 50 if (session_id()) { 51 $core->session->destroy(); 52 } 53 http::redirect(DC_AUTH_PAGE); 54 } 55 } 56 57 # Top of admin page 58 public static function open($title='', $head='') 59 { 60 global $core, $dc_blogs; 61 62 # List of user's blogs 63 $blogs = array(); 64 65 foreach ($core->blogs as $k=>$v) { 66 $blogs[html::escapeHTML($v['name']).' - '.$v['url']] = $k; 67 } 68 69 if (count($blogs) == 1 || count($blogs) > 20) 70 { 71 $blog_box = 72 __('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. 73 html::escapeHTML($core->blog->name).'</strong>'; 74 75 if (count($blogs) > 20) { 76 $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; 77 } 78 } 79 else 80 { 81 uasort($blogs,create_function('$a,$b','return !strcmp(strtolower($a),strtolower($b));')); 82 $blog_box = 83 __('Blogs:').' '. 84 form::combo('switchblog',$blogs,$core->blog->id, '',1). 85 '<noscript><div><input type="submit" value="'.__('ok').'" /></div></noscript>'; 86 } 87 88 # Display 89 header('Content-Type: text/html; charset=UTF-8'); 90 echo 91 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 92 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 93 '<html xmlns="http://www.w3.org/1999/xhtml" '. 94 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 95 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 96 "<head>\n". 97 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 98 ' <title>'.$title.' - '.$core->blog->name.' - '.DC_VENDOR_NAME.' - '.DC_VERSION.'</title>'."\n". 99 100 ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". 101 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 102 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 103 104 self::jsLoadIE7(). 105 ' <style type="text/css">'."\n". 106 ' @import "style/default.css";'."\n". 107 " </style>\n"; 108 109 # --BEHAVIOR-- adminPageHTMLHead 110 $core->callBehavior('adminPageHTMLHead'); 111 112 echo 113 self::jsCommon(). 114 $head. 115 "</head>\n". 116 '<body id="dotclear-admin">'."\n". 117 118 '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; 119 120 121 echo 122 '<div id="info-box">'. 123 '<form action="index.php" method="post"><div>'. 124 $blog_box. 125 ' - <a href="'.$core->blog->url.'">'.__('View site').'</a>'. 126 ' - '.__('User:').' <strong>'.$core->auth->userID().'</strong>'. 127 ' - <a href="index.php?logout=1">'.__('Logout').'</a>'. 128 '</div></form>'. 129 '</div>'; 130 131 echo 132 '<div id="main">'."\n". 133 '<div id="content">'."\n"; 134 135 if ($core->error->flag()) { 136 echo 137 '<div class="error"><strong>'.__('Errors:').'</strong>'. 138 $core->error->toHTML(). 139 '</div>'; 140 } 141 } 142 143 public static function close() 144 { 145 $menu =& $GLOBALS['_menu']; 146 147 echo 148 "</div>\n". // End of #content 149 "</div>\n". // End of #main 150 151 '<div id="main-menu">'."\n"; 152 153 foreach ($menu as $k => $v) { 154 echo $menu[$k]->draw(); 155 } 156 157 echo 158 '</div>'."\n". 159 '<p id="footer"><a href="http://www.dotclear.net/"><img '. 160 'src="images/dotclear_pw.png" alt="dotclear blog" /></a></p>'."\n"; 161 162 if (defined('DC_DEV') && DC_DEV === true) { 163 echo self::debugInfo(); 164 } 165 166 echo 167 '</body></html>'; 168 } 169 170 public static function openPopup($title='', $head='') 171 { 172 global $core, $dc_blogs; 173 174 # Display 175 header('Content-Type: text/html; charset=UTF-8'); 176 echo 177 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 178 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 179 '<html xmlns="http://www.w3.org/1999/xhtml" '. 180 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 181 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 182 "<head>\n". 183 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 184 ' <title>'.$title.' - '.$core->blog->name.' - '.DC_VENDOR_NAME.' - '.DC_VERSION.'</title>'."\n". 185 186 ' <meta name="MSSmartTagsPreventParsing" content="TRUE" />'."\n". 187 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 188 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 189 190 self::jsLoadIE7(). 191 ' <style type="text/css">'."\n". 192 ' @import "style/default.css";'."\n". 193 " </style>\n"; 194 195 # --BEHAVIOR-- adminPageHTMLHead 196 $core->callBehavior('adminPageHTMLHead'); 197 198 echo 199 self::jsCommon(). 200 $head. 201 "</head>\n". 202 '<body id="dotclear-admin" class="popup">'."\n". 203 204 '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; 205 206 echo 207 '<div id="main">'."\n". 208 '<div id="content">'."\n"; 209 210 if ($core->error->flag()) { 211 echo 212 '<div class="error"><strong>'.__('Errors:').'</strong>'. 213 $core->error->toHTML(). 214 '</div>'; 215 } 216 } 217 218 public static function closePopup() 219 { 220 echo 221 "</div>\n". // End of #content 222 "</div>\n". // End of #main 223 224 '<p id="footer"><a href="http://www.dotclear.net/"><img '. 225 'src="images/dotclear_pw.png" alt="dotclear blog" /></a></p>'."\n". 226 '</body></html>'; 227 } 228 229 private static function debugInfo() 230 { 231 $global_vars = implode(', ',array_keys($GLOBALS)); 232 233 $res = 234 '<div id="debug"><div>'. 235 '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; 236 237 if (function_exists('xdebug_get_profiler_filename')) 238 { 239 $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; 240 241 $prof_file = xdebug_get_profiler_filename(); 242 if ($prof_file) { 243 $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; 244 } else { 245 $prof_url = http::getSelfURI(); 246 $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; 247 $prof_url .= 'XDEBUG_PROFILE'; 248 $res .= '<p><a href="'.$prof_url.'">Trigger profiler</a></p>'; 249 } 250 251 /* xdebug configuration: 252 zend_extension = /.../xdebug.so 253 xdebug.auto_trace = On 254 xdebug.trace_format = 0 255 xdebug.trace_options = 1 256 xdebug.show_mem_delta = On 257 xdebug.profiler_enable = 0 258 xdebug.profiler_enable_trigger = 1 259 xdebug.profiler_output_dir = /tmp 260 xdebug.profiler_append = 0 261 xdebug.profiler_output_name = timestamp 262 */ 263 } 264 265 $res .= 266 '<p>Global vars: '.$global_vars.'</p>'. 267 '</div></div>'; 268 269 return $res; 270 } 271 272 public static function help($page,$index='') 273 { 274 $url = 'help.php?p='.$page.($index ? '#'.$index : ''); 275 276 return 277 ' <a href="'.$url.'" class="help-link">'. 278 '<img src="images/help.png" alt="('.__('help').')" /></a> '; 279 } 280 281 public static function jsLoad($src) 282 { 283 return '<script type="text/javascript" src="'.html::escapeHTML($src).'"></script>'."\n"; 284 } 285 286 public static function jsVar($n,$v) 287 { 288 return $n." = '".html::escapeJS($v)."';\n"; 289 } 290 291 public static function jsCommon() 292 { 293 return 294 self::jsLoad('js/jquery/jquery.js'). 295 self::jsLoad('js/jquery/jquery.cookie.js'). 296 self::jsLoad('js/jquery/jquery.bgFade.js'). 297 self::jsLoad('js/common.js'). 298 299 '<script type="text/javascript">'."\n". 300 "//<![CDATA[\n". 301 self::jsVar('dotclear.msg.select_all', 302 __('select all')). 303 self::jsVar('dotclear.msg.invert_sel', 304 __('invert selection')). 305 self::jsVar('dotclear.msg.add_another_file', 306 __('add another files')). 307 self::jsVar('dotclear.msg.website', 308 __('Web site:')). 309 self::jsVar('dotclear.msg.email', 310 __('Email:')). 311 self::jsVar('dotclear.msg.ip_address', 312 __('IP address:')). 313 self::jsVar('dotclear.msg.confirm_delete_posts', 314 __("Are you sure you want to delete selected entries?")). 315 self::jsVar('dotclear.msg.confirm_delete_post', 316 __("Are you sure you want to delete this entry?")). 317 self::jsVar('dotclear.msg.confirm_delete_comments', 318 __('Are you sure you want to delete selected comments?')). 319 self::jsVar('dotclear.msg.confirm_delete_comment', 320 __('Are you sure you want to delete this comment?')). 321 self::jsVar('dotclear.msg.confirm_delete_user', 322 __('Are you sure you want to delete selected users?')). 323 self::jsVar('dotclear.msg.confirm_delete_categories', 324 __('Are you sure you want to delete the selected categories?')). 325 self::jsVar('dotclear.msg.confirm_delete_media', 326 __('Are you sure you want to remove this item?')). 327 self::jsVar('dotclear.msg.confirm_remove_attachment', 328 __('Are you sure you want to remove this attachment?')). 329 self::jsVar('dotclear.msg.confirm_delete_plugins', 330 __('Are you sure you want to delete selected plugins?')). 331 "\n//]]>\n". 332 "</script>\n"; 333 } 334 335 public static function jsLoadIE7() 336 { 337 return 338 '<!--[if lt IE 7]>'."\n". 339 self::jsLoad('js/ie7/ie7-standard-p.js'). 340 '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". 341 '<![endif]-->'."\n"; 342 } 343 344 public static function jsConfirmClose() 345 { 346 $args = func_get_args(); 347 if (count($args) > 0) { 348 foreach ($args as $k => $v) { 349 $args[$k] = "'".html::escapeJS($v)."'"; 350 } 351 $args = implode(',',$args); 352 } else { 353 $args = ''; 354 } 355 356 return 357 self::jsLoad('js/confirm-close.js'). 358 '<script type="text/javascript">'."\n". 359 "//<![CDATA[\n". 360 "confirmClosePage = new confirmClose(".$args."); ". 361 "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". 362 "\n//]]>\n". 363 "</script>\n"; 364 } 365 366 public static function jsPageTabs($default=null) 367 { 368 if ($default) { 369 $default = "'".html::escapeJS($default)."'"; 370 } 371 372 return 373 self::jsLoad('js/jquery/jquery.pageTabs.js'). 374 '<script type="text/javascript">'."\n". 375 "//<![CDATA[\n". 376 "\$(function() {\n". 377 " \$.pageTabs(".$default.");\n". 378 "});\n". 379 "\n//]]>\n". 380 "</script>\n"; 381 } 382 383 public static function jsDatePicker() 384 { 385 return 386 '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". 387 self::jsLoad('js/date-picker.js'). 388 '<script type="text/javascript">'."\n". 389 "//<![CDATA[\n". 390 391 "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 392 "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 393 "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 394 "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 395 "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 396 "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 397 "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 398 "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 399 "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 400 "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 401 "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 402 "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 403 404 "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 405 "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 406 "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 407 "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 408 "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 409 "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 410 "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 411 412 "datePicker.prototype.img_src = 'images/date-picker.png'; ". 413 414 "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 415 "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 416 417 "\n//]]>\n". 418 "</script>\n"; 419 } 420 421 public static function jsToolBar() 422 { 423 $res = 424 '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. 425 '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; 426 427 if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { 428 $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; 429 } 430 431 $res .= 432 '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. 433 '<script type="text/javascript">'."\n". 434 "//<![CDATA[\n". 435 "jsToolBar.prototype.dialog_url = 'popup.php'; ". 436 "jsToolBar.prototype.iframe_css = '". 437 'body{'. 438 'font: x-small/1.5em Verdana,Geneva,sans-serif;'. 439 'color : #000;'. 440 'background: #f9f9f9;'. 441 'margin: 0;'. 442 'padding : 2px;'. 443 'border: none;'. 444 '}'. 445 'pre, code, kbd, samp {'. 446 'font-family:"Courier New",Courier,monospace;'. 447 'font-size : 1.1em;'. 448 '}'. 449 'code {'. 450 'color : #666;'. 451 'font-weight : bold;'. 452 '}'. 453 'body > p:first-child {'. 454 'margin-top: 0;'. 455 '}'. 456 "'; ". 457 "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". 458 "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". 459 "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". 460 "jsToolBar.prototype.legend_msg = '". 461 html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". 462 "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". 463 "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". 464 "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". 465 "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". 466 "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". 467 "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". 468 "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". 469 "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". 470 "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". 471 "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". 472 "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". 473 474 "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". 475 "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". 476 "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". 477 478 "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". 479 "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". 480 481 "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Image chooser'))."'; "; 482 483 if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { 484 $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; 485 } 486 487 $res .= 488 "\n//]]>\n". 489 "</script>\n"; 490 491 return $res; 492 } 493 494 public static function jsToolMan() 495 { 496 return 497 '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 498 '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 499 '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 500 '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 501 '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 502 '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 503 '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 504 } 505 } 506 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |