90 lines
2.6 KiB
PHP
90 lines
2.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @package MokoSuiteBackup
|
||
|
|
* @subpackage com_mokosuitebackup
|
||
|
|
* @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
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace Joomla\Component\MokoSuiteBackup\Administrator\View\Runbackup;
|
||
|
|
|
||
|
|
defined('_JEXEC') or die;
|
||
|
|
|
||
|
|
use Joomla\CMS\Factory;
|
||
|
|
use Joomla\CMS\Language\Text;
|
||
|
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Full-screen "run a backup" progress view.
|
||
|
|
*
|
||
|
|
* Auto-starts the stepped backup (ajax.init → loop ajax.step) and shows a
|
||
|
|
* full-page progress screen. Used both by the dashboard "Backup Now" action
|
||
|
|
* and — via the system plugin's pre-update redirect — as the interstitial
|
||
|
|
* between clicking Joomla's Update and the update actually running. When a
|
||
|
|
* `returnurl` is supplied the page redirects there once the backup completes
|
||
|
|
* (e.g. back to `com_joomlaupdate&task=update.install&is_backed_up=1`).
|
||
|
|
*/
|
||
|
|
class HtmlView extends BaseHtmlView
|
||
|
|
{
|
||
|
|
public int $profileId = 1;
|
||
|
|
|
||
|
|
public string $profileTitle = '';
|
||
|
|
|
||
|
|
public string $description = '';
|
||
|
|
|
||
|
|
/** Raw (possibly base64) return URL from the request; validated in the layout. */
|
||
|
|
public string $returnUrl = '';
|
||
|
|
|
||
|
|
public bool $autostart = true;
|
||
|
|
|
||
|
|
public function display($tpl = null): void
|
||
|
|
{
|
||
|
|
$input = Factory::getApplication()->getInput();
|
||
|
|
|
||
|
|
$this->profileId = (int) $input->getInt('profile_id', $input->getInt('profileid', 1));
|
||
|
|
$this->description = $input->getString('description', '');
|
||
|
|
$this->returnUrl = $input->getRaw('returnurl', '');
|
||
|
|
$this->autostart = (bool) $input->getInt('autostart', 1);
|
||
|
|
|
||
|
|
if ($this->profileId <= 0) {
|
||
|
|
$this->profileId = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->profileTitle = $this->loadProfileTitle($this->profileId);
|
||
|
|
|
||
|
|
$this->addToolbar();
|
||
|
|
|
||
|
|
parent::display($tpl);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Look up the target profile's title for display (best-effort).
|
||
|
|
*/
|
||
|
|
private function loadProfileTitle(int $profileId): string
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
|
||
|
|
$query = $db->getQuery(true)
|
||
|
|
->select($db->quoteName('title'))
|
||
|
|
->from($db->quoteName('#__mokosuitebackup_profiles'))
|
||
|
|
->where($db->quoteName('id') . ' = ' . (int) $profileId);
|
||
|
|
$db->setQuery($query);
|
||
|
|
|
||
|
|
return (string) ($db->loadResult() ?? '');
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function addToolbar(): void
|
||
|
|
{
|
||
|
|
ToolbarHelper::title(
|
||
|
|
Text::_('COM_MOKOJOOMBACKUP_SHORT') . ': ' . Text::_('COM_MOKOJOOMBACKUP_RUNBACKUP_TITLE'),
|
||
|
|
'archive'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|