FOF30\Toolbar\Toolbar::onBrowse PHP Метод

onBrowse() публичный Метод

Renders the toolbar for the component's Browse pages (the plural views)
public onBrowse ( ) : void
Результат void
    public function onBrowse()
    {
        // On frontend, buttons must be added specifically
        if ($this->container->platform->isBackend() || $this->renderFrontendSubmenu) {
            $this->renderSubmenu();
        }
        if (!$this->container->platform->isBackend() && !$this->renderFrontendButtons) {
            return;
        }
        // Setup
        $option = $this->container->componentName;
        $view = $this->container->input->getCmd('view', 'cpanel');
        // Set toolbar title
        $subtitle_key = strtoupper($option . '_TITLE_' . $view);
        JToolBarHelper::title(JText::_(strtoupper($option)) . ': ' . JText::_($subtitle_key), str_replace('com_', '', $option));
        if (!$this->isDataView()) {
            return;
        }
        // Add toolbar buttons
        if ($this->perms->create) {
            JToolBarHelper::addNew();
        }
        if ($this->perms->edit) {
            JToolBarHelper::editList();
        }
        if ($this->perms->create || $this->perms->edit) {
            JToolBarHelper::divider();
        }
        // Published buttons are only added if there is a enabled field in the table
        try {
            $model = $this->container->factory->model($view);
            if ($model->hasField('enabled') && $this->perms->editstate) {
                JToolBarHelper::publishList();
                JToolBarHelper::unpublishList();
                JToolBarHelper::divider();
            }
        } catch (\Exception $e) {
            // Yeah. Let's not add the buttons if we can't load the model...
        }
        if ($this->perms->delete) {
            $msg = JText::_($option . '_CONFIRM_DELETE');
            JToolBarHelper::deleteList(strtoupper($msg));
        }
        // A Check-In button is only added if there is a locked_on field in the table
        try {
            $model = $this->container->factory->model($view);
            if ($model->hasField('locked_on') && $this->perms->edit) {
                JToolBarHelper::checkin();
            }
        } catch (\Exception $e) {
            // Yeah. Let's not add the button if we can't load the model...
        }
    }

Usage Example

Пример #1
0
 public function onBrowse()
 {
     parent::onBrowse();
     JToolBarHelper::divider();
     JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_ars');
 }