| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/classes.zip |
PK 8�!]�`�} } manager.phpnu &1i� <?php
/**
* @package JCE
* @subpackage Editor
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
class WFMediaManager extends WFMediaManagerBase
{
}PK 8�!]~4�s^- ^-
packer.phpnu &1i� <?php
/**
* @package JCE
* @subpackage Editor
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Uri\Uri;
class WFPacker extends CMSObject
{
const IMPORT_RX = '#@import.*?(?:\(([^\)]+)\);|(?:[\'"]([^\'"]+)[\'"]);)#i'; // match @import url('...'); or @import '...'; or @import "...";
protected $files = array();
protected $type = 'javascript';
protected $text = '';
protected $start = '';
protected $end = '';
protected static $imports = array();
/**
* Constructor activating the default information of the class.
*/
public function __construct($config = array())
{
$this->setProperties($config);
}
public function setFiles($files = array())
{
$this->files = $files;
}
public function getFiles()
{
return $this->files;
}
public function setText($text = '')
{
$this->text = $text;
}
public function setContentStart($start = '')
{
$this->start = $start;
}
public function getContentStart()
{
return $this->start;
}
public function setContentEnd($end = '')
{
$this->end = $end;
}
public function getContentEnd()
{
return $this->end;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
/**
* Get encoding.
*
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved
*/
private static function getEncoding()
{
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
return false;
}
$encoding = false;
if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
$encoding = 'gzip';
}
if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
$encoding = 'x-gzip';
}
return $encoding;
}
private function getEtag($hash)
{
if (strpos($hash, '"') !== 0) {
$hash = '"' . $hash . '"';
}
return $hash;
}
/**
* Pack and output content based on type.
*
* @param bool|true $minify
* @param bool|true $cache
* @param bool|false $gzip
* Contains some code from libraries/joomla/cache/controller/page.php - Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved
*/
public function pack($minify = true, $cache_validation = true, $gzip = false)
{
$type = $this->getType();
ob_start();
// Headers
if ($type == 'javascript') {
header('Content-type: application/javascript; charset: UTF-8');
}
if ($type == 'css') {
header('Content-type: text/css; charset: UTF-8');
}
// encoding
header('Vary: Accept-Encoding');
// cache control
header('Cache-Control: max-age=0,no-cache');
$files = $this->getFiles();
$content = $this->getContentStart();
if (empty($files)) {
$content .= $this->getText();
} else {
foreach ($files as $file) {
$content .= $this->getText($file, $minify);
}
}
if ($this->getType() == 'css') {
// move external import rules to top
foreach (array_unique(self::$imports) as $import) {
if (strpos($import, '//') !== false) {
$content = '@import url("' . $import . '");' . $content;
}
}
}
$content .= $this->getContentEnd();
// trim content
$content = trim($content);
// force browser caching using an E-tag
if ($cache_validation) {
// get content hash
$hash = md5(implode(' ', array_map('basename', $files)) . $content);
// create E-tag
$etag = $this->getEtag($hash);
// set etag header
header('ETag: ' . $etag);
// check for sent etag against hash
if (!headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
if ($_etag && $_etag === $etag) {
header('HTTP/1.x 304 Not Modified', true);
exit(ob_get_clean());
}
}
}
// Generate GZIP'd content
if ($gzip) {
$encoding = self::getEncoding();
$zlib = function_exists('ini_get') && extension_loaded('zlib') && ini_get('zlib.output_compression');
if (!empty($encoding) && !$zlib && function_exists('gzencode')) {
header('Content-Encoding: ' . $encoding);
$content = gzencode($content, 4, FORCE_GZIP);
}
}
// stream to client
echo $content;
exit(ob_get_clean());
}
protected function jsmin($data)
{
// remove header comments
return preg_replace('#^\/\*[\s\S]+?\*\/#', '', $data);
}
/**
* Simple CSS Minifier
* https://github.com/GaryJones/Simple-PHP-CSS-Minification.
*
* @param $data Data string to minify
*/
protected function cssmin($css)
{
// Normalize whitespace
//$css = preg_replace('/\s+/', ' ', $css);
// Remove comment blocks, everything between /* and */, unless
// preserved with /*! ... */
//$css = preg_replace('/\/\*[^\!](.*?)\*\//', '', $css);
// Remove space after , : ; { }
//$css = preg_replace('/(,|:|;|\{|}) /', '$1', $css);
// Remove space before , ; { }
//$css = preg_replace('/ (,|;|\{|})/', '$1', $css);
// Strips leading 0 on decimal values (converts 0.5px into .5px)
//$css = preg_replace('/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css);
// Strips units if value is 0 (converts 0px to 0)
//$css = preg_replace('/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css);
// Converts all zeros value into short-hand
//$css = preg_replace('/0 0 0 0/', '0', $css);
// Shortern 6-character hex color codes to 3-character where possible
//$css = preg_replace('/#([a-f0-9])\\1([a-f0-9])\\2([a-f0-9])\\3/i', '#\1\2\3', $css);
require_once __DIR__ . '/vendor/cssmin/cssmin.php';
try {
$css = CssMin::minify($css);
} catch (Exception $e) {
}
return trim($css);
}
/**
* Import CSS from a file.
*
* @param file File path where data comes from
* @param $data Data from file
*/
protected function importCss($data, $file)
{
if (preg_match_all(self::IMPORT_RX, $data, $matches)) {
$data = '';
foreach ($matches[1] as $match) {
// clean up url
$match = str_replace(array('url', '"', "'", '(', ')'), '', $match);
// trim
$match = trim($match);
if ($match) {
// external url, skip it
if (strpos($match, '//') !== false) {
// add to imports list
self::$imports[] = $match;
continue;
}
// url has a query, remove
if (strpos($match, '?') !== false) {
$match = substr($match, 0, strpos($match, '?'));
}
if (strpos($match, '&') !== false) {
$match = substr($match, 0, strpos($match, '&'));
}
// get full path
$path = realpath($this->get('_cssbase') . '/' . $match);
// already import, don't repeat!
if (in_array($path, self::$imports)) {
continue;
}
// get data
$data .= $this->getText($path);
}
}
return $data;
}
return '';
}
protected function compileLess($string, $path)
{
$less = new lessc();
// add file directory
$less->addImportDir($path);
// add joomla media folder
$less->addImportDir(JPATH_SITE . '/media');
try {
return $less->compile($string);
} catch (Exception $e) {
return '/* LESS file could not be compiled due to error - ' . $e->getMessage() . ' */';
}
}
protected function getText($file = null, $minify = true)
{
if ($file && is_file($file)) {
$text = file_get_contents($file);
if ($text) {
// process css files
if ($this->getType() == 'css') {
// compile less files
if (preg_match('#\.less$#', $file)) {
$text = $this->compileLess($text, dirname($file));
}
if ($minify) {
// minify
$text = $this->cssmin($text, $file);
}
// add to imports list
self::$imports[] = $file;
if (strpos($text, '@import') !== false) {
// store the base path of the current file
$this->set('_cssbase', dirname($file));
// process import rules
$text = $this->importCss($text, $file) . preg_replace(self::IMPORT_RX, '', $text);
}
// store the base path of the current file
$this->set('_imgbase', dirname($file));
// process urls
$text = preg_replace_callback('#url\s?\([\'"]?([^\'"\))]+)[\'"]?\)#', array('WFPacker', 'processPaths'), $text);
}
// make sure text ends in a semi-colon;
if ($this->getType() == 'javascript') {
$text = rtrim(trim($text), ';') . ';';
if ($minify) {
$text = $this->jsmin($text);
}
}
return $text;
}
}
return $this->text;
}
protected function processPaths($data)
{
if (isset($data[1])) {
if (strpos($data[1], '//') === false) {
$path = parse_url($data[1], PHP_URL_PATH);
if (empty($path)) {
$path = $data[1];
}
// get query, if any, eg: ?v=273
$query = parse_url($data[1], PHP_URL_QUERY);
if (empty($query)) {
$query = "";
} else {
$query = "?" . $query;
}
$path = str_replace(JPATH_SITE, '', realpath($this->get('_imgbase') . '/' . $path));
if ($path) {
return "url('" . Uri::root(true) . str_replace('\\', '/', $path) . $query . "')";
}
return "url('" . $data[1] . "')";
}
return $data[1];
}
return '';
}
}
PK 8�!]O���04 04 languageparser.phpnu &1i� <?php
/**
* @package JCE
* @subpackage Editor
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Filesystem\Path;
use Joomla\CMS\Object\CMSObject;
class WFLanguageParser extends CMSObject
{
protected $mode = 'editor';
protected $plugins = array();
protected $sections = array();
protected $language = 'en-GB';
/**
* Cache of processed data.
*
* @var array
*
* @since 11.1
*/
protected static $cache = array();
public function __construct($config = array())
{
if (array_key_exists('plugins', $config)) {
$config['plugins'] = (array) $config['plugins'];
}
if (array_key_exists('sections', $config)) {
$config['sections'] = (array) $config['sections'];
}
if (array_key_exists('language', $config)) {
$config['language'] = $config['language'];
}
$this->setProperties($config);
}
/**
* Parse an INI formatted string and convert it into an array.
*
* @param string $data INI formatted string to convert
* @param bool $process_sections A boolean setting to process sections
* @param array $sections An array of sections to include
* @param mixed $filter A regular expression to filter sections by
*
* @return array Data array
*
* @since 2.4
*
* Based on JRegistryFormatINI::stringToObject
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
protected static function ini_to_array($data, $process_sections = false, $sections = array(), $filter = '')
{
// Check the memory cache for already processed strings.
$hash = md5($data . ':' . (int) $process_sections . ':' . serialize($sections) . ':' . $filter);
if (isset(self::$cache[$hash])) {
return self::$cache[$hash];
}
// If no lines present just return the array.
if (empty($data)) {
return array();
}
$array = array();
$section = false;
$lines = explode("\n", $data);
// Process the lines.
foreach ($lines as $line) {
// Trim any unnecessary whitespace.
$line = trim($line);
// Ignore empty lines and comments.
if (empty($line) || ($line[0] == ';')) {
continue;
}
if ($process_sections) {
$length = strlen($line);
// If we are processing sections and the line is a section add the object and continue.
if (($line[0] == '[') && ($line[$length - 1] == ']')) {
$section = substr($line, 1, $length - 2);
// filter section by regular expression
if ($filter) {
if (preg_match('#' . $filter . '#', $section)) {
continue;
}
}
// allow all sections
if (empty($sections)) {
$array[$section] = array();
} else {
if (in_array($section, $sections)) {
$array[$section] = array();
}
}
continue;
}
} elseif ($line[0] == '[') {
continue;
}
// Check that an equal sign exists and is not the first character of the line.
if (!strpos($line, '=')) {
// Maybe throw exception?
continue;
}
// Get the key and value for the line.
list($key, $value) = explode('=', $line, 2);
// Validate the key.
if (preg_match('/[^A-Z0-9_]/i', $key)) {
// Maybe throw exception?
continue;
}
// If the value is quoted then we assume it is a string.
$length = strlen($value);
if ($length && ($value[0] == '"') && ($value[$length - 1] == '"')) {
// Strip the quotes and Convert the new line characters.
$value = stripcslashes(substr($value, 1, ($length - 2)));
$value = str_replace(array("\n", "\r"), array('\n', '\r'), $value);
} else {
// If the value is not quoted, we assume it is not a string.
// If the value is 'false' assume boolean false.
if ($value == 'false') {
$value = false;
}
// If the value is 'true' assume boolean true.
elseif ($value == 'true') {
$value = true;
}
// If the value is numeric than it is either a float or int.
elseif (is_numeric($value)) {
// If there is a period then we assume a float.
if (strpos($value, '.') !== false) {
$value = (float) $value;
} else {
$value = (int) $value;
}
}
}
// If a section is set add the key/value to the section, otherwise top level.
if ($section) {
$array[$section][$key] = $value;
} else {
$array[$key] = $value;
}
}
// Cache the string
self::$cache[$hash] = $array;
return $array;
}
protected static function getOverrides()
{
// get the language file
$language = Factory::getLanguage();
// get language tag
$tag = $language->getTag();
$file = JPATH_SITE . '/language/overrides/' . $tag . '.override.ini';
$ini = array();
if (is_file($file)) {
$content = @file_get_contents($file);
if ($content && is_string($content)) {
$ini = @parse_ini_string($content, true);
}
}
return $ini;
}
protected static function filterSections($ini, $sections = array(), $filter = '')
{
if ($ini && is_array($ini)) {
if (!empty($sections)) {
$ini = array_intersect_key($ini, array_flip($sections));
}
// filter keys by regular expression
if ($filter) {
foreach (array_keys($ini) as $key) {
if (preg_match('#' . $filter . '#', $key)) {
unset($ini[$key]);
}
}
}
}
return $ini;
}
protected static function processLanguageINI($files, $sections = array(), $filter = '')
{
$data = array();
foreach ((array) $files as $file) {
if (!is_file($file)) {
continue;
}
$ini = false;
$content = @file_get_contents($file);
if ($content && is_string($content)) {
if (function_exists('parse_ini_string')) {
$ini = @parse_ini_string($content, true);
// filter
$ini = self::filterSections($ini, $sections, $filter);
} else {
$ini = self::ini_to_array($content, true, $sections, $filter);
}
}
// merge with data array
if ($ini && is_array($ini)) {
$data = array_merge($data, $ini);
}
}
$output = '';
// get overrides
$overrides = self::getOverrides();
if (!empty($data)) {
$x = 0;
foreach ($data as $key => $strings) {
if (is_array($strings)) {
$output .= '"' . strtolower($key) . '":{';
$i = 0;
foreach ($strings as $k => $v) {
if (!empty($overrides) && array_key_exists(strtoupper($k), $overrides)) {
$v = $overrides[$k];
}
// remove "
$v = str_replace('"', '', $v);
if (is_numeric($v)) {
$v = (float) $v;
} else {
$v = '"' . $v . '"';
}
// key to lowercase
$k = strtolower($k);
// remove WF_
$k = str_replace('wf_', '', $k);
// remove "_dlg"
$key = preg_replace('#_dlg$#', '', $key);
// remove the section name
$k = preg_replace('#^' . $key . '(_dlg)?_#', '', $k);
// hex colours to uppercase and remove marker
if (strpos($k, 'hex_') !== false) {
$k = strtoupper(str_replace('hex_', '', $k));
}
// create key/value pair as JSON string
$output .= '"' . $k . '":' . $v . ',';
++$i;
}
// remove last comma
$output = rtrim(trim($output), ',');
$output .= '},';
++$x;
}
}
// remove last comma
$output = rtrim(trim($output), ',');
}
return $output;
}
private function getFilter()
{
return '';
}
public function load($files = array())
{
// get language tag
$tag = $this->language;
// base language path
$path = JPATH_SITE . '/language/' . $tag;
// if no file set
if (empty($files)) {
// Add English language
$files[] = JPATH_SITE . '/language/en-GB/en-GB.com_jce.ini';
// add pro language file
$files[] = JPATH_SITE . '/language/en-GB/en-GB.com_jce_pro.ini';
// non-english language
if ($tag != 'en-GB') {
if (is_dir($path)) {
$core = $path . '/' . $tag . '.com_jce.ini';
$pro = $path . '/' . $tag . '.com_jce_pro.ini';
if (is_file($core)) {
$files[] = $core;
if (is_file($pro)) {
$files[] = $pro;
}
} else {
$tag = 'en-GB';
}
} else {
$tag = 'en-GB';
}
}
$plugins = $this->get('plugins');
if (!empty($plugins)) {
foreach ($plugins['external'] as $name => $plugin) {
// rewrite name from plugin url
$name = basename(dirname($plugin));
$name = str_replace('plg_jce_', '', $name);
$filename = 'en-GB.plg_jce_' . $name . '.ini';
// add English file
$ini = Path::find(array(
JPATH_ADMINISTRATOR . '/language/en-GB',
JPATH_PLUGINS . '/jce/' . $name . '/language/en-GB'
), $filename);
if ($ini) {
$files[] = $ini;
}
// non-english language
if ($tag != 'en-GB') {
$filename = $tag . '.plg_jce_' . $name . '.ini';
$ini = Path::find(array(
JPATH_ADMINISTRATOR . '/language/' . $tag,
JPATH_PLUGINS . '/jce/' . $name . '/language/' . $tag
), $filename);
if ($ini) {
$files[] = $ini;
}
}
}
}
}
// shorten the tag, eg: en-GB -> en
$tag = substr($tag, 0, strpos($tag, '-'));
$sections = $this->get('sections');
$filter = $this->getFilter();
$data = self::processLanguageINI($files, $sections, $filter);
// clean data
$data = rtrim(trim($data), ',');
return 'tinyMCE.addI18n({"' . $tag . '":{' . $data . '}});';
}
public function output($data)
{
if ($data) {
ob_start();
header('Content-type: application/javascript; charset: UTF-8');
header('Vary: Accept-Encoding');
// cache control
header('Cache-Control: max-age=0,no-cache');
// get content hash
$hash = md5($data);
// set etag header
header('ETag: "' . $hash . '"');
echo $data;
exit(ob_get_clean());
}
exit();
}
}
PK 8�!]� } } view.phpnu &1i� <?php
/**
* @package JCE
* @subpackage Editor
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\Filesystem\Path;
use Joomla\CMS\Object\CMSObject;
final class WFView extends CMSObject
{
private $path = array();
public function __construct($config = array())
{
if (!array_key_exists('base_path', $config)) {
$config['base_path'] = WF_EDITOR_LIBRARIES;
}
if (!array_key_exists('layout', $config)) {
$config['layout'] = 'default';
}
if (!array_key_exists('name', $config)) {
$config['name'] = '';
}
$this->setProperties($config);
if (array_key_exists('template_path', $config)) {
$this->addTemplatePath($config['template_path']);
} else {
$this->addTemplatePath($this->get('base_path') . '/views/' . $this->getName() . '/tmpl');
}
}
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse;
* automatically searches through the template paths
*
* @copyright Copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved
* @license GNU/GPL, see LICENSE.php
*/
public function display($tpl = null)
{
$result = $this->loadTemplate($tpl);
if ($result instanceof Exception) {
return $result;
}
echo $result;
}
public function getName()
{
return $this->get('name');
}
public function setLayout($layout)
{
$this->set('layout', $layout);
}
public function getLayout()
{
return $this->get('layout');
}
public function addTemplatePath($path)
{
$this->path[] = $path;
}
public function getTemplatePath()
{
return $this->path;
}
/**
* Load a template file.
*
* @param string $tpl The name of the template source file ...
* automatically searches the template paths and compiles as needed
*
* @return string The output of the the template script.
*
* @copyright Copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved
* @license GNU/GPL, see LICENSE.php
*/
public function loadTemplate($tpl = null)
{
// clear prior output
$output = null;
$template = null;
//create the template file name based on the layout
$file = isset($tpl) ? $this->getLayout() . '_' . $tpl : $this->getLayout();
// clean the file name
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $file);
if (isset($tpl)) {
$tpl = preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl);
}
$path = $this->getTemplatePath();
$template = Path::find($path, $file . '.php');
if ($template != false) {
// unset so as not to introduce into template scope
unset($tpl);
unset($file);
// never allow a 'this' property
if (isset($this->this)) {
unset($this->this);
}
// start capturing output into a buffer
ob_start();
// include the requested template filename in the local scope
// (this will execute the view logic).
include $template;
// done with the requested template; get the buffer and
// clear it.
$output = ob_get_contents();
ob_end_clean();
return $output;
} else {
throw new InvalidArgumentException('Layout "' . $file . '" not found in Paths ' . implode(', ', $path));
}
}
}
PK 8�!]b� �� �
editor.phpnu &1i� <?php
/**
* @package JCE
* @subpackage Editor
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
class WFEditor
{
// Editor instance
protected static $instances;
/**
* Profile object.
*
* @var object
*/
private $profile = null;
/**
* Context hash.
*
* @var string
*/
protected $context = '';
/**
* Array of linked scripts.
*
* @var array
*/
private $scripts = array();
/**
* Array of linked style sheets.
*
* @var array
*/
private $stylesheets = array();
/**
* Array of included style declarations.
*
* @var array
*/
private $styles = array();
/**
* Array of scripts placed in the header.
*
* @var array
*/
private $javascript = array();
/**
* Array of script options.
*
* @var array
*/
private $scriptOptions = array();
/**
* Array of core plugins
*
* @var array
*/
private static $plugins = array('core', 'help', 'autolink', 'effects', 'cleanup', 'code', 'format', 'importcss', 'colorpicker', 'blobupload', 'upload', 'figure', 'ui', 'noneditable', 'branding');
/**
* Initialization state
*
* @var boolean
*/
public $initialized = false;
private function addScript($url, $type = 'text/javascript')
{
$url = $this->addAssetVersion($url);
$this->scripts[$url] = $type;
}
private function addStyleSheet($url)
{
$url = $this->addAssetVersion($url);
$this->stylesheets[] = $url;
}
private function addScriptDeclaration($text)
{
$this->javascript[] = $text;
}
private function addScriptOptions($text)
{
$this->scriptOptions[] = $text;
}
private function addStyleDeclaration($text)
{
$this->styles[] = $text;
}
public function getScripts()
{
return $this->scripts;
}
public function getStyleSheets()
{
return $this->stylesheets;
}
public function getScriptDeclaration()
{
return $this->javascript;
}
public function getScriptOptions()
{
return $this->scriptOptions;
}
public function __construct($config = array())
{
$app = Factory::getApplication();
$wf = WFApplication::getInstance();
if (!isset($config['plugin'])) {
$config['plugin'] = '';
}
if (!isset($config['profile_id'])) {
$config['profile_id'] = 0;
}
// trigger event
$app->triggerEvent('onBeforeWfEditorLoad', array(&$config));
// set profile from "default"
$this->profile = $wf->getActiveProfile($config);
// set context
$this->context = $wf->getContext();
}
/**
* Returns a reference to a editor object.
*
* This method must be invoked as:
* <pre> $editor =WFEditor::getInstance();</pre>
*
* @return JCE The editor object
*/
public static function getInstance($config = array())
{
$signature = md5(serialize($config));
if (empty(self::$instances[$signature])) {
self::$instances[$signature] = new self($config);
}
return self::$instances[$signature];
}
private function addAssetVersion($url)
{
$version = md5(self::getVersion());
if (strpos($url, '?') === false) {
$url .= '?' . $version;
} else {
$url .= '&' . $version;
}
return $url;
}
/**
* Setup the editor
* This will create the settings array and render the editor
*
* @param boolean $autoInit Automatically initialize the editor
* @return WFEditor
*/
public function setup($autoInit = true)
{
if ($this->initialized) {
return $this;
}
$this->initialized = true;
$settings = $this->getSettings();
Factory::getApplication()->triggerEvent('onBeforeWfEditorRender', array(&$settings));
$this->render($settings, $autoInit);
return $this;
}
/**
* Legacy function to build the editor
*
* @return String
*/
public function buildEditor()
{
$this->setup()->getOutput();
}
/**
* Legacy function to get the editor settings
*
* @return array
*/
public function getEditorSettings()
{
return $this->getSettings();
}
private function getCompressionOptions()
{
$wf = WFApplication::getInstance();
// check for joomla debug mode
$debug = Factory::getConfig()->get('debug');
// default compression states
$options = array(
'javascript' => 0,
'css' => 0,
);
// set compression states, only if debug mode is off
if ((int) $debug === 0) {
$options = array(
'javascript' => (int) $wf->getParam('editor.compress_javascript', 0, 0),
'css' => (int) $wf->getParam('editor.compress_css', 0, 0),
);
}
return $options;
}
private function assignEditorSkin(&$settings)
{
// get an editor instance
$wf = WFApplication::getInstance();
// assign skin - new default is "modern"
$settings['skin'] = $wf->getParam('editor.toolbar_theme', 'modern');
if (empty($settings['skin'])) {
$settings['skin'] = 'modern';
}
if (strpos($settings['skin'], '.') !== false) {
list($settings['skin'], $settings['skin_variant']) = explode('.', $settings['skin']);
}
// classic has been removed
if ($settings['skin'] == 'classic') {
$settings['skin'] = 'default';
}
if ($settings['skin'] == 'mobile') {
$settings['skin'] = 'modern';
$settings['skin_variant'] = 'touch';
}
}
/**
* Porcess and assign custom configuration variables
*
* @param [Array] $settings
* @return void
*/
private function getCustomConfig(&$settings)
{
// get an editor instance
$wf = WFApplication::getInstance();
// Other - user specified
$userParams = $wf->getParam('editor.custom_config', '');
if ($userParams) {
// legacy format, eg: key:value;key:value
if (!WFUtility::isJson($userParams)) {
$userParams = explode(';', $userParams);
} else {
$userParams = json_decode($userParams, true);
}
// Remove values with invalid key, must be indexed array
$userParams = array_filter($userParams, function ($value, $key) {
return is_numeric($key) && $value != "";
}, ARRAY_FILTER_USE_BOTH);
foreach ($userParams as $userParam) {
if (empty($userParam)) {
continue;
}
$name = '';
$value = '';
// legacy string
if (is_string($userParam)) {
list($name, $value) = explode(':', $userParam);
}
// json associative array
if (is_array($userParam) && array_key_exists('name', $userParam)) {
extract($userParam);
}
if ($name && $value !== '') {
$value = trim($value, " \t\n\r\0\x0B'\"");
// convert to boolean
if (is_bool($value)) {
$value = (bool) $value;
}
$settings[$name] = $value;
}
}
}
}
private function isSkinRtl()
{
$language = Factory::getLanguage();
if ($language->getTag() === WFLanguage::getTag()) {
return $language->isRTL();
}
return false;
}
private function getLanguageDirection()
{
$user = Factory::getUser();
$params = ComponentHelper::getParams('com_languages');
$locale = $user->getParam('language', $params->get('site', 'en-GB'));
$language = Language::getInstance($locale);
return $language->isRTL() ? 'rtl' : 'ltr';
}
protected function getLanguageCode()
{
return WFLanguage::getCode();
}
protected function getLanguageTag()
{
return WFLanguage::getTag();
}
public function getSettings()
{
$app = Factory::getApplication();
// get an editor instance
$wf = WFApplication::getInstance();
// create token
$token = Session::getFormToken();
// get editor version
$version = self::getVersion();
$settings = array(
'token' => $token,
'base_url' => Uri::root(),
'language' => $this->getLanguageCode(),
'directionality' => $this->getLanguageDirection(),
'theme' => 'none',
'plugins' => '',
'skin' => 'default',
'query' => array(
$token => 1,
'context' => $this->context,
),
);
// if a profile is set
if (is_object($this->profile)) {
$settings['query']['profile_id'] = $this->profile->id;
$settings = array_merge($settings, array('theme' => 'advanced'), $this->getToolbar());
// add plugins
$plugins = $this->getPlugins();
// add core plugins
if (!empty($plugins['core'])) {
$settings['plugins'] = array_values($plugins['core']);
}
// add external plugins
if (!empty($plugins['external'])) {
$settings['external_plugins'] = $plugins['external'];
}
// Theme and skins
$theme = array(
'toolbar_location' => array('top', 'top', 'string'),
'toolbar_align' => array('left', 'left', 'string'),
'statusbar_location' => array('bottom', 'bottom', 'string'),
'path' => array(1, 1, 'boolean'),
'resizing' => array(1, 0, 'boolean'),
'resize_horizontal' => array(1, 1, 'boolean'),
);
// set rows key to pass to plugin config
$settings['rows'] = $this->profile->rows;
foreach ($theme as $k => $v) {
$settings['theme_' . $k] = $wf->getParam('editor.' . $k, $v[0], $v[1], $v[2]);
}
$settings['width'] = $wf->getParam('editor.width');
$settings['height'] = $wf->getParam('editor.height');
// process and assign the editor skin
$this->assignEditorSkin($settings);
// get body class if any
$body_class = $wf->getParam('editor.body_class', '');
// check for editor reset - options are 1, 0, auto
$settings['content_style_reset'] = $wf->getParam('editor.content_style_reset', 'auto');
// if enabled, add the "mceContentReset" class to the body
$content_reset = $settings['content_style_reset'] == 1 ? 'mceContentReset' : '';
// combine body class and reset
$settings['body_class'] = trim($body_class . ' ' . $content_reset);
// set body id
$settings['body_id'] = $wf->getParam('editor.body_id', '');
// get stylesheets
$stylesheets = (array) self::getTemplateStyleSheets();
// set stylesheets as string
$settings['content_css'] = implode(',', $stylesheets);
// use cookies to store state
$settings['use_state_cookies'] = (bool) $wf->getParam('editor.use_cookies', 1);
// Set active tab
$settings['active_tab'] = 'wf-editor-' . $wf->getParam('editor.active_tab', 'wysiwyg');
$settings['invalid_elements'] = array();
// Get all optional plugin configuration options
$this->getPluginConfig($settings);
// clean up invalid_elements
if (!empty($settings['invalid_elements'])) {
$settings['invalid_elements'] = array_values($settings['invalid_elements']);
}
} else {
$settings['readonly'] = true;
}
// get compression options stylesheet
$settings['compress'] = $this->getCompressionOptions();
// set css compression
if ($settings['compress']['css']) {
$this->addStyleSheet(Uri::base(true) . '/index.php?option=com_jce&task=editor.pack&type=css&' . http_build_query((array) $settings['query']));
} else {
// CSS
$this->addStyleSheet($this->getURL(true) . '/css/editor.min.css');
// load default skin
$this->addStyleSheet($this->getURL(true) . '/tinymce/themes/advanced/skins/default/ui.css');
// load other skin
if ($settings['skin'] != 'default') {
$this->addStyleSheet($this->getURL(true) . '/tinymce/themes/advanced/skins/' . $settings['skin'] . '/ui.css');
}
// load variant
if (isset($settings['skin_variant'])) {
$this->addStyleSheet($this->getURL(true) . '/tinymce/themes/advanced/skins/' . $settings['skin'] . '/ui_' . $settings['skin_variant'] . '.css');
}
}
if ($this->isSkinRtl()) {
$settings['skin_directionality'] = 'rtl';
}
$app->triggerEvent('onBeforeWfEditorSettings', array(&$settings));
// add module in Joomla 5
if (version_compare(JVERSION, '5', 'ge')) {
$this->addScript($this->getURL(true) . '/js/editor.module.js', 'module');
}
// set javascript compression script
if ($settings['compress']['javascript']) {
$this->addScript(Uri::base(true) . '/index.php?option=com_jce&task=editor.pack&' . http_build_query((array) $settings['query']));
} else {
// Tinymce
$this->addScript($this->getURL(true) . '/tinymce/tinymce.js');
// Editor
$this->addScript($this->getURL(true) . '/js/editor.min.js');
}
// language
$this->addScript(Uri::base(true) . '/index.php?option=com_jce&task=editor.loadlanguages&lang=' . $settings['language'] . '&' . http_build_query((array) $settings['query']));
$this->getCustomConfig($settings);
// process settings
array_walk($settings, function (&$value, $key) {
// remove 'rows' key from $settings
if ($key == "rows") {
$value = '';
}
// implode standard arrays
if (is_array($value) && $value === array_values($value)) {
$value = implode(',', $value);
}
// convert json strings to objects to prevent encoding
if (is_string($value)) {
// decode string
$val = json_decode($value);
// valid json
if ($val) {
$value = $val;
}
}
// convert stringified booleans to booleans
if (is_string($value) && $value == 'true') {
$value = true;
}
if (is_string($value) && $value == 'false') {
$value = false;
}
});
// Remove empty values
$settings = array_filter($settings, function ($value) {
return $value !== '';
});
return $settings;
}
public function render($settings, $autoInit = true)
{
// get an editor instance
$wf = WFApplication::getInstance();
if ($autoInit) {
// encode as json string
$tinymce = json_encode($settings, JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES);
$this->addScriptDeclaration("try{WfEditor.init(" . $tinymce . ");}catch(e){console.debug(e);}");
} else {
$this->addScriptOptions($settings);
}
if (is_object($this->profile)) {
if ($wf->getParam('editor.callback_file')) {
$this->addScript(Uri::root(true) . '/' . $wf->getParam('editor.callback_file'));
}
// add callback file if exists
if (is_file(JPATH_SITE . '/media/jce/js/editor.js')) {
$this->addScript(Uri::root(true) . '/media/jce/js/editor.js');
}
// add custom editor.css if exists
if (is_file(JPATH_SITE . '/media/jce/css/editor.css')) {
$this->addStyleSheet(Uri::root(true) . '/media/jce/css/editor.css');
}
}
}
private function getOutput()
{
$document = Factory::getDocument();
$end = $document->_getLineEnd();
$tab = $document->_getTab();
$version = self::getVersion();
$output = '';
foreach ($this->stylesheets as $stylesheet) {
// don't add hash to dynamic php url
if (strpos($stylesheet, 'index.php') === false) {
$version = md5(basename($stylesheet) . $version);
if (strpos($stylesheet, '?') === false) {
$stylesheet .= '?' . $version;
} else {
$stylesheet .= '&' . $version;
}
}
$output .= $tab . '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" />' . $end;
}
foreach ($this->scripts as $script) {
// don't add hash to dynamic php url
if (strpos($script, 'index.php') === false) {
$version = md5(basename($script) . $version);
if (strpos($script, '?') === false) {
$script .= '?' . $version;
} else {
$script .= '&' . $version;
}
}
$output .= $tab . '<script data-cfasync="false" type="text/javascript" src="' . $script . '" defer></script>' . $end;
}
foreach ($this->javascript as $script) {
$output .= $tab . '<script data-cfasync="false" type="text/javascript">' . $script . '</script>' . $end;
}
foreach ($this->styles as $style) {
$output .= $tab . '<style type="text/css">' . $style . '</style>' . $end;
}
return $output;
}
/**
* Get the current version from the editor manifest.
*
* @return Version
*/
private static function getVersion()
{
return WF_VERSION;
}
/**
* Check if an icon already exists in a toolbar row
*
* @param [Array] $rows
* @param [Mixed] $icon
* @return Boolean
*/
private function rowHasIcon($rows, $icon)
{
$found = false;
foreach ($rows as $key => $row) {
if (in_array($icon, $row)) {
$found = true;
break;
}
}
return $found;
}
/**
* Return a list of icons for each JCE editor row.
*
* @param string The number of rows
*
* @return The row array
*/
private function getToolbar()
{
$wf = WFApplication::getInstance();
$rows = array('theme_buttons1' => array(), 'theme_buttons2' => array(), 'theme_buttons3' => array());
// we need a profile object and some defined rows
if (!is_object($this->profile) || empty($this->profile->rows)) {
return $rows;
}
// get plugins
$plugins = JcePluginsHelper::getPlugins();
// get core commands
$commands = JcePluginsHelper::getCommands();
// merge plugins and commands
$icons = array_merge($commands, $plugins);
// create an array of rows
$lists = explode(';', $this->profile->rows);
// backwards compatability map
$map = array(
'paste' => 'clipboard',
'spacer' => '|',
'forecolor' => 'fontcolor',
'backcolor' => 'backcolor',
);
$x = 0;
for ($i = 1; $i <= count($lists); ++$i) {
$buttons = array();
$items = explode(',', $lists[$x]);
// map legacy values etc.
array_walk($items, function (&$item) use ($map) {
if (array_key_exists($item, $map)) {
$item = $map[$item];
}
});
// remove duplicates
$items = array_unique($items);
foreach ($items as $item) {
// set the plugin/command name
$name = $item;
// check if button should be in toolbar
if ($item !== '|') {
if (array_key_exists($item, $icons) === false) {
continue;
}
// assign icon
$item = $icons[$item]->icon;
}
// check for custom plugin buttons
if (array_key_exists($name, $plugins)) {
$custom = $wf->getParam($name . '.buttons');
if (!empty($custom)) {
$custom = array_filter((array) $custom);
if (empty($custom)) {
$item = '';
} else {
$a = array();
foreach (explode(',', $item) as $s) {
if (in_array($s, $custom) || $s == '|') {
$a[] = $s;
}
}
$item = implode(',', $a);
// remove leading or trailing |
$item = trim($item, '|');
}
}
}
if (!empty($item)) {
// remove double spacer
$item = preg_replace('#(\|,)+#', '|,', $item);
if ($this->rowHasIcon($rows, $item)) {
continue;
}
$buttons[] = $item;
}
}
if (!empty($buttons)) {
$rows['theme_buttons' . $i] = $buttons;
}
++$x;
}
return $rows;
}
/**
* Determine whether the editor has a profile assigned
*
* @return boolean
*/
public function hasProfile()
{
return is_object($this->profile);
}
/**
* Determine whether a plugin is loaded
*
* @param [string] $name
* @return boolean
*/
public function hasPlugin($name)
{
$plugins = $this->getPlugins();
if (in_array($name, $plugins['core'])) {
return true;
}
if (!empty($plugins['external'])) {
if (array_key_exists($name, $plugins['external'])) {
return true;
}
}
return false;
}
/**
* Return a list of published JCE plugins.
*
* @return string list
*/
public function getPlugins()
{
static $plugins;
$wf = WFApplication::getInstance();
if (is_object($this->profile)) {
if (!is_array($plugins)) {
// get plugin items from profile
$profile_plugins = explode(',', $this->profile->plugins);
$items = array();
// get core and installed plugins list
$list = JcePluginsHelper::getPlugins();
// check that the plugin is available
$items = array_filter(array_keys($list), function ($item) use ($profile_plugins) {
return in_array($item, $profile_plugins);
});
// add advlists plugin if lists are loaded
if (in_array('lists', $items)) {
$items[] = 'advlist';
}
// Load wordcount if enabled
if ($wf->getParam('editor.wordcount', 1)) {
$items[] = 'wordcount';
}
// reset index
$items = array_values($items);
// add core plugins
$items = array_merge(self::$plugins, $items);
// remove duplicates and empty values
$items = array_unique(array_filter($items));
// create plugins array
$plugins = array('core' => array(), 'external' => array());
// check installed plugins are valid
foreach ($list as $name => $attribs) {
// skip core plugins
if ($attribs->core) {
continue;
}
// find plugin key in plugins list
$pos = array_search($name, $items);
// check it is in profile plugin list
if ($pos === false) {
continue;
}
// remove from items array
unset($items[$pos]);
// reset index
$items = array_values($items);
// legacy file name
if (is_file($attribs->path . '/editor_plugin.js')) {
$plugins['external'][$name] = Uri::root(true) . '/' . $attribs->url . '/editor_plugin.js';
} else {
$plugins['external'][$name] = Uri::root(true) . '/' . $attribs->url . '/plugin.js';
}
}
// remove missing plugins
$items = array_filter($items, function ($item) {
return is_file(WF_EDITOR_MEDIA . '/tinymce/plugins/' . $item . '/plugin.js');
});
// update core plugins
$plugins['core'] = $items;
}
}
return $plugins;
}
/**
* Get all loaded plugins config options.
*
* @param array $settings passed by reference
*/
private function getPluginConfig(&$settings)
{
$app = Factory::getApplication();
$core = (array) $settings['plugins'];
$items = array();
// Core plugins
foreach ($core as $plugin) {
$file = WF_EDITOR_PLUGINS . '/' . $plugin . '/config.php';
$file = Path::clean($file);
if (is_file($file)) {
// add plugin name to array
$items[$plugin] = $file;
}
}
// Installed plugins
if (array_key_exists('external_plugins', $settings)) {
$installed = (array) $settings['external_plugins'];
foreach ($installed as $plugin => $path) {
$file = Path::find(array(
// new path
JPATH_PLUGINS . '/jce/editor_' . $plugin,
// old path
JPATH_PLUGINS . '/jce/editor-' . $plugin,
// legacy path
JPATH_PLUGINS . '/jce/editor-' . $plugin . '/classes'
), 'config.php');
if ($file) {
// add plugin name to array
$items[$plugin] = $file;
}
}
}
$app->triggerEvent('onBeforeWfEditorPluginConfig', array($settings, &$items));
$delim = array('-', '_');
// loop through list and create/call method
foreach ($items as $plugin => $file) {
$name = str_replace($delim, ' ', $plugin);
// Create class name
$classname = 'WF' . ucwords($name) . 'PluginConfig';
// remove space
$classname = str_replace(' ', '', $classname);
require_once $file;
// Check class and method are callable, and call
if (class_exists($classname) && method_exists($classname, 'getConfig')) {
call_user_func_array(array($classname, 'getConfig'), array(&$settings));
}
}
}
/**
* Remove keys from an array.
*/
public function removeKeys(&$array, $keys)
{
if (!is_array($keys)) {
$keys = array($keys);
}
$array = array_diff($array, $keys);
}
/**
* Add keys to an array.
*
* @return The string list with added key or the key
*
* @param string The array
* @param string The keys to add
*/
public function addKeys(&$array, $keys)
{
if (!is_array($keys)) {
$keys = array($keys);
}
$array = array_unique(array_merge($array, $keys));
}
/**
* Get a list of editor font families.
*
* @return string font family list
*
* @param string $add Font family to add
* @param string $remove Font family to remove
*
* Deprecated in 2.3.4
*/
public function getEditorFonts()
{
return '';
}
/**
* Return the current site template name.
*/
private static function getSiteTemplates()
{
$db = Factory::getDBO();
$app = Factory::getApplication();
$id = 0;
// only process when front-end editing
if ($app->getClientId() == 0) {
$menus = $app->getMenu();
$menu = $menus->getActive();
if ($menu) {
$id = isset($menu->template_style_id) ? $menu->template_style_id : $menu->id;
}
}
$query = $db->getQuery(true);
$query->select('*, template AS name')->from('#__template_styles')->where(array('client_id = 0'));
$db->setQuery($query);
$templates = $db->loadObjectList();
$assigned = array();
foreach ($templates as $template) {
// default template
if ((string) $template->home == '1') {
$assigned[] = $template;
continue;
}
// assigned template
if ($id == $template->id) {
array_unshift($assigned, $template);
}
}
// return templates
return $assigned;
}
private static function hasEditorStylesheet($name)
{
// editor.css file is not suitable
if ($name == 'cassiopeia') {
return false;
}
// search for editor.css file using Path
$file = Path::find(array(
JPATH_SITE . '/templates/' . $name . '/css',
JPATH_SITE . '/media/templates/site/' . $name . '/css',
), 'editor.css');
if ($file && filesize($file) > 0) {
// make relative
$file = str_replace(JPATH_SITE, '', $file);
// remove leading slash
$file = trim($file, '/');
return $file;
}
return false;
}
private static function getTemplateStyleSheetsList($absolute = false)
{
// set default url as empty value
$url = '';
// set default template as empty value
$template = (object) array('name' => '');
// use editor default styles
$styles = '';
// stylesheets
$stylesheets = array();
// files
$files = array();
// get templates
$templates = self::getSiteTemplates();
foreach ($templates as $item) {
// Template CSS
$path = JPATH_SITE . '/templates/' . $item->name;
// get the first path that exists
if (is_dir($path)) {
// assign template
$template = $item;
break;
}
}
$wf = WFApplication::getInstance();
$global = intval($wf->getParam('editor.content_css', 1));
$profile = intval($wf->getParam('editor.profile_content_css', 2));
switch ($global) {
// Custom template css files
case 0:
// use getParam so result is cleaned
$global_custom = $wf->getParam('editor.content_css_custom', '');
if (is_string($global_custom)) {
$global_custom = explode(',', $global_custom);
}
foreach ($global_custom as $tmp) {
$tmp = trim($tmp);
if (empty($tmp)) {
continue;
}
// external url
if (strpos($tmp, '://') !== false) {
$files[] = $tmp;
continue;
}
// clean slashes
$tmp = preg_replace('#[/\\\\]+#', '/', $tmp);
// Replace $template variable with site template name
$tmp = str_replace('$template', $template->name, $tmp);
$file = JPATH_SITE . '/' . $tmp;
$list = array();
$file = Path::clean($file);
// check if path is a file
if (is_file($file)) {
$list[] = $file;
// find files using pattern
} else {
$list = glob($file);
}
if (!empty($list)) {
foreach ($list as $item) {
if (is_file($item) && preg_match('#\.(css|less)$#', $item)) {
$files[] = substr($item, strlen(JPATH_SITE) + 1);
}
}
}
}
break;
// Template css (template.css or template_css.css)
case 1:
$files = array();
// check editor.css file first
$file = self::hasEditorStylesheet($template->name);
if ($file) {
$files[] = $file;
} else {
Factory::getApplication()->triggerEvent('onWfGetTemplateStylesheets', array(&$files, $template));
}
break;
// Nothing, use editor default
case 2:
break;
}
switch ($profile) {
// add to global config value
case 0:
case 1:
$profile_custom = $wf->getParam('editor.profile_content_css_custom', '');
if (is_string($profile_custom)) {
$profile_custom = explode(',', $profile_custom);
}
$custom = array();
foreach ($profile_custom as $tmp) {
$tmp = trim($tmp);
if (empty($tmp)) {
continue;
}
// external url
if (strpos($tmp, '://') !== false) {
$custom[] = $tmp;
continue;
}
// clean slashes
$tmp = preg_replace('#[/\\\\]+#', '/', $tmp);
// Replace $template variable with site template name (defaults to 'system')
$tmp = str_replace('$template', $template->name, $tmp);
$list = array();
$file = JPATH_SITE . '/' . $tmp;
// check if path is a file
if (is_file($file)) {
$list[] = $file;
// find files using pattern
} else {
$list = glob($file);
}
if (!empty($list)) {
foreach ($list as $item) {
if (is_file($item) && preg_match('#\.(css|less)$#', $item)) {
$custom[] = substr($item, strlen(JPATH_SITE) + 1);
}
}
}
}
// add to existing list
if ($profile === 0) {
$files = array_merge($files, $custom);
// overwrite global config value
} else {
$files = (array) $custom;
}
break;
// inherit global config value
case 2:
break;
}
// remove duplicates
$files = array_unique(array_filter($files));
// get the root directory
$root = $absolute ? JPATH_SITE : Uri::root(true);
// check for existence of each file and make array of stylesheets
foreach ($files as $file) {
if (empty($file)) {
continue;
}
// full path
if (strpos($file, '://') !== false) {
$stylesheets[] = $file;
continue;
}
// remove leading slash
$file = ltrim($file, '/');
$fullpath = JPATH_SITE . '/' . $file;
if (is_file($fullpath)) {
// less
if (pathinfo($file, PATHINFO_EXTENSION) == 'less') {
$stylesheets[] = $fullpath;
continue;
}
$stylesheets[] = $root . '/' . $file;
}
}
// remove duplicates
$stylesheets = array_unique(array_filter($stylesheets));
return $stylesheets;
}
/**
* Get an array of stylesheets used by the editor.
* References the WFEditor class.
* If the list contains any LESS stylesheets, the list is returned as a URL to compile.
*
* @return string
*/
public static function getTemplateStyleSheets()
{
$stylesheets = self::getTemplateStyleSheetsList();
// check for less files in the array
$less = preg_grep('#\.less$#', $stylesheets);
// process less files etc.
if (!empty($less)) {
// create token
$token = Session::getFormToken();
$version = self::getVersion();
return Uri::base(true) . '/index.php?option=com_jce&task=editor.compileless&' . $token . '=1';
}
return $stylesheets;
}
/**
* Get the URL of the editor.
*
* @param bool $relative
*
* @return string
*/
private function getURL($relative = false)
{
if ($relative) {
return Uri::root(true) . '/media/com_jce/editor';
}
return Uri::root() . 'media/com_jce/editor';
}
/**
* Pack / compress editor files.
*/
public function pack()
{
$wf = WFApplication::getInstance();
$type = $wf->input->getWord('type', 'javascript');
// javascript
$packer = new WFPacker(array('type' => $type));
$themes = 'none';
$plugins = array();
$suffix = $wf->input->getWord('suffix', '');
// if a profile is set
if ($this->profile) {
$themes = 'advanced';
$plugins = $this->getPlugins();
}
$themes = explode(',', $themes);
// toolbar theme
$toolbar = explode('.', $wf->getParam('editor.toolbar_theme', 'default'));
// base skin value
$skin = $toolbar[0];
switch ($type) {
case 'language':
$files = array();
$data = $this->loadLanguages(array(), array(), '(^dlg$|_dlg$)', true);
$packer->setText($data);
break;
case 'javascript':
$files = array();
// add core file
$files[] = WF_EDITOR_MEDIA . '/tinymce/tinymce' . $suffix . '.js';
// Add themes in dev mode
foreach ($themes as $theme) {
$files[] = WF_EDITOR_MEDIA . '/tinymce/themes/' . $theme . '/theme' . $suffix . '.js';
}
// Add core plugins
foreach ($plugins['core'] as $plugin) {
if (in_array($plugin, self::$plugins)) {
continue;
}
$files[] = WF_EDITOR_MEDIA . '/tinymce/plugins/' . $plugin . '/plugin' . $suffix . '.js';
}
// add external and pro plugins
foreach ($plugins['external'] as $plugin => $path) {
// get base path from plugin path
$basepath = dirname($path);
$basepath = WFUtility::uriToAbsolutePath($basepath);
$file = Path::find(
array(
JPATH_SITE . '/' . $basepath
),
'plugin' . $suffix . '.js'
);
if ($file) {
$files[] = $file;
}
}
// add Editor file
$files[] = WF_EDITOR_MEDIA . '/js/editor.min.js';
break;
case 'css':
$slot = $wf->input->getCmd('slot', 'editor');
if ($slot == 'content') {
$files = array();
$files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $skin . '/content.css';
// get template stylesheets
$styles = self::getTemplateStyleSheetsList(true);
foreach ($styles as $style) {
$style = Path::clean($style);
if (is_file($style)) {
$files[] = $style;
}
}
// Add core plugins
foreach ($plugins['core'] as $plugin) {
$content = WF_EDITOR_MEDIA . '/tinymce/plugins/' . $plugin . '/css/content.css';
if (is_file($content)) {
$files[] = $content;
}
}
// add external and pro plugins
foreach ($plugins['external'] as $plugin => $path) {
// get base path from plugin path
$basepath = dirname($path);
$basepath = WFUtility::uriToAbsolutePath($basepath);
$content = Path::find(
array(
$basepath . '/css'
),
'content.css'
);
if ($content) {
$files[] = $content;
}
}
} elseif ($slot == 'preview') {
$files = array();
$files[] = WF_EDITOR_MEDIA . '/tinymce/plugins/preview/css/preview.css';
// get template stylesheets
$styles = self::getTemplateStyleSheetsList(true);
foreach ($styles as $style) {
$style = Path::clean($style);
if (is_file($style)) {
$files[] = $style;
}
}
} else {
$files = array();
$files[] = WF_EDITOR_MEDIA . '/css/editor.min.css';
$variant = '';
if (count($toolbar) > 1) {
$variant = $toolbar[1];
}
// load 'default'
$files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/default/ui.css';
if ($skin !== 'default') {
$files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $skin . '/ui.css';
}
if (isset($variant)) {
$files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $skin . '/ui_' . $variant . '.css';
}
}
break;
}
$cache_validation = (bool) $this->getParam('editor.compress_cache_validation', true);
$packer->setFiles($files);
$packer->pack(true, $cache_validation);
}
public function loadlanguages()
{
$parser = new WFLanguageParser(array('language' => $this->getLanguageTag(), 'plugins' => $this->getPlugins()));
$data = $parser->load();
$parser->output($data);
}
public function compileless()
{
$files = self::getTemplateStyleSheetsList(true);
if (!empty($files)) {
$packer = new WFPacker(array('files' => $files, 'type' => 'css'));
$packer->pack(false);
}
}
public function getToken($id)
{
return '<input type="hidden" name="' . Session::getFormToken() . '" value="1" />';
}
/**
* Proxy function for legacy compatablity with 3rd party extensions that access the API directly
*
* @param string $key
* @param string $fallback
* @param string $default
* @param string $type
* @param boolean $allowempty
* @return void
*/
public function getParam($key, $fallback = '', $default = '', $type = 'string', $allowempty = true)
{
$wf = WFApplication::getInstance();
return $wf->getParam($key, $fallback, $default, $type, $allowempty);
}
}
PK 8�!]�#o, ,
index.htmlnu &1i� <html><body bgcolor="#FFFFFF"></body></html>PK 8�!]#��� manager/manager.phpnu &1i� <?php
/**
* @copyright Copyright (c) 2009-2021 Ryan Demmer. All rights reserved
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses
*/
defined('JPATH_PLATFORM') or die;
class WFMediaManager extends WFMediaManagerBase
{
}
PK 8�!]g�b#<