Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
fd17ceff14 | |||
aa1328410a | |||
3682051b0b | |||
9234d153d0 | |||
449c3e7d10 | |||
2019c9593b | |||
b9ef62c63e | |||
05a9e3db2e | |||
39efa1cdf9 | |||
b6cbb427cf | |||
d3be419308 | |||
bf467e4280 | |||
fc8742e895 | |||
3c1f5ac91d | |||
cba4d9a3ed | |||
16b41d096e | |||
f3ac9d0ae2 | |||
aeafe02431 | |||
e18c29cca4 | |||
f0466acc80 | |||
de2e4b9932 | |||
1f1b493ab6 | |||
0738f3063d | |||
a13b26f240 | |||
5d74f1f840 | |||
577be918fd | |||
28aa53bff5 | |||
8cd501c81e | |||
7587446311 | |||
df639d5e05 | |||
ebefbd8925 | |||
805ebd7d78 | |||
19ac3408f2 | |||
8e0e70717d | |||
e600979c73 | |||
3bc83f484c | |||
3879a908c5 | |||
58022aa777 | |||
a686d7104f | |||
2f4861cb3e | |||
e187592118 | |||
1c30e0dfb7 |
@ -1,258 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
|
||||
/**
|
||||
* Extension - Componentbuilder Export Compiler plugin.
|
||||
*
|
||||
* @package ComponentbuilderExportCompiler
|
||||
* @since 1.2.0
|
||||
*/
|
||||
class PlgExtensionComponentbuilderExportCompiler extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Application object
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* The language string builder
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $languageArray = [];
|
||||
|
||||
/*
|
||||
* The Export Text Only switch
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $exportTextOnly = 0;
|
||||
|
||||
/*
|
||||
* The Strict Field Export Permissions switch
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $strictFieldExportPermissions = false;
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Get Component Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onAfterGetComponentData()
|
||||
{
|
||||
if ($this->exportTextOnly && $this->componentActive())
|
||||
{
|
||||
// activate export text only
|
||||
CFactory::_('Config')->set('export_text_only', (int) $this->exportTextOnly);
|
||||
|
||||
// activate strict_permission_per_field if set in plugin (default true)
|
||||
CFactory::_('Config')->set('permission_strict_per_field', (bool) $this->strictFieldExportPermissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on After Model Component Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onAfterModelComponentData(&$component)
|
||||
{
|
||||
// check if we have export for any view
|
||||
if ($this->componentActive())
|
||||
{
|
||||
// set the export/import option
|
||||
if (isset($component->admin_views) && ArrayHelper::check($component->admin_views))
|
||||
{
|
||||
foreach ($component->admin_views as $view)
|
||||
{
|
||||
if (!$this->exportTextOnly && (isset($view['port']) && $view['port'] || 1 == $view['settings']->add_custom_import))
|
||||
{
|
||||
$this->exportTextOnly = 1;
|
||||
$this->strictFieldExportPermissions = (bool) $this->params->get('strict_permission_per_field', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Set Lang File Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeSetLangFileData()
|
||||
{
|
||||
if ($this->exportTextOnly && $this->componentActive() && ArrayHelper::check($this->languageArray))
|
||||
{
|
||||
foreach($this->languageArray as $key => $string)
|
||||
{
|
||||
CFactory::_('Language')->set('adminsys', $key, $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Set Config Field sets]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeSetConfigFieldsets(&$timer)
|
||||
{
|
||||
// only add fields after second time
|
||||
if ($this->exportTextOnly && $this->componentActive() && $timer == 2)
|
||||
{
|
||||
// main lang prefix
|
||||
$lang = CFactory::_('Config')->lang_prefix . '_CONFIG';
|
||||
// start building field set for config
|
||||
$configFieldSets[] = Indent::_(1) . "<fieldset";
|
||||
$configFieldSets[] = Indent::_(2) . 'name="export_text_only_config"';
|
||||
$configFieldSets[] = Indent::_(2) . 'label="' . $lang . '_EXPORT_TEXT_ONLY_TAB_LABEL"';
|
||||
$configFieldSets[] = Indent::_(2) . 'description="' . $lang . '_EXPORT_TEXT_ONLY_TAB_DESCRIPTION">';
|
||||
// setup lang
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_TAB_LABEL'] = "Export Options";
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_TAB_DESCRIPTION'] = "Here are some extra option to adjust the export behavior of admin views.";
|
||||
// add custom Export Options
|
||||
if (isset($configFieldSetsCustomField['Export Options']) && ArrayHelper::check($configFieldSetsCustomField['Export Options']))
|
||||
{
|
||||
$configFieldSets[] = implode("", $configFieldSetsCustomField['Export Options']);
|
||||
unset($configFieldSetsCustomField['Export Options']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_LABEL'] = "Export Text Only";
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_DESCRIPTION'] = "This option enables the export of string/text instead of linked IDs in all admin views that have an export option.";
|
||||
|
||||
$this->languageArray[$lang . '_ACTIVATE'] = "Activate";
|
||||
$this->languageArray[$lang . '_DEACTIVATE'] = "Deactivate";
|
||||
|
||||
$configFieldSets[] = PHP_EOL . Indent::_(2) . "<!--" . Line::_(__Line__, __Class__) . " Export Text Only Field. Type: Radio. (joomla) -->";
|
||||
$configFieldSets[] = Indent::_(2) . "<field";
|
||||
$configFieldSets[] = Indent::_(3) . "type=\"radio\"";
|
||||
$configFieldSets[] = Indent::_(3) . "name=\"export_text_only\"";
|
||||
$configFieldSets[] = Indent::_(3) . "label=\"" . $lang . "_EXPORT_TEXT_ONLY_LABEL\"";
|
||||
$configFieldSets[] = Indent::_(3) . "description=\"" . $lang . "_EXPORT_TEXT_ONLY_DESCRIPTION\"";
|
||||
$configFieldSets[] = Indent::_(3) . "class=\"btn-group btn-group-yesno\"";
|
||||
$configFieldSets[] = Indent::_(3) . "default=\"0\">";
|
||||
$configFieldSets[] = Indent::_(3) . "<!--" . Line::_(__Line__, __Class__) . " Option Set. -->";
|
||||
$configFieldSets[] = Indent::_(3) . "<option value=\"1\">";
|
||||
$configFieldSets[] = Indent::_(4) . $lang . "_ACTIVATE</option>";
|
||||
$configFieldSets[] = Indent::_(3) . "<option value=\"0\">";
|
||||
$configFieldSets[] = Indent::_(4) . $lang . "_DEACTIVATE</option>";
|
||||
$configFieldSets[] = Indent::_(2) . "</field>";
|
||||
|
||||
// add strict Field Export Permissions field
|
||||
if ($this->strictFieldExportPermissions)
|
||||
{
|
||||
$this->languageArray[$lang . '_STRICT_PERMISSION_PER_FIELD_LABEL'] = "Use Strict Permission per/field";
|
||||
$this->languageArray[$lang . '_STRICT_PERMISSION_PER_FIELD_DESCRIPTION'] = "Use strict permissions per/field in the export methods where there are fields permissions in a view.";
|
||||
|
||||
$configFieldSets[] = PHP_EOL . Indent::_(2) . "<!--" . Line::_(__Line__, __Class__) . " Strict_permission_per_field Field. Type: Radio. (joomla) -->";
|
||||
$configFieldSets[] = Indent::_(2) . "<field";
|
||||
$configFieldSets[] = Indent::_(3) . "type=\"radio\"";
|
||||
$configFieldSets[] = Indent::_(3) . "name=\"strict_permission_per_field\"";
|
||||
$configFieldSets[] = Indent::_(3) . "label=\"" . $lang . "_STRICT_PERMISSION_PER_FIELD_LABEL\"";
|
||||
$configFieldSets[] = Indent::_(3) . "description=\"" . $lang . "_STRICT_PERMISSION_PER_FIELD_DESCRIPTION\"";
|
||||
$configFieldSets[] = Indent::_(3) . "class=\"btn-group btn-group-yesno\"";
|
||||
$configFieldSets[] = Indent::_(3) . "default=\"1\">";
|
||||
$configFieldSets[] = Indent::_(3) . "<!--" . Line::_(__Line__, __Class__) . " Option Set. -->";
|
||||
$configFieldSets[] = Indent::_(3) . "<option value=\"1\">";
|
||||
$configFieldSets[] = Indent::_(4) . $lang . "_ACTIVATE</option>";
|
||||
$configFieldSets[] = Indent::_(3) . "<option value=\"0\">";
|
||||
$configFieldSets[] = Indent::_(4) . $lang . "_DEACTIVATE</option>";
|
||||
$configFieldSets[] = Indent::_(2) . "</field>";
|
||||
}
|
||||
}
|
||||
// close that fieldset
|
||||
$configFieldSets[] = Indent::_(1) . "</fieldset>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of active components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $componentsActive;
|
||||
|
||||
/**
|
||||
* The activate option
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $activateOption = 0;
|
||||
|
||||
/**
|
||||
* Set the line number in comments
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
protected function componentActive()
|
||||
{
|
||||
// check the active option
|
||||
if (!$this->activateOption)
|
||||
{
|
||||
$this->activateOption = $this->params->get('activate_option', 1);
|
||||
}
|
||||
// active for all components
|
||||
if ($this->activateOption == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// first check is we have the active components set
|
||||
if ($this->activateOption == 2 && !ArrayHelper::check($this->componentsActive))
|
||||
{
|
||||
$this->componentsActive = $this->params->get('components');
|
||||
}
|
||||
// only check if there are active
|
||||
if (ArrayHelper::check($this->componentsActive))
|
||||
{
|
||||
return in_array((int) CFactory::_('Config')->component_id, $this->componentsActive);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.10" group="extension" method="upgrade">
|
||||
<extension type="plugin" version="4.0" group="extension" method="upgrade">
|
||||
<name>PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER</name>
|
||||
<creationDate>9th March, 2024</creationDate>
|
||||
<creationDate>7th November, 2024</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<version>1.2.0</version>
|
||||
<version>3.0.0</version>
|
||||
<namespace path="src">VDM\Plugin\Extension\ComponentbuilderExportCompiler</namespace>
|
||||
<description>PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION</description>
|
||||
|
||||
<!-- Scripts to run on installation -->
|
||||
@ -15,21 +16,22 @@
|
||||
|
||||
<!-- Language files -->
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderexportcompiler.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderexportcompiler.sys.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_extension_componentbuilderexportcompiler.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_extension_componentbuilderexportcompiler.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<!-- Plugin files -->
|
||||
<files>
|
||||
<filename plugin="componentbuilderexportcompiler">componentbuilderexportcompiler.php</filename>
|
||||
<folder plugin="componentbuilderexportcompiler">services</folder>
|
||||
<filename>index.html</filename>
|
||||
<folder>language</folder>
|
||||
<folder>services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
|
||||
<!-- Config parameter -->
|
||||
<!-- Config parameters -->
|
||||
<config
|
||||
addrulepath="/administrator/components/com_componentbuilder/models/rules"
|
||||
addfieldpath="/administrator/components/com_componentbuilder/models/fields"
|
||||
addruleprefix="VDM\Component\Componentbuilder\Administrator\Rule"
|
||||
addfieldprefix="VDM\Component\Componentbuilder\Administrator\Field">
|
||||
>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_SETTINGS">
|
||||
|
@ -1,6 +1,6 @@
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER="Extension - Componentbuilder Export Compiler"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_DESCRIPTION="This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab."
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Export Compiler (v.1.2.0)</h1> <div style='clear: both;'></div><p>This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 21st August, 2019</small></p>"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Export Compiler (v.3.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 10th March, 2024</small></p>"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_SETTINGS="Settings"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_DESCRIPTION="You can select the kind of activation control you would like to use. <b>All</b> will target all components, and <b>Selected</b> will let you select only those you want to be active."
|
@ -1,6 +1,6 @@
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER="Extension - Componentbuilder Export Compiler"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_DESCRIPTION="This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab."
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Export Compiler (v.1.2.0)</h1> <div style='clear: both;'></div><p>This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 21st August, 2019</small></p>"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Export Compiler (v.3.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to tweak the export options for your components during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to activate the component/s that should be targeted with this added export feature under the Component Activation tab.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 10th March, 2024</small></p>"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_SETTINGS="Settings"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options"
|
||||
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_DESCRIPTION="You can select the kind of activation control you would like to use. <b>All</b> will target all components, and <b>Selected</b> will let you select only those you want to be active."
|
134
script.php
134
script.php
@ -20,140 +20,8 @@ use Joomla\CMS\Filesystem\Folder;
|
||||
/**
|
||||
* Extension - Componentbuilder Export Compiler script file.
|
||||
*
|
||||
* @package PlgExtensionComponentbuilderExportCompiler
|
||||
* @package ComponentbuilderExportCompiler
|
||||
*/
|
||||
class plgExtensionComponentbuilderExportCompilerInstallerScript
|
||||
{
|
||||
|
||||
/**
|
||||
* Called before any type of action
|
||||
*
|
||||
* @param string $route Which action is happening (install|uninstall|discover_install|update)
|
||||
* @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function preflight($route, $adapter)
|
||||
{
|
||||
// get application
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// the default for both install and update
|
||||
$jversion = new JVersion();
|
||||
if (!$jversion->isCompatible('3.8.0'))
|
||||
{
|
||||
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('install' === $route)
|
||||
{
|
||||
// needs fix
|
||||
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// load the helper class
|
||||
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
||||
|
||||
// block install
|
||||
$blockInstall = true;
|
||||
|
||||
// check the version of JCB
|
||||
$manifest = ComponentbuilderHelper::manifest();
|
||||
if (isset($manifest->version) && strpos($manifest->version, '.') !== false)
|
||||
{
|
||||
// get the version
|
||||
$jcbVersion = explode('.', $manifest->version);
|
||||
// check that we have JCB 3.0.0 or higher installed
|
||||
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 &&
|
||||
(
|
||||
($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 0) ||
|
||||
($jcbVersion[0] == 3 && $jcbVersion[1] > 0) ||
|
||||
$jcbVersion[0] > 3)
|
||||
)
|
||||
{
|
||||
$blockInstall = false;
|
||||
}
|
||||
}
|
||||
|
||||
// allow install if all conditions are met
|
||||
if ($blockInstall)
|
||||
{
|
||||
$app->enqueueMessage('Please upgrade to JCB v3.0.0 or higher before installing this plugin.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
// load the helper class
|
||||
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
||||
// block install
|
||||
$blockInstall = true;
|
||||
// check the version of JCB
|
||||
$manifest = ComponentbuilderHelper::manifest();
|
||||
if (isset($manifest->version) && strpos($manifest->version, '.') !== false)
|
||||
{
|
||||
// get the version
|
||||
$jcbVersion = explode('.', $manifest->version);
|
||||
// check that we have JCB 2.10.13 or higher installed
|
||||
if (count($jcbVersion) == 3 && (($jcbVersion[0] == 2 && $jcbVersion[1] >= 10 && (($jcbVersion[1] == 10 && $jcbVersion[2] >= 13) || ($jcbVersion[1] > 10))) || $jcbVersion[0] >= 3))
|
||||
{
|
||||
$blockInstall = false;
|
||||
}
|
||||
}
|
||||
// allow install if all conditions are met
|
||||
if ($blockInstall)
|
||||
{
|
||||
$app->enqueueMessage('Please upgrade to JCB 2.10.13 or higher before installing this plugin.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that componentbuilder is installed
|
||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||
if (!JFile::exists($pathToCore))
|
||||
{
|
||||
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
1
services/index.html
Normal file
1
services/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
48
services/provider.php
Normal file
48
services/provider.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use VDM\Plugin\Extension\ComponentbuilderExportCompiler\Extension\ComponentbuilderExportCompiler;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new ComponentbuilderExportCompiler(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('extension', 'componentbuilderexportcompiler')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
267
src/Extension/ComponentbuilderExportCompiler.php
Normal file
267
src/Extension/ComponentbuilderExportCompiler.php
Normal file
@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
namespace VDM\Plugin\Extension\ComponentbuilderExportCompiler\Extension;
|
||||
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
/**
|
||||
* Extension - Componentbuilder Export Compiler plugin.
|
||||
*
|
||||
* @package ComponentbuilderExportCompiler
|
||||
* @since 3.0.0
|
||||
*/
|
||||
final class ComponentbuilderExportCompiler extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* The language string builder
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $languageArray = [];
|
||||
|
||||
/*
|
||||
* The Export Text Only switch
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $exportTextOnly = 0;
|
||||
|
||||
/*
|
||||
* The Strict Field Export Permissions switch
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $strictFieldExportPermissions = false;
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Get Component Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onAfterGetComponentData()
|
||||
{
|
||||
if ($this->exportTextOnly && $this->componentActive())
|
||||
{
|
||||
// activate export text only
|
||||
Factory::_('Config')->set('export_text_only', (int) $this->exportTextOnly);
|
||||
|
||||
// activate strict_permission_per_field if set in plugin (default true)
|
||||
Factory::_('Config')->set('permission_strict_per_field', (bool) $this->strictFieldExportPermissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on After Model Component Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onAfterModelComponentData(&$component)
|
||||
{
|
||||
// check if we have export for any view
|
||||
if ($this->componentActive())
|
||||
{
|
||||
// set the export/import option
|
||||
if (isset($component->admin_views) && ArrayHelper::check($component->admin_views))
|
||||
{
|
||||
foreach ($component->admin_views as $view)
|
||||
{
|
||||
if (!$this->exportTextOnly && (isset($view['port']) && $view['port'] || 1 == $view['settings']->add_custom_import))
|
||||
{
|
||||
$this->exportTextOnly = 1;
|
||||
$this->strictFieldExportPermissions = (bool) $this->params->get('strict_permission_per_field', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Set Lang File Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeSetLangFileData()
|
||||
{
|
||||
if ($this->exportTextOnly && $this->componentActive() && ArrayHelper::check($this->languageArray))
|
||||
{
|
||||
foreach($this->languageArray as $key => $string)
|
||||
{
|
||||
Factory::_('Language')->set('adminsys', $key, $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on Before Set Config Field sets]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeSetConfigFieldsets(&$timer)
|
||||
{
|
||||
// only add fields after second time
|
||||
if ($this->exportTextOnly && $this->componentActive() && $timer == 2)
|
||||
{
|
||||
// main lang prefix
|
||||
$lang = Factory::_('Config')->lang_prefix . '_CONFIG';
|
||||
// start building field set for config
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(1) . "<fieldset");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . 'name="export_text_only_config"');
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . 'label="' . $lang . '_EXPORT_TEXT_ONLY_TAB_LABEL"');
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . 'description="' . $lang . '_EXPORT_TEXT_ONLY_TAB_DESCRIPTION">');
|
||||
// setup lang
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_TAB_LABEL'] = "Export Options";
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_TAB_DESCRIPTION'] = "Here are some extra option to adjust the export behaviour of admin views.";
|
||||
// add custom Export Options
|
||||
if (isset($configFieldSetsCustomField['Export Options']) && ArrayHelper::check($configFieldSetsCustomField['Export Options']))
|
||||
{
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', implode("", $configFieldSetsCustomField['Export Options']));
|
||||
unset($configFieldSetsCustomField['Export Options']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_LABEL'] = "Export Text Only";
|
||||
$this->languageArray[$lang . '_EXPORT_TEXT_ONLY_DESCRIPTION'] = "This option enables the export of string/text instead of linked IDs in all admin views that have an export option.";
|
||||
|
||||
$this->languageArray[$lang . '_ACTIVATE'] = "Activate";
|
||||
$this->languageArray[$lang . '_DEACTIVATE'] = "Deactivate";
|
||||
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', PHP_EOL . Indent::_(2) . "<!--" . Line::_(__Line__, __Class__) . " Export Text Only Field. Type: Radio. (joomla) -->");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . "<field");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "type=\"radio\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "name=\"export_text_only\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "label=\"" . $lang . "_EXPORT_TEXT_ONLY_LABEL\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "description=\"" . $lang . "_EXPORT_TEXT_ONLY_DESCRIPTION\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "class=\"btn-group btn-group-yesno\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "default=\"0\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<!--" . Line::_(__Line__, __Class__) . " Option Set. -->");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<option value=\"1\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(4) . $lang . "_ACTIVATE</option>");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<option value=\"0\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(4) . $lang . "_DEACTIVATE</option>");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . "</field>");
|
||||
|
||||
// add strict Field Export Permissions field
|
||||
if ($this->strictFieldExportPermissions)
|
||||
{
|
||||
$this->languageArray[$lang . '_STRICT_PERMISSION_PER_FIELD_LABEL'] = "Use Strict Permission per/field";
|
||||
$this->languageArray[$lang . '_STRICT_PERMISSION_PER_FIELD_DESCRIPTION'] = "Use strict permissions per/field in the export methods where there are fields permissions in a view.";
|
||||
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', PHP_EOL . Indent::_(2) . "<!--" . Line::_(__Line__, __Class__) . " Strict_permission_per_field Field. Type: Radio. (joomla) -->");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . "<field");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "type=\"radio\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "name=\"strict_permission_per_field\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "label=\"" . $lang . "_STRICT_PERMISSION_PER_FIELD_LABEL\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "description=\"" . $lang . "_STRICT_PERMISSION_PER_FIELD_DESCRIPTION\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "class=\"btn-group btn-group-yesno\"");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "default=\"1\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<!--" . Line::_(__Line__, __Class__) . " Option Set. -->");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<option value=\"1\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(4) . $lang . "_ACTIVATE</option>");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(3) . "<option value=\"0\">");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(4) . $lang . "_DEACTIVATE</option>");
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(2) . "</field>");
|
||||
}
|
||||
}
|
||||
// close that fieldset
|
||||
Factory::_('Compiler.Builder.Config.Fieldsets')->add('component', Indent::_(1) . "</fieldset>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of active components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $componentsActive;
|
||||
|
||||
/**
|
||||
* The activate option
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $activateOption = 0;
|
||||
|
||||
/**
|
||||
* Set the line number in comments
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
protected function componentActive()
|
||||
{
|
||||
// check the active option
|
||||
if (!$this->activateOption)
|
||||
{
|
||||
$this->activateOption = $this->params->get('activate_option', 1);
|
||||
}
|
||||
// active for all components
|
||||
if ($this->activateOption == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// first check is we have the active components set
|
||||
if ($this->activateOption == 2 && !ArrayHelper::check($this->componentsActive))
|
||||
{
|
||||
$this->componentsActive = $this->params->get('components');
|
||||
}
|
||||
// only check if there are active
|
||||
if (ArrayHelper::check($this->componentsActive))
|
||||
{
|
||||
return in_array((int) Factory::_('Config')->component_id, $this->componentsActive);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'jcb_ce_onAfterGetComponentData' => 'jcb_ce_onAfterGetComponentData',
|
||||
'jcb_ce_onAfterModelComponentData' => 'jcb_ce_onAfterModelComponentData',
|
||||
'jcb_ce_onBeforeSetLangFileData' => 'jcb_ce_onBeforeSetLangFileData',
|
||||
'jcb_ce_onBeforeSetConfigFieldsets' => 'jcb_ce_onBeforeSetConfigFieldsets'
|
||||
];
|
||||
}
|
||||
}
|
1
src/Extension/index.html
Normal file
1
src/Extension/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Loading…
Reference in New Issue
Block a user