- md5
- 7b44976c80bdfc1d83b1931628b218e0
- sha1
- 7590d46f01e2ff73bea3f3f700c924353b164508
- sha256
- 8ca452e01efbd31f2e2b6462e48fa07f8503681369fbd387b4e97df5d4c96bce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
<?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @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\Component\Media\Administrator\Plugin;
use Joomla\CMS\Event\Model\PrepareFormEvent;
use Joomla\CMS\Form\Form;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\CMSPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Media Manager Base Plugin for the media actions
*
* @since 4.0.0
*/
class MediaActionPlugin extends CMSPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
*
* @since 4.0.0
*/
protected $autoloadLanguage = true;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.2.0
*/
public static function getSubscribedEvents(): array
{
return [
'onContentPrepareForm' => 'onContentPrepareFormListener',
];
}
/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
*
* @param PrepareFormEvent $event Event instance.
*
* @return void
*
* @since 5.2.0
*/
public function onContentPrepareFormListener(PrepareFormEvent $event): void
{
$this->onContentPrepareForm($event->getForm(), $event->getData());
}
/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
*
* @param Form $form The form
* @param \stdClass $data The data
*
* @return void
*
* @since 4.0.0
*/
public function onContentPrepareForm(Form $form, $data)
{
// Check if it is the right form
if ($form->getName() != 'com_media.file') {
return;
}
$this->loadCss();
$this->loadJs();
// The file with the params for the edit view
$paramsFile = JPATH_PLUGINS . '/media-action/' . $this->_name . '/form/' . $this->_name . '.xml';
// When the file exists, load it into the form
if (file_exists($paramsFile)) {
$form->loadFile($paramsFile);
}
}
/**
* Load the javascript files of the plugin.
*
* @return void
*
* @since 4.0.0
*/
protected function loadJs()
{
HTMLHelper::_(
'script',
'plg_media-action_' . $this->_name . '/' . $this->_name . '.js',
['version' => 'auto', 'relative' => true],
['type' => 'module']
);
}
/**
* Load the CSS files of the plugin.
*
* @return void
*
* @since 4.0.0
*/
protected function loadCss()
{
HTMLHelper::_(
'stylesheet',
'plg_media-action_' . $this->_name . '/' . $this->_name . '.css',
['version' => 'auto', 'relative' => true]
);
}
}
The same content is in 113 releases, Joomla 5.2.0-beta2 to 6.2.1-rc1. See them all, or every version of this file.