* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Uri\Uri;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
->useScript('form.validate')
->useStyle('com_media.mediamanager');
$script = $wa->getAsset('script', 'com_media.edit-images')->getUri(true);
$params = ComponentHelper::getParams('com_media');
$input = Factory::getApplication()->input;
/** @var \Joomla\CMS\Form\Form $form */
$form = $this->form;
$tmpl = $input->getCmd('tmpl');
$input->set('hidemainmenu', true);
// Load the toolbar when we are in an iframe
if ($tmpl == 'component') {
echo '
';
echo Toolbar::getInstance('toolbar')->render();
echo '
';
}
$mediaTypes = $input->getString('mediatypes', '0');
// Populate the media config
$config = [
'apiBaseUrl' => Uri::base() . 'index.php?option=com_media&format=json' . '&mediatypes=' . $mediaTypes,
'csrfToken' => Session::getFormToken(),
'uploadPath' => $this->file->path,
'editViewUrl' => Uri::base() . 'index.php?option=com_media&view=file' . ($tmpl ? '&tmpl=' . $tmpl : '') . '&mediatypes=' . $mediaTypes,
'imagesExtensions' => array_map('trim', explode(',', $params->get('image_extensions', 'bmp,gif,jpg,jpeg,png,webp'))),
'audioExtensions' => array_map('trim', explode(',', $params->get('audio_extensions', 'mp3,m4a,mp4a,ogg'))),
'videoExtensions' => array_map('trim', explode(',', $params->get('video_extensions', 'mp4,mp4v,mpeg,mov,webm'))),
'documentExtensions' => array_map('trim', explode(',', $params->get('doc_extensions', 'doc,odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv'))),
'maxUploadSizeMb' => $params->get('upload_maxsize', 10),
'contents' => $this->file->content,
];
$this->document->addScriptOptions('com_media', $config);
$this->useCoreUI = true;
?>