This commit is contained in:
AlexBa16
2026-06-08 15:29:52 +02:00
commit 27903eed4a
9931 changed files with 1535659 additions and 0 deletions
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="filesystem" method="upgrade">
<name>plg_filesystem_local</name>
<author>Joomla! Project</author>
<creationDate>2017-04</creationDate>
<copyright>(C) 2017 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_FILESYSTEM_LOCAL_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Filesystem\Local</namespace>
<files>
<folder plugin="local">services</folder>
<folder>src</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_filesystem_local.ini</language>
<language tag="en-GB">language/en-GB/plg_filesystem_local.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="directories"
type="subform"
label="PLG_FILESYSTEM_LOCAL_DIRECTORIES_LABEL"
multiple="true"
layout="joomla.form.field.subform.repeatable-table"
buttons="add,remove,move"
default='[{"directory":"images"},{"directory":"files"}]'
>
<form>
<field
name="directory"
type="folderlist"
default="images"
label="PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_LABEL"
folderFilter=""
exclude=""
stripext=""
hide_none="true"
validate="options"
/>
<field
name="thumbs"
type="radio"
label="PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_THUMBNAILS_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</form>
</field>
</fieldset>
</fields>
</config>
</extension>
@@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Filesystem.local
*
* @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\Plugin\Filesystem\Local\Extension\Local;
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.3.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
$container->lazy(Local::class, function (Container $container) {
$plugin = new Local(
(array) PluginHelper::getPlugin('filesystem', 'local'),
JPATH_ROOT
);
$plugin->setApplication(Factory::getApplication());
return $plugin;
})
);
}
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,160 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage FileSystem.local
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Filesystem\Local\Extension;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Component\Media\Administrator\Event\MediaProviderEvent;
use Joomla\Component\Media\Administrator\Provider\ProviderInterface;
use Joomla\Event\SubscriberInterface;
use Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* FileSystem Local plugin.
*
* The plugin to deal with the local filesystem in Media Manager.
*
* @since 4.0.0
*/
final class Local extends CMSPlugin implements SubscriberInterface, ProviderInterface
{
/**
* Affects constructor behavior. If true, language files will be loaded automatically.
*
* @var boolean
* @since 4.0.0
*/
protected $autoloadLanguage = true;
/**
* The root directory path
*
* @var string
* @since 4.3.0
*/
private $rootDirectory;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.4.0
*/
public static function getSubscribedEvents(): array
{
return [
'onSetupProviders' => 'onSetupProviders',
];
}
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings
* @param string $rootDirectory The root directory to look for images
*
* @since 4.3.0
*/
public function __construct(array $config, string $rootDirectory)
{
parent::__construct($config);
$this->rootDirectory = $rootDirectory;
}
/**
* Setup Providers for Local Adapter
*
* @param MediaProviderEvent $event Event for ProviderManager
*
* @return void
*
* @since 4.0.0
*/
public function onSetupProviders(MediaProviderEvent $event)
{
$event->getProviderManager()->registerProvider($this);
}
/**
* Returns the ID of the provider
*
* @return string
*
* @since 4.0.0
*/
public function getID()
{
return $this->_name;
}
/**
* Returns the display name of the provider
*
* @return string
*
* @since 4.0.0
*/
public function getDisplayName()
{
return $this->getApplication()->getLanguage()->_('PLG_FILESYSTEM_LOCAL_DEFAULT_NAME');
}
/**
* Returns and array of adapters
*
* @return \Joomla\Component\Media\Administrator\Adapter\AdapterInterface[]
*
* @since 4.0.0
*/
public function getAdapters()
{
$adapters = [];
$directories = $this->params->get('directories', [(object) ['directory' => 'images', 'thumbs' => 0], (object) ['directory' => 'files']]);
// Do a check if default settings are not saved by user, if not initialize them manually
if (\is_string($directories)) {
$directories = json_decode($directories);
}
foreach ($directories as $directoryEntity) {
if (!$directoryEntity->directory) {
continue;
}
$directoryPath = $this->rootDirectory . '/' . $directoryEntity->directory;
$directoryPath = rtrim($directoryPath) . '/';
if (!isset($directoryEntity->thumbs)) {
$directoryEntity->thumbs = 0;
}
$adapter = new LocalAdapter(
$directoryPath,
$directoryEntity->directory,
$directoryEntity->thumbs,
[200, 200]
);
if ($this->getApplication()->getIdentity()) {
$adapter->setCurrentUser($this->getApplication()->getIdentity());
}
$adapters[$adapter->getAdapterName()] = $adapter;
}
return $adapters;
}
}