diff --git a/componentbuilderpowersautoloadercompiler.php b/componentbuilderpowersautoloadercompiler.php index 1a91a86..07bae52 100644 --- a/componentbuilderpowersautoloadercompiler.php +++ b/componentbuilderpowersautoloadercompiler.php @@ -12,6 +12,8 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Registry\Registry; @@ -25,7 +27,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; * Extension - Componentbuilder Powers Autoloader Compiler plugin. * * @package ComponentbuilderPowersAutoloaderCompiler - * @since 1.1.1 + * @since 1.2.0 */ class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin { @@ -44,10 +46,10 @@ class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onAfterGet(&$context, $compiler) + public function jcb_ce_onAfterGet() { // check if this component needs a power autoloader plugin loaded - if ($compiler->addPower && $this->componentActive($context) && ComponentbuilderHelper::checkArray($compiler->linkedPowers)) + if (CFactory::_('Config')->add_power && $this->componentActive()) { // now get the plugin ID if set if (($id = (int) $this->params->get('plugin', 0)) !== 0) @@ -59,7 +61,7 @@ class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin } else { - JFactory::getApplication()->enqueueMessage(JText::_('PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_POWER_PLUGIN_SETUP_SO_THE_POWERS_PLUGIN_AUTOLOADER_COULD_NOT_BE_ADDED'), 'Error'); + Factory::getApplication()->enqueueMessage(Text::_('PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_POWER_PLUGIN_SETUP_SO_THE_POWERS_PLUGIN_AUTOLOADER_COULD_NOT_BE_ADDED'), 'Error'); } } } @@ -81,12 +83,10 @@ class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin /** * Set the line number in comments * - * @param string $context The context of the current executing component - * * @return bool * */ - protected function componentActive(&$context) + protected function componentActive() { // check the active option if (!$this->activateOption) @@ -106,7 +106,7 @@ class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin // only check if there are active if (ArrayHelper::check($this->componentsActive)) { - return in_array((int) filter_var($context, FILTER_SANITIZE_NUMBER_INT), $this->componentsActive); + return in_array((int) CFactory::_('Config')->component_id, $this->componentsActive); } return false; } diff --git a/componentbuilderpowersautoloadercompiler.xml b/componentbuilderpowersautoloadercompiler.xml index e05ca77..ce1a75e 100644 --- a/componentbuilderpowersautoloadercompiler.xml +++ b/componentbuilderpowersautoloadercompiler.xml @@ -1,13 +1,13 @@ - + PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER - 24th October, 2023 + 2nd March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 1.1.1 + 1.2.0 PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_XML_DESCRIPTION diff --git a/fields/joomlacomponents.php b/fields/joomlacomponents.php index 512150b..17b7bb1 100644 --- a/fields/joomlacomponents.php +++ b/fields/joomlacomponents.php @@ -12,6 +12,10 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); @@ -24,14 +28,14 @@ class JFormFieldJoomlacomponents extends JFormFieldList /** * The joomlacomponents field type. * - * @var string + * @var string */ public $type = 'joomlacomponents'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/fields/joomlaplugins.php b/fields/joomlaplugins.php index 16462c0..379ca5e 100644 --- a/fields/joomlaplugins.php +++ b/fields/joomlaplugins.php @@ -12,6 +12,10 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); @@ -24,7 +28,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList /** * The joomlaplugins field type. * - * @var string + * @var string */ public $type = 'joomlaplugins'; @@ -48,7 +52,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList $script = array(); $button_code_name = $this->getAttribute('name'); // get the input from url - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $jinput = $app->input; // get the view name & id $values = $jinput->getArray(array( @@ -64,7 +68,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; // get the return value. - $_uri = (string) JUri::getInstance(); + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); $_return = urlencode(base64_encode($_uri)); // load return value. $ref .= '&return=' . $_return; @@ -77,20 +81,20 @@ class JFormFieldJoomlaplugins extends JFormFieldList $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); $button_label = ucfirst(strtolower($button_label)); // get user object - $user = JFactory::getUser(); + $user = Factory::getUser(); // only add if user allowed to create joomla_plugin - if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. { // build Create button - $button[] = ' '; } // only add if user allowed to edit joomla_plugin - if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. { // build edit button - $button[] = ''; // build script $script[] = " @@ -123,7 +127,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList if (is_array($button) && count($button) > 0) { // Load the needed script. - $document = JFactory::getDocument(); + $document = Factory::getDocument(); $document->addScriptDeclaration(implode(' ',$script)); // return the button attached to input field. return '
' .$html . implode('',$button).'
'; @@ -135,7 +139,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.ini b/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.ini index 1e229eb..f5ba1d0 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.ini @@ -1,6 +1,6 @@ PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER="Extension - Componentbuilder Powers Autoloader Compiler" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_DESCRIPTION="This plugin is used to build the power autoloader plugin for your component 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." -PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Powers Autoloader Compiler (v.1.1.1)

This plugin is used to build the power autoloader plugin for your component 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.

Created by Llewellyn van der Merwe
Development started 13th November, 2021

" +PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Powers Autoloader Compiler (v.1.2.0)

This plugin is used to build the power autoloader plugin for your component 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.

Created by Llewellyn van der Merwe
Development started 13th November, 2021

" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_POWER_PLUGIN_SETUP_SO_THE_POWERS_PLUGIN_AUTOLOADER_COULD_NOT_BE_ADDED="You do not have a global power plugin setup, so the powers plugin autoloader could not be added." PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_GLOBAL_AUTOLOADER="Global Autoloader" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_NOTE_SELECT_POWER_PLUGIN_LABEL="Select your power autoloader plugin here." diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.sys.ini b/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.sys.ini index 1e229eb..f5ba1d0 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.sys.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderpowersautoloadercompiler.sys.ini @@ -1,6 +1,6 @@ PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER="Extension - Componentbuilder Powers Autoloader Compiler" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_DESCRIPTION="This plugin is used to build the power autoloader plugin for your component 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." -PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Powers Autoloader Compiler (v.1.1.1)

This plugin is used to build the power autoloader plugin for your component 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.

Created by Llewellyn van der Merwe
Development started 13th November, 2021

" +PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Powers Autoloader Compiler (v.1.2.0)

This plugin is used to build the power autoloader plugin for your component 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.

Created by Llewellyn van der Merwe
Development started 13th November, 2021

" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_POWER_PLUGIN_SETUP_SO_THE_POWERS_PLUGIN_AUTOLOADER_COULD_NOT_BE_ADDED="You do not have a global power plugin setup, so the powers plugin autoloader could not be added." PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_GLOBAL_AUTOLOADER="Global Autoloader" PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER_NOTE_SELECT_POWER_PLUGIN_LABEL="Select your power autoloader plugin here." diff --git a/script.php b/script.php index 066fbe5..046fabb 100644 --- a/script.php +++ b/script.php @@ -12,6 +12,11 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; + /** * Extension - Componentbuilder Powers Autoloader Compiler script file. * @@ -31,7 +36,7 @@ class plgExtensionComponentbuilderPowersAutoloaderCompilerInstallerScript public function preflight($route, $adapter) { // get application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // the default for both install and update $jversion = new JVersion();