- md5
- 6600e0c3d6e9e57a3b159e8c4654a979
- sha1
- 25803bfb4e29868245f48496d71a61cc11c1f07e
- sha256
- b8521836c8ebe7fef9d9c54a77756a3c629eac622721c10ffeef165e763fd3e4
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Form Field class for the TinyMCE editor.
*
* @package Joomla.Plugin
* @subpackage Editors.tinymce
* @since 3.7.0
*/
class JFormFieldTinymceBuilder extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 3.7.0
*/
protected $type = 'tinymcebuilder';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7.0
*/
protected $layout = 'plugins.editors.tinymce.field.tinymcebuilder';
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$paramsAll = (object) $this->form->getValue('params');
$setsAmount = empty($paramsAll->sets_amount) ? 3 : $paramsAll->sets_amount;
// Get the plugin
require_once JPATH_PLUGINS . '/editors/tinymce/tinymce.php';
$menus = array(
'edit' => array('label' => 'Edit'),
'insert' => array('label' => 'Insert'),
'view' => array('label' => 'View'),
'format' => array('label' => 'Format'),
'table' => array('label' => 'Table'),
'tools' => array('label' => 'Tools'),
);
$data['menus'] = $menus;
$data['menubarSource'] = array_keys($menus);
$data['buttons'] = PlgEditorTinymce::getKnownButtons();
$data['buttonsSource'] = array_keys($data['buttons']);
$data['toolbarPreset'] = PlgEditorTinymce::getToolbarPreset();
$data['setsAmount'] = $setsAmount;
// Get array of sets names
for ($i = 0; $i < $setsAmount; $i++)
{
$data['setsNames'][$i] = JText::sprintf('PLG_TINY_SET_TITLE', $i);
}
// Prepare the forms for each set
$setsForms = array();
$formsource = JPATH_PLUGINS . '/editors/tinymce/form/setoptions.xml';
// Preload an old params for B/C
$setParams = new stdClass;
if (!empty($paramsAll->html_width) && empty($paramsAll->configuration['setoptions']))
{
$plugin = JPluginHelper::getPlugin('editors', 'tinymce');
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_TINY_LEGACY_WARNING', '#'), 'warning');
if (is_object($plugin) && !empty($plugin->params))
{
$setParams = (object) json_decode($plugin->params);
}
}
// Collect already used groups
$groupsInUse = array();
// Prepare the Set forms, for the set options
foreach (array_keys($data['setsNames']) as $num)
{
$formname = 'set.form.' . $num;
$control = $this->name . '[setoptions][' . $num . ']';
$setsForms[$num] = JForm::getInstance($formname, $formsource, array('control' => $control));
// Check whether we already have saved values or it first time or even old params
if (empty($this->value['setoptions'][$num]))
{
$formValues = $setParams;
/*
* Predefine group:
* Set 0: for Administrator, Editor, Super Users (4,7,8)
* Set 1: for Registered, Manager (2,6), all else are public
*/
$formValues->access = !$num ? array(4,7,8) : ($num === 1 ? array(2,6) : array());
// Assign Public to the new Set, but only when it not in use already
if (empty($formValues->access) && !in_array(1, $groupsInUse))
{
$formValues->access = array(1);
}
}
else
{
$formValues = (object) $this->value['setoptions'][$num];
}
// Collect already used groups
if (!empty($formValues->access))
{
$groupsInUse = array_merge($groupsInUse, $formValues->access);
}
// Bind the values
$setsForms[$num]->bind($formValues);
}
krsort($data['setsNames']);
$data['setsForms'] = $setsForms;
// Check for TinyMCE language file
$language = JFactory::getLanguage();
$languageFile1 = 'media/editors/tinymce/langs/' . $language->getTag() . '.js';
$languageFile2 = 'media/editors/tinymce/langs/' . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . '.js';
$data['languageFile'] = '';
if (file_exists(JPATH_ROOT . '/' . $languageFile1))
{
$data['languageFile'] = $languageFile1;
}
elseif (file_exists(JPATH_ROOT . '/' . $languageFile2))
{
$data['languageFile'] = $languageFile2;
}
return $data;
}
}
The same content is in 3 releases, Joomla 3.7.0-alpha2 to 3.7.0-beta2. See them all, or every version of this file.