- md5
- b770bdad61601b68e7dc0761e40f429f
- sha1
- 5ddacfd1ad851567a8fb3eeed68bd2e49c71182f
- sha256
- fc71a05af50d34d1bc8e3c85047cfa4c167d3481810a6d603fe6b80e747561e1
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Editors\TinyMCE\Extension;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Session\Session;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Plugin\Editors\TinyMCE\PluginTraits\DisplayTrait;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* TinyMCE Editor Plugin
*
* @since 1.5
*/
final class TinyMCE extends CMSPlugin
{
use DisplayTrait;
use DatabaseAwareTrait;
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Returns the templates
*
* @return void
*
* @since 5.0.0
*/
public function onAjaxTinymce()
{
if (!Session::checkToken('request')) {
echo json_encode([]);
exit();
}
$templates = [];
$language = $this->getApplication()->getLanguage();
$template = $this->getApplication()->getInput()->getPath('template', '');
if ('' === $template) {
echo json_encode([]);
exit();
}
$filepaths = Folder::exists(JPATH_ROOT . '/templates/' . $template)
? Folder::files(JPATH_ROOT . '/templates/' . $template, '\.(html|txt)$', false, true)
: [];
foreach ($filepaths as $filepath) {
$fileinfo = pathinfo($filepath);
$filename = $fileinfo['filename'];
$title_upper = strtoupper($filename);
if ($filename === 'index') {
continue;
}
$templates[] = (object) [
'title' => $language->hasKey('PLG_TINY_TEMPLATE_' . $title_upper . '_TITLE') ? Text::_('PLG_TINY_TEMPLATE_' . $title_upper . '_TITLE') : $filename,
'description' => $language->hasKey('PLG_TINY_TEMPLATE_' . $title_upper . '_DESC') ? Text::_('PLG_TINY_TEMPLATE_' . $title_upper . '_DESC') : ' ',
'content' => file_get_contents($filepath),
];
}
echo json_encode($templates);
exit();
}
}
The same content is in 3 releases, Joomla 5.0.0-alpha3 to 5.0.0-beta1. See them all, or every version of this file.