first commit
This commit is contained in:
73
components/com_jce/editor/extensions/aggregator/audio.php
Normal file
73
components/com_jce/editor/extensions/aggregator/audio.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2019 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_Audio extends WFAggregatorExtension
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'format' => 'video',
|
||||
));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript('audio', 'extensions/aggregator/audio/js');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'controls' => (int) $plugin->getParam('aggregator.audio.controls', 1),
|
||||
'loop' => (int) $plugin->getParam('aggregator.audio.loop', 0),
|
||||
'autoplay' => (int) $plugin->getParam('aggregator.audio.autoplay', 0),
|
||||
'muted' => (int) $plugin->getParam('aggregator.audio.mute', 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function getEmbedData($data, $url)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$default = array(
|
||||
'controls' => 1,
|
||||
'loop' => 0,
|
||||
'autoplay' => 0,
|
||||
'muted' => 0
|
||||
);
|
||||
|
||||
foreach($params as $name => $value) {
|
||||
if ($default[$name] === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value !== '') {
|
||||
$data[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['src'] = $url;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
40
components/com_jce/editor/extensions/aggregator/audio.xml
Normal file
40
components/com_jce/editor/extensions/aggregator/audio.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_AGGREGATOR_AUDIO_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_AGGREGATOR_AUDIO_DESC</description>
|
||||
<files>
|
||||
<filename>audio.php</filename>
|
||||
<folder>audio</folder>
|
||||
</files>
|
||||
<fields name="audio">
|
||||
<fieldset name="aggregator.audio">
|
||||
<field name="controls" type="yesno" default="1" label="WF_AGGREGATOR_AUDIO_CONTROLS" description="WF_AGGREGATOR_AUDIO_CONTROLS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="loop" type="yesno" default="0" label="WF_AGGREGATOR_AUDIO_LOOP" description="WF_AGGREGATOR_AUDIO_LOOP_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="autoplay" type="yesno" default="0" label="WF_AGGREGATOR_AUDIO_AUTOPLAY" description="WF_AGGREGATOR_AUDIO_AUTOPLAY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="mute" type="yesno" default="0" label="WF_AGGREGATOR_AUDIO_MUTE" description="WF_AGGREGATOR_AUDIO_MUTE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -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 */
|
||||
WFAggregator.add("audio",{params:{},props:{autoplay:0,loop:0,controls:1,mute:0},setup:function(){$.each(this.params,function(k,v){$("#audio_"+k).val(v).filter(":checkbox, :radio").prop("checked",!!v)})},getTitle:function(){return this.title||this.name},getType:function(){return"audio"},isSupported:function(v){return!1}});
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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_Dailymotion extends WFAggregatorExtension
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'format' => 'video',
|
||||
));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript('dailymotion', 'extensions/aggregator/dailymotion/js');
|
||||
$document->addStyleSheet('dailymotion', 'extensions/aggregator/dailymotion/css');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return $plugin->checkAccess('aggregator.dailymotion.enable', 1);
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'width' => $plugin->getParam('aggregator.dailymotion.width', 480),
|
||||
'height' => $plugin->getParam('aggregator.dailymotion.height', 270),
|
||||
);
|
||||
}
|
||||
|
||||
public function getEmbedData($data, $url)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$default = array(
|
||||
'width' => 480,
|
||||
'height' => 270
|
||||
);
|
||||
|
||||
foreach($params as $name => $value) {
|
||||
if (isset($default[$name]) && $value === $default[$name]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($name === 'width' || $name == 'height') {
|
||||
$data[$name] = $value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_AGGREGATOR_DAILYMOTION_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_AGGREGATOR_DAILYMOTION_DESC</description>
|
||||
<files>
|
||||
<filename>dailymotion</filename>
|
||||
<folder>dailymotion</folder>
|
||||
</files>
|
||||
<fields name="dailymotion">
|
||||
<fieldset name="aggregator.dailymotion">
|
||||
<field name="enable" type="yesno" default="1" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="width" type="number" default="400" class="input-small" label="WF_LABEL_WIDTH" />
|
||||
<field name="height" type="number" default="225" class="input-small" label="WF_LABEL_HEIGHT" />
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1 @@
|
||||
#dailymotion_player_size{width:150px!important}#dailymotion_player_size_custom{width:65px!important}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -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 */
|
||||
WFAggregator.add("dailymotion",{params:{width:480,height:270,autoPlay:!1},props:{autoPlay:0,start:0},setup:function(){$("#dailymotion_autoPlay").prop("checked",this.params.autoPlay),$("#dailymotion_player_size").on("change",function(){var v=parseInt(this.value,10);$("#dailymotion_player_size_custom").toggleClass("uk-hidden",!!this.value),v&&($("#width").val(v),$("#height").val(Math.round(9*v/16)))}),$("#dailymotion_player_size_custom").on("change",function(){var v=parseInt(this.value,10);v&&($("#width").val(v),$("#height").val(Math.round(16*v/9)))})},getTitle:function(){return this.title||this.name},getType:function(){return"iframe"},isSupported:function(v){return"object"==typeof v&&(v=v.src||v.data||""),!!/dai\.?ly(motion)?(\.com)?/.test(v)&&"dailymotion"},getValues:function(src){var self=this,data={},args={},id="";src.indexOf("=")!==-1&&$.extend(args,Wf.String.query(src)),$("input[id], select[id]","#dailymotion_options").each(function(){var k=$(this).attr("id"),v=$(this).val();k=k.substr(k.indexOf("_")+1),$(this).is(":checkbox")&&(v=$(this).is(":checked")?1:0),k.indexOf("player_size")===-1&&self.props[k]!==v&&""!==v&&(args[k]=v)});var m=src.match(/dai\.?ly(motion\.com)?\/(embed)?\/?(swf|video)?\/?([a-z0-9]+)_?/);m&&(id=m.pop()),src="https://www.dailymotion.com/embed/video/"+id;var query=$.param(args);return query&&(src=src+(/\?/.test(src)?"&":"?")+query),data.src=src,$.extend(data,{frameborder:0,allowfullscreen:"allowfullscreen"}),data},setValues:function(data){var self=this,src=data.src||data.data||"",id="";if(!src)return data;var query=Wf.String.query(src);$.each(query,function(key,val){return self.props[key]==val||void(data["dailymotion_"+key]=val)}),src=src.replace(/&/g,"&");var m=src.match(/dai\.?ly(motion\.com)?\/(embed)?\/?(swf|video)?\/?([a-z0-9]+)_?/);return m&&(id=m.pop()),data.src="https://www.dailymotion.com/embed/video/"+id,data},getAttributes:function(src){var args={},data=this.setValues({src:src})||{};return $.each(data,function(k,v){"src"!=k&&(args["dailymotion_"+k]=v)}),$.extend(args,{src:data.src||src,width:this.params.width,height:this.params.height}),args},setAttributes:function(){},onSelectFile:function(){},onInsert:function(){}});
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
?>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="dailymotion_autoPlay" title="<?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_AUTOPLAY_DESC') ?>"
|
||||
class="tooltip uk-form-label uk-width-1-5"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_AUTOPLAY') ?></label>
|
||||
<div class="uk-width-4-5">
|
||||
<div class="uk-form-controls uk-width-1-5">
|
||||
<input type="checkbox" id="dailymotion_autoPlay" />
|
||||
</div>
|
||||
|
||||
<label for="dailymotion_start" title="<?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_START_DESC') ?>"
|
||||
class="tooltip uk-form-label uk-width-1-5"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_START') ?></label>
|
||||
<div class="uk-form-controls uk-width-1-5">
|
||||
<input id="dailymotion_start" type="number" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label class="uk-form-label uk-width-1-5"
|
||||
title="<?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE'); ?>"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE'); ?></label>
|
||||
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<select id="dailymotion_player_size">
|
||||
<option value="320"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE_SMALL'); ?></option>
|
||||
<option value="480"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE_MEDIUM'); ?></option>
|
||||
<option value="560"><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE_LARGE'); ?></option>
|
||||
<option value=""><?php echo JText::_('WF_AGGREGATOR_DAILYMOTION_SIZE_CUSTOM'); ?></option>
|
||||
</select>
|
||||
|
||||
<input type="number" id="dailymotion_player_size_custom" class="uk-hidden uk-margin-small-left" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
76
components/com_jce/editor/extensions/aggregator/video.php
Normal file
76
components/com_jce/editor/extensions/aggregator/video.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2019 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_Video extends WFAggregatorExtension
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'format' => 'video',
|
||||
));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript('video', 'extensions/aggregator/video/js');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'width' => $plugin->getParam('aggregator.video.width', ''),
|
||||
'height' => $plugin->getParam('aggregator.video.height', ''),
|
||||
|
||||
'controls' => (int) $plugin->getParam('aggregator.video.controls', 1),
|
||||
'loop' => (int) $plugin->getParam('aggregator.video.loop', 0),
|
||||
'autoplay' => (int) $plugin->getParam('aggregator.video.autoplay', 0),
|
||||
'muted' => (int) $plugin->getParam('aggregator.video.mute', 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function getEmbedData($data, $url)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$default = array(
|
||||
'controls' => 1,
|
||||
'loop' => 0,
|
||||
'autoplay' => 0,
|
||||
'muted' => 0
|
||||
);
|
||||
|
||||
foreach($params as $name => $value) {
|
||||
if ($default[$name] === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value !== '') {
|
||||
$data[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['src'] = $url;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
39
components/com_jce/editor/extensions/aggregator/video.xml
Normal file
39
components/com_jce/editor/extensions/aggregator/video.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_AGGREGATOR_VIDEO_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_AGGREGATOR_VIDEO_DESC</description>
|
||||
<files>
|
||||
<filename>video.php</filename>
|
||||
</files>
|
||||
<fields name="video">
|
||||
<fieldset name="aggregator.video">
|
||||
<field name="controls" type="yesno" default="1" label="WF_AGGREGATOR_VIDEO_CONTROLS" description="WF_AGGREGATOR_VIDEO_CONTROLS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="loop" type="yesno" default="0" label="WF_AGGREGATOR_VIDEO_LOOP" description="WF_AGGREGATOR_VIDEO_LOOP_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="autoplay" type="yesno" default="0" label="WF_AGGREGATOR_VIDEO_AUTOPLAY" description="WF_AGGREGATOR_VIDEO_AUTOPLAY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="mute" type="yesno" default="0" label="WF_AGGREGATOR_VIDEO_MUTE" description="WF_AGGREGATOR_VIDEO_MUTE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -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 */
|
||||
WFAggregator.add("video",{params:{},props:{autoplay:0,loop:0,controls:1,mute:0},setup:function(){$.each(this.params,function(k,v){$("#video_"+k).val(v).filter(":checkbox, :radio").prop("checked",!!v)})},getTitle:function(){return this.title||this.name},getType:function(){return"video"},isSupported:function(v){return!1}});
|
||||
92
components/com_jce/editor/extensions/aggregator/vimeo.php
Normal file
92
components/com_jce/editor/extensions/aggregator/vimeo.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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_Vimeo extends WFAggregatorExtension
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'format' => 'video',
|
||||
));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript('vimeo', 'extensions/aggregator/vimeo/js');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return $plugin->checkAccess('aggregator.vimeo.enable', 1);
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'width' => $plugin->getParam('aggregator.vimeo.width', 400),
|
||||
'height' => $plugin->getParam('aggregator.vimeo.height', 225),
|
||||
|
||||
'color' => (string) $plugin->getParam('aggregator.vimeo.color', ''),
|
||||
'loop' => (int) $plugin->getParam('aggregator.vimeo.loop', 0),
|
||||
'autoplay' => (int) $plugin->getParam('aggregator.vimeo.autoplay', 0),
|
||||
'intro' => (int) $plugin->getParam('aggregator.vimeo.intro', 0),
|
||||
'title' => (int) $plugin->getParam('aggregator.vimeo.title', 0),
|
||||
'byline' => (int) $plugin->getParam('aggregator.vimeo.byline', 0),
|
||||
'portrait' => (int) $plugin->getParam('aggregator.vimeo.portrait', 0),
|
||||
'fullscreen' => (int) $plugin->getParam('aggregator.vimeo.fullscreen', 1),
|
||||
'dnt' => (int) $plugin->getParam('aggregator.vimeo.dnt', 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function getEmbedData($data, $url)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$default = array(
|
||||
'width' => 560,
|
||||
'height' => 315,
|
||||
'controls' => 1,
|
||||
'loop' => 0,
|
||||
'autoplay' => 0,
|
||||
'rel' => 1,
|
||||
'modestbranding' => 0,
|
||||
'privacy' => 0
|
||||
);
|
||||
|
||||
foreach($params as $name => $value) {
|
||||
if (isset($default[$name]) && $value === $default[$name]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($name === 'width' || $name == 'height') {
|
||||
$data[$name] = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
$query[$name] = $value;
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
$data['query'] = http_build_query($options);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
69
components/com_jce/editor/extensions/aggregator/vimeo.xml
Normal file
69
components/com_jce/editor/extensions/aggregator/vimeo.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_AGGREGATOR_VIMEO_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_AGGREGATOR_VIMEO_DESC</description>
|
||||
<files>
|
||||
<filename>vimeo.php</filename>
|
||||
<folder>vimeo</folder>
|
||||
</files>
|
||||
<fields name="vimeo">
|
||||
<fieldset name="aggregator.vimeo">
|
||||
<field name="enable" type="yesno" default="1" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="width" type="number" default="400" class="input-small" label="WF_LABEL_WIDTH" description="WF_AGGREGATOR_VIMEO_WIDTH_DESC" />
|
||||
<field name="height" type="number" default="225" class="input-small" label="WF_LABEL_HEIGHT" description="WF_AGGREGATOR_VIMEO_HEIGHT_DESC" />
|
||||
|
||||
<field name="color" type="color" size="10" default="" label="WF_AGGREGATOR_VIMEO_COLOR" description="WF_AGGREGATOR_VIMEO_COLOR_DESC" />
|
||||
|
||||
<field name="intro" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_INTRO" description="WF_AGGREGATOR_VIMEO_INTRO_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="portrait" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_PORTRAIT" description="WF_AGGREGATOR_VIMEO_PORTRAIT_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="title" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_INTROTITLE" description="WF_AGGREGATOR_VIMEO_INTROTITLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="byline" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_BYLINE" description="WF_AGGREGATOR_VIMEO_BYLINE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="autoplay" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_AUTOPLAY" description="WF_AGGREGATOR_VIMEO_AUTOPLAY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="loop" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_LOOP" description="WF_AGGREGATOR_VIMEO_LOOP_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="fullscreen" type="yesno" default="1" label="WF_AGGREGATOR_VIMEO_FULLSCREEN" description="WF_AGGREGATOR_VIMEO_FULLSCREEN_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="dnt" type="yesno" default="0" label="WF_AGGREGATOR_VIMEO_DNT" description="WF_AGGREGATOR_VIMEO_DNT_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -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 */
|
||||
WFAggregator.add("vimeo",{params:{width:480,height:480,embed:!0},props:{color:"",autoplay:0,loop:0,fullscreen:1,dnt:0},setup:function(){$("#vimeo_embed").toggle(this.params.embed),$.each(this.params,function(k,v){$("#vimeo_"+k).val(v).filter(":checkbox, :radio").prop("checked",!!v)})},getTitle:function(){return this.title||this.name},getType:function(){return"iframe"},isSupported:function(v){return"object"==typeof v&&(v=v.src||v.data||""),!!/vimeo(.+)?\/(.+)/.test(v)&&(!/\/external\//.test(v)&&"vimeo")},getValues:function(src){var self=this,data={},args={},id="";if(src.indexOf("=")!==-1&&$.extend(args,Wf.String.query(src)),$("input, select","#vimeo_options").not("#vimeo_embed").each(function(){var k=$(this).attr("id"),v=$(this).val();k=k.substr(k.indexOf("_")+1),$(this).is(":checkbox")&&(v=$(this).is(":checked")?1:0),self.props[k]!=v&&""!==v&&("color"===k&&"#"===v.charAt(0)&&(v=v.substr(1)),args[k]=v)}),args.clip_id)id=args.clip_id;else{var id="",hash="",matches=/vimeo\.com\/([0-9]+)\/?([a-z0-9]+)?/.exec(src);if(matches&&tinymce.is(matches,"array")){var id=matches[1];matches.length>2&&(hash=matches[2])}id+=hash?"?h="+hash:""}src="https://player.vimeo.com/video/"+id;var query=$.param(args);return query&&(src=src+(/\?/.test(src)?"&":"?")+query),data.src=src,$.extend(data,{frameborder:0}),0!==args.fullscreen&&$.extend(data,{allowfullscreen:!0}),data},setValues:function(data){var self=this,src=data.src||data.data||"",id="";if(!src)return data;var query=Wf.String.query(src);if(src=src.replace(/&/g,"&"),/moogaloop.swf/.test(src))data.vimeo_embed=!0,id=query.clip_id,delete query.clip_id,delete data.clip_id,$.each(["portrait","title","byline"],function(i,s){delete data["show_"+s]});else{var id="",hash="",matches=/vimeo\.com\/(?:\w+\/){0,3}((?:[0-9]+\b)(?:\/[a-z0-9]+)?)/.exec(src);if(matches&&"array"==$.type(matches)){var params=matches[1].split("/"),id=params[0];2==params.length&&(hash=params[1]),id+=hash?"/"+hash:""}}return $.each(query,function(key,val){return self.props[key]===val||("color"==key&&"#"!==val.charAt(0)&&(val="#"+val),"autoplay"==key&&(val=parseInt(val,10)),void(data["vimeo_"+key]=val))}),src="https://vimeo.com/"+id,$.each(data,function(key,val){/^iframe_(allow|frameborder|allowfullscreen)/.test(key)&&delete data[key]}),data.src=src,data},getAttributes:function(src){var args={},data=this.setValues({src:src})||{};return $.each(data,function(k,v){"src"!=k&&(args["vimeo_"+k]=v)}),$.extend(args,{src:data.src||src,width:this.params.width,height:this.params.height}),args},setAttributes:function(){},onSelectFile:function(){},onInsert:function(){}});
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
?>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="vimeo_color" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_COLOR_DESC') ?>"
|
||||
class="tooltip uk-form-label uk-width-1-5"><?php echo JText::_('WF_AGGREGATOR_VIMEO_COLOR') ?></label>
|
||||
|
||||
<div class="uk-form-controls uk-width-1-5">
|
||||
<input type="text" id="vimeo_color" class="color"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
|
||||
<label for="vimeo_intro" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_INTRO_DESC') ?>"
|
||||
class="tooltip uk-form-label uk-width-1-5"><?php echo JText::_('WF_AGGREGATOR_VIMEO_INTRO') ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<input type="checkbox" id="vimeo_portrait" />
|
||||
<label for="vimeo_portrait" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_PORTRAIT_DESC') ?>"
|
||||
class="tooltip uk-margin-right"><?php echo JText::_('WF_AGGREGATOR_VIMEO_PORTRAIT') ?></label>
|
||||
|
||||
<input type="checkbox" id="vimeo_title" />
|
||||
<label for="vimeo_title" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_INTROTITLE_DESC') ?>"
|
||||
class="tooltip uk-margin-right"><?php echo JText::_('WF_AGGREGATOR_VIMEO_INTROTITLE') ?></label>
|
||||
|
||||
<input type="checkbox" id="vimeo_byline" />
|
||||
<label for="vimeo_byline" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_BYLINE_DESC') ?>"
|
||||
class="tooltip"><?php echo JText::_('WF_AGGREGATOR_VIMEO_BYLINE') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="vimeo_special"
|
||||
class="uk-form-label uk-width-1-5"><?php echo JText::_('WF_AGGREGATOR_VIMEO_SPECIAL') ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
|
||||
<input type="checkbox" id="vimeo_autoplay"/>
|
||||
<label for="vimeo_autoplay" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_AUTOPLAY_DESC') ?>"
|
||||
class="tooltip uk-margin-right"><?php echo JText::_('WF_AGGREGATOR_VIMEO_AUTOPLAY') ?></label>
|
||||
|
||||
<input type="checkbox" id="vimeo_loop"/>
|
||||
<label for="vimeo_loop" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_LOOP_DESC') ?>"
|
||||
class="tooltip uk-margin-right"><?php echo JText::_('WF_AGGREGATOR_VIMEO_LOOP') ?></label>
|
||||
|
||||
<input type="checkbox" id="vimeo_fullscreen" checked="checked"/>
|
||||
<label for="vimeo_fullscreen" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_FULLSCREEN_DESC') ?>"
|
||||
class="tooltip"><?php echo JText::_('WF_AGGREGATOR_VIMEO_FULLSCREEN') ?></label>
|
||||
|
||||
<input type="checkbox" id="vimeo_dnt" />
|
||||
<label for="vimeo_dnt" title="<?php echo JText::_('WF_AGGREGATOR_VIMEO_DNT_DESC') ?>"
|
||||
class="tooltip"><?php echo JText::_('WF_AGGREGATOR_VIMEO_DNT') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
91
components/com_jce/editor/extensions/aggregator/youtube.php
Normal file
91
components/com_jce/editor/extensions/aggregator/youtube.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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_Youtube extends WFAggregatorExtension
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(
|
||||
'format' => 'video',
|
||||
));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript('youtube', 'extensions/aggregator/youtube/js');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return $plugin->checkAccess('aggregator.youtube.enable', 1);
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$plugin = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'width' => $plugin->getParam('aggregator.youtube.width', 560),
|
||||
'height' => $plugin->getParam('aggregator.youtube.height', 315),
|
||||
|
||||
'controls' => (int) $plugin->getParam('aggregator.youtube.controls', 1),
|
||||
'loop' => (int) $plugin->getParam('aggregator.youtube.loop', 0),
|
||||
'autoplay' => (int) $plugin->getParam('aggregator.youtube.autoplay', 0),
|
||||
'rel' => (int) $plugin->getParam('aggregator.youtube.related', 1),
|
||||
'modestbranding' => (int) $plugin->getParam('aggregator.youtube.modestbranding', 0),
|
||||
'privacy' => (int) $plugin->getParam('aggregator.youtube.privacy', 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function getEmbedData($data)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$default = array(
|
||||
'width' => 560,
|
||||
'height' => 315,
|
||||
'controls' => 1,
|
||||
'loop' => 0,
|
||||
'autoplay' => 0,
|
||||
'rel' => 1,
|
||||
'modestbranding' => 0,
|
||||
'privacy' => 0
|
||||
);
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach($params as $name => $value) {
|
||||
if (isset($default[$name]) && $value === $default[$name]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($name === 'width' || $name == 'height') {
|
||||
$data[$name] = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[$name] = $value;
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
$data['query'] = http_build_query($options);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
57
components/com_jce/editor/extensions/aggregator/youtube.xml
Normal file
57
components/com_jce/editor/extensions/aggregator/youtube.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_AGGREGATOR_YOUTUBE_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_AGGREGATOR_YOUTUBE_DESC</description>
|
||||
<files>
|
||||
<filename>youtube.php</filename>
|
||||
<folder>youtube</folder>
|
||||
</files>
|
||||
<fields name="youtube">
|
||||
<fieldset name="aggregator.youtube">
|
||||
<field name="enable" type="yesno" default="1" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="width" type="number" default="560" class="input-small" label="WF_LABEL_WIDTH" description="WF_AGGREGATOR_YOUTUBE_WIDTH_DESC" />
|
||||
<field name="height" type="number" default="315" class="input-small" label="WF_LABEL_HEIGHT" description="WF_AGGREGATOR_YOUTUBE_HEIGHT_DESC" />
|
||||
|
||||
<field name="controls" type="yesno" default="1" label="WF_AGGREGATOR_YOUTUBE_CONTROLS" description="WF_AGGREGATOR_YOUTUBE_CONTROLS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="related" type="yesno" default="1" label="WF_AGGREGATOR_YOUTUBE_RELATED" description="WF_AGGREGATOR_YOUTUBE_RELATED_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="loop" type="yesno" default="1" label="WF_AGGREGATOR_YOUTUBE_LOOP" description="WF_AGGREGATOR_YOUTUBE_LOOP_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="autoplay" type="yesno" default="0" label="WF_AGGREGATOR_YOUTUBE_AUTOPLAY" description="WF_AGGREGATOR_YOUTUBE_AUTOPLAY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="privacy" type="yesno" default="0" label="WF_AGGREGATOR_YOUTUBE_PRIVACY" description="WF_AGGREGATOR_YOUTUBE_PRIVACY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="modestbranding" type="yesno" default="0" label="WF_AGGREGATOR_YOUTUBE_MODESTBRANDING" description="WF_AGGREGATOR_YOUTUBE_MODESTBRANDING_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -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 */
|
||||
WFAggregator.add("youtube",{params:{width:560,height:315,embed:!0},props:{rel:1,autoplay:0,controls:1,modestbranding:0,enablejsapi:0,loop:0,playlist:"",start:"",end:"",privacy:0},setup:function(){$.each(this.params,function(k,v){$("#youtube_"+k).val(v).filter(":checkbox, :radio").prop("checked",!!v)})},getTitle:function(){return this.title||this.name},getType:function(){return $("#youtube_embed:visible").is(":checked")?"flash":"iframe"},isSupported:function(v){return"object"==typeof v&&(v=v.src||v.data||""),!!/youtu(\.)?be(.+)?\/(.+)/.test(v)&&"youtube"},getValues:function(src){var id,self=this,data={},args={},type=this.getType(),query={},u=this.parseURL(src);u.query&&(query=Wf.String.query(u.query)),$.extend(args,query),src=src.replace(/^(http:)?\/\//,"https://"),$(":input","#youtube_options").not("#youtube_embed, #youtube_https, #youtube_privacy").each(function(){var k=$(this).attr("id"),v=$(this).val();return!k||(k=k.substr(k.indexOf("_")+1),$(this).is(":checkbox")&&(v=$(this).is(":checked")?1:0),void(self.props[k]!=v&&""!==v&&(args[k]=v)))}),src=src.replace(/youtu(\.)?be([^\/]+)?\/(.+)/,function(a,b,c,d){return d=d.replace(/(watch\?v=|v\/|embed\/)/,""),b&&!c&&(c=".com"),id=d.replace(/([^\?&#]+)/,function($0,$1){return $1}),"youtube"+c+"/"+("iframe"==type?"embed":"v")+"/"+d}),id&&args.loop&&!args.playlist&&(args.playlist=id),src=$("#youtube_privacy").is(":checked")?src.replace(/youtube\./,"youtube-nocookie."):src.replace(/youtube-nocookie\./,"youtube."),"iframe"==type?$.extend(data,{allowfullscreen:!0,frameborder:0}):$.extend(!0,data,{param:{allowfullscreen:!0,wmode:"opaque"}}),$(".uk-repeatable","#youtube_params").each(function(){var key=$('input[name^="youtube_params_name"]',this).val(),value=$('input[name^="youtube_params_value"]',this).val();""!==key&&""!==value&&(args[key]=value)});var q=$.param(args);return q&&(src=src+(/\?/.test(src)?"&":"?")+q),data.src=src,data},parseURL:function(url){var o={};return url=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(url),$.each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(i,v){var s=url[i];s&&(o[v]=s)}),o},setValues:function(data){var self=this,id="",src=data.src||data.data||"",query={};if(!src)return data;var u=this.parseURL(src);if(u.query&&(query=Wf.String.query(u.query)),src="https://"+u.host+u.path,src.indexOf("youtube-nocookie")!==-1&&(data.youtube_privacy=1),query.v)id=query.v,delete query.v;else{var s=/\/?(embed|v)?\/([\w-]+)\b/.exec(u.path);s&&"array"===$.type(s)&&(id=s.pop())}return $.each(query,function(key,val){try{val=decodeURIComponent(val)}catch(e){}return"autoplay"==key&&(val=parseInt(val,10)),"playlist"==key&&val==id||("wmode"==key||(self.props[key]===val||(data["youtube_"+key]=val,void delete data[key])))}),src=src.replace(/youtu(\.)?be([^\/]+)?\/(.+)/,function(a,b,c,d){var args="youtube";if(b&&(args+=".com"),c&&(args+=c),args+="/embed",args+="/"+id,u.anchor){var s=u.anchor;s=s.replace(/(\?|&)(.+)/,""),args+="#"+s}return args}).replace(/\/\/youtube/i,"//www.youtube"),$.each(data,function(key,val){/^iframe_(allow|frameborder|allowfullscreen)/.test(key)&&delete data[key]}),data.src=src,data},getAttributes:function(src){var args={},data=this.setValues({src:src})||{};return $.each(data,function(k,v){"src"!==k&&(args["youtube_"+k]=v)}),args=$.extend(args,{src:data.src||src,width:this.params.width,height:this.params.height})},setAttributes:function(){},onSelectFile:function(){},onInsert:function(){}});
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
?>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<div class="uk-width-4-10">
|
||||
<input type="checkbox" id="youtube_controls" checked />
|
||||
<label for="youtube_controls" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_CONTROLS_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_CONTROLS') ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="uk-width-6-10">
|
||||
<input type="checkbox" id="youtube_loop" />
|
||||
<label for="youtube_loop" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_LOOP_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_LOOP') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<div class="uk-width-4-10">
|
||||
<input type="checkbox" id="youtube_autoplay" />
|
||||
<label for="youtube_autoplay" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_AUTOPLAY_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_AUTOPLAY') ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="uk-width-6-10">
|
||||
<input type="checkbox" id="youtube_privacy" />
|
||||
<label for="youtube_privacy" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PRIVACY_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PRIVACY') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<div class="uk-width-4-10 uk-grid uk-grid-collapse">
|
||||
<input type="checkbox" id="youtube_modestbranding" checked />
|
||||
<label for="youtube_modestbranding" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_MODESTBRANDING_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_MODESTBRANDING') ?>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="uk-width-6-10 uk-grid uk-grid-collapse">
|
||||
<label for="youtube_rel" class="uk-form-label uk-width-1-5 tooltip" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_RELATED_DESC') ?>">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_RELATED') ?>
|
||||
</label>
|
||||
|
||||
<select id="youtube_rel">
|
||||
<option value="1">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_RELATED_ALL') ?>
|
||||
</option>
|
||||
<option value="0">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_RELATED_CHANNEL') ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-grid uk-grid-small">
|
||||
<label for="youtube_start" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_START_DESC') ?>" class="tooltip uk-form-label uk-width-2-10">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_START') ?>
|
||||
</label>
|
||||
|
||||
<div class="uk-form-controls uk-width-2-10">
|
||||
<input type="number" id="youtube_start" />
|
||||
</div>
|
||||
<div class="uk-width-6-10">
|
||||
<label for="youtube_end" class="uk-form-label uk-width-2-10" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_END_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_END') ?>
|
||||
</label>
|
||||
<div class="uk-form-controls uk-width-3-10">
|
||||
<input type="number" id="youtube_end" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-grid uk-grid-small">
|
||||
<label for="youtube_playlist" class="uk-form-label uk-width-1-5" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PLAYLIST_DESC') ?>" class="tooltip">
|
||||
<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PLAYLIST') ?>
|
||||
</label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<input type="text" id="youtube_playlist" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="youtube_params" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PARAMS_DESC'); ?>"><?php echo JText::_('WF_AGGREGATOR_YOUTUBE_PARAMS'); ?></label>
|
||||
<div class="uk-width-4-5" id="youtube_params">
|
||||
<div class="uk-form-row uk-repeatable">
|
||||
<div class="uk-form-controls uk-grid uk-grid-small uk-width-9-10">
|
||||
<label class="uk-form-label uk-width-1-6"><?php echo JText::_('WF_LABEL_NAME'); ?></label>
|
||||
<div class="uk-form-controls uk-width-1-3">
|
||||
<input type="text" name="youtube_params_name[]" />
|
||||
</div>
|
||||
<label class="uk-form-label uk-width-1-6"><?php echo JText::_('WF_LABEL_VALUE'); ?></label>
|
||||
<div class="uk-form-controls uk-width-1-3">
|
||||
<input type="text" name="youtube_params_value[]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-controls uk-margin-small-left">
|
||||
<button type="button" class="uk-button uk-button-link uk-repeatable-create"><i class="uk-icon-plus"></i></button>
|
||||
<button type="button" class="uk-button uk-button-link uk-repeatable-delete"><i class="uk-icon-trash"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
958
components/com_jce/editor/extensions/filesystem/joomla.php
Normal file
958
components/com_jce/editor/extensions/filesystem/joomla.php
Normal file
@@ -0,0 +1,958 @@
|
||||
<?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;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
class WFJoomlaFileSystem extends WFFileSystem
|
||||
{
|
||||
private static $restricted = array(
|
||||
'administrator', 'bin', 'cache', 'components', 'cli', 'includes', 'language', 'layouts', 'libraries', 'logs', 'media', 'modules', 'plugins', 'templates', 'tmp', 'xmlrpc',
|
||||
);
|
||||
|
||||
private static $allowroot = false;
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
$safe_mode = false;
|
||||
|
||||
// check for safe mode
|
||||
if (function_exists('ini_get')) {
|
||||
$safe_mode = ini_get('safe_mode');
|
||||
// assume safe mode if can't check ini
|
||||
} else {
|
||||
$safe_mode = true;
|
||||
}
|
||||
|
||||
$this->setProperties(array(
|
||||
'local' => true,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)) {
|
||||
$root = parent::getRootDir();
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
// list of restricted directories
|
||||
$restricted = $wf->getParam('filesystem.joomla.restrict_dir', self::$restricted);
|
||||
|
||||
// explode to array
|
||||
if (is_string($restricted)) {
|
||||
self::$restricted = explode(',', $restricted);
|
||||
} else {
|
||||
self::$restricted = $restricted;
|
||||
}
|
||||
|
||||
// is root allowed?
|
||||
self::$allowroot = (bool) $wf->getParam('filesystem.joomla.allow_root', 0);
|
||||
|
||||
// set $root to empty if it is allowed
|
||||
if (self::$allowroot) {
|
||||
$root = '';
|
||||
} else {
|
||||
// Revert to default if empty
|
||||
if (empty($root)) {
|
||||
$root = 'images';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($root)) {
|
||||
// Create the folder
|
||||
$full = WFUtility::makePath(JPATH_SITE, $root);
|
||||
|
||||
if (!JFolder::exists($full)) {
|
||||
$this->folderCreate($full);
|
||||
}
|
||||
|
||||
// Fallback
|
||||
$root = JFolder::exists($full) ? $root : 'images';
|
||||
}
|
||||
}
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemGetRootDir', array(&$root));
|
||||
|
||||
return $root;
|
||||
}
|
||||
|
||||
public function toAbsolute($path)
|
||||
{
|
||||
return WFUtility::makePath($this->getBaseDir(), $path);
|
||||
}
|
||||
|
||||
public function toRelative($path, $isabsolute = true)
|
||||
{
|
||||
// path is absolute
|
||||
$base = $this->getBaseDir();
|
||||
|
||||
// path is relative to Joomla! root, eg: images/folder
|
||||
if ($isabsolute === false) {
|
||||
$base = $this->getRootDir();
|
||||
}
|
||||
|
||||
if (function_exists('mb_substr')) {
|
||||
$path = mb_substr($path, mb_strlen($base));
|
||||
} else {
|
||||
$path = substr($path, strlen($base));
|
||||
}
|
||||
|
||||
$path = WFUtility::cleanPath($path);
|
||||
|
||||
return ltrim($path, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether FTP mode is enabled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFtp()
|
||||
{
|
||||
// Initialize variables
|
||||
jimport('joomla.client.helper');
|
||||
$FTPOptions = JClientHelper::getCredentials('ftp');
|
||||
|
||||
return $FTPOptions['enabled'] == 1;
|
||||
}
|
||||
|
||||
public function getTotalSize($path, $recurse = true)
|
||||
{
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
$total = 0;
|
||||
|
||||
if (strpos($path, $this->getBaseDir()) === false) {
|
||||
$path = $this->toAbsolute($path);
|
||||
}
|
||||
|
||||
if (JFolder::exists($path)) {
|
||||
$files = JFolder::files($path, '.', $recurse, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html', 'thumbs.db'));
|
||||
|
||||
foreach ($files as $file) {
|
||||
$total += filesize($file);
|
||||
}
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of files in a folder.
|
||||
*
|
||||
* @return int File total
|
||||
*
|
||||
* @param string $path Absolute path to folder
|
||||
*/
|
||||
public function countFiles($path, $recurse = false)
|
||||
{
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
if (strpos($path, $this->getBaseDir()) === false) {
|
||||
$path = $this->toAbsolute($path);
|
||||
}
|
||||
|
||||
if (JFolder::exists($path)) {
|
||||
$files = JFolder::files($path, '.', $recurse, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html', 'thumbs.db'));
|
||||
|
||||
return count($files);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of folders in a folder.
|
||||
*
|
||||
* @return int Folder total
|
||||
*
|
||||
* @param string $path Absolute path to folder
|
||||
*/
|
||||
public function countFolders($path)
|
||||
{
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
if (strpos($path, $this->getBaseDir()) === false) {
|
||||
$path = $this->toAbsolute($path);
|
||||
}
|
||||
|
||||
if (JFolder::exists($path)) {
|
||||
$folders = JFolder::folders($path, '.', false, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX'));
|
||||
|
||||
return count($folders);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFolders($relative, $filter = '', $sort = '', $limit = 25, $start = 0, $depth = 0)
|
||||
{
|
||||
$path = $this->toAbsolute($relative);
|
||||
$path = WFUtility::fixPath($path);
|
||||
|
||||
if (!JFolder::exists($path)) {
|
||||
$relative = '/';
|
||||
$path = $this->getBaseDir();
|
||||
}
|
||||
|
||||
$list = JFolder::folders($path, $filter, $depth, true);
|
||||
|
||||
$folders = array();
|
||||
|
||||
if (!empty($list)) {
|
||||
// Sort alphabetically by default
|
||||
natcasesort($list);
|
||||
|
||||
foreach ($list as $item) {
|
||||
$item = rawurldecode($item);
|
||||
|
||||
// clean path to remove multiple slashes
|
||||
$item = WFUtility::cleanPath($item);
|
||||
|
||||
$name = WFUtility::mb_basename($item);
|
||||
$name = WFUtility::convertEncoding($name);
|
||||
|
||||
$break = false;
|
||||
|
||||
if (self::$allowroot) {
|
||||
foreach (self::$restricted as $val) {
|
||||
if ($item === WFUtility::makePath($path, $val)) {
|
||||
$break = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($break) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = WFUtility::makePath($relative, $name, '/');
|
||||
|
||||
if ($depth) {
|
||||
$id = $this->toRelative($item);
|
||||
$id = WFUtility::convertEncoding($id);
|
||||
$name = $id;
|
||||
}
|
||||
|
||||
// trim leading slash
|
||||
$id = ltrim($id, '/');
|
||||
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'writable' => is_writable($item) || $this->isFtp(),
|
||||
'type' => 'folders',
|
||||
'properties' => $this->getFolderDetails($id),
|
||||
);
|
||||
|
||||
$folders[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sort && strpos($sort, 'extension') === false) {
|
||||
$folders = self::sortItemsByKey($folders, $sort);
|
||||
}
|
||||
|
||||
return $folders;
|
||||
}
|
||||
|
||||
public function getFiles($relative, $filter = '', $sort = '', $limit = 25, $start = 0, $depth = 0)
|
||||
{
|
||||
$path = $this->toAbsolute($relative);
|
||||
$path = WFUtility::fixPath($path);
|
||||
|
||||
if (!JFolder::exists($path)) {
|
||||
$relative = '/';
|
||||
$path = $this->getBaseDir();
|
||||
}
|
||||
|
||||
// excluded files
|
||||
$exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html');
|
||||
|
||||
$list = JFolder::files($path, $filter, $depth, true, $exclude);
|
||||
|
||||
$files = array();
|
||||
|
||||
// get the total files in the list
|
||||
$count = count($list);
|
||||
|
||||
if (!empty($list)) {
|
||||
// Sort alphabetically by default
|
||||
natcasesort($list);
|
||||
|
||||
foreach ($list as $item) {
|
||||
$item = rawurldecode($item);
|
||||
|
||||
$name = WFUtility::mb_basename($item);
|
||||
$name = WFUtility::convertEncoding($name);
|
||||
|
||||
// create relative file
|
||||
$id = WFUtility::makePath($relative, $name, '/');
|
||||
|
||||
// check for file validity - prevent display of files with invalid encoding that have been "cleaned"
|
||||
if (!is_file(WFUtility::makePath($this->getBaseDir(), $id, '/'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($depth) {
|
||||
$id = $this->toRelative($item);
|
||||
$id = WFUtility::convertEncoding($id);
|
||||
$name = $id;
|
||||
}
|
||||
|
||||
// get basename of file name
|
||||
$name = WFUtility::mb_basename($name);
|
||||
|
||||
// create url
|
||||
$url = WFUtility::makePath($this->getRootDir(), $id, '/');
|
||||
|
||||
// remove leading slash
|
||||
$url = ltrim($url, '/');
|
||||
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
'url' => $url,
|
||||
'name' => $name,
|
||||
'writable' => is_writable($item) || $this->isFtp(),
|
||||
'type' => 'files',
|
||||
'extension' => WFUtility::getExtension($name),
|
||||
'properties' => $this->getFileDetails($id, $count),
|
||||
);
|
||||
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sort) {
|
||||
$files = self::sortItemsByKey($files, $sort);
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
public function searchItems($relative, $query = '', $filetypes = array(), $sort = '', $depth = 3)
|
||||
{
|
||||
$result = array(
|
||||
'folders' => array(),
|
||||
'files' => array(),
|
||||
);
|
||||
|
||||
// get folder list
|
||||
$folders = $this->getFolders($relative, '', 0, 0, $sort, 3);
|
||||
|
||||
// filter based on passed in query
|
||||
foreach ($folders as $folder) {
|
||||
if (preg_match("/$query/u", $folder['id'])) {
|
||||
$result['folders'][] = $folder;
|
||||
}
|
||||
}
|
||||
|
||||
$filter = '';
|
||||
|
||||
// create filter for filetypes
|
||||
if (!empty($filestypes)) {
|
||||
$filter .= '\.(?i)(' . implode('|', $filetypes) . ')$';
|
||||
}
|
||||
|
||||
// get file list
|
||||
$files = $this->getFiles($relative, $filter, 0, 0, $sort, 3);
|
||||
|
||||
// filter based on passed in query
|
||||
foreach ($files as $files) {
|
||||
if (preg_match("/$query/u", $files['id'])) {
|
||||
$result['files'][] = $files;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a folders properties.
|
||||
*
|
||||
* @return array Array of properties
|
||||
*
|
||||
* @param string $dir Folder relative path
|
||||
* @param string $types File Types
|
||||
*/
|
||||
public function getFolderDetails($dir)
|
||||
{
|
||||
clearstatcache();
|
||||
|
||||
if (is_array($dir)) {
|
||||
$dir = isset($dir['id']) ? $dir['id'] : '';
|
||||
}
|
||||
|
||||
if (empty($dir)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$path = $this->toAbsolute(rawurldecode($dir));
|
||||
$date = @filemtime($path);
|
||||
|
||||
return array('modified' => $date, 'size' => '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source directory of a file path.
|
||||
*/
|
||||
public function getSourceDir($path)
|
||||
{
|
||||
// return nothing if absolute $path
|
||||
if (preg_match('#^(file|http(s)?):\/\/#', $path)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// directory path relative base directory
|
||||
if ($this->is_dir($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// directory path relative to site root
|
||||
if (is_dir(WFUtility::makePath(JPATH_SITE, $path))) {
|
||||
if (function_exists('mb_substr')) {
|
||||
return mb_substr($path, mb_strlen($this->getRootDir()));
|
||||
}
|
||||
|
||||
return substr($path, strlen($this->getRootDir()));
|
||||
}
|
||||
|
||||
// file url relative to site root
|
||||
if (is_file(WFUtility::makePath(JPATH_SITE, $path))) {
|
||||
if (function_exists('mb_substr')) {
|
||||
return mb_substr(dirname($path), mb_strlen($this->getRootDir()));
|
||||
}
|
||||
|
||||
return substr(dirname($path), strlen($this->getRootDir()));
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function isMatch($needle, $haystack)
|
||||
{
|
||||
return $needle == $haystack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return constituent parts of a file path eg: base directory, file name.
|
||||
*
|
||||
* @param $path Relative or absolute path
|
||||
*/
|
||||
public function pathinfo($path)
|
||||
{
|
||||
return pathinfo($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a files properties.
|
||||
*
|
||||
* @return array Array of properties
|
||||
*
|
||||
* @param string $file File relative path
|
||||
*/
|
||||
public function getFileDetails($file, $count = 1)
|
||||
{
|
||||
clearstatcache();
|
||||
|
||||
if (is_array($file)) {
|
||||
$file = isset($file['id']) ? $file['id'] : '';
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$path = $this->toAbsolute(rawurldecode($file));
|
||||
$url = WFUtility::makePath($this->getBaseUrl(), rawurldecode($file));
|
||||
|
||||
$date = @filemtime($path);
|
||||
$size = @filesize($path);
|
||||
|
||||
$data = array(
|
||||
'size' => $size,
|
||||
'modified' => $date,
|
||||
);
|
||||
|
||||
$data['preview'] = WFUtility::cleanPath($url, '/');
|
||||
|
||||
if (preg_match('#\.(jpg|jpeg|bmp|gif|tiff|png|svg)#i', $file)) {
|
||||
$image = array();
|
||||
|
||||
if ($count <= 100) {
|
||||
if (preg_match('#\.svg$#i', $file)) {
|
||||
$svg = @simplexml_load_file($path);
|
||||
|
||||
if ($svg && isset($svg['viewBox'])) {
|
||||
list($start_x, $start_y, $end_x, $end_y) = explode(' ', $svg['viewBox']);
|
||||
|
||||
$width = (int) $end_x;
|
||||
$height = (int) $end_y;
|
||||
|
||||
if ($width && $height) {
|
||||
$image['width'] = $width;
|
||||
$image['height'] = $height;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list($image['width'], $image['height']) = @getimagesize($path);
|
||||
}
|
||||
}
|
||||
|
||||
$data['preview'] .= '?' . $date;
|
||||
|
||||
return array_merge_recursive($data, $image);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function checkRestrictedDirectory($path)
|
||||
{
|
||||
if (self::$allowroot) {
|
||||
foreach (self::$restricted as $name) {
|
||||
$restricted = $this->toAbsolute($name);
|
||||
|
||||
$match = false;
|
||||
|
||||
if (function_exists('mb_substr')) {
|
||||
$match = (mb_substr($path, 0, mb_strlen($restricted)) === $restricted);
|
||||
} else {
|
||||
$match = (substr($path, 0, strlen($restricted)) === $restricted);
|
||||
}
|
||||
|
||||
if ($match === true) {
|
||||
throw new Exception('Access to the target directory is restricted');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the relative file(s).
|
||||
*
|
||||
* @param $files the relative path to the file name or comma seperated list of multiple paths
|
||||
*
|
||||
* @return string $error on failure
|
||||
*/
|
||||
public function delete($src)
|
||||
{
|
||||
$path = $this->toAbsolute($src);
|
||||
|
||||
// get error class
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
// check path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($path);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemBeforeDelete', array(&$path));
|
||||
|
||||
if (is_file($path)) {
|
||||
$result->type = 'files';
|
||||
$result->state = JFile::delete($path);
|
||||
} elseif (is_dir($path)) {
|
||||
$result->type = 'folders';
|
||||
|
||||
if ($this->countFiles($path) > 0 || $this->countFolders($path) > 0) {
|
||||
$result->message = JText::sprintf('WF_MANAGER_FOLDER_NOT_EMPTY', WFUtility::mb_basename($path));
|
||||
} else {
|
||||
$result->state = JFolder::delete($path);
|
||||
}
|
||||
}
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemAfterDelete', array($path, $result->state));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a file.
|
||||
*
|
||||
* @param string $src The relative path of the source file
|
||||
* @param string $dest The name of the new file
|
||||
*
|
||||
* @return string $error
|
||||
*/
|
||||
public function rename($src, $dest)
|
||||
{
|
||||
$src = $this->toAbsolute(rawurldecode($src));
|
||||
$dir = WFUtility::mb_dirname($src);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemBeforeRename', array(&$src, &$dest));
|
||||
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
if (is_file($src)) {
|
||||
$ext = WFUtility::getExtension($src);
|
||||
$file = $dest . '.' . $ext;
|
||||
$path = WFUtility::makePath($dir, $file);
|
||||
|
||||
// check path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($path);
|
||||
|
||||
$result->type = 'files';
|
||||
$result->state = JFile::move($src, $path);
|
||||
$result->path = $path;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
} elseif (is_dir($src)) {
|
||||
$path = WFUtility::makePath($dir, $dest);
|
||||
|
||||
$result->type = 'folders';
|
||||
$result->state = JFolder::move($src, $path);
|
||||
$result->path = $path;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
}
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemAfterRename', array(&$result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $files The relative file or comma seperated list of files
|
||||
* @param string $dest The relative path of the destination dir
|
||||
*
|
||||
* @return string $error on failure
|
||||
*/
|
||||
public function copy($file, $destination)
|
||||
{
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
// trim to remove leading slash
|
||||
$file = trim($file, '/');
|
||||
|
||||
$src = $this->toAbsolute($file);
|
||||
// destination relative path
|
||||
$dest = WFUtility::makePath($destination, WFUtility::mb_basename($file));
|
||||
// destination full path
|
||||
$dest = $this->toAbsolute($dest);
|
||||
|
||||
// check destination path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($dest);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemBeforeCopy', array(&$src, &$dest));
|
||||
|
||||
// src is a file
|
||||
if (is_file($src)) {
|
||||
$result->type = 'files';
|
||||
$result->state = JFile::copy($src, $dest);
|
||||
$result->path = $dest;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
} elseif (is_dir($src)) {
|
||||
// Folders cannot be copied into themselves as this creates an infinite copy / paste loop
|
||||
if ($file === $destination) {
|
||||
$result->message = JText::_('WF_MANAGER_COPY_INTO_ERROR');
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result->type = 'folders';
|
||||
$result->state = JFolder::copy($src, $dest);
|
||||
$result->path = $dest;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
}
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemAfterCopy', array(&$result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $files The relative file or comma seperated list of files
|
||||
* @param string $dest The relative path of the destination dir
|
||||
*
|
||||
* @return string $error on failure
|
||||
*/
|
||||
public function move($file, $destination)
|
||||
{
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
// trim to remove leading slash
|
||||
$file = trim($file, '/');
|
||||
|
||||
$src = $this->toAbsolute($file);
|
||||
// destination relative path
|
||||
$dest = WFUtility::makePath($destination, WFUtility::mb_basename($file));
|
||||
// destination full path
|
||||
$dest = $this->toAbsolute($dest);
|
||||
|
||||
// check destination path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($dest);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemBeforeMove', array(&$src, &$dest));
|
||||
|
||||
if ($src != $dest) {
|
||||
// src is a file
|
||||
if (is_file($src)) {
|
||||
$result->type = 'files';
|
||||
$result->state = JFile::move($src, $dest);
|
||||
$result->path = $dest;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
} elseif (is_dir($src)) {
|
||||
// Folders cannot be copied into themselves as this creates an infinite copy / paste loop
|
||||
if ($file === $destination) {
|
||||
$result->message = JText::_('WF_MANAGER_COPY_INTO_ERROR');
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result->type = 'folders';
|
||||
$result->state = JFolder::move($src, $dest);
|
||||
$result->path = $dest;
|
||||
// include original source path
|
||||
$result->source = $src;
|
||||
}
|
||||
}
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemAfterMove', array(&$result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* New folder base function. A wrapper for the JFolder::create function.
|
||||
*
|
||||
* @param string $folder The folder to create
|
||||
*
|
||||
* @return bool true on success
|
||||
*/
|
||||
public function folderCreate($folder)
|
||||
{
|
||||
if (is_dir($folder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (@JFolder::create($folder)) {
|
||||
$buffer = '<html><body bgcolor="#FFFFFF"></body></html>';
|
||||
JFile::write($folder . '/index.html', $buffer);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* New folder.
|
||||
*
|
||||
* @param string $dir The base dir
|
||||
* @param string $new_dir The folder to be created
|
||||
*
|
||||
* @return string $error on failure
|
||||
*/
|
||||
public function createFolder($dir, $new)
|
||||
{
|
||||
// relative new folder path
|
||||
$dir = WFUtility::makePath(rawurldecode($dir), $new);
|
||||
// full folder path
|
||||
$path = $this->toAbsolute($dir);
|
||||
|
||||
// check path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($path);
|
||||
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
$result->state = $this->folderCreate($path);
|
||||
$result->path = $path;
|
||||
$result->type = 'folders';
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemCreateFolder', array($path, $result->state));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDimensions($file)
|
||||
{
|
||||
$path = $this->toAbsolute(utf8_decode(rawurldecode($file)));
|
||||
|
||||
$data = array(
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
);
|
||||
if (file_exists($path)) {
|
||||
$dim = @getimagesize($path);
|
||||
$data = array(
|
||||
'width' => $dim[0],
|
||||
'height' => $dim[1],
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function upload($method, $src, $dir, $name, $chunks = 1, $chunk = 0)
|
||||
{
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// full destination directory path
|
||||
$path = $this->toAbsolute(rawurldecode($dir));
|
||||
// full file path
|
||||
$dest = WFUtility::makePath($path, $name);
|
||||
|
||||
// check destination path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($dest);
|
||||
|
||||
// check for safe mode
|
||||
$safe_mode = false;
|
||||
|
||||
if (function_exists('ini_get')) {
|
||||
$safe_mode = ini_get('safe_mode');
|
||||
} else {
|
||||
$safe_mode = true;
|
||||
}
|
||||
|
||||
$result = new WFFileSystemResult();
|
||||
|
||||
// get overwrite state
|
||||
$conflict = $this->get('upload_conflict', 'overwrite');
|
||||
// get suffix
|
||||
$suffix = $this->get('upload_suffix', '_copy');
|
||||
|
||||
if ($conflict == 'unique') {
|
||||
// get extension
|
||||
$extension = WFUtility::getExtension($name);
|
||||
// get name without extension
|
||||
$name = WFUtility::stripExtension($name);
|
||||
// create tmp copy
|
||||
$tmpname = $name;
|
||||
|
||||
$x = 1;
|
||||
|
||||
while (JFile::exists($dest)) {
|
||||
if (strpos($suffix, '$') !== false) {
|
||||
$tmpname = $name . str_replace('$', $x, $suffix);
|
||||
} else {
|
||||
$tmpname .= $suffix;
|
||||
}
|
||||
|
||||
$dest = WFUtility::makePath($path, $tmpname . '.' . $extension);
|
||||
|
||||
++$x;
|
||||
}
|
||||
}
|
||||
|
||||
$app->triggerEvent('onWfFileSystemBeforeUpload', array(&$src, &$dest));
|
||||
|
||||
// create object to pass to joomla event
|
||||
$object_file = new JObject(array(
|
||||
'name' => WFUtility::mb_basename($dest),
|
||||
'tmp_name' => $src,
|
||||
'filepath' => $dest,
|
||||
));
|
||||
|
||||
// vars for Joomla events
|
||||
$vars = array('com_jce.file', &$object_file, true, array());
|
||||
|
||||
// trigger Joomla event before upload
|
||||
$app->triggerEvent('onContentBeforeSave', $vars);
|
||||
|
||||
if (JFile::upload($src, $dest, false, true)) {
|
||||
$result->state = true;
|
||||
$result->path = $dest;
|
||||
}
|
||||
|
||||
$app->triggerEvent('onWfFileSystemAfterUpload', array(&$result));
|
||||
|
||||
// update $object_file
|
||||
$object_file->name = WFUtility::mb_basename($result->path);
|
||||
$object_file->filepath = $result->path;
|
||||
|
||||
// trigger Joomla event after upload
|
||||
$app->triggerEvent('onContentAfterSave', $vars);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function exists($path)
|
||||
{
|
||||
return $this->is_dir($path) || $this->is_file($path);
|
||||
}
|
||||
|
||||
public function read($file)
|
||||
{
|
||||
$path = $this->toAbsolute(rawurldecode($file));
|
||||
|
||||
return file_get_contents($path);
|
||||
}
|
||||
|
||||
public function write($file, $content)
|
||||
{
|
||||
$path = $this->toAbsolute(rawurldecode($file));
|
||||
|
||||
// check path does not fall within a restricted folder
|
||||
$this->checkRestrictedDirectory($path);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemBeforeWrite', array(&$path, &$content));
|
||||
|
||||
$result = JFile::write($path, $content);
|
||||
|
||||
JFactory::getApplication()->triggerEvent('onWfFileSystemAfterWrite', array($path, $result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function is_file($path)
|
||||
{
|
||||
$path = $this->toAbsolute($path);
|
||||
return is_file($path);
|
||||
}
|
||||
|
||||
public function is_dir($path)
|
||||
{
|
||||
$path = $this->toAbsolute($path);
|
||||
return is_dir($path);
|
||||
}
|
||||
}
|
||||
40
components/com_jce/editor/extensions/filesystem/joomla.xml
Normal file
40
components/com_jce/editor/extensions/filesystem/joomla.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.8">
|
||||
<name>WF_FILESYSTEM_JOOMLA_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_FILESYSTEM_JOOMLA_DESC</description>
|
||||
<files></files>
|
||||
<fields>
|
||||
<fieldset name="filesystem.joomla">
|
||||
<field name="allow_root" type="radio" default="0" label="WF_PARAM_ALLOW_ROOT" description="WF_PARAM_ALLOW_ROOT_DESC" class="btn-group btn-group-yesno">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="restrict_dir" type="customlist" default="administrator,bin,cache,components,cli,includes,language,layouts,libraries,logs,media,modules,plugins,templates,tmp,xmlrpc" multiple="true" label="WF_PARAM_DIRECTORY_RESTRICTED" description="WF_PARAM_DIRECTORY_RESTRICTED_DESC" layout="joomla.form.field.list-fancy-select" showon="allow_root:1">
|
||||
<option value="administrator">administrator</option>
|
||||
<option value="bin">bin</option>
|
||||
<option value="cache">cache</option>
|
||||
<option value="components">components</option>
|
||||
<option value="cli">cli</option>
|
||||
<option value="includes">includes</option>
|
||||
<option value="language">language</option>
|
||||
<option value="layouts">layouts</option>
|
||||
<option value="libraries">libraries</option>
|
||||
<option value="logs">logs</option>
|
||||
<option value="media">media</option>
|
||||
<option value="modules">modules</option>
|
||||
<option value="plugins">plugins</option>
|
||||
<option value="templates">templates</option>
|
||||
<option value="tmp">tmp</option>
|
||||
<option value="xmlrpc">xmlrpc</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</extension>
|
||||
1
components/com_jce/editor/extensions/index.html
Normal file
1
components/com_jce/editor/extensions/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
1
components/com_jce/editor/extensions/links/index.html
Normal file
1
components/com_jce/editor/extensions/links/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
118
components/com_jce/editor/extensions/links/joomlalinks.php
Normal file
118
components/com_jce/editor/extensions/links/joomlalinks.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
|
||||
class WFLinkBrowser_Joomlalinks
|
||||
{
|
||||
public $_option = array();
|
||||
public $_adapters = array();
|
||||
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$path = __DIR__ . '/joomlalinks';
|
||||
|
||||
// Get all files
|
||||
$files = JFolder::files($path, '\.(php)$');
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $file) {
|
||||
$name = basename($file, '.php');
|
||||
|
||||
if (!$this->checkOptionAccess($name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip weblinks if it doesn't exist!
|
||||
if ($name == 'weblinks' && !JComponentHelper::isEnabled('com_weblinks')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
require_once $path . '/' . $file;
|
||||
|
||||
$classname = 'Joomlalinks' . ucfirst($name);
|
||||
|
||||
if (class_exists($classname)) {
|
||||
$this->_adapters[] = new $classname();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkOptionAccess($option)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$option = str_replace('com_', '', $option);
|
||||
|
||||
if ($option === "contact") {
|
||||
$option = "contacts";
|
||||
}
|
||||
|
||||
return (int) $wf->getParam('links.joomlalinks.' . $option, 1) === 1;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
// Load css
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addStyleSheet(array('joomlalinks'), 'extensions/links/joomlalinks/css');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
return (bool) $wf->getParam('links.joomlalinks.enable', 1);
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
foreach ($this->_adapters as $adapter) {
|
||||
$this->_option[] = $adapter->getOption();
|
||||
}
|
||||
|
||||
return $this->_option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
$list = '';
|
||||
|
||||
foreach ($this->_adapters as $adapter) {
|
||||
$list .= $adapter->getList();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
foreach ($this->_adapters as $adapter) {
|
||||
if ($adapter->getOption() == $args->option) {
|
||||
|
||||
if (!$this->checkOptionAccess($args->option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $adapter->getLinks($args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
components/com_jce/editor/extensions/links/joomlalinks.xml
Normal file
75
components/com_jce/editor/extensions/links/joomlalinks.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_LINKS_JOOMLALINKS_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_LINKS_JOOMLALINKS_DESC</description>
|
||||
<files>
|
||||
<filename>joomlalinks.php</filename>
|
||||
<folder>joomlalinks</folder>
|
||||
</files>
|
||||
<!--params group="links">
|
||||
<field name="joomlalinks" type="yesno" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</params-->
|
||||
<fields name="joomlalinks">
|
||||
<fieldset name="links.joomlalinks">
|
||||
<field name="content" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_CONTENT" description="WF_LINKS_JOOMLALINKS_PARAM_CONTENT_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="article_alias" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_ARTICLE_ALIAS" description="WF_LINKS_JOOMLALINKS_PARAM_ARTICLE_ALIAS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="article_unpublished" type="yesno" default="0" label="WF_LINKS_JOOMLALINKS_PARAM_ARTICLE_UNPUBLISHED" description="WF_LINKS_JOOMLALINKS_PARAM_ARTICLE_UNPUBLISHED_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="static" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_UNCATEGORIZED" description="WF_LINKS_JOOMLALINKS_PARAM_UNCATEGORIZED_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="contacts" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_CONTACT" description="WF_LINKS_JOOMLALINKS_PARAM_CONTACT_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="weblinks" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_WEBLINKS" description="WF_LINKS_JOOMLALINKS_PARAM_WEBLINKS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="weblinks_alias" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_WEBLINKS_ALIAS" description="WF_LINKS_JOOMLALINKS_PARAM_WEBLINKS_ALIAS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="menu" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_MENU" description="WF_LINKS_JOOMLALINKS_PARAM_MENU_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="tags" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_TAGS" description="WF_LINKS_JOOMLALINKS_PARAM_TAGS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="tags_alias" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_PARAM_TAGS_ALIAS" description="WF_LINKS_JOOMLALINKS_PARAM_TAGS_ALIAS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="itemid" type="yesno" default="1" label="WF_LINKS_JOOMLALINKS_ITEMID" description="WF_LINKS_JOOMLALINKS_ITEMID_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="sef_url" type="yesno" default="0" label="WF_LINKS_JOOMLALINKS_SEF_URL" description="WF_LINKS_JOOMLALINKS_SEF_URL_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins></plugins>
|
||||
</extension>
|
||||
@@ -0,0 +1,167 @@
|
||||
<?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 JoomlalinksContact extends JObject
|
||||
{
|
||||
private $option = 'com_contact';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_contact" class="folder contact nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_CONTACTS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
switch ($view) {
|
||||
default:
|
||||
$categories = WFLinkBrowser::getCategory('com_contact', 1, $this->get('category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$url = JHelperRoute::getCategoryRoute($category->id, $language, 'com_contact');
|
||||
|
||||
// convert to SEF
|
||||
$url = self::route($url);
|
||||
|
||||
$items[] = array(
|
||||
'id' => 'index.php?option=com_contact&view=category&id=' . $category->id,
|
||||
'url' => $url,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder contact',
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'category':
|
||||
$categories = WFLinkBrowser::getCategory('com_contact', $args->id, $this->get('category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$children = WFLinkBrowser::getCategory('com_contact', $category->id, $this->get('category_alias', 1));
|
||||
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
if ($children) {
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_contact');
|
||||
} else {
|
||||
$id = JHelperRoute::getCategoryRoute($category->slug, $language, 'com_contact');
|
||||
}
|
||||
|
||||
// convert to SEF
|
||||
$url = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'url' => $url,
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
|
||||
$contacts = self::getContacts($args->id);
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
// language
|
||||
if (isset($contact->language)) {
|
||||
$language = $contact->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($contact->id, 'com_contact.contact', '', $language, $args->id);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $contact->name . ' / ' . $contact->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private static function getContacts($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('id, name, alias, language')->from('#__contact_details')->where(array('catid=' . (int) $id, 'published = 1'));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
<?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 JoomlalinksContent extends JObject
|
||||
{
|
||||
private $option = 'com_content';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_content" class="folder content nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_CONTENT') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
switch ($view) {
|
||||
// get top-level categories
|
||||
default:
|
||||
$articles = array();
|
||||
|
||||
if (!isset($args->id)) {
|
||||
$args->id = 1;
|
||||
}
|
||||
|
||||
$categories = WFLinkBrowser::getCategory('com_content', $args->id);
|
||||
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$articles = self::getArticles($args->id);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$url = '';
|
||||
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_content');
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = self::getMenuLink($id);
|
||||
$id = 'index.php?option=com_content&view=category&id=' . $category->id;
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($articles)) {
|
||||
// output article links
|
||||
foreach ($articles as $article) {
|
||||
if (isset($article->language)) {
|
||||
$language = $article->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($article->slug, 'com_content.article', '', $language, $article->catslug);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $article->title . ' / ' . $article->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
|
||||
$anchors = self::getAnchors($article->content);
|
||||
|
||||
foreach ($anchors as $anchor) {
|
||||
$items[] = array(
|
||||
'id' => $id . '#' . $anchor,
|
||||
'name' => '#' . $anchor,
|
||||
'class' => 'file anchor',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// get articles and / or sub-categories
|
||||
case 'category':
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$articles = self::getArticles($args->id);
|
||||
|
||||
// get sub-categories
|
||||
$categories = WFLinkBrowser::getCategory('com_content', $args->id);
|
||||
|
||||
if (count($categories)) {
|
||||
foreach ($categories as $category) {
|
||||
// check for sub-categories
|
||||
$sub = WFLinkBrowser::getCategory('com_content', $category->id);
|
||||
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_content');
|
||||
|
||||
// get sub-categories
|
||||
if (count($sub)) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_content&view=section&id=' . $category->id;
|
||||
// no sub-categories, get articles for category
|
||||
} else {
|
||||
// no com_content, might be link like index.php?ItemId=1
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id; //$id;
|
||||
$id = 'index.php?option=com_content&view=category&id=' . $category->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($url, 'index.php?Itemid=') !== false) {
|
||||
$url = self::getMenuLink($url);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// output article links
|
||||
foreach ($articles as $article) {
|
||||
// language
|
||||
if (isset($article->language)) {
|
||||
$language = $article->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($article->slug, 'com_content.article', '', $language, $article->catslug);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $article->title . ' / ' . $article->alias,
|
||||
'class' => 'file' . ($article->state ? '' : ' unpublished uk-text-muted'),
|
||||
);
|
||||
|
||||
$anchors = self::getAnchors($article->content);
|
||||
|
||||
foreach ($anchors as $anchor) {
|
||||
$items[] = array(
|
||||
'id' => $id . '#' . $anchor,
|
||||
'name' => '#' . $anchor,
|
||||
'class' => 'file anchor',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getMenuLink($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
// resolve the url from the menu link
|
||||
if ($wf->getParam('links.joomlalinks.article_resolve_alias', 1)) {
|
||||
// get itemid
|
||||
preg_match('#Itemid=([\d]+)#', $url, $matches);
|
||||
// get link from menu
|
||||
if (count($matches) > 1) {
|
||||
$menu = JTable::getInstance('menu');
|
||||
$menu->load($matches[1]);
|
||||
|
||||
if ($menu->link) {
|
||||
return $menu->link . '&Itemid=' . $menu->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private function getArticles($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$case = '';
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.article_alias', 1)) {
|
||||
//sqlsrv changes
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $a_id . ' END as slug';
|
||||
|
||||
$case_when2 = ' CASE WHEN ';
|
||||
$case_when2 .= $query->charLength('b.alias', '!=', '0');
|
||||
$case_when2 .= ' THEN ';
|
||||
$c_id = $query->castAsChar('b.id');
|
||||
$case_when2 .= $query->concatenate(array($c_id, 'b.alias'), ':');
|
||||
$case_when2 .= ' ELSE ';
|
||||
$case_when2 .= $c_id . ' END as catslug';
|
||||
|
||||
$case = ',' . $case_when1 . ',' . $case_when2;
|
||||
}
|
||||
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
|
||||
$query->select('a.id AS slug, b.id AS catslug, a.alias, a.state, a.title AS title, a.access, ' . $query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS content, a.language' . $case);
|
||||
$query->from('#__content AS a');
|
||||
$query->innerJoin('#__categories AS b ON b.id = ' . (int) $id);
|
||||
|
||||
$query->where('a.catid = ' . (int) $id);
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.article_unpublished', 0) == 1) {
|
||||
$query->where('(a.state = 0 OR a.state = 1)');
|
||||
} else {
|
||||
$query->where('a.state = 1');
|
||||
}
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
$query->where('b.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function getAnchors($content)
|
||||
{
|
||||
preg_match_all('#<a([^>]+)(name|id)="([a-z]+[\w\-\:\.]*)"([^>]*)>#i', $content, $matches, PREG_SET_ORDER);
|
||||
|
||||
$anchors = array();
|
||||
|
||||
if (!empty($matches)) {
|
||||
foreach ($matches as $match) {
|
||||
if (strpos($match[0], 'href') === false) {
|
||||
$anchors[] = $match[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $anchors;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid if set
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
.unpublished .uk-icon::before{content:"\e99d"}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
347
components/com_jce/editor/extensions/links/joomlalinks/menu.php
Normal file
347
components/com_jce/editor/extensions/links/joomlalinks/menu.php
Normal file
@@ -0,0 +1,347 @@
|
||||
<?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 JoomlalinksMenu extends JObject
|
||||
{
|
||||
private $option = 'com_menu';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_menu" class="folder menu nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_MENU') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
switch ($view) {
|
||||
// create top-level (non-linkable) menu types
|
||||
default:
|
||||
$types = self::getMenuTypes();
|
||||
foreach ($types as $type) {
|
||||
$items[] = array(
|
||||
'id' => 'index.php?option=com_menu&view=menu&type=' . $type->id,
|
||||
'name' => $type->title,
|
||||
'class' => 'folder menu nolink',
|
||||
);
|
||||
}
|
||||
break;
|
||||
// get menus and sub-menus
|
||||
case 'menu':
|
||||
$type = isset($args->type) ? $args->type : 0;
|
||||
$id = $type ? 0 : $args->id;
|
||||
|
||||
$menus = self::getMenu($id, $type);
|
||||
|
||||
foreach ($menus as $menu) {
|
||||
$class = array();
|
||||
|
||||
// bypass errors in menu parameters syntax
|
||||
try {
|
||||
$params = new JRegistry($menu->params);
|
||||
} catch (Exception $e) {
|
||||
$params = new JRegistry();
|
||||
}
|
||||
|
||||
switch ($menu->type) {
|
||||
case 'separator':
|
||||
if (!$menu->link) {
|
||||
$class[] = 'nolink';
|
||||
}
|
||||
|
||||
$link = '';
|
||||
break;
|
||||
|
||||
case 'alias':
|
||||
// If this is an alias use the item id stored in the parameters to make the link.
|
||||
$link = 'index.php?Itemid=' . $params->get('aliasoptions');
|
||||
break;
|
||||
|
||||
default:
|
||||
// resolve link
|
||||
$link = $this->resolveLink($menu);
|
||||
break;
|
||||
}
|
||||
|
||||
$children = (int) self::getChildren($menu->id);
|
||||
$title = isset($menu->name) ? $menu->name : $menu->title;
|
||||
|
||||
if ($children) {
|
||||
$class = array_merge($class, array('folder', 'menu'));
|
||||
} else {
|
||||
$class[] = 'file';
|
||||
}
|
||||
|
||||
if ($params->get('secure')) {
|
||||
$link = self::toSSL($link);
|
||||
}
|
||||
|
||||
// language
|
||||
if (isset($menu->language)) {
|
||||
$link .= $this->getLangauge($menu->language);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => $children ? 'index.php?option=com_menu&view=menu&id=' . $menu->id : $link,
|
||||
'url' => self::route($link),
|
||||
'name' => $title . ' / ' . $menu->alias,
|
||||
'class' => implode(' ', $class),
|
||||
);
|
||||
}
|
||||
break;
|
||||
// get menu items
|
||||
case 'submenu':
|
||||
$menus = self::getMenu($args->id);
|
||||
foreach ($menus as $menu) {
|
||||
if ($menu->type == 'menulink') {
|
||||
//$menu = AdvlinkMenu::_alias($menu->id);
|
||||
}
|
||||
|
||||
$children = (int) self::getChildren($menu->id);
|
||||
|
||||
$title = isset($menu->name) ? $menu->name : $menu->title;
|
||||
|
||||
// get params
|
||||
$params = new JRegistry($menu->params);
|
||||
|
||||
// resolve link
|
||||
$link = $this->resolveLink($menu);
|
||||
|
||||
// language
|
||||
if (isset($menu->language)) {
|
||||
$link .= $this->getLangauge($menu->language);
|
||||
}
|
||||
|
||||
if ($params->get('secure')) {
|
||||
$link = self::toSSL($link);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => self::route($link),
|
||||
'name' => $title . ' / ' . $menu->alias,
|
||||
'class' => $children ? 'folder menu' : 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert link to SSL.
|
||||
*
|
||||
* @param type $link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function toSSL($link)
|
||||
{
|
||||
if (strcasecmp(substr($link, 0, 4), 'http') && (strpos($link, 'index.php?') !== false)) {
|
||||
$uri = JURI::getInstance();
|
||||
|
||||
// Get prefix
|
||||
$prefix = $uri->toString(array('host', 'port'));
|
||||
|
||||
// trim slashes
|
||||
$link = trim($link, '/');
|
||||
|
||||
// Build the URL.
|
||||
$link = 'https://' . $prefix . '/' . $link;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
private function resolveLink($menu)
|
||||
{
|
||||
// get link from menu object
|
||||
$link = $menu->link;
|
||||
|
||||
// internal link
|
||||
if ($link && strpos($link, 'index.php') === 0) {
|
||||
if ((int) $this->get('menu_resolve_alias', 1)) {
|
||||
// no Itemid
|
||||
if (strpos($link, 'Itemid=') === false) {
|
||||
$link .= '&Itemid=' . $menu->id;
|
||||
}
|
||||
// short link
|
||||
} else {
|
||||
$link = 'index.php?Itemid=' . $menu->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
private static function getMenuTypes()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('*')->from('#__menu_types')->where('client_id = 0')->order('title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function getAlias($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('params')->from('#__menu')->where('id = ' . (int) $id);
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
$params = new JRegistry($db->loadResult());
|
||||
|
||||
$query->clear();
|
||||
$query->select('id, name, link, alias')->from('#__menu')->where(array('published = 1', 'id = ' . (int) $params->get('menu_item')));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$query->order('name');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObject();
|
||||
}
|
||||
|
||||
private static function getChildren($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('COUNT(id)')->from('#__menu')->where(array('published = 1', 'client_id = 0'));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$query->where('parent_id = ' . (int) $id);
|
||||
}
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadResult();
|
||||
}
|
||||
|
||||
private static function getMenu($parent = 0, $type = 0)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('m.*')->from('#__menu AS m');
|
||||
|
||||
if ($type) {
|
||||
$query->innerJoin('#__menu_types AS s ON s.id = ' . (int) $type);
|
||||
$query->where('m.menutype = s.menutype');
|
||||
}
|
||||
|
||||
if ($parent == 0) {
|
||||
$parent = 1;
|
||||
}
|
||||
|
||||
$query->where(array('m.published = 1', 'm.parent_id = ' . (int) $parent));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('m.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
// only site menu items
|
||||
$query->where('m.client_id = 0');
|
||||
|
||||
$query->order('m.lft ASC');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private function getLangauge($language)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$link = '';
|
||||
|
||||
$query->select('a.sef AS sef');
|
||||
$query->select('a.lang_code AS lang_code');
|
||||
$query->from('#__languages AS a');
|
||||
$db->setQuery($query);
|
||||
$langs = $db->loadObjectList();
|
||||
|
||||
foreach ($langs as $lang) {
|
||||
if ($language == $lang->lang_code) {
|
||||
$language = $lang->sef;
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
150
components/com_jce/editor/extensions/links/joomlalinks/tags.php
Normal file
150
components/com_jce/editor/extensions/links/joomlalinks/tags.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?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 JoomlalinksTags extends JObject
|
||||
{
|
||||
private $option = 'com_tags';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_tags" class="folder content nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_TAGS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
require_once JPATH_SITE . '/components/com_tags/helpers/route.php';
|
||||
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
$tags = array();
|
||||
|
||||
if (!isset($args->id)) {
|
||||
$args->id = 1;
|
||||
}
|
||||
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$tags = self::getTags($args->id);
|
||||
|
||||
if (!empty($tags)) {
|
||||
// output article links
|
||||
foreach ($tags as $tag) {
|
||||
if (isset($tag->language)) {
|
||||
$language = $tag->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($tag->slug, 'com_tags.tag', '', $language);
|
||||
$id = $this->route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $tag->title . ' / ' . $tag->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getTags($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('a.id, a.title, a.alias');
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.tag_alias', 1)) {
|
||||
$case_when_item_alias = ' CASE WHEN ';
|
||||
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when_item_alias .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when_item_alias .= ' ELSE ';
|
||||
$case_when_item_alias .= $a_id . ' END as slug';
|
||||
$query->select($case_when_item_alias);
|
||||
}
|
||||
|
||||
$query->from('#__tags AS a');
|
||||
$query->where('a.alias <> ' . $db->quote('root'));
|
||||
$query->where($db->qn('a.published') . ' = 1');
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
if (JLanguageMultilang::isEnabled()) {
|
||||
$tag = JFactory::getLanguage()->getTag();
|
||||
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
|
||||
}
|
||||
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
<?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 JoomlalinksWeblinks extends JObject
|
||||
{
|
||||
private $option = 'com_weblinks';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_weblinks&view=categories" class="folder menu nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_WEBLINKS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
$items = array();
|
||||
|
||||
if (!defined('JPATH_PLATFORM')) {
|
||||
require_once JPATH_SITE . '/includes/application.php';
|
||||
}
|
||||
|
||||
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
|
||||
|
||||
$language = '';
|
||||
|
||||
switch ($args->view) {
|
||||
// Get all WebLink categories
|
||||
default:
|
||||
case 'categories':
|
||||
$categories = WFLinkBrowser::getCategory('com_weblinks', 1, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$url = '';
|
||||
|
||||
if (method_exists('WeblinksHelperRoute', 'getCategoryRoute')) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getCategoryRoute($category->id, $language);
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
}
|
||||
} else {
|
||||
$itemid = WFLinkBrowser::getItemId('com_weblinks', array('categories' => null, 'category' => $category->id));
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id . $itemid;
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder weblink',
|
||||
);
|
||||
}
|
||||
break;
|
||||
// Get all links in the category
|
||||
case 'category':
|
||||
$categories = WFLinkBrowser::getCategory('com_weblinks', $args->id, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
if (count($categories)) {
|
||||
foreach ($categories as $category) {
|
||||
$children = WFLinkBrowser::getCategory('com_weblinks', $category->id, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($children) {
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
} else {
|
||||
if (method_exists('WeblinksHelperRoute', 'getCategoryRoute')) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getCategoryRoute($category->id, $language);
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
}
|
||||
} else {
|
||||
$itemid = WFLinkBrowser::getItemId('com_weblinks', array('categories' => null, 'category' => $category->id));
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id . $itemid;
|
||||
}
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder weblink',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$weblinks = self::getWeblinks($args->id);
|
||||
|
||||
foreach ($weblinks as $weblink) {
|
||||
// language
|
||||
if (isset($weblink->language)) {
|
||||
$language = $weblink->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getWeblinkRoute($weblink->slug, $weblink->catslug, $language);
|
||||
|
||||
if (defined('JPATH_PLATFORM')) {
|
||||
$id .= '&task=weblink.go';
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => self::route($id),
|
||||
'name' => $weblink->title . ' / ' . $weblink->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getWeblinks($id)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$dbquery = $db->getQuery(true);
|
||||
|
||||
$section = JText::_('Web Links');
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$case = '';
|
||||
|
||||
if ((int) $wf->getParam('links.joomlalinks.weblinks_alias', 1)) {
|
||||
//sqlsrv changes
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $dbquery->charLength('a.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$a_id = $dbquery->castAsChar('a.id');
|
||||
$case_when1 .= $dbquery->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $a_id . ' END as slug';
|
||||
|
||||
$case_when2 = ' CASE WHEN ';
|
||||
$case_when2 .= $dbquery->charLength('b.alias', '!=', '0');
|
||||
$case_when2 .= ' THEN ';
|
||||
$c_id = $dbquery->castAsChar('b.id');
|
||||
$case_when2 .= $dbquery->concatenate(array($c_id, 'b.alias'), ':');
|
||||
$case_when2 .= ' ELSE ';
|
||||
$case_when2 .= $c_id . ' END as catslug';
|
||||
|
||||
$case .= ',' . $case_when1 . ',' . $case_when2;
|
||||
}
|
||||
|
||||
$query->select('a.id AS slug, b.id AS catslug, a.title AS title, a.description AS text, a.url, a.alias, a.language' . $case);
|
||||
|
||||
$query->from('#__weblinks AS a');
|
||||
$query->innerJoin('#__categories AS b ON b.id = ' . (int) $id);
|
||||
$query->where('a.catid = ' . (int) $id);
|
||||
|
||||
$query->where('a.state = 1');
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('b.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$query->where('b.published = 1');
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
1
components/com_jce/editor/extensions/popups/index.html
Normal file
1
components/com_jce/editor/extensions/popups/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
63
components/com_jce/editor/extensions/popups/jcemediabox.php
Normal file
63
components/com_jce/editor/extensions/popups/jcemediabox.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
|
||||
class WFPopupsExtension_Jcemediabox
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (self::isEnabled()) {
|
||||
$scripts = array();
|
||||
|
||||
$document = WFDocument::getInstance();
|
||||
|
||||
$document->addScript('jcemediabox', 'extensions/popups/jcemediabox/js');
|
||||
$document->addStyleSheet('jcemediabox', 'extensions/popups/jcemediabox/css');
|
||||
}
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
return array(
|
||||
'width' => 600,
|
||||
'album' => '#jcemediabox_popup_group',
|
||||
'multiple' => '#jcemediabox_popup_title,#jcemediabox_popup_caption',
|
||||
'attribute' => $wf->getParam('popups.jcemediabox.attribute', 'data-mediabox'),
|
||||
'popup_group' => $wf->getParam('popups.jcemediabox.popup_group', ''),
|
||||
'popup_icon' => $wf->getParam('popups.jcemediabox.popup_icon', 1),
|
||||
'popup_icon_position' => $wf->getParam('popups.jcemediabox.popup_icon_position', ''),
|
||||
'popup_autopopup' => $wf->getParam('popups.jcemediabox.popup_autopopup', ''),
|
||||
'popup_hide' => $wf->getParam('popups.jcemediabox.popup_hide', 0),
|
||||
'popup_mediatype' => $wf->getParam('popups.jcemediabox.popup_mediatype', ''),
|
||||
);
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((JPluginHelper::isEnabled('system', 'jcemediabox') || JPluginHelper::isEnabled('system', 'wf_lightcase')) && $wf->getParam('popups.jcemediabox.enable', 1) == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkVersion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
74
components/com_jce/editor/extensions/popups/jcemediabox.xml
Normal file
74
components/com_jce/editor/extensions/popups/jcemediabox.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_POPUPS_JCEMEDIABOX_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_POPUPS_JCEMEDIABOX_DESC</description>
|
||||
<files>
|
||||
<file>jcemediabox.php</file>
|
||||
<folder>jcemediabox</folder>
|
||||
</files>
|
||||
<fields name="jcemediabox">
|
||||
<fieldset name="jcemediabox">
|
||||
<field name="enable" type="yesno" default="1" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="popup_group" type="text" default="" label="WF_POPUPS_JCEMEDIABOX_GROUP" description="WF_POPUPS_JCEMEDIABOX_GROUP_DESC" />
|
||||
|
||||
<field name="popup_icon" type="yesno" default="1" label="WF_POPUPS_JCEMEDIABOX_ICON" description="WF_POPUPS_JCEMEDIABOX_ICON_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="popup_icon_position" type="list" default="" label="WF_POPUPS_JCEMEDIABOX_ICON_POSITION" description="WF_POPUPS_JCEMEDIABOX_ICON_POSITION_DESC">
|
||||
<option value="">WF_OPTION_NOT_SET</option>
|
||||
<option value="icon-left">WF_OPTION_LEFT</option>
|
||||
<option value="icon-right">WF_OPTION_RIGHT</option>
|
||||
<option value="icon-top-left">WF_OPTION_TOP_LEFT</option>
|
||||
<option value="icon-top-right">WF_OPTION_TOP_RIGHT</option>
|
||||
<option value="icon-bottom-left">WF_OPTION_BOTTOM_LEFT</option>
|
||||
<option value="icon-bottom-right">WF_OPTION_BOTTOM_RIGHT</option>
|
||||
</field>
|
||||
|
||||
<field name="popup_autopopup" type="list" default="" label="WF_POPUPS_JCEMEDIABOX_AUTO" description="WF_POPUPS_JCEMEDIABOX_AUTO_DESC">
|
||||
<option value="">WF_OPTION_NOT_SET</option>
|
||||
<option value="autopopup-single">WF_POPUPS_JCEMEDIABOX_AUTO_SINGLE</option>
|
||||
<option value="autopopup-multiple">WF_POPUPS_JCEMEDIABOX_AUTO_MULTIPLE</option>
|
||||
</field>
|
||||
|
||||
<field name="popup_hide" type="yesno" default="0" label="WF_POPUPS_JCEMEDIABOX_HIDE" description="WF_POPUPS_JCEMEDIABOX_HIDE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="popup_mediatype" type="list" default="" label="WF_POPUPS_JCEMEDIABOX_MEDIATYPE" description="WF_POPUPS_JCEMEDIABOX_MEDIATYPE_DESC">
|
||||
<option value="">WF_OPTION_NOT_SET</option>
|
||||
<option value="text/html">WF_POPUPS_JCEMEDIABOX_INTERNAL</option>
|
||||
<option value="iframe">WF_POPUPS_JCEMEDIABOX_EXTERNAL</option>
|
||||
<option value="image">WF_POPUPS_JCEMEDIABOX_IMAGE</option>
|
||||
<option value="application/x-shockwave-flash">WF_POPUPS_JCEMEDIABOX_FLASH</option>
|
||||
<option value="video/quicktime">WF_POPUPS_JCEMEDIABOX_QUICKTIME</option>
|
||||
<option value="application/x-mplayer2">WF_POPUPS_JCEMEDIABOX_WINDOWSMEDIA</option>
|
||||
<option value="video/divx">WF_POPUPS_JCEMEDIABOX_DIVX</option>
|
||||
<option value="application/x-director">WF_POPUPS_JCEMEDIABOX_DIRECTOR</option>
|
||||
<option value="audio/x-pn-realaudio-plugin">WF_POPUPS_JCEMEDIABOX_REAL</option>
|
||||
<option value="video/mp4">WF_POPUPS_JCEMEDIABOX_VIDEO_MP4</option>
|
||||
<option value="audio/mp3">WF_POPUPS_JCEMEDIABOX_AUDIO_MP3</option>
|
||||
<option value="video/webm">WF_POPUPS_JCEMEDIABOX_VIDEO_WEBM</option>
|
||||
<option value="audio/webm">WF_POPUPS_JCEMEDIABOX_AUDIO_WEBM</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
<media></media>
|
||||
<plugins>link,imgmanager_ext,mediamanager,filemanager</plugins>
|
||||
<languages></languages>
|
||||
</extension>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
#jcemediabox_popup_height,#jcemediabox_popup_width{width:65px}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,151 @@
|
||||
<?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('_WF_EXT') or die('RESTRICTED');
|
||||
|
||||
?>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_title" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_OPTION_TITLE_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_OPTION_TITLE'); ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<input id="jcemediabox_popup_title" class="uk-input-multiple" type="text" class="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_caption" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_CAPTION_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_CAPTION'); ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<input id="jcemediabox_popup_caption" class="uk-input-multiple" type="text" class="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_group" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_GROUP_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_GROUP'); ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<input id="jcemediabox_popup_group" type="text" class="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label class="hastip uk-form-label uk-width-1-5" title="<?php echo JText::_('WF_LABEL_DIMENSIONS_DESC'); ?>">
|
||||
<?php echo JText::_('WF_LABEL_DIMENSIONS'); ?>
|
||||
</label>
|
||||
<div class="uk-form-controls uk-grid uk-grid-collapse uk-width-4-5 uk-form-constrain">
|
||||
|
||||
<div class="uk-form-controls">
|
||||
<input type="text" id="jcemediabox_popup_width" value="" class="uk-text-center" />
|
||||
</div>
|
||||
|
||||
<div class="uk-form-controls">
|
||||
<strong class="uk-form-label uk-text-center uk-vertical-align-middle">×</strong>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-controls">
|
||||
<input type="text" id="jcemediabox_popup_height" value="" class="uk-text-center" />
|
||||
</div>
|
||||
|
||||
<label class="uk-form-label">
|
||||
<input class="uk-constrain-checkbox" type="checkbox" checked />
|
||||
<?php echo JText::_('WF_LABEL_PROPORTIONAL'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_icon" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_ICON_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_ICON'); ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<div class="uk-width-1-5">
|
||||
<select id="jcemediabox_popup_icon">
|
||||
<option value="0"><?php echo JText::_('JNO'); ?></option>
|
||||
<option value="1" selected="selected"><?php echo JText::_('JYES'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="uk-width-3-5 uk-margin-left">
|
||||
<label for="jcemediabox_popup_icon_position" class="uk-form-label uk-width-2-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_ICON_POSITION_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_ICON_POSITION'); ?></label>
|
||||
<div class="uk-form-controls uk-width-3-5">
|
||||
<select id="jcemediabox_popup_icon_position">
|
||||
<option value=""><?php echo JText::_('WF_OPTION_NOT_SET'); ?></option>
|
||||
<option value="zoom-left"><?php echo JText::_('WF_OPTION_LEFT'); ?></option>
|
||||
<option value="zoom-right"><?php echo JText::_('WF_OPTION_RIGHT'); ?></option>
|
||||
<option value="zoom-top-left"><?php echo JText::_('WF_OPTION_TOP_LEFT'); ?></option>
|
||||
<option value="zoom-top-right"><?php echo JText::_('WF_OPTION_TOP_RIGHT'); ?></option>
|
||||
<option value="zoom-bottom-left"><?php echo JText::_('WF_OPTION_BOTTOM_LEFT'); ?></option>
|
||||
<option value="zoom-bottom-right"><?php echo JText::_('WF_OPTION_BOTTOM_RIGHT'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_hide" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_HIDE_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_HIDE'); ?></label>
|
||||
<div class="uk-form-controls uk-width-4-5">
|
||||
<div class="uk-width-1-5">
|
||||
<select id="jcemediabox_popup_hide">
|
||||
<option value="0"><?php echo JText::_('JNO'); ?></option>
|
||||
<option value="1"><?php echo JText::_('JYES'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="uk-width-3-5 uk-margin-left">
|
||||
<label for="jcemediabox_popup_autopopup" class="uk-form-label uk-width-2-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUTO_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUTO'); ?></label>
|
||||
<div class="uk-form-controls uk-width-3-5">
|
||||
<select id="jcemediabox_popup_autopopup">
|
||||
<option value=""><?php echo JText::_('WF_OPTION_NOT_SET'); ?></option>
|
||||
<option value="autopopup-single"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUTO_SINGLE'); ?></option>
|
||||
<option value="autopopup-multiple"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUTO_MULTIPLE'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_mediatype" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_MEDIATYPE_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_MEDIATYPE'); ?></label>
|
||||
<div class="uk-form-controls uk-width-2-5">
|
||||
<select id="jcemediabox_popup_mediatype">
|
||||
<option value=""><?php echo JText::_('WF_OPTION_NOT_SET'); ?></option>
|
||||
<option value="text/html"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_INTERNAL'); ?></option>
|
||||
<option value="iframe"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_EXTERNAL'); ?></option>
|
||||
<option value="image"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_IMAGE'); ?></option>
|
||||
<option value="video/youtube"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_YOUTUBE'); ?></option>
|
||||
<option value="video/vimeo"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_VIMEO'); ?></option>
|
||||
<option value="application/x-shockwave-flash"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_FLASH'); ?></option>
|
||||
<option value="video/quicktime"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_QUICKTIME'); ?></option>
|
||||
<option value="application/x-mplayer2"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_WINDOWSMEDIA'); ?></option>
|
||||
<option value="video/divx"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_DIVX'); ?></option>
|
||||
<option value="application/x-director"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_DIRECTOR'); ?></option>
|
||||
<option value="audio/x-pn-realaudio-plugin"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_REAL'); ?></option>
|
||||
<option value="video/mp4"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_VIDEO_MP4'); ?></option>
|
||||
<option value="audio/mp3"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUDIO_MP3'); ?></option>
|
||||
<option value="video/webm"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_VIDEO_WEBM'); ?></option>
|
||||
<option value="audio/webm"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_AUDIO_WEBM'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-row uk-grid uk-grid-small">
|
||||
<label for="jcemediabox_popup_params" class="uk-form-label uk-width-1-5 hastip" title="<?php echo JText::_('WF_POPUPS_JCEMEDIABOX_PARAMS_DESC'); ?>"><?php echo JText::_('WF_POPUPS_JCEMEDIABOX_PARAMS'); ?></label>
|
||||
<div class="uk-width-4-5" id="jcemediabox_popup_params">
|
||||
<div class="uk-form-row uk-repeatable">
|
||||
<div class="uk-form-controls uk-grid uk-grid-small uk-width-9-10">
|
||||
<label class="uk-form-label uk-width-1-6"><?php echo JText::_('WF_LABEL_NAME'); ?></label>
|
||||
<div class="uk-form-controls uk-width-1-3">
|
||||
<input type="text" name="jcemediabox_popup_params_name[]" />
|
||||
</div>
|
||||
<label class="uk-form-label uk-width-1-6"><?php echo JText::_('WF_LABEL_VALUE'); ?></label>
|
||||
<div class="uk-form-controls uk-width-1-3">
|
||||
<input type="text" name="jcemediabox_popup_params_value[]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-form-controls uk-margin-small-left">
|
||||
<button class="uk-button uk-button-link uk-repeatable-create" aria-label="<?php echo JText::_('WF_LABEL_ADD'); ?>" title="<?php echo JText::_('WF_LABEL_ADD'); ?>"><i class="uk-icon-plus"></i></button>
|
||||
<button class="uk-button uk-button-link uk-repeatable-delete" aria-label="<?php echo JText::_('WF_LABEL_REMOVE'); ?>" title="<?php echo JText::_('WF_LABEL_REMOVE'); ?>"><i class="uk-icon-trash"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,135 @@
|
||||
<?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
|
||||
*
|
||||
* Adapted from the Joomla Search.categories plugin - plugins/search/categories/categories.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Categories search plugin.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class PlgWfSearchCategories extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Determine areas searchable by this plugin.
|
||||
*
|
||||
* @return array An array of search areas.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function onContentSearchAreas()
|
||||
{
|
||||
static $areas = array(
|
||||
'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES',
|
||||
);
|
||||
|
||||
return $areas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search content (categories).
|
||||
*
|
||||
* The SQL must return the following fields that are used in a common display
|
||||
* routine: href, title, section, created, text, browsernav.
|
||||
*
|
||||
* @param string $text Target search string.
|
||||
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
|
||||
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
|
||||
* @param mixed $areas An array if the search is to be restricted to areas or null to search all areas.
|
||||
*
|
||||
* @return array Search results.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$user = JFactory::getUser();
|
||||
$app = JFactory::getApplication();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$searchText = $text;
|
||||
|
||||
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$limit = $this->params->def('search_limit', 50);
|
||||
$text = trim($text);
|
||||
|
||||
if ($text === '') {
|
||||
return array();
|
||||
}
|
||||
|
||||
switch ($ordering) {
|
||||
case 'alpha':
|
||||
$order = 'a.title ASC';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
case 'popular':
|
||||
case 'newest':
|
||||
case 'oldest':
|
||||
default:
|
||||
$order = 'a.title DESC';
|
||||
}
|
||||
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// SQLSRV changes.
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $a_id . ' END as slug';
|
||||
|
||||
$query->select('a.title, a.description AS text, a.id AS catid, a.created_time, a.language, ' . $case_when);
|
||||
$query->from('#__categories AS a');
|
||||
$query->where(
|
||||
'(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published = 1 AND a.extension = '
|
||||
. $db->quote('com_content') . 'AND a.access IN (' . $groups . ')'
|
||||
);
|
||||
|
||||
$query->group('a.id, a.title, a.description, a.alias, a.created_time');
|
||||
$query->order($order);
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
try
|
||||
{
|
||||
$rows = $db->loadObjectList();
|
||||
} catch (RuntimeException $e) {
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
|
||||
}
|
||||
|
||||
if ($rows) {
|
||||
foreach ($rows as $i => $row) {
|
||||
$rows[$i]->href = JHelperRoute::getCategoryRoute($row->slug, $row->language, 'com_content');
|
||||
$rows[$i]->section = JText::_('JCATEGORY');
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,166 @@
|
||||
<?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
|
||||
*
|
||||
* Adapted from the Joomla Search.contacts plugin - plugins/search/contacts/contacts.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Contacts search plugin.
|
||||
*/
|
||||
class PlgWfSearchContacts extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Determine areas searchable by this plugin.
|
||||
*
|
||||
* @return array An array of search areas.
|
||||
*/
|
||||
public function onContentSearchAreas()
|
||||
{
|
||||
static $areas = array(
|
||||
'contacts' => 'PLG_SEARCH_CONTACTS_CONTACTS'
|
||||
);
|
||||
|
||||
return $areas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search content (contacts).
|
||||
*
|
||||
* The SQL must return the following fields that are used in a common display
|
||||
* routine: href, title, section, created, text, browsernav.
|
||||
*
|
||||
* @param string $text Target search string.
|
||||
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
|
||||
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
|
||||
* @param string $areas An array if the search is to be restricted to areas or null to search all areas.
|
||||
*
|
||||
* @return array Search results.
|
||||
*/
|
||||
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$limit = $this->params->def('search_limit', 50);
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if ($text === '')
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$section = JText::_('PLG_SEARCH_CONTACTS_CONTACTS');
|
||||
|
||||
switch ($ordering)
|
||||
{
|
||||
case 'alpha':
|
||||
$order = 'a.name ASC';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$order = 'c.title ASC, a.name ASC';
|
||||
break;
|
||||
|
||||
case 'popular':
|
||||
case 'newest':
|
||||
case 'oldest':
|
||||
default:
|
||||
$order = 'a.name DESC';
|
||||
}
|
||||
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// SQLSRV changes.
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $a_id . ' END as slug';
|
||||
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $query->charLength('c.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$c_id = $query->castAsChar('c.id');
|
||||
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $c_id . ' END as catslug';
|
||||
|
||||
$query->select(
|
||||
'a.name AS title, a.con_position, a.misc, a.language, '
|
||||
. $case_when . ',' . $case_when1 . ', '
|
||||
. $query->concatenate(array('a.name', 'a.con_position', 'a.misc'), ',') . ' AS text'
|
||||
);
|
||||
$query->from('#__contact_details AS a')
|
||||
->join('INNER', '#__categories AS c ON c.id = a.catid')
|
||||
->where(
|
||||
'(a.name LIKE ' . $text . ' OR a.misc LIKE ' . $text . ' OR a.con_position LIKE ' . $text
|
||||
. ' OR a.address LIKE ' . $text . ' OR a.suburb LIKE ' . $text . ' OR a.state LIKE ' . $text
|
||||
. ' OR a.country LIKE ' . $text . ' OR a.postcode LIKE ' . $text . ' OR a.telephone LIKE ' . $text
|
||||
. ' OR a.fax LIKE ' . $text . ') AND a.published = 1 AND c.published = 1 '
|
||||
. ' AND a.access IN (' . $groups . ') AND c.access IN (' . $groups . ')'
|
||||
)
|
||||
->order($order);
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
try
|
||||
{
|
||||
$rows = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$rows = array();
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
|
||||
}
|
||||
|
||||
if ($rows)
|
||||
{
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
foreach ($rows as $key => $row)
|
||||
{
|
||||
$rows[$key]->href = $router->getRoute($row->slug, 'com_contact.contact', '', $row->language, $row->catslug);
|
||||
$rows[$key]->text = $row->title;
|
||||
$rows[$key]->text .= $row->con_position ? ', ' . $row->con_position : '';
|
||||
$rows[$key]->text .= $row->misc ? ', ' . $row->misc : '';
|
||||
|
||||
$rows[$key]->section = $section;
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,201 @@
|
||||
<?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
|
||||
*
|
||||
* Adapted from the Joomla Search.content plugin - plugins/search/content/content.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Content search plugin.
|
||||
*
|
||||
*/
|
||||
class PlgWfSearchContent extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Determine areas searchable by this plugin.
|
||||
*
|
||||
* @return array An array of search areas.
|
||||
*
|
||||
*/
|
||||
public function onContentSearchAreas()
|
||||
{
|
||||
static $areas = array(
|
||||
'content' => 'JGLOBAL_ARTICLES',
|
||||
);
|
||||
|
||||
return $areas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search content (articles).
|
||||
* The SQL must return the following fields that are used in a common display
|
||||
* routine: href, title, section, created, text, browsernav.
|
||||
*
|
||||
* @param string $text Target search string.
|
||||
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
|
||||
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
|
||||
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
|
||||
*
|
||||
* @return array Search results.
|
||||
*
|
||||
*/
|
||||
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$serverType = $db->getServerType();
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$tag = JFactory::getLanguage()->getTag();
|
||||
|
||||
$searchText = $text;
|
||||
|
||||
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$limit = $this->params->def('search_limit', 50);
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$date = JFactory::getDate();
|
||||
$now = $date->toSql();
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if ($text === '') {
|
||||
return array();
|
||||
}
|
||||
|
||||
$relevance = array();
|
||||
|
||||
switch ($phrase) {
|
||||
case 'exact':
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
$wheres2 = array();
|
||||
$wheres2[] = 'a.title LIKE ' . $text;
|
||||
$wheres2[] = 'a.introtext LIKE ' . $text;
|
||||
$wheres2[] = 'a.fulltext LIKE ' . $text;
|
||||
|
||||
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
|
||||
|
||||
$where = '(' . implode(') OR (', $wheres2) . ')';
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
case 'any':
|
||||
default:
|
||||
$words = explode(' ', $text);
|
||||
$wheres = array();
|
||||
|
||||
foreach ($words as $word) {
|
||||
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
|
||||
$wheres2 = array();
|
||||
$wheres2[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
|
||||
$wheres2[] = 'LOWER(a.introtext) LIKE LOWER(' . $word . ')';
|
||||
$wheres2[] = 'LOWER(a.fulltext) LIKE LOWER(' . $word . ')';
|
||||
|
||||
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
|
||||
|
||||
$wheres[] = implode(' OR ', $wheres2);
|
||||
}
|
||||
|
||||
$where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($ordering) {
|
||||
case 'oldest':
|
||||
$order = 'a.created ASC';
|
||||
break;
|
||||
|
||||
case 'popular':
|
||||
$order = 'a.hits DESC';
|
||||
break;
|
||||
|
||||
case 'alpha':
|
||||
$order = 'a.title ASC';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$order = 'c.title ASC, a.title ASC';
|
||||
break;
|
||||
|
||||
case 'newest':
|
||||
default:
|
||||
$order = 'a.created DESC';
|
||||
break;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Search articles.
|
||||
if ($limit > 0) {
|
||||
//sqlsrv changes
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $a_id . ' END as slug';
|
||||
|
||||
$case_when2 = ' CASE WHEN ';
|
||||
$case_when2 .= $query->charLength('b.alias', '!=', '0');
|
||||
$case_when2 .= ' THEN ';
|
||||
$c_id = $query->castAsChar('b.id');
|
||||
$case_when2 .= $query->concatenate(array($c_id, 'b.alias'), ':');
|
||||
$case_when2 .= ' ELSE ';
|
||||
$case_when2 .= $c_id . ' END as catslug';
|
||||
|
||||
$case = ',' . $case_when1 . ',' . $case_when2;
|
||||
|
||||
if (!empty($relevance)) {
|
||||
$query->select(implode(' + ', $relevance) . ' AS relevance');
|
||||
$order = ' relevance DESC, ' . $order;
|
||||
}
|
||||
|
||||
$query->select('a.id AS slug, b.id AS catslug, a.alias, a.state, a.title AS title, a.access, ' . $query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text, a.language' . $case);
|
||||
$query->from('#__content AS a');
|
||||
$query->innerJoin('#__categories AS b ON b.id = a.catid');
|
||||
$query->where('(' . $where . ') AND a.state = 1 AND b.published = 1');
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
$query->where('b.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
$query->order($order);
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
try
|
||||
{
|
||||
$rows = $db->loadObjectList();
|
||||
} catch (RuntimeException $e) {
|
||||
$rows = array();
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
|
||||
}
|
||||
|
||||
if ($rows) {
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
foreach ($rows as $key => $row) {
|
||||
$rows[$key]->href = $router->getRoute($row->slug, 'com_content.article', '', $row->language, $row->catslug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,160 @@
|
||||
<?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
|
||||
*
|
||||
* Adapted from the Joomla Search.tags plugin - plugins/search/tags/tags.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Tags search plugin.
|
||||
*
|
||||
*/
|
||||
class PlgWfSearchTags extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Determine areas searchable by this plugin.
|
||||
*
|
||||
* @return array An array of search areas.
|
||||
*
|
||||
*/
|
||||
public function onContentSearchAreas()
|
||||
{
|
||||
static $areas = array(
|
||||
'tags' => 'PLG_SEARCH_TAGS_TAGS'
|
||||
);
|
||||
|
||||
return $areas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search content (tags).
|
||||
*
|
||||
* The SQL must return the following fields that are used in a common display
|
||||
* routine: href, title, section, created, text, browsernav.
|
||||
*
|
||||
* @param string $text Target search string.
|
||||
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
|
||||
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
|
||||
* @param string $areas An array if the search is to be restricted to areas or null to search all areas.
|
||||
*
|
||||
* @return array Search results.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
$section = JText::_('PLG_SEARCH_TAGS_TAGS');
|
||||
$limit = $this->params->def('search_limit', 50);
|
||||
|
||||
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if ($text === '')
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
|
||||
switch ($ordering)
|
||||
{
|
||||
case 'alpha':
|
||||
$order = 'a.title ASC';
|
||||
break;
|
||||
|
||||
case 'newest':
|
||||
$order = 'a.created_time DESC';
|
||||
break;
|
||||
|
||||
case 'oldest':
|
||||
$order = 'a.created_time ASC';
|
||||
break;
|
||||
|
||||
case 'popular':
|
||||
default:
|
||||
$order = 'a.title DESC';
|
||||
}
|
||||
|
||||
$query->select('a.id, a.title, a.alias, a.note, a.published, a.access'
|
||||
. ', a.checked_out, a.checked_out_time, a.created_user_id'
|
||||
. ', a.path, a.parent_id, a.level, a.lft, a.rgt'
|
||||
. ', a.language, a.created_time AS created, a.description');
|
||||
|
||||
$case_when_item_alias = ' CASE WHEN ';
|
||||
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when_item_alias .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when_item_alias .= ' ELSE ';
|
||||
$case_when_item_alias .= $a_id . ' END as slug';
|
||||
$query->select($case_when_item_alias);
|
||||
|
||||
$query->from('#__tags AS a');
|
||||
$query->where('a.alias <> ' . $db->quote('root'));
|
||||
|
||||
$query->where('(a.title LIKE ' . $text . ' OR a.alias LIKE ' . $text . ')');
|
||||
|
||||
$query->where($db->qn('a.published') . ' = 1');
|
||||
|
||||
if (!$user->authorise('core.admin'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
$query->order($order);
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
try
|
||||
{
|
||||
$rows = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$rows = array();
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
|
||||
}
|
||||
|
||||
if ($rows)
|
||||
{
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
foreach ($rows as $key => $row)
|
||||
{
|
||||
$rows[$key]->href = $router->getRoute($row->slug, 'com_tags.tag', '', $row->language);
|
||||
$rows[$key]->text = ($row->description !== '' ? $row->description : $row->title);
|
||||
$rows[$key]->text .= $row->note;
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1,179 @@
|
||||
<?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
|
||||
*
|
||||
* Adapted from the Joomla Search.weblinks plugin - plugins/search/weblinks/weblinks.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*
|
||||
* 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;
|
||||
|
||||
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
|
||||
|
||||
/**
|
||||
* Weblinks search plugin.
|
||||
*
|
||||
*/
|
||||
class PlgWfSearchWeblinks extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Determine areas searchable by this plugin.
|
||||
*
|
||||
* @return array An array of search areas.
|
||||
*
|
||||
*/
|
||||
public function onContentSearchAreas()
|
||||
{
|
||||
static $areas = array(
|
||||
'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS'
|
||||
);
|
||||
|
||||
return $areas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search content (weblinks).
|
||||
*
|
||||
* The SQL must return the following fields that are used in a common display
|
||||
* routine: href, title, section, created, text, browsernav
|
||||
*
|
||||
* @param string $text Target search string.
|
||||
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
|
||||
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
|
||||
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
|
||||
*
|
||||
* @return array Search results.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
|
||||
|
||||
$searchText = $text;
|
||||
|
||||
if (is_array($areas))
|
||||
{
|
||||
if (!array_intersect($areas, array_keys($this->onContentSearchAreas())))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
$limit = $this->params->def('search_limit', 50);
|
||||
$state = array();
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if ($text == '')
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
switch ($phrase)
|
||||
{
|
||||
case 'exact':
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
$wheres2 = array();
|
||||
$wheres2[] = 'a.url LIKE ' . $text;
|
||||
$wheres2[] = 'a.description LIKE ' . $text;
|
||||
$wheres2[] = 'a.title LIKE ' . $text;
|
||||
$where = '(' . implode(') OR (', $wheres2) . ')';
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
case 'any':
|
||||
default:
|
||||
$words = explode(' ', $text);
|
||||
$wheres = array();
|
||||
|
||||
foreach ($words as $word)
|
||||
{
|
||||
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
|
||||
$wheres2 = array();
|
||||
$wheres2[] = 'a.url LIKE ' . $word;
|
||||
$wheres2[] = 'a.description LIKE ' . $word;
|
||||
$wheres2[] = 'a.title LIKE ' . $word;
|
||||
$wheres[] = implode(' OR ', $wheres2);
|
||||
}
|
||||
|
||||
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($ordering)
|
||||
{
|
||||
case 'oldest':
|
||||
$order = 'a.created ASC';
|
||||
break;
|
||||
|
||||
case 'popular':
|
||||
$order = 'a.hits DESC';
|
||||
break;
|
||||
|
||||
case 'alpha':
|
||||
$order = 'a.title ASC';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$order = 'c.title ASC, a.title ASC';
|
||||
break;
|
||||
|
||||
case 'newest':
|
||||
default:
|
||||
$order = 'a.created DESC';
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// SQLSRV changes.
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $a_id . ' END as slug';
|
||||
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $query->charLength('c.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$c_id = $query->castAsChar('c.id');
|
||||
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $c_id . ' END as catslug';
|
||||
|
||||
$query->select('a.title AS title, a.created AS created, a.url, a.description AS text, a.language, ' . $case_when . "," . $case_when1)
|
||||
->from('#__weblinks AS a')
|
||||
->join('INNER', '#__categories as c ON c.id = a.catid')
|
||||
->where('(' . $where . ') AND a.state = 1 AND c.published = 1 AND c.access IN (' . $groups . ')')
|
||||
->order($order);
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
if ($rows)
|
||||
{
|
||||
foreach ($rows as $key => $row)
|
||||
{
|
||||
$rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug, $row->language);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
1
components/com_jce/editor/extensions/search/css/link.css
Normal file
1
components/com_jce/editor/extensions/search/css/link.css
Normal file
@@ -0,0 +1 @@
|
||||
#search-browser,#searchbox{position:relative}#search-browser button{padding:0 .5em}#search-browser button .uk-icon{margin:auto}#searchbox{z-index:1}div#search-browser input[type=checkbox],div#search-browser input[type=radio]{vertical-align:middle}.phrases-box input[type=radio]{margin:-3px 5px 0 0}#searchbox input{border-top-right-radius:0;border-bottom-right-radius:0;margin:0}#searchbox+div{margin-left:-1px;padding:0}#search-button{border-top-left-radius:0;border-bottom-left-radius:0}#search-clear{display:none}#search-clear.uk-active{display:block}#search-browser .uk-icon-spinner{display:none;right:0}#search-browser.loading .uk-icon-spinner{display:block;opacity:1}#search-result{width:100%;height:100%;position:absolute;display:none;overflow:auto;overflow-x:hidden;margin:2px 0}#search-result dl{margin:5px 0;padding:10px}#search-result dl dt{cursor:pointer;font-weight:700;text-overflow:ellipsis;overflow:hidden;white-space:pre;text-decoration:underline}div#search-browser div#search-result dl.odd{background-color:#F5F5F5}div#search-browser div#search-result dl dd.anchor{line-height:32px;cursor:pointer}div#search-browser #search-options{width:100%;padding:5px;margin:2px 0 0}div#search-browser #search-options fieldset{margin:0;padding:0}div#search-browser #search-options fieldset>div{margin:5px 0}div#search-browser #search-options label{min-width:40px}#search-options-button{line-height:1}#search-options .search_only ul{list-style:none;padding:0;margin:0}#search-options .search_only ul li{display:inline-block}@media (max-width:375px){#search-button span{display:none}}
|
||||
1
components/com_jce/editor/extensions/search/index.html
Normal file
1
components/com_jce/editor/extensions/search/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
2
components/com_jce/editor/extensions/search/js/link.js
Normal file
2
components/com_jce/editor/extensions/search/js/link.js
Normal 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 */
|
||||
var WFLinkSearch=WFExtensions.add("LinkSearch",{options:{element:"#search-input",button:"#search-button",clear:"#search-clear",empty:"No Results",onClick:$.noop},init:function(options){$.extend(this.options,options);var self=this,el=this.options.element,btn=this.options.button;$(btn).on("click",function(e){self.search(),e.preventDefault()}).button({icons:{primary:"uk-icon-search"}}),$("#search-clear").on("click",function(e){$(this).hasClass("uk-active")&&($(this).removeClass("uk-active"),$(el).val(""),$("#search-result").empty().hide())}),$("#search-options-button").on("click",function(e){e.preventDefault(),$(this).addClass("uk-active");var $p=$("#search-options").parent();$("#search-options").height($p.parent().height()-$p.outerHeight()-15).toggle()}).on("close",function(){$(this).removeClass("uk-active"),$("#search-options").hide()}),$(el).on("change keyup",function(){""===this.value&&($("#search-result").empty().hide(),$("#search-clear").removeClass("uk-active"))})},search:function(){var self=this,s=this.options,el=s.element,$p=(s.button,$("#search-result").parent()),query=$(el).val();query&&!$(el).hasClass("placeholder")&&($("#search-clear").removeClass("uk-active"),$("#search-browser").addClass("loading"),query=$.trim(query.replace(/[\///<>#]/g,"")),Wf.JSON.request("doSearch",{json:[query]},function(results){if(results){if(results.error)return void Wf.Dialog.alert(results.error);$("#search-result").empty(),results.length?($.each(results,function(i,values){console.log(values),$.each(values,function(name,items){$("<h3>"+name+"</h3>").appendTo("#search-result"),$.each(items,function(i,item){var $dl=$('<dl class="uk-margin-small" />').appendTo("#search-result");$('<dt class="link uk-margin-small" />').text(item.title).on("click",function(){$.isFunction(self.options.onClick)&&self.options.onClick.call(this,Wf.String.decode(item.link))}).prepend('<i class="uk-icon uk-icon-file-text-o uk-margin-small-right" />').appendTo($dl),$('<dd class="text">'+item.text+"</dd>").appendTo($dl),item.anchors&&$.each(item.anchors,function(i,a){$('<dd class="anchor"><i role="presentation" class="uk-icon uk-icon-anchor uk-margin-small-right"></i>#'+a+"</dd>").on("click",function(){self.options.onClick.call(this,Wf.String.decode(item.link)+"#"+a)}).appendTo($dl)})})})}),$("dl:odd","#search-result").addClass("odd")):$("#search-result").append("<p>"+s.empty+"</p>"),$("#search-options-button").trigger("close"),$("#search-result").height($p.parent().height()-$p.outerHeight()-5).show()}$("#search-browser").removeClass("loading"),$("#search-clear").addClass("uk-active")},self))}});
|
||||
459
components/com_jce/editor/extensions/search/link.php
Normal file
459
components/com_jce/editor/extensions/search/link.php
Normal file
@@ -0,0 +1,459 @@
|
||||
<?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;
|
||||
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
class WFLinkSearchExtension extends WFSearchExtension
|
||||
{
|
||||
private $enabled = array();
|
||||
|
||||
protected function loadDefaultAdapter($plugin)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// create component name from plugin - special case for "contacts"
|
||||
$component = ($plugin == 'contacts') ? 'com_contact' : 'com_' . $plugin;
|
||||
|
||||
// check for associated component
|
||||
if (!JComponentHelper::isEnabled($component)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$adapter = __DIR__ . '/adapter/' . $plugin . '/' . $plugin . '.php';
|
||||
|
||||
if (!is_file($adapter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once $adapter;
|
||||
|
||||
// create classname, eg: PlgSearchContent
|
||||
$className = 'PlgWfSearch' . ucfirst($plugin);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// simple plugin config
|
||||
$config = array(
|
||||
'name' => $plugin,
|
||||
'type' => 'search',
|
||||
'params' => array(
|
||||
'search_limit' => 10
|
||||
),
|
||||
);
|
||||
|
||||
// Joomla 4
|
||||
if (method_exists($app, 'getDispatcher')) {
|
||||
$dispatcher = $app->getDispatcher();
|
||||
$instance = new $className($dispatcher, (array) $config);
|
||||
$instance->registerListeners();
|
||||
} else {
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$instance = new $className($dispatcher, (array) $config);
|
||||
}
|
||||
|
||||
$this->enabled[] = $plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$request = WFRequest::getInstance();
|
||||
|
||||
$request->setRequest(array($this, 'doSearch'));
|
||||
$request->setRequest(array($this, 'getAreas'));
|
||||
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
// get plugins
|
||||
$plugins = $wf->getParam('search.link.plugins', array());
|
||||
|
||||
// set defaults if empty
|
||||
if (empty($plugins)) {
|
||||
$plugins = array('categories', 'contacts', 'content', 'tags');
|
||||
}
|
||||
|
||||
// list core adapters
|
||||
$adapters = array('categories', 'contacts', 'content', 'tags', 'weblinks');
|
||||
|
||||
// check and load external search plugins
|
||||
foreach ($plugins as $plugin) {
|
||||
// process core search plugins
|
||||
if (in_array($plugin, $adapters)) {
|
||||
$this->loadDefaultAdapter($plugin);
|
||||
continue;
|
||||
}
|
||||
|
||||
// plugin must be enabled
|
||||
if (!JPluginHelper::isEnabled('search', $plugin)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check plugin imports correctly - plugin may have a db entry, but is missing files
|
||||
if (JPluginHelper::importPlugin('search', $plugin)) {
|
||||
$this->enabled[] = $plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
parent::display();
|
||||
|
||||
$document = WFDocument::getInstance();
|
||||
$document->addScript(array('link'), 'extensions.search.js');
|
||||
$document->addStylesheet(array('link'), 'extensions.search.css');
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
return (bool) $wf->getParam('search.link.enable', 1) && !empty($this->enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the search areas.
|
||||
*/
|
||||
public function getAreas()
|
||||
{
|
||||
$app = JFactory::getApplication('site');
|
||||
|
||||
$areas = array();
|
||||
$results = array();
|
||||
|
||||
$searchareas = $app->triggerEvent('onContentSearchAreas');
|
||||
|
||||
foreach ($searchareas as $area) {
|
||||
if (is_array($area)) {
|
||||
$areas = array_merge($areas, $area);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($areas as $k => $v) {
|
||||
$results[$k] = JText::_($v);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*
|
||||
* Truncate search text
|
||||
* This method uses portions of components/com_finder/views/search/tmpl/default_result.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*/
|
||||
private function truncateText($text, $searchword)
|
||||
{
|
||||
// Calculate number of characters to display around the result
|
||||
$term_length = StringHelper::strlen($searchword);
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
$desc_length = $lang->getSearchDisplayedCharactersNumber();
|
||||
|
||||
$pad_length = $term_length < $desc_length ? (int) floor(($desc_length - $term_length) / 2) : 0;
|
||||
|
||||
// Find the position of the search term
|
||||
$pos = $term_length ? StringHelper::strpos(StringHelper::strtolower($text), StringHelper::strtolower($searchword)) : false;
|
||||
|
||||
// Find a potential start point
|
||||
$start = ($pos && $pos > $pad_length) ? $pos - $pad_length : 0;
|
||||
|
||||
// Find a space between $start and $pos, start right after it.
|
||||
$space = StringHelper::strpos($text, ' ', $start > 0 ? $start - 1 : 0);
|
||||
$start = ($space && $space < $pos) ? $space + 1 : $start;
|
||||
|
||||
$text = JHtml::_('string.truncate', StringHelper::substr($text, $start), $desc_length, false);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare search content by clean and truncating
|
||||
* This method uses portions of SearchHelper::prepareSearchContent from administrator/components/com_search/helpers/search.php
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
*/
|
||||
public function prepareSearchContent($text, $searchword)
|
||||
{
|
||||
// Replace line breaking tags with whitespace.
|
||||
$text = preg_replace("'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text);
|
||||
|
||||
// clean text
|
||||
$text = htmlspecialchars(strip_tags($text));
|
||||
|
||||
// remove shortcode
|
||||
$text = preg_replace('#{.+?}#', '', $text);
|
||||
|
||||
// truncate text based around searchword
|
||||
$text = $this->truncateText($text, $searchword);
|
||||
|
||||
// highlight searchword
|
||||
$text = preg_replace('#\b(' . preg_quote($searchword, '#') . ')\b#i', '<mark>$1</mark>', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/*
|
||||
* Render Search fields
|
||||
* This method uses portions of SearchViewSearch::display from components/com_search/views/search/view.html.php
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// built select lists
|
||||
$orders = array();
|
||||
$orders[] = JHtml::_('select.option', 'newest', JText::_('WF_SEARCH_NEWEST_FIRST'));
|
||||
$orders[] = JHtml::_('select.option', 'oldest', JText::_('WF_SEARCH_OLDEST_FIRST'));
|
||||
$orders[] = JHtml::_('select.option', 'popular', JText::_('WF_SEARCH_MOST_POPULAR'));
|
||||
$orders[] = JHtml::_('select.option', 'alpha', JText::_('WF_SEARCH_ALPHABETICAL'));
|
||||
$orders[] = JHtml::_('select.option', 'category', JText::_('WF_CATEGORY'));
|
||||
|
||||
$lists = array();
|
||||
$lists['ordering'] = JHtml::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text');
|
||||
|
||||
$searchphrases = array();
|
||||
$searchphrases[] = JHtml::_('select.option', 'all', JText::_('WF_SEARCH_ALL_WORDS'));
|
||||
$searchphrases[] = JHtml::_('select.option', 'any', JText::_('WF_SEARCH_ANY_WORDS'));
|
||||
$searchphrases[] = JHtml::_('select.option', 'exact', JText::_('WF_SEARCH_EXACT_PHRASE'));
|
||||
$lists['searchphrase'] = JHtml::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', 'all');
|
||||
|
||||
$view = $this->getView(array('name' => 'search', 'layout' => 'search'));
|
||||
|
||||
$view->searchareas = self::getAreas();
|
||||
$view->lists = $lists;
|
||||
|
||||
$view->display();
|
||||
}
|
||||
|
||||
private static function getSearchAreaFromUrl($url)
|
||||
{
|
||||
$query = parse_url($url, PHP_URL_QUERY);
|
||||
|
||||
if (empty($query)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
parse_str($query, $values);
|
||||
|
||||
if (!array_key_exists('option', $values)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$language = JFactory::getLanguage();
|
||||
|
||||
$option = $values['option'];
|
||||
|
||||
// load system language file
|
||||
$language->load($option . '.sys', JPATH_ADMINISTRATOR);
|
||||
$language->load($option, JPATH_ADMINISTRATOR);
|
||||
|
||||
return JText::_($option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process search.
|
||||
*
|
||||
* @param type $query Search query
|
||||
* @return array Search Results
|
||||
*
|
||||
* This method uses portions of SearchController::search from components/com_search/controller.php
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved
|
||||
*/
|
||||
public function doSearch($query)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$results = array();
|
||||
|
||||
if (empty($query)) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
// search area
|
||||
$area = null;
|
||||
|
||||
// available search areas
|
||||
$areas = $this->getAreas();
|
||||
|
||||
// query using a specific plugin
|
||||
if (strpos($query, ':') !== false) {
|
||||
preg_match('#^(' . implode('|', $areas) . ')\:(.+)#', $query, $matches);
|
||||
|
||||
if ($matches) {
|
||||
$area = array($matches[1]);
|
||||
$query = $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('JSite')) {
|
||||
// Load JSite class
|
||||
JLoader::register('JSite', JPATH_SITE . '/includes/application.php');
|
||||
}
|
||||
|
||||
$app = JFactory::getApplication('site');
|
||||
$filter = JFilterInput::getInstance();
|
||||
$router = $app::getRouter('site');
|
||||
|
||||
// get router mode
|
||||
$sef = (int) $wf->getParam('search.link.sef_url', 0);
|
||||
|
||||
$limit = (int) $wf->getParam('search.link.limit', 50);
|
||||
|
||||
// set router off so a raw url is returned by the Search plugin
|
||||
if ($router) {
|
||||
//$router->setMode(0);
|
||||
}
|
||||
|
||||
// slashes cause errors, <> get stripped anyway later on. # causes problems.
|
||||
$searchword = trim(str_replace(array('#', '>', '<', '\\'), '', $filter->clean($query)));
|
||||
|
||||
$ordering = null;
|
||||
$searchphrase = 'all';
|
||||
|
||||
// if searchword enclosed in double quotes, strip quotes and do exact match
|
||||
if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"') {
|
||||
$searchword = substr($searchword, 1, -1);
|
||||
$searchphrase = 'exact';
|
||||
}
|
||||
|
||||
$searchphrase = $app->input->post->getWord('searchphrase', $searchphrase);
|
||||
|
||||
// get passed through ordering
|
||||
$ordering = $app->input->post->getWord('ordering', $ordering);
|
||||
|
||||
// get passed through area
|
||||
$area = $app->input->post->getCmd('areas', (array) $area);
|
||||
|
||||
if (empty($area)) {
|
||||
$area = null;
|
||||
}
|
||||
|
||||
// trigger search on loaded plugins
|
||||
$searches = $app->triggerEvent('onContentSearch', array(
|
||||
$searchword,
|
||||
$searchphrase,
|
||||
$ordering,
|
||||
$area,
|
||||
));
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($searches as $search) {
|
||||
$rows = array_merge((array) $rows, (array) $search);
|
||||
}
|
||||
|
||||
// get first 10
|
||||
$rows = array_slice($rows, 0, $limit);
|
||||
|
||||
$areas = array();
|
||||
|
||||
for ($i = 0, $count = count($rows); $i < $count; ++$i) {
|
||||
$row = &$rows[$i];
|
||||
|
||||
if (empty($row->href) || empty($row->title)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$area = isset($row->section) ? $row->section : self::getSearchAreaFromUrl($row->href);
|
||||
|
||||
if (!isset($areas[$area])) {
|
||||
$areas[$area] = array();
|
||||
}
|
||||
|
||||
$result = new StdClass;
|
||||
|
||||
if ($searchphrase == 'exact') {
|
||||
$searchwords = array($searchword);
|
||||
$needle = $searchword;
|
||||
} else {
|
||||
$searchworda = preg_replace('#\xE3\x80\x80#s', ' ', $searchword);
|
||||
$searchwords = preg_split("/\s+/u", $searchworda);
|
||||
$needle = $searchwords[0];
|
||||
}
|
||||
|
||||
// get anchors if any...
|
||||
$row->anchors = self::getAnchors($row->text);
|
||||
|
||||
// prepare and truncate search text
|
||||
$row->text = $this->prepareSearchContent($row->text, $needle);
|
||||
|
||||
// remove base url
|
||||
if (JURI::base(true) && strpos($row->href, JURI::base(true)) !== false) {
|
||||
$row->href = substr_replace($row->href, '', 0, strlen(JURI::base(true)) + 1);
|
||||
}
|
||||
|
||||
// remove the alias or ItemId from a link
|
||||
$row->href = self::route($row->href);
|
||||
|
||||
$result->title = $row->title;
|
||||
$result->text = $row->text;
|
||||
$result->link = $row->href;
|
||||
|
||||
if (!empty($row->anchors)) {
|
||||
$result->anchors = $row->anchors;
|
||||
}
|
||||
|
||||
$areas[$area][] = $result;
|
||||
}
|
||||
|
||||
if (!empty($areas)) {
|
||||
$results[] = $areas;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('search.link.remove_alias', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid if set
|
||||
if ((bool) $wf->getParam('search.link.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private static function getAnchors($content)
|
||||
{
|
||||
preg_match_all('#<a([^>]+)(name|id)="([a-z]+[\w\-\:\.]*)"([^>]*)>#i', $content, $matches, PREG_SET_ORDER);
|
||||
|
||||
$anchors = array();
|
||||
|
||||
if (!empty($matches)) {
|
||||
foreach ($matches as $match) {
|
||||
if (strpos($match[0], 'href') === false) {
|
||||
$anchors[] = $match[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $anchors;
|
||||
}
|
||||
}
|
||||
36
components/com_jce/editor/extensions/search/link.xml
Normal file
36
components/com_jce/editor/extensions/search/link.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_LINK_SEARCH_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>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_LINK_SEARCH_DESC</description>
|
||||
<files>
|
||||
<filename>link.php</filename>
|
||||
<folder>link</folder>
|
||||
</files>
|
||||
<fields name="link">
|
||||
<fieldset name="link">
|
||||
<field name="enable" type="yesno" default="1" label="WF_LABEL_EXTENSION_ENABLE" description="WF_LABEL_EXTENSION_ENABLE_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="plugins" type="searchplugins" multiple="true" label="WF_PARAM_LINK_SEARCH_PLUGINS" description="WF_PARAM_LINK_SEARCH_PLUGINS_DESC" default="categories,contacts,content,weblinks,tags" layout="joomla.form.field.list-fancy-select" />
|
||||
<field name="remove_alias" type="yesno" default="0" label="WF_LINK_SEARCH_REMOVE_ALIAS" description="WF_LINK_SEARCH_REMOVE_ALIAS_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="itemid" type="yesno" default="1" label="WF_LINK_SEARCH_ITEMID" description="WF_LINK_SEARCH_ITEMID_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<plugins>link</plugins>
|
||||
<media></media>
|
||||
<languages></languages>
|
||||
</extension>
|
||||
1
components/com_jce/editor/index.html
Normal file
1
components/com_jce/editor/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
471
components/com_jce/editor/libraries/classes/application.php
Normal file
471
components/com_jce/editor/libraries/classes/application.php
Normal file
@@ -0,0 +1,471 @@
|
||||
<?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;
|
||||
|
||||
require_once JPATH_ADMINISTRATOR . '/components/com_jce/includes/base.php';
|
||||
|
||||
/**
|
||||
* JCE class.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class WFApplication extends JObject
|
||||
{
|
||||
// Editor instance
|
||||
protected static $instance;
|
||||
|
||||
// Editor Profile
|
||||
protected static $profile = array();
|
||||
|
||||
// Editor Params
|
||||
protected static $params = array();
|
||||
|
||||
// JInput Reference
|
||||
public $input;
|
||||
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->setProperties($config);
|
||||
|
||||
// store a reference to the Joomla Application input
|
||||
$this->input = JFactory::getApplication()->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*/
|
||||
public static function getInstance($config = array())
|
||||
{
|
||||
if (!isset(self::$instance)) {
|
||||
self::$instance = new self($config);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
$manifest = WF_ADMINISTRATOR . '/jce.xml';
|
||||
|
||||
$version = md5_file($manifest);
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
protected function getComponent($id = null, $option = null)
|
||||
{
|
||||
if ($id) {
|
||||
$components = JComponentHelper::getComponents();
|
||||
|
||||
foreach ($components as $option => $component) {
|
||||
if ($id == $component->id) {
|
||||
return $component;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JComponentHelper::getComponent($option);
|
||||
}
|
||||
|
||||
public function getContext()
|
||||
{
|
||||
$option = JFactory::getApplication()->input->getCmd('option');
|
||||
$component = JComponentHelper::getComponent($option, true);
|
||||
|
||||
return $component->id;
|
||||
}
|
||||
|
||||
private function getProfileVars()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$option = $this->getComponentOption();
|
||||
|
||||
$settings = array(
|
||||
'option' => $option,
|
||||
'area' => 2,
|
||||
'device' => 'desktop',
|
||||
'groups' => array(),
|
||||
);
|
||||
|
||||
// find the component if this is called from within the JCE component
|
||||
if ($option == 'com_jce') {
|
||||
$context = $app->input->getInt('context');
|
||||
|
||||
if ($context) {
|
||||
|
||||
if ($context === 'mediafield') {
|
||||
$settings['option'] = 'mediafield';
|
||||
} else {
|
||||
$component = $this->getComponent($context);
|
||||
$settings['option'] = $component->option;
|
||||
}
|
||||
}
|
||||
|
||||
$profile_id = $app->input->getInt('profile_id');
|
||||
|
||||
if ($profile_id) {
|
||||
$settings['profile_id'] = $profile_id;
|
||||
}
|
||||
}
|
||||
|
||||
// get the Joomla! area, default to "site"
|
||||
$settings['area'] = $app->getClientId() === 0 ? 1 : 2;
|
||||
|
||||
$mobile = new Wf_Mobile_Detect();
|
||||
|
||||
// phone
|
||||
if ($mobile->isMobile()) {
|
||||
$settings['device'] = 'phone';
|
||||
}
|
||||
|
||||
if ($mobile->isTablet()) {
|
||||
$settings['device'] = 'tablet';
|
||||
}
|
||||
|
||||
$settings['groups'] = $user->getAuthorisedGroups();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
private function isCorePlugin($plugin)
|
||||
{
|
||||
return in_array($plugin, array('core', 'autolink', 'cleanup', 'code', 'format', 'importcss', 'colorpicker', 'upload', 'branding', 'inlinepopups', 'figure', 'ui'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an appropriate editor profile.
|
||||
*/
|
||||
public function getProfile($plugin = '', $id = 0)
|
||||
{
|
||||
// reset the value if it is a core plugin
|
||||
if ($this->isCorePlugin($plugin)) {
|
||||
$plugin = '';
|
||||
}
|
||||
|
||||
// get the profile variables for the current context
|
||||
$options = $this->getProfileVars();
|
||||
|
||||
// add plugin to options array
|
||||
$options['plugin'] = $plugin;
|
||||
|
||||
// assign profile_id to simple variable
|
||||
if (isset($options['profile_id'])) {
|
||||
$id = (int) $options['profile_id'];
|
||||
}
|
||||
|
||||
// create a signature to store
|
||||
$signature = md5(serialize($options));
|
||||
|
||||
if (!isset(self::$profile[$signature])) {
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('*')->from('#__wf_profiles')->where('published = 1')->order('ordering ASC');
|
||||
|
||||
if ($id) {
|
||||
$query->where('id = ' . (int) $id);
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$profiles = $db->loadObjectList();
|
||||
|
||||
// nothing found...
|
||||
if (empty($profiles)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// select and return a specific profile by id
|
||||
if ($id) {
|
||||
// return
|
||||
return (object) $profiles[0];
|
||||
}
|
||||
|
||||
foreach ($profiles as $item) {
|
||||
// at least one user group or user must be set
|
||||
if (empty($item->types) && empty($item->users)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check user groups - a value should always be set
|
||||
$groups = array_intersect($options['groups'], explode(',', $item->types));
|
||||
|
||||
// user not in the current group...
|
||||
if (empty($groups)) {
|
||||
// no additional users set or no user match
|
||||
if (empty($item->users) || in_array($user->id, explode(',', $item->users)) === false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// check component
|
||||
if (!empty($item->components)) {
|
||||
if (in_array($options['option'], explode(',', $item->components)) === false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// set device default as 'desktop,tablet,mobile'
|
||||
if (empty($item->device)) {
|
||||
$item->device = 'desktop,tablet,phone';
|
||||
}
|
||||
|
||||
// check device
|
||||
if (in_array($options['device'], explode(',', $item->device)) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check area
|
||||
if (!empty($item->area) && (int) $item->area != $options['area']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check against passed in plugin value
|
||||
if ($plugin && in_array($plugin, explode(',', $item->plugins)) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// decrypt params
|
||||
if (!empty($item->params)) {
|
||||
$item->params = JceEncryptHelper::decrypt($item->params);
|
||||
}
|
||||
|
||||
// assign item to profile
|
||||
self::$profile[$signature] = (object) $item;
|
||||
|
||||
// return
|
||||
return self::$profile[$signature];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::$profile[$signature];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the component option.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComponentOption()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$option = $app->input->getCmd('option', '');
|
||||
|
||||
switch ($option) {
|
||||
case 'com_section':
|
||||
$option = 'com_content';
|
||||
break;
|
||||
case 'com_categories':
|
||||
$section = $app->input->getCmd('section');
|
||||
|
||||
if ($section) {
|
||||
$option = $section;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get editor parameters.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getParams($options = array())
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
if (!isset(self::$params)) {
|
||||
self::$params = array();
|
||||
}
|
||||
|
||||
// set blank key if not set
|
||||
if (!isset($options['key'])) {
|
||||
$options['key'] = '';
|
||||
}
|
||||
// set blank path if not set
|
||||
if (!isset($options['path'])) {
|
||||
$options['path'] = '';
|
||||
}
|
||||
|
||||
// get plugin name
|
||||
$plugin = $app->input->getCmd('plugin', '');
|
||||
|
||||
// reset the plugin value if this is not called from within the JCE component
|
||||
if ($app->input->getCmd('option') !== 'com_jce') {
|
||||
$plugin = '';
|
||||
}
|
||||
|
||||
if ($plugin) {
|
||||
// optional caller, eg: Link
|
||||
$caller = '';
|
||||
|
||||
// get name and caller from plugin name
|
||||
if (strpos($plugin, '.') !== false) {
|
||||
list($plugin, $caller) = explode('.', $plugin);
|
||||
|
||||
if ($caller) {
|
||||
$options['caller'] = $caller;
|
||||
}
|
||||
}
|
||||
|
||||
$options['plugin'] = $plugin;
|
||||
}
|
||||
|
||||
$signature = serialize($options);
|
||||
|
||||
if (empty(self::$params[$signature])) {
|
||||
// get plugin
|
||||
$editor = JPluginHelper::getPlugin('editors', 'jce');
|
||||
|
||||
if (empty($editor->params)) {
|
||||
$editor->params = '{}';
|
||||
}
|
||||
|
||||
// get editor params as an associative array
|
||||
$data1 = json_decode($editor->params, true);
|
||||
|
||||
// if null or false, revert to array
|
||||
if (empty($data1)) {
|
||||
$data1 = array();
|
||||
}
|
||||
|
||||
// assign params to "editor" key
|
||||
$data1 = array('editor' => $data1);
|
||||
|
||||
// get params data for this profile
|
||||
$profile = $this->getProfile($plugin);
|
||||
|
||||
// create empty default if no profile or params are set
|
||||
$params = empty($profile->params) ? '{}' : $profile->params;
|
||||
|
||||
// get profile params as an associative array
|
||||
$data2 = json_decode($params, true);
|
||||
|
||||
// if null or false, revert to array
|
||||
if (empty($data2)) {
|
||||
$data2 = array();
|
||||
}
|
||||
|
||||
// merge params, but ignore empty values
|
||||
$data = WFUtility::array_merge_recursive_distinct($data1, $data2, true);
|
||||
|
||||
// create new registry with params
|
||||
$params = new JRegistry($data);
|
||||
|
||||
self::$params[$signature] = $params;
|
||||
}
|
||||
|
||||
return self::$params[$signature];
|
||||
}
|
||||
|
||||
private function isEmptyValue($value)
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
return empty($value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a parameter by key.
|
||||
*
|
||||
* @param $key Parameter key eg: editor.width
|
||||
* @param $fallback Fallback value
|
||||
* @param $default Default value
|
||||
*/
|
||||
public function getParam($key, $fallback = '', $default = '', $type = 'string')
|
||||
{
|
||||
// get params for base key
|
||||
$params = $this->getParams();
|
||||
|
||||
// get a parameter
|
||||
$value = $params->get($key);
|
||||
|
||||
// key not present in params or was empty string or empty array (JRegistry returns null), use fallback value
|
||||
if (self::isEmptyValue($value)) {
|
||||
// set default as empty string
|
||||
$value = '';
|
||||
|
||||
// key does not exist (parameter was not set) - use fallback
|
||||
if ($params->exists($key) === false) {
|
||||
$value = $fallback;
|
||||
|
||||
// if fallback is empty, revert to system default if it is non-empty
|
||||
if ($fallback == '' && $default != '') {
|
||||
$value = $default;
|
||||
|
||||
// reset $default to prevent clearing
|
||||
$default = '';
|
||||
}
|
||||
// parameter is set, but is empty, but fallback is not (inherited values)
|
||||
} else if ($fallback != '') {
|
||||
$value = $fallback;
|
||||
}
|
||||
}
|
||||
|
||||
// clean string value of whitespace
|
||||
if (is_string($value)) {
|
||||
$value = trim(preg_replace('#[\n\r\t]+#', '', $value));
|
||||
}
|
||||
|
||||
// cast default to float if numeric
|
||||
if (is_numeric($default)) {
|
||||
$default = (float) $default;
|
||||
}
|
||||
|
||||
// cast value to float if numeric
|
||||
if (is_numeric($value)) {
|
||||
$value = (float) $value;
|
||||
}
|
||||
|
||||
// if value is equal to system default, clear $value and return
|
||||
if ($value === $default) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// cast value to boolean
|
||||
if ($type == 'boolean') {
|
||||
$value = (bool) $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
1815
components/com_jce/editor/libraries/classes/browser.php
Normal file
1815
components/com_jce/editor/libraries/classes/browser.php
Normal file
File diff suppressed because it is too large
Load Diff
697
components/com_jce/editor/libraries/classes/document.php
Normal file
697
components/com_jce/editor/libraries/classes/document.php
Normal file
@@ -0,0 +1,697 @@
|
||||
<?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 WFDocument extends JObject
|
||||
{
|
||||
/**
|
||||
* Array of linked scripts.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $scripts = array();
|
||||
|
||||
/**
|
||||
* Array of scripts placed in the header.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $script = array();
|
||||
|
||||
/**
|
||||
* Array of linked style sheets.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $styles = array();
|
||||
|
||||
/**
|
||||
* Array of head items.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $head = array();
|
||||
|
||||
/**
|
||||
* Body content.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $body = '';
|
||||
|
||||
/**
|
||||
* Document title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $title = '';
|
||||
|
||||
/**
|
||||
* Contains the document language setting.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $language = 'en-gb';
|
||||
|
||||
/**
|
||||
* Contains the document direction setting.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $direction = 'ltr';
|
||||
|
||||
private static $queryMap = array(
|
||||
'imgmanager'=> 'image',
|
||||
'imgmanager_ext' => 'imagepro'
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// set document title
|
||||
if (isset($config['title'])) {
|
||||
$this->setTitle($config['title']);
|
||||
}
|
||||
|
||||
$this->setProperties($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a WFDocument object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $document = WFDocument::getInstance();</pre>
|
||||
*
|
||||
* @return object WFDocument
|
||||
*/
|
||||
public static function getInstance($config = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($config);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the document title.
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the document name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the editor URL.
|
||||
*
|
||||
* @param bool $relative
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getURL($relative = false)
|
||||
{
|
||||
if ($relative) {
|
||||
return JURI::root(true) . '/components/com_jce/editor';
|
||||
}
|
||||
|
||||
return JURI::root() . 'components/com_jce/editor';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global document language declaration. Default is English (en-gb).
|
||||
*
|
||||
* @param string $lang
|
||||
*/
|
||||
public function setLanguage($lang = 'en-gb')
|
||||
{
|
||||
$this->language = strtolower($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document language.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global document direction declaration. Default is left-to-right (ltr).
|
||||
*
|
||||
* @param string $lang
|
||||
*/
|
||||
public function setDirection($dir = 'ltr')
|
||||
{
|
||||
$this->direction = strtolower($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document language.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirection()
|
||||
{
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JCE resource url.
|
||||
*
|
||||
* @param string The path to resolve eg: libaries
|
||||
* @param bool Create a relative url
|
||||
*
|
||||
* @return full url
|
||||
*/
|
||||
private function getBaseURL($path, $type = '')
|
||||
{
|
||||
static $url;
|
||||
|
||||
if (!isset($url)) {
|
||||
$url = array();
|
||||
}
|
||||
|
||||
$signature = serialize(array($type, $path));
|
||||
|
||||
// Check if value is already stored
|
||||
if (!isset($url[$signature])) {
|
||||
// get the plugin name using this document instance
|
||||
$plugin = $this->get('name');
|
||||
|
||||
$base = $this->getURL(true) . '/';
|
||||
|
||||
$parts = explode('.', $path);
|
||||
$path = array_shift($parts);
|
||||
|
||||
switch ($path) {
|
||||
// JCE root folder
|
||||
case 'jce':
|
||||
$pre = $base . '';
|
||||
break;
|
||||
// JCE libraries resource folder
|
||||
case 'libraries':
|
||||
$pre = $base . 'libraries/' . $type;
|
||||
break;
|
||||
case 'pro':
|
||||
$pre = $base . 'libraries/pro/' . $type;
|
||||
break;
|
||||
case 'jquery':
|
||||
$pre = $base . 'libraries/vendor/jquery/' . $type;
|
||||
break;
|
||||
// TinyMCE folder
|
||||
case 'tiny_mce':
|
||||
$pre = $base . 'tiny_mce';
|
||||
break;
|
||||
// Tinymce plugins folder
|
||||
case 'plugins':
|
||||
$pre = $base . 'tiny_mce/plugins/' . $plugin . '/' . $type;
|
||||
break;
|
||||
// Extensions folder
|
||||
case 'extensions':
|
||||
$pre = $base . 'extensions';
|
||||
break;
|
||||
case 'joomla':
|
||||
return JURI::root(true);
|
||||
break;
|
||||
case 'media':
|
||||
return JURI::root(true) . '/media/system';
|
||||
break;
|
||||
case 'component':
|
||||
$pre = JURI::root(true) . '/administrator/components/com_jce/media/' . $type;
|
||||
break;
|
||||
default:
|
||||
$pre = $base . $path;
|
||||
break;
|
||||
}
|
||||
|
||||
if (count($parts)) {
|
||||
$pre = rtrim($pre, '/') . '/' . implode('/', $parts);
|
||||
}
|
||||
|
||||
// Store url
|
||||
$url[$signature] = $pre;
|
||||
}
|
||||
|
||||
return $url[$signature];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a url to path.
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function urlToPath($url)
|
||||
{
|
||||
jimport('joomla.filesystem.path');
|
||||
|
||||
$root = JURI::root(true);
|
||||
|
||||
// remove root from url
|
||||
if (!empty($root)) {
|
||||
$url = substr($url, strlen($root));
|
||||
}
|
||||
|
||||
return WFUtility::makePath(JPATH_SITE, JPath::clean($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image url.
|
||||
*
|
||||
* @param string The file to load including path and extension eg: libaries.image.gif
|
||||
*
|
||||
* @return Image url
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function image($image, $root = 'libraries')
|
||||
{
|
||||
$parts = explode('.', $image);
|
||||
$parts = preg_replace('#[^A-Z0-9-_]#i', '', $parts);
|
||||
|
||||
$ext = array_pop($parts);
|
||||
$name = trim(array_pop($parts), '/');
|
||||
|
||||
$parts[] = 'img';
|
||||
$parts[] = $name . '.' . $ext;
|
||||
|
||||
return $this->getBaseURL($root) . implode('/', $parts);
|
||||
}
|
||||
|
||||
public function removeScript($file, $root = 'libraries')
|
||||
{
|
||||
$file = $this->buildScriptPath($file, $root);
|
||||
unset($this->scripts[$file]);
|
||||
}
|
||||
|
||||
public function removeCss($file, $root = 'libraries')
|
||||
{
|
||||
$file = $this->buildStylePath($file, $root);
|
||||
unset($this->styles[$file]);
|
||||
}
|
||||
|
||||
public function buildScriptPath($file, $root)
|
||||
{
|
||||
$file = preg_replace('#[^A-Z0-9-_\/\.]#i', '', $file);
|
||||
// get base dir
|
||||
$base = dirname($file);
|
||||
// remove extension if present
|
||||
$file = basename($file, '.js');
|
||||
// strip . and trailing /
|
||||
$file = trim(trim($base, '.'), '/') . '/' . $file . '.js';
|
||||
// remove leading and trailing slashes
|
||||
$file = trim($file, '/');
|
||||
// create path
|
||||
$file = $this->getBaseURL($root, 'js') . '/' . $file;
|
||||
// remove duplicate slashes
|
||||
$file = preg_replace('#[/\\\\]+#', '/', $file);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function buildStylePath($file, $root)
|
||||
{
|
||||
$file = preg_replace('#[^A-Z0-9-_\/\.]#i', '', $file);
|
||||
// get base dir
|
||||
$base = dirname($file);
|
||||
// remove extension if present
|
||||
$file = basename($file, '.css');
|
||||
// strip . and trailing /
|
||||
$file = trim(trim($base, '.'), '/') . '/' . $file . '.css';
|
||||
// remove leading and trailing slashes
|
||||
$file = trim($file, '/');
|
||||
// create path
|
||||
$file = $this->getBaseURL($root, 'css') . '/' . $file;
|
||||
// remove duplicate slashes
|
||||
$file = preg_replace('#[/\\\\]+#', '/', $file);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a javascript file.
|
||||
*
|
||||
* @param string The file to load including path eg: libaries.manager
|
||||
* @param bool Debug mode load src file
|
||||
*
|
||||
* @return echo script html
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function addScript($files, $root = 'libraries', $type = 'text/javascript')
|
||||
{
|
||||
$files = (array) $files;
|
||||
|
||||
foreach ($files as $file) {
|
||||
// external link
|
||||
if (strpos($file, '://') !== false || strpos($file, 'index.php?option=com_jce') !== false) {
|
||||
$this->scripts[$file] = $type;
|
||||
} else {
|
||||
$file = $this->buildScriptPath($file, $root);
|
||||
// store path
|
||||
$this->scripts[$file] = $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a css file.
|
||||
*
|
||||
* @param string The file to load including path eg: libaries.manager
|
||||
* @param string Root folder
|
||||
*
|
||||
* @return echo css html
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function addStyleSheet($files, $root = 'libraries', $type = 'text/css')
|
||||
{
|
||||
$files = (array) $files;
|
||||
|
||||
foreach ($files as $file) {
|
||||
$url = $this->buildStylePath($file, $root);
|
||||
// store path
|
||||
$this->styles[$url] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
public function addScriptDeclaration($content, $type = 'text/javascript')
|
||||
{
|
||||
if (!isset($this->script[strtolower($type)])) {
|
||||
$this->script[strtolower($type)] = $content;
|
||||
} else {
|
||||
$this->script[strtolower($type)] .= chr(13) . $content;
|
||||
}
|
||||
}
|
||||
|
||||
private function getScriptDeclarations()
|
||||
{
|
||||
return $this->script;
|
||||
}
|
||||
|
||||
private function getScripts()
|
||||
{
|
||||
return $this->scripts;
|
||||
}
|
||||
|
||||
private function getStyleSheets()
|
||||
{
|
||||
return $this->styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup head data.
|
||||
*/
|
||||
private function setHead($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
$this->head = array_merge($this->head, $data);
|
||||
} else {
|
||||
$this->head[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getQueryString($query = array())
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// get plugin name and assign to query
|
||||
$name = $this->get('name');
|
||||
|
||||
// re-map plugin name
|
||||
if (array_key_exists($name, self::$queryMap)) {
|
||||
$name = self::$queryMap[$name];
|
||||
}
|
||||
|
||||
$query['plugin'] = $name;
|
||||
|
||||
// set slot
|
||||
$query['slot'] = $app->input->getCmd('slot');
|
||||
|
||||
// set standalone mode (for File Browser etc)
|
||||
$query['standalone'] = $this->get('standalone');
|
||||
|
||||
// set context id
|
||||
$query['context'] = $app->input->getInt('context');
|
||||
|
||||
// get token
|
||||
$token = JSession::getFormToken();
|
||||
|
||||
// set token
|
||||
$query[$token] = 1;
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach ($query as $key => $value) {
|
||||
if ($value) {
|
||||
$output[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
return implode('&', $output);
|
||||
}
|
||||
|
||||
private function getHash($files)
|
||||
{
|
||||
$seed = '';
|
||||
$hash = '';
|
||||
|
||||
// cast as array
|
||||
$files = (array) $files;
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
// only add stamp to static stylesheets
|
||||
if (strpos($file, '://') === false && strpos($file, 'index.php?option=com_jce') === false) {
|
||||
$seed .= basename($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($seed) {
|
||||
$hash = md5(WF_VERSION . $seed);
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render document head data.
|
||||
*/
|
||||
private function getHead()
|
||||
{
|
||||
// set title
|
||||
$output = '<title>' . $this->getTitle() . '</title>' . "\n";
|
||||
|
||||
// render stylesheets
|
||||
if ($this->get('compress_css', 0)) {
|
||||
$file = JURI::base(true) . '/index.php?option=com_jce&' . $this->getQueryString(array('task' => 'plugin.pack', 'type' => 'css'));
|
||||
// add hash
|
||||
$file .= '&' . $this->getHash(array_keys($this->styles));
|
||||
|
||||
$output .= "\t\t<link href=\"" . $file . "\" rel=\"stylesheet\" type=\"text/css\" />\n";
|
||||
} else {
|
||||
foreach ($this->styles as $src => $type) {
|
||||
$hash = $this->getHash($src);
|
||||
|
||||
// only add stamp to static stylesheets
|
||||
if (!empty($hash)) {
|
||||
$hash = strpos($src, '?') === false ? '?' . $hash : '&' . $hash;
|
||||
}
|
||||
|
||||
$output .= "\t\t<link href=\"" . $src . $hash . '" rel="stylesheet" type="' . $type . "\" />\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Render scripts
|
||||
if ($this->get('compress_javascript', 0)) {
|
||||
$script = JURI::base(true) . '/index.php?option=com_jce&' . $this->getQueryString(array('task' => 'plugin.pack'));
|
||||
// add hash
|
||||
$script .= '&' . $this->getHash(array_keys($this->scripts));
|
||||
|
||||
$output .= "\t\t<script data-cfasync=\"false\" type=\"text/javascript\" src=\"" . $script . "\"></script>\n";
|
||||
} else {
|
||||
foreach ($this->scripts as $src => $type) {
|
||||
$hash = $this->getHash($src);
|
||||
|
||||
// only add stamp to static stylesheets
|
||||
if (!empty($hash)) {
|
||||
$hash = strpos($src, '?') === false ? '?' . $hash : '&' . $hash;
|
||||
}
|
||||
|
||||
$output .= "\t\t<script data-cfasync=\"false\" type=\"" . $type . '" src="' . $src . $hash . "\"></script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Script declarations
|
||||
foreach ($this->script as $type => $content) {
|
||||
$output .= "\t\t<script data-cfasync=\"false\" type=\"" . $type . '">' . $content . '</script>';
|
||||
}
|
||||
|
||||
// Other head data
|
||||
foreach ($this->head as $head) {
|
||||
$output .= "\t" . $head . "\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function setBody($data = '')
|
||||
{
|
||||
$this->body = $data;
|
||||
}
|
||||
|
||||
private function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
private function loadData()
|
||||
{
|
||||
//get the file content
|
||||
ob_start();
|
||||
require_once WF_EDITOR_LIBRARIES . '/views/plugin/index.php';
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the document.
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
// assign language
|
||||
$this->language = $this->getLanguage();
|
||||
$this->direction = $this->getDirection();
|
||||
|
||||
// load template data
|
||||
$output = $this->loadData();
|
||||
$output = $this->parseData($output);
|
||||
|
||||
exit($output);
|
||||
}
|
||||
|
||||
private function parseData($data)
|
||||
{
|
||||
$data = preg_replace_callback('#<!-- \[head\] -->#', array($this, 'getHead'), $data);
|
||||
$data = preg_replace_callback('#<!-- \[body\] -->#', array($this, 'getBody'), $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* pack function for plugins.
|
||||
*/
|
||||
public function pack($minify = true, $gzip = false)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
if ($app->input->getCmd('task') == 'pack') {
|
||||
|
||||
// check token
|
||||
JSession::checkToken('get') or jexit();
|
||||
|
||||
$type = $app->input->getWord('type', 'javascript');
|
||||
|
||||
// create packer
|
||||
$packer = new WFPacker(array('type' => $type));
|
||||
|
||||
$files = array();
|
||||
|
||||
switch ($type) {
|
||||
case 'javascript':
|
||||
$data = '';
|
||||
|
||||
foreach ($this->getScripts() as $src => $type) {
|
||||
if (strpos($src, '://') === false && strpos($src, 'index.php') === false) {
|
||||
$src .= preg_match('/\.js$/', $src) ? '' : '.js';
|
||||
|
||||
$files[] = $this->urlToPath($src);
|
||||
}
|
||||
}
|
||||
|
||||
// parse ini language files
|
||||
$parser = new WFLanguageParser(array(
|
||||
'plugins' => array('core' => array($this->getName()), 'external' => array()),
|
||||
'sections' => array('dlg', $this->getName() . '_dlg'),
|
||||
'mode' => 'plugin',
|
||||
'language' => WFLanguage::getTag()
|
||||
));
|
||||
|
||||
$data .= $parser->load();
|
||||
|
||||
// add script declarations
|
||||
/*foreach ($this->getScriptDeclarations() as $script) {
|
||||
$data .= $script;
|
||||
}*/
|
||||
|
||||
$packer->setContentEnd($data);
|
||||
|
||||
break;
|
||||
case 'css':
|
||||
foreach ($this->getStyleSheets() as $style => $type) {
|
||||
if (strpos($style, '://') === false && strpos($style, 'index.php') === false) {
|
||||
$style .= preg_match('/\.css$/', $style) ? '' : '.css';
|
||||
|
||||
$files[] = $this->urlToPath($style);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$packer->setFiles($files);
|
||||
$packer->pack($minify, $gzip);
|
||||
}
|
||||
}
|
||||
}
|
||||
1562
components/com_jce/editor/libraries/classes/editor.php
Normal file
1562
components/com_jce/editor/libraries/classes/editor.php
Normal file
File diff suppressed because it is too large
Load Diff
548
components/com_jce/editor/libraries/classes/encrypt.php
Normal file
548
components/com_jce/editor/libraries/classes/encrypt.php
Normal file
@@ -0,0 +1,548 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c)2009-2013 Nicholas K. Dionysopoulos
|
||||
* @license GNU General Public License version 3, or later
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
|
||||
// Protection against direct access
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* AES implementation in PHP (c) Chris Veness 2005-2013.
|
||||
* Right to use and adapt is granted for under a simple creative commons attribution
|
||||
* licence. No warranty of any form is offered.
|
||||
*
|
||||
* Modified for Akeeba Backup by Nicholas K. Dionysopoulos
|
||||
* Included for JCE with the kind permission of Nicholas K. Dionysopoulos
|
||||
*/
|
||||
class WFUtilEncrypt
|
||||
{
|
||||
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [<5B>5.1.1]
|
||||
protected static $Sbox =
|
||||
array(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
||||
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
||||
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
||||
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
||||
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
||||
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
||||
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
||||
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
||||
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
||||
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
||||
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
||||
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
||||
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
||||
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
||||
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16, );
|
||||
|
||||
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [<5B>5.2]
|
||||
protected static $Rcon = array(
|
||||
array(0x00, 0x00, 0x00, 0x00),
|
||||
array(0x01, 0x00, 0x00, 0x00),
|
||||
array(0x02, 0x00, 0x00, 0x00),
|
||||
array(0x04, 0x00, 0x00, 0x00),
|
||||
array(0x08, 0x00, 0x00, 0x00),
|
||||
array(0x10, 0x00, 0x00, 0x00),
|
||||
array(0x20, 0x00, 0x00, 0x00),
|
||||
array(0x40, 0x00, 0x00, 0x00),
|
||||
array(0x80, 0x00, 0x00, 0x00),
|
||||
array(0x1b, 0x00, 0x00, 0x00),
|
||||
array(0x36, 0x00, 0x00, 0x00), );
|
||||
|
||||
protected static $passwords = array();
|
||||
|
||||
/**
|
||||
* AES Cipher function: encrypt 'input' with Rijndael algorithm.
|
||||
*
|
||||
* @param input message as byte-array (16 bytes)
|
||||
* @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) -
|
||||
* generated from the cipher key by KeyExpansion()
|
||||
*
|
||||
* @return ciphertext as byte-array (16 bytes)
|
||||
*/
|
||||
public static function Cipher($input, $w)
|
||||
{ // main Cipher function [<5B>5.1]
|
||||
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
||||
$Nr = count($w) / $Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
||||
|
||||
$state = array(); // initialise 4xNb byte-array 'state' with input [<5B>3.4]
|
||||
for ($i = 0; $i < 4 * $Nb; ++$i) {
|
||||
$state[$i % 4][floor($i / 4)] = $input[$i];
|
||||
}
|
||||
|
||||
$state = self::AddRoundKey($state, $w, 0, $Nb);
|
||||
|
||||
for ($round = 1; $round < $Nr; ++$round) { // apply Nr rounds
|
||||
$state = self::SubBytes($state, $Nb);
|
||||
$state = self::ShiftRows($state, $Nb);
|
||||
$state = self::MixColumns($state, $Nb);
|
||||
$state = self::AddRoundKey($state, $w, $round, $Nb);
|
||||
}
|
||||
|
||||
$state = self::SubBytes($state, $Nb);
|
||||
$state = self::ShiftRows($state, $Nb);
|
||||
$state = self::AddRoundKey($state, $w, $Nr, $Nb);
|
||||
|
||||
$output = array(4 * $Nb); // convert state to 1-d array before returning [<5B>3.4]
|
||||
for ($i = 0; $i < 4 * $Nb; ++$i) {
|
||||
$output[$i] = $state[$i % 4][floor($i / 4)];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected static function AddRoundKey($state, $w, $rnd, $Nb)
|
||||
{ // xor Round Key into state S [<5B>5.1.4]
|
||||
for ($r = 0; $r < 4; ++$r) {
|
||||
for ($c = 0; $c < $Nb; ++$c) {
|
||||
$state[$r][$c] ^= $w[$rnd * 4 + $c][$r];
|
||||
}
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
protected static function SubBytes($s, $Nb)
|
||||
{ // apply SBox to state S [<5B>5.1.1]
|
||||
for ($r = 0; $r < 4; ++$r) {
|
||||
for ($c = 0; $c < $Nb; ++$c) {
|
||||
$s[$r][$c] = self::$Sbox[$s[$r][$c]];
|
||||
}
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected static function ShiftRows($s, $Nb)
|
||||
{ // shift row r of state S left by r bytes [<5B>5.1.2]
|
||||
$t = array(4);
|
||||
for ($r = 1; $r < 4; ++$r) {
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$t[$c] = $s[$r][($c + $r) % $Nb];
|
||||
} // shift into temp copy
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$s[$r][$c] = $t[$c];
|
||||
} // and copy back
|
||||
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
|
||||
return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
|
||||
}
|
||||
|
||||
protected static function MixColumns($s, $Nb)
|
||||
{ // combine bytes of each col of state S [<5B>5.1.3]
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$a = array(4); // 'a' is a copy of the current column from 's'
|
||||
$b = array(4); // 'b' is a<>{02} in GF(2^8)
|
||||
for ($i = 0; $i < 4; ++$i) {
|
||||
$a[$i] = $s[$i][$c];
|
||||
$b[$i] = $s[$i][$c] & 0x80 ? $s[$i][$c] << 1 ^ 0x011b : $s[$i][$c] << 1;
|
||||
}
|
||||
// a[n] ^ b[n] is a<>{03} in GF(2^8)
|
||||
$s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3
|
||||
$s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3
|
||||
$s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3
|
||||
$s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Key expansion for Rijndael Cipher(): performs key expansion on cipher key
|
||||
* to generate a key schedule.
|
||||
*
|
||||
* @param key cipher key byte-array (16 bytes)
|
||||
*
|
||||
* @return key schedule as 2D byte-array (Nr+1 x Nb bytes)
|
||||
*/
|
||||
public static function KeyExpansion($key)
|
||||
{ // generate Key Schedule from Cipher Key [<5B>5.2]
|
||||
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
||||
$Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys
|
||||
$Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
||||
|
||||
$w = array();
|
||||
$temp = array();
|
||||
|
||||
for ($i = 0; $i < $Nk; ++$i) {
|
||||
$r = array($key[4 * $i], $key[4 * $i + 1], $key[4 * $i + 2], $key[4 * $i + 3]);
|
||||
$w[$i] = $r;
|
||||
}
|
||||
|
||||
for ($i = $Nk; $i < ($Nb * ($Nr + 1)); ++$i) {
|
||||
$w[$i] = array();
|
||||
for ($t = 0; $t < 4; ++$t) {
|
||||
$temp[$t] = $w[$i - 1][$t];
|
||||
}
|
||||
if ($i % $Nk == 0) {
|
||||
$temp = self::SubWord(self::RotWord($temp));
|
||||
for ($t = 0; $t < 4; ++$t) {
|
||||
$temp[$t] ^= self::$Rcon[$i / $Nk][$t];
|
||||
}
|
||||
} elseif ($Nk > 6 && $i % $Nk == 4) {
|
||||
$temp = self::SubWord($temp);
|
||||
}
|
||||
for ($t = 0; $t < 4; ++$t) {
|
||||
$w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t];
|
||||
}
|
||||
}
|
||||
|
||||
return $w;
|
||||
}
|
||||
|
||||
protected static function SubWord($w)
|
||||
{ // apply SBox to 4-byte word w
|
||||
for ($i = 0; $i < 4; ++$i) {
|
||||
$w[$i] = self::$Sbox[$w[$i]];
|
||||
}
|
||||
|
||||
return $w;
|
||||
}
|
||||
|
||||
protected static function RotWord($w)
|
||||
{ // rotate 4-byte word w left by one byte
|
||||
$tmp = $w[0];
|
||||
for ($i = 0; $i < 3; ++$i) {
|
||||
$w[$i] = $w[$i + 1];
|
||||
}
|
||||
$w[3] = $tmp;
|
||||
|
||||
return $w;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints
|
||||
*
|
||||
* @param a number to be shifted (32-bit integer)
|
||||
* @param b number of bits to shift a to the right (0..31)
|
||||
* @return a right-shifted and zero-filled by b bits
|
||||
*/
|
||||
protected static function urs($a, $b)
|
||||
{
|
||||
$a &= 0xffffffff;
|
||||
$b &= 0x1f; // (bounds check)
|
||||
if ($a & 0x80000000 && $b > 0) { // if left-most bit set
|
||||
$a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit
|
||||
$a = $a >> ($b - 1); // remaining right-shifts
|
||||
} else { // otherwise
|
||||
$a = ($a >> $b); // use normal right-shift
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt a text using AES encryption in Counter mode of operation
|
||||
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf.
|
||||
*
|
||||
* Unicode multi-byte character safe
|
||||
*
|
||||
* @param plaintext source text to be encrypted
|
||||
* @param password the password to use to generate a key
|
||||
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
||||
*
|
||||
* @return encrypted text
|
||||
*/
|
||||
public static function AESEncryptCtr($plaintext, $password, $nBits)
|
||||
{
|
||||
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
||||
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) {
|
||||
return '';
|
||||
} // standard allows 128/192/256 bit keys
|
||||
// note PHP (5) gives us plaintext and password in UTF8 encoding!
|
||||
|
||||
// use AES itself to encrypt password to get cipher key (using plain password as source for
|
||||
// key expansion) - gives us well encrypted key
|
||||
$nBytes = $nBits / 8; // no bytes in key
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$key = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
||||
|
||||
// initialise counter block (NIST SP800-38A <20>B.2): millisecond time-stamp for nonce in
|
||||
// 1st 8 bytes, block counter in 2nd 8 bytes
|
||||
$counterBlock = array();
|
||||
$nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970
|
||||
$nonceSec = floor($nonce / 1000);
|
||||
$nonceMs = $nonce % 1000;
|
||||
// encode nonce with seconds in 1st 4 bytes, and (repeated) ms part filling 2nd 4 bytes
|
||||
for ($i = 0; $i < 4; ++$i) {
|
||||
$counterBlock[$i] = self::urs($nonceSec, $i * 8) & 0xff;
|
||||
}
|
||||
for ($i = 0; $i < 4; ++$i) {
|
||||
$counterBlock[$i + 4] = $nonceMs & 0xff;
|
||||
}
|
||||
// and convert it to a string to go on the front of the ciphertext
|
||||
$ctrTxt = '';
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
$ctrTxt .= chr($counterBlock[$i]);
|
||||
}
|
||||
|
||||
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
|
||||
$keySchedule = self::KeyExpansion($key);
|
||||
|
||||
$blockCount = ceil(strlen($plaintext) / $blockSize);
|
||||
$ciphertxt = array(); // ciphertext as array of strings
|
||||
|
||||
for ($b = 0; $b < $blockCount; ++$b) {
|
||||
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
||||
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
||||
}
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8);
|
||||
}
|
||||
|
||||
$cipherCntr = self::Cipher($counterBlock, $keySchedule); // -- encrypt counter block --
|
||||
|
||||
// block size is reduced on final block
|
||||
$blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1;
|
||||
$cipherByte = array();
|
||||
|
||||
for ($i = 0; $i < $blockLength; ++$i) { // -- xor plaintext with ciphered counter byte-by-byte --
|
||||
$cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1));
|
||||
$cipherByte[$i] = chr($cipherByte[$i]);
|
||||
}
|
||||
$ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext
|
||||
}
|
||||
|
||||
// implode is more efficient than repeated string concatenation
|
||||
$ciphertext = $ctrTxt.implode('', $ciphertxt);
|
||||
$ciphertext = base64_encode($ciphertext);
|
||||
|
||||
return $ciphertext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a text encrypted by AES in counter mode of operation.
|
||||
*
|
||||
* @param ciphertext source text to be decrypted
|
||||
* @param password the password to use to generate a key
|
||||
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
||||
*
|
||||
* @return decrypted text
|
||||
*/
|
||||
public static function AESDecryptCtr($ciphertext, $password, $nBits)
|
||||
{
|
||||
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
||||
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) {
|
||||
return '';
|
||||
} // standard allows 128/192/256 bit keys
|
||||
$ciphertext = base64_decode($ciphertext);
|
||||
|
||||
// use AES to encrypt password (mirroring encrypt routine)
|
||||
$nBytes = $nBits / 8; // no bytes in key
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$key = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
||||
|
||||
// recover nonce from 1st element of ciphertext
|
||||
$counterBlock = array();
|
||||
$ctrTxt = substr($ciphertext, 0, 8);
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
$counterBlock[$i] = ord(substr($ctrTxt, $i, 1));
|
||||
}
|
||||
|
||||
// generate key schedule
|
||||
$keySchedule = self::KeyExpansion($key);
|
||||
|
||||
// separate ciphertext into blocks (skipping past initial 8 bytes)
|
||||
$nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize);
|
||||
$ct = array();
|
||||
for ($b = 0; $b < $nBlocks; ++$b) {
|
||||
$ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16);
|
||||
}
|
||||
$ciphertext = $ct; // ciphertext is now array of block-length strings
|
||||
|
||||
// plaintext will get generated block-by-block into array of block-length strings
|
||||
$plaintxt = array();
|
||||
|
||||
for ($b = 0; $b < $nBlocks; ++$b) {
|
||||
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
||||
}
|
||||
for ($c = 0; $c < 4; ++$c) {
|
||||
$counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff;
|
||||
}
|
||||
|
||||
$cipherCntr = self::Cipher($counterBlock, $keySchedule); // encrypt counter block
|
||||
|
||||
$plaintxtByte = array();
|
||||
for ($i = 0; $i < strlen($ciphertext[$b]); ++$i) {
|
||||
// -- xor plaintext with ciphered counter byte-by-byte --
|
||||
$plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1));
|
||||
$plaintxtByte[$i] = chr($plaintxtByte[$i]);
|
||||
}
|
||||
$plaintxt[$b] = implode('', $plaintxtByte);
|
||||
}
|
||||
|
||||
// join array of blocks into single plaintext string
|
||||
$plaintext = implode('', $plaintxt);
|
||||
|
||||
return $plaintext;
|
||||
}
|
||||
|
||||
/**
|
||||
* AES encryption in CBC mode. This is the standard mode (the CTR methods
|
||||
* actually use Rijndael-128 in CTR mode, which - technically - isn't AES).
|
||||
* The data length is tucked as a 32-bit unsigned integer (little endian)
|
||||
* after the ciphertext. It supports AES-128, AES-192 and AES-256.
|
||||
*
|
||||
* @since 3.0.1
|
||||
*
|
||||
* @author Nicholas K. Dionysopoulos
|
||||
*
|
||||
* @param string $plaintext The data to encrypt
|
||||
* @param string $password Encryption password
|
||||
* @param int $nBits Encryption key size. Can be 128, 192 or 256
|
||||
*
|
||||
* @return string The ciphertext
|
||||
*/
|
||||
public static function AESEncryptCBC($plaintext, $password, $nBits = 128)
|
||||
{
|
||||
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) {
|
||||
return false;
|
||||
} // standard allows 128/192/256 bit keys
|
||||
if (!function_exists('mcrypt_module_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to fetch cached key/iv or create them if they do not exist
|
||||
$lookupKey = $password.'-'.$nBits;
|
||||
if (array_key_exists($lookupKey, self::$passwords)) {
|
||||
$key = self::$passwords[$lookupKey]['key'];
|
||||
$iv = self::$passwords[$lookupKey]['iv'];
|
||||
} else {
|
||||
// use AES itself to encrypt password to get cipher key (using plain password as source for
|
||||
// key expansion) - gives us well encrypted key
|
||||
$nBytes = $nBits / 8; // no bytes in key
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$key = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
||||
$newKey = '';
|
||||
foreach ($key as $int) {
|
||||
$newKey .= chr($int);
|
||||
}
|
||||
$key = $newKey;
|
||||
|
||||
// Create an Initialization Vector (IV) based on the password, using the same technique as for the key
|
||||
$nBytes = 16; // AES uses a 128 -bit (16 byte) block size, hence the IV size is always 16 bytes
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$iv = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$newIV = '';
|
||||
foreach ($iv as $int) {
|
||||
$newIV .= chr($int);
|
||||
}
|
||||
$iv = $newIV;
|
||||
|
||||
self::$passwords[$lookupKey]['key'] = $key;
|
||||
self::$passwords[$lookupKey]['iv'] = $iv;
|
||||
}
|
||||
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
|
||||
mcrypt_generic_init($td, $key, $iv);
|
||||
$ciphertext = mcrypt_generic($td, $plaintext);
|
||||
mcrypt_generic_deinit($td);
|
||||
|
||||
$ciphertext .= pack('V', strlen($plaintext));
|
||||
|
||||
return $ciphertext;
|
||||
}
|
||||
|
||||
/**
|
||||
* AES decryption in CBC mode. This is the standard mode (the CTR methods
|
||||
* actually use Rijndael-128 in CTR mode, which - technically - isn't AES).
|
||||
*
|
||||
* Supports AES-128, AES-192 and AES-256. It supposes that the last 4 bytes
|
||||
* contained a little-endian unsigned long integer representing the unpadded
|
||||
* data length.
|
||||
*
|
||||
* @since 3.0.1
|
||||
*
|
||||
* @author Nicholas K. Dionysopoulos
|
||||
*
|
||||
* @param string $ciphertext The data to encrypt
|
||||
* @param string $password Encryption password
|
||||
* @param int $nBits Encryption key size. Can be 128, 192 or 256
|
||||
*
|
||||
* @return string The plaintext
|
||||
*/
|
||||
public static function AESDecryptCBC($ciphertext, $password, $nBits = 128)
|
||||
{
|
||||
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) {
|
||||
return false;
|
||||
} // standard allows 128/192/256 bit keys
|
||||
if (!function_exists('mcrypt_module_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to fetch cached key/iv or create them if they do not exist
|
||||
$lookupKey = $password.'-'.$nBits;
|
||||
if (array_key_exists($lookupKey, self::$passwords)) {
|
||||
$key = self::$passwords[$lookupKey]['key'];
|
||||
$iv = self::$passwords[$lookupKey]['iv'];
|
||||
} else {
|
||||
// use AES itself to encrypt password to get cipher key (using plain password as source for
|
||||
// key expansion) - gives us well encrypted key
|
||||
$nBytes = $nBits / 8; // no bytes in key
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$key = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
||||
$newKey = '';
|
||||
foreach ($key as $int) {
|
||||
$newKey .= chr($int);
|
||||
}
|
||||
$key = $newKey;
|
||||
|
||||
// Create an Initialization Vector (IV) based on the password, using the same technique as for the key
|
||||
$nBytes = 16; // AES uses a 128 -bit (16 byte) block size, hence the IV size is always 16 bytes
|
||||
$pwBytes = array();
|
||||
for ($i = 0; $i < $nBytes; ++$i) {
|
||||
$pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
||||
}
|
||||
$iv = self::Cipher($pwBytes, self::KeyExpansion($pwBytes));
|
||||
$newIV = '';
|
||||
foreach ($iv as $int) {
|
||||
$newIV .= chr($int);
|
||||
}
|
||||
$iv = $newIV;
|
||||
|
||||
self::$passwords[$lookupKey]['key'] = $key;
|
||||
self::$passwords[$lookupKey]['iv'] = $iv;
|
||||
}
|
||||
|
||||
// Read the data size
|
||||
$data_size = unpack('V', substr($ciphertext, -4));
|
||||
|
||||
// Decrypt
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
|
||||
mcrypt_generic_init($td, $key, $iv);
|
||||
$plaintext = mdecrypt_generic($td, substr($ciphertext, 0, -4));
|
||||
mcrypt_generic_deinit($td);
|
||||
|
||||
// Trim padding, if necessary
|
||||
if (strlen($plaintext) > $data_size) {
|
||||
$plaintext = substr($plaintext, 0, $data_size);
|
||||
}
|
||||
|
||||
return $plaintext;
|
||||
}
|
||||
}
|
||||
281
components/com_jce/editor/libraries/classes/extensions.php
Normal file
281
components/com_jce/editor/libraries/classes/extensions.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?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;
|
||||
// set as an extension parent
|
||||
if (!defined('_WF_EXT')) {
|
||||
define('_WF_EXT', 1);
|
||||
}
|
||||
|
||||
class WFExtension extends JObject
|
||||
{
|
||||
/**
|
||||
* Constructor activating the default information of the class.
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// set extension properties
|
||||
$this->setProperties($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a WFExtension object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $extension = WFExtension::getInstance();</pre>
|
||||
*
|
||||
* @return object WFExtension
|
||||
*/
|
||||
/* public static function getInstance()
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new WFExtension();
|
||||
}
|
||||
return $instance;
|
||||
} */
|
||||
|
||||
/**
|
||||
* Display the extension.
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a plugin extension.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function _load($types = array(), $extension = null, $config = array())
|
||||
{
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$language = JFactory::getLanguage();
|
||||
|
||||
$extensions = array();
|
||||
|
||||
if (!isset($config['base_path'])) {
|
||||
$config['base_path'] = WF_EDITOR;
|
||||
}
|
||||
|
||||
// core extensions path
|
||||
$path = $config['base_path'] . '/extensions';
|
||||
|
||||
// cast as array
|
||||
$types = (array) $types;
|
||||
|
||||
// get all installed plugins
|
||||
$installed = JPluginHelper::getPlugin('jce');
|
||||
|
||||
if (!empty($installed)) {
|
||||
foreach ($installed as $p) {
|
||||
|
||||
// check for delimiter, only load "extensions"
|
||||
if (strpos($p->name, '-') === false || strpos($p->name, 'editor-') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// set path
|
||||
$p->path = JPATH_PLUGINS . '/jce/' . $p->name;
|
||||
|
||||
// get type and name
|
||||
$parts = explode('-', $p->name);
|
||||
$p->folder = $parts[0];
|
||||
$p->extension = $parts[1];
|
||||
|
||||
// load the correct type if set
|
||||
if (!empty($types) && !in_array($p->folder, $types)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// specific extension
|
||||
if ($extension && $p->extension !== $extension) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$language->load('plg_jce_' . $p->name, JPATH_ADMINISTRATOR);
|
||||
$language->load('plg_jce_' . $p->name, $p->path);
|
||||
|
||||
// add to array
|
||||
$extensions[$p->extension] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
// get legacy extensions
|
||||
$legacy = JFolder::folders(WF_EDITOR . '/extensions', '.', false, true);
|
||||
|
||||
$core = array(
|
||||
'aggregator' => array(
|
||||
'dailymotion', 'vimeo', 'youtube',
|
||||
),
|
||||
'filesystem' => array(
|
||||
'joomla',
|
||||
),
|
||||
'links' => array(
|
||||
'joomlalinks',
|
||||
),
|
||||
'popups' => array(
|
||||
'jcemediabox',
|
||||
),
|
||||
'search' => array(
|
||||
'link',
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($legacy as $item) {
|
||||
$type = basename($item);
|
||||
|
||||
// unknown type
|
||||
if (array_key_exists($type, $core) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// load the correct type if set
|
||||
if (!empty($types) && !in_array($type, $types)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// specific extension
|
||||
if ($extension && !JFile::exists($item . '/' . $extension . '.php')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($extension)) {
|
||||
// already loaded as Joomla plugin
|
||||
if (isset($extensions[$extension])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files = array($item . '/' . $extension . '.xml');
|
||||
} else {
|
||||
$files = JFolder::files($item, '\.xml$', false, true);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$extension = basename($file, '.xml');
|
||||
|
||||
// unknown extension
|
||||
if (!in_array($extension, $core[$type])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$object = new stdClass();
|
||||
$object->folder = $type;
|
||||
$object->path = dirname($file);
|
||||
$object->extension = $extension;
|
||||
|
||||
if (!isset($extensions[$extension])) {
|
||||
$extensions[$extension] = $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load & Call an extension.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadExtensions($type, $extension = null, $config = array())
|
||||
{
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
if (!isset($config['base_path'])) {
|
||||
$config['base_path'] = WF_EDITOR;
|
||||
}
|
||||
|
||||
// sanitize $type
|
||||
$type = preg_replace('#[^A-Z0-9\._-]#i', '', $type);
|
||||
|
||||
// sanitize $extension
|
||||
if ($extension) {
|
||||
$extension = preg_replace('#[^A-Z0-9\._-]#i', '', $extension);
|
||||
}
|
||||
|
||||
// Get all extensions
|
||||
$extensions = self::_load((array) $type, $extension, $config);
|
||||
|
||||
$result = array();
|
||||
|
||||
if (!empty($extensions)) {
|
||||
foreach ($extensions as $item) {
|
||||
$name = isset($item->extension) ? $item->extension : '';
|
||||
|
||||
$type = $item->folder;
|
||||
$path = $item->path;
|
||||
|
||||
if ($name) {
|
||||
$root = $path . '/' . basename($path) . '.php';
|
||||
|
||||
// store name in item object
|
||||
$item->name = $name;
|
||||
|
||||
// legacy - clean defined path for Windows!!
|
||||
if (WFUtility::cleanPath(dirname($path)) === WFUtility::cleanPath(WF_EDITOR_EXTENSIONS)) {
|
||||
$root = $path . '/' . $name . '.php';
|
||||
// redefine path
|
||||
$item->path = $path . '/' . $name;
|
||||
}
|
||||
|
||||
if (file_exists($root)) {
|
||||
// Load root extension file
|
||||
require_once $root;
|
||||
|
||||
// Return array of extension names
|
||||
$result[$type][] = $item;
|
||||
|
||||
// if we only want a named extension
|
||||
if ($extension && $extension == $name) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only return extension types requested
|
||||
if ($type && array_key_exists($type, $result)) {
|
||||
return $result[$type];
|
||||
}
|
||||
|
||||
// Return array or extension name
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a parameter for the current plugin / group.
|
||||
*
|
||||
* @param object $key Parameter name
|
||||
* @param object $default Default value
|
||||
*
|
||||
* @return string Parameter value
|
||||
*/
|
||||
public function getParam($key, $default = '')
|
||||
{
|
||||
$wf = WFApplication::getInstance();
|
||||
|
||||
return $wf->getParam($key, $default);
|
||||
}
|
||||
|
||||
public function getView($options = array())
|
||||
{
|
||||
return new WFView($options);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
241
components/com_jce/editor/libraries/classes/extensions/link.php
Normal file
241
components/com_jce/editor/libraries/classes/extensions/link.php
Normal 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('&', '<', '>', ''', '"'), $string);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class WFLinkBrowser extends WFLinkExtension
|
||||
{
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
1
components/com_jce/editor/libraries/classes/index.html
Normal file
1
components/com_jce/editor/libraries/classes/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
81
components/com_jce/editor/libraries/classes/language.php
Normal file
81
components/com_jce/editor/libraries/classes/language.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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
|
||||
*/
|
||||
abstract class WFLanguage
|
||||
{
|
||||
/* Map language code to generic tag */
|
||||
protected static $map = array(
|
||||
'de' => 'de-DE',
|
||||
'fr' => 'fr-FR',
|
||||
);
|
||||
|
||||
/*
|
||||
* Check a language file exists and is the correct version
|
||||
*/
|
||||
protected static function isValid($tag)
|
||||
{
|
||||
return file_exists(JPATH_SITE . '/language/' . $tag . '/' . $tag . '.com_jce.ini');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the curernt language code.
|
||||
*
|
||||
* @return language code
|
||||
*/
|
||||
public static function getDir()
|
||||
{
|
||||
return JFactory::getLanguage()->isRTL() ? 'rtl' : 'ltr';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the curernt language code.
|
||||
*
|
||||
* @return language code
|
||||
*/
|
||||
public static function getTag()
|
||||
{
|
||||
$tag = JFactory::getLanguage()->getTag();
|
||||
|
||||
$code = substr($tag, 0, strpos($tag, '-'));
|
||||
|
||||
if (array_key_exists($code, self::$map)) {
|
||||
$tag = self::$map[$code];
|
||||
}
|
||||
|
||||
if (false == self::isValid($tag)) {
|
||||
return 'en-GB';
|
||||
}
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the curernt language code.
|
||||
*
|
||||
* @return language code
|
||||
*/
|
||||
public static function getCode()
|
||||
{
|
||||
$tag = self::getTag();
|
||||
|
||||
return substr($tag, 0, strpos($tag, '-'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a language file.
|
||||
*
|
||||
* @param string $prefix Language prefix
|
||||
* @param object $path[optional] Base path
|
||||
*/
|
||||
public static function load($prefix, $path = JPATH_SITE)
|
||||
{
|
||||
JFactory::getLanguage()->load($prefix, $path);
|
||||
}
|
||||
}
|
||||
415
components/com_jce/editor/libraries/classes/languageparser.php
Normal file
415
components/com_jce/editor/libraries/classes/languageparser.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?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 WFLanguageParser extends JObject
|
||||
{
|
||||
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 = JFactory::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 (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) {
|
||||
// add English file
|
||||
$ini = JPATH_ADMINISTRATOR . '/language/en-GB/en-GB.plg_jce_editor_' . $name . '.ini';
|
||||
|
||||
if (is_file($ini)) {
|
||||
$files[] = $ini;
|
||||
}
|
||||
|
||||
// non-english language
|
||||
if ($tag != 'en-GB') {
|
||||
$ini = JPATH_ADMINISTRATOR . '/language/' . $tag . '/' . $tag . '.plg_jce_editor_' . $name . '.ini';
|
||||
|
||||
if (is_file($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();
|
||||
}
|
||||
}
|
||||
74
components/com_jce/editor/libraries/classes/linkhelper.php
Normal file
74
components/com_jce/editor/libraries/classes/linkhelper.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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('RESTRICTED');
|
||||
|
||||
abstract class WFLinkHelper
|
||||
{
|
||||
/**
|
||||
* Translates an internal Joomla URL to a humanly readible URL.
|
||||
*
|
||||
* @param string $url Absolute or Relative URI to Joomla resource
|
||||
*
|
||||
* @return The translated humanly readible URL
|
||||
*/
|
||||
public static function route($url)
|
||||
{
|
||||
$app = Joomla\CMS\Application\CMSApplication::getInstance('site');
|
||||
$router = $app->getRouter('site');
|
||||
|
||||
if (!$router) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$uri = $router->build($url);
|
||||
$url = $uri->toString();
|
||||
$url = str_replace('/administrator/', '/', $url);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function removeItemId($url)
|
||||
{
|
||||
$url = preg_replace('#&Itemid=[0-9]+#', '', $url);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function removeHomeItemId($url) {
|
||||
if (strpos($url, 'Itemid') === false) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$parsed = parse_url($url, PHP_URL_QUERY);
|
||||
$parsed = str_replace('&', '&', $parsed);
|
||||
|
||||
parse_str($parsed, $vars);
|
||||
|
||||
if (!array_key_exists('Itemid', $vars)) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// get menus
|
||||
$menus = JFactory::getApplication()->getMenu('site');
|
||||
// get "default" menu
|
||||
$default = $menus->getDefault();
|
||||
|
||||
// Itemid is unique
|
||||
if ($default->id != $vars['Itemid']) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// remove "default" Itemid
|
||||
$url = self::removeItemId($url);
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
14
components/com_jce/editor/libraries/classes/manager.php
Normal file
14
components/com_jce/editor/libraries/classes/manager.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?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
|
||||
*/
|
||||
if (is_dir(WF_EDITOR_LIBRARIES.'/pro')) {
|
||||
require_once WF_EDITOR_LIBRARIES.'/pro/classes/manager.php';
|
||||
} else {
|
||||
require_once __DIR__.'/manager/manager.php';
|
||||
}
|
||||
275
components/com_jce/editor/libraries/classes/manager/base.php
Normal file
275
components/com_jce/editor/libraries/classes/manager/base.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?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 WFMediaManagerBase extends WFEditorPlugin
|
||||
{
|
||||
protected $_filetypes = 'jpg,jpeg,png,gif';
|
||||
|
||||
private static $browser = array();
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
// use the full "manager" layout by default
|
||||
if (!array_key_exists('layout', $config)) {
|
||||
$config['layout'] = 'manager';
|
||||
}
|
||||
|
||||
if (!array_key_exists('view_path', $config)) {
|
||||
$config['view_path'] = WF_EDITOR_LIBRARIES . '/views/plugin';
|
||||
}
|
||||
|
||||
if (!array_key_exists('template_path', $config)) {
|
||||
$config['template_path'] = WF_EDITOR_LIBRARIES . '/views/plugin/tmpl';
|
||||
}
|
||||
|
||||
// Call parent
|
||||
parent::__construct($config);
|
||||
|
||||
// initialize the browser
|
||||
$browser = $this->getFileBrowser();
|
||||
$request = WFRequest::getInstance();
|
||||
|
||||
// Setup plugin XHR callback functions
|
||||
$request->setRequest(array($this, 'getDimensions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the File Browser instance.
|
||||
*
|
||||
* @return object WFBrowserExtension
|
||||
*/
|
||||
public function getFileBrowser()
|
||||
{
|
||||
$name = $this->getName();
|
||||
$caller = $this->get('caller');
|
||||
|
||||
// add caller if set
|
||||
if ($caller) {
|
||||
$name .= '.' . $caller;
|
||||
}
|
||||
|
||||
if (!isset(self::$browser[$name])) {
|
||||
self::$browser[$name] = new WFFileBrowser($this->getFileBrowserConfig());
|
||||
}
|
||||
|
||||
return self::$browser[$name];
|
||||
}
|
||||
|
||||
protected function addFileBrowserAction($name, $options = array())
|
||||
{
|
||||
$this->getFileBrowser()->addAction($name, $options);
|
||||
}
|
||||
|
||||
protected function addFileBrowserButton($type, $name, $options = array())
|
||||
{
|
||||
$this->getFileBrowser()->addButton($type, $name, $options);
|
||||
}
|
||||
|
||||
protected function addFileBrowserEvent($name, $function = array())
|
||||
{
|
||||
$this->getFileBrowser()->addEvent($name, $function);
|
||||
}
|
||||
|
||||
public function getBrowser()
|
||||
{
|
||||
return $this->getFileBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin.
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
parent::display();
|
||||
|
||||
$document = WFDocument::getInstance();
|
||||
|
||||
$view = $this->getView();
|
||||
$browser = $this->getFileBrowser();
|
||||
|
||||
$browser->display();
|
||||
$view->filebrowser = $browser;
|
||||
|
||||
$options = $browser->getProperties();
|
||||
|
||||
// process options array
|
||||
$browser->getFileSystem()->updateOptions($options);
|
||||
|
||||
// set global options
|
||||
$document->addScriptDeclaration('FileBrowser.options=' . json_encode($options) . ';');
|
||||
}
|
||||
|
||||
public function getFileTypes($format = 'array', $list = '')
|
||||
{
|
||||
return $this->getFileBrowser()->getFileTypes($format, $list);
|
||||
}
|
||||
|
||||
protected function setFileTypes($filetypes)
|
||||
{
|
||||
return $this->getFileBrowser()->setFileTypes($filetypes);
|
||||
}
|
||||
|
||||
private function getFileSystem()
|
||||
{
|
||||
$filesystem = $this->getParam('filesystem.name', '');
|
||||
|
||||
// if an object, get the name
|
||||
if (is_object($filesystem)) {
|
||||
$filesystem = isset($filesystem->name) ? $filesystem->name : 'joomla';
|
||||
}
|
||||
|
||||
// if no value, default to "joomla"
|
||||
if (empty($filesystem)) {
|
||||
$filesystem = 'joomla';
|
||||
}
|
||||
|
||||
return $filesystem;
|
||||
}
|
||||
|
||||
public function onUpload($file, $relative = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function getDimensions($file)
|
||||
{
|
||||
$browser = $this->getFileBrowser();
|
||||
$filesystem = $browser->getFileSystem();
|
||||
|
||||
$path = WFUtility::makePath($filesystem->getBaseDir(), rawurldecode($file));
|
||||
|
||||
$data = array();
|
||||
|
||||
// images and flash
|
||||
if (preg_match('#\.(jpg|jpeg|png|apng|gif|bmp|wbmp|tif|tiff|psd|ico|webp|swf)$#i', $file)) {
|
||||
list($data['width'], $data['height']) = getimagesize($path);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// svg
|
||||
if (preg_match('#\.svg$#i', $file)) {
|
||||
$svg = @simplexml_load_file($path);
|
||||
|
||||
if ($svg && isset($svg['viewBox'])) {
|
||||
list($start_x, $start_y, $end_x, $end_y) = explode(' ', $svg['viewBox']);
|
||||
|
||||
$width = (int) $end_x;
|
||||
$height = (int) $end_y;
|
||||
|
||||
if ($width && $height) {
|
||||
$data['width'] = $width;
|
||||
$data['height'] = $height;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Media Manager configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getFileBrowserConfig($config = array())
|
||||
{
|
||||
$filetypes = $this->getParam('extensions', $this->get('_filetypes'));
|
||||
$textcase = $this->getParam('editor.websafe_textcase', '');
|
||||
|
||||
// implode textcase array to create string
|
||||
if (is_array($textcase)) {
|
||||
$textcase = array_filter($textcase, 'strlen');
|
||||
$textcase = implode(',', $textcase);
|
||||
}
|
||||
|
||||
$filter = $this->getParam('editor.dir_filter', array());
|
||||
|
||||
// explode to array if string - 2.7.x...2.7.11
|
||||
if (!is_array($filter)) {
|
||||
$filter = explode(',', $filter);
|
||||
}
|
||||
|
||||
// remove empty values
|
||||
$filter = array_filter((array) $filter);
|
||||
|
||||
// get base directory from editor parameter
|
||||
$baseDir = $this->getParam('editor.dir', '', '', false);
|
||||
|
||||
// get directory from plugin parameter, fallback to base directory as it cannot itself be empty
|
||||
$dir = $this->getParam($this->getName() . '.dir', $baseDir);
|
||||
|
||||
// get websafe spaces parameter and convert legacy values
|
||||
$websafe_spaces = $this->getParam('editor.websafe_allow_spaces', '_');
|
||||
|
||||
if (is_numeric($websafe_spaces)) {
|
||||
// legacy replacement
|
||||
if ($websafe_spaces == 0) {
|
||||
$websafe_spaces = '_';
|
||||
}
|
||||
// convert to space
|
||||
if ($websafe_spaces == 1) {
|
||||
$websafe_spaces = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
// fix legacy list limit value
|
||||
$list_limit = $this->getParam('editor.list_limit', 0);
|
||||
|
||||
// convert "all" to 0
|
||||
if (!is_numeric($list_limit)) {
|
||||
$list_limit = 0;
|
||||
}
|
||||
|
||||
$base = array(
|
||||
'dir' => $dir,
|
||||
'filesystem' => $this->getFileSystem(),
|
||||
'filetypes' => $filetypes,
|
||||
'filter' => $filter,
|
||||
'upload' => array(
|
||||
'max_size' => $this->getParam('max_size', 1024),
|
||||
'validate_mimetype' => (int) $this->getParam('editor.validate_mimetype', 1),
|
||||
'add_random' => (int) $this->getParam('editor.upload_add_random', 0),
|
||||
'total_files' => (float) $this->getParam('editor.total_files', 0),
|
||||
'total_size' => (float) $this->getParam('editor.total_size', 0),
|
||||
'remove_exif' => (int) $this->getParam('editor.upload_remove_exif', 0),
|
||||
),
|
||||
'folder_tree' => $this->getParam('editor.folder_tree', 1),
|
||||
'list_limit' => $list_limit,
|
||||
'features' => array(
|
||||
'upload' => $this->getParam('upload', 1),
|
||||
'folder' => array(
|
||||
'create' => $this->getParam('folder_new', 1),
|
||||
'delete' => $this->getParam('folder_delete', 1),
|
||||
'rename' => $this->getParam('folder_rename', 1),
|
||||
'move' => $this->getParam('folder_move', 1),
|
||||
),
|
||||
'file' => array(
|
||||
'delete' => $this->getParam('file_delete', 1),
|
||||
'rename' => $this->getParam('file_rename', 1),
|
||||
'move' => $this->getParam('file_move', 1),
|
||||
),
|
||||
),
|
||||
'websafe_mode' => $this->getParam('editor.websafe_mode', 'utf-8'),
|
||||
'websafe_spaces' => $websafe_spaces,
|
||||
'websafe_textcase' => $textcase,
|
||||
'date_format' => $this->getParam('editor.date_format', '%d/%m/%Y, %H:%M'),
|
||||
'position' => $this->getParam('editor.filebrowser_position', $this->getParam('editor.browser_position', 'bottom')),
|
||||
'use_state_cookies' => $this->getParam('editor.use_cookies', true),
|
||||
'search_depth' => $this->getParam('editor.filebrowser_search_depth', 3),
|
||||
'allow_download' => $this->getParam('allow_download', 0)
|
||||
);
|
||||
|
||||
return WFUtility::array_merge_recursive_distinct($base, $config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user