2021-12-08 20:41: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-08 20:41: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');
|
|
|
|
|
|
|
|
use Joomla\CMS\Form\Form;
|
2024-03-11 16:31:53 +00:00
|
|
|
use Joomla\CMS\Plugin\CMSPlugin;
|
|
|
|
use Joomla\CMS\Component\ComponentHelper;
|
2023-10-18 07:28:04 +00:00
|
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
2021-12-08 20:41:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Content - Componentbuilder Component Dashboard Headers Tabs plugin.
|
|
|
|
*
|
|
|
|
* @package ComponentbuilderComponentDashboardHeadersTabs
|
2024-03-11 16:31:53 +00:00
|
|
|
* @since 3.0.0
|
2021-12-08 20:41:29 +00:00
|
|
|
*/
|
|
|
|
class PlgContentComponentbuilderComponentDashboardHeadersTabs extends CMSPlugin
|
|
|
|
{
|
2022-01-10 14:10:43 +00:00
|
|
|
|
2021-12-08 20:41:29 +00:00
|
|
|
/**
|
2024-03-11 16:31:53 +00:00
|
|
|
* Affects constructor behaviour. If true, language files will be loaded automatically.
|
2021-12-08 20:41:29 +00:00
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
|
|
|
protected $autoloadLanguage = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs on content preparation of form.
|
|
|
|
*
|
2024-03-11 16:31:53 +00:00
|
|
|
* @param Form $form The form
|
|
|
|
* @param \stdClass $data The data
|
2021-12-08 20:41:29 +00:00
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
|
|
|
public function onContentPrepareForm(Form $form, $data)
|
|
|
|
{
|
|
|
|
$context = $form->getName();
|
|
|
|
|
2022-01-10 14:10:43 +00:00
|
|
|
// When this is componentbuilder component_dashboard
|
2021-12-08 20:41:29 +00:00
|
|
|
if (strpos($context, 'com_componentbuilder.component_dashboard') === 0)
|
|
|
|
{
|
|
|
|
// Add the forms path
|
|
|
|
Form::addFormPath(__DIR__ . '/forms');
|
|
|
|
// add the admin view params for privacy integration
|
|
|
|
$form->loadFile('component_dashboard');
|
|
|
|
// update all editors to use this components global editor
|
2024-03-11 16:31:53 +00:00
|
|
|
$global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none');
|
2021-12-08 20:41:29 +00:00
|
|
|
// set the field editor value (with none as fallback)
|
|
|
|
$editors = $form->getXml()->xpath('descendant::fields[@name="component_dashboard_headers"]//field[@type="editor"]');
|
|
|
|
// check if we found any
|
2023-10-18 07:28:04 +00:00
|
|
|
if (ArrayHelper::check($editors))
|
2021-12-08 20:41:29 +00:00
|
|
|
{
|
|
|
|
foreach ($editors as $editor)
|
|
|
|
{
|
|
|
|
// set the editor to the global option
|
|
|
|
$editor['editor'] = $global_editor . '|none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|