2021-12-03 02:46:29 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
2022-08-20 16:38:51 +00:00
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-12-03 02:46:29 +00:00
|
|
|
* @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');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Language\Text;
|
2024-03-11 14:14:23 +00:00
|
|
|
use Joomla\CMS\Plugin\CMSPlugin;
|
|
|
|
use VDM\Joomla\Componentbuilder\Compiler\Factory as CompilerFactory;
|
|
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
2021-12-03 02:46:29 +00:00
|
|
|
/**
|
|
|
|
* Extension - Componentbuilder Powers Autoloader Compiler plugin.
|
|
|
|
*
|
|
|
|
* @package ComponentbuilderPowersAutoloaderCompiler
|
2024-03-11 14:14:23 +00:00
|
|
|
* @since 2.0.0
|
2021-12-03 02:46:29 +00:00
|
|
|
*/
|
|
|
|
class PlgExtensionComponentbuilderPowersAutoloaderCompiler extends CMSPlugin
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Affects constructor behavior. If true, language files will be loaded automatically.
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
protected $autoloadLanguage = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event Triggered in the compiler [on After Get]
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
2024-03-02 20:10:30 +00:00
|
|
|
public function jcb_ce_onAfterGet()
|
2021-12-03 02:46:29 +00:00
|
|
|
{
|
|
|
|
// check if this component needs a power autoloader plugin loaded
|
2024-03-11 14:14:23 +00:00
|
|
|
if (CompilerFactory::_('Config')->add_power && $this->componentActive())
|
2021-12-03 02:46:29 +00:00
|
|
|
{
|
|
|
|
// now get the plugin ID if set
|
|
|
|
if (($id = (int) $this->params->get('plugin', 0)) !== 0)
|
|
|
|
{
|
|
|
|
// load the power autoloader plugin
|
2024-03-11 14:14:23 +00:00
|
|
|
CompilerFactory::_('Joomlaplugin.Data')->set($id);
|
2021-12-03 02:46:29 +00:00
|
|
|
// now set the plugin powers placeholder
|
2024-03-11 14:14:23 +00:00
|
|
|
CompilerFactory::_('Compiler.Builder.Content.One')->set('PLUGIN_POWER_AUTOLOADER', '');
|
2021-12-03 02:46:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
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');
|
2021-12-03 02:46:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The array of active components
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $componentsActive;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The activate option
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $activateOption = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the line number in comments
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*
|
|
|
|
*/
|
2024-03-02 20:10:30 +00:00
|
|
|
protected function componentActive()
|
2021-12-03 02:46:29 +00:00
|
|
|
{
|
|
|
|
// check the active option
|
|
|
|
if (!$this->activateOption)
|
|
|
|
{
|
|
|
|
$this->activateOption = $this->params->get('activate_option', 1);
|
|
|
|
}
|
|
|
|
// active for all components
|
|
|
|
if ($this->activateOption == 1)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// first check is we have the active components set
|
2023-10-18 07:28:04 +00:00
|
|
|
if ($this->activateOption == 2 && !ArrayHelper::check($this->componentsActive))
|
2021-12-03 02:46:29 +00:00
|
|
|
{
|
|
|
|
$this->componentsActive = $this->params->get('components');
|
|
|
|
}
|
|
|
|
// only check if there are active
|
2023-10-18 07:28:04 +00:00
|
|
|
if (ArrayHelper::check($this->componentsActive))
|
2021-12-03 02:46:29 +00:00
|
|
|
{
|
2024-03-11 14:14:23 +00:00
|
|
|
return in_array((int) CompilerFactory::_('Config')->component_id, $this->componentsActive);
|
2021-12-03 02:46:29 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|