CoreFiles by mySites.guru
MediaActionPlugin.php97 lines, 1,999 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
019bcfd4ad5f9068ea2be957010b3995
sha1
d0f1e5f78b2a77aafc767cc3c83a9d4a328e2f2c
sha256
d969c972c7e2f95517cba30e7ec4e48522ae8813042426dddd7725fb3f01a11b
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_media
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Media\Administrator\Plugin;

defined('_JEXEC') or die;

use Joomla\CMS\Form\Form;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\CMSPlugin;

/**
 * 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;

	/**
	 * 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]
		);
	}

	/**
	 * 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 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.