first commit

This commit is contained in:
2025-06-17 11:53:18 +02:00
commit 9f0f7ba12b
8804 changed files with 1369176 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="installer">
<name>plg_installer_folderinstaller</name>
<author>Joomla! Project</author>
<creationDate>2016-05</creationDate>
<copyright>(C) 2016 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.6.0</version>
<description>PLG_INSTALLER_FOLDERINSTALLER_PLUGIN_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Installer\Folder</namespace>
<files>
<folder plugin="folderinstaller">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_installer_folderinstaller.ini</language>
<language tag="en-GB">language/en-GB/plg_installer_folderinstaller.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.folderinstaller
*
* @copyright (C) 2023 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\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Installer\Folder\Extension\FolderInstaller;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new FolderInstaller(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('installer', 'folderinstaller')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.folderinstaller
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Installer\Folder\Extension;
use Joomla\CMS\Event\Installer\AddInstallationTabEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* FolderInstaller Plugin.
*
* @since 3.6.0
*/
final class FolderInstaller extends CMSPlugin implements SubscriberInterface
{
/**
* Application object.
*
* @var \Joomla\CMS\Application\CMSApplication
* @since 4.0.0
* @deprecated 6.0 Is needed for template overrides, use getApplication instead
*/
protected $app;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.0.0
*/
public static function getSubscribedEvents(): array
{
return ['onInstallerAddInstallationTab' => 'onInstallerAddInstallationTab'];
}
/**
* Installer add Installation Tab listener.
*
* @param AddInstallationTabEvent $event The event instance
*
* @return void
*
* @since 3.6.0
*/
public function onInstallerAddInstallationTab(AddInstallationTabEvent $event)
{
// Load language files
$this->loadLanguage();
$tab = [];
$tab['name'] = 'folder';
$tab['label'] = $this->getApplication()->getLanguage()->_('PLG_INSTALLER_FOLDERINSTALLER_TEXT');
// Render the input
ob_start();
include PluginHelper::getLayoutPath('installer', 'folderinstaller');
$tab['content'] = ob_get_clean();
$event->addResult($tab);
}
}

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.folderinstaller
*
* @copyright (C) 2016 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\Language\Text;
/** @var PlgInstallerFolderInstaller $this */
Text::script('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH');
$this->getApplication()->getDocument()->getWebAssetManager()
->registerAndUseScript(
'plg_installer_folderinstaller.folderinstaller',
'plg_installer_folderinstaller/folderinstaller.js',
[],
['defer' => true],
['core']
);
?>
<legend><?php echo Text::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT'); ?></legend>
<div class="control-group">
<label for="install_directory" class="control-label">
<?php echo Text::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT'); ?>
</label>
<div class="controls">
<input type="text" id="install_directory" name="install_directory" class="form-control"
value="<?php echo $this->getApplication()->getInput()->get('install_directory', $this->getApplication()->get('tmp_path')); ?>">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="button" class="btn btn-primary" id="installbutton_directory" onclick="Joomla.submitbuttonfolder()">
<?php echo Text::_('PLG_INSTALLER_FOLDERINSTALLER_BUTTON'); ?>
</button>
</div>
</div>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="installer" method="upgrade">
<name>plg_installer_override</name>
<author>Joomla! Project</author>
<creationDate>2018-06</creationDate>
<copyright>(C) 2018 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>4.0.0</version>
<description>PLG_INSTALLER_OVERRIDE_PLUGIN_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Installer\Override</namespace>
<files>
<folder plugin="override">services</folder>
<folder>src</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_installer_override.ini</language>
<language tag="en-GB">language/en-GB/plg_installer_override.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,48 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.override
*
* @copyright (C) 2023 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\CMS\Plugin\PluginHelper;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Installer\Override\Extension\Override;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new Override(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('installer', 'override')
);
$plugin->setApplication(Factory::getApplication());
$plugin->setDatabase($container->get(DatabaseInterface::class));
return $plugin;
}
);
}
};

View File

@ -0,0 +1,398 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.override
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Installer\Override\Extension;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Override Plugin
*
* @since 4.0.0
*/
final class Override extends CMSPlugin
{
use DatabaseAwareTrait;
/**
* Load the language file on instantiation.
*
* @var boolean
*
* @since 4.0.0
*/
protected $autoloadLanguage = true;
/**
* Method to get com_templates model instance.
*
* @param string $name The model name. Optional
* @param string $prefix The class prefix. Optional
*
* @return \Joomla\Component\Templates\Administrator\Model\TemplateModel
*
* @since 4.0.0
*
* @throws \Exception
*/
public function getModel($name = 'Template', $prefix = 'Administrator')
{
/** @var \Joomla\Component\Templates\Administrator\Extension\TemplatesComponent $templateProvider */
$templateProvider = $this->getApplication()->bootComponent('com_templates');
/** @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $model */
$model = $templateProvider->getMVCFactory()->createModel($name, $prefix);
return $model;
}
/**
* Purges session array.
*
* @return void
*
* @since 4.0.0
*/
public function purge()
{
// Delete stored session value.
$session = $this->getApplication()->getSession();
$session->remove('override.beforeEventFiles');
$session->remove('override.afterEventFiles');
}
/**
* Method to store files before event.
*
* @return void
*
* @since 4.0.0
*/
public function storeBeforeEventFiles()
{
// Delete stored session value.
$this->purge();
// Get list and store in session.
$list = $this->getOverrideCoreList();
$this->getApplication()->getSession()->set('override.beforeEventFiles', $list);
}
/**
* Method to store files after event.
*
* @return void
*
* @since 4.0.0
*/
public function storeAfterEventFiles()
{
// Get list and store in session.
$list = $this->getOverrideCoreList();
$this->getApplication()->getSession()->set('override.afterEventFiles', $list);
}
/**
* Method to prepare changed or updated core file.
*
* @param string $action The name of the action.
*
* @return array A list of changed files.
*
* @since 4.0.0
*/
public function getUpdatedFiles($action)
{
$session = $this->getApplication()->getSession();
$after = $session->get('override.afterEventFiles');
$before = $session->get('override.beforeEventFiles');
$result = [];
if (!\is_array($after) || !\is_array($before)) {
return $result;
}
$size1 = \count($after);
$size2 = \count($before);
if ($size1 === $size2) {
for ($i = 0; $i < $size1; $i++) {
if ($after[$i]->coreFile !== $before[$i]->coreFile) {
$after[$i]->action = $action;
$result[] = $after[$i];
}
}
}
return $result;
}
/**
* Method to get core list of override files.
*
* @return array The list of core files.
*
* @since 4.0.0
*/
public function getOverrideCoreList()
{
try {
/** @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $templateModel */
$templateModel = $this->getModel();
} catch (\Exception $e) {
return [];
}
return $templateModel->getCoreList();
}
/**
* Last process of this plugin.
*
* @param array $result Result array.
*
* @return void
*
* @since 4.0.0
*/
public function finalize($result)
{
$num = \count($result);
$link = 'index.php?option=com_templates&view=templates';
if ($num != 0) {
$this->getApplication()->enqueueMessage(Text::plural('PLG_INSTALLER_OVERRIDE_N_FILE_UPDATED', $num, $link), 'notice');
$this->saveOverrides($result);
}
// Delete stored session value.
$this->purge();
}
/**
* Event before extension update.
*
* @return void
*
* @since 4.0.0
*/
public function onExtensionBeforeUpdate()
{
$this->storeBeforeEventFiles();
}
/**
* Event after extension update.
*
* @return void
*
* @since 4.0.0
*/
public function onExtensionAfterUpdate()
{
$this->storeAfterEventFiles();
$result = $this->getUpdatedFiles('Extension Update');
$this->finalize($result);
}
/**
* Event before joomla update.
*
* @return void
*
* @since 4.0.0
*/
public function onJoomlaBeforeUpdate()
{
$this->storeBeforeEventFiles();
}
/**
* Event after joomla update.
*
* @return void
*
* @since 4.0.0
*/
public function onJoomlaAfterUpdate()
{
$this->storeAfterEventFiles();
$result = $this->getUpdatedFiles('Joomla Update');
$this->finalize($result);
}
/**
* Event before install.
*
* @return void
*
* @since 4.0.0
*/
public function onInstallerBeforeInstaller()
{
$this->storeBeforeEventFiles();
}
/**
* Event after install.
*
* @return void
*
* @since 4.0.0
*/
public function onInstallerAfterInstaller()
{
$this->storeAfterEventFiles();
$result = $this->getUpdatedFiles('Extension Install');
$this->finalize($result);
}
/**
* Check for existing id.
*
* @param string $id Hash id of file.
* @param integer $exid Extension id of file.
*
* @return boolean True/False
*
* @since 4.0.0
*/
public function load($id, $exid)
{
$db = $this->getDatabase();
// Create a new query object.
$query = $db->getQuery(true);
$query
->select($db->quoteName('hash_id'))
->from($db->quoteName('#__template_overrides'))
->where($db->quoteName('hash_id') . ' = :id')
->where($db->quoteName('extension_id') . ' = :exid')
->bind(':id', $id)
->bind(':exid', $exid, ParameterType::INTEGER);
$db->setQuery($query);
$results = $db->loadObjectList();
if (\count($results) === 1) {
return true;
}
return false;
}
/**
* Save the updated files.
*
* @param array $pks Updated files.
*
* @return void
*
* @since 4.0.0
* @throws \Joomla\Database\Exception\ExecutionFailureException|\Joomla\Database\Exception\ConnectionFailureException
*/
private function saveOverrides($pks)
{
// Insert columns.
$columns = [
'template',
'hash_id',
'action',
'created_date',
'modified_date',
'extension_id',
'state',
'client_id',
];
$db = $this->getDatabase();
// Create an insert query.
$insertQuery = $db->getQuery(true)
->insert($db->quoteName('#__template_overrides'))
->columns($db->quoteName($columns));
foreach ($pks as $pk) {
$date = new Date('now');
$createdDate = $date->toSql();
if (empty($pk->coreFile)) {
$modifiedDate = null;
} else {
$modifiedDate = $createdDate;
}
if ($this->load($pk->id, $pk->extension_id)) {
$updateQuery = $db->getQuery(true)
->update($db->quoteName('#__template_overrides'))
->set(
[
$db->quoteName('modified_date') . ' = :modifiedDate',
$db->quoteName('action') . ' = :pkAction',
$db->quoteName('state') . ' = 0',
]
)
->where($db->quoteName('hash_id') . ' = :pkId')
->where($db->quoteName('extension_id') . ' = :exId')
->bind(':modifiedDate', $modifiedDate)
->bind(':pkAction', $pk->action)
->bind(':pkId', $pk->id)
->bind(':exId', $pk->extension_id, ParameterType::INTEGER);
// Set the query using our newly populated query object and execute it.
$db->setQuery($updateQuery);
$db->execute();
continue;
}
// Insert values, preserve order
$bindArray = $insertQuery->bindArray(
[
$pk->template,
$pk->id,
$pk->action,
$createdDate,
$modifiedDate,
],
ParameterType::STRING
);
$bindArray = array_merge(
$bindArray,
$insertQuery->bindArray(
[
$pk->extension_id,
0,
(int) $pk->client,
],
ParameterType::INTEGER
)
);
$insertQuery->values(implode(',', $bindArray));
}
if (!empty($bindArray)) {
$db->setQuery($insertQuery);
$db->execute();
}
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="installer">
<name>plg_installer_packageinstaller</name>
<author>Joomla! Project</author>
<creationDate>2016-05</creationDate>
<copyright>(C) 2016 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.6.0</version>
<description>PLG_INSTALLER_PACKAGEINSTALLER_PLUGIN_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Installer\Package</namespace>
<files>
<folder plugin="packageinstaller">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_installer_packageinstaller.ini</language>
<language tag="en-GB">language/en-GB/plg_installer_packageinstaller.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.packageinstaller
*
* @copyright (C) 2023 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\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Installer\Package\Extension\PackageInstaller;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new PackageInstaller(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('installer', 'packageinstaller')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.packageinstaller
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Installer\Package\Extension;
use Joomla\CMS\Event\Installer\AddInstallationTabEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* PackageInstaller Plugin.
*
* @since 3.6.0
*/
final class PackageInstaller extends CMSPlugin implements SubscriberInterface
{
/**
* Application object
*
* @var \Joomla\CMS\Application\CMSApplication
* @since 4.0.0
* @deprecated 6.0 Is needed for template overrides, use getApplication instead
*/
protected $app;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.0.0
*/
public static function getSubscribedEvents(): array
{
return ['onInstallerAddInstallationTab' => 'onInstallerAddInstallationTab'];
}
/**
* Installer add Installation Tab listener.
*
* @param AddInstallationTabEvent $event The event instance
*
* @return void
*
* @since 3.6.0
*/
public function onInstallerAddInstallationTab(AddInstallationTabEvent $event)
{
// Load language files
$this->loadLanguage();
$tab = [];
$tab['name'] = 'package';
$tab['label'] = $this->getApplication()->getLanguage()->_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_PACKAGE_FILE');
// Render the input
ob_start();
include PluginHelper::getLayoutPath('installer', 'packageinstaller');
$tab['content'] = ob_get_clean();
$event->addResult($tab);
}
}

View File

@ -0,0 +1,109 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.packageinstaller
*
* @copyright (C) 2016 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\Filesystem\FilesystemHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Plugin\Installer\Package\Extension\PackageInstaller;
/** @var PackageInstaller $this */
HTMLHelper::_('form.csrf');
Text::script('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE');
Text::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN');
Text::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY');
Text::script('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG');
$this->getApplication()->getDocument()->getWebAssetManager()
->registerAndUseScript(
'plg_installer_packageinstaller.packageinstaller',
'plg_installer_packageinstaller/packageinstaller.js',
[],
['defer' => true],
['core']
);
$return = $this->getApplication()->getInput()->getBase64('return');
$maxSizeBytes = FilesystemHelper::fileUploadMaxSize(false);
$maxSize = HTMLHelper::_('number.bytes', $maxSizeBytes);
?>
<legend><?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_INSTALL_JOOMLA_EXTENSION'); ?></legend>
<div id="uploader-wrapper">
<div id="dragarea" data-state="pending">
<div id="dragarea-content" class="text-center">
<p>
<span id="upload-icon" class="icon-upload" aria-hidden="true"></span>
</p>
<div id="upload-progress" class="upload-progress">
<div class="progress">
<div class="progress-bar progress-bar-striped bg-success progress-bar-animated"
style="width: 0;"
role="progressbar"
aria-valuenow="0"
aria-valuemin="0"
aria-valuemax="100"
></div>
</div>
<p class="lead">
<span class="uploading-text">
<?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOADING'); ?>
</span>
<span class="uploading-number">0</span><span class="uploading-symbol">%</span>
</p>
</div>
<div class="install-progress">
<div class="progress">
<div class="progress-bar progress-bar-striped" style="width: 100%;"></div>
</div>
<p class="lead">
<span class="installing-text">
<?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_INSTALLING'); ?>
</span>
</p>
</div>
<div class="upload-actions">
<p class="lead">
<?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_DRAG_FILE_HERE'); ?>
</p>
<p>
<button id="select-file-button" type="button" class="btn btn-success">
<span class="icon-copy" aria-hidden="true"></span>
<?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_SELECT_FILE'); ?>
</button>
</p>
<p>
<?php echo Text::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', '&#x200E;' . $maxSize); ?>
</p>
</div>
</div>
</div>
</div>
<div id="legacy-uploader" class="hidden">
<div class="control-group">
<label for="install_package" class="control-label"><?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_EXTENSION_PACKAGE_FILE'); ?></label>
<div class="controls">
<input class="form-control-file" id="install_package" name="install_package" type="file">
<input id="max_upload_size" name="max_upload_size" type="hidden" value="<?php echo $maxSizeBytes; ?>" />
<small class="form-text"><?php echo Text::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?></small>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" type="button" id="installbutton_package">
<?php echo Text::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_AND_INSTALL'); ?>
</button>
</div>
<input id="installer-return" name="return" type="hidden" value="<?php echo $return; ?>">
</div>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.urlinstaller
*
* @copyright (C) 2023 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\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Installer\Url\Extension\UrlInstaller;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new UrlInstaller(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('installer', 'urlinstaller')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.urlinstaller
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Installer\Url\Extension;
use Joomla\CMS\Event\Installer\AddInstallationTabEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* UrlFolderInstaller Plugin.
*
* @since 3.6.0
*/
final class UrlInstaller extends CMSPlugin implements SubscriberInterface
{
/**
* Application object.
*
* @var \Joomla\CMS\Application\CMSApplication
* @since 4.0.0
* @deprecated 6.0 Is needed for template overrides, use getApplication instead
*/
protected $app;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.0.0
*/
public static function getSubscribedEvents(): array
{
return ['onInstallerAddInstallationTab' => 'onInstallerAddInstallationTab'];
}
/**
* Installer add Installation Tab listener.
*
* @param AddInstallationTabEvent $event The event instance
*
* @return void
*
* @since 3.6.0
*/
public function onInstallerAddInstallationTab(AddInstallationTabEvent $event)
{
// Load language files
$this->loadLanguage();
$tab = [];
$tab['name'] = 'url';
$tab['label'] = $this->getApplication()->getLanguage()->_('PLG_INSTALLER_URLINSTALLER_TEXT');
// Render the input
ob_start();
include PluginHelper::getLayoutPath('installer', 'urlinstaller');
$tab['content'] = ob_get_clean();
$event->addResult($tab);
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.urlinstaller
*
* @copyright (C) 2016 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\Language\Text;
use Joomla\Plugin\Installer\Url\Extension\UrlInstaller;
/** @var UrlInstaller $this */
$this->getApplication()->getDocument()->getWebAssetManager()
->registerAndUseScript('plg_installer_urlinstaller.urlinstaller', 'plg_installer_urlinstaller/urlinstaller.js', [], ['defer' => true], ['core']);
?>
<legend><?php echo Text::_('PLG_INSTALLER_URLINSTALLER_TEXT'); ?></legend>
<div class="control-group">
<label for="install_url" class="control-label">
<?php echo Text::_('PLG_INSTALLER_URLINSTALLER_TEXT'); ?>
</label>
<div class="controls">
<input type="text" id="install_url" name="install_url" class="form-control" placeholder="https://">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="button" class="btn btn-primary" id="installbutton_url" onclick="Joomla.submitbuttonurl()">
<?php echo Text::_('PLG_INSTALLER_URLINSTALLER_BUTTON'); ?>
</button>
</div>
</div>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="installer">
<name>plg_installer_urlinstaller</name>
<author>Joomla! Project</author>
<creationDate>2016-05</creationDate>
<copyright>(C) 2016 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.6.0</version>
<description>PLG_INSTALLER_URLINSTALLER_PLUGIN_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Installer\Url</namespace>
<files>
<folder plugin="urlinstaller">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_installer_urlinstaller.ini</language>
<language tag="en-GB">language/en-GB/plg_installer_urlinstaller.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.webinstaller
*
* @copyright (C) 2023 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\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Installer\Web\Extension\WebInstaller;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new WebInstaller(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('installer', 'webinstaller')
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
}
);
}
};

View File

@ -0,0 +1,192 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.webinstaller
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Installer\Web\Extension;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Event\Installer\AddInstallationTabEvent;
use Joomla\CMS\Form\Rule\UrlRule;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Updater\Update;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Version;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Support for the "Install from Web" tab
*
* @since 3.2
*/
final class WebInstaller extends CMSPlugin implements SubscriberInterface
{
/**
* The URL for the remote server.
*
* @var string
* @since 4.0.0
*/
public const REMOTE_URL = 'https://appscdn.joomla.org/webapps/';
/**
* The application object.
*
* @var CMSApplication
* @since 4.0.0
* @deprecated 6.0 Is needed for template overrides, use getApplication instead
*/
protected $app;
/**
* The URL to install from
*
* @var string|null
* @since 4.0.0
*/
private $installfrom = null;
/**
* Flag if the document is in a RTL direction
*
* @var integer|null
* @since 4.0.0
*/
private $rtl = null;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.0.0
*/
public static function getSubscribedEvents(): array
{
return ['onInstallerAddInstallationTab' => 'onInstallerAddInstallationTab'];
}
/**
* Event listener for the `onInstallerAddInstallationTab` event.
*
* @param AddInstallationTabEvent $event The event instance
*
* @return void
*
* @since 4.0.0
*/
public function onInstallerAddInstallationTab(AddInstallationTabEvent $event)
{
// Load language files
$this->loadLanguage();
$installfrom = $this->getInstallFrom();
$doc = $this->getApplication()->getDocument();
$lang = $this->getApplication()->getLanguage();
// Push language strings to the JavaScript store
Text::script('PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN');
Text::script('PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL');
$doc->getWebAssetManager()
->registerAndUseStyle('plg_installer_webinstaller.client', 'plg_installer_webinstaller/client.min.css')
->registerAndUseScript(
'plg_installer_webinstaller.client',
'plg_installer_webinstaller/client.min.js',
[],
['type' => 'module'],
['core']
);
$devLevel = Version::PATCH_VERSION;
if (!empty(Version::EXTRA_VERSION)) {
$devLevel .= '-' . Version::EXTRA_VERSION;
}
$doc->addScriptOptions(
'plg_installer_webinstaller',
[
'base_url' => addslashes(self::REMOTE_URL),
'installat_url' => base64_encode(Uri::current() . '?option=com_installer&view=install'),
'installfrom_url' => addslashes($installfrom),
'product' => base64_encode(Version::PRODUCT),
'release' => base64_encode(Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION),
'dev_level' => base64_encode($devLevel),
'installfromon' => $installfrom ? 1 : 0,
'language' => base64_encode($lang->getTag()),
'installFrom' => $installfrom != '' ? 4 : 5,
]
);
$tab = [
'name' => 'web',
'label' => $lang->_('PLG_INSTALLER_WEBINSTALLER_TAB_LABEL'),
];
// Render the input
ob_start();
include PluginHelper::getLayoutPath('installer', 'webinstaller');
$tab['content'] = ob_get_clean();
$tab['content'] = '<legend>' . $tab['label'] . '</legend>' . $tab['content'];
$event->addResult($tab);
}
/**
* Internal check to determine if the output is in a RTL direction
*
* @return integer
*
* @since 3.2
*/
private function isRTL()
{
if ($this->rtl === null) {
$this->rtl = strtolower($this->getApplication()->getDocument()->getDirection()) === 'rtl' ? 1 : 0;
}
return $this->rtl;
}
/**
* Get the install from URL
*
* @return string
*
* @since 3.2
*/
private function getInstallFrom()
{
if ($this->installfrom === null) {
$installfrom = base64_decode($this->getApplication()->getInput()->getBase64('installfrom', ''));
$field = new \SimpleXMLElement('<field></field>');
if ((new UrlRule())->test($field, $installfrom) && preg_match('/\.xml\s*$/', $installfrom)) {
$update = new Update();
$update->loadFromXml($installfrom);
$package_url = trim($update->get('downloadurl', false)->_data);
if ($package_url) {
$installfrom = $package_url;
}
}
$this->installfrom = $installfrom;
}
return $this->installfrom;
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.Webinstaller
*
* @copyright (C) 2018 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\Language\Text;
/** @var PlgInstallerWebinstaller $this */
$dir = $this->isRTL() ? ' dir="ltr"' : '';
Text::script('JSEARCH_FILTER_CLEAR');
Text::script('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING_ERROR');
?>
<div id="jed-container" class="tab-pane">
<div class="card" id="web-loader">
<div class="card-body">
<h2 class="card-title"><?php echo Text::_('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING'); ?></h2>
</div>
</div>
<div class="hidden" id="web-loader-error">
</div>
</div>
<fieldset class="form-group hidden" id="uploadform-web"<?php echo $dir; ?>>
<p><strong><?php echo Text::_('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM'); ?></strong></p>
<dl>
<dt id="uploadform-web-name-label"><?php echo Text::_('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_NAME'); ?></dt>
<dd id="uploadform-web-name"></dd>
<dt><?php echo Text::_('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_URL'); ?></dt>
<dd id="uploadform-web-url"></dd>
</dl>
<div class="card card-light">
<div class="card-body">
<div class="card-text">
<button type="button" class="btn btn-primary" id="uploadform-web-install"><?php echo Text::_('COM_INSTALLER_INSTALL_BUTTON'); ?></button>
<button type="button" class="btn btn-secondary" id="uploadform-web-cancel"><?php echo Text::_('JCANCEL'); ?></button>
</div>
</div>
</div>
</fieldset>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="installer" method="upgrade">
<name>plg_installer_webinstaller</name>
<author>Joomla! Project</author>
<creationDate>2017-04</creationDate>
<copyright>(C) 2018 Open Source Matters, Inc.</copyright>
<license>https://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>4.0.0</version>
<description>PLG_INSTALLER_WEBINSTALLER_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Installer\Web</namespace>
<files>
<folder plugin="webinstaller">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_installer_webinstaller.ini</language>
<language tag="en-GB">language/en-GB/plg_installer_webinstaller.sys.ini</language>
</languages>
</extension>