Spade
Mini Shell
codemirror/codemirror.php000064400000024510151167742650011607
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
/**
* CodeMirror Editor Plugin.
*
* @since 1.6
*/
class PlgEditorCodemirror extends JPlugin
{
/**
* Affects constructor behavior. If true, language files will be loaded
automatically.
*
* @var boolean
* @since 3.1.4
*/
protected $autoloadLanguage = true;
/**
* Mapping of syntax to CodeMirror modes.
*
* @var array
*/
protected $modeAlias = array();
/**
* Initialises the Editor.
*
* @return void
*/
public function onInit()
{
static $done = false;
// Do this only once.
if ($done)
{
return;
}
$done = true;
// Most likely need this later
$doc = JFactory::getDocument();
// Codemirror shall have its own group of plugins to modify and extend
its behavior
JPluginHelper::importPlugin('editors_codemirror');
$dispatcher = JEventDispatcher::getInstance();
// At this point, params can be modified by a plugin before going to the
layout renderer.
$dispatcher->trigger('onCodeMirrorBeforeInit',
array(&$this->params));
$displayData = (object) array('params' =>
$this->params);
// We need to do output buffering here because layouts may actually
'echo' things which we do not want.
ob_start();
JLayoutHelper::render('editors.codemirror.init', $displayData,
__DIR__ . '/layouts');
ob_end_clean();
$font = $this->params->get('fontFamily', '0');
$fontInfo = $this->getFontInfo($font);
if (isset($fontInfo))
{
if (isset($fontInfo->url))
{
$doc->addStyleSheet($fontInfo->url);
}
if (isset($fontInfo->css))
{
$displayData->fontFamily = $fontInfo->css .
'!important';
}
}
// We need to do output buffering here because layouts may actually
'echo' things which we do not want.
ob_start();
JLayoutHelper::render('editors.codemirror.styles',
$displayData, __DIR__ . '/layouts');
ob_end_clean();
$dispatcher->trigger('onCodeMirrorAfterInit',
array(&$this->params));
}
/**
* Copy editor content to form field.
*
* @param string $id The id of the editor field.
*
* @return string Javascript
*
* @deprecated 4.0 Code executes directly on submit
*/
public function onSave($id)
{
return sprintf('document.getElementById(%1$s).value =
Joomla.editors.instances[%1$s].getValue();', json_encode((string)
$id));
}
/**
* Get the editor content.
*
* @param string $id The id of the editor field.
*
* @return string Javascript
*
* @deprecated 4.0 Use directly the returned code
*/
public function onGetContent($id)
{
return sprintf('Joomla.editors.instances[%1$s].getValue();',
json_encode((string) $id));
}
/**
* Set the editor content.
*
* @param string $id The id of the editor field.
* @param string $content The content to set.
*
* @return string Javascript
*
* @deprecated 4.0 Use directly the returned code
*/
public function onSetContent($id, $content)
{
return
sprintf('Joomla.editors.instances[%1$s].setValue(%2$s);',
json_encode((string) $id), json_encode((string) $content));
}
/**
* Adds the editor specific insert method.
*
* @return void
*
* @deprecated 4.0 Code is loaded in the init script
*/
public function onGetInsertMethod()
{
static $done = false;
// Do this only once.
if ($done)
{
return true;
}
$done = true;
JFactory::getDocument()->addScriptDeclaration("
;function jInsertEditorText(text, editor) {
Joomla.editors.instances[editor].replaceSelection(text); }
");
return true;
}
/**
* Display the editor area.
*
* @param string $name The control name.
* @param string $content The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param int $col The number of columns for the textarea.
* @param int $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be
displayed.
* @param string $id An optional ID for the textarea (note:
since 1.6). If not supplied the name is used.
* @param string $asset Not used.
* @param object $author Not used.
* @param array $params Associative array of editor parameters.
*
* @return string HTML
*/
public function onDisplay(
$name, $content, $width, $height, $col, $row, $buttons = true, $id =
null, $asset = null, $author = null, $params = array())
{
// True if a CodeMirror already has autofocus. Prevent multiple
autofocuses.
static $autofocused;
$id = empty($id) ? $name : $id;
// Must pass the field id to the buttons in this editor.
$buttons = $this->displayButtons($id, $buttons, $asset, $author);
// Only add "px" to width and height if they are not given as a
percentage.
$width .= is_numeric($width) ? 'px' : '';
$height .= is_numeric($height) ? 'px' : '';
// Options for the CodeMirror constructor.
$options = new stdClass;
// Is field readonly?
if (!empty($params['readonly']))
{
$options->readOnly = 'nocursor';
}
// Should we focus on the editor on load?
if (!$autofocused)
{
$options->autofocus = isset($params['autofocus']) ? (bool)
$params['autofocus'] : false;
$autofocused = $options->autofocus;
}
$options->lineWrapping = (boolean)
$this->params->get('lineWrapping', 1);
// Add styling to the active line.
$options->styleActiveLine = (boolean)
$this->params->get('activeLine', 1);
// Do we highlight selection matches?
if ($this->params->get('selectionMatches', 1))
{
$options->highlightSelectionMatches = array(
'showToken' => true,
'annotateScrollbar' => true,
);
}
// Do we use line numbering?
if ($options->lineNumbers = (boolean)
$this->params->get('lineNumbers', 1))
{
$options->gutters[] = 'CodeMirror-linenumbers';
}
// Do we use code folding?
if ($options->foldGutter = (boolean)
$this->params->get('codeFolding', 1))
{
$options->gutters[] = 'CodeMirror-foldgutter';
}
// Do we use a marker gutter?
if ($options->markerGutter = (boolean)
$this->params->get('markerGutter',
$this->params->get('marker-gutter', 1)))
{
$options->gutters[] = 'CodeMirror-markergutter';
}
// Load the syntax mode.
$syntax = !empty($params['syntax'])
? $params['syntax']
: $this->params->get('syntax', 'html');
$options->mode = isset($this->modeAlias[$syntax]) ?
$this->modeAlias[$syntax] : $syntax;
// Load the theme if specified.
if ($theme = $this->params->get('theme'))
{
$options->theme = $theme;
JHtml::_('stylesheet',
$this->params->get('basePath',
'media/editors/codemirror/') . 'theme/' . $theme .
'.css', array('version' => 'auto'));
}
// Special options for tagged modes (xml/html).
if (in_array($options->mode, array('xml', 'html',
'php')))
{
// Autogenerate closing tags (html/xml only).
$options->autoCloseTags = (boolean)
$this->params->get('autoCloseTags', 1);
// Highlight the matching tag when the cursor is in a tag (html/xml
only).
$options->matchTags = (boolean)
$this->params->get('matchTags', 1);
}
// Special options for non-tagged modes.
if (!in_array($options->mode, array('xml',
'html')))
{
// Autogenerate closing brackets.
$options->autoCloseBrackets = (boolean)
$this->params->get('autoCloseBrackets', 1);
// Highlight the matching bracket.
$options->matchBrackets = (boolean)
$this->params->get('matchBrackets', 1);
}
$options->scrollbarStyle =
$this->params->get('scrollbarStyle', 'native');
// KeyMap settings.
$options->keyMap = $this->params->get('keyMap',
false);
// Support for older settings.
if ($options->keyMap === false)
{
$options->keyMap =
$this->params->get('vimKeyBinding', 0) ? 'vim' :
'default';
}
if ($options->keyMap && $options->keyMap !=
'default')
{
$this->loadKeyMap($options->keyMap);
}
$displayData = (object) array(
'options' => $options,
'params' => $this->params,
'name' => $name,
'id' => $id,
'cols' => $col,
'rows' => $row,
'content' => $content,
'buttons' => $buttons
);
$dispatcher = JEventDispatcher::getInstance();
// At this point, displayData can be modified by a plugin before going to
the layout renderer.
$results = $dispatcher->trigger('onCodeMirrorBeforeDisplay',
array(&$displayData));
$results[] =
JLayoutHelper::render('editors.codemirror.element', $displayData,
__DIR__ . '/layouts', array('debug' => JDEBUG));
foreach ($dispatcher->trigger('onCodeMirrorAfterDisplay',
array(&$displayData)) as $result)
{
$results[] = $result;
}
return implode("\n", $results);
}
/**
* Displays the editor buttons.
*
* @param string $name Button name.
* @param mixed $buttons [array with button objects | boolean true to
display buttons]
* @param mixed $asset Unused.
* @param mixed $author Unused.
*
* @return string HTML
*/
protected function displayButtons($name, $buttons, $asset, $author)
{
$return = '';
$args = array(
'name' => $name,
'event' => 'onGetInsertMethod'
);
$results = (array) $this->update($args);
if ($results)
{
foreach ($results as $result)
{
if (is_string($result) && trim($result))
{
$return .= $result;
}
}
}
if (is_array($buttons) || (is_bool($buttons) && $buttons))
{
$buttons = $this->_subject->getButtons($name, $buttons, $asset,
$author);
$return .= JLayoutHelper::render('joomla.editors.buttons',
$buttons);
}
return $return;
}
/**
* Gets font info from the json data file
*
* @param string $font A key from the $fonts array.
*
* @return object
*/
protected function getFontInfo($font)
{
static $fonts;
if (!$fonts)
{
$fonts = json_decode(file_get_contents(__DIR__ .
'/fonts.json'), true);
}
return isset($fonts[$font]) ? (object) $fonts[$font] : null;
}
/**
* Loads a keyMap file
*
* @param string $keyMap The name of a keyMap file to load.
*
* @return void
*/
protected function loadKeyMap($keyMap)
{
$basePath = $this->params->get('basePath',
'media/editors/codemirror/');
$ext = JDEBUG ? '.js' : '.min.js';
JHtml::_('script', $basePath . 'keymap/' . $keyMap .
$ext, array('version' => 'auto'));
}
}
codemirror/codemirror.xml000064400000024674151167742650011633
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension version="3.2" type="plugin"
group="editors" method="upgrade">
<name>plg_editors_codemirror</name>
<version>5.56.0</version>
<creationDate>28 March 2011</creationDate>
<author>Marijn Haverbeke</author>
<authorEmail>marijnh@gmail.com</authorEmail>
<authorUrl>https://codemirror.net/</authorUrl>
<copyright>Copyright (C) 2014 - 2017 by Marijn Haverbeke
<marijnh@gmail.com> and others</copyright>
<license>MIT license: https://codemirror.net/LICENSE</license>
<description>PLG_CODEMIRROR_XML_DESCRIPTION</description>
<files>
<filename
plugin="codemirror">codemirror.php</filename>
<filename>styles.css</filename>
<filename>styles.min.css</filename>
<filename>fonts.json</filename>
<filename>fonts.php</filename>
</files>
<languages>
<language
tag="en-GB">en-GB.plg_editors_codemirror.ini</language>
<language
tag="en-GB">en-GB.plg_editors_codemirror.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="lineNumbers"
type="radio"
label="PLG_CODEMIRROR_FIELD_LINENUMBERS_LABEL"
description="PLG_CODEMIRROR_FIELD_LINENUMBERS_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="codeFolding"
type="radio"
label="PLG_CODEMIRROR_FIELD_CODEFOLDING_LABEL"
description="PLG_CODEMIRROR_FIELD_CODEFOLDING_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="markerGutter"
type="radio"
label="PLG_CODEMIRROR_FIELD_MARKERGUTTER_LABEL"
description="PLG_CODEMIRROR_FIELD_MARKERGUTTER_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="lineWrapping"
type="radio"
label="PLG_CODEMIRROR_FIELD_LINEWRAPPING_LABEL"
description="PLG_CODEMIRROR_FIELD_LINEWRAPPING_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="activeLine"
type="radio"
label="PLG_CODEMIRROR_FIELD_ACTIVELINE_LABEL"
description="PLG_CODEMIRROR_FIELD_ACTIVELINE_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="selectionMatches"
type="radio"
label="PLG_CODEMIRROR_FIELD_SELECTIONMATCHES_LABEL"
description="PLG_CODEMIRROR_FIELD_SELECTIONMATCHES_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="matchTags"
type="radio"
label="PLG_CODEMIRROR_FIELD_MATCHTAGS_LABEL"
description="PLG_CODEMIRROR_FIELD_MATCHTAGS_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="matchBrackets"
type="radio"
label="PLG_CODEMIRROR_FIELD_MATCHBRACKETS_LABEL"
description="PLG_CODEMIRROR_FIELD_MATCHBRACKETS_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="autoCloseTags"
type="radio"
label="PLG_CODEMIRROR_FIELD_AUTOCLOSETAGS_LABEL"
description="PLG_CODEMIRROR_FIELD_AUTOCLOSETAGS_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="autoCloseBrackets"
type="radio"
label="PLG_CODEMIRROR_FIELD_AUTOCLOSEBRACKET_LABEL"
description="PLG_CODEMIRROR_FIELD_AUTOCLOSEBRACKET_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="keyMap"
type="list"
label="PLG_CODEMIRROR_FIELD_KEYMAP_LABEL"
description="PLG_CODEMIRROR_FIELD_KEYMAP_DESC"
default=""
>
<option value="">JDEFAULT</option>
<option
value="emacs">PLG_CODEMIRROR_FIELD_KEYMAP_EMACS</option>
<option
value="sublime">PLG_CODEMIRROR_FIELD_KEYMAP_SUBLIME</option>
<option
value="vim">PLG_CODEMIRROR_FIELD_KEYMAP_VIM</option>
</field>
<field
name="fullScreen"
type="list"
label="PLG_CODEMIRROR_FIELD_FULLSCREEN_LABEL"
description="PLG_CODEMIRROR_FIELD_FULLSCREEN_DESC"
default="F10"
>
<option value="F1">F1</option>
<option value="F2">F2</option>
<option value="F3">F3</option>
<option value="F4">F4</option>
<option value="F5">F5</option>
<option value="F6">F6</option>
<option value="F7">F7</option>
<option value="F8">F8</option>
<option value="F9">F9</option>
<option value="F10">F10</option>
<option value="F11">F11</option>
<option value="F12">F12</option>
</field>
<field
name="fullScreenMod"
type="checkboxes"
label="PLG_CODEMIRROR_FIELD_FULLSCREEN_MOD_LABEL"
description="PLG_CODEMIRROR_FIELD_FULLSCREEN_MOD_DESC"
>
<option
value="Shift">PLG_CODEMIRROR_FIELD_VALUE_FULLSCREEN_MOD_SHIFT</option>
<option
value="Cmd">PLG_CODEMIRROR_FIELD_VALUE_FULLSCREEN_MOD_CMD</option>
<option
value="Ctrl">PLG_CODEMIRROR_FIELD_VALUE_FULLSCREEN_MOD_CTRL</option>
<option
value="Alt">PLG_CODEMIRROR_FIELD_VALUE_FULLSCREEN_MOD_ALT</option>
</field>
<field
name="basePath"
type="hidden"
default="media/editors/codemirror/"
/>
<field
name="modePath"
type="hidden"
default="media/editors/codemirror/mode/%N/%N"
/>
</fieldset>
<fieldset name="appearance"
label="PLG_CODEMIRROR_FIELDSET_APPEARANCE_OPTIONS_LABEL"
addfieldpath="plugins/editors/codemirror">
<field
name="theme"
type="filelist"
label="PLG_CODEMIRROR_FIELD_THEME_LABEL"
description="PLG_CODEMIRROR_FIELD_THEME_DESC"
default=""
filter="\.css$"
stripext="true"
hide_none="true"
hide_default="false"
directory="media/editors/codemirror/theme"
/>
<field
name="activeLineColor"
type="color"
label="PLG_CODEMIRROR_FIELD_ACTIVELINE_COLOR_LABEL"
description="PLG_CODEMIRROR_FIELD_ACTIVELINE_COLOR_DESC"
default="#a4c2eb"
filter="color"
/>
<field
name="highlightMatchColor"
type="color"
label="PLG_CODEMIRROR_FIELD_HIGHLIGHT_MATCH_COLOR_LABEL"
description="PLG_CODEMIRROR_FIELD_HIGHLIGHT_MATCH_COLOR_DESC"
default="#fa542f"
filter="color"
/>
<field
name="fontFamily"
type="fonts"
label="PLG_CODEMIRROR_FIELD_FONT_FAMILY_LABEL"
description="PLG_CODEMIRROR_FIELD_FONT_FAMILY_DESC"
default="0"
>
<option
value="0">PLG_CODEMIRROR_FIELD_VALUE_FONT_FAMILY_DEFAULT</option>
</field>
<field
name="fontSize"
type="integer"
label="PLG_CODEMIRROR_FIELD_FONT_SIZE_LABEL"
description="PLG_CODEMIRROR_FIELD_FONT_SIZE_DESC"
first="6"
last="16"
step="1"
default="13"
filter="integer"
/>
<field
name="lineHeight"
type="list"
label="PLG_CODEMIRROR_FIELD_LINE_HEIGHT_LABEL"
description="PLG_CODEMIRROR_FIELD_LINE_HEIGHT_DESC"
default="1.2"
filter="float"
>
<option value="1">1</option>
<option value="1.1">1.1</option>
<option value="1.2">1.2</option>
<option value="1.3">1.3</option>
<option value="1.4">1.4</option>
<option value="1.5">1.5</option>
<option value="1.6">1.6</option>
<option value="1.7">1.7</option>
<option value="1.8">1.8</option>
<option value="1.9">1.9</option>
<option value="2">2</option>
</field>
<field
name="scrollbarStyle"
type="radio"
label="PLG_CODEMIRROR_FIELD_VALUE_SCROLLBARSTYLE_LABEL"
description="PLG_CODEMIRROR_FIELD_VALUE_SCROLLBARSTYLE_DESC"
class="btn-group btn-group-yesno"
default="native"
>
<option
value="native">PLG_CODEMIRROR_FIELD_VALUE_SCROLLBARSTYLE_DEFAULT</option>
<option
value="simple">PLG_CODEMIRROR_FIELD_VALUE_SCROLLBARSTYLE_SIMPLE</option>
<option
value="overlay">PLG_CODEMIRROR_FIELD_VALUE_SCROLLBARSTYLE_OVERLAY</option>
</field>
<field
name="preview"
type="editor"
label="PLG_CODEMIRROR_FIELD_PREVIEW_LABEL"
description="PLG_CODEMIRROR_FIELD_PREVIEW_DESC"
editor="codemirror"
filter="unset"
buttons="false"
>
<default>
<![CDATA[
<script type="text/javascript">
jQuery(function ($) {
$('.hello').html('Hello World');
});
</script>
<style type="text/css">
h1 {
background-clip: border-box;
background-color: #cacaff;
background-image: linear-gradient(45deg, transparent 0px, transparent
30px, #ababff 30px, #ababff 60px, transparent 60px);
background-repeat: repeat-x;
background-size: 90px 100%;
border: 1px solid #8989ff;
border-radius: 10px;
color: #333;
padding: 0 15px;
}
</style>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
a ornare lectus, quis semper urna. Vestibulum ante ipsum primis in faucibus
orci luctus et ultrices posuere cubilia Curae; Vivamus interdum metus id
elit rutrum sollicitudin. Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas. Aliquam in fermentum risus, id
facilisis nulla. Phasellus gravida erat sed ullamcorper accumsan. Donec
blandit sem eget sem congue, a varius sapien semper.</p>
<p>Integer euismod tempor convallis. Nullam porttitor et ex ac
fringilla. Quisque facilisis est ac erat condimentum malesuada. Aenean
commodo quam odio, tincidunt ultricies mauris suscipit et.</p>
<ul>
<li>Vivamus ultrices ligula a odio lacinia pellentesque.</li>
<li>Curabitur iaculis arcu pharetra, mollis turpis id, commodo
erat.</li>
<li>Etiam consequat enim quis faucibus interdum.</li>
<li>Morbi in ipsum pulvinar, eleifend lorem sit amet, euismod
magna.</li>
<li>Donec consectetur lacus vitae eros euismod porta.</li>
</ul>
</div>
]]>
</default>
</field>
</fieldset>
</fields>
</config>
</extension>
codemirror/fonts.json000064400000006055151167742650010761 0ustar00{
"anonymous_pro": {
"name": "Anonymous Pro",
"url":
"https://fonts.googleapis.com/css?family=Anonymous+Pro",
"css": "'Anonymous Pro', monospace"
},
"cousine": {
"name": "Cousine",
"url":
"https://fonts.googleapis.com/css?family=Cousine",
"css": "Cousine, monospace"
},
"cutive_mono": {
"name": "Cutive Mono",
"url":
"https://fonts.googleapis.com/css?family=Cutive+Mono",
"css": "'Cutive Mono', monospace"
},
"droid_sans_mono": {
"name": "Droid Sans Mono",
"url":
"https://fonts.googleapis.com/css?family=Droid+Sans+Mono",
"css": "'Droid Sans Mono', monospace"
},
"fira_mono": {
"name": "Fira Mono",
"url":
"https://fonts.googleapis.com/css?family=Fira+Mono",
"css": "'Fira Mono', monospace"
},
"ibm_plex_mono": {
"name": "IBM Plex Mono",
"url":
"https://fonts.googleapis.com/css?family=IBM+Plex+Mono",
"css": "'IBM Plex Mono', monospace;"
},
"inconsolata": {
"name": "Inconsolata",
"url":
"https://fonts.googleapis.com/css?family=Inconsolata",
"css": "Inconsolata, monospace"
},
"lekton": {
"name": "Lekton",
"url":
"https://fonts.googleapis.com/css?family=Lekton",
"css": "Lekton, monospace"
},
"nanum_gothic_coding": {
"name": "Nanum Gothic Coding",
"url":
"https://fonts.googleapis.com/css?family=Nanum+Gothic+Coding",
"css": "'Nanum Gothic Coding', monospace"
},
"nova_mono": {
"name": "Nova Mono",
"url":
"https://fonts.googleapis.com/css?family=Nova+Mono",
"css": "'Nova Mono', monospace"
},
"overpass_mono": {
"name": "Overpass Mono",
"url":
"https://fonts.googleapis.com/css?family=Overpass+Mono",
"css": "'Overpass Mono', monospace"
},
"oxygen_mono": {
"name": "Oxygen Mono",
"url":
"https://fonts.googleapis.com/css?family=Oxygen+Mono",
"css": "'Oxygen Mono', monospace"
},
"press_start_2p": {
"name": "Press Start 2P",
"url":
"https://fonts.googleapis.com/css?family=Press+Start+2P",
"css": "'Press Start 2P', monospace"
},
"pt_mono": {
"name": "PT Mono",
"url":
"https://fonts.googleapis.com/css?family=PT+Mono",
"css": "'PT Mono', monospace"
},
"roboto_mono": {
"name": "Roboto Mono",
"url":
"https://fonts.googleapis.com/css?family=Roboto+Mono",
"css": "'Roboto Mono', monospace"
},
"rubik_mono_one": {
"name": "Rubik Mono One",
"url":
"https://fonts.googleapis.com/css?family=Rubik+Mono+One",
"css": "'Rubik Mono One', monospace"
},
"share_tech_mono": {
"name": "Share Tech Mono",
"url":
"https://fonts.googleapis.com/css?family=Share+Tech+Mono",
"css": "'Share Tech Mono', monospace"
},
"source_code_pro": {
"name": "Source Code Pro",
"url":
"https://fonts.googleapis.com/css?family=Source+Code+Pro",
"css": "'Source Code Pro', monospace"
},
"space_mono": {
"name": "Space Mono",
"url":
"https://fonts.googleapis.com/css?family=Space+Mono",
"css": "'Space Mono', monospace"
},
"ubuntu_mono": {
"name": "Ubuntu Mono",
"url":
"https://fonts.googleapis.com/css?family=Ubuntu+Mono",
"css": "'Ubuntu Mono', monospace"
},
"vt323": {
"name": "VT323",
"url":
"https://fonts.googleapis.com/css?family=VT323",
"css": "'VT323', monospace"
}
}
codemirror/fonts.php000064400000002121151167742650010565 0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Supports an HTML select list of fonts
*
* @package Joomla.Plugin
* @subpackage Editors.codemirror
* @since 3.4
*/
class JFormFieldFonts extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.4
*/
protected $type = 'Fonts';
/**
* Method to get the list of fonts field options.
*
* @return array The field option objects.
*
* @since 3.4
*/
protected function getOptions()
{
$fonts = json_decode(file_get_contents(__DIR__ .
'/fonts.json'));
$options = array();
foreach ($fonts as $key => $info)
{
$options[] = JHtml::_('select.option', $key, $info->name);
}
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(), $options);
}
}
codemirror/layouts/editors/codemirror/element.php000064400000002067151167742650016414
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
$options = $displayData->options;
$params = $displayData->params;
$name = $displayData->name;
$id = $displayData->id;
$cols = $displayData->cols;
$rows = $displayData->rows;
$content = $displayData->content;
$buttons = $displayData->buttons;
$modifier = $params->get('fullScreenMod', array()) ?
implode(' + ', $params->get('fullScreenMod',
array())) . ' + ' : '';
?>
<p class="label">
<?php echo
JText::sprintf('PLG_CODEMIRROR_TOGGLE_FULL_SCREEN', $modifier,
$params->get('fullScreen', 'F10')); ?>
</p>
<?php
echo '<textarea class="codemirror-source"
name="', $name,
'" id="', $id,
'" cols="', $cols,
'" rows="', $rows,
'" data-options="',
htmlspecialchars(json_encode($options)),
'">', $content, '</textarea>';
?>
<?php echo $buttons; ?>
codemirror/layouts/editors/codemirror/init.php000064400000007260151167742650015726
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
$params = $displayData->params;
$basePath = $params->get('basePath',
'media/editors/codemirror/');
$modePath = $params->get('modePath',
'media/editors/codemirror/mode/%N/%N');
$extJS = JDEBUG ? '.js' : '.min.js';
$extCSS = JDEBUG ? '.css' : '.min.css';
JHtml::_('script', $basePath . 'lib/codemirror' .
$extJS, array('version' => 'auto'));
JHtml::_('script', $basePath . 'lib/addons' . $extJS,
array('version' => 'auto'));
JHtml::_('stylesheet', $basePath . 'lib/codemirror' .
$extCSS, array('version' => 'auto'));
JHtml::_('stylesheet', $basePath . 'lib/addons' .
$extCSS, array('version' => 'auto'));
$fskeys = $params->get('fullScreenMod', array());
$fskeys[] = $params->get('fullScreen',
'F10');
$fullScreenCombo = implode('-', $fskeys);
$fsCombo = json_encode($fullScreenCombo);
$modPath = json_encode(JUri::root(true) . '/' . $modePath
. $extJS);
JFactory::getDocument()->addScriptDeclaration(
<<<JS
;(function (cm, $) {
cm.commands.toggleFullScreen = function (cm) {
cm.setOption('fullScreen',
!cm.getOption('fullScreen'));
};
cm.commands.closeFullScreen = function (cm) {
cm.getOption('fullScreen') &&
cm.setOption('fullScreen', false);
};
cm.keyMap.default['Ctrl-Q'] = 'toggleFullScreen';
cm.keyMap.default[$fsCombo] = 'toggleFullScreen';
cm.keyMap.default['Esc'] = 'closeFullScreen';
// For mode autoloading.
cm.modeURL = $modPath;
// Fire this function any time an editor is created.
cm.defineInitHook(function (editor)
{
// Try to set up the mode
var mode = cm.findModeByMIME(editor.options.mode || '') ||
cm.findModeByName(editor.options.mode || '') ||
cm.findModeByExtension(editor.options.mode || '');
cm.autoLoadMode(editor, mode ? mode.mode : editor.options.mode);
if (mode && mode.mime)
{
editor.setOption('mode', mode.mime);
}
// Handle gutter clicks (place or remove a marker).
editor.on('gutterClick', function (ed, n, gutter) {
if (gutter != 'CodeMirror-markergutter') { return; }
var info = ed.lineInfo(n),
hasMarker = !!info.gutterMarkers &&
!!info.gutterMarkers['CodeMirror-markergutter'];
ed.setGutterMarker(n, 'CodeMirror-markergutter', hasMarker ?
null : makeMarker());
});
// jQuery's ready function.
$(function () {
// Some browsers do something weird with the fieldset which
doesn't work well with CodeMirror. Fix it.
$(editor.getWrapperElement()).parent('fieldset').css('min-width',
0);
// Listen for Bootstrap's 'shown' event. If this editor
was in a hidden element when created, it may need to be refreshed.
$(document.body).on('shown shown.bs.tab shown.bs.modal',
function () { editor.refresh(); });
});
});
function makeMarker()
{
var marker = document.createElement('div');
marker.className = 'CodeMirror-markergutter-mark';
return marker;
}
// Initialize any CodeMirrors on page load and when a subform is added
$(function ($) {
initCodeMirror();
$('body').on('subform-row-add', initCodeMirror);
});
function initCodeMirror(event, container)
{
container = container || document;
$(container).find('textarea.codemirror-source').each(function
() {
var input = $(this).removeClass('codemirror-source');
var id = input.prop('id');
Joomla.editors.instances[id] = cm.fromTextArea(this,
input.data('options'));
});
}
}(CodeMirror, jQuery));
JS
);
codemirror/layouts/editors/codemirror/styles.php000064400000004517151167742650016310
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
$params = $displayData->params;
$fontFamily = isset($displayData->fontFamily) ?
$displayData->fontFamily : 'monospace';
$fontSize = $params->get('fontSize', 13) . 'px;';
$lineHeight = $params->get('lineHeight', 1.2) .
'em;';
// Set the active line color.
$color = $params->get('activeLineColor',
'#a4c2eb');
$r = hexdec($color[1] . $color[2]);
$g = hexdec($color[3] . $color[4]);
$b = hexdec($color[5] . $color[6]);
$activeLineColor = 'rgba(' . $r . ', ' . $g . ',
' . $b . ', .5)';
// Set the color for matched tags.
$color = $params->get('highlightMatchColor',
'#fa542f');
$r = hexdec($color[1] . $color[2]);
$g = hexdec($color[3] . $color[4]);
$b = hexdec($color[5] . $color[6]);
$highlightMatchColor = 'rgba(' . $r . ', ' . $g .
', ' . $b . ', .5)';
JFactory::getDocument()->addStyleDeclaration(
<<<CSS
.CodeMirror
{
font-family: $fontFamily;
font-size: $fontSize;
line-height: $lineHeight;
border: 1px solid #ccc;
}
/* In order to hid the Joomla menu */
.CodeMirror-fullscreen
{
z-index: 1040;
}
/* Make the fold marker a little more visible/nice */
.CodeMirror-foldmarker
{
background: rgb(255, 128, 0);
background: rgba(255, 128, 0, .5);
box-shadow: inset 0 0 2px rgba(255, 255, 255, .5);
font-family: serif;
font-size: 90%;
border-radius: 1em;
padding: 0 1em;
vertical-align: middle;
color: white;
text-shadow: none;
}
.CodeMirror-foldgutter, .CodeMirror-markergutter { width: 1.2em;
text-align: center; }
.CodeMirror-markergutter { cursor: pointer; }
.CodeMirror-markergutter-mark { cursor: pointer; text-align: center; }
.CodeMirror-markergutter-mark:after { content: "\25CF"; }
.CodeMirror-activeline-background { background: $activeLineColor; }
.CodeMirror-matchingtag { background: $highlightMatchColor; }
.cm-matchhighlight {background-color: $highlightMatchColor; }
.CodeMirror-selection-highlight-scrollbar {background-color:
$highlightMatchColor; }
CSS
);
none/none.php000064400000007602151167742650007176 0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.none
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Plain Textarea Editor Plugin
*
* @since 1.5
*/
class PlgEditorNone extends JPlugin
{
/**
* Method to handle the onInitEditor event.
* - Initialises the Editor
*
* @return void
*
* @since 1.5
*/
public function onInit()
{
JHtml::_('script', 'editors/none/none.min.js',
array('version' => 'auto', 'relative'
=> true));
}
/**
* Copy editor content to form field.
*
* Not applicable in this editor.
*
* @param string $editor the editor id
*
* @return void
*
* @deprecated 4.0 Use directly the returned code
*/
public function onSave($editor)
{
}
/**
* Get the editor content.
*
* @param string $id The id of the editor field.
*
* @return string
*
* @deprecated 4.0 Use directly the returned code
*/
public function onGetContent($id)
{
return 'Joomla.editors.instances[' . json_encode($id) .
'].getValue();';
}
/**
* Set the editor content.
*
* @param string $id The id of the editor field.
* @param string $html The content to set.
*
* @return string
*
* @deprecated 4.0 Use directly the returned code
*/
public function onSetContent($id, $html)
{
return 'Joomla.editors.instances[' . json_encode($id) .
'].setValue(' . json_encode($html) . ');';
}
/**
* Inserts html code into the editor
*
* @param string $id The id of the editor field
*
* @return void
*
* @deprecated 4.0
*/
public function onGetInsertMethod($id)
{
}
/**
* Display the editor area.
*
* @param string $name The control name.
* @param string $content The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param integer $col The number of columns for the textarea.
* @param integer $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be
displayed.
* @param string $id An optional ID for the textarea (note:
since 1.6). If not supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
*
* @return string
*/
public function onDisplay($name, $content, $width, $height, $col, $row,
$buttons = true,
$id = null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
$id = $name;
}
// Only add "px" to width and height if they are not given as a
percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
$readonly = !empty($params['readonly']) ? ' readonly
disabled' : '';
$editor = '<div class="js-editor-none">'
. '<textarea name="' . $name . '"
id="' . $id . '" cols="' . $col .
'" rows="' . $row
. '" style="width: ' . $width . '; height:
' . $height . ';"' . $readonly . '>' .
$content . '</textarea>'
. $this->_displayButtons($id, $buttons, $asset, $author)
. '</div>';
return $editor;
}
/**
* Displays the editor buttons.
*
* @param string $name The control name.
* @param mixed $buttons [array with button objects | boolean true to
display buttons]
* @param string $asset The object asset
* @param object $author The author.
*
* @return void|string HTML
*/
public function _displayButtons($name, $buttons, $asset, $author)
{
if (is_array($buttons) || (is_bool($buttons) && $buttons))
{
$buttons = $this->_subject->getButtons($name, $buttons, $asset,
$author);
return JLayoutHelper::render('joomla.editors.buttons',
$buttons);
}
}
}
none/none.xml000064400000001431151167742660007202 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin"
group="editors" method="upgrade">
<name>plg_editors_none</name>
<version>3.0.0</version>
<creationDate>September 2005</creationDate>
<author>Joomla! Project</author>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<copyright>Copyright (C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<description>PLG_NONE_XML_DESCRIPTION</description>
<files>
<filename plugin="none">none.php</filename>
</files>
<languages>
<language
tag="en-GB">en-GB.plg_editors_none.ini</language>
<language
tag="en-GB">en-GB.plg_editors_none.sys.ini</language>
</languages>
</extension>
tinymce/field/skins.php000064400000002755151167742660011167
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Generates the list of options for available skins.
*
* @package Joomla.Plugin
* @subpackage Editors.tinymce
* @since 3.4
*/
class JFormFieldSkins extends JFormFieldList
{
protected $type = 'skins';
/**
* Method to get the skins options.
*
* @return array The skins option objects.
*
* @since 3.4
*/
public function getOptions()
{
$options = array();
$directories = glob(JPATH_ROOT . '/media/editors/tinymce/skins'
. '/*', GLOB_ONLYDIR);
for ($i = 0, $iMax = count($directories); $i < $iMax; ++$i)
{
$dir = basename($directories[$i]);
$options[] = JHtml::_('select.option', $i, $dir);
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* Method to get the field input markup for the list of skins.
*
* @return string The field input markup.
*
* @since 3.4
*/
protected function getInput()
{
$html = array();
// Get the field options.
$options = (array) $this->getOptions();
// Create a regular list.
$html[] = JHtml::_('select.genericlist', $options,
$this->name, '', 'value', 'text',
$this->value, $this->id);
return implode($html);
}
}
tinymce/field/tinymcebuilder.php000064400000011072151167742660013047
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2020 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';
/**
* The prepared layout data
*
* @var array
* @since 3.7.0
*/
protected $layoutData = array();
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7.0
*/
protected function getLayoutData()
{
if (!empty($this->layoutData))
{
return $this->layoutData;
}
$data = parent::getLayoutData();
$paramsAll = (object) $this->form->getValue('params');
$setsAmount = empty($paramsAll->sets_amount) ? 3 :
$paramsAll->sets_amount;
if (empty($data['value']))
{
$data['value'] = array();
}
// 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;
}
$this->layoutData = $data;
return $data;
}
}
tinymce/field/uploaddirs.php000064400000004565151167742660012207
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('folderlist');
/**
* Generates the list of directories available for drag and drop upload.
*
* @package Joomla.Plugin
* @subpackage Editors.tinymce
* @since 3.7.0
*/
class JFormFieldUploaddirs extends JFormFieldFolderList
{
protected $type = 'uploaddirs';
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.7.0
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
// Get the path in which to search for file options.
$this->directory =
JComponentHelper::getParams('com_media')->get('image_path');
$this->recursive = true;
$this->hideDefault = true;
return $return;
}
/**
* Method to get the directories options.
*
* @return array The dirs option objects.
*
* @since 3.7.0
*/
public function getOptions()
{
return parent::getOptions();
}
/**
* Method to get the field input markup for the list of directories.
*
* @return string The field input markup.
*
* @since 3.7.0
*/
protected function getInput()
{
$html = array();
// Get the field options.
$options = (array) $this->getOptions();
// Reset the non selected value to null
if ($options[0]->value === '-1')
{
$options[0]->value = '';
}
// Create a regular list.
$html[] = JHtml::_('select.genericlist', $options,
$this->name, '', 'value', 'text',
$this->value, $this->id);
return implode($html);
}
}
tinymce/form/setoptions.xml000064400000017641151167742660012140
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<field
name="access"
type="usergrouplist"
label="PLG_TINY_FIELD_SETACCESS_LABEL"
description="PLG_TINY_FIELD_SETACCESS_DESC"
multiple="true"
class="access-select"
labelclass="label label-success"
/>
<field
name="skins"
type="note"
label="PLG_TINY_FIELD_SKIN_INFO_LABEL"
description="PLG_TINY_FIELD_SKIN_INFO_DESC"
/>
<field
name="skin"
type="skins"
label="PLG_TINY_FIELD_SKIN_LABEL"
description="PLG_TINY_FIELD_SKIN_DESC"
/>
<field
name="skin_admin"
type="skins"
label="PLG_TINY_FIELD_SKIN_ADMIN_LABEL"
description="PLG_TINY_FIELD_SKIN_ADMIN_DESC"
/>
<field
name="mobile"
type="radio"
label="PLG_TINY_FIELD_MOBILE_LABEL"
description="PLG_TINY_FIELD_MOBILE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="drag_drop"
type="radio"
label="PLG_TINY_FIELD_DRAG_DROP_LABEL"
description="PLG_TINY_FIELD_DRAG_DROP_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="path"
type="uploaddirs"
label="PLG_TINY_FIELD_CUSTOM_PATH_LABEL"
description="PLG_TINY_FIELD_CUSTOM_PATH_DESC"
class="input-xxlarge"
showon="drag_drop:1"
/>
<field
name="entity_encoding"
type="list"
label="PLG_TINY_FIELD_ENCODING_LABEL"
description="PLG_TINY_FIELD_ENCODING_DESC"
default="raw"
>
<option
value="named">PLG_TINY_FIELD_VALUE_NAMED</option>
<option
value="numeric">PLG_TINY_FIELD_VALUE_NUMERIC</option>
<option
value="raw">PLG_TINY_FIELD_VALUE_RAW</option>
</field>
<field
name="lang_mode"
type="radio"
label="PLG_TINY_FIELD_LANGSELECT_LABEL"
description="PLG_TINY_FIELD_LANGSELECT_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="lang_code"
type="filelist"
label="PLG_TINY_FIELD_LANGCODE_LABEL"
description="PLG_TINY_FIELD_LANGCODE_DESC"
class="inputbox"
stripext="1"
directory="media/editors/tinymce/langs/"
hide_none="1"
default="en"
hide_default="1"
filter="\.js$"
size="10"
showon="lang_mode:0"
/>
<field
name="text_direction"
type="list"
label="PLG_TINY_FIELD_DIRECTION_LABEL"
description="PLG_TINY_FIELD_DIRECTION_DESC"
default="ltr"
>
<option
value="ltr">PLG_TINY_FIELD_VALUE_LTR</option>
<option
value="rtl">PLG_TINY_FIELD_VALUE_RTL</option>
</field>
<field
name="content_css"
type="radio"
label="PLG_TINY_FIELD_CSS_LABEL"
description="PLG_TINY_FIELD_CSS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="content_css_custom"
type="text"
label="PLG_TINY_FIELD_CUSTOM_CSS_LABEL"
description="PLG_TINY_FIELD_CUSTOM_CSS_DESC"
class="input-xxlarge"
/>
<field
name="relative_urls"
type="list"
label="PLG_TINY_FIELD_URLS_LABEL"
description="PLG_TINY_FIELD_URLS_DESC"
default="1"
>
<option
value="0">PLG_TINY_FIELD_VALUE_ABSOLUTE</option>
<option
value="1">PLG_TINY_FIELD_VALUE_RELATIVE</option>
</field>
<field
name="newlines"
type="list"
label="PLG_TINY_FIELD_NEWLINES_LABEL"
description="PLG_TINY_FIELD_NEWLINES_DESC"
default="0"
>
<option
value="1">PLG_TINY_FIELD_VALUE_BR</option>
<option
value="0">PLG_TINY_FIELD_VALUE_P</option>
</field>
<field
name="use_config_textfilters"
type="radio"
label="PLG_TINY_CONFIG_TEXTFILTER_ACL_LABEL"
description="PLG_TINY_CONFIG_TEXTFILTER_ACL_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="invalid_elements"
type="text"
label="PLG_TINY_FIELD_PROHIBITED_LABEL"
description="PLG_TINY_FIELD_PROHIBITED_DESC"
showon="use_config_textfilters:0"
default="script,applet,iframe"
class="input-xxlarge"
/>
<field
name="valid_elements"
type="text"
label="PLG_TINY_FIELD_VALIDELEMENTS_LABEL"
description="PLG_TINY_FIELD_VALIDELEMENTS_DESC"
showon="use_config_textfilters:0"
class="input-xxlarge"
/>
<field
name="extended_elements"
type="text"
label="PLG_TINY_FIELD_ELEMENTS_LABEL"
description="PLG_TINY_FIELD_ELEMENTS_DESC"
showon="use_config_textfilters:0"
class="input-xxlarge"
/>
<!-- Extra plugins -->
<field
name="resizing"
type="radio"
label="PLG_TINY_FIELD_RESIZING_LABEL"
description="PLG_TINY_FIELD_RESIZING_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="resize_horizontal"
type="radio"
label="PLG_TINY_FIELD_RESIZE_HORIZONTAL_LABEL"
description="PLG_TINY_FIELD_RESIZE_HORIZONTAL_DESC"
class="btn-group btn-group-yesno"
default="1"
showon="resizing:1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="element_path"
type="radio"
label="PLG_TINY_FIELD_PATH_LABEL"
description="PLG_TINY_FIELD_PATH_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="wordcount"
type="radio"
label="PLG_TINY_FIELD_WORDCOUNT_LABEL"
description="PLG_TINY_FIELD_WORDCOUNT_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="image_advtab"
type="radio"
label="PLG_TINY_FIELD_ADVIMAGE_LABEL"
description="PLG_TINY_FIELD_ADVIMAGE_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="advlist"
type="radio"
label="PLG_TINY_FIELD_ADVLIST_LABEL"
description="PLG_TINY_FIELD_ADVLIST_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="contextmenu"
type="radio"
label="PLG_TINY_FIELD_CONTEXTMENU_LABEL"
description="PLG_TINY_FIELD_CONTEXTMENU_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field
name="custom_plugin"
type="text"
label="PLG_TINY_FIELD_CUSTOMPLUGIN_LABEL"
description="PLG_TINY_FIELD_CUSTOMPLUGIN_DESC"
class="input-xxlarge"
/>
<field
name="custom_button"
type="text"
label="PLG_TINY_FIELD_CUSTOMBUTTON_LABEL"
description="PLG_TINY_FIELD_CUSTOMBUTTON_DESC"
class="input-xxlarge"
/>
</form>tinymce/tinymce.php000064400000163217151167742660010426
0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
/**
* TinyMCE Editor Plugin
*
* @since 1.5
*/
class PlgEditorTinymce extends JPlugin
{
/**
* Base path for editor files
*
* @since 3.5
*/
protected $_basePath = 'media/editors/tinymce';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Loads the application object
*
* @var JApplicationCms
* @since 3.2
*/
protected $app = null;
/**
* Initialises the Editor.
*
* @return void
*
* @since 1.5
*/
public function onInit()
{
JHtml::_('behavior.core');
JHtml::_('behavior.polyfill', array('event'),
'lt IE 9');
JHtml::_('script', $this->_basePath .
'/tinymce.min.js', array('version' =>
'auto'));
JHtml::_('script', 'editors/tinymce/tinymce.min.js',
array('version' => 'auto', 'relative'
=> true));
}
/**
* TinyMCE WYSIWYG Editor - get the editor content
*
* @param string $id The name of the editor
*
* @since 1.5
*
* @return string
*
* @deprecated 4.0 Use directly the returned code
*/
public function onGetContent($id)
{
return 'Joomla.editors.instances[' . json_encode($id) .
'].getValue();';
}
/**
* TinyMCE WYSIWYG Editor - set the editor content
*
* @param string $id The name of the editor
* @param string $html The html to place in the editor
*
* @since 1.5
*
* @return string
*
* @deprecated 4.0 Use directly the returned code
*/
public function onSetContent($id, $html)
{
return 'Joomla.editors.instances[' . json_encode($id) .
'].setValue(' . json_encode($html) . ');';
}
/**
* TinyMCE WYSIWYG Editor - copy editor content to form field
*
* @param string $id The name of the editor
*
* @since 1.5
*
* @return void
*
* @deprecated 4.0 Use directly the returned code
*/
public function onSave($id)
{
}
/**
* Inserts html code into the editor
*
* @param string $name The name of the editor
*
* @since 1.5
*
* @return string
*
* @deprecated 3.5 tinyMCE (API v4) will get the content automatically
from the text area
*/
public function onGetInsertMethod($name)
{
}
/**
* Display the editor area.
*
* @param string $name The name of the editor area.
* @param string $content The content of the field.
* @param string $width The width of the editor area.
* @param string $height The height of the editor area.
* @param int $col The number of columns for the editor area.
* @param int $row The number of rows for the editor area.
* @param boolean $buttons True and the editor buttons will be
displayed.
* @param string $id An optional ID for the textarea. If not
supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
*
* @return string
*/
public function onDisplay(
$name, $content, $width, $height, $col, $row, $buttons = true, $id =
null, $asset = null, $author = null, $params = array())
{
$app = JFactory::getApplication();
// Check for old params for B/C
$config_warn_count =
$app->getUserState('plg_editors_tinymce.config_legacy_warn_count',
0);
if ($this->params->exists('mode') &&
$this->params->exists('alignment'))
{
if ($app->isClient('administrator') &&
$config_warn_count < 2)
{
$link =
JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id='
. $this->getPluginId());
$app->enqueueMessage(JText::sprintf('PLG_TINY_LEGACY_WARNING',
$link), 'warning');
$app->setUserState('plg_editors_tinymce.config_legacy_warn_count',
++$config_warn_count);
}
return $this->onDisplayLegacy($name, $content, $width, $height, $col,
$row, $buttons, $id, $asset, $author, $params);
}
if (empty($id))
{
$id = $name;
}
$id = preg_replace('/(\s|[^A-Za-z0-9_])+/',
'_', $id);
$nameGroup = explode('[',
preg_replace('/\[\]|\]/', '', $name));
$fieldName = end($nameGroup);
$scriptOptions = array();
// Check for existing options
$doc = JFactory::getDocument();
$options = $doc->getScriptOptions('plg_editor_tinymce');
// Only add "px" to width and height if they are not given as a
percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
// Data object for the layout
$textarea = new stdClass;
$textarea->name = $name;
$textarea->id = $id;
$textarea->class = 'mce_editable joomla-editor-tinymce';
$textarea->cols = $col;
$textarea->rows = $row;
$textarea->width = $width;
$textarea->height = $height;
$textarea->content = $content;
// Set editor to readonly mode
$textarea->readonly = !empty($params['readonly']);
// Render Editor markup
$editor = '<div class="js-editor-tinymce">';
$editor .= JLayoutHelper::render('joomla.tinymce.textarea',
$textarea);
$editor .= $this->_toogleButton($id);
$editor .= '</div>';
// Prepare the instance specific options, actually the ext-buttons
if
(empty($options['tinyMCE'][$fieldName]['joomlaExtButtons']))
{
$btns = $this->tinyButtons($id, $buttons);
if (!empty($btns['names']))
{
JHtml::_('script',
'editors/tinymce/tiny-close.min.js', array('version'
=> 'auto', 'relative' => true),
array('defer' => 'defer'));
}
// Set editor to readonly mode
if (!empty($params['readonly']))
{
$options['tinyMCE'][$fieldName]['readonly'] = 1;
}
$options['tinyMCE'][$fieldName]['joomlaMergeDefaults']
= true;
$options['tinyMCE'][$fieldName]['joomlaExtButtons']
= $btns;
$doc->addScriptOptions('plg_editor_tinymce', $options,
false);
}
// Setup Default (common) options for the Editor script
// Check whether we already have them
if (!empty($options['tinyMCE']['default']))
{
return $editor;
}
$user = JFactory::getUser();
$language = JFactory::getLanguage();
$theme = 'modern';
$ugroups = array_combine($user->getAuthorisedGroups(),
$user->getAuthorisedGroups());
// Prepare the parameters
$levelParams = new Joomla\Registry\Registry;
$extraOptions = new stdClass;
$toolbarParams = new stdClass;
$extraOptionsAll =
$this->params->get('configuration.setoptions', array());
$toolbarParamsAll =
$this->params->get('configuration.toolbars', array());
// Get configuration depend from User group
foreach ($extraOptionsAll as $set => $val)
{
$val->access = empty($val->access) ? array() : $val->access;
// Check whether User in one of allowed group
foreach ($val->access as $group)
{
if (isset($ugroups[$group]))
{
$extraOptions = $val;
$toolbarParams = $toolbarParamsAll->$set;
}
}
}
// Merge the params
$levelParams->loadObject($toolbarParams);
$levelParams->loadObject($extraOptions);
// List the skins
$skindirs = glob(JPATH_ROOT . '/media/editors/tinymce/skins' .
'/*', GLOB_ONLYDIR);
// Set the selected skin
$skin = 'lightgray';
$side = $app->isClient('administrator') ?
'skin_admin' : 'skin';
if ((int) $levelParams->get($side, 0) < count($skindirs))
{
$skin = basename($skindirs[(int) $levelParams->get($side, 0)]);
}
$langMode = $levelParams->get('lang_mode', 1);
$langPrefix = $levelParams->get('lang_code',
'en');
if ($langMode)
{
if (file_exists(JPATH_ROOT . '/media/editors/tinymce/langs/' .
$language->getTag() . '.js'))
{
$langPrefix = $language->getTag();
}
elseif (file_exists(JPATH_ROOT .
'/media/editors/tinymce/langs/' . substr($language->getTag(),
0, strpos($language->getTag(), '-')) . '.js'))
{
$langPrefix = substr($language->getTag(), 0,
strpos($language->getTag(), '-'));
}
else
{
$langPrefix = 'en';
}
}
$text_direction = 'ltr';
if ($language->isRtl())
{
$text_direction = 'rtl';
}
$use_content_css = $levelParams->get('content_css', 1);
$content_css_custom =
$levelParams->get('content_css_custom', '');
/*
* Lets get the default template for the site application
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('template')
->from('#__template_styles')
->where('client_id=0 AND home=' .
$db->quote('1'));
$db->setQuery($query);
try
{
$template = $db->loadResult();
}
catch (RuntimeException $e)
{
$app->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'),
'error');
return '';
}
$content_css = null;
$templates_path = JPATH_SITE . '/templates';
// Loading of css file for 'styles' dropdown
if ($content_css_custom)
{
// If URL, just pass it to $content_css
if (strpos($content_css_custom, 'http') !== false)
{
$content_css = $content_css_custom;
}
// If it is not a URL, assume it is a file name in the current template
folder
else
{
$content_css = JUri::root(true) . '/templates/' . $template .
'/css/' . $content_css_custom;
// Issue warning notice if the file is not found (but pass name to
$content_css anyway to avoid TinyMCE error
if (!file_exists($templates_path . '/' . $template .
'/css/' . $content_css_custom))
{
$msg =
sprintf(JText::_('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'),
$content_css_custom);
JLog::add($msg, JLog::WARNING, 'jerror');
}
}
}
else
{
// Process when use_content_css is Yes and no custom file given
if ($use_content_css)
{
// First check templates folder for default template
// if no editor.css file in templates folder, check system template
folder
if (!file_exists($templates_path . '/' . $template .
'/css/editor.css'))
{
// If no editor.css file in system folder, show alert
if (!file_exists($templates_path .
'/system/css/editor.css'))
{
JLog::add(JText::_('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT'),
JLog::WARNING, 'jerror');
}
else
{
$content_css = JUri::root(true) .
'/templates/system/css/editor.css';
}
}
else
{
$content_css = JUri::root(true) . '/templates/' . $template
. '/css/editor.css';
}
}
}
$ignore_filter = false;
// Text filtering
if ($levelParams->get('use_config_textfilters', 0))
{
// Use filters from com_config
$filter = static::getGlobalFilters();
$ignore_filter = $filter === false;
$tagBlacklist = !empty($filter->tagBlacklist) ?
$filter->tagBlacklist : array();
$attrBlacklist = !empty($filter->attrBlacklist) ?
$filter->attrBlacklist : array();
$tagArray = !empty($filter->tagArray) ? $filter->tagArray :
array();
$attrArray = !empty($filter->attrArray) ? $filter->attrArray :
array();
$invalid_elements = implode(',', array_merge($tagBlacklist,
$attrBlacklist, $tagArray, $attrArray));
// Valid elements are all whitelist entries in com_config, which are now
missing in the tagBlacklist
$default_filter = JFilterInput::getInstance();
$valid_elements = implode(',',
array_diff($default_filter->tagBlacklist, $tagBlacklist));
$extended_elements = '';
}
else
{
// Use filters from TinyMCE params
$invalid_elements =
trim($levelParams->get('invalid_elements',
'script,applet,iframe'));
$extended_elements =
trim($levelParams->get('extended_elements', ''));
$valid_elements =
trim($levelParams->get('valid_elements', ''));
}
$html_height = $this->params->get('html_height',
'550');
$html_width = $this->params->get('html_width',
'');
if ($html_width == 750)
{
$html_width = '';
}
// The param is true for vertical resizing only, false or both
$resizing = (bool) $levelParams->get('resizing',
true);
$resize_horizontal = (bool)
$levelParams->get('resize_horizontal', true);
if ($resizing && $resize_horizontal)
{
$resizing = 'both';
}
// Set of always available plugins
$plugins = array(
'autolink',
'lists',
'colorpicker',
'importcss',
);
// Allowed elements
$elements = array(
'hr[id|title|alt|class|width|size|noshade]',
);
if ($extended_elements)
{
$elements = array_merge($elements, explode(',',
$extended_elements));
}
// Prepare the toolbar/menubar
$knownButtons = static::getKnownButtons();
// Check if there no value at all
if (!$levelParams->get('menu') &&
!$levelParams->get('toolbar1') &&
!$levelParams->get('toolbar2'))
{
// Get from preset
$presets = static::getToolbarPreset();
/*
* Predefine group as:
* Set 0: for Administrator, Editor, Super Users (4,7,8)
* Set 1: for Registered, Manager (2,6), all else are public
*/
switch (true)
{
case isset($ugroups[4]) || isset($ugroups[7]) || isset($ugroups[8]):
$preset = $presets['advanced'];
break;
case isset($ugroups[2]) || isset($ugroups[6]):
$preset = $presets['medium'];
break;
default:
$preset = $presets['simple'];
}
$levelParams->loadArray($preset);
}
$menubar = (array) $levelParams->get('menu', array());
$toolbar1 = (array) $levelParams->get('toolbar1', array());
$toolbar2 = (array) $levelParams->get('toolbar2', array());
// Make an easy way to check which button is enabled
$allButtons = array_merge($toolbar1, $toolbar2);
$allButtons = array_combine($allButtons, $allButtons);
// Check for button-specific plugins
foreach ($allButtons as $btnName)
{
if (!empty($knownButtons[$btnName]['plugin']))
{
$plugins[] = $knownButtons[$btnName]['plugin'];
}
}
// Template
$templates = array();
if (!empty($allButtons['template']))
{
// Note this check for the template_list.js file will be removed in
Joomla 4.0
if (is_file(JPATH_ROOT .
'/media/editors/tinymce/templates/template_list.js'))
{
// If using the legacy file we need to include and input the files the
new way
$str = file_get_contents(JPATH_ROOT .
'/media/editors/tinymce/templates/template_list.js');
// Find from one [ to the last ]
$matches = array();
preg_match_all('/\[.*\]/', $str, $matches);
// Set variables
foreach ($matches['0'] as $match)
{
$values = array();
preg_match_all('/\".*\"/', $match, $values);
$result = trim($values['0']['0'],
'"');
$final_result = explode(',', $result);
$templates[] = array(
'title' => trim($final_result['0'], '
" '),
'description' => trim($final_result['2'],
' " '),
'url' => JUri::root(true) . '/' .
trim($final_result['1'], ' " '),
);
}
}
else
{
foreach (glob(JPATH_ROOT .
'/media/editors/tinymce/templates/*.html') as $filename)
{
$filename = basename($filename, '.html');
if ($filename !== 'index')
{
$lang = JFactory::getLanguage();
$title = $filename;
$description = ' ';
if ($lang->hasKey('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_TITLE'))
{
$title = JText::_('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_TITLE');
}
if ($lang->hasKey('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_DESC'))
{
$description = JText::_('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_DESC');
}
$templates[] = array(
'title' => $title,
'description' => $description,
'url' => JUri::root(true) .
'/media/editors/tinymce/templates/' . $filename .
'.html',
);
}
}
}
}
// Check for extra plugins, from the setoptions form
foreach (array('wordcount' => 1, 'advlist' =>
1, 'autosave' => 1, 'contextmenu' => 1) as $pName
=> $def)
{
if ($levelParams->get($pName, $def))
{
$plugins[] = $pName;
}
}
// User custom plugins and buttons
$custom_plugin = trim($levelParams->get('custom_plugin',
''));
$custom_button = trim($levelParams->get('custom_button',
''));
if ($custom_plugin)
{
$separator = strpos($custom_plugin, ',') !== false ?
',' : ' ';
$plugins = array_merge($plugins, explode($separator, $custom_plugin));
}
if ($custom_button)
{
$separator = strpos($custom_button, ',') !== false ?
',' : ' ';
$toolbar1 = array_merge($toolbar1, explode($separator,
$custom_button));
}
// Drag and drop Images
$allowImgPaste = false;
$dragdrop = $levelParams->get('drag_drop', 1);
if ($dragdrop && $user->authorise('core.create',
'com_media'))
{
$externalPlugins['jdragdrop'] = HTMLHelper::_(
'script',
'editors/tinymce/plugins/dragdrop/plugin.min.js',
array('relative' => true, 'version' =>
'auto', 'pathOnly' => true)
);
$allowImgPaste = true;
$isSubDir = '';
$session = JFactory::getSession();
$uploadUrl = JUri::base() .
'index.php?option=com_media&task=file.upload&tmpl=component&'
. $session->getName() . '=' . $session->getId()
. '&' . JSession::getFormToken() . '=1'
. '&asset=image&format=json';
if ($app->isClient('site'))
{
$uploadUrl = htmlentities($uploadUrl, null, 'UTF-8', null);
}
// Is Joomla installed in subdirectory
if (JUri::root(true) !== '/')
{
$isSubDir = JUri::root(true);
}
JText::script('PLG_TINY_ERR_UNSUPPORTEDBROWSER');
$scriptOptions['setCustomDir'] = $isSubDir;
$scriptOptions['mediaUploadPath'] =
$levelParams->get('path', '');
$scriptOptions['uploadUri'] = $uploadUrl;
}
// Build the final options set
$scriptOptions = array_merge(
$scriptOptions,
array(
'suffix' => '.min',
'baseURL' => JUri::root(true) .
'/media/editors/tinymce',
'directionality' => $text_direction,
'language' => $langPrefix,
'autosave_restore_when_empty' => false,
'skin' => $skin,
'theme' => $theme,
'schema' => 'html5',
// Toolbars
'menubar' => empty($menubar) ? false : implode('
', array_unique($menubar)),
'toolbar1' => empty($toolbar1) ? null : implode('
', $toolbar1),
'toolbar2' => empty($toolbar2) ? null : implode('
', $toolbar2),
'plugins' => implode(',',
array_unique($plugins)),
// Cleanup/Output
'inline_styles' => true,
'gecko_spellcheck' => true,
'entity_encoding' =>
$levelParams->get('entity_encoding', 'raw'),
'verify_html' => !$ignore_filter,
'valid_elements' => $valid_elements,
'extended_valid_elements' => implode(',',
$elements),
'invalid_elements' => $invalid_elements,
// URL
'relative_urls' => (bool)
$levelParams->get('relative_urls', true),
'remove_script_host' => false,
// Layout
'content_css' => $content_css,
'document_base_url' => JUri::root(true) . '/',
'paste_data_images' => $allowImgPaste,
'importcss_append' => true,
'image_title' => true,
'height' => $html_height,
'width' => $html_width,
'resize' => $resizing,
'templates' => $templates,
'image_advtab' => (bool)
$levelParams->get('image_advtab', false),
'external_plugins' => empty($externalPlugins) ? null :
$externalPlugins,
'contextmenu' => (bool)
$levelParams->get('contextmenu', true) ? null : false,
'elementpath' => (bool)
$levelParams->get('element_path', true),
)
);
if ($levelParams->get('newlines'))
{
// Break
$scriptOptions['force_br_newlines'] = true;
$scriptOptions['force_p_newlines'] = false;
$scriptOptions['forced_root_block'] = '';
}
else
{
// Paragraph
$scriptOptions['force_br_newlines'] = false;
$scriptOptions['force_p_newlines'] = true;
$scriptOptions['forced_root_block'] = 'p';
}
$scriptOptions['rel_list'] = array(
array('title' => 'None', 'value' =>
''),
array('title' => 'Alternate', 'value'
=> 'alternate'),
array('title' => 'Author', 'value'
=> 'author'),
array('title' => 'Bookmark', 'value'
=> 'bookmark'),
array('title' => 'Help', 'value' =>
'help'),
array('title' => 'License', 'value'
=> 'license'),
array('title' => 'Lightbox', 'value'
=> 'lightbox'),
array('title' => 'Next', 'value' =>
'next'),
array('title' => 'No Follow', 'value'
=> 'nofollow'),
array('title' => 'No Referrer', 'value'
=> 'noreferrer'),
array('title' => 'Prefetch', 'value'
=> 'prefetch'),
array('title' => 'Prev', 'value' =>
'prev'),
array('title' => 'Search', 'value'
=> 'search'),
array('title' => 'Tag', 'value' =>
'tag'),
);
/**
* Shrink the buttons if not on a mobile or if mobile view is off.
* If mobile view is on force into simple mode and enlarge the buttons
**/
if (!$this->app->client->mobile)
{
$scriptOptions['toolbar_items_size'] = 'small';
}
elseif ($levelParams->get('mobile', 0))
{
$scriptOptions['menubar'] = false;
unset($scriptOptions['toolbar2']);
}
$options['tinyMCE']['default'] = $scriptOptions;
$doc->addStyleDeclaration('.mce-in { padding: 5px 10px
!important;}');
$doc->addScriptOptions('plg_editor_tinymce', $options);
return $editor;
}
/**
* Get the toggle editor button
*
* @param string $name Editor name
*
* @return string
*/
private function _toogleButton($name)
{
return JLayoutHelper::render('joomla.tinymce.togglebutton',
$name);
}
/**
* Get the XTD buttons and render them inside tinyMCE
*
* @param string $name the id of the editor field
* @param string $excluded the buttons that should be hidden
*
* @return array
*/
private function tinyButtons($name, $excluded)
{
// Get the available buttons
$buttons = $this->_subject->getButtons($name, $excluded);
// Init the arrays for the buttons
$tinyBtns = array();
$btnsNames = array();
// Build the script
foreach ($buttons as $i => $button)
{
if ($button->get('name'))
{
// Set some vars
$name = 'button-' . $i . str_replace(' ',
'', $button->get('text'));
$title = $button->get('text');
$onclick = $button->get('onclick') ?: null;
$options = $button->get('options');
$icon = $button->get('name');
if ($button->get('link') !== '#')
{
$href = JUri::base() . $button->get('link');
}
else
{
$href = null;
}
// We do some hack here to set the correct icon for 3PD buttons
$icon = 'none icon-' . $icon;
$tempConstructor = array();
// Now we can built the script
$tempConstructor[] = '!(function(){';
// Get the modal width/height
if ($options && is_scalar($options))
{
$tempConstructor[] = 'var getBtnOptions=new Function("return
' . addslashes($options) . '"),';
$tempConstructor[] = 'btnOptions=getBtnOptions(),';
$tempConstructor[] =
'modalWidth=btnOptions.size&&btnOptions.size.x?btnOptions.size.x:null,';
$tempConstructor[] =
'modalHeight=btnOptions.size&&btnOptions.size.y?btnOptions.size.y:null;';
}
else
{
$tempConstructor[] = 'var
btnOptions={},modalWidth=null,modalHeight=null;';
}
// Now we can built the script
// AddButton starts here
$tempConstructor[] = 'editor.addButton("' . $name .
'",{';
$tempConstructor[] = 'text:"' . $title .
'",';
$tempConstructor[] = 'title:"' . $title .
'",';
$tempConstructor[] = 'icon:"' . $icon .
'",';
// Onclick starts here
$tempConstructor[] = 'onclick:function(){';
if ($href || $button->get('modal'))
{
// TinyMCE standard modal options
$tempConstructor[] = 'var modalOptions={';
$tempConstructor[] = 'title:"' . $title .
'",';
$tempConstructor[] = 'url:"' . $href .
'",';
$tempConstructor[] = 'buttons:[{text:
"Close",onclick:"close"}]';
$tempConstructor[] = '};';
// Set width/height
$tempConstructor[] =
'if(modalWidth){modalOptions.width=modalWidth;}';
$tempConstructor[] = 'if(modalHeight){modalOptions.height =
modalHeight;}';
$tempConstructor[] = 'var
win=editor.windowManager.open(modalOptions);';
if (JFactory::getApplication()->client->mobile)
{
$tempConstructor[] = 'win.fullscreen(true);';
}
if ($onclick && ($button->get('modal') || $href))
{
// Adds callback for close button
$tempConstructor[] = $onclick . ';';
}
}
else
{
// Adds callback for the button, eg: readmore
$tempConstructor[] = $onclick . ';';
}
// Onclick ends here
$tempConstructor[] = '}';
// AddButton ends here
$tempConstructor[] = '});';
// IIFE ends here
$tempConstructor[] = '})();';
// The array with the toolbar buttons
$btnsNames[] = $name . ' | ';
// The array with code for each button
$tinyBtns[] = implode('', $tempConstructor);
}
}
return array(
'names' => $btnsNames,
'script' => $tinyBtns
);
}
/**
* Get the global text filters to arbitrary text as per settings for
current user groups
*
* @return JFilterInput
*
* @since 3.6
*/
protected static function getGlobalFilters()
{
// Filter settings
$config = JComponentHelper::getParams('com_config');
$user = JFactory::getUser();
$userGroups = JAccess::getGroupsByUser($user->get('id'));
$filters = $config->get('filters');
$blackListTags = array();
$blackListAttributes = array();
$customListTags = array();
$customListAttributes = array();
$whiteListTags = array();
$whiteListAttributes = array();
$whiteList = false;
$blackList = false;
$customList = false;
$unfiltered = false;
// Cycle through each of the user groups the user is in.
// Remember they are included in the public group as well.
foreach ($userGroups as $groupId)
{
// May have added a group but not saved the filters.
if (!isset($filters->$groupId))
{
continue;
}
// Each group the user is in could have different filtering properties.
$filterData = $filters->$groupId;
$filterType = strtoupper($filterData->filter_type);
if ($filterType === 'NH')
{
// Maximum HTML filtering.
}
elseif ($filterType === 'NONE')
{
// No HTML filtering.
$unfiltered = true;
}
else
{
// Blacklist or whitelist.
// Preprocess the tags and attributes.
$tags = explode(',', $filterData->filter_tags);
$attributes = explode(',',
$filterData->filter_attributes);
$tempTags = array();
$tempAttributes = array();
foreach ($tags as $tag)
{
$tag = trim($tag);
if ($tag)
{
$tempTags[] = $tag;
}
}
foreach ($attributes as $attribute)
{
$attribute = trim($attribute);
if ($attribute)
{
$tempAttributes[] = $attribute;
}
}
// Collect the blacklist or whitelist tags and attributes.
// Each list is cummulative.
if ($filterType === 'BL')
{
$blackList = true;
$blackListTags = array_merge($blackListTags, $tempTags);
$blackListAttributes = array_merge($blackListAttributes,
$tempAttributes);
}
elseif ($filterType === 'CBL')
{
// Only set to true if Tags or Attributes were added
if ($tempTags || $tempAttributes)
{
$customList = true;
$customListTags = array_merge($customListTags, $tempTags);
$customListAttributes = array_merge($customListAttributes,
$tempAttributes);
}
}
elseif ($filterType === 'WL')
{
$whiteList = true;
$whiteListTags = array_merge($whiteListTags, $tempTags);
$whiteListAttributes = array_merge($whiteListAttributes,
$tempAttributes);
}
}
}
// Remove duplicates before processing (because the blacklist uses both
sets of arrays).
$blackListTags = array_unique($blackListTags);
$blackListAttributes = array_unique($blackListAttributes);
$customListTags = array_unique($customListTags);
$customListAttributes = array_unique($customListAttributes);
$whiteListTags = array_unique($whiteListTags);
$whiteListAttributes = array_unique($whiteListAttributes);
// Unfiltered assumes first priority.
if ($unfiltered)
{
// Dont apply filtering.
return false;
}
else
{
// Custom blacklist precedes Default blacklist
if ($customList)
{
$filter = JFilterInput::getInstance(array(), array(), 1, 1);
// Override filter's default blacklist tags and attributes
if ($customListTags)
{
$filter->tagBlacklist = $customListTags;
}
if ($customListAttributes)
{
$filter->attrBlacklist = $customListAttributes;
}
}
// Blacklists take second precedence.
elseif ($blackList)
{
// Remove the white-listed tags and attributes from the black-list.
$blackListTags = array_diff($blackListTags, $whiteListTags);
$blackListAttributes = array_diff($blackListAttributes,
$whiteListAttributes);
$filter = JFilterInput::getInstance($blackListTags,
$blackListAttributes, 1, 1);
// Remove whitelisted tags from filter's default blacklist
if ($whiteListTags)
{
$filter->tagBlacklist = array_diff($filter->tagBlacklist,
$whiteListTags);
}
// Remove whitelisted attributes from filter's default blacklist
if ($whiteListAttributes)
{
$filter->attrBlacklist = array_diff($filter->attrBlacklist,
$whiteListAttributes);
}
}
// Whitelists take third precedence.
elseif ($whiteList)
{
// Turn off XSS auto clean
$filter = JFilterInput::getInstance($whiteListTags,
$whiteListAttributes, 0, 0, 0);
}
// No HTML takes last place.
else
{
$filter = JFilterInput::getInstance();
}
return $filter;
}
}
/**
* Return list of known TinyMCE buttons
*
* @return array
*
* @since 3.7.0
*/
public static function getKnownButtons()
{
// See https://www.tinymce.com/docs/demo/full-featured/
// And https://www.tinymce.com/docs/plugins/
$buttons = array(
// General buttons
'|' => array('label' =>
JText::_('PLG_TINY_TOOLBAR_BUTTON_SEPARATOR'), 'text'
=> '|'),
'undo' => array('label' =>
'Undo'),
'redo' => array('label' =>
'Redo'),
'bold' => array('label' =>
'Bold'),
'italic' => array('label' =>
'Italic'),
'underline' => array('label' =>
'Underline'),
'strikethrough' => array('label' =>
'Strikethrough'),
'styleselect' => array('label' =>
JText::_('PLG_TINY_TOOLBAR_BUTTON_STYLESELECT'), 'text'
=> 'Formats'),
'formatselect' => array('label' =>
JText::_('PLG_TINY_TOOLBAR_BUTTON_FORMATSELECT'),
'text' => 'Paragraph'),
'fontselect' => array('label' =>
JText::_('PLG_TINY_TOOLBAR_BUTTON_FONTSELECT'), 'text'
=> 'Font Family'),
'fontsizeselect' => array('label' =>
JText::_('PLG_TINY_TOOLBAR_BUTTON_FONTSIZESELECT'),
'text' => 'Font Sizes'),
'alignleft' => array('label' =>
'Align left'),
'aligncenter' => array('label' =>
'Align center'),
'alignright' => array('label' =>
'Align right'),
'alignjustify' => array('label' =>
'Justify'),
'outdent' => array('label' =>
'Decrease indent'),
'indent' => array('label' =>
'Increase indent'),
'bullist' => array('label' =>
'Bullet list'),
'numlist' => array('label' =>
'Numbered list'),
'link' => array('label' =>
'Insert/edit link', 'plugin' => 'link'),
'unlink' => array('label' =>
'Remove link', 'plugin' => 'link'),
'subscript' => array('label' =>
'Subscript'),
'superscript' => array('label' =>
'Superscript'),
'blockquote' => array('label' =>
'Blockquote'),
'cut' => array('label' =>
'Cut'),
'copy' => array('label' =>
'Copy'),
'paste' => array('label' =>
'Paste', 'plugin' => 'paste'),
'pastetext' => array('label' =>
'Paste as text', 'plugin' => 'paste'),
'removeformat' => array('label' =>
'Clear formatting'),
// Buttons from the plugins
'forecolor' => array('label' =>
'Text color', 'plugin' => 'textcolor'),
'backcolor' => array('label' =>
'Background color', 'plugin' =>
'textcolor'),
'anchor' => array('label' =>
'Anchor', 'plugin' => 'anchor'),
'hr' => array('label' =>
'Horizontal line', 'plugin' => 'hr'),
'ltr' => array('label' =>
'Left to right', 'plugin' =>
'directionality'),
'rtl' => array('label' =>
'Right to left', 'plugin' =>
'directionality'),
'code' => array('label' =>
'Source code', 'plugin' => 'code'),
'codesample' => array('label' =>
'Insert/Edit code sample', 'plugin' =>
'codesample'),
'table' => array('label' =>
'Table', 'plugin' => 'table'),
'charmap' => array('label' =>
'Special character', 'plugin' =>
'charmap'),
'visualchars' => array('label' =>
'Show invisible characters', 'plugin' =>
'visualchars'),
'visualblocks' => array('label' =>
'Show blocks', 'plugin' =>
'visualblocks'),
'nonbreaking' => array('label' =>
'Nonbreaking space', 'plugin' =>
'nonbreaking'),
'emoticons' => array('label' =>
'Emoticons', 'plugin' => 'emoticons'),
'image' => array('label' =>
'Insert/edit image', 'plugin' => 'image'),
'media' => array('label' =>
'Insert/edit video', 'plugin' => 'media'),
'pagebreak' => array('label' =>
'Page break', 'plugin' => 'pagebreak'),
'print' => array('label' =>
'Print', 'plugin' => 'print'),
'preview' => array('label' =>
'Preview', 'plugin' => 'preview'),
'fullscreen' => array('label' =>
'Fullscreen', 'plugin' => 'fullscreen'),
'template' => array('label' =>
'Insert template', 'plugin' =>
'template'),
'searchreplace' => array('label' =>
'Find and replace', 'plugin' =>
'searchreplace'),
'insertdatetime' => array('label' =>
'Insert date/time', 'plugin' =>
'insertdatetime'),
// 'spellchecker' => array('label' =>
'Spellcheck', 'plugin' => 'spellchecker'),
);
return $buttons;
}
/**
* Return toolbar presets
*
* @return array
*
* @since 3.7.0
*/
public static function getToolbarPreset()
{
$preset = array();
$preset['simple'] = array(
'menu' => array(),
'toolbar1' => array(
'bold', 'underline', 'strikethrough',
'|',
'undo', 'redo', '|',
'bullist', 'numlist', '|',
'pastetext'
),
'toolbar2' => array(),
);
$preset['medium'] = array(
'menu' => array('edit', 'insert',
'view', 'format', 'table',
'tools'),
'toolbar1' => array(
'bold', 'italic', 'underline',
'strikethrough', '|',
'alignleft', 'aligncenter', 'alignright',
'alignjustify', '|',
'formatselect', '|',
'bullist', 'numlist', '|',
'outdent', 'indent', '|',
'undo', 'redo', '|',
'link', 'unlink', 'anchor',
'code', '|',
'hr', 'table', '|',
'subscript', 'superscript', '|',
'charmap', 'pastetext' , 'preview'
),
'toolbar2' => array(),
);
$preset['advanced'] = array(
'menu' => array('edit', 'insert',
'view', 'format', 'table',
'tools'),
'toolbar1' => array(
'bold', 'italic', 'underline',
'strikethrough', '|',
'alignleft', 'aligncenter', 'alignright',
'alignjustify', '|',
'styleselect', '|',
'formatselect', 'fontselect',
'fontsizeselect', '|',
'searchreplace', '|',
'bullist', 'numlist', '|',
'outdent', 'indent', '|',
'undo', 'redo', '|',
'link', 'unlink', 'anchor',
'image', '|',
'code', '|',
'forecolor', 'backcolor', '|',
'fullscreen', '|',
'table', '|',
'subscript', 'superscript', '|',
'charmap', 'emoticons', 'media',
'hr', 'ltr', 'rtl', '|',
'cut', 'copy', 'paste',
'pastetext', '|',
'visualchars', 'visualblocks',
'nonbreaking', 'blockquote', 'template',
'|',
'print', 'preview', 'codesample',
'insertdatetime', 'removeformat',
),
'toolbar2' => array(),
);
return $preset;
}
/**
* Gets the plugin extension id.
*
* @return int The plugin id.
*
* @since 3.7.0
*/
private function getPluginId()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('folder') . ' = ' .
$db->quote($this->_type))
->where($db->quoteName('element') . ' = ' .
$db->quote($this->_name));
$db->setQuery($query);
return (int) $db->loadResult();
}
/**
* Display the editor area.
*
* @param string $name The name of the editor area.
* @param string $content The content of the field.
* @param string $width The width of the editor area.
* @param string $height The height of the editor area.
* @param int $col The number of columns for the editor area.
* @param int $row The number of rows for the editor area.
* @param boolean $buttons True and the editor buttons will be
displayed.
* @param string $id An optional ID for the textarea. If not
supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
*
* @return string
*
* @since 3.7.0
*
* @deprecated 4.0
*/
private function onDisplayLegacy(
$name, $content, $width, $height, $col, $row, $buttons = true, $id =
null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
$id = $name;
}
$id = preg_replace('/(\s|[^A-Za-z0-9_])+/',
'_', $id);
$nameGroup = explode('[',
preg_replace('/\[\]|\]/', '', $name));
$fieldName = end($nameGroup);
$scriptOptions = array();
// Check for existing options
$doc = JFactory::getDocument();
$options = $doc->getScriptOptions('plg_editor_tinymce');
// Only add "px" to width and height if they are not given as a
percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
// Data object for the layout
$textarea = new stdClass;
$textarea->name = $name;
$textarea->id = $id;
$textarea->class = 'mce_editable joomla-editor-tinymce';
$textarea->cols = $col;
$textarea->rows = $row;
$textarea->width = $width;
$textarea->height = $height;
$textarea->content = $content;
// Set editor to readonly mode
$textarea->readonly = !empty($params['readonly']);
// Render Editor markup
$editor = '<div class="editor
js-editor-tinymce">';
$editor .= JLayoutHelper::render('joomla.tinymce.textarea',
$textarea);
$editor .= $this->_toogleButton($id);
$editor .= '</div>';
// Prepare instance specific options, actually the ext-buttons
if
(empty($options['tinyMCE'][$fieldName]['joomlaExtButtons']))
{
$btns = $this->tinyButtons($id, $buttons);
if (!empty($btns['names']))
{
JHtml::_('script',
'editors/tinymce/tiny-close.min.js', array('version'
=> 'auto', 'relative' => true),
array('defer' => 'defer'));
}
// Set editor to readonly mode
if (!empty($params['readonly']))
{
$options['tinyMCE'][$fieldName]['readonly'] = 1;
}
$options['tinyMCE'][$fieldName]['joomlaMergeDefaults']
= true;
$options['tinyMCE'][$fieldName]['joomlaExtButtons']
= $btns;
$doc->addScriptOptions('plg_editor_tinymce', $options,
false);
}
// Setup Default options for the Editor script
// Check whether we already have them
if (!empty($options['tinyMCE']['default']))
{
return $editor;
}
$app = JFactory::getApplication();
$user = JFactory::getUser();
$language = JFactory::getLanguage();
$mode = (int) $this->params->get('mode', 1);
$theme = 'modern';
// List the skins
$skindirs = glob(JPATH_ROOT . '/media/editors/tinymce/skins' .
'/*', GLOB_ONLYDIR);
// Set the selected skin
$skin = 'lightgray';
$side = $app->isClient('administrator') ?
'skin_admin' : 'skin';
if ((int) $this->params->get($side, 0) < count($skindirs))
{
$skin = basename($skindirs[(int) $this->params->get($side, 0)]);
}
$langMode = $this->params->get('lang_mode', 0);
$langPrefix = $this->params->get('lang_code',
'en');
if ($langMode)
{
if (file_exists(JPATH_ROOT . "/media/editors/tinymce/langs/" .
$language->getTag() . ".js"))
{
$langPrefix = $language->getTag();
}
elseif (file_exists(JPATH_ROOT .
"/media/editors/tinymce/langs/" . substr($language->getTag(),
0, strpos($language->getTag(), '-')) . ".js"))
{
$langPrefix = substr($language->getTag(), 0,
strpos($language->getTag(), '-'));
}
else
{
$langPrefix = "en";
}
}
$text_direction = 'ltr';
if ($language->isRtl())
{
$text_direction = 'rtl';
}
$use_content_css = $this->params->get('content_css',
1);
$content_css_custom =
$this->params->get('content_css_custom', '');
/*
* Lets get the default template for the site application
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('template')
->from('#__template_styles')
->where('client_id=0 AND home=' .
$db->quote('1'));
$db->setQuery($query);
try
{
$template = $db->loadResult();
}
catch (RuntimeException $e)
{
$app->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'),
'error');
return;
}
$content_css = null;
$templates_path = JPATH_SITE . '/templates';
// Loading of css file for 'styles' dropdown
if ($content_css_custom)
{
// If URL, just pass it to $content_css
if (strpos($content_css_custom, 'http') !== false)
{
$content_css = $content_css_custom;
}
// If it is not a URL, assume it is a file name in the current template
folder
else
{
$content_css = JUri::root(true) . '/templates/' . $template .
'/css/' . $content_css_custom;
// Issue warning notice if the file is not found (but pass name to
$content_css anyway to avoid TinyMCE error
if (!file_exists($templates_path . '/' . $template .
'/css/' . $content_css_custom))
{
$msg =
sprintf(JText::_('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'),
$content_css_custom);
JLog::add($msg, JLog::WARNING, 'jerror');
}
}
}
else
{
// Process when use_content_css is Yes and no custom file given
if ($use_content_css)
{
// First check templates folder for default template
// if no editor.css file in templates folder, check system template
folder
if (!file_exists($templates_path . '/' . $template .
'/css/editor.css'))
{
// If no editor.css file in system folder, show alert
if (!file_exists($templates_path .
'/system/css/editor.css'))
{
JLog::add(JText::_('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT'),
JLog::WARNING, 'jerror');
}
else
{
$content_css = JUri::root(true) .
'/templates/system/css/editor.css';
}
}
else
{
$content_css = JUri::root(true) . '/templates/' . $template
. '/css/editor.css';
}
}
}
$ignore_filter = false;
// Text filtering
if ($this->params->get('use_config_textfilters', 0))
{
// Use filters from com_config
$filter = static::getGlobalFilters();
$ignore_filter = $filter === false;
$tagBlacklist = !empty($filter->tagBlacklist) ?
$filter->tagBlacklist : array();
$attrBlacklist = !empty($filter->attrBlacklist) ?
$filter->attrBlacklist : array();
$tagArray = !empty($filter->tagArray) ? $filter->tagArray :
array();
$attrArray = !empty($filter->attrArray) ? $filter->attrArray :
array();
$invalid_elements = implode(',', array_merge($tagBlacklist,
$attrBlacklist, $tagArray, $attrArray));
// Valid elements are all whitelist entries in com_config, which are now
missing in the tagBlacklist
$default_filter = JFilterInput::getInstance();
$valid_elements = implode(',',
array_diff($default_filter->tagBlacklist, $tagBlacklist));
$extended_elements = '';
}
else
{
// Use filters from TinyMCE params
$invalid_elements =
$this->params->get('invalid_elements',
'script,applet,iframe');
$extended_elements =
$this->params->get('extended_elements', '');
$valid_elements =
$this->params->get('valid_elements', '');
}
// Advanced Options
$access = $user->getAuthorisedViewLevels();
// Flip for performance, so we can direct check for the key
isset($access[$key])
$access = array_flip($access);
$html_height = $this->params->get('html_height',
'550');
$html_width = $this->params->get('html_width',
'');
if ($html_width == 750)
{
$html_width = '';
}
// Image advanced options
$image_advtab = $this->params->get('image_advtab', true);
if (isset($access[$image_advtab]))
{
$image_advtab = true;
}
else
{
$image_advtab = false;
}
// The param is true for vertical resizing only, false or both
$resizing = $this->params->get('resizing',
'1');
$resize_horizontal =
$this->params->get('resize_horizontal', '1');
if ($resizing || $resizing == 'true')
{
if ($resize_horizontal || $resize_horizontal == 'true')
{
$resizing = 'both';
}
else
{
$resizing = true;
}
}
else
{
$resizing = false;
}
$toolbar1_add = array();
$toolbar2_add = array();
$toolbar3_add = array();
$toolbar4_add = array();
$elements = array();
$plugins = array(
'autolink',
'lists',
'image',
'charmap',
'print',
'preview',
'anchor',
'pagebreak',
'code',
'save',
'textcolor',
'colorpicker',
'importcss');
$toolbar1_add[] = 'bold';
$toolbar1_add[] = 'italic';
$toolbar1_add[] = 'underline';
$toolbar1_add[] = 'strikethrough';
// Alignment buttons
$alignment = $this->params->get('alignment', 1);
if (isset($access[$alignment]))
{
$toolbar1_add[] = '|';
$toolbar1_add[] = 'alignleft';
$toolbar1_add[] = 'aligncenter';
$toolbar1_add[] = 'alignright';
$toolbar1_add[] = 'alignjustify';
}
$toolbar1_add[] = '|';
$toolbar1_add[] = 'styleselect';
$toolbar1_add[] = '|';
$toolbar1_add[] = 'formatselect';
// Fonts
$fonts = $this->params->get('fonts', 1);
if (isset($access[$fonts]))
{
$toolbar1_add[] = 'fontselect';
$toolbar1_add[] = 'fontsizeselect';
}
// Search & replace
$searchreplace = $this->params->get('searchreplace', 1);
if (isset($access[$searchreplace]))
{
$plugins[] = 'searchreplace';
$toolbar2_add[] = 'searchreplace';
}
$toolbar2_add[] = '|';
$toolbar2_add[] = 'bullist';
$toolbar2_add[] = 'numlist';
$toolbar2_add[] = '|';
$toolbar2_add[] = 'outdent';
$toolbar2_add[] = 'indent';
$toolbar2_add[] = '|';
$toolbar2_add[] = 'undo';
$toolbar2_add[] = 'redo';
$toolbar2_add[] = '|';
// Insert date and/or time plugin
$insertdate = $this->params->get('insertdate', 1);
if (isset($access[$insertdate]))
{
$plugins[] = 'insertdatetime';
$toolbar4_add[] = 'inserttime';
}
// Link plugin
$link = $this->params->get('link', 1);
if (isset($access[$link]))
{
$plugins[] = 'link';
$toolbar2_add[] = 'link';
$toolbar2_add[] = 'unlink';
}
$toolbar2_add[] = 'anchor';
$toolbar2_add[] = 'image';
$toolbar2_add[] = '|';
$toolbar2_add[] = 'code';
// Colors
$colors = $this->params->get('colors', 1);
if (isset($access[$colors]))
{
$toolbar2_add[] = '|';
$toolbar2_add[] = 'forecolor,backcolor';
}
// Fullscreen
$fullscreen = $this->params->get('fullscreen', 1);
if (isset($access[$fullscreen]))
{
$plugins[] = 'fullscreen';
$toolbar2_add[] = '|';
$toolbar2_add[] = 'fullscreen';
}
// Table
$table = $this->params->get('table', 1);
if (isset($access[$table]))
{
$plugins[] = 'table';
$toolbar3_add[] = 'table';
$toolbar3_add[] = '|';
}
$toolbar3_add[] = 'subscript';
$toolbar3_add[] = 'superscript';
$toolbar3_add[] = '|';
$toolbar3_add[] = 'charmap';
// Emotions
$smilies = $this->params->get('smilies', 1);
if (isset($access[$smilies]))
{
$plugins[] = 'emoticons';
$toolbar3_add[] = 'emoticons';
}
// Media plugin
$media = $this->params->get('media', 1);
if (isset($access[$media]))
{
$plugins[] = 'media';
$toolbar3_add[] = 'media';
}
// Horizontal line
$hr = $this->params->get('hr', 1);
if (isset($access[$hr]))
{
$plugins[] = 'hr';
$elements[] = 'hr[id|title|alt|class|width|size|noshade]';
$toolbar3_add[] = 'hr';
}
else
{
$elements[] = 'hr[id|class|title|alt]';
}
// RTL/LTR buttons
$directionality = $this->params->get('directionality',
1);
if (isset($access[$directionality]))
{
$plugins[] = 'directionality';
$toolbar3_add[] = 'ltr rtl';
}
if ($extended_elements != "")
{
$elements = explode(',', $extended_elements);
}
$toolbar4_add[] = 'cut';
$toolbar4_add[] = 'copy';
// Paste
$paste = $this->params->get('paste', 1);
if (isset($access[$paste]))
{
$plugins[] = 'paste';
$toolbar4_add[] = 'paste';
}
$toolbar4_add[] = '|';
// Visualchars
$visualchars = $this->params->get('visualchars', 1);
if (isset($access[$visualchars]))
{
$plugins[] = 'visualchars';
$toolbar4_add[] = 'visualchars';
}
// Visualblocks
$visualblocks = $this->params->get('visualblocks', 1);
if (isset($access[$visualblocks]))
{
$plugins[] = 'visualblocks';
$toolbar4_add[] = 'visualblocks';
}
// Non-breaking
$nonbreaking = $this->params->get('nonbreaking', 1);
if (isset($access[$nonbreaking]))
{
$plugins[] = 'nonbreaking';
$toolbar4_add[] = 'nonbreaking';
}
// Blockquote
$blockquote = $this->params->get('blockquote', 1);
if (isset($access[$blockquote]))
{
$toolbar4_add[] = 'blockquote';
}
// Template
$template = $this->params->get('template', 1);
$templates = array();
if (isset($access[$template]))
{
$plugins[] = 'template';
$toolbar4_add[] = 'template';
// Note this check for the template_list.js file will be removed in
Joomla 4.0
if (is_file(JPATH_ROOT .
"/media/editors/tinymce/templates/template_list.js"))
{
// If using the legacy file we need to include and input the files the
new way
$str = file_get_contents(JPATH_ROOT .
"/media/editors/tinymce/templates/template_list.js");
// Find from one [ to the last ]
$matches = array();
preg_match_all('/\[.*\]/', $str, $matches);
// Set variables
foreach ($matches['0'] as $match)
{
$values = array();
preg_match_all('/\".*\"/', $match, $values);
$result = trim($values["0"]["0"],
'"');
$final_result = explode(',', $result);
$templates[] = array(
'title' => trim($final_result['0'], '
" '),
'description' => trim($final_result['2'],
' " '),
'url' => JUri::root(true) . '/' .
trim($final_result['1'], ' " '),
);
}
}
else
{
foreach (glob(JPATH_ROOT .
'/media/editors/tinymce/templates/*.html') as $filename)
{
$filename = basename($filename, '.html');
if ($filename !== 'index')
{
$lang = JFactory::getLanguage();
$title = $filename;
$description = ' ';
if ($lang->hasKey('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_TITLE'))
{
$title = JText::_('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_TITLE');
}
if ($lang->hasKey('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_DESC'))
{
$description = JText::_('PLG_TINY_TEMPLATE_' .
strtoupper($filename) . '_DESC');
}
$templates[] = array(
'title' => $title,
'description' => $description,
'url' => JUri::root(true) .
'/media/editors/tinymce/templates/' . $filename .
'.html',
);
}
}
}
}
// Print
$print = $this->params->get('print', 1);
if (isset($access[$print]))
{
$plugins[] = 'print';
$toolbar4_add[] = '|';
$toolbar4_add[] = 'print';
$toolbar4_add[] = 'preview';
}
// Spellchecker
$spell = $this->params->get('spell', 0);
if (isset($access[$spell]))
{
$plugins[] = 'spellchecker';
$toolbar4_add[] = '|';
$toolbar4_add[] = 'spellchecker';
}
// Wordcount
$wordcount = $this->params->get('wordcount', 1);
if (isset($access[$wordcount]))
{
$plugins[] = 'wordcount';
}
// Advlist
$advlist = $this->params->get('advlist', 1);
if (isset($access[$advlist]))
{
$plugins[] = 'advlist';
}
// Codesample
$advlist = $this->params->get('code_sample', 1);
if (isset($access[$advlist]))
{
$plugins[] = 'codesample';
$toolbar4_add[] = 'codesample';
}
// Autosave
$autosave = $this->params->get('autosave', 1);
if (isset($access[$autosave]))
{
$plugins[] = 'autosave';
}
// Context menu
$contextmenu = $this->params->get('contextmenu', 1);
if (isset($access[$contextmenu]))
{
$plugins[] = 'contextmenu';
}
$custom_plugin = $this->params->get('custom_plugin',
'');
if ($custom_plugin != "")
{
$plugins[] = $custom_plugin;
}
$custom_button = $this->params->get('custom_button',
'');
if ($custom_button != "")
{
$toolbar4_add[] = $custom_button;
}
// Drag and drop Images
$externalPlugins = array();
$allowImgPaste = false;
$dragdrop = $this->params->get('drag_drop', 1);
if ($dragdrop && $user->authorise('core.create',
'com_media'))
{
$allowImgPaste = true;
$isSubDir = '';
$session = JFactory::getSession();
$uploadUrl = JUri::base() .
'index.php?option=com_media&task=file.upload&tmpl=component&'
. $session->getName() . '=' . $session->getId()
. '&' . JSession::getFormToken() . '=1'
. '&asset=image&format=json';
if ($app->isClient('site'))
{
$uploadUrl = htmlentities($uploadUrl, null, 'UTF-8', null);
}
// Is Joomla installed in subdirectory
if (JUri::root(true) != '/')
{
$isSubDir = JUri::root(true);
}
JText::script('PLG_TINY_ERR_UNSUPPORTEDBROWSER');
$scriptOptions['setCustomDir'] = $isSubDir;
$scriptOptions['mediaUploadPath'] =
$this->params->get('path', '');
$scriptOptions['uploadUri'] = $uploadUrl;
$externalPlugins = array(
array(
'jdragdrop' => HTMLHelper::_(
'script',
'editors/tinymce/plugins/dragdrop/plugin.min.js',
array('relative' => true, 'version' =>
'auto', 'pathOnly' => true)
),
),
);
}
// Prepare config variables
$plugins = implode(',', $plugins);
$elements = implode(',', $elements);
// Prepare config variables
$toolbar1 = implode(' ', $toolbar1_add) . ' | '
. implode(' ', $toolbar2_add) . ' | '
. implode(' ', $toolbar3_add) . ' | '
. implode(' ', $toolbar4_add);
// See if mobileVersion is activated
$mobileVersion = $this->params->get('mobile', 0);
$scriptOptions = array_merge(
$scriptOptions,
array(
'suffix' => '.min',
'baseURL' => JUri::root(true) .
'/media/editors/tinymce',
'directionality' => $text_direction,
'language' => $langPrefix,
'autosave_restore_when_empty' => false,
'skin' => $skin,
'theme' => $theme,
'schema' => 'html5',
// Cleanup/Output
'inline_styles' => true,
'gecko_spellcheck' => true,
'entity_encoding' =>
$this->params->get('entity_encoding', 'raw'),
'verify_html' => !$ignore_filter,
// URL
'relative_urls' => (bool)
$this->params->get('relative_urls', true),
'remove_script_host' => false,
// Layout
'content_css' => $content_css,
'document_base_url' => JUri::root(true) . '/',
'paste_data_images' => $allowImgPaste,
'externalPlugins' => json_encode($externalPlugins),
)
);
if ($this->params->get('newlines'))
{
// Break
$scriptOptions['force_br_newlines'] = true;
$scriptOptions['force_p_newlines'] = false;
$scriptOptions['forced_root_block'] = '';
}
else
{
// Paragraph
$scriptOptions['force_br_newlines'] = false;
$scriptOptions['force_p_newlines'] = true;
$scriptOptions['forced_root_block'] = 'p';
}
/**
* Shrink the buttons if not on a mobile or if mobile view is off.
* If mobile view is on force into simple mode and enlarge the buttons
**/
if (!$this->app->client->mobile)
{
$scriptOptions['toolbar_items_size'] = 'small';
}
elseif ($mobileVersion)
{
$mode = 0;
}
switch ($mode)
{
case 0: /* Simple mode*/
$scriptOptions['menubar'] = false;
$scriptOptions['toolbar1'] = 'bold italic underline
strikethrough | undo redo | bullist numlist | code';
$scriptOptions['plugins'] = ' code';
break;
case 1:
default: /* Advanced mode*/
$toolbar1 = "bold italic underline strikethrough | alignleft
aligncenter alignright alignjustify | formatselect | bullist numlist "
. "| outdent indent | undo redo | link unlink anchor code | hr
table | subscript superscript | charmap";
$scriptOptions['valid_elements'] = $valid_elements;
$scriptOptions['extended_valid_elements'] = $elements;
$scriptOptions['invalid_elements'] = $invalid_elements;
$scriptOptions['plugins'] = 'table link code hr charmap
autolink lists importcss ';
$scriptOptions['toolbar1'] = $toolbar1;
$scriptOptions['removed_menuitems'] =
'newdocument';
$scriptOptions['importcss_append'] = true;
$scriptOptions['height'] = $html_height;
$scriptOptions['width'] = $html_width;
$scriptOptions['resize'] = $resizing;
break;
case 2: /* Extended mode*/
$scriptOptions['valid_elements'] = $valid_elements;
$scriptOptions['extended_valid_elements'] = $elements;
$scriptOptions['invalid_elements'] = $invalid_elements;
$scriptOptions['plugins'] = $plugins;
$scriptOptions['toolbar1'] = $toolbar1;
$scriptOptions['removed_menuitems'] =
'newdocument';
$scriptOptions['rel_list'] = array(
array('title' => 'None', 'value'
=> ''),
array('title' => 'Alternate', 'value'
=> 'alternate'),
array('title' => 'Author', 'value'
=> 'author'),
array('title' => 'Bookmark', 'value'
=> 'bookmark'),
array('title' => 'Help', 'value'
=> 'help'),
array('title' => 'License', 'value'
=> 'license'),
array('title' => 'Lightbox', 'value'
=> 'lightbox'),
array('title' => 'Next', 'value'
=> 'next'),
array('title' => 'No Follow', 'value'
=> 'nofollow'),
array('title' => 'No Referrer',
'value' => 'noreferrer'),
array('title' => 'Prefetch', 'value'
=> 'prefetch'),
array('title' => 'Prev', 'value'
=> 'prev'),
array('title' => 'Search', 'value'
=> 'search'),
array('title' => 'Tag', 'value' =>
'tag'),
);
$scriptOptions['importcss_append'] = true;
$scriptOptions['image_advtab'] = $image_advtab;
$scriptOptions['height'] = $html_height;
$scriptOptions['width'] = $html_width;
$scriptOptions['resize'] = $resizing;
$scriptOptions['templates'] = $templates;
break;
}
$options['tinyMCE']['default'] = $scriptOptions;
$doc->addStyleDeclaration(".mce-in { padding: 5px 10px
!important;}");
$doc->addScriptOptions('plg_editor_tinymce', $options);
return $editor;
}
}
tinymce/tinymce.xml000064400000003267151167742660010435 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension version="3.2" type="plugin"
group="editors" method="upgrade">
<name>plg_editors_tinymce</name>
<version>4.5.12</version>
<creationDate>2005-2020</creationDate>
<author>Tiny Technologies, Inc</author>
<authorEmail>N/A</authorEmail>
<authorUrl>https://www.tiny.cloud</authorUrl>
<copyright>Tiny Technologies, Inc</copyright>
<license>LGPL</license>
<description>PLG_TINY_XML_DESCRIPTION</description>
<files>
<filename plugin="tinymce">tinymce.php</filename>
<folder>fields</folder>
<folder>form</folder>
</files>
<media destination="editors" folder="media">
<folder>tinymce</folder>
</media>
<languages>
<language
tag="en-GB">en-GB.plg_editors_tinymce.ini</language>
<language
tag="en-GB">en-GB.plg_editors_tinymce.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="configuration"
type="tinymcebuilder"
hiddenLabel="true"
/>
</fieldset>
<fieldset name="advanced"
label="PLG_TINY_FIELD_LABEL_ADVANCEDPARAMS">
<field
name="sets_amount"
type="number"
label="PLG_TINY_FIELD_NUMBER_OF_SETS_LABEL"
description="PLG_TINY_FIELD_NUMBER_OF_SETS_DESC"
filter="int"
validate="number"
min="3"
default="3"
/>
<field
name="html_height"
type="text"
label="PLG_TINY_FIELD_HTMLHEIGHT_LABEL"
description="PLG_TINY_FIELD_HTMLHEIGHT_DESC"
default="550px"
/>
<field
name="html_width"
type="text"
label="PLG_TINY_FIELD_HTMLWIDTH_LABEL"
description="PLG_TINY_FIELD_HTMLWIDTH_DESC"
default=""
/>
</fieldset>
</fields>
</config>
</extension>