diff --git a/componentbuildercustomadminheaderstabs.php b/componentbuildercustomadminheaderstabs.php index 221ed8f..2d8165c 100644 --- a/componentbuildercustomadminheaderstabs.php +++ b/componentbuildercustomadminheaderstabs.php @@ -13,22 +13,21 @@ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Form\Form; -use Joomla\CMS\Plugin\CMSPlugin; +use Joomla\CMS\Plugin\CMSPlugin; +use Joomla\CMS\Component\ComponentHelper; use VDM\Joomla\Utilities\ArrayHelper; - -JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); /** * Content - Componentbuilder Custom Admin Headers Tabs plugin. * * @package ComponentbuilderCustomAdminHeadersTabs - * @since 2.0.1 + * @since 3.0.0 */ class PlgContentComponentbuilderCustomAdminHeadersTabs extends CMSPlugin { /** - * Affects constructor behavior. If true, language files will be loaded automatically. + * Affects constructor behaviour. If true, language files will be loaded automatically. * * @var boolean * @since 1.0 @@ -38,8 +37,8 @@ class PlgContentComponentbuilderCustomAdminHeadersTabs extends CMSPlugin /** * Runs on content preparation of form. * - * @param JForm $form The form - * @param stdClass $data The data + * @param Form $form The form + * @param \stdClass $data The data * * @return boolean * @@ -57,7 +56,7 @@ class PlgContentComponentbuilderCustomAdminHeadersTabs extends CMSPlugin // add the admin view params for privacy integration $form->loadFile('custom_admin_view'); // update all editors to use this components global editor - $global_editor = \JComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); // set the field editor value (with none as fallback) $editors = $form->getXml()->xpath('descendant::fields[@name="custom_admin_view_headers"]//field[@type="editor"]'); // check if we found any diff --git a/componentbuildercustomadminheaderstabs.xml b/componentbuildercustomadminheaderstabs.xml index 96faba4..3852541 100644 --- a/componentbuildercustomadminheaderstabs.xml +++ b/componentbuildercustomadminheaderstabs.xml @@ -1,13 +1,13 @@ - + PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS - 9th March, 2024 + 11th 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 - 2.0.1 + 3.0.0 PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_XML_DESCRIPTION diff --git a/forms/custom_admin_view.xml b/forms/custom_admin_view.xml index ea793ca..1f1850a 100644 --- a/forms/custom_admin_view.xml +++ b/forms/custom_admin_view.xml @@ -1,8 +1,8 @@
diff --git a/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.ini b/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.ini index f4ae144..309f1d1 100644 --- a/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.ini +++ b/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.ini @@ -1,6 +1,6 @@ PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS="Content - Componentbuilder Custom Admin Headers Tabs" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_DESCRIPTION="This plugin is used to set custom admin class custom headers." -PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_XML_DESCRIPTION="

Content - Componentbuilder Custom Admin Headers Tabs (v.2.0.1)

This plugin is used to set custom admin class custom headers.

Created by Llewellyn van der Merwe
Development started 8th December, 2020

" +PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_XML_DESCRIPTION="

Content - Componentbuilder Custom Admin Headers Tabs (v.3.0.0)

This plugin is used to set custom admin class custom headers.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_CLASS_HEADERS="Class Headers" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_ADD_CUSTOM_ADMIN_VIEW_MODEL_LABEL="Target Custom Admin View
Model Header" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_ADD_CUSTOM_ADMIN_VIEW_MODEL_DESCRIPTION="Only use this option if you have a getItem as your Main Get." diff --git a/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.sys.ini b/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.sys.ini index f4ae144..309f1d1 100644 --- a/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.sys.ini +++ b/language/en-GB/en-GB.plg_content_componentbuildercustomadminheaderstabs.sys.ini @@ -1,6 +1,6 @@ PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS="Content - Componentbuilder Custom Admin Headers Tabs" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_DESCRIPTION="This plugin is used to set custom admin class custom headers." -PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_XML_DESCRIPTION="

Content - Componentbuilder Custom Admin Headers Tabs (v.2.0.1)

This plugin is used to set custom admin class custom headers.

Created by Llewellyn van der Merwe
Development started 8th December, 2020

" +PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_XML_DESCRIPTION="

Content - Componentbuilder Custom Admin Headers Tabs (v.3.0.0)

This plugin is used to set custom admin class custom headers.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_CLASS_HEADERS="Class Headers" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_ADD_CUSTOM_ADMIN_VIEW_MODEL_LABEL="Target Custom Admin View
Model Header" PLG_CONTENT_COMPONENTBUILDERCUSTOMADMINHEADERSTABS_ADD_CUSTOM_ADMIN_VIEW_MODEL_DESCRIPTION="Only use this option if you have a getItem as your Main Get." diff --git a/script.php b/script.php index 9bff16d..a9e6678 100644 --- a/script.php +++ b/script.php @@ -24,382 +24,4 @@ use Joomla\CMS\Filesystem\Folder; */ class plgContentComponentbuilderCustomAdminHeadersTabsInstallerScript { - - /** - * Called before any type of action - * - * @param string $route Which action is happening (install|uninstall|discover_install|update) - * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($route, $adapter) - { - // get application - $app = Factory::getApplication(); - - // the default for both install and update - $jversion = new JVersion(); - if (!$jversion->isCompatible('3.8.0')) - { - $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); - return false; - } - - if ('install' === $route) - { -// needs fix - - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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 Joomla Component Builder.', '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.1.18 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 1 && $jcbVersion[2] >= 18) || - ($jcbVersion[0] == 3 && $jcbVersion[1] > 1) || - $jcbVersion[0] > 3) - ) - { - $blockInstall = false; - } - } - - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB v3.1.18 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 Joomla Component Builder.', '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.14 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 14) || - ($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.14 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 Joomla Component Builder.', '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.1.18 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 1 && $jcbVersion[2] >= 18) || - ($jcbVersion[0] == 3 && $jcbVersion[1] > 1) || - $jcbVersion[0] > 3) - ) - { - $blockInstall = false; - } - } - - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB v3.1.18 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 Joomla Component Builder.', '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.14 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 14) || - ($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.14 or higher before installing this plugin.', 'error'); - return false; - } - - } - - return true; - } }