| Joomla! | PHP Cross Reference | Web Portals |
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 defined('_JEXEC') or die; 10 11 /** 12 * Utility class for the button bar. 13 * 14 * @package Joomla.Administrator 15 * @since 1.5 16 */ 17 abstract class JToolbarHelper 18 { 19 /** 20 * Title cell. 21 * For the title and toolbar to be rendered correctly, 22 * this title fucntion must be called before the starttable function and the toolbars icons 23 * this is due to the nature of how the css has been used to postion the title in respect to the toolbar. 24 * 25 * @param string $title The title. 26 * @param string $icon The space-separated names of the image. 27 * 28 * @return void 29 * 30 * @since 1.5 31 */ 32 public static function title($title, $icon = 'generic.png') 33 { 34 // Strip the extension. 35 $icons = explode(' ', $icon); 36 foreach ($icons as &$icon) 37 { 38 $icon = 'icon-48-' . preg_replace('#\.[^.]*$#', '', $icon); 39 } 40 41 $html = '<div class="pagetitle ' . htmlspecialchars(implode(' ', $icons)) . '"><h2>' . $title . '</h2></div>'; 42 43 $app = JFactory::getApplication(); 44 $app->JComponentTitle = $html; 45 } 46 47 /** 48 * Writes a spacer cell. 49 * 50 * @param string $width The width for the cell 51 * 52 * @return void 53 * 54 * @since 1.5 55 */ 56 public static function spacer($width = '') 57 { 58 $bar = JToolbar::getInstance('toolbar'); 59 60 // Add a spacer. 61 $bar->appendButton('Separator', 'spacer', $width); 62 } 63 64 /** 65 * Writes a divider between menu buttons 66 * 67 * @return void 68 * 69 * @since 1.5 70 */ 71 public static function divider() 72 { 73 $bar = JToolbar::getInstance('toolbar'); 74 75 // Add a divider. 76 $bar->appendButton('Separator', 'divider'); 77 } 78 79 /** 80 * Writes a custom option and task button for the button bar. 81 * 82 * @param string $task The task to perform (picked up by the switch($task) blocks. 83 * @param string $icon The image to display. 84 * @param string $iconOver The image to display when moused over. 85 * @param string $alt The alt text for the icon image. 86 * @param bool $listSelect True if required to check that a standard list item is checked. 87 * 88 * @return void 89 * 90 * @since 1.5 91 */ 92 public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true) 93 { 94 $bar = JToolbar::getInstance('toolbar'); 95 96 // Strip extension. 97 $icon = preg_replace('#\.[^.]*$#', '', $icon); 98 99 // Add a standard button. 100 $bar->appendButton('Standard', $icon, $alt, $task, $listSelect); 101 } 102 103 /** 104 * Writes a preview button for a given option (opens a popup window). 105 * 106 * @param string $url The name of the popup file (excluding the file extension) 107 * @param bool $updateEditors 108 * 109 * @return void 110 * 111 * @since 1.5 112 */ 113 public static function preview($url = '', $updateEditors = false) 114 { 115 $bar = JToolbar::getInstance('toolbar'); 116 117 // Add a preview button. 118 $bar->appendButton('Popup', 'preview', 'Preview', $url.'&task=preview'); 119 } 120 121 /** 122 * Writes a preview button for a given option (opens a popup window). 123 * 124 * @param string $ref The name of the popup file (excluding the file extension for an xml file). 125 * @param bool $com Use the help file in the component directory. 126 * @param string $override Use this URL instead of any other 127 * @param string $component Name of component to get Help (null for current component) 128 * 129 * @return void 130 * 131 * @since 1.5 132 */ 133 public static function help($ref, $com = false, $override = null, $component = null) 134 { 135 $bar = JToolbar::getInstance('toolbar'); 136 137 // Add a help button. 138 $bar->appendButton('Help', $ref, $com, $override, $component); 139 } 140 141 /** 142 * Writes a cancel button that will go back to the previous page without doing 143 * any other operation. 144 * 145 * @param string $alt Alternative text. 146 * @param string $href URL of the href attribute. 147 * 148 * @return void 149 * 150 * @since 1.5 151 */ 152 public static function back($alt = 'JTOOLBAR_BACK', $href = 'javascript:history.back();') 153 { 154 $bar = JToolbar::getInstance('toolbar'); 155 156 // Add a back button. 157 $bar->appendButton('Link', 'back', $alt, $href); 158 } 159 160 /** 161 * Writes a media_manager button. 162 * 163 * @param string $directory The sub-directory to upload the media to. 164 * @param string $alt An override for the alt text. 165 * 166 * @return void 167 * 168 * @since 1.5 169 */ 170 public static function media_manager($directory = '', $alt = 'JTOOLBAR_UPLOAD') 171 { 172 $bar = JToolbar::getInstance('toolbar'); 173 174 // Add an upload button. 175 $bar->appendButton('Popup', 'upload', $alt, 'index.php?option=com_media&tmpl=component&task=popupUpload&folder=' . $directory, 800, 520); 176 } 177 178 /** 179 * Writes a common 'default' button for a record. 180 * 181 * @param string $task An override for the task. 182 * @param string $alt An override for the alt text. 183 * 184 * @return void 185 * 186 * @since 1.5 187 */ 188 public static function makeDefault($task = 'default', $alt = 'JTOOLBAR_DEFAULT') 189 { 190 $bar = JToolbar::getInstance('toolbar'); 191 192 // Add a default button. 193 $bar->appendButton('Standard', 'star', $alt, $task, true); 194 } 195 196 /** 197 * Writes a common 'assign' button for a record. 198 * 199 * @param string $task An override for the task. 200 * @param string $alt An override for the alt text. 201 * 202 * @return void 203 * 204 * @since 1.5 205 */ 206 public static function assign($task = 'assign', $alt = 'JTOOLBAR_ASSIGN') 207 { 208 $bar = JToolbar::getInstance('toolbar'); 209 210 // Add an assign button. 211 $bar->appendButton('Standard', 'assign', $alt, $task, true); 212 } 213 214 /** 215 * Writes the common 'new' icon for the button bar. 216 * 217 * @param string $task An override for the task. 218 * @param string $alt An override for the alt text. 219 * @param boolean $check True if required to check that a standard list item is checked. 220 * 221 * @return void 222 * 223 * @since 1.5 224 */ 225 public static function addNew($task = 'add', $alt = 'JTOOLBAR_NEW', $check = false) 226 { 227 $bar = JToolbar::getInstance('toolbar'); 228 229 // Add a new button. 230 $bar->appendButton('Standard', 'new', $alt, $task, $check); 231 } 232 233 /** 234 * Writes a common 'publish' button. 235 * 236 * @param string $task An override for the task. 237 * @param string $alt An override for the alt text. 238 * @param boolean $check True if required to check that a standard list item is checked. 239 * 240 * @return void 241 * 242 * @since 1.5 243 */ 244 public static function publish($task = 'publish', $alt = 'JTOOLBAR_PUBLISH', $check = false) 245 { 246 $bar = JToolbar::getInstance('toolbar'); 247 248 // Add a publish button. 249 $bar->appendButton('Standard', 'publish', $alt, $task, $check); 250 } 251 252 /** 253 * Writes a common 'publish' button for a list of records. 254 * 255 * @param string $task An override for the task. 256 * @param string $alt An override for the alt text. 257 * 258 * @return void 259 * 260 * @since 1.5 261 */ 262 public static function publishList($task = 'publish', $alt = 'JTOOLBAR_PUBLISH') 263 { 264 $bar = JToolbar::getInstance('toolbar'); 265 266 // Add a publish button (list). 267 $bar->appendButton('Standard', 'publish', $alt, $task, true); 268 } 269 270 /** 271 * Writes a common 'unpublish' button. 272 * 273 * @param string $task An override for the task. 274 * @param string $alt An override for the alt text. 275 * @param boolean $check True if required to check that a standard list item is checked. 276 * 277 * @return void 278 * 279 * @since 1.5 280 */ 281 public static function unpublish($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH', $check = false) 282 { 283 $bar = JToolbar::getInstance('toolbar'); 284 285 // Add an unpublish button 286 $bar->appendButton('Standard', 'unpublish', $alt, $task, $check); 287 } 288 289 /** 290 * Writes a common 'unpublish' button for a list of records. 291 * 292 * @param string $task An override for the task. 293 * @param string $alt An override for the alt text. 294 * 295 * @return void 296 * 297 * @since 1.5 298 */ 299 public static function unpublishList($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH') 300 { 301 $bar = JToolbar::getInstance('toolbar'); 302 303 // Add an unpublish button (list). 304 $bar->appendButton('Standard', 'unpublish', $alt, $task, true); 305 } 306 307 /** 308 * Writes a common 'archive' button for a list of records. 309 * 310 * @param string $task An override for the task. 311 * @param string $alt An override for the alt text. 312 * 313 * @return void 314 * 315 * @since 1.5 316 */ 317 public static function archiveList($task = 'archive', $alt = 'JTOOLBAR_ARCHIVE') 318 { 319 $bar = JToolbar::getInstance('toolbar'); 320 321 // Add an archive button. 322 $bar->appendButton('Standard', 'archive', $alt, $task, true); 323 } 324 325 /** 326 * Writes an unarchive button for a list of records. 327 * 328 * @param string $task An override for the task. 329 * @param string $alt An override for the alt text. 330 * 331 * @return void 332 * 333 * @since 1.5 334 */ 335 public static function unarchiveList($task = 'unarchive', $alt = 'JTOOLBAR_UNARCHIVE') 336 { 337 $bar = JToolbar::getInstance('toolbar'); 338 339 // Add an unarchive button (list). 340 $bar->appendButton('Standard', 'unarchive', $alt, $task, true); 341 } 342 343 /** 344 * Writes a common 'edit' button for a list of records. 345 * 346 * @param string $task An override for the task. 347 * @param string $alt An override for the alt text. 348 * 349 * @return void 350 * 351 * @since 1.5 352 */ 353 public static function editList($task = 'edit', $alt = 'JTOOLBAR_EDIT') 354 { 355 $bar = JToolbar::getInstance('toolbar'); 356 357 // Add an edit button. 358 $bar->appendButton('Standard', 'edit', $alt, $task, true); 359 } 360 361 /** 362 * Writes a common 'edit' button for a template html. 363 * 364 * @param string $task An override for the task. 365 * @param string $alt An override for the alt text. 366 * 367 * @return void 368 * 369 * @since 1.5 370 */ 371 public static function editHtml($task = 'edit_source', $alt = 'JTOOLBAR_EDIT_HTML') 372 { 373 $bar = JToolbar::getInstance('toolbar'); 374 375 // Add an edit html button. 376 $bar->appendButton('Standard', 'edithtml', $alt, $task, true); 377 } 378 379 /** 380 * Writes a common 'edit' button for a template css. 381 * 382 * @param string $task An override for the task. 383 * @param string $alt An override for the alt text. 384 * 385 * @return void 386 * 387 * @since 1.5 388 */ 389 public static function editCss($task = 'edit_css', $alt = 'JTOOLBAR_EDIT_CSS') 390 { 391 $bar = JToolbar::getInstance('toolbar'); 392 393 // Add an edit css button (hide). 394 $bar->appendButton('Standard', 'editcss', $alt, $task, true); 395 } 396 397 /** 398 * Writes a common 'delete' button for a list of records. 399 * 400 * @param string $msg Postscript for the 'are you sure' message. 401 * @param string $task An override for the task. 402 * @param string $alt An override for the alt text. 403 * 404 * @return void 405 * 406 * @since 1.5 407 */ 408 public static function deleteList($msg = '', $task = 'remove', $alt = 'JTOOLBAR_DELETE') 409 { 410 $bar = JToolbar::getInstance('toolbar'); 411 412 // Add a delete button. 413 if ($msg) 414 { 415 $bar->appendButton('Confirm', $msg, 'delete', $alt, $task, true); 416 } 417 else 418 { 419 $bar->appendButton('Standard', 'delete', $alt, $task, true); 420 } 421 } 422 423 /** 424 * Write a trash button that will move items to Trash Manager. 425 * 426 * @param string $task An override for the task. 427 * @param string $alt An override for the alt text. 428 * @param bool $check 429 * 430 * @return void 431 * 432 * @since 1.5 433 */ 434 public static function trash($task = 'remove', $alt = 'JTOOLBAR_TRASH', $check = true) 435 { 436 $bar = JToolbar::getInstance('toolbar'); 437 438 // Add a trash button. 439 $bar->appendButton('Standard', 'trash', $alt, $task, $check, false); 440 } 441 442 /** 443 * Writes a save button for a given option. 444 * Apply operation leads to a save action only (does not leave edit mode). 445 * 446 * @param string $task An override for the task. 447 * @param string $alt An override for the alt text. 448 * 449 * @return void 450 * 451 * @since 1.5 452 */ 453 public static function apply($task = 'apply', $alt = 'JTOOLBAR_APPLY') 454 { 455 $bar = JToolbar::getInstance('toolbar'); 456 457 // Add an apply button 458 $bar->appendButton('Standard', 'apply', $alt, $task, false); 459 } 460 461 /** 462 * Writes a save button for a given option. 463 * Save operation leads to a save and then close action. 464 * 465 * @param string $task An override for the task. 466 * @param string $alt An override for the alt text. 467 * 468 * @return void 469 * 470 * @since 1.5 471 */ 472 public static function save($task = 'save', $alt = 'JTOOLBAR_SAVE') 473 { 474 $bar = JToolbar::getInstance('toolbar'); 475 476 // Add a save button. 477 $bar->appendButton('Standard', 'save', $alt, $task, false); 478 } 479 480 /** 481 * Writes a save and create new button for a given option. 482 * Save and create operation leads to a save and then add action. 483 * 484 * @param string $task An override for the task. 485 * @param string $alt An override for the alt text. 486 * 487 * @return void 488 * 489 * @since 1.6 490 */ 491 public static function save2new($task = 'save2new', $alt = 'JTOOLBAR_SAVE_AND_NEW') 492 { 493 $bar = JToolbar::getInstance('toolbar'); 494 495 // Add a save and create new button. 496 $bar->appendButton('Standard', 'save-new', $alt, $task, false); 497 } 498 499 /** 500 * Writes a save as copy button for a given option. 501 * Save as copy operation leads to a save after clearing the key, 502 * then returns user to edit mode with new key. 503 * 504 * @param string $task An override for the task. 505 * @param string $alt An override for the alt text. 506 * 507 * @return void 508 * 509 * @since 1.6 510 */ 511 public static function save2copy($task = 'save2copy', $alt = 'JTOOLBAR_SAVE_AS_COPY') 512 { 513 $bar = JToolbar::getInstance('toolbar'); 514 515 // Add a save and create new button. 516 $bar->appendButton('Standard', 'save-copy', $alt, $task, false); 517 } 518 519 /** 520 * Writes a checkin button for a given option. 521 * 522 * @param string $task An override for the task. 523 * @param string $alt An override for the alt text. 524 * @param boolean $check True if required to check that a standard list item is checked. 525 * 526 * @return void 527 * 528 * @since 1.7 529 */ 530 public static function checkin($task = 'checkin', $alt = 'JTOOLBAR_CHECKIN', $check = true) 531 { 532 $bar = JToolbar::getInstance('toolbar'); 533 534 // Add a save and create new button. 535 $bar->appendButton('Standard', 'checkin', $alt, $task, $check); 536 } 537 538 /** 539 * Writes a cancel button and invokes a cancel operation (eg a checkin). 540 * 541 * @param string $task An override for the task. 542 * @param string $alt An override for the alt text. 543 * 544 * @return void 545 * 546 * @since 1.5 547 */ 548 public static function cancel($task = 'cancel', $alt = 'JTOOLBAR_CANCEL') 549 { 550 $bar = JToolbar::getInstance('toolbar'); 551 552 // Add a cancel button. 553 $bar->appendButton('Standard', 'cancel', $alt, $task, false); 554 } 555 556 /** 557 * Writes a configuration button and invokes a cancel operation (eg a checkin). 558 * 559 * @param string $component The name of the component, eg, com_content. 560 * @param int $height The height of the popup. [UNUSED] 561 * @param int $width The width of the popup. [UNUSED] 562 * @param string $alt The name of the button. 563 * @param string $path An alternative path for the configuation xml relative to JPATH_SITE. 564 * 565 * @return void 566 * 567 * @since 1.5 568 */ 569 public static function preferences($component, $height = '550', $width = '875', $alt = 'JToolbar_Options', $path = '') 570 { 571 $component = urlencode($component); 572 $path = urlencode($path); 573 $bar = JToolBar::getInstance('toolbar'); 574 575 $uri = (string) JUri::getInstance(); 576 $return = urlencode(base64_encode($uri)); 577 578 // Add a button linking to config for component. 579 $bar->appendButton('Link', 'options', $alt, 'index.php?option=com_config&view=component&component=' . $component . '&path=' . $path . '&return=' . $return); 580 } 581 } 582 583 /** 584 * Utility class for the submenu. 585 * 586 * @package Joomla.Administrator 587 * @since 1.5 588 * @deprecated 4.0 Use JHtmlSidebar instead. 589 */ 590 abstract class JSubMenuHelper 591 { 592 /** 593 * Menu entries 594 * 595 * @var array 596 * @since 3.0 597 * @deprecated 4.0 598 */ 599 protected static $entries = array(); 600 601 /** 602 * Filters 603 * 604 * @var array 605 * @since 3.0 606 * @deprecated 4.0 607 */ 608 protected static $filters = array(); 609 610 /** 611 * Value for the action attribute of the form. 612 * 613 * @var string 614 * @since 3.0 615 * @deprecated 4.0 616 */ 617 protected static $action = ''; 618 619 /** 620 * Method to add a menu item to submenu. 621 * 622 * @param string $name Name of the menu item. 623 * @param string $link URL of the menu item. 624 * @param bool $active True if the item is active, false otherwise. 625 * 626 * @return void 627 * 628 * @since 1.5 629 * @deprecated 4.0 Use JHtmlSidebar::addEntry() instead. 630 */ 631 public static function addEntry($name, $link = '', $active = false) 632 { 633 JLog::add('JSubMenuHelper::addEntry() is deprecated. Use JHtmlSidebar::addEntry() instead.', JLog::WARNING, 'deprecated'); 634 array_push(self::$entries, array($name, $link, $active)); 635 } 636 637 /** 638 * Returns an array of all submenu entries 639 * 640 * @return array 641 * 642 * @since 3.0 643 * @deprecated 4.0 Use JHtmlSidebar::getEntries() instead. 644 */ 645 public static function getEntries() 646 { 647 JLog::add('JSubMenuHelper::getEntries() is deprecated. Use JHtmlSidebar::getEntries() instead.', JLog::WARNING, 'deprecated'); 648 return self::$entries; 649 } 650 651 /** 652 * Method to add a filter to the submenu 653 * 654 * @param string $label Label for the menu item. 655 * @param string $name name for the filter. Also used as id. 656 * @param string $options options for the select field. 657 * @param bool $noDefault Don't the label as the empty option 658 * 659 * @return void 660 * 661 * @since 3.0 662 * @deprecated 4.0 Use JHtmlSidebar::addFilter() instead. 663 */ 664 public static function addFilter($label, $name, $options, $noDefault = false) 665 { 666 JLog::add('JSubMenuHelper::addFilter() is deprecated. Use JHtmlSidebar::addFilter() instead.', JLog::WARNING, 'deprecated'); 667 array_push(self::$filters, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); 668 } 669 670 /** 671 * Returns an array of all filters 672 * 673 * @return array 674 * 675 * @since 3.0 676 * @deprecated 4.0 Use JHtmlSidebar::getFilters() instead. 677 */ 678 public static function getFilters() 679 { 680 JLog::add('JSubMenuHelper::getFilters() is deprecated. Use JHtmlSidebar::getFilters() instead.', JLog::WARNING, 'deprecated'); 681 return self::$filters; 682 } 683 684 /** 685 * Set value for the action attribute of the filter form 686 * 687 * @param string $action Value for the action attribute of the form 688 * 689 * @return void 690 * 691 * @since 3.0 692 * @deprecated 4.0 Use JHtmlSidebar::setAction() instead. 693 */ 694 public static function setAction($action) 695 { 696 JLog::add('JSubMenuHelper::setAction() is deprecated. Use JHtmlSidebar::setAction() instead.', JLog::WARNING, 'deprecated'); 697 self::$action = $action; 698 } 699 700 /** 701 * Get value for the action attribute of the filter form 702 * 703 * @return string Value for the action attribute of the form 704 * 705 * @since 3.0 706 * @deprecated 4.0 Use JHtmlSidebar::getAction() instead. 707 */ 708 public static function getAction() 709 { 710 JLog::add('JSubMenuHelper::getAction() is deprecated. Use JHtmlSidebar::getAction() instead.', JLog::WARNING, 'deprecated'); 711 return self::$action; 712 } 713 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title