52
0

Compare commits

...

39 Commits
4.x ... 5.x

Author SHA1 Message Date
ef57f8bd5f
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-11-07 10:55:30 +02:00
9d3a1f6ac6
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-10-13 22:54:01 +02:00
b6ad804633
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-10-08 00:33:55 +02:00
393b7b37c4
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-09-30 01:56:42 +02:00
899fcf304a
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-09-20 03:01:45 +02:00
9b36213aef
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-09-19 05:50:09 +02:00
8f2384a449
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-09-18 04:40:33 +02:00
c7338fe6af
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-08-21 21:38:38 +02:00
7d189ecc93
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-08-20 22:34:47 +02:00
92dfce2457
Update on v3.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-08-16 19:22:12 +02:00
e022c6d727
Release of v3.0.0 2024-08-15 01:35:23 +02:00
85ea763c3c
Release of v2.0.0 2024-07-27 23:01:47 +02:00
bb15917b42
Release of v2.0.0 2024-07-26 15:41:46 +02:00
2f564337cd
Release of v2.0.0 2024-07-20 22:46:52 +02:00
251ee285b4
Release of v2.0.0 2024-07-18 15:04:31 +02:00
163f8232a7
Release of v2.0.0 2024-07-17 02:37:06 +02:00
7242166e5b
Release of v2.0.0 2024-07-08 23:01:22 +02:00
3506fb1a3f
Release of v2.0.0 2024-06-28 03:57:03 +02:00
9f3aeff78a
Release of v2.0.0 2024-06-21 03:32:13 +02:00
e9fb7e4ce3
Release of v2.0.0 2024-06-07 23:27:38 +02:00
fb032a4f79
Release of v2.0.0 2024-06-05 17:15:46 +02:00
0af86a232c
Release of v2.0.0 2024-05-16 16:12:41 +02:00
3b9ef6cb5d
Release of v2.0.0 2024-05-13 12:26:41 +02:00
f0188d00cc
Release of v2.0.0 2024-05-10 18:20:26 +02:00
48eb235886
Release of v2.0.0 2024-05-06 07:54:17 +02:00
7a25e82631
Release of v2.0.0 2024-05-03 07:53:10 +02:00
6c084e1020
Release of v2.0.0 2024-04-30 12:35:09 +02:00
aa99a3424a
Release of v2.0.0 2024-04-27 16:06:02 +02:00
3b75db13cb
Release of v2.0.0 2024-04-24 21:43:39 +02:00
a71266e235
Release of v2.0.0 2024-04-22 01:20:29 +02:00
9db558acb7
Release of v2.0.0 2024-04-16 20:32:13 +02:00
519be7a111
Release of v2.0.0 2024-04-09 14:00:52 +02:00
11cc628e33
Release of v2.0.0 2024-04-07 12:06:55 +02:00
46a60d4d37
Release of v2.0.0 2024-04-06 23:47:21 +02:00
5344035c04
Release of v2.0.0 2024-03-26 22:38:08 +02:00
9488c95a3b
Release of v2.0.0 2024-03-20 14:27:40 +02:00
6f0c5ded1a
Release of v2.0.0 2024-03-15 12:32:05 +02:00
1a5583af29
Release of v2.0.0 2024-03-12 13:02:01 +02:00
1e8f174933
Release of v2.0.0 2024-03-11 18:36:21 +02:00
9 changed files with 427 additions and 386 deletions

View File

@ -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;
}
}

View File

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.10" group="extension" method="upgrade"> <extension type="plugin" version="5.0" group="extension" method="upgrade">
<name>PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER</name> <name>PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER</name>
<creationDate>9th March, 2024</creationDate> <creationDate>7th November, 2024</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright> <copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> <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> <description>PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_XML_DESCRIPTION</description>
<!-- Scripts to run on installation --> <!-- Scripts to run on installation -->
@ -15,21 +16,22 @@
<!-- Language files --> <!-- Language files -->
<languages folder="language"> <languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderexportcompiler.ini</language> <language tag="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.sys.ini</language>
</languages> </languages>
<!-- Plugin files --> <!-- Plugin files -->
<files> <files>
<filename plugin="componentbuilderexportcompiler">componentbuilderexportcompiler.php</filename> <folder plugin="componentbuilderexportcompiler">services</folder>
<filename>index.html</filename> <filename>index.html</filename>
<folder>language</folder> <folder>services</folder>
<folder>src</folder>
</files> </files>
<!-- Config parameter --> <!-- Config parameters -->
<config <config
addrulepath="/administrator/components/com_componentbuilder/models/rules" addruleprefix="VDM\Component\Componentbuilder\Administrator\Rule"
addfieldpath="/administrator/components/com_componentbuilder/models/fields" addfieldprefix="VDM\Component\Componentbuilder\Administrator\Field">
> >
<fields name="params"> <fields name="params">
<fieldset name="basic" label="PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_SETTINGS"> <fieldset name="basic" label="PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_SETTINGS">

View File

@ -1,6 +1,6 @@
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER="Extension - Componentbuilder Export Compiler" 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_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_SETTINGS="Settings"
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options" 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." 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."

View File

@ -1,6 +1,6 @@
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER="Extension - Componentbuilder Export Compiler" 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_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_SETTINGS="Settings"
PLG_EXTENSION_COMPONENTBUILDEREXPORTCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options" 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." 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."

View File

@ -13,147 +13,129 @@
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use Joomla\CMS\Version;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File; use Joomla\Filesystem\File;
use Joomla\CMS\Filesystem\Folder; use Joomla\Filesystem\Folder;
/** /**
* Extension - Componentbuilder Export Compiler script file. * Extension - Componentbuilder Export Compiler script file.
* *
* @package PlgExtensionComponentbuilderExportCompiler * @package ComponentbuilderExportCompiler
*/ */
class plgExtensionComponentbuilderExportCompilerInstallerScript class plgExtensionComponentbuilderExportCompilerInstallerScript
{ {
/**
* The CMS Application.
*
* @since 4.4.2
*/
protected $app;
/**
* A list of files to be deleted
*
* @var array
* @since 3.6
*/
protected array $deleteFiles = [];
/**
* A list of folders to be deleted
*
* @var array
* @since 3.6
*/
protected array $deleteFolders = [];
/**
* Constructor
*
* @param InstallerAdapter $adapter The object responsible for running this script
*/
public function __construct($adapter)
{
// get application
$this->app = Factory::getApplication();
if (is_file(JPATH_ROOT . '/plugins/extension/componentbuilderexportcompiler/componentbuilderexportcompiler.php'))
{
$this->deleteFiles[] = '/plugins/extension/componentbuilderexportcompiler/componentbuilderexportcompiler.php';
}
}
/** /**
* Called before any type of action * Called before any type of action
* *
* @param string $route Which action is happening (install|uninstall|discover_install|update) * @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 * @param InstallerAdapter $adapter The object responsible for running this script
* *
* @return boolean True on success * @return boolean True on success
*/ */
public function preflight($route, $adapter) public function preflight($route, $adapter)
{ {
// get application // set application to local method var, just use $this->app in future [we will drop $app in J6]
$app = Factory::getApplication(); $app = $this->app;
// the default for both install and update // the default for both install and update
$jversion = new JVersion(); $jversion = new Version();
if (!$jversion->isCompatible('3.8.0')) if (!$jversion->isCompatible('5.0.0'))
{ {
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); $app->enqueueMessage('Please upgrade to at least Joomla! 5.0.0 before continuing!', 'error');
return false; return false;
} }
if ('install' === $route) // remove old files and folders
{ $this->removeFiles();
// 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; return true;
} }
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param InstallerAdapter $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, $adapter)
{
// set application to local method var, just use $this->app in future [we will drop $app in J6]
$app = $this->app;
return true;
}
/**
* Remove the files and folders in the given array from
*
* @return void
* @since 5.0.2
*/
protected function removeFiles()
{
if (!empty($this->deleteFiles))
{
foreach ($this->deleteFiles as $file)
{
if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))
{
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '<br>';
}
}
}
if (!empty($this->deleteFolders))
{
foreach ($this->deleteFolders as $folder)
{
if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder))
{
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '<br>';
}
}
}
}
} }

1
services/index.html Normal file
View File

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

47
services/provider.php Normal file
View File

@ -0,0 +1,47 @@
<?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\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;
}
);
}
};

View File

@ -0,0 +1,266 @@
<?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 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
View File

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