first commit - v1.0.0
This commit is contained in:
commit
58c7545afe
88
componentbuilderfieldorderingcompiler.php
Normal file
88
componentbuilderfieldorderingcompiler.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
28
componentbuilderfieldorderingcompiler.xml
Normal file
28
componentbuilderfieldorderingcompiler.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.8" group="extension" method="upgrade">
|
||||
<name>PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER</name>
|
||||
<creationDate>20th February, 2021</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||
<authorUrl>http://www.joomlacomponentbuilder.com</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.0.0</version>
|
||||
<description>PLG_EXTENSION_COMPONENTBUILDERFIELDORDERINGCOMPILER_XML_DESCRIPTION</description>
|
||||
|
||||
<!-- Scripts to run on installation -->
|
||||
<scriptfile>script.php</scriptfile>
|
||||
|
||||
<!-- Language files -->
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderfieldorderingcompiler.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<!-- Plugin files -->
|
||||
<files>
|
||||
<filename plugin="componentbuilderfieldorderingcompiler">componentbuilderfieldorderingcompiler.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
</extension>
|
1
index.html
Normal file
1
index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -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="<h1>Extension - Componentbuilder Field Ordering Compiler (v.1.0.0)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 21st May, 2020</small></p>"
|
@ -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="<h1>Extension - Componentbuilder Field Ordering Compiler (v.1.0.0)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 21st May, 2020</small></p>"
|
1
language/en-GB/index.html
Normal file
1
language/en-GB/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
1
language/index.html
Normal file
1
language/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
79
script.php
Normal file
79
script.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/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 <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.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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user