Robot
85610e0f7a
Here's an update on the current version, which includes changes towards the next release still in beta.
92 lines
2.6 KiB
PHP
92 lines
2.6 KiB
PHP
<?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 Joomla\Registry\Registry;
|
|
use VDM\Joomla\Utilities\JsonHelper;
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
|
use VDM\Joomla\Utilities\StringHelper;
|
|
|
|
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
|
|
|
/**
|
|
* Extension - Componentbuilder Field Ordering Compiler plugin.
|
|
*
|
|
* @package ComponentbuilderFieldOrderingCompiler
|
|
* @since 1.0.2
|
|
*/
|
|
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) && JsonHelper::check($view->params)) ? json_decode($view->params, true) : $view->params;
|
|
if (ArrayHelper::check($view->params) && isset($view->params['fieldordering']) && ArrayHelper::check($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 = StringHelper::safe($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;
|
|
}
|
|
}
|
|
|
|
}
|