[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 /* 13 * MyBB Admin CP Page Generation Class 14 */ 15 class DefaultPage 16 { 17 18 /** 19 * @var string The current style in use. 20 */ 21 public $style; 22 23 /** 24 * @var array The primary menu items. 25 */ 26 public $menu = array(); 27 28 /** 29 * @var string The side bar menu items. 30 */ 31 public $submenu = ''; 32 33 /** 34 * @var string The module we're currently in. 35 */ 36 public $active_module; 37 38 /** 39 * @var string The action we're currently performing. 40 */ 41 public $active_action; 42 43 /** 44 * @var string Content for the side bar of the page if we have one. 45 */ 46 public $sidebar; 47 48 /** 49 * @var array The breadcrumb trail leading up to this page. 50 */ 51 public $_breadcrumb_trail = array(); 52 53 /** 54 * @var string Any additional information to add between the <head> tags. 55 */ 56 public $extra_header = ""; 57 58 /** 59 * @var string Show a post verify error 60 */ 61 public $show_post_verify_error = ''; 62 63 /** 64 * Output the page header. 65 * 66 * @param string The title of the page. 67 */ 68 function output_header($title="") 69 { 70 global $mybb, $admin_session, $lang, $plugins; 71 72 $plugins->run_hooks("admin_page_output_header"); 73 74 if(!$title) 75 { 76 $title = $lang->mybb_admin_panel; 77 } 78 79 $rtl = ""; 80 if($lang->settings['rtl'] == 1) 81 { 82 $rtl = " dir=\"rtl\""; 83 } 84 85 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; 86 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"{$rtl}>\n"; 87 echo "<head profile=\"http://gmpg.org/xfn/1\">\n"; 88 echo " <title>".$title."</title>\n"; 89 echo " <meta name=\"author\" content=\"MyBB Group\" />\n"; 90 echo " <meta name=\"copyright\" content=\"Copyright ".COPY_YEAR." MyBB Group.\" />\n"; 91 echo " <link rel=\"stylesheet\" href=\"styles/".$this->style."/main.css\" type=\"text/css\" />\n"; 92 93 // Load stylesheet for this module if it has one 94 if(file_exists(MYBB_ADMIN_DIR."styles/{$this->style}/{$this->active_module}.css")) 95 { 96 echo " <link rel=\"stylesheet\" href=\"styles/{$this->style}/{$this->active_module}.css\" type=\"text/css\" />\n"; 97 } 98 99 echo " <script type=\"text/javascript\" src=\"../jscripts/prototype.js\"></script>\n"; 100 echo " <script type=\"text/javascript\" src=\"../jscripts/general.js\"></script>\n"; 101 echo " <script type=\"text/javascript\" src=\"../jscripts/popup_menu.js\"></script>\n"; 102 echo " <script type=\"text/javascript\" src=\"./jscripts/admincp.js\"></script>\n"; 103 echo " <script type=\"text/javascript\" src=\"./jscripts/tabs.js\"></script>\n"; 104 105 // Stop JS elements showing while page is loading (JS supported browsers only) 106 echo " <style type=\"text/css\">.popup_button { display: none; } </style>\n"; 107 echo " <script type=\"text/javascript\">\n". 108 "//<![CDATA[\n". 109 " document.write('<style type=\"text/css\">.popup_button { display: inline; } .popup_menu { display: none; }<\/style>');\n". 110 "//]]>\n". 111 "</script>\n"; 112 113 echo " <script type=\"text/javascript\"> 114 //<![CDATA[ 115 var loading_text = '{$lang->loading_text}'; 116 var cookieDomain = '{$mybb->settings['cookiedomain']}'; 117 var cookiePath = '{$mybb->settings['cookiepath']}'; 118 var cookiePrefix = '{$mybb->settings['cookieprefix']}'; 119 var imagepath = '../images'; 120 //]]> 121 </script>\n"; 122 echo $this->extra_header; 123 echo "</head>\n"; 124 echo "<body>\n"; 125 echo "<div id=\"container\">\n"; 126 echo " <div id=\"logo\"><h1><span class=\"invisible\">{$lang->mybb_admin_cp}</span></h1></div>\n"; 127 echo " <div id=\"welcome\"><span class=\"logged_in_as\">{$lang->logged_in_as} <a href=\"index.php?module=user-users&action=edit&uid={$mybb->user['uid']}\" class=\"username\">{$mybb->user['username']}</a></span> | <a href=\"{$mybb->settings['bburl']}\" target=\"_blank\" class=\"forum\">{$lang->view_board}</a> | <a href=\"index.php?action=logout&my_post_key={$mybb->post_code}\" class=\"logout\">{$lang->logout}</a></div>\n"; 128 echo $this->_build_menu(); 129 echo " <div id=\"page\">\n"; 130 echo " <div id=\"left_menu\">\n"; 131 echo $this->submenu; 132 echo $this->sidebar; 133 echo " </div>\n"; 134 echo " <div id=\"content\">\n"; 135 echo " <div class=\"breadcrumb\">\n"; 136 echo $this->_generate_breadcrumb(); 137 echo " </div>\n"; 138 echo " <div id=\"inner\">\n"; 139 if(isset($admin_session['data']['flash_message']) && $admin_session['data']['flash_message']) 140 { 141 $message = $admin_session['data']['flash_message']['message']; 142 $type = $admin_session['data']['flash_message']['type']; 143 echo "<div id=\"flash_message\" class=\"{$type}\">\n"; 144 echo "{$message}\n"; 145 echo "</div>\n"; 146 update_admin_session('flash_message', ''); 147 } 148 if($this->show_post_verify_error == true) 149 { 150 $this->output_error($lang->invalid_post_verify_key); 151 } 152 } 153 154 /** 155 * Output the page footer. 156 */ 157 function output_footer($quit=true) 158 { 159 global $mybb, $maintimer, $db, $lang, $plugins; 160 161 $plugins->run_hooks("admin_page_output_footer"); 162 163 $memory_usage = get_friendly_size(get_memory_usage()); 164 165 $totaltime = $maintimer->stop(); 166 $querycount = $db->query_count; 167 echo " </div>\n"; 168 echo " </div>\n"; 169 echo " <br style=\"clear: both;\" />"; 170 echo " <br style=\"clear: both;\" />"; 171 echo " </div>\n"; 172 echo "<div id=\"footer\"><p class=\"generation\">".$lang->sprintf($lang->generated_in, $totaltime, $querycount, $memory_usage)."</p><p class=\"powered\">Powered By MyBB. © ".COPY_YEAR." MyBB Group. All Rights Reserved.</p></div>\n"; 173 if($mybb->debug_mode) 174 { 175 echo $db->explain; 176 } 177 echo "</div>\n"; 178 echo "</body>\n"; 179 echo "</html>\n"; 180 181 if($quit != false) 182 { 183 exit; 184 } 185 } 186 187 /** 188 * Add an item to the page breadcrumb trail. 189 * 190 * @param string The name of the item to add. 191 * @param string The URL to the item we're adding (if there is one) 192 */ 193 function add_breadcrumb_item($name, $url="") 194 { 195 $this->_breadcrumb_trail[] = array("name" => $name, "url" => $url); 196 } 197 198 /** 199 * Generate a breadcrumb trail. 200 */ 201 function _generate_breadcrumb() 202 { 203 if(!is_array($this->_breadcrumb_trail)) 204 { 205 return false; 206 } 207 $trail = ""; 208 foreach($this->_breadcrumb_trail as $key => $crumb) 209 { 210 if(isset($this->_breadcrumb_trail[$key+1])) 211 { 212 $trail .= "<a href=\"".$crumb['url']."\">".$crumb['name']."</a>"; 213 if(isset($this->_breadcrumb_trail[$key+2])) 214 { 215 $trail .= " » "; 216 } 217 } 218 else 219 { 220 $trail .= "<span class=\"active\">".$crumb['name']."</span>"; 221 } 222 } 223 return $trail; 224 } 225 226 /** 227 * Output a success message. 228 * 229 * @param string The message to output. 230 */ 231 function output_success($message) 232 { 233 echo "<div class=\"success\">{$message}</div>\n"; 234 } 235 236 /** 237 * Output an alert/warning message. 238 * 239 * @param string The message to output. 240 * @param string The ID of the alert/warning (optional) 241 */ 242 function output_alert($message, $id="") 243 { 244 if($id) 245 { 246 $id = " id=\"{$id}\""; 247 } 248 echo "<div class=\"alert\"{$id}>{$message}</div>\n"; 249 } 250 251 /** 252 * Output an inline message. 253 * 254 * @param string The message to output. 255 */ 256 function output_inline_message($message) 257 { 258 echo "<div class=\"inline_message\">{$message}</div>\n"; 259 } 260 261 /** 262 * Output a single error message. 263 * 264 * @param string The message to output. 265 */ 266 function output_error($error) 267 { 268 echo "<div class=\"error\">\n"; 269 echo "{$error}\n"; 270 echo "</div>\n"; 271 } 272 273 /** 274 * Output one or more inline error messages. 275 * 276 * @param array Array of error messages to output. 277 */ 278 function output_inline_error($errors) 279 { 280 global $lang; 281 282 if(!is_array($errors)) 283 { 284 $errors = array($errors); 285 } 286 echo "<div class=\"error\">\n"; 287 echo "<p><em>{$lang->encountered_errors}</em></p>\n"; 288 echo "<ul>\n"; 289 foreach($errors as $error) 290 { 291 echo "<li>{$error}</li>\n"; 292 } 293 echo "</ul>\n"; 294 echo "</div>\n"; 295 } 296 297 298 /** 299 * Generate the login page. 300 * 301 * @param string The any message to output on the page if there is one. 302 * @param string The class name of the message (defaults to success) 303 */ 304 function show_login($message="", $class="success") 305 { 306 global $lang, $cp_style, $mybb; 307 308 $copy_year = COPY_YEAR; 309 310 $login_container_width = ""; 311 $login_label_width = ""; 312 313 // If the language string for "Username" is too cramped then use this to define how much larger you want the gap to be (in px) 314 if(isset($lang->login_field_width)) 315 { 316 $login_label_width = " style=\"width: ".(intval($lang->login_field_width)+100)."px;\""; 317 $login_container_width = " style=\"width: ".(410+(intval($lang->login_field_width)))."px;\""; 318 } 319 320 print <<<EOF 321 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 322 <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 323 <head profile="http://gmpg.org/xfn/1"> 324 <title>{$lang->mybb_admin_login}</title> 325 <meta name="author" content="MyBB Group" /> 326 <meta name="copyright" content="Copyright {$copy_year} MyBB Group." /> 327 <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" /> 328 <script type="text/javascript" src="../jscripts/prototype.js"></script> 329 <script type="text/javascript" src="../jscripts/general.js"></script> 330 <script type="text/javascript" src="./jscripts/admincp.js"></script> 331 <script type="text/javascript"> 332 //<![CDATA[ 333 loading_text = '{$lang->loading_text}'; 334 //]]> 335 </script> 336 </head> 337 <body> 338 <div id="container"{$login_container_width}> 339 <div id="header"> 340 <div id="logo"> 341 <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1> 342 343 </div> 344 </div> 345 <div id="content"> 346 <h2>{$lang->please_login}</h2> 347 EOF; 348 if($message) 349 { 350 echo "<p id=\"message\" class=\"{$class}\"><span class=\"text\">{$message}</span></p>"; 351 } 352 // Make query string nice and pretty so that user can go to his/her preferred destination 353 $query_string = ''; 354 if($_SERVER['QUERY_STRING']) 355 { 356 $query_string = '?'.preg_replace('#adminsid=(.{32})#i', '', $_SERVER['QUERY_STRING']); 357 $query_string = preg_replace('#my_post_key=(.{32})#i', '', $query_string); 358 $query_string = str_replace('action=logout', '', $query_string); 359 $query_string = preg_replace('#&+#', '&', $query_string); 360 $query_string = str_replace('?&', '?', $query_string); 361 $query_string = htmlspecialchars_uni($query_string); 362 } 363 switch($mybb->settings['username_method']) 364 { 365 case 0: 366 $lang_username = $lang->username; 367 break; 368 case 1: 369 $lang_username = $lang->username1; 370 break; 371 case 2: 372 $lang_username = $lang->username2; 373 break; 374 default: 375 $lang_username = $lang->username; 376 break; 377 } 378 379 // TODO: Better Fix? 380 $_SERVER['PHP_SELF'] = htmlspecialchars_uni($_SERVER['PHP_SELF']); 381 print <<<EOF 382 <p>{$lang->enter_username_and_password}</p> 383 <form method="post" action="{$_SERVER['PHP_SELF']}{$query_string}"> 384 <div class="form_container"> 385 386 <div class="label"{$login_label_width}><label for="username">{$lang_username}</label></div> 387 388 <div class="field"><input type="text" name="username" id="username" class="text_input initial_focus" /></div> 389 390 <div class="label"{$login_label_width}><label for="password">{$lang->password}</label></div> 391 <div class="field"><input type="password" name="password" id="password" class="text_input" /></div> 392 </div> 393 <p class="submit"> 394 <span class="forgot_password"> 395 <a href="../member.php?action=lostpw">{$lang->lost_password}</a> 396 </span> 397 398 <input type="submit" value="{$lang->login}" /> 399 <input type="hidden" name="do" value="login" /> 400 </p> 401 </form> 402 </div> 403 </div> 404 </body> 405 </html> 406 EOF; 407 exit; 408 } 409 410 /** 411 * Generate the lockout page 412 * 413 */ 414 function show_lockedout() 415 { 416 global $lang, $mybb, $cp_style; 417 418 $copy_year = COPY_YEAR; 419 $allowed_attempts = intval($mybb->settings['maxloginattempts']); 420 $lockedout_message = $lang->sprintf($lang->error_mybb_admin_lockedout_message, $allowed_attempts); 421 422 print <<<EOF 423 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 424 <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 425 <head profile="http://gmpg.org/xfn/1"> 426 <title>{$lang->mybb_admin_cp} - {$lang->error_mybb_admin_lockedout}</title> 427 <meta name="author" content="MyBB Group" /> 428 <meta name="copyright" content="Copyright {$copy_year} MyBB Group." /> 429 <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" /> 430 </head> 431 <body> 432 <div id="container"> 433 <div id="header"> 434 <div id="logo"> 435 <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1> 436 437 </div> 438 </div> 439 <div id="content"> 440 <h2>{$lang->error_mybb_admin_lockedout}</h2> 441 <div class="alert">{$lockedout_message}</div> 442 </div> 443 </div> 444 </body> 445 </html> 446 EOF; 447 exit; 448 } 449 450 /** 451 * Generate the lockout unlock page 452 * 453 * @param string The any message to output on the page if there is one. 454 * @param string The class name of the message (defaults to success) 455 */ 456 function show_lockout_unlock($message="", $class="success") 457 { 458 global $lang, $mybb, $cp_style; 459 460 $copy_year = COPY_YEAR; 461 switch($mybb->settings['username_method']) 462 { 463 case 0: 464 $lang_username = $lang->username; 465 break; 466 case 1: 467 $lang_username = $lang->username1; 468 break; 469 case 2: 470 $lang_username = $lang->username2; 471 break; 472 default: 473 $lang_username = $lang->username; 474 break; 475 } 476 477 if($message) 478 { 479 $message = "<p id=\"message\" class=\"{$class}\"><span class=\"text\">{$message}</span></p>"; 480 } 481 482 print <<<EOF 483 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 484 <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 485 <head profile="http://gmpg.org/xfn/1"> 486 <title>{$lang->mybb_admin_cp} - {$lang->lockout_unlock}</title> 487 <meta name="author" content="MyBB Group" /> 488 <meta name="copyright" content="Copyright {$copy_year} MyBB Group." /> 489 <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" /> 490 </head> 491 <body> 492 <div id="container"> 493 <div id="header"> 494 <div id="logo"> 495 <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1> 496 497 </div> 498 </div> 499 <div id="content"> 500 <h2>{$lang->lockout_unlock}</h2> 501 {$message} 502 <p>{$lang->enter_username_and_token}</p> 503 <form method="post" action="index.php"> 504 <div class="form_container"> 505 506 <div class="label"{$login_label_width}><label for="username">{$lang_username}</label></div> 507 508 <div class="field"><input type="text" name="username" id="username" class="text_input initial_focus" /></div> 509 510 <div class="label"{$login_label_width}><label for="token">{$lang->unlock_token}</label></div> 511 <div class="field"><input type="text" name="token" id="token" class="text_input" /></div> 512 </div> 513 <p class="submit"> 514 <span class="forgot_password"> 515 <a href="../member.php?action=lostpw">{$lang->lost_password}</a> 516 </span> 517 518 <input type="submit" value="{$lang->unlock_account}" /> 519 <input type="hidden" name="action" value="unlock" /> 520 </p> 521 </form> 522 </div> 523 </div> 524 </body> 525 </html> 526 EOF; 527 exit; 528 } 529 530 /** 531 * Add an item to the primary navigation menu. 532 * 533 * @param string The title of the menu item. 534 * @param string The ID of the menu item. This should correspond with the module the menu will run. 535 * @param string The link to follow when the menu item is clicked. 536 * @param int The display order of the menu item. Lower display order means closer to start of the menu. 537 * @param array Array of sub menu items if there are any. 538 */ 539 function add_menu_item($title, $id, $link, $order=10, $submenu=array()) 540 { 541 $this->_menu[$order][] = array( 542 "title" => $title, 543 "id" => $id, 544 "link" => $link, 545 "submenu" => $submenu 546 ); 547 } 548 549 /** 550 * Build the actual navigation menu. 551 */ 552 function _build_menu() 553 { 554 if(!is_array($this->_menu)) 555 { 556 return false; 557 } 558 $build_menu = "<div id=\"menu\">\n<ul>\n"; 559 ksort($this->_menu); 560 foreach($this->_menu as $items) 561 { 562 foreach($items as $menu_item) 563 { 564 $menu_item['link'] = htmlspecialchars_uni($menu_item['link']); 565 if($menu_item['id'] == $this->active_module) 566 { 567 $sub_menu = $menu_item['submenu']; 568 $sub_menu_title = $menu_item['title']; 569 $build_menu .= "<li><a href=\"{$menu_item['link']}\" class=\"active\">{$menu_item['title']}</a></li>\n"; 570 571 } 572 else 573 { 574 $build_menu .= "<li><a href=\"{$menu_item['link']}\">{$menu_item['title']}</a></li>\n"; 575 } 576 } 577 } 578 $build_menu .= "</ul>\n</div>"; 579 580 if($sub_menu) 581 { 582 $this->_build_submenu($sub_menu_title, $sub_menu); 583 } 584 return $build_menu; 585 } 586 587 588 /** 589 * Build a navigation sub menu if we have one. 590 * 591 * @param string A title for the sub menu. 592 * @param array Array of items for the sub menu. 593 */ 594 function _build_submenu($title, $items) 595 { 596 if(is_array($items)) 597 { 598 $sidebar = new sideBarItem($title); 599 $sidebar->add_menu_items($items, $this->active_action); 600 $this->submenu .= $sidebar->get_markup(); 601 } 602 } 603 604 /** 605 * Switch between two different alternating background colours. 606 */ 607 function get_alt_bg() 608 { 609 static $alt_bg; 610 if($alt_bg == "alt1") 611 { 612 $alt_bg = "alt2"; 613 return "alt1"; 614 } 615 else 616 { 617 $alt_bg = "alt1"; 618 return $alt_bg; 619 } 620 } 621 622 /** 623 * Output a Javascript based tab control on to the page. 624 * 625 * @param array Array of tabs in name => title format. Name should correspond to the name of a DIV containing the tab content. 626 * @param boolean Whether or not to run the event onload or instantly 627 * @param string The ID to use for the tabs for if you run multiple instances of the tabbing control in one html page 628 */ 629 function output_tab_control($tabs=array(), $observe_onload=true, $id="tabs") 630 { 631 global $plugins; 632 $tabs = $plugins->run_hooks("admin_page_output_tab_control_start", $tabs); 633 echo "<script type=\"text/javascript\">\n"; 634 if($observe_onload) 635 { 636 echo "Event.observe(window,'load',function(){\n"; 637 } 638 echo " \$\$('#{$id}').each(function(tabs)\n"; 639 echo " {\n"; 640 echo " new Control.Tabs(tabs);\n"; 641 echo " });\n"; 642 if($observe_onload) 643 { 644 echo "});\n"; 645 } 646 echo "</script>\n"; 647 echo "<ul class=\"tabs\" id=\"{$id}\">\n"; 648 $tab_count = count($tabs); 649 $done = 1; 650 foreach($tabs as $anchor => $title) 651 { 652 $class = ""; 653 if($tab_count == $done) 654 { 655 $class .= " last"; 656 } 657 if($done == 1) 658 { 659 $class .= " first"; 660 } 661 ++$done; 662 echo "<li class=\"{$class}\"><a href=\"#tab_{$anchor}\">{$title}</a></li>\n"; 663 } 664 echo "</ul>\n"; 665 $plugins->run_hooks("admin_page_output_tab_control_end", $tabs); 666 } 667 668 /** 669 * Output a series of primary navigation tabs for swithcing between items within a particular module/action. 670 * 671 * @param array Nested array of tabs containing possible keys of align, link_target, link, title. 672 * @param string The name of the active tab. Corresponds with the key of each tab item. 673 */ 674 function output_nav_tabs($tabs=array(), $active='') 675 { 676 global $plugins; 677 $tabs = $plugins->run_hooks("admin_page_output_nav_tabs_start", $tabs); 678 echo "<div class=\"nav_tabs\">"; 679 echo "\t<ul>\n"; 680 foreach($tabs as $id => $tab) 681 { 682 $class = ''; 683 if($id == $active) 684 { 685 $class = ' active'; 686 } 687 if(isset($tab['align']) == "right") 688 { 689 $class .= " right"; 690 } 691 $target = ''; 692 if(isset($tab['link_target'])) 693 { 694 $target = " target=\"{$tab['link_target']}\""; 695 } 696 if(!isset($tab['link'])) 697 { 698 $tab['link'] = ''; 699 } 700 echo "\t\t<li class=\"{$class}\"><a href=\"{$tab['link']}\"{$target}>{$tab['title']}</a></li>\n"; 701 $target = ''; 702 } 703 echo "\t</ul>\n"; 704 if($tabs[$active]['description']) 705 { 706 echo "\t<div class=\"tab_description\">{$tabs[$active]['description']}</div>\n"; 707 } 708 echo "</div>"; 709 $arguments = array('tabs' => $tabs, 'active' => $active); 710 $plugins->run_hooks("admin_page_output_nav_tabs_end", $arguments); 711 } 712 713 /** 714 * Output a page asking if a user wishes to continue performing a specific action. 715 * 716 * @param string The URL to be forwarded to. 717 * @param string The confirmation message to output. 718 * @param string The title to use in the output header 719 */ 720 function output_confirm_action($url, $message="", $title="") 721 { 722 global $lang; 723 724 if(!$message) 725 { 726 $message = $lang->confirm_action; 727 } 728 $this->output_header($title); 729 $form = new Form($url, 'post'); 730 echo "<div class=\"confirm_action\">\n"; 731 echo "<p>{$message}</p>\n"; 732 echo "<br />\n"; 733 echo "<p class=\"buttons\">\n"; 734 echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes')); 735 echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no')); 736 echo "</p>\n"; 737 echo "</div>\n"; 738 $form->end(); 739 $this->output_footer(); 740 } 741 742 /** 743 * Build a clickable MyCode editor for the Admin CP. 744 * 745 * @param string The ID of the textarea to bind the editor to. 746 * @param string The language string for the editor. 747 * @return string The build MyCode editor Javascript. 748 */ 749 function build_codebuttons_editor($bind, $editor_language) 750 { 751 global $lang; 752 if($bind == "signature") 753 { 754 $tabs_js = "Control.Tabs.observe('afterChange', function(instance, new_tab) { if(new_tab.id == \"tab_signature\") { initEditor() }});"; 755 } 756 return "<script type=\"text/javascript\" src=\"../jscripts/editor.js\"></script>\n". 757 "<script type=\"text/javascript\">\n". 758 "//<![CDATA[\n". 759 " {$editor_language}". 760 " {$tabs_js}". 761 " var clickableEditor = ''; function initEditor() { if(!clickableEditor) { clickableEditor = new messageEditor(\"{$bind}\", {lang: editor_language, rtl: {$lang->settings['rtl']}})}; };\n". 762 "//]]>". 763 "</script>"; 764 } 765 } 766 767 /** 768 * A class for generating side bar blocks. 769 */ 770 class DefaultSidebarItem 771 { 772 /** 773 * @var The title of the side bar block. 774 */ 775 private $_title; 776 777 /** 778 * @var string The contents of the side bar block. 779 */ 780 private $_contents; 781 782 /** 783 * Constructor. Set the title of the side bar block. 784 * 785 * @param string The title of the side bar block. 786 */ 787 function __construct($title="") 788 { 789 $this->_title = $title; 790 } 791 792 /** 793 * Add menus item to the side bar block. 794 * 795 * @param array Array of menu items to add. Each menu item should be a nested array of id, link and title. 796 * @param string The ID of the active menu item if there is one. 797 */ 798 function add_menu_items($items, $active) 799 { 800 global $run_module; 801 802 $this->_contents = "<ul class=\"menu\">"; 803 foreach($items as $item) 804 { 805 if(!check_admin_permissions(array("module" => $run_module, "action" => $item['id']), false)) 806 { 807 continue; 808 } 809 810 $class = ""; 811 if($item['id'] == $active) 812 { 813 $class = "active"; 814 } 815 $item['link'] = htmlspecialchars_uni($item['link']); 816 $this->_contents .= "<li class=\"{$class}\"><a href=\"{$item['link']}\">{$item['title']}</a></li>\n"; 817 } 818 $this->_contents .= "</ul>"; 819 } 820 821 /** 822 * Sets custom html to the contents variable 823 * 824 * @param string The custom html to set 825 */ 826 function set_contents($html) 827 { 828 $this->_contents = $html; 829 } 830 831 /** 832 * Fetch the HTML markup for the side bar box. 833 */ 834 function get_markup() 835 { 836 $markup = "<div class=\"left_menu_box\">\n"; 837 $markup .= "<div class=\"title\">{$this->_title}</div>\n"; 838 if($this->_contents) 839 { 840 $markup .= $this->_contents; 841 } 842 $markup .= "</div>\n"; 843 return $markup; 844 } 845 } 846 847 /** 848 * Generate a Javascript based popup menu. 849 */ 850 class DefaultPopupMenu 851 { 852 /** 853 * @var string The title of the popup menu to be shown on the button. 854 */ 855 private $_title; 856 857 /** 858 * @var string The ID of this popup menu. Must be unique. 859 */ 860 private $_id; 861 862 /** 863 * @var string Built HTML for the items in the popup menu. 864 */ 865 private $_items; 866 867 /** 868 * Initialise a new popup menu. 869 * 870 * @var string The ID of the popup menu. 871 * @var string The title of the popup menu. 872 */ 873 function __construct($id, $title='') 874 { 875 $this->_id = $id; 876 $this->_title = $title; 877 } 878 879 /** 880 * Add an item to the popup menu. 881 * 882 * @param string The title of this item. 883 * @param string The page this item should link to. 884 * @param string The onclick event handler if we have one. 885 */ 886 function add_item($text, $link, $onclick='') 887 { 888 if($onclick) 889 { 890 $onclick = " onclick=\"{$onclick}\""; 891 } 892 $this->_items .= "<div class=\"popup_item_container\"><a href=\"{$link}\"{$onclick} class=\"popup_item\">{$text}</a></div>\n"; 893 } 894 895 /** 896 * Fetch the contents of the popup menu. 897 * 898 * @return string The popup menu. 899 */ 900 function fetch() 901 { 902 $popup = "<div class=\"popup_menu\" id=\"{$this->_id}_popup\">\n{$this->_items}</div>\n"; 903 if($this->_title) 904 { 905 $popup .= "<a href=\"javascript:;\" id=\"{$this->_id}\" class=\"popup_button\">{$this->_title}</a>\n"; 906 } 907 $popup .= "<script type=\"text/javascript\">\n"; 908 $popup .= "new PopupMenu('{$this->_id}');\n"; 909 $popup .= "</script>\n"; 910 return $popup; 911 } 912 913 /** 914 * Outputs a popup menu to the browser. 915 */ 916 function output() 917 { 918 echo $this->fetch(); 919 } 920 } 921 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |