primo commit
This commit is contained in:
145
plugins/editors-xtd/retabulizer/retabulizer.php
Normal file
145
plugins/editors-xtd/retabulizer/retabulizer.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* @version 6.2.6 tabulizer $
|
||||
* @package tabulizer
|
||||
* @copyright Copyright © 2011 - All rights reserved.
|
||||
* @license GNU/GPL
|
||||
* @author Dimitrios Mourloukos
|
||||
* @author mail info@alterora.gr
|
||||
* @website www.tabulizer.com
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport( 'joomla.plugin.plugin' );
|
||||
|
||||
if(!defined('DS')){define('DS',DIRECTORY_SEPARATOR);}
|
||||
|
||||
|
||||
class plgButtonRetabulizer extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(& $subject, $config)
|
||||
{
|
||||
parent::__construct($subject, $config);
|
||||
$this->loadLanguage();
|
||||
}
|
||||
|
||||
public function onDisplay($name, $asset = null, $author = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$doc = JFactory::getDocument();
|
||||
$template = $app->getTemplate();
|
||||
|
||||
if(version_compare(JVERSION,'1.6.0','ge')) {
|
||||
$tabulizer_plugin = JPluginHelper::getPlugin('editors-xtd', 'tabulizer');
|
||||
$tabulizerPluginParams = new JRegistry();
|
||||
$tabulizerPluginParams->loadString($tabulizer_plugin->params);
|
||||
$tabulizer_directive_add_comments = 0;
|
||||
} else {
|
||||
$tabulizer_plugin = &JPluginHelper::getPlugin('editors-xtd', 'tabulizer');
|
||||
$tabulizerPluginParams = new JRegistry($tabulizer_plugin->params);
|
||||
$tabulizer_directive_add_comments = 0;
|
||||
}
|
||||
|
||||
$popup_url = JURI::base() . 'index.php?option=com_tabulizer&task=dialog&tmpl=component&use_comments='.$tabulizer_directive_add_comments;
|
||||
|
||||
$tinymce_warning_msg = JText::_('PLG_RETABULIZER_INVALID_EDITOR');
|
||||
|
||||
require_once(JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_tabulizer'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'helper.php');
|
||||
$no_use_permissions = (TabulizerPermissions::isAllowed('ruleset-use'))?0:1;
|
||||
$no_use_permissions_warning_msg = TabulizerString::makeHTMLSafe(JText::_('PLG_RETABULIZER_RULESET_USE_PERMISSION_INVALID'));
|
||||
|
||||
$setOriginalContent = $this->_subject->setContent($name, 'original_content' );
|
||||
$setNewContent = $this->_subject->setContent($name, 'new_content' );
|
||||
|
||||
// remove surrounding quotes, if present
|
||||
$quotes = array('"',"'");
|
||||
foreach ($quotes as $quote) {
|
||||
$setOriginalContent = str_replace("{$quote}original_content{$quote}","original_content",$setOriginalContent);
|
||||
$setNewContent = str_replace("{$quote}new_content{$quote}","new_content",$setNewContent);
|
||||
}
|
||||
|
||||
$js = "
|
||||
|
||||
function retabulizerGetCaretPosition (editor)
|
||||
{
|
||||
var LOCATION_TOKEN = '{TABULIZER-CARET-POSITION-MARK-F6ZX7E39DE6G}';
|
||||
var original_content = ".$this->_subject->getContent($name)."
|
||||
jInsertEditorText( LOCATION_TOKEN, editor );
|
||||
var content = ".$this->_subject->getContent($name)."
|
||||
var caret_position = content.indexOf(LOCATION_TOKEN);
|
||||
{$setOriginalContent}
|
||||
|
||||
return caret_position;
|
||||
}
|
||||
|
||||
function retabulizerGetEditorContent ()
|
||||
{
|
||||
var content = ".$this->_subject->getContent($name)."
|
||||
return content;
|
||||
}
|
||||
|
||||
function retabulizerOpenDialog( editor )
|
||||
{
|
||||
if ($no_use_permissions) {
|
||||
alert('{$no_use_permissions_warning_msg}');
|
||||
return;
|
||||
}
|
||||
var caret_position = retabulizerGetCaretPosition (editor);
|
||||
var durl = '{$popup_url}&clb_name=' + editor + '&caret_position=' + caret_position;
|
||||
var wnd = window.open( durl, '_blank', 'status=no,resizable=yes,width=720,height=680,left=50,top=50' );
|
||||
wnd.focus();
|
||||
return wnd;
|
||||
}
|
||||
|
||||
function retabulizerClickCallback( editor, result, replace_from, replace_to )
|
||||
{
|
||||
if (result) {
|
||||
var r1 = parseInt(replace_from);
|
||||
var r2 = parseInt(replace_to);
|
||||
|
||||
var content = ".$this->_subject->getContent($name)."
|
||||
var new_content = content.substr(0,r1) + result + content.substr(r2+1);
|
||||
$setNewContent
|
||||
}
|
||||
}
|
||||
";
|
||||
|
||||
$doc->addScriptDeclaration($js);
|
||||
|
||||
if(version_compare(JVERSION,'1.6.0','ge')) {
|
||||
// Joomla! 1.6 code here
|
||||
$plugin_dir = 'plugins/editors-xtd/tabulizer/tabulizer';
|
||||
} else {
|
||||
// Joomla! 1.5 code here
|
||||
$plugin_dir = 'plugins/editors-xtd/tabulizer';
|
||||
}
|
||||
|
||||
$css = " .button2-left .Retabulizer { background: url(../{$plugin_dir}/images/retabulizer_button.png) 100% 0 no-repeat; } \n";
|
||||
$css .= " .icon-Retabulizer { background: url(../{$plugin_dir}/images/retabulizer_button_j3.png) 100% 0 no-repeat; } \n";
|
||||
|
||||
$doc->addStyleDeclaration($css);
|
||||
|
||||
$button = new JObject();
|
||||
$button->set('modal', false);
|
||||
$button->set('onclick', 'retabulizerOpenDialog(\''.$name.'\'); return false;');
|
||||
$button->set('text', JText::_('PLG_RETABULIZER_BUTTON_LABEL'));
|
||||
$button->set('name', 'Retabulizer');
|
||||
$button->set('link', '#');
|
||||
if(version_compare(JVERSION,'3.1.0','ge')) {
|
||||
$button->set('class','btn');
|
||||
}
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
20
plugins/editors-xtd/retabulizer/retabulizer.xml
Normal file
20
plugins/editors-xtd/retabulizer/retabulizer.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="1.5" group="editors-xtd" method="upgrade">
|
||||
<name>Button - ReTabulizer</name>
|
||||
<creationDate>2019-01-17</creationDate>
|
||||
<copyright>Copyright (C) 2011. All rights reserved.</copyright>
|
||||
<license>GNU General Public License</license>
|
||||
<author>Dimitrios Mourloukos</author>
|
||||
<authorEmail>info@alterora.gr</authorEmail>
|
||||
<authorUrl>www.tabulizer.gr</authorUrl>
|
||||
<version>6.2.6</version>
|
||||
|
||||
<description>PLG_RETABULIZER_DESCRIPTION</description>
|
||||
<files>
|
||||
<filename plugin="retabulizer">retabulizer.php</filename>
|
||||
</files>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_editors-xtd_retabulizer.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_editors-xtd_retabulizer.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
Reference in New Issue
Block a user