Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
ef57f8bd5f | |||
9d3a1f6ac6 | |||
b6ad804633 | |||
393b7b37c4 | |||
899fcf304a | |||
9b36213aef | |||
8f2384a449 | |||
c7338fe6af | |||
7d189ecc93 | |||
92dfce2457 | |||
e022c6d727 | |||
85ea763c3c | |||
bb15917b42 | |||
2f564337cd | |||
251ee285b4 | |||
163f8232a7 | |||
7242166e5b | |||
3506fb1a3f | |||
9f3aeff78a | |||
e9fb7e4ce3 | |||
fb032a4f79 | |||
0af86a232c | |||
3b9ef6cb5d | |||
f0188d00cc | |||
48eb235886 | |||
7a25e82631 | |||
6c084e1020 | |||
aa99a3424a | |||
3b75db13cb | |||
a71266e235 | |||
9db558acb7 | |||
519be7a111 | |||
11cc628e33 | |||
46a60d4d37 | |||
5344035c04 | |||
9488c95a3b | |||
6f0c5ded1a | |||
1a5583af29 | |||
1e8f174933 |
@ -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="5.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."
|
214
script.php
214
script.php
@ -13,147 +13,129 @@
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Version;
|
||||
use Joomla\CMS\Installer\InstallerAdapter;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\Filesystem\File;
|
||||
use Joomla\Filesystem\Folder;
|
||||
|
||||
/**
|
||||
* Extension - Componentbuilder Export Compiler script file.
|
||||
*
|
||||
* @package PlgExtensionComponentbuilderExportCompiler
|
||||
* @package ComponentbuilderExportCompiler
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function preflight($route, $adapter)
|
||||
{
|
||||
// get application
|
||||
$app = Factory::getApplication();
|
||||
// set application to local method var, just use $this->app in future [we will drop $app in J6]
|
||||
$app = $this->app;
|
||||
|
||||
// the default for both install and update
|
||||
$jversion = new JVersion();
|
||||
if (!$jversion->isCompatible('3.8.0'))
|
||||
$jversion = new Version();
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
// remove old files and folders
|
||||
$this->removeFiles();
|
||||
|
||||
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
1
services/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
47
services/provider.php
Normal file
47
services/provider.php
Normal 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;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
266
src/Extension/ComponentbuilderExportCompiler.php
Normal file
266
src/Extension/ComponentbuilderExportCompiler.php
Normal 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
1
src/Extension/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Loading…
Reference in New Issue
Block a user