[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Toolbar/ -> ToolbarHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Toolbar;
  11  
  12  use Joomla\CMS\Factory;
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Layout\FileLayout;
  15  use Joomla\CMS\Table\Table;
  16  use Joomla\CMS\Uri\Uri;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Utility class for the button bar.
  24   *
  25   * @since  1.5
  26   */
  27  abstract class ToolbarHelper
  28  {
  29      /**
  30       * Title cell.
  31       * For the title and toolbar to be rendered correctly,
  32       * this title function must be called before the starttable function and the toolbars icons
  33       * this is due to the nature of how the css has been used to position the title in respect to the toolbar.
  34       *
  35       * @param   string  $title  The title.
  36       * @param   string  $icon   The space-separated names of the image.
  37       *
  38       * @return  void
  39       *
  40       * @since   1.5
  41       */
  42      public static function title($title, $icon = 'generic.png')
  43      {
  44          $layout = new FileLayout('joomla.toolbar.title');
  45          $html   = $layout->render(array('title' => $title, 'icon' => $icon));
  46  
  47          $app = Factory::getApplication();
  48          $app->JComponentTitle = $html;
  49          $title = strip_tags($title) . ' - ' . $app->get('sitename');
  50  
  51          if ($app->isClient('administrator')) {
  52              $title .= ' - ' . Text::_('JADMINISTRATION');
  53          }
  54  
  55          Factory::getDocument()->setTitle($title);
  56      }
  57  
  58      /**
  59       * Writes a spacer cell.
  60       *
  61       * @param   string  $width  The width for the cell
  62       *
  63       * @return  void
  64       *
  65       * @since   1.5
  66       */
  67      public static function spacer($width = '')
  68      {
  69          $bar = Toolbar::getInstance('toolbar');
  70  
  71          // Add a spacer.
  72          $bar->appendButton('Separator', 'spacer', $width);
  73      }
  74  
  75      /**
  76       * Writes a divider between menu buttons
  77       *
  78       * @return  void
  79       *
  80       * @since   1.5
  81       */
  82      public static function divider()
  83      {
  84          $bar = Toolbar::getInstance('toolbar');
  85  
  86          // Add a divider.
  87          $bar->appendButton('Separator', 'divider');
  88      }
  89  
  90      /**
  91       * Writes a custom option and task button for the button bar.
  92       *
  93       * @param   string  $task        The task to perform (picked up by the switch($task) blocks).
  94       * @param   string  $icon        The image to display.
  95       * @param   string  $iconOver    @deprecated 5.0
  96       * @param   string  $alt         The alt text for the icon image.
  97       * @param   bool    $listSelect  True if required to check that a standard list item is checked.
  98       * @param   string  $formId      The id of action form.
  99       *
 100       * @return  void
 101       *
 102       * @since   1.5
 103       */
 104      public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $formId = null)
 105      {
 106          $bar = Toolbar::getInstance('toolbar');
 107  
 108          // Strip extension.
 109          $icon = preg_replace('#\.[^.]*$#', '', $icon);
 110  
 111          // Add a standard button.
 112          $bar->appendButton('Standard', $icon, $alt, $task, $listSelect, $formId);
 113      }
 114  
 115      /**
 116       * Writes a preview button for a given option (opens a popup window).
 117       *
 118       * @param   string   $url            The name of the popup file (excluding the file extension)
 119       * @param   bool     $updateEditors  Unused
 120       * @param   string   $icon           The image to display.
 121       * @param   integer  $bodyHeight     The body height of the preview popup
 122       * @param   integer  $modalWidth     The modal width of the preview popup
 123       *
 124       * @return  void
 125       *
 126       * @since   1.5
 127       */
 128      public static function preview($url = '', $updateEditors = false, $icon = 'preview', $bodyHeight = null, $modalWidth = null)
 129      {
 130          $bar = Toolbar::getInstance('toolbar');
 131  
 132          // Add a preview button.
 133          $bar->appendButton('Popup', $icon, 'Preview', $url . '&task=preview', 640, 480, $bodyHeight, $modalWidth);
 134      }
 135  
 136      /**
 137       * Writes a jooa11y accessibility checker button for a given option (opens a popup window).
 138       *
 139       * @param   string   $url            The url to open
 140       * @param   bool     $updateEditors  Unused
 141       * @param   string   $icon           The image to display.
 142       * @param   integer  $bodyHeight     The body height of the preview popup
 143       * @param   integer  $modalWidth     The modal width of the preview popup
 144       *
 145       * @return  void
 146       *
 147       * @since   4.1.0
 148       */
 149      public static function jooa11y($url = '', $updateEditors = false, $icon = 'icon-universal-access', $bodyHeight = null, $modalWidth = null)
 150      {
 151          $bar = Toolbar::getInstance('toolbar');
 152  
 153          // Add a button.
 154          $bar->appendButton('Popup', $icon, 'Preview', $url . '&task=preview', 640, 480, $bodyHeight, $modalWidth);
 155      }
 156  
 157      /**
 158       * Writes a help button for a given option (opens a popup window).
 159       *
 160       * @param   string  $ref        The name of the popup file (excluding the file extension for an xml file).
 161       * @param   bool    $com        Use the help file in the component directory.
 162       * @param   string  $override   Use this URL instead of any other
 163       * @param   string  $component  Name of component to get Help (null for current component)
 164       *
 165       * @return  void
 166       *
 167       * @since   1.5
 168       */
 169      public static function help($ref, $com = false, $override = null, $component = null)
 170      {
 171          // Don't show a help button if neither $ref nor $override is given
 172          if (!$ref && !$override) {
 173              return;
 174          }
 175  
 176          $bar = Toolbar::getInstance('toolbar');
 177  
 178          // Add a help button.
 179          $bar->appendButton('Help', $ref, $com, $override, $component);
 180      }
 181  
 182      /**
 183       * Writes a help button for showing/hiding the inline help of a form
 184       *
 185       * @param   string  $class   The class used by the inline help items.
 186       *
 187       * @return  void
 188       *
 189       * @since   4.1.0
 190       */
 191      public static function inlinehelp(string $class = "hide-aware-inline-help")
 192      {
 193          $bar = Toolbar::getInstance('toolbar');
 194  
 195          // Add a help button.
 196          $bar->inlinehelpButton('inlinehelp')
 197              ->targetclass($class)
 198              ->icon('fa fa-question-circle');
 199      }
 200  
 201      /**
 202       * Writes a cancel button that will go back to the previous page without doing
 203       * any other operation.
 204       *
 205       * @param   string  $alt   Alternative text.
 206       * @param   string  $href  URL of the href attribute.
 207       *
 208       * @return  void
 209       *
 210       * @since   1.5
 211       */
 212      public static function back($alt = 'JTOOLBAR_BACK', $href = 'javascript:history.back();')
 213      {
 214          $bar = Toolbar::getInstance('toolbar');
 215  
 216          // Add a back button.
 217          $arrow  = Factory::getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left';
 218          $bar->appendButton('Link', $arrow, $alt, $href);
 219      }
 220  
 221      /**
 222       * Creates a button to redirect to a link
 223       *
 224       * @param   string  $url   The link url
 225       * @param   string  $text  Button text
 226       * @param   string  $name  Name to be used as apart of the id
 227       *
 228       * @return  void
 229       *
 230       * @since   3.5
 231       */
 232      public static function link($url, $text, $name = 'link')
 233      {
 234          $bar = Toolbar::getInstance('toolbar');
 235  
 236          $bar->appendButton('Link', $name, $text, $url);
 237      }
 238  
 239      /**
 240       * Writes a media_manager button.
 241       *
 242       * @param   string  $directory  The subdirectory to upload the media to.
 243       * @param   string  $alt        An override for the alt text.
 244       *
 245       * @return  void
 246       *
 247       * @since   1.5
 248       */
 249      public static function media_manager($directory = '', $alt = 'JTOOLBAR_UPLOAD')
 250      {
 251          $bar = Toolbar::getInstance('toolbar');
 252  
 253          // Add an upload button.
 254          $bar->appendButton('Popup', 'upload', $alt, 'index.php?option=com_media&tmpl=component&task=popupUpload&folder=' . $directory, 800, 520);
 255      }
 256  
 257      /**
 258       * Writes a common 'default' button for a record.
 259       *
 260       * @param   string  $task  An override for the task.
 261       * @param   string  $alt   An override for the alt text.
 262       *
 263       * @return  void
 264       *
 265       * @since   1.5
 266       */
 267      public static function makeDefault($task = 'default', $alt = 'JTOOLBAR_DEFAULT')
 268      {
 269          $bar = Toolbar::getInstance('toolbar');
 270  
 271          // Add a default button.
 272          $bar->appendButton('Standard', 'default', $alt, $task, true);
 273      }
 274  
 275      /**
 276       * Writes a common 'assign' button for a record.
 277       *
 278       * @param   string  $task  An override for the task.
 279       * @param   string  $alt   An override for the alt text.
 280       *
 281       * @return  void
 282       *
 283       * @since   1.5
 284       */
 285      public static function assign($task = 'assign', $alt = 'JTOOLBAR_ASSIGN')
 286      {
 287          $bar = Toolbar::getInstance('toolbar');
 288  
 289          // Add an assign button.
 290          $bar->appendButton('Standard', 'assign', $alt, $task, true);
 291      }
 292  
 293      /**
 294       * Writes the common 'new' icon for the button bar.
 295       *
 296       * @param   string   $task   An override for the task.
 297       * @param   string   $alt    An override for the alt text.
 298       * @param   boolean  $check  True if required to check that a standard list item is checked.
 299       *
 300       * @return  void
 301       *
 302       * @since   1.5
 303       */
 304      public static function addNew($task = 'add', $alt = 'JTOOLBAR_NEW', $check = false)
 305      {
 306          $bar = Toolbar::getInstance('toolbar');
 307  
 308          // Add a new button.
 309          $bar->appendButton('Standard', 'new', $alt, $task, $check);
 310      }
 311  
 312      /**
 313       * Writes a common 'publish' button.
 314       *
 315       * @param   string   $task   An override for the task.
 316       * @param   string   $alt    An override for the alt text.
 317       * @param   boolean  $check  True if required to check that a standard list item is checked.
 318       *
 319       * @return  void
 320       *
 321       * @since   1.5
 322       */
 323      public static function publish($task = 'publish', $alt = 'JTOOLBAR_PUBLISH', $check = false)
 324      {
 325          $bar = Toolbar::getInstance('toolbar');
 326  
 327          // Add a publish button.
 328          $bar->appendButton('Standard', 'publish', $alt, $task, $check);
 329      }
 330  
 331      /**
 332       * Writes a common 'publish' button for a list of records.
 333       *
 334       * @param   string  $task  An override for the task.
 335       * @param   string  $alt   An override for the alt text.
 336       *
 337       * @return  void
 338       *
 339       * @since   1.5
 340       */
 341      public static function publishList($task = 'publish', $alt = 'JTOOLBAR_PUBLISH')
 342      {
 343          $bar = Toolbar::getInstance('toolbar');
 344  
 345          // Add a publish button (list).
 346          $bar->appendButton('Standard', 'publish', $alt, $task, true);
 347      }
 348  
 349      /**
 350       * Writes a common 'unpublish' button.
 351       *
 352       * @param   string   $task   An override for the task.
 353       * @param   string   $alt    An override for the alt text.
 354       * @param   boolean  $check  True if required to check that a standard list item is checked.
 355       *
 356       * @return  void
 357       *
 358       * @since   1.5
 359       */
 360      public static function unpublish($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH', $check = false)
 361      {
 362          $bar = Toolbar::getInstance('toolbar');
 363  
 364          // Add an unpublish button
 365          $bar->appendButton('Standard', 'unpublish', $alt, $task, $check);
 366      }
 367  
 368      /**
 369       * Writes a common 'unpublish' button for a list of records.
 370       *
 371       * @param   string  $task  An override for the task.
 372       * @param   string  $alt   An override for the alt text.
 373       *
 374       * @return  void
 375       *
 376       * @since   1.5
 377       */
 378      public static function unpublishList($task = 'unpublish', $alt = 'JTOOLBAR_UNPUBLISH')
 379      {
 380          $bar = Toolbar::getInstance('toolbar');
 381  
 382          // Add an unpublish button (list).
 383          $bar->appendButton('Standard', 'unpublish', $alt, $task, true);
 384      }
 385  
 386      /**
 387       * Writes a common 'archive' button for a list of records.
 388       *
 389       * @param   string  $task  An override for the task.
 390       * @param   string  $alt   An override for the alt text.
 391       *
 392       * @return  void
 393       *
 394       * @since   1.5
 395       */
 396      public static function archiveList($task = 'archive', $alt = 'JTOOLBAR_ARCHIVE')
 397      {
 398          $bar = Toolbar::getInstance('toolbar');
 399  
 400          // Add an archive button.
 401          $bar->appendButton('Standard', 'archive', $alt, $task, true);
 402      }
 403  
 404      /**
 405       * Writes an unarchive button for a list of records.
 406       *
 407       * @param   string  $task  An override for the task.
 408       * @param   string  $alt   An override for the alt text.
 409       *
 410       * @return  void
 411       *
 412       * @since   1.5
 413       */
 414      public static function unarchiveList($task = 'unarchive', $alt = 'JTOOLBAR_UNARCHIVE')
 415      {
 416          $bar = Toolbar::getInstance('toolbar');
 417  
 418          // Add an unarchive button (list).
 419          $bar->appendButton('Standard', 'unarchive', $alt, $task, true);
 420      }
 421  
 422      /**
 423       * Writes a common 'edit' button for a list of records.
 424       *
 425       * @param   string  $task  An override for the task.
 426       * @param   string  $alt   An override for the alt text.
 427       *
 428       * @return  void
 429       *
 430       * @since   1.5
 431       */
 432      public static function editList($task = 'edit', $alt = 'JTOOLBAR_EDIT')
 433      {
 434          $bar = Toolbar::getInstance('toolbar');
 435  
 436          // Add an edit button.
 437          $bar->appendButton('Standard', 'edit', $alt, $task, true);
 438      }
 439  
 440      /**
 441       * Writes a common 'edit' button for a template html.
 442       *
 443       * @param   string  $task  An override for the task.
 444       * @param   string  $alt   An override for the alt text.
 445       *
 446       * @return  void
 447       *
 448       * @since   1.5
 449       */
 450      public static function editHtml($task = 'edit_source', $alt = 'JTOOLBAR_EDIT_HTML')
 451      {
 452          $bar = Toolbar::getInstance('toolbar');
 453  
 454          // Add an edit html button.
 455          $bar->appendButton('Standard', 'edithtml', $alt, $task, true);
 456      }
 457  
 458      /**
 459       * Writes a common 'edit' button for a template css.
 460       *
 461       * @param   string  $task  An override for the task.
 462       * @param   string  $alt   An override for the alt text.
 463       *
 464       * @return  void
 465       *
 466       * @since   1.5
 467       */
 468      public static function editCss($task = 'edit_css', $alt = 'JTOOLBAR_EDIT_CSS')
 469      {
 470          $bar = Toolbar::getInstance('toolbar');
 471  
 472          // Add an edit css button (hide).
 473          $bar->appendButton('Standard', 'editcss', $alt, $task, true);
 474      }
 475  
 476      /**
 477       * Writes a common 'delete' button for a list of records.
 478       *
 479       * @param   string  $msg   Postscript for the 'are you sure' message.
 480       * @param   string  $task  An override for the task.
 481       * @param   string  $alt   An override for the alt text.
 482       *
 483       * @return  void
 484       *
 485       * @since   1.5
 486       */
 487      public static function deleteList($msg = '', $task = 'remove', $alt = 'JTOOLBAR_DELETE')
 488      {
 489          $bar = Toolbar::getInstance('toolbar');
 490  
 491          // Add a delete button.
 492          if ($msg) {
 493              $bar->appendButton('Confirm', $msg, 'delete', $alt, $task, true);
 494          } else {
 495              $bar->appendButton('Standard', 'delete', $alt, $task, true);
 496          }
 497      }
 498  
 499      /**
 500       * Writes a common 'trash' button for a list of records.
 501       *
 502       * @param   string  $task   An override for the task.
 503       * @param   string  $alt    An override for the alt text.
 504       * @param   bool    $check  True to allow lists.
 505       *
 506       * @return  void
 507       *
 508       * @since   1.5
 509       */
 510      public static function trash($task = 'remove', $alt = 'JTOOLBAR_TRASH', $check = true)
 511      {
 512          $bar = Toolbar::getInstance('toolbar');
 513  
 514          // Add a trash button.
 515          $bar->appendButton('Standard', 'trash', $alt, $task, $check, false);
 516      }
 517  
 518      /**
 519       * Writes a save button for a given option.
 520       * Apply operation leads to a save action only (does not leave edit mode).
 521       *
 522       * @param   string  $task  An override for the task.
 523       * @param   string  $alt   An override for the alt text.
 524       *
 525       * @return  void
 526       *
 527       * @since   1.5
 528       */
 529      public static function apply($task = 'apply', $alt = 'JTOOLBAR_APPLY')
 530      {
 531          $bar = Toolbar::getInstance('toolbar');
 532  
 533          // Add an apply button
 534          $bar->apply($task, $alt);
 535      }
 536  
 537      /**
 538       * Writes a save button for a given option.
 539       * Save operation leads to a save and then close action.
 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 save($task = 'save', $alt = 'JTOOLBAR_SAVE')
 549      {
 550          $bar = Toolbar::getInstance('toolbar');
 551  
 552          // Add a save button.
 553          $bar->save($task, $alt);
 554      }
 555  
 556      /**
 557       * Writes a save and create new button for a given option.
 558       * Save and create operation leads to a save and then add action.
 559       *
 560       * @param   string   $task  An override for the task.
 561       * @param   string   $alt   An override for the alt text.
 562       *
 563       * @return  void
 564       *
 565       * @since   1.6
 566       */
 567      public static function save2new($task = 'save2new', $alt = 'JTOOLBAR_SAVE_AND_NEW')
 568      {
 569          $bar = Toolbar::getInstance('toolbar');
 570  
 571          // Add a save and create new button.
 572          $bar->save2new($task, $alt);
 573      }
 574  
 575      /**
 576       * Writes a save as copy button for a given option.
 577       * Save as copy operation leads to a save after clearing the key,
 578       * then returns user to edit mode with new key.
 579       *
 580       * @param   string   $task  An override for the task.
 581       * @param   string   $alt   An override for the alt text.
 582       *
 583       * @return  void
 584       *
 585       * @since   1.6
 586       */
 587      public static function save2copy($task = 'save2copy', $alt = 'JTOOLBAR_SAVE_AS_COPY')
 588      {
 589          $bar = Toolbar::getInstance('toolbar');
 590  
 591          // Add a save and create new button.
 592          $bar->save2copy($task, $alt);
 593      }
 594  
 595      /**
 596       * Writes a checkin button for a given option.
 597       *
 598       * @param   string   $task   An override for the task.
 599       * @param   string   $alt    An override for the alt text.
 600       * @param   boolean  $check  True if required to check that a standard list item is checked.
 601       *
 602       * @return  void
 603       *
 604       * @since   1.7
 605       */
 606      public static function checkin($task = 'checkin', $alt = 'JTOOLBAR_CHECKIN', $check = true)
 607      {
 608          $bar = Toolbar::getInstance('toolbar');
 609  
 610          // Add a save and create new button.
 611          $bar->appendButton('Standard', 'checkin', $alt, $task, $check);
 612      }
 613  
 614      /**
 615       * Writes a cancel button and invokes a cancel operation (eg a checkin).
 616       *
 617       * @param   string  $task  An override for the task.
 618       * @param   string  $alt   An override for the alt text.
 619       *
 620       * @return  void
 621       *
 622       * @since   1.5
 623       */
 624      public static function cancel($task = 'cancel', $alt = 'JTOOLBAR_CANCEL')
 625      {
 626          $bar = Toolbar::getInstance('toolbar');
 627  
 628          // Add a cancel button.
 629          $bar->appendButton('Standard', 'cancel', $alt, $task, false);
 630      }
 631  
 632      /**
 633       * Writes a configuration button and invokes a cancel operation (eg a checkin).
 634       *
 635       * @param   string   $component  The name of the component, eg, com_content.
 636       * @param   integer  $height     The height of the popup. [UNUSED]
 637       * @param   integer  $width      The width of the popup. [UNUSED]
 638       * @param   string   $alt        The name of the button.
 639       * @param   string   $path       An alternative path for the configuration xml relative to JPATH_SITE.
 640       *
 641       * @return  void
 642       *
 643       * @since   1.5
 644       */
 645      public static function preferences($component, $height = 550, $width = 875, $alt = 'JTOOLBAR_OPTIONS', $path = '')
 646      {
 647          $component = urlencode($component);
 648          $path = urlencode($path);
 649          $bar = Toolbar::getInstance('toolbar');
 650  
 651          $uri = (string) Uri::getInstance();
 652          $return = urlencode(base64_encode($uri));
 653  
 654          // Add a button linking to config for component.
 655          $bar->appendButton(
 656              'Link',
 657              'options',
 658              $alt,
 659              'index.php?option=com_config&amp;view=component&amp;component=' . $component . '&amp;path=' . $path . '&amp;return=' . $return
 660          );
 661      }
 662  
 663      /**
 664       * Writes a version history
 665       *
 666       * @param   string   $typeAlias  The component and type, for example 'com_content.article'
 667       * @param   integer  $itemId     The id of the item, for example the article id.
 668       * @param   integer  $height     The height of the popup.
 669       * @param   integer  $width      The width of the popup.
 670       * @param   string   $alt        The name of the button.
 671       *
 672       * @return  void
 673       *
 674       * @since   3.2
 675       */
 676      public static function versions($typeAlias, $itemId, $height = 800, $width = 500, $alt = 'JTOOLBAR_VERSIONS')
 677      {
 678          $lang = Factory::getLanguage();
 679          $lang->load('com_contenthistory', JPATH_ADMINISTRATOR, $lang->getTag(), true);
 680  
 681          /** @var \Joomla\CMS\Table\ContentType $contentTypeTable */
 682          $contentTypeTable = Table::getInstance('Contenttype');
 683          $typeId           = $contentTypeTable->getTypeId($typeAlias);
 684  
 685          // Options array for Layout
 686          $options              = array();
 687          $options['title']     = Text::_($alt);
 688          $options['height']    = $height;
 689          $options['width']     = $width;
 690          $options['itemId']    = $typeAlias . '.' . $itemId;
 691  
 692          $bar    = Toolbar::getInstance('toolbar');
 693          $layout = new FileLayout('joomla.toolbar.versions');
 694          $bar->appendButton('Custom', $layout->render($options), 'versions');
 695      }
 696  
 697      /**
 698       * Writes a save button for a given option, with an additional dropdown
 699       *
 700       * @param   array   $buttons  An array of buttons
 701       * @param   string  $class    The button class
 702       *
 703       * @return  void
 704       *
 705       * @since   4.0.0
 706       */
 707      public static function saveGroup($buttons = array(), $class = 'btn-success')
 708      {
 709          $validOptions = array(
 710              'apply'     => 'JTOOLBAR_APPLY',
 711              'save'      => 'JTOOLBAR_SAVE',
 712              'save2new'  => 'JTOOLBAR_SAVE_AND_NEW',
 713              'save2copy' => 'JTOOLBAR_SAVE_AS_COPY'
 714          );
 715  
 716          $bar = Toolbar::getInstance('toolbar');
 717  
 718          $saveGroup = $bar->dropdownButton('save-group');
 719  
 720          $saveGroup->configure(
 721              function (Toolbar $childBar) use ($buttons, $validOptions) {
 722                  foreach ($buttons as $button) {
 723                      if (!\array_key_exists($button[0], $validOptions)) {
 724                          continue;
 725                      }
 726  
 727                      $options['group'] = true;
 728                      $altText = $button[2] ?? $validOptions[$button[0]];
 729  
 730                      $childBar->{$button[0]}($button[1])
 731                          ->text($altText);
 732                  }
 733              }
 734          );
 735      }
 736  
 737      /**
 738       * Displays a modal button
 739       *
 740       * @param   string  $targetModalId  ID of the target modal box
 741       * @param   string  $icon           Icon class to show on modal button
 742       * @param   string  $alt            Title for the modal button
 743       * @param   string  $class          The button class
 744       *
 745       * @return  void
 746       *
 747       * @since   3.2
 748       */
 749      public static function modal($targetModalId, $icon, $alt, $class = 'btn-primary')
 750      {
 751          $title = Text::_($alt);
 752  
 753          $dhtml = '<joomla-toolbar-button><button data-bs-toggle="modal" data-bs-target="#' . $targetModalId . '" class="btn ' . $class . '">
 754              <span class="' . $icon . ' icon-fw" title="' . $title . '"></span> ' . $title . '</button></joomla-toolbar-button>';
 755  
 756          $bar = Toolbar::getInstance('toolbar');
 757          $bar->appendButton('Custom', $dhtml, $alt);
 758      }
 759  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer