From 58c7545afe4517d70c8d95a13304666f3363555c Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 14 Oct 2021 16:31:37 +0200 Subject: [PATCH] first commit - v1.0.0 --- componentbuilderfieldorderingcompiler.php | 88 +++++++++++++++++++ componentbuilderfieldorderingcompiler.xml | 28 ++++++ index.html | 1 + ..._componentbuilderfieldorderingcompiler.ini | 7 ++ ...ponentbuilderfieldorderingcompiler.sys.ini | 7 ++ language/en-GB/index.html | 1 + language/index.html | 1 + script.php | 79 +++++++++++++++++ 8 files changed, 212 insertions(+) create mode 100644 componentbuilderfieldorderingcompiler.php create mode 100644 componentbuilderfieldorderingcompiler.xml create mode 100644 index.html create mode 100644 language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini create mode 100644 language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini create mode 100644 language/en-GB/index.html create mode 100644 language/index.html create mode 100644 script.php diff --git a/componentbuilderfieldorderingcompiler.php b/componentbuilderfieldorderingcompiler.php new file mode 100644 index 0000000..02ea19a --- /dev/null +++ b/componentbuilderfieldorderingcompiler.php @@ -0,0 +1,88 @@ + + * @github 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 Joomla\Registry\Registry; + +JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); + +/** + * Extension - Componentbuilder Field Ordering Compiler plugin. + * + * @package ComponentbuilderFieldOrderingCompiler + * @since 1.0.0 + */ +class PlgExtensionComponentbuilderFieldOrderingCompiler extends CMSPlugin +{ + /** + * Global switch to see if component have need of field ordering. + * + * @var boolean + * @since 1.0.0 + */ + protected $loadFieldordering = false; + + /** + * The Views active with default ordering options + * + * @var array + * @since 1.0.0 + */ + protected $activeViews = array(); + + /** + * Event Triggered in the compiler [on Before Model View Data] + * + * @return void + * + * @since 1.0 + */ + public function jcb_ce_onBeforeModelViewData(&$context, &$view, &$placeholders) + { + // add the privacy + $view->params = (isset($view->params) && ComponentbuilderHelper::checkJson($view->params)) ? json_decode($view->params, true) : $view->params; + if (ComponentbuilderHelper::checkArray($view->params) && isset($view->params['fieldordering']) && ComponentbuilderHelper::checkArray($view->params['fieldordering'])) + { + if ($view->params['fieldordering']['add_admin_ordering'] == 1 + || $view->params['fieldordering']['add_linked_ordering'] == 1) + { + // activate the load of the privacy plugin + $this->loadFieldordering = true; + // setup the view key name + $name_list = ComponentbuilderHelper::safeString($view->name_list); + // load the admin view details + $this->activeViews[$name_list] = $view->params['fieldordering']; + } + } + } + + /** + * Event Triggered in the compiler [on After Get] + * + * @return void + * + * @since 1.0 + */ + public function jcb_ce_onAfterGet(&$context, $compiler) + { + // check if this component needs a privacy plugin loaded + if ($this->loadFieldordering) + { + // move the data to the compiler + $compiler->viewsDefaultOrdering =& $this->activeViews; + } + } + +} diff --git a/componentbuilderfieldorderingcompiler.xml b/componentbuilderfieldorderingcompiler.xml new file mode 100644 index 0000000..7bc710c --- /dev/null +++ b/componentbuilderfieldorderingcompiler.xml @@ -0,0 +1,28 @@ + + + PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER + 20th February, 2021 + Llewellyn van der Merwe + llewellyn@joomlacomponentbuilder.com + http://www.joomlacomponentbuilder.com + Copyright (C) 2015 Vast Development Method. All rights reserved. + GNU General Public License version 2 or later; see LICENSE.txt + 1.0.0 + PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_XML_DESCRIPTION + + + script.php + + + + en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini + en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini + + + + + componentbuilderfieldorderingcompiler.php + index.html + language + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini b/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini new file mode 100644 index 0000000..f56aed0 --- /dev/null +++ b/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini @@ -0,0 +1,7 @@ +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER="Extension - Componentbuilder Field Ordering Compiler" +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_DESCRIPTION="This plugin is used to set the ordring for your component views 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 set your admin views where you would like to use Field Ordering." +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Field Ordering Compiler (v.1.0.0)

This plugin is used to set the ordring for your component views 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 set your admin views where you would like to use Field Ordering.

Created by Llewellyn van der Merwe
Development started 21st May, 2020

" \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini b/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini new file mode 100644 index 0000000..f56aed0 --- /dev/null +++ b/language/en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini @@ -0,0 +1,7 @@ +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER="Extension - Componentbuilder Field Ordering Compiler" +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_DESCRIPTION="This plugin is used to set the ordring for your component views 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 set your admin views where you would like to use Field Ordering." +PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Field Ordering Compiler (v.1.0.0)

This plugin is used to set the ordring for your component views 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 set your admin views where you would like to use Field Ordering.

Created by Llewellyn van der Merwe
Development started 21st May, 2020

" \ No newline at end of file diff --git a/language/en-GB/index.html b/language/en-GB/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/en-GB/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/index.html b/language/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/script.php b/script.php new file mode 100644 index 0000000..eda2520 --- /dev/null +++ b/script.php @@ -0,0 +1,79 @@ + + * @github 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'); + +/** + * Extension - Componentbuilder Field Ordering Compiler script file. + * + * @package PlgExtensionComponentbuilderFieldOrderingCompiler + */ +class plgExtensionComponentbuilderFieldOrderingCompilerInstallerScript +{ + + /** + * Called before any type of action + * + * @param string $route Which action is happening (install|uninstall|discover_install|update) + * @param JAdapterInstance $adapter The object responsible for running this script + * + * @return boolean True on success + */ + public function preflight($route, JAdapterInstance $adapter) + { + // get application + $app = JFactory::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) + { + // 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.11.1 or higher installed + if (count($jcbVersion) == 3 && $jcbVersion[0] >= 2 && $jcbVersion[1] >= 11 && (($jcbVersion[1] == 11 && $jcbVersion[2] >= 1) || ($jcbVersion[1] > 11))) + { + $blockInstall = false; + } + } + // allow install if all conditions are met + if ($blockInstall) + { + $app->enqueueMessage('Please upgrade to JCB 2.11.1 or higher before installing this plugin.', 'error'); + return false; + } + } + + return true; + } +}