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,18 @@
<?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
*/
class WFPreviewPluginConfig
{
public static function getConfig(&$settings)
{
$wf = WFApplication::getInstance();
$settings['extension_id'] = $wf->getContext();
}
}

View File

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

View File

@@ -0,0 +1 @@
html{height:100%}

View File

@@ -0,0 +1,2 @@
/* jce - 2.9.32 | 2022-11-01 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function(){function uid(){var i,guid=(new Date).getTime().toString(32);for(i=0;i<5;i++)guid+=Math.floor(65535*Math.random()).toString(32);return"wf_"+guid+(counter++).toString(32)}var DOM=tinymce.DOM,counter=0;tinymce.create("tinymce.plugins.PreviewPlugin",{init:function(ed,url){function isEditorActive(){return 0==DOM.hasClass(ed.getElement(),"wf-no-editor")}this.editor=ed;var self=this;ed.onInit.add(function(ed){if(0!=isEditorActive()){var activeTab=ed.settings.active_tab||"";"wf-editor-preview"===activeTab&&(ed.hide(),DOM.hide(ed.getElement()),self.toggle())}})},hide:function(){DOM.hide(this.editor.id+"_editor_preview")},toggle:function(){function update(text){var doc=iframe.contentWindow.document,css=[],scripts=/<script[^>]+>[\s\S]*<\/script>/.exec(text);text=text.replace(/<script[^>]+>[\s\S]*<\/script>/gi,"");var html="<!DOCTYPE html>";html+='<head xmlns="http://www.w3.org/1999/xhtml">',html+='<base href="'+s.document_base_url+'" />',html+='<meta http-equiv="X-UA-Compatible" content="IE=7" />',html+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',css=s.compress.css?[s.site_url+"index.php?option=com_jce&task=editor.pack&type=css&slot=preview&"+s.query]:tinymce.explode(s.content_css),tinymce.each(css,function(url){html+='<link href="'+url+'" rel="stylesheet" type="text/css" />'}),scripts&&tinymce.each(scripts,function(script){html+=""+script}),html+='</head><body style="margin:5px;">',html+=""+text,html+="</body></html>",doc.open(),doc.write(html),doc.close(),DOM.removeClass(container,"mce-loading")}var ed=this.editor,s=ed.settings,element=ed.getElement(),container=element.parentNode,header=DOM.getPrev(element,".wf-editor-header"),ifrHeight=parseInt(DOM.get(ed.id+"_ifr").style.height,10)||s.height,preview=DOM.get(ed.id+"_editor_preview"),iframe=DOM.get(ed.id+"_editor_preview_iframe"),o=tinymce.util.Storage.getHash("TinyMCE_"+ed.id+"_size");if(o&&o.height&&(ifrHeight=o.height),!preview){var preview=DOM.add(container,"div",{role:"textbox",id:ed.id+"_editor_preview",class:"wf-editor-preview"});iframe=DOM.add(preview,"iframe",{frameborder:0,src:'javascript:""',id:ed.id+"_editor_preview_iframe"})}var height=ed.settings.container_height||sessionStorage.getItem("wf-editor-container-height")||ifrHeight;if(DOM.hasClass(container,"mce-fullscreen")){var vp=DOM.getViewPort();height=vp.h-header.offsetHeight}DOM.setStyle(preview,"height",height),DOM.setStyle(preview,"max-width","100%");var width=ed.settings.container_width||sessionStorage.getItem("wf-editor-container-width");width&&!DOM.hasClass(container,"mce-fullscreen")&&DOM.setStyle(preview,"max-width",width),DOM.show(preview);var query="",args={};tinymce.extend(args,{data:ed.getContent(),id:uid()});for(var k in args)query+="&"+k+"="+encodeURIComponent(args[k]);tinymce.util.XHR.send({url:s.site_url+"index.php?option=com_jce&task=plugin.display&plugin=preview&"+tinymce.query,data:"json="+JSON.stringify({method:"showPreview"})+"&"+query,content_type:"application/x-www-form-urlencoded",success:function(x){var o={};try{o=JSON.parse(x)}catch(e){o.error=/[{}]/.test(o)?"The server returned an invalid JSON response":x}var r=o.result;x&&!o.error||(r=ed.getContent()),update(r)},error:function(e,x){update(ed.getContent())}})}}),tinymce.PluginManager.add("preview",tinymce.plugins.PreviewPlugin)}();

View File

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

View File

@@ -0,0 +1,142 @@
<?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 WFPreviewPlugin extends WFEditorPlugin
{
/**
* Constructor activating the default information of the class.
*/
public function __construct()
{
parent::__construct();
$request = WFRequest::getInstance();
// Setup plugin XHR callback functions
$request->setRequest(array($this, 'showPreview'));
$this->execute();
}
/**
* Display Preview content.
*/
public function showPreview()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
// reset document type
$document = JFactory::getDocument();
$document->setType('html');
// required by module loadposition
jimport('joomla.application.module.helper');
// load paramter class
jimport('joomla.html.parameter');
// register autoload for ContentHelperRoute
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
// get post data
$data = $app->input->post->get('data', '', 'RAW');
// cleanup data
$data = preg_replace(array('#<!DOCTYPE([^>]+)>#i', '#<(head|title|meta)([^>]*)>([\w\W]+)<\/1>#i', '#<\/?(html|body)([^>]*)>#i'), '', rawurldecode($data));
// create params registry object
$params = new JRegistry();
$params->loadString("");
// create context
$context = "";
$extension_id = $app->input->getInt('extension_id');
$extension = JTable::getInstance('extension');
if ($extension->load($extension_id)) {
$option = $extension->element;
// process attribs (com_content etc.)
$params->loadString($extension->params);
// create context
$context = $option . '.article';
}
$article = JTable::getInstance('content');
$article->id = 0;
$article->created_by = $user->get('id');
$article->parameters = new JRegistry();
$article->text = $data;
// load system plugins
JPluginHelper::importPlugin('system');
$app->triggerEvent('onWfContentPreview', array($context, &$article, &$params, 0));
// allow this to be skipped as some plugins can cause FATAL errors.
if ((bool) $this->getParam('process_content', 1)) {
$page = 0;
// load content plugins
JPluginHelper::importPlugin('content');
// set error reporting off to produce empty string on Fatal error
error_reporting(0);
$app->triggerEvent('onContentPrepare', array($context, &$article, &$params, $page));
}
$this->processURLS($article);
return $article->text;
}
/**
* Convert URLs.
*
* @param object $article Article object
*/
private function processURLS(&$article)
{
$base = JURI::root(true) . '/';
$buffer = $article->text;
$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href|poster)="(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer);
$regex = '#(onclick="window.open\(\')(?!/|' . $protocols . '|\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, '$1' . $base . '$2', $buffer);
// ONMOUSEOVER / ONMOUSEOUT
$regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, '$1="this.src=$2' . $base . '$3$4"', $buffer);
// Background image
$regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|' . $protocols . '|\#)([^\)\'\"]+)[\'\"]?\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer);
// OBJECT <field name="xx", value="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\s+)name\s*=\s*"(movie|src|url)"[^>]\s*value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
// OBJECT <field value="xx", name="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\s+[^>]*)value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"\s*name\s*=\s*"(movie|src|url)"#m';
$buffer = preg_replace($regex, '<field value="' . $base . '$2" name="$3"', $buffer);
// OBJECT data="xx" attribute -- fix it only in the object tag
$regex = '#(<object\s+[^>]*)data\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer);
$article->text = $buffer;
}
}

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" ?>
<extension version="3.4" type="plugin" group="jce" method="upgrade">
<name>WF_PREVIEW_TITLE</name>
<version>2.9.32</version>
<creationDate>01-11-2022</creationDate>
<author>Ryan Demmer</author>
<authorEmail>info@joomlacontenteditor.net</authorEmail>
<authorUrl>https://www.joomlacontenteditor.net/</authorUrl>
<copyright>Ryan Demmer</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<description>WF_PREVIEW_DESC</description>
<icon></icon>
<fields name="preview">
<fieldset name="config">
<field name="process_content" type="yesno" default="1" label="WF_PREVIEW_PARAM_PROCESS_CONTENT" description="WF_PREVIEW_PARAM_PROCESS_CONTENT_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help>
<topic key="preview.about" title="WF_PREVIEW_HELP_ABOUT" />
</help>
<languages></languages>
</extension>