2026-06-02 13:47:36 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-11 12:24:27 -05:00
|
|
|
* @package MokoSuiteBackup
|
|
|
|
|
* @subpackage com_mokosuitebackup
|
2026-06-02 13:47:36 -05:00
|
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
|
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
2026-06-11 12:24:27 -05:00
|
|
|
namespace Joomla\Component\MokoSuiteBackup\Administrator\View\Profile;
|
2026-06-02 13:47:36 -05:00
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
2026-06-13 07:23:53 -05:00
|
|
|
use Joomla\CMS\Factory;
|
2026-06-02 13:47:36 -05:00
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
2026-06-23 11:03:13 -05:00
|
|
|
use Joomla\CMS\Router\Route;
|
|
|
|
|
use Joomla\CMS\Session\Session;
|
|
|
|
|
use Joomla\CMS\Toolbar\Toolbar;
|
2026-06-02 13:47:36 -05:00
|
|
|
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);
|
2026-06-06 14:52:27 -05:00
|
|
|
$title = $isNew ? 'COM_MOKOJOOMBACKUP_PROFILE_NEW' : 'COM_MOKOJOOMBACKUP_PROFILE_EDIT';
|
2026-06-13 07:23:53 -05:00
|
|
|
$user = Factory::getApplication()->getIdentity();
|
|
|
|
|
$canSave = $isNew
|
|
|
|
|
? $user->authorise('core.create', 'com_mokosuitebackup')
|
|
|
|
|
: $user->authorise('core.edit', 'com_mokosuitebackup');
|
2026-06-02 13:47:36 -05:00
|
|
|
|
|
|
|
|
ToolbarHelper::title(Text::_($title), 'cog');
|
2026-06-13 07:23:53 -05:00
|
|
|
|
|
|
|
|
if ($canSave) {
|
|
|
|
|
ToolbarHelper::apply('profile.apply');
|
|
|
|
|
ToolbarHelper::save('profile.save');
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-23 11:03:13 -05:00
|
|
|
if (!$isNew) {
|
|
|
|
|
$toolbar = Toolbar::getInstance();
|
|
|
|
|
$profileId = (int) $this->item->id;
|
|
|
|
|
|
|
|
|
|
// "Run Backup Now" button — links to backup start with CSRF token
|
|
|
|
|
if ($user->authorise('mokosuitebackup.backup.run', 'com_mokosuitebackup')) {
|
|
|
|
|
$runUrl = Route::_('index.php?option=com_mokosuitebackup&view=backups&task=backups.start&profile_id=' . $profileId . '&' . Session::getFormToken() . '=1');
|
|
|
|
|
$toolbar->linkButton('run-backup', 'COM_MOKOJOOMBACKUP_RUN_BACKUP_NOW')
|
|
|
|
|
->url($runUrl)
|
|
|
|
|
->icon('icon-play')
|
|
|
|
|
->buttonClass('btn btn-success');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// "View Backups" link button
|
|
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-02 13:47:36 -05:00
|
|
|
ToolbarHelper::cancel('profile.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE');
|
|
|
|
|
}
|
|
|
|
|
}
|