- md5
- 2539a2d098c5a2de9359ed53ad87e90c
- sha1
- 44a446d70b145ae4476683a33f9a2be9037ddf02
- sha256
- 5f69a21a3c3c4d7717cb4b663500c5ce4411b36d7b7af6286274a04ad5b8e508
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
<?php
/**
* @package Joomla.Administrator
* @subpackage com_joomlaupdate
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Joomlaupdate\Administrator\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;
/**
* Joomla! Update Controller
*
* @since 2.5.4
*/
class DisplayController extends BaseController
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
*
* @return static This object to support chaining.
*
* @since 2.5.4
*/
public function display($cachable = false, $urlparams = false)
{
// Get the document object.
$document = $this->app->getDocument();
// Set the default view name and format from the Request.
$vName = $this->input->get('view', 'Joomlaupdate');
$vFormat = $document->getType();
$lName = $this->input->get('layout', 'default', 'string');
// Get and render the view.
if ($view = $this->getView($vName, $vFormat))
{
// Only super user can access file upload
if ($view == 'upload' && !$this->app->getIdentity()->authorise('core.admin', 'com_joomlaupdate'))
{
$this->app->redirect(Route::_('index.php?option=com_joomlaupdate', true));
}
// Get the model for the view.
/** @var \Joomla\Component\Joomlaupdate\Administrator\Model\UpdateModel $model */
$model = $this->getModel('Update');
/** @var ?\Joomla\Component\Installer\Administrator\Model\WarningsModel $warningsModel */
$warningsModel = $this->app->bootComponent('com_installer')
->getMVCFactory()->createModel('Warnings', 'Administrator', ['ignore_request' => true]);
if ($warningsModel !== null)
{
$view->setModel($warningsModel, false);
}
// Perform update source preference check and refresh update information.
$model->applyUpdateSite();
$model->refreshUpdates();
// Push the model into the view (as default).
$view->setModel($model, true);
$view->setLayout($lName);
// Push document object into the view.
$view->document = $document;
$view->display();
}
return $this;
}
/**
* Provide the data for a badge in a menu item via JSON
*
* @return void
*
* @since 4.0.0
* @throws \Exception
*/
public function getMenuBadgeData()
{
if (!$this->app->getIdentity()->authorise('core.manage', 'com_joomlaupdate'))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}
$model = $this->getModel('Update');
$model->refreshUpdates();
$joomlaUpdate = $model->getUpdateInformation();
$hasUpdate = $joomlaUpdate['hasUpdate'] ? $joomlaUpdate['latest'] : '';
echo new JsonResponse($hasUpdate);
}
}
The same content is in 43 releases, Joomla 4.0.0 to 4.2.0-beta2. See them all, or every version of this file.