first commit
This commit is contained in:
34
plugins/quickicon/joomlaupdate/joomlaupdate.xml
Normal file
34
plugins/quickicon/joomlaupdate/joomlaupdate.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="quickicon" method="upgrade">
|
||||
<name>plg_quickicon_joomlaupdate</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2011-08</creationDate>
|
||||
<copyright>(C) 2011 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_QUICKICON_JOOMLAUPDATE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Quickicon\Joomlaupdate</namespace>
|
||||
<files>
|
||||
<folder plugin="joomlaupdate">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_quickicon_joomlaupdate.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_quickicon_joomlaupdate.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="context"
|
||||
type="text"
|
||||
label="PLG_QUICKICON_JOOMLAUPDATE_GROUP_LABEL"
|
||||
description="PLG_QUICKICON_JOOMLAUPDATE_GROUP_DESC"
|
||||
default="update_quickicon"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
49
plugins/quickicon/joomlaupdate/services/provider.php
Normal file
49
plugins/quickicon/joomlaupdate/services/provider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Quickicon.Joomlaupdate
|
||||
*
|
||||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\Quickicon\Joomlaupdate\Extension\Joomlaupdate;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
// @Todo This needs to be changed to a proper factory
|
||||
$plugin = \Joomla\CMS\Plugin\PluginHelper::getPlugin('quickicon', 'joomlaupdate');
|
||||
|
||||
$plugin = new Joomlaupdate(
|
||||
$container->get(DispatcherInterface::class),
|
||||
Factory::getApplication()->getDocument(),
|
||||
(array) $plugin
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
141
plugins/quickicon/joomlaupdate/src/Extension/Joomlaupdate.php
Normal file
141
plugins/quickicon/joomlaupdate/src/Extension/Joomlaupdate.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Quickicon.Joomlaupdate
|
||||
*
|
||||
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Quickicon\Joomlaupdate\Extension;
|
||||
|
||||
use Joomla\CMS\Document\Document;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
use Joomla\Module\Quickicon\Administrator\Event\QuickIconsEvent;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Joomla! update notification plugin
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class Joomlaupdate extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* The document.
|
||||
*
|
||||
* @var Document
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $document;
|
||||
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'onGetIcons' => 'getCoreUpdateNotification',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DispatcherInterface $dispatcher The object to observe
|
||||
* @param Document $document The document
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'group', 'params', 'language'
|
||||
* (this list is not meant to be comprehensive).
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct($dispatcher, Document $document, array $config = [])
|
||||
{
|
||||
parent::__construct($dispatcher, $config);
|
||||
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the Quick Icons module is constructing its set
|
||||
* of icons. You can return an array which defines a single icon and it will
|
||||
* be rendered right after the stock Quick Icons.
|
||||
*
|
||||
* @param QuickIconsEvent $event The event object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getCoreUpdateNotification(QuickIconsEvent $event)
|
||||
{
|
||||
$context = $event->getContext();
|
||||
|
||||
if (
|
||||
$context !== $this->params->get('context', 'update_quickicon')
|
||||
|| !$this->getApplication()->getIdentity()->authorise('core.manage', 'com_joomlaupdate')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Text::script('PLG_QUICKICON_JOOMLAUPDATE_ERROR');
|
||||
Text::script('PLG_QUICKICON_JOOMLAUPDATE_UPDATEFOUND');
|
||||
Text::script('PLG_QUICKICON_JOOMLAUPDATE_UPTODATE');
|
||||
Text::script('MESSAGE');
|
||||
Text::script('ERROR');
|
||||
Text::script('INFO');
|
||||
Text::script('WARNING');
|
||||
|
||||
$this->document->addScriptOptions(
|
||||
'js-joomla-update',
|
||||
[
|
||||
'url' => Uri::base() . 'index.php?option=com_joomlaupdate',
|
||||
'ajaxUrl' => Uri::base() . 'index.php?option=com_joomlaupdate&task=update.ajax&'
|
||||
. Session::getFormToken() . '=1',
|
||||
'version' => JVERSION,
|
||||
]
|
||||
);
|
||||
|
||||
$this->document->getWebAssetManager()
|
||||
->registerAndUseScript('plg_quickicon_joomlaupdate', 'plg_quickicon_joomlaupdate/jupdatecheck.min.js', [], ['defer' => true], ['core']);
|
||||
|
||||
// Add the icon to the result array
|
||||
$result = $event->getArgument('result', []);
|
||||
|
||||
$result[] = [
|
||||
[
|
||||
'link' => 'index.php?option=com_joomlaupdate',
|
||||
'image' => 'icon-joomla',
|
||||
'icon' => '',
|
||||
'text' => Text::_('PLG_QUICKICON_JOOMLAUPDATE_CHECKING'),
|
||||
'id' => 'plg_quickicon_joomlaupdate',
|
||||
'group' => 'MOD_QUICKICON_MAINTENANCE',
|
||||
],
|
||||
];
|
||||
|
||||
$event->setArgument('result', $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user