* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved. * @license GNU General Public License version 3 or later; see LICENSE */ namespace Joomla\Component\MokoSuiteBackup\Administrator\View\Profile; defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; class HtmlView extends BaseHtmlView { protected $item; protected $form; public function display($tpl = null): void { $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->addToolbar(); parent::display($tpl); } protected function addToolbar(): void { $isNew = empty($this->item->id); $title = $isNew ? 'COM_MOKOJOOMBACKUP_PROFILE_NEW' : 'COM_MOKOJOOMBACKUP_PROFILE_EDIT'; $user = Factory::getApplication()->getIdentity(); $canSave = $isNew ? $user->authorise('core.create', 'com_mokosuitebackup') : $user->authorise('core.edit', 'com_mokosuitebackup'); ToolbarHelper::title(Text::_($title), 'cog'); if ($canSave) { ToolbarHelper::apply('profile.apply'); ToolbarHelper::save('profile.save'); } if (!$isNew) { $toolbar = Toolbar::getInstance(); $profileId = (int) $this->item->id; $backupsUrl = Route::_('index.php?option=com_mokosuitebackup&view=backups&filter[PROFILE_ID]=' . $profileId); $toolbar->linkButton('view-backups', 'COM_MOKOJOOMBACKUP_VIEW_BACKUPS') ->url($backupsUrl) ->icon('icon-database') ->buttonClass('btn btn-info'); } ToolbarHelper::cancel('profile.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE'); } }