first commit
This commit is contained in:
7
plugins/system/j2xml/install.mysql.sql
Normal file
7
plugins/system/j2xml/install.mysql.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Enable the plugin:
|
||||
|
||||
UPDATE `#__extensions`
|
||||
SET `enabled` = 1
|
||||
WHERE `type` = 'plugin'
|
||||
AND `folder` = 'system'
|
||||
AND `element` = 'j2xml';
|
||||
7
plugins/system/j2xml/install.postgresql.sql
Normal file
7
plugins/system/j2xml/install.postgresql.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Enable the plugin:
|
||||
|
||||
UPDATE "#__extensions"
|
||||
SET "enabled" = 1
|
||||
WHERE "type" = 'plugin'
|
||||
AND "folder" = 'system'
|
||||
AND "element" = 'j2xml';
|
||||
344
plugins/system/j2xml/j2xml.php
Normal file
344
plugins/system/j2xml/j2xml.php
Normal file
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 1.5
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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.
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die('Restricted access.');
|
||||
|
||||
JLoader::import('eshiol.J2xml.Exporter');
|
||||
JLoader::import('eshiol.J2xml.Sender');
|
||||
|
||||
JLoader::register('eshiol\\J2xml\\Helper\\Joomla', __DIR__ . '/src/J2xml/Helper/Joomla.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class plgSystemJ2xml extends JPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Application object.
|
||||
*
|
||||
* @var JApplicationCms
|
||||
* @since 3.9.0
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $subject
|
||||
* The object to observe
|
||||
* @param array $config
|
||||
* An array that holds the plugin configuration
|
||||
*/
|
||||
function __construct(&$subject, $config)
|
||||
{
|
||||
parent::__construct($subject, $config);
|
||||
|
||||
$cparams = JComponentHelper::getParams('com_j2xml');
|
||||
if ($this->params->get('debug', $cparams->get('debug', false)) || defined('JDEBUG') && JDEBUG)
|
||||
{
|
||||
JLog::addLogger(
|
||||
array('text_file' => $this->params->get('log', 'eshiol.log.php'), 'extension' => 'plg_system_j2xml_file'),
|
||||
JLog::ALL,
|
||||
array('plg_system_j2xml'));
|
||||
}
|
||||
if (PHP_SAPI == 'cli')
|
||||
{
|
||||
JLog::addLogger(
|
||||
array('logger' => 'echo', 'extension' => 'plg_system_j2xml'),
|
||||
JLog::ALL & ~ JLog::DEBUG,
|
||||
array('plg_system_j2xml'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JLog::addLogger(
|
||||
array('logger' => (null !== $this->params->get('logger')) ? $this->params->get('logger') : 'messagequeue', 'extension' => 'plg_system_j2xml'),
|
||||
JLog::ALL & ~ JLog::DEBUG,
|
||||
array('plg_system_j2xml'));
|
||||
}
|
||||
JLog::add(new JLogEntry(__METHOD__, JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
$version = new JVersion();
|
||||
|
||||
if (!$version->isCompatible('4'))
|
||||
{
|
||||
// overwrite original Joomla
|
||||
$loader = require JPATH_LIBRARIES . '/vendor/autoload.php';
|
||||
|
||||
// update class maps
|
||||
$classMap = $loader->getClassMap();
|
||||
if ($version->isCompatible('3.8'))
|
||||
{
|
||||
$classMap['Joomla\CMS\Layout\FileLayout'] = __DIR__ . '/src/joomla/src/Layout/FileLayout.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
$classMap['JLayoutFile'] = __DIR__ . '/src/joomla/cms/layout/file.php';
|
||||
}
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
|
||||
// Only render in backend
|
||||
if ($version->isCompatible('3.7'))
|
||||
{
|
||||
if (!$this->app->isClient('administrator'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$this->app->isAdmin())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Only render if J2XML is installed and enabled
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('enabled'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('name') . ' = ' . $db->quote('com_j2xml'));
|
||||
JLog::add(new JLogEntry($query, JLog::DEBUG, 'plg_system_j2xml'));
|
||||
$is_enabled = $db->setQuery($query)->loadResult();
|
||||
if (!$is_enabled)
|
||||
{
|
||||
JLog::add(new JLogEntry(JText::sprintf('PLG_SYSTEM_J2XML_MSG_REQUIREMENTS_COM', JText::_('PLG_SYSTEM_J2XML')), JLog::WARNING, 'plg_system_j2xml'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method is called by index.php and administrator/index.php
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function onAfterDispatch()
|
||||
{
|
||||
JLog::add(new JLogEntry(__METHOD__, JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
if ($this->app->input->get('format') == 'xmlrpc')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only render for HTML output.
|
||||
if (JFactory::getDocument()->getType() !== 'html')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only render in backend
|
||||
$version = new JVersion();
|
||||
|
||||
if ($version->isCompatible('3.7'))
|
||||
{
|
||||
if (!$this->app->isClient('administrator'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$this->app->isAdmin())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Only render if J2XML is installed and enabled
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('enabled'))
|
||||
->from('#__extensions')
|
||||
->where($db->quoteName('name') . ' = ' . $db->quote('com_j2xml'));
|
||||
JLog::add(new JLogEntry($query, JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
$is_enabled = $db->setQuery($query)->loadResult();
|
||||
if (!$is_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$input = $this->app->input;
|
||||
$option = $input->get('option');
|
||||
$contentType = substr($option, 4);
|
||||
|
||||
$allowedView = $contentType;
|
||||
if (substr($allowedView, -1) != 's')
|
||||
{
|
||||
$allowedView .= 's';
|
||||
}
|
||||
$view = $input->get('view', $allowedView);
|
||||
|
||||
if ($contentType == 'content')
|
||||
{
|
||||
if (($view != 'contents') && ($view != 'articles') && ($view != 'featured'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($contentType == 'users')
|
||||
{
|
||||
if ($view == 'notes')
|
||||
{
|
||||
$contentType = 'usernotes';
|
||||
}
|
||||
elseif ($view != $allowedView)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
elseif ($view != $allowedView)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only render if J2XML view exists and J2XML Library is loaded
|
||||
if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_j2xml/views/' . $contentType . '/view.raw.php'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_j2xml/views/export/tmpl/' . $contentType . '.php'))
|
||||
{
|
||||
if (class_exists('eshiol\\J2xml\\Exporter') && method_exists('eshiol\\J2xml\\Exporter', $contentType))
|
||||
{
|
||||
$bar = JToolbar::getInstance('toolbar');
|
||||
|
||||
$version = new JVersion();
|
||||
if ($version->isCompatible('4'))
|
||||
{
|
||||
$buttonClass = 'button-download btn btn-sm';
|
||||
|
||||
foreach ($bar->getItems() as $button)
|
||||
{
|
||||
if (gettype($button) != 'array')
|
||||
{
|
||||
if ($button->getName() == 'status-group')
|
||||
{
|
||||
$bar = $button->getChildToolbar();
|
||||
$buttonClass = 'button-download dropdown-item';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$iconExport = 'icon-download';
|
||||
$iconSend = 'icon-out';
|
||||
$layout = new JLayoutFile('joomla4.toolbar.modal');
|
||||
}
|
||||
else
|
||||
{
|
||||
$buttonClass = 'btn btn-small';
|
||||
$iconExport = 'download';
|
||||
$iconSend = 'out';
|
||||
$layout = new JLayoutFile('joomla.toolbar.modal');
|
||||
}
|
||||
|
||||
$layout->addIncludePath(JPATH_PLUGINS . '/system/j2xml/layouts');
|
||||
$selector = 'j2xmlExport';
|
||||
$dHtml = $layout->render(
|
||||
array(
|
||||
'selector' => $selector,
|
||||
'icon' => $iconExport,
|
||||
'text' => JText::_('JTOOLBAR_EXPORT'),
|
||||
'title' => JText::_('PLG_SYSTEM_J2XML_EXPORT_' . strtoupper($contentType)),
|
||||
'class' => $buttonClass,
|
||||
'doTask' => JRoute::_('index.php?option=com_j2xml&view=export&layout=' . $contentType . '&format=html&tmpl=component'),
|
||||
'ok' => JText::_('JTOOLBAR_EXPORT'),
|
||||
'onclick' => 'var cids=new Array();jQuery(\'input:checkbox[name=\\\'cid\[\]\\\']:checked\').each( function(){cids.push(jQuery(this).val());});jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#jform_cid\').val(cids);'
|
||||
));
|
||||
|
||||
$bar->appendButton('Custom', $dHtml, 'download');
|
||||
|
||||
if ($version->isCompatible('3.9'))
|
||||
{
|
||||
$lib_xmlrpc = 'eshiol/phpxmlrpc';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lib_xmlrpc = 'phpxmlrpc';
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('extension_id'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('library'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($lib_xmlrpc));
|
||||
JLog::add(new JLogEntry($query, JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
if ($db->setQuery($query)->loadResult() && JLibraryHelper::isEnabled($lib_xmlrpc))
|
||||
{
|
||||
JText::script('LIB_J2XML_ERROR_UNKNOWN');
|
||||
|
||||
$layout->addIncludePath(JPATH_PLUGINS . '/system/j2xml/layout');
|
||||
$selector = 'j2xmlSend';
|
||||
$dHtml = $layout->render(
|
||||
array(
|
||||
'selector' => $selector,
|
||||
'icon' => $iconSend,
|
||||
'text' => JText::_('PLG_SYSTEM_J2XML_BUTTON_SEND'),
|
||||
'title' => JText::_('PLG_SYSTEM_J2XML_SEND_' . strtoupper($contentType)),
|
||||
'class' => $buttonClass,
|
||||
'doTask' => JRoute::_('index.php?option=com_j2xml&view=send&layout=' . $contentType . '&format=html&tmpl=component'),
|
||||
'ok' => JText::_('PLG_SYSTEM_J2XML_BUTTON_SEND'),
|
||||
'onclick' => 'var cids=new Array();jQuery(\'input:checkbox[name=\\\'cid\[\]\\\']:checked\').each( function(){cids.push(jQuery(this).val());});jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#jform_cid\').val(cids);',
|
||||
'formValidation' => true
|
||||
));
|
||||
$bar->appendButton('Custom', $dHtml, 'send');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger the onAfterDispatch event.
|
||||
// JPluginHelper::importPlugin('j2xml');
|
||||
// JFactory::getApplication()->triggerEvent('onLoadJS');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an assets for debugger.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onBeforeCompileHead()
|
||||
{
|
||||
// $version = new JVersion();
|
||||
$version = new Joomla\CMS\Version();
|
||||
|
||||
if ($version->isCompatible( '4' ))
|
||||
{
|
||||
// Use our own jQuery and fontawesome instead of the debug bar shipped version
|
||||
$assetManager = $this->app->getDocument()->getWebAssetManager();
|
||||
$assetManager->useScript('core')->useScript('jquery');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
44
plugins/system/j2xml/j2xml.xml
Normal file
44
plugins/system/j2xml/j2xml.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" group="system" method="upgrade">
|
||||
<name>plg_system_j2xml</name>
|
||||
<description>PLG_SYSTEM_J2XML_XML_DESCRIPTION</description>
|
||||
<author>Helios Ciancio</author>
|
||||
<authorEmail>info (at) eshiol (dot) it</authorEmail>
|
||||
<authorUrl>www.eshiol.it</authorUrl>
|
||||
<creationDate>06 March 2023</creationDate>
|
||||
<copyright><![CDATA[(C) 2010 - 2023 Helios Ciancio. All Rights Reserved.]]></copyright>
|
||||
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3</license>
|
||||
<version>3.9.229-rc1</version>
|
||||
<files>
|
||||
<filename plugin="j2xml">j2xml.php</filename>
|
||||
<filename>install.mysql.sql</filename>
|
||||
<filename>install.postgresql.sql</filename>
|
||||
<folder>layouts</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<install>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">install.mysql.sql</file>
|
||||
<file driver="postgresql" charset="utf8">install.postgresql.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_system_j2xml.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_system_j2xml.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="debug" label="PLG_SYSTEM_J2XML_DEBUG_SYSTEM_LABEL">
|
||||
<field name="debug" type="list" default="" filter="integer"
|
||||
description="PLG_SYSTEM_J2XML_DEBUG_SYSTEM_DESC" label="PLG_SYSTEM_J2XML_DEBUG_SYSTEM_LABEL">
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="log" type="text" label="PLG_SYSTEM_J2XML_DEBUG_FILENAME_LABEL"
|
||||
description="PLG_SYSTEM_J2XML_DEBUG_FILENAME_DESC" default="eshiol.log.php"
|
||||
showon="debug:1" />
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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('_JEXEC') or die;
|
||||
|
||||
extract($displayData);
|
||||
|
||||
/**
|
||||
* Layout variables
|
||||
* -----------------
|
||||
* @var string $autocomplete Autocomplete attribute for the field.
|
||||
* @var boolean $autofocus Is autofocus enabled?
|
||||
* @var string $class Classes for the input.
|
||||
* @var string $description Description of the field.
|
||||
* @var boolean $disabled Is this field disabled?
|
||||
* @var string $group Group the field belongs to. <fields> section in form XML.
|
||||
* @var boolean $hidden Is this field hidden in the form?
|
||||
* @var string $hint Placeholder for the field.
|
||||
* @var string $id DOM id of the field.
|
||||
* @var string $label Label of the field.
|
||||
* @var string $labelclass Classes to apply to the label.
|
||||
* @var boolean $multiple Does this field support multiple values?
|
||||
* @var string $name Name of the input field.
|
||||
* @var string $onchange Onchange attribute for the field.
|
||||
* @var string $onclick Onclick attribute for the field.
|
||||
* @var string $pattern Pattern (Reg Ex) of value of the form field.
|
||||
* @var boolean $readonly Is this field read only?
|
||||
* @var boolean $repeat Allows extensions to duplicate elements.
|
||||
* @var boolean $required Is this field required?
|
||||
* @var integer $size Size attribute of the input.
|
||||
* @var boolean $spellcheck Spellcheck state for the form field.
|
||||
* @var string $validate Validation rules to apply.
|
||||
* @var string $value Value attribute of the field.
|
||||
* @var array $options Options available for this field.
|
||||
*/
|
||||
|
||||
// Including fallback code for HTML5 non supported browsers.
|
||||
JHtml::_('jquery.framework');
|
||||
JHtml::_('script', 'system/html5fallback.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9'));
|
||||
|
||||
/**
|
||||
* The format of the input tag to be filled in using sprintf.
|
||||
* %1 - id
|
||||
* %2 - name
|
||||
* %3 - value
|
||||
* %4 = any other attributes
|
||||
*/
|
||||
$format = '<input type="radio" id="%1$s" name="%2$s" value="%3$s" %4$s />';
|
||||
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||
?>
|
||||
<fieldset id="<?php echo $id; ?>" class="<?php echo trim($class . ' radio' . ($readonly || $disabled ? ' disabled' : '') . ($readonly ? ' readonly' : '')); ?>"
|
||||
<?php echo $disabled ? 'disabled' : ''; ?>
|
||||
<?php echo $readonly || $disabled ? 'style="pointer-events: none"' : '' ?>
|
||||
<?php echo $required ? 'required aria-required="true"' : ''; ?>
|
||||
<?php echo $autofocus ? 'autofocus' : ''; ?>>
|
||||
|
||||
<?php if (!empty($options)) : ?>
|
||||
<?php foreach ($options as $i => $option) : ?>
|
||||
<?php
|
||||
// Initialize some option attributes.
|
||||
$checked = ((string) $option->value === $value) ? 'checked="checked"' : '';
|
||||
$disabled = !empty($option->disable) ? 'disabled' : '';
|
||||
$style = $disabled ? 'style="pointer-events: none"' : '';
|
||||
$option->class = !empty($option->class) ? $option->class : '';
|
||||
$option->class = trim($option->class . ' ' . $disabled);
|
||||
$optionClass = !empty($option->class) ? 'class="' . $option->class . '"' : '';
|
||||
|
||||
// Initialize some JavaScript option attributes.
|
||||
$onclick = !empty($option->onclick) ? 'onclick="' . $option->onclick . '"' : '';
|
||||
$onchange = !empty($option->onchange) ? 'onchange="' . $option->onchange . '"' : '';
|
||||
$oid = $id . $i;
|
||||
$ovalue = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8');
|
||||
$attributes = array_filter(array($checked, $optionClass, $disabled, $style, $onchange, $onclick));
|
||||
?>
|
||||
|
||||
<?php if ($required) : ?>
|
||||
<?php $attributes[] = 'required aria-required="true"'; ?>
|
||||
<?php endif; ?>
|
||||
<?php echo sprintf($format, $oid, $name, $ovalue, implode(' ', $attributes)); ?>
|
||||
<label for="<?php echo $oid; ?>" <?php echo trim($optionClass . ' ' . $style); ?>>
|
||||
<?php echo $option->text; ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
84
plugins/system/j2xml/layouts/joomla/toolbar/modal.php
Normal file
84
plugins/system/j2xml/layouts/joomla/toolbar/modal.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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.
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die('Restricted access.');
|
||||
|
||||
\JLog::add(new \JLogEntry(__FILE__, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
JHtml::_('behavior.core');
|
||||
|
||||
/**
|
||||
* Generic toolbar button layout to open a modal
|
||||
* -----------------------------------------------
|
||||
* @param array $displayData Button parameters. Default supported parameters:
|
||||
* - selector string Unique DOM identifier for the modal. CSS id without #
|
||||
* - class string Button class
|
||||
* - icon string Button icon
|
||||
* - text string Button text
|
||||
*/
|
||||
|
||||
$selector = $displayData['selector'];
|
||||
$class = isset($displayData['class']) ? $displayData['class'] : 'btn btn-small';
|
||||
$icon = isset($displayData['icon']) ? $displayData['icon'] : 'out-3';
|
||||
$title = $displayData['title'];
|
||||
$text = isset($displayData['text']) ? $displayData['text'] : '';
|
||||
$onclick = isset($displayData['onclick']) ? $displayData['onclick'] : '';
|
||||
$cancel = isset($displayData['cancel']) ? $displayData['cancel'] : JText::_('JCANCEL');
|
||||
$ok = isset($displayData['ok']) ? $displayData['ok'] : JText::_('JOK');
|
||||
|
||||
JText::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
|
||||
$message = "alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));";
|
||||
?>
|
||||
<button type="button" class="<?php echo $class; ?>" data-toggle="modal" onclick="if (document.adminForm.boxchecked.value==0){<?php echo $message; ?>}else{jQuery('#<?php echo $selector; ?>Modal').modal('show');return true;}">
|
||||
<span class="icon-<?php echo $icon; ?>" aria-hidden="true"></span>
|
||||
<?php echo $text; ?>
|
||||
</button>
|
||||
|
||||
<!-- Render the modal -->
|
||||
<?php
|
||||
$version = new \JVersion();
|
||||
if ($version->isCompatible('3.4'))
|
||||
{
|
||||
echo JHtml::_('bootstrap.renderModal', $selector . 'Modal', array(
|
||||
'url' => $displayData['doTask'],
|
||||
'title' => $title,
|
||||
'modalWidth' => '40',
|
||||
'height' => '310px',
|
||||
'footer' => '<button class="btn" data-dismiss="modal" type="button"'
|
||||
. ' onclick="jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#' . $selector . 'CancelBtn\').click();">' . $cancel . '</button>'
|
||||
. '<button class="btn btn-success" type="button"'
|
||||
. ' onclick="' . $onclick . 'jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#' . $selector . 'OkBtn\').click();">'
|
||||
. $ok . '</button>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo JHtml::_(
|
||||
'bootstrap.renderModal',
|
||||
$selector . 'Modal',
|
||||
array(
|
||||
'url' => $displayData['doTask'],
|
||||
'title' => $title,
|
||||
'modalWidth' => '40',
|
||||
'height' => '310px'),
|
||||
'<button class="btn" data-dismiss="modal" type="button"'
|
||||
. ' onclick="jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#' . $selector . 'CancelBtn\').click();">' . $cancel . '</button>'
|
||||
. '<button class="btn btn-success" type="button"'
|
||||
. ' onclick="' . $onclick . 'jQuery(\'#' . $selector . 'Modal iframe\').contents().find(\'#' . $selector . 'OkBtn\').click();">'
|
||||
. $ok . '</button>');
|
||||
}
|
||||
85
plugins/system/j2xml/layouts/joomla4/toolbar/modal.php
Normal file
85
plugins/system/j2xml/layouts/joomla4/toolbar/modal.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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.
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die('Restricted access.');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HtmlHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()
|
||||
->useScript('webcomponent.toolbar-button');
|
||||
|
||||
/**
|
||||
* Generic toolbar button layout to open a modal
|
||||
* -----------------------------------------------
|
||||
* @param array $displayData Button parameters. Default supported parameters:
|
||||
* - selector string Unique DOM identifier for the modal. CSS id without #
|
||||
* - class string Button class
|
||||
* - icon string Button icon
|
||||
* - text string Button text
|
||||
*/
|
||||
|
||||
$tagName = $tagName ?? 'button';
|
||||
|
||||
$selector = $displayData['selector'];
|
||||
$id = isset($displayData['id']) ? $displayData['id'] : '';
|
||||
$class = isset($displayData['class']) ? $displayData['class'] : 'btn btn-sm btn-primary';
|
||||
$icon = isset($displayData['icon']) ? $displayData['icon'] : 'fas fa-download';
|
||||
$title = $displayData['title'];
|
||||
$text = isset($displayData['text']) ? $displayData['text'] : '';
|
||||
$cancel = isset($displayData['cancel']) ? $displayData['cancel'] : Text::_('JCANCEL');
|
||||
$ok = isset($displayData['ok']) ? $displayData['ok'] : Text::_('JOK');
|
||||
$onclick = isset($displayData['onclick']) ? $displayData['onclick'] : '';
|
||||
$validate = !empty($formValidation) ? ' form-validation' : '';
|
||||
?>
|
||||
|
||||
<joomla-toolbar-button<?php echo $id; ?> onclick="document.getElementById('<?php echo $selector; ?>Modal').open();
|
||||
document.body.appendChild(document.getElementById('<?php echo $selector; ?>Modal'));"
|
||||
data-toggle="modal">
|
||||
<<?php echo $tagName; ?>
|
||||
class="<?php echo $class ?? ''; ?>"
|
||||
<?php echo $htmlAttributes ?? ''; ?>
|
||||
<?php echo $title; ?>
|
||||
>
|
||||
<span class="<?php echo $icon; ?>" aria-hidden="true"></span>
|
||||
<?php echo $text ?? ''; ?>
|
||||
</<?php echo $tagName; ?>>
|
||||
</joomla-toolbar-button>
|
||||
|
||||
<!-- Render the modal -->
|
||||
<?php
|
||||
echo HtmlHelper::_('bootstrap.renderModal',
|
||||
$selector . 'Modal',
|
||||
array(
|
||||
'url' => $displayData['doTask'],
|
||||
'title' => $title,
|
||||
'modalWidth' => '40',
|
||||
'height' => '310px',
|
||||
'closeButton' => true,
|
||||
'footer' => '<button class="btn btn-secondary" data-dismiss="modal" type="button"'
|
||||
. ' onclick="window.parent.Joomla.Modal.getCurrent().close();">'
|
||||
. $cancel . '</button>'
|
||||
.'<joomla-toolbar-button' . $validate
|
||||
. ' onclick="' . $onclick . 'Joomla.iframeButtonClick({iframeSelector: \'#' . $selector . 'Modal\', buttonSelector: \'#' . $selector . 'OkBtn\'})">'
|
||||
. '<button class="btn btn-success" type="button">'
|
||||
. $ok . '</button>'
|
||||
.'</joomla-toolbar-button>'
|
||||
)
|
||||
);
|
||||
39
plugins/system/j2xml/src/J2xml/Helper/Joomla.php
Normal file
39
plugins/system/j2xml/src/J2xml/Helper/Joomla.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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.
|
||||
*/
|
||||
|
||||
namespace eshiol\J2xml\Helper;
|
||||
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
|
||||
class Joomla {
|
||||
// Create alias class for original call in $filepath, then overload the class
|
||||
public static function makeAlias($filepath, $originClassName, $aliasClassName)
|
||||
{
|
||||
\JLog::add(new \JLogEntry(__METHOD__, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
\JLog::add(new \JLogEntry($filepath, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
\JLog::add(new \JLogEntry($originClassName, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
\JLog::add(new \JLogEntry($aliasClassName, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
if (!is_file($filepath)) return false;
|
||||
|
||||
$code = file_get_contents($filepath);
|
||||
$code = str_replace('class ' . $originClassName, 'class ' . $aliasClassName, $code);
|
||||
eval('?>'. $code);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
48
plugins/system/j2xml/src/joomla/cms/layout/file.php
Normal file
48
plugins/system/j2xml/src/joomla/cms/layout/file.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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;
|
||||
|
||||
\JLog::add(new \JLogEntry(__FILE__, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
|
||||
// Make alias of original FileLayout
|
||||
\eshiol\J2xml\Helper\Joomla::makeAlias(JPATH_LIBRARIES . '/cms/layout/file.php', 'JLayoutFile', '_JLayoutFile');
|
||||
|
||||
// Override original FileLayout to trigger event when find layout
|
||||
class JLayoutFile extends _JLayoutFile
|
||||
{
|
||||
public function getDefaultIncludePaths()
|
||||
{
|
||||
\JLog::add(new \JLogEntry(__METHOD__, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
$layoutPath = array(JPATH_PLUGINS . '/system/j2xml/layouts');
|
||||
|
||||
$paths = parent::getDefaultIncludePaths();
|
||||
if (empty($paths))
|
||||
{
|
||||
$paths = $layoutPath;
|
||||
}
|
||||
else //if (is_array($paths))
|
||||
{
|
||||
$paths = array_unique(array_merge($paths, $layoutPath));
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
47
plugins/system/j2xml/src/joomla/src/Layout/FileLayout.php
Normal file
47
plugins/system/j2xml/src/joomla/src/Layout/FileLayout.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Plugins
|
||||
* @subpackage System.J2xml
|
||||
*
|
||||
* @version 3.9.229-rc1
|
||||
* @since 3.9
|
||||
*
|
||||
* @author Helios Ciancio <info (at) eshiol (dot) it>
|
||||
* @link https://www.eshiol.it
|
||||
* @copyright Copyright (C) 2010 - 2023 Helios Ciancio. All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3
|
||||
* J2XML 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.
|
||||
*/
|
||||
|
||||
namespace Joomla\CMS\Layout;
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
// Make alias of original FileLayout
|
||||
\eshiol\J2xml\Helper\Joomla::makeAlias(JPATH_LIBRARIES . '/src/Layout/FileLayout.php', 'FileLayout', '_FileLayout');
|
||||
|
||||
// Override original FileLayout to trigger event when find layout
|
||||
class FileLayout extends _FileLayout
|
||||
{
|
||||
public function getDefaultIncludePaths()
|
||||
{
|
||||
\JLog::add(new \JLogEntry(__METHOD__, \JLog::DEBUG, 'plg_system_j2xml'));
|
||||
|
||||
$layoutPath = array(JPATH_PLUGINS . '/system/j2xml/layouts');
|
||||
|
||||
$paths = parent::getDefaultIncludePaths();
|
||||
if (empty($paths))
|
||||
{
|
||||
$paths = $layoutPath;
|
||||
}
|
||||
else //if (is_array($paths))
|
||||
{
|
||||
$paths = array_unique(array_merge($paths, $layoutPath));
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user