first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,140 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFAggregatorExtension extends WFExtension
{
protected static $instance;
/**
* Returns a reference to a plugin object.
*
* This method must be invoked as:
* <pre> $advlink =AdvLink::getInstance();</pre>
*
* @return JCE The editor object
*
* @since 1.5
*/
public static function getInstance($config = array())
{
if (!isset(self::$instance)) {
self::$instance = new self($config);
}
return self::$instance;
}
public function getName()
{
return $this->get('name');
}
public function getTitle()
{
return $this->get('title');
}
public function display()
{
parent::display();
$document = WFDocument::getInstance();
$aggregators = $this->getAggregators();
foreach ($aggregators as $aggregator) {
$aggregator->display();
$params = $aggregator->getParams();
if (!empty($params)) {
$document->addScriptDeclaration('WFExtensions.Aggregator.setParams("' . $aggregator->getName() . '",' . json_encode($params) . ');');
}
}
}
public function getAggregators()
{
static $aggregators;
if (!isset($aggregators)) {
$aggregators = array();
}
// get the aggregator format for this instance
$format = $this->get('format');
if (empty($aggregators[$format])) {
jimport('joomla.filesystem.folder');
// get a plugin instance
$plugin = WFEditorPlugin::getInstance();
$aggregators[$format] = array();
$path = WF_EDITOR_EXTENSIONS . '/aggregator';
$files = JFolder::files($path, '\.php$', false, true);
foreach ($files as $file) {
require_once $file;
$name = basename($file, '.php');
$classname = 'WFAggregatorExtension_' . ucfirst($name);
// only load if enabled
if (class_exists($classname)) {
$aggregator = new $classname();
// check if enabled
if ($aggregator->isEnabled()) {
if ($aggregator->get('format') == $format) {
$aggregator->set('name', $name);
$aggregator->set('title', 'WF_AGGREGATOR_' . strtoupper($name) . '_TITLE');
$aggregators[$format][] = $aggregator;
}
}
}
}
}
return $aggregators[$format];
}
/**
* @param object $player
*
* @return string
*/
public function loadTemplate($name, $tpl = '')
{
$path = WF_EDITOR_EXTENSIONS . '/aggregator/' . $name;
$output = '';
$file = 'default.php';
if ($tpl) {
$file = 'default_' . $tpl . '.php';
}
if (file_exists($path . '/tmpl/' . $file)) {
ob_start();
include $path . '/tmpl/' . $file;
$output .= ob_get_contents();
ob_end_clean();
}
return $output;
}
}

View File

@@ -0,0 +1,399 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFFileSystem extends WFExtension
{
/**
* Constructor activating the default information of the class.
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->setProperties(array_merge($config, array(
'local' => true,
)));
// get path variable properties
$vars = $this->getPathVariables();
// assign to instance
$this->setProperties($vars);
}
/**
* Returns a reference to a plugin object.
*
* This method must be invoked as:
* <pre> $advlink =AdvLink::getInstance();</pre>
*
* @return JCE The editor object
*
* @since 1.5
*/
public static function getInstance($type = 'joomla', $config = array())
{
static $instances = array();
$signature = md5($type . serialize($config));
if (!isset($instances[$signature])) {
$fs = parent::loadExtensions('filesystem', $type);
// load the default...
if (empty($fs)) {
$fs = parent::loadExtensions('filesystem', 'joomla');
}
// get the first filesystem extension only
if (is_array($fs)) {
$fs = array_shift($fs);
}
$classname = 'WF' . ucfirst($fs->name) . 'FileSystem';
if (class_exists($classname)) {
$instances[$signature] = new $classname($config);
} else {
$instances[$signature] = new self($config);
}
}
return $instances[$signature];
}
public function updateOptions(&$options)
{
$options['dir'] = $this->getRootDir();
}
/**
* Get the base directory.
*
* @return string base dir
*/
public function getBaseDir()
{
return WFUtility::makePath(JPATH_SITE, $this->getRootDir());
}
/**
* Get the full base url.
*
* @return string base url
*/
public function getBaseURL()
{
return WFUtility::makePath(JURI::root(true), $this->getRootDir());
}
private function getPathVariables()
{
static $variables;
if (!isset($variables)) {
$user = JFactory::getUser();
$wf = WFApplication::getInstance();
$profile = $wf->getProfile();
jimport('joomla.user.helper');
$groups = JUserHelper::getUserGroups($user->id);
// get keys only
$groups = array_keys($groups);
// get the first group
$group_id = array_shift($groups);
if (is_int($group_id)) {
// usergroup table
$group = JTable::getInstance('Usergroup');
$group->load($group_id);
// usertype
$usertype = $group->title;
} else {
$usertype = $group_id;
}
// Replace any path variables
$path_pattern = array('/\$id/', '/\$username/', '/\$name/', '/\$user(group|type)/', '/\$(group|profile)/', '/\$day/', '/\$month/', '/\$year/');
$path_replacement = array($user->id, $user->username, $user->name, $usertype, $profile->name, date('d'), date('m'), date('Y'));
$websafe_textcase = $wf->getParam('editor.websafe_textcase', '');
// implode textcase array to create string
if (is_array($websafe_textcase)) {
$websafe_textcase = implode(',', $websafe_textcase);
}
$websafe_mode = $wf->getParam('editor.websafe_mode', 'utf-8');
$websafe_allow_spaces = $wf->getParam('editor.websafe_allow_spaces', '_');
$variables = compact('path_pattern', 'path_replacement', 'websafe_textcase', 'websafe_mode', 'websafe_allow_spaces');
}
return $variables;
}
public function processPath(&$path)
{
$path = preg_replace($this->get('path_pattern', array()), $this->get('path_replacement', array()), $path);
// split into path parts to preserve /
$parts = explode('/', $path);
// clean path parts
$parts = WFUtility::makeSafe($parts, $this->get('websafe_mode', 'utf-8'), $this->get('websafe_allow_spaces', '_'), $this->get('websafe_textcase', ''));
// join path parts
$path = implode('/', $parts);
}
/**
* Return the full user directory path. Create if required.
*
* @param string The base path
*
* @return Full path to folder
*/
public function getRootDir()
{
static $root;
if (!isset($root)) {
// Get base directory as shared parameter
$root = $this->get('dir', '');
// Remove whitespace
$root = trim($root);
if (!empty($root)) {
// Convert slashes / Strip double slashes
$root = preg_replace('/[\\\\]+/', '/', $root);
// Remove first leading slash
$root = ltrim($root, '/');
// Force default directory if base param is now empty or starts with a variable or a . eg $id
if (empty($root) || preg_match('/[\.\$]/', $root[0])) {
$root = 'images';
}
$this->processPath($root);
}
}
return $root;
}
protected static function sortItemsByKey($items, $type)
{
$sortable = array();
// set default direction
$direction = 'asc';
if ($type[0] === '-') {
$direction = 'desc';
$type = substr($type, 1);
}
foreach ($items as $key => $item) {
$sortable[$key] = isset($item[$type]) ? $item[$type] : $item['properties'][$type];
}
array_multisort($sortable, $direction === 'desc' ? SORT_DESC : SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $items);
return $items;
}
public function toAbsolute($path)
{
return $path;
}
public function toRelative($path)
{
return $path;
}
public function getTotalSize($path, $recurse = true)
{
return 0;
}
public function countFiles($path, $recurse = false)
{
return 0;
}
public function getFiles($path, $filter)
{
return array();
}
public function getFolders($path, $filter)
{
return array();
}
public function getSourceDir($path)
{
return $path;
}
public function isMatch($needle, $haystack)
{
return $needle == $haystack;
}
public function pathinfo($path)
{
return pathinfo($path);
}
public function delete($path)
{
return true;
}
public function createFolder($path, $new)
{
return true;
}
public function rename($src, $dest)
{
return true;
}
public function copy($src, $dest)
{
return true;
}
public function move($src, $dest)
{
return true;
}
public function getFolderDetails($path)
{
return array(
'properties' => array('modified' => ''),
);
}
public function getFileDetails($path)
{
$data = array(
'properties' => array(
'size' => '',
'modified' => '',
),
);
if (preg_match('#\.(jpg|jpeg|bmp|gif|tiff|png)#i', $path)) {
$image = array(
'properties' => array(
'width' => 0,
'height' => 0,
'preview' => '',
),
);
return array_merge_recursive($data, $image);
}
return $data;
}
public function getDimensions($path)
{
return array(
'width' => '',
'height' => '',
);
}
public function upload($method, $src, $dir, $name, $chunks = 0, $chunk = 0)
{
return true;
}
public function exists($path)
{
return true;
}
public function read($path)
{
return '';
}
public function write($path, $content)
{
return true;
}
public function isLocal()
{
return $this->get('local') === true;
}
public function is_file($path)
{
return true;
}
public function is_dir($path)
{
return true;
}
}
/**
* Filesystem Error class.
*/
final class WFFileSystemResult
{
/*
* @var Object type eg: file / folder
*/
public $type = 'files';
/*
* @boolean Result state
*/
public $state = false;
/*
* @int Error code
*/
public $code = null;
/*
* @var Error message
*/
public $message = null;
/*
* @var File / Folder path
*/
public $path = null;
/*
* @var File / Folder url
*/
public $url = null;
public function __construct()
{
}
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,241 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFLinkExtension extends WFExtension
{
/*
* @var varchar
*/
private $extensions = array();
protected static $instance;
protected static $links = array();
/**
* Constructor activating the default information of the class.
*/
public function __construct()
{
parent::__construct();
$extensions = self::loadExtensions('links');
// Load all link extensions
foreach ($extensions as $link) {
$this->extensions[] = $this->getLinkExtension($link->name);
}
$request = WFRequest::getInstance();
$request->setRequest(array($this, 'getLinks'));
}
public static function getInstance($config = array())
{
if (!isset(self::$instance)) {
self::$instance = new self($config);
}
return self::$instance;
}
public function display()
{
parent::display();
foreach ($this->extensions as $extension) {
$extension->display();
}
}
private function getLinkExtension($name)
{
if (array_key_exists($name, self::$links) === false || empty(self::$links[$name])) {
$classname = 'WFLinkBrowser_' . ucfirst($name);
// create class
if (class_exists($classname)) {
self::$links[$name] = new $classname();
}
}
return self::$links[$name];
}
public function getLists()
{
$list = array();
foreach ($this->extensions as $extension) {
if ($extension->isEnabled()) {
$list[] = $extension->getList();
}
}
return $list;
}
public function render()
{
$list = $this->getLists();
if (empty($list)) {
return '';
}
$view = $this->getView(array('name' => 'links', 'layout' => 'links'));
$view->list = implode("\n", $list);
$view->display();
}
private static function cleanInput($args, $method = 'string')
{
$filter = JFilterInput::getInstance();
foreach ($args as $k => $v) {
$args->$k = $filter->clean($v, $method);
$args->$k = (string) filter_var($args->$k, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_BACKTICK);
$args->$k = htmlspecialchars(strip_tags($args->$k));
}
return $args;
}
public function getLinks($args)
{
$args = self::cleanInput($args, 'STRING');
foreach ($this->extensions as $extension) {
if (in_array($args->option, $extension->getOption())) {
$items = $extension->getLinks($args);
}
}
$array = array();
$result = array();
if (isset($items)) {
foreach ($items as $item) {
$array[] = array(
'id' => isset($item['id']) ? self::xmlEncode($item['id']) : '',
'url' => isset($item['url']) ? self::xmlEncode($item['url']) : '',
'name' => self::xmlEncode($item['name']), 'class' => $item['class'],
);
}
$result = array('folders' => $array);
}
return $result;
}
/**
* Category function used by many extensions.
*
* @return Category list object
*
* @since 1.5
*/
public static function getCategory($section, $parent = 1)
{
$db = JFactory::getDBO();
$user = JFactory::getUser();
$wf = WFEditorPlugin::getInstance();
$query = $db->getQuery(true);
$where = array();
$version = new JVersion();
$language = $version->isCompatible('3.0') ? ', language' : '';
$where[] = 'parent_id = ' . (int) $parent;
$where[] = 'extension = ' . $db->Quote($section);
if (!$user->authorise('core.admin')) {
$where[] = 'access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')';
}
if (!$wf->checkAccess('static', 1)) {
$where[] = 'path != ' . $db->Quote('uncategorised');
}
$case = '';
if ($wf->getParam('category_alias', 1) == 1) {
//sqlsrv changes
$case = ', CASE WHEN ';
$case .= $query->charLength('alias', '!=', '0');
$case .= ' THEN ';
$a_id = $query->castAsChar('id');
$case .= $query->concatenate(array($a_id, 'alias'), ':');
$case .= ' ELSE ';
$case .= $a_id . ' END as slug';
}
$where[] = 'published = 1';
$query->select('id AS slug, id AS id, title, alias, access' . $language . $case)->from('#__categories')->where($where)->order('title');
$db->setQuery($query);
return $db->loadObjectList();
}
/**
* (Attempt to) Get an Itemid.
*
* @param string $component
* @param array $needles
*
* @return Category list object
*/
public function getItemId($component, $needles = array())
{
$match = null;
//require_once(JPATH_SITE . '/includes/application.php');
$app = JApplication::getInstance('site');
$tag = defined('JPATH_PLATFORM') ? 'component_id' : 'componentid';
$component = JComponentHelper::getComponent($component);
$menu = $app->getMenu('site');
$items = $menu->getItems($tag, $component->id);
if ($items) {
foreach ($needles as $needle => $id) {
foreach ($items as $item) {
if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
$match = $item->id;
break;
}
}
if (isset($match)) {
break;
}
}
}
return $match ? '&Itemid=' . $match : '';
}
/**
* XML encode a string.
*
* @param string String to encode
*
* @return string Encoded string
*/
private static function xmlEncode($string)
{
return str_replace(array('&', '<', '>', "'", '"'), array('&amp;', '&lt;', '&gt;', '&apos;', '&quot;'), $string);
}
}
abstract class WFLinkBrowser extends WFLinkExtension
{
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFMediaPlayerExtension extends WFExtension
{
protected static $instance;
public function __construct($config = array())
{
$default = array(
'name' => '',
'title' => '',
'params' => array(),
);
$config = array_merge($default, $config);
parent::__construct($config);
}
/**
* Returns a reference to a manager object.
*
* This method must be invoked as:
* <pre> $manager =MediaManager::getInstance();</pre>
*
* @return MediaManager The manager object
*
* @since 1.5
*/
public static function getInstance($name = 'jceplayer')
{
if (!isset(self::$instance)) {
$classname = '';
if ($name && $name != 'none') {
$player = parent::loadExtensions('mediaplayer', $name);
if ($player) {
$classname = 'WFMediaPlayerExtension_'.ucfirst($player->name);
}
}
if ($classname && class_exists($classname)) {
self::$instance = new $classname();
} else {
self::$instance = new self();
}
}
return self::$instance;
}
public function display()
{
parent::display();
$document = WFDocument::getInstance();
if ($this->isEnabled() && $this->get('name')) {
$document->addScript(array(
'mediaplayer/'.$this->get('name').'/js/'.$this->get('name'),
), 'extensions');
$document->addStyleSheet(array(
'mediaplayer/'.$this->get('name').'/css/'.$this->get('name'),
), 'extensions');
$document->addScriptDeclaration('WFExtensions.MediaPlayer.init('.json_encode($this->getProperties()).')');
}
}
public function isEnabled()
{
return false;
}
public function getName()
{
return $this->get('name');
}
public function getTitle()
{
return $this->get('title');
}
public function getParams()
{
return $this->params;
}
public function getParam($param, $default = '')
{
$params = $this->getParams();
return isset($params[$param]) ? $params[$param] : $default;
}
/**
* @param object $player
*
* @return string
*/
public function loadTemplate($tpl = '')
{
$output = '';
if ($this->isEnabled()) {
$path = WF_EDITOR_EXTENSIONS.'/mediaplayer/'.$this->get('name');
$file = 'default.php';
if ($tpl) {
$file = 'default_'.$tpl.'.php';
}
if (file_exists($path.'/tmpl/'.$file)) {
ob_start();
include $path.'/tmpl/'.$file;
$output .= ob_get_contents();
ob_end_clean();
}
}
return $output;
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFPopupsExtension extends WFExtension
{
protected static $instance;
private $_popups = array();
private $_templates = array();
/**
* Constructor activating the default information of the class.
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->setProperties($config);
}
/**
* Returns a reference to a plugin object.
*
* This method must be invoked as:
* <pre> $advlink =AdvLink::getInstance();</pre>
*
* @return JCE The editor object
*
* @since 1.5
*/
public static function getInstance($config = array())
{
if (!isset(self::$instance)) {
self::$instance = new self($config);
}
return self::$instance;
}
public function display()
{
parent::display();
$document = WFDocument::getInstance();
// get all popups extensions
$popups = parent::loadExtensions('popups');
$config = $this->getProperties();
if ($config) {
// Create global config
$document->addScriptDeclaration('WFExtensions.Popups.setConfig(' . json_encode($config) . ');');
}
// Create an instance of each popup and check if enabled
foreach ($popups as $item) {
$popup = $this->getPopupExtension($item->name);
if ($popup->isEnabled()) {
$this->addPopup($item);
$params = $popup->getParams();
if (!empty($params)) {
$document->addScriptDeclaration('WFExtensions.Popups.setParams("' . $item->name . '",' . json_encode($params) . ');');
}
}
}
$tabs = WFTabs::getInstance();
// Add popup tab and assign popups reference to document
if (count($this->getPopups())) {
$tabs->addTab('popups');
$panel = $tabs->getPanel('popups');
$panel->popups = $this;
}
}
private function getPopups()
{
return $this->_popups;
}
public function addPopup($popup)
{
$this->_popups[] = $popup;
}
private function getTemplates()
{
return $this->_templates;
}
public function addTemplate($template)
{
$this->_templates[] = $template;
}
private function getPopupExtension($name)
{
static $popups = array();
if (!isset($popups[$name])) {
$classname = 'WFPopupsExtension_' . ucfirst($name);
$popups[$name] = new $classname();
}
return $popups[$name];
}
public function getPopupList()
{
$options = array();
$options[] = JHTML::_('select.option', '', '-- ' . JText::_('WF_POPUP_TYPE_SELECT') . ' --');
foreach ($this->getPopups() as $popup) {
$options[] = JHTML::_('select.option', $popup->name, JText::_('WF_POPUPS_' . strtoupper($popup->name) . '_TITLE'));
}
return JHTML::_('select.genericlist', $options, 'popup_list', '', 'value', 'text', $this->get('default'));
}
public function getPopupTemplates()
{
$output = '';
foreach ($this->getTemplates() as $template) {
$wf = WFEditorPlugin::getInstance();
$view = $wf->getView();
$output .= $view->loadTemplate($template);
}
foreach ($this->getPopups() as $popup) {
$view = new WFView(array(
'name' => $popup->name,
'base_path' => $popup->path,
'template_path' => $popup->path . '/tmpl',
));
$instance = $this->getPopupExtension($popup->name);
$view->popup = $instance;
if (file_exists($popup->path . '/tmpl/default.php')) {
ob_start();
$output .= '<div id="popup_extension_' . $popup->name . '" style="display:none;">';
$view->display();
$output .= ob_get_contents();
$output .= '</div>';
ob_end_clean();
}
}
return $output;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2009-2022 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 WFSearchExtension extends WFExtension
{
private static $instances = array();
/**
* Returns a reference to a plugin object.
*
* This method must be invoked as:
* <pre> $advlink =AdvLink::getInstance();</pre>
*
* @return JCE The editor object
*
* @since 1.5
*/
public static function getInstance($type, $config = array())
{
if (!isset(self::$instances)) {
self::$instances = array();
}
if (empty(self::$instances[$type])) {
$file = WF_EDITOR . '/extensions/search/' . $type . '.php';
if (is_file($file)) {
require_once WF_EDITOR . '/extensions/search/' . $type . '.php';
}
$classname = 'WF' . ucfirst($type) . 'SearchExtension';
if (class_exists($classname)) {
self::$instances[$type] = new $classname($config);
} else {
self::$instances[$type] = new self();
}
}
return self::$instances[$type];
}
}