first commit - v1.0.0
This commit is contained in:
commit
3b3e59d2ad
73
componentbuildercomponentheaderstabs.php
Normal file
73
componentbuildercomponentheaderstabs.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?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\Form\Form;
|
||||||
|
use Joomla\CMS\Plugin\CMSPlugin;
|
||||||
|
|
||||||
|
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content - Componentbuilder Component Headers Tabs plugin.
|
||||||
|
*
|
||||||
|
* @package ComponentbuilderComponentHeadersTabs
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class PlgContentComponentbuilderComponentHeadersTabs extends CMSPlugin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
protected $autoloadLanguage = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs on content preparation of form.
|
||||||
|
*
|
||||||
|
* @param JForm $form The form
|
||||||
|
* @param stdClass $data The data
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public function onContentPrepareForm(Form $form, $data)
|
||||||
|
{
|
||||||
|
$context = $form->getName();
|
||||||
|
|
||||||
|
// When this is componentbuilder joomla component
|
||||||
|
if (strpos($context, 'com_componentbuilder.joomla_component') === 0)
|
||||||
|
{
|
||||||
|
// Add the forms path
|
||||||
|
Form::addFormPath(__DIR__ . '/forms');
|
||||||
|
// add the admin view params for privacy integration
|
||||||
|
$form->loadFile('joomla_component');
|
||||||
|
// update all editors to use this components global editor
|
||||||
|
$global_editor = JComponentHelper::getParams('com_componentbuilder')->get('editor', 'none');
|
||||||
|
// set the field editor value (with none as fallback)
|
||||||
|
$editors = $form->getXml()->xpath('descendant::fields[@name="joomla_component_headers"]//field[@type="editor"]');
|
||||||
|
// check if we found any
|
||||||
|
if (ComponentbuilderHelper::checkArray($editors))
|
||||||
|
{
|
||||||
|
foreach ($editors as $editor)
|
||||||
|
{
|
||||||
|
// set the editor to the global option
|
||||||
|
$editor['editor'] = $global_editor . '|none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
31
componentbuildercomponentheaderstabs.xml
Normal file
31
componentbuildercomponentheaderstabs.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<extension type="plugin" version="3.8" group="content" method="upgrade">
|
||||||
|
<name>PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS</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_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_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_content_componentbuildercomponentheaderstabs.ini</language>
|
||||||
|
<language tag="en-GB">en-GB/en-GB.plg_content_componentbuildercomponentheaderstabs.sys.ini</language>
|
||||||
|
</languages>
|
||||||
|
|
||||||
|
<!-- Plugin files -->
|
||||||
|
<files>
|
||||||
|
<filename plugin="componentbuildercomponentheaderstabs">componentbuildercomponentheaderstabs.php</filename>
|
||||||
|
<filename>index.html</filename>
|
||||||
|
<folder>language</folder>
|
||||||
|
<folder>fields</folder>
|
||||||
|
<folder>forms</folder>
|
||||||
|
<folder>rules</folder>
|
||||||
|
</files>
|
||||||
|
</extension>
|
1
fields/index.html
Normal file
1
fields/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
1
forms/index.html
Normal file
1
forms/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
138
forms/joomla_component.xml
Normal file
138
forms/joomla_component.xml
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- default paths of joomla_component form points to componentbuilder -->
|
||||||
|
<form>
|
||||||
|
<fields name="params">
|
||||||
|
<!-- default paths of joomla_component_headers fieldset points to the plugin -->
|
||||||
|
<fieldset name="joomla_component_headers" label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_CLASS_HEADERS"
|
||||||
|
addrulepath="/plugins/content/componentbuildercomponentheaderstabs/rules"
|
||||||
|
addfieldpath="/plugins/content/componentbuildercomponentheaderstabs/fields"
|
||||||
|
>
|
||||||
|
<fields name="joomla_component_headers">
|
||||||
|
<!-- Add_admin_component Field. Type: Radio. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="radio"
|
||||||
|
name="add_admin_component"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_COMPONENT_LABEL"
|
||||||
|
class="btn-group btn-group-yesno"
|
||||||
|
default="0"
|
||||||
|
required="true">
|
||||||
|
<!-- Option Set. -->
|
||||||
|
<option value="1">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES</option>
|
||||||
|
<option value="0">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO</option>
|
||||||
|
</field>
|
||||||
|
<!-- Admin_component Field. Type: Editor. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="editor"
|
||||||
|
name="admin_component"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_COMPONENT_LABEL"
|
||||||
|
width="100%"
|
||||||
|
height="100px"
|
||||||
|
cols="15"
|
||||||
|
rows="10"
|
||||||
|
buttons="no"
|
||||||
|
syntax="php"
|
||||||
|
editor="codemirror|none"
|
||||||
|
filter="raw"
|
||||||
|
required="false"
|
||||||
|
validate="code"
|
||||||
|
showon="add_admin_component:1"
|
||||||
|
/>
|
||||||
|
<!-- Add_site_component Field. Type: Radio. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="radio"
|
||||||
|
name="add_site_component"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_COMPONENT_LABEL"
|
||||||
|
class="btn-group btn-group-yesno"
|
||||||
|
default="0"
|
||||||
|
required="true">
|
||||||
|
<!-- Option Set. -->
|
||||||
|
<option value="1">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES</option>
|
||||||
|
<option value="0">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO</option>
|
||||||
|
</field>
|
||||||
|
<!-- Site_component Field. Type: Editor. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="editor"
|
||||||
|
name="site_component"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_COMPONENT_LABEL"
|
||||||
|
width="100%"
|
||||||
|
height="100px"
|
||||||
|
cols="15"
|
||||||
|
rows="10"
|
||||||
|
buttons="no"
|
||||||
|
syntax="php"
|
||||||
|
editor="codemirror|none"
|
||||||
|
filter="raw"
|
||||||
|
required="false"
|
||||||
|
validate="code"
|
||||||
|
showon="add_site_component:1"
|
||||||
|
/>
|
||||||
|
<!-- Add_admin_helper Field. Type: Radio. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="radio"
|
||||||
|
name="add_admin_helper"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_HELPER_LABEL"
|
||||||
|
class="btn-group btn-group-yesno"
|
||||||
|
default="0"
|
||||||
|
required="true">
|
||||||
|
<!-- Option Set. -->
|
||||||
|
<option value="1">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES</option>
|
||||||
|
<option value="0">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO</option>
|
||||||
|
</field>
|
||||||
|
<!-- Admin_helper Field. Type: Editor. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="editor"
|
||||||
|
name="admin_helper"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_HELPER_LABEL"
|
||||||
|
width="100%"
|
||||||
|
height="100px"
|
||||||
|
cols="15"
|
||||||
|
rows="10"
|
||||||
|
buttons="no"
|
||||||
|
syntax="php"
|
||||||
|
editor="codemirror|none"
|
||||||
|
filter="raw"
|
||||||
|
required="false"
|
||||||
|
validate="code"
|
||||||
|
showon="add_admin_helper:1"
|
||||||
|
/>
|
||||||
|
<!-- Add_site_helper Field. Type: Radio. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="radio"
|
||||||
|
name="add_site_helper"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_HELPER_LABEL"
|
||||||
|
class="btn-group btn-group-yesno"
|
||||||
|
default="0"
|
||||||
|
required="true">
|
||||||
|
<!-- Option Set. -->
|
||||||
|
<option value="1">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES</option>
|
||||||
|
<option value="0">
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO</option>
|
||||||
|
</field>
|
||||||
|
<!-- Site_helper Field. Type: Editor. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="editor"
|
||||||
|
name="site_helper"
|
||||||
|
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_HELPER_LABEL"
|
||||||
|
width="100%"
|
||||||
|
height="100px"
|
||||||
|
cols="15"
|
||||||
|
rows="10"
|
||||||
|
buttons="no"
|
||||||
|
syntax="php"
|
||||||
|
editor="codemirror|none"
|
||||||
|
filter="raw"
|
||||||
|
required="false"
|
||||||
|
validate="code"
|
||||||
|
showon="add_site_helper:1"
|
||||||
|
/>
|
||||||
|
</fields>
|
||||||
|
</fieldset>
|
||||||
|
</fields>
|
||||||
|
</form>
|
1
index.html
Normal file
1
index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,18 @@
|
|||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS="Content - Componentbuilder Component Headers Tabs"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_DESCRIPTION="This plugin is used to set component class custom headers."
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_XML_DESCRIPTION="<h1>Content - Componentbuilder Component Headers Tabs (v.1.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to set component class custom headers.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 26th December, 2020</small></p>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_CLASS_HEADERS="Class Headers"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_COMPONENT_LABEL="Admin Component<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES="Yes"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO="No"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_COMPONENT_LABEL="Header<br />
|
||||||
|
<small>(admin.component)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_COMPONENT_LABEL="Site Component<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_COMPONENT_LABEL="Header<br />
|
||||||
|
<small>(site.component)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_HELPER_LABEL="Admin Helper<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_HELPER_LABEL="Header<br />
|
||||||
|
<small>(admin.helper)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_HELPER_LABEL="Site Helper<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_HELPER_LABEL="Header<br />
|
||||||
|
<small>(site.helper)</small>"
|
@ -0,0 +1,18 @@
|
|||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS="Content - Componentbuilder Component Headers Tabs"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_DESCRIPTION="This plugin is used to set component class custom headers."
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_XML_DESCRIPTION="<h1>Content - Componentbuilder Component Headers Tabs (v.1.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to set component class custom headers.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 26th December, 2020</small></p>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_CLASS_HEADERS="Class Headers"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_COMPONENT_LABEL="Admin Component<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_YES="Yes"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NO="No"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_COMPONENT_LABEL="Header<br />
|
||||||
|
<small>(admin.component)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_COMPONENT_LABEL="Site Component<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_COMPONENT_LABEL="Header<br />
|
||||||
|
<small>(site.component)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_ADMIN_HELPER_LABEL="Admin Helper<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADMIN_HELPER_LABEL="Header<br />
|
||||||
|
<small>(admin.helper)</small>"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_ADD_SITE_HELPER_LABEL="Site Helper<br />Header"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SITE_HELPER_LABEL="Header<br />
|
||||||
|
<small>(site.helper)</small>"
|
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>
|
53
rules/code.php
Normal file
53
rules/code.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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('JPATH_PLATFORM') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\Form\Form;
|
||||||
|
use Joomla\CMS\Form\FormRule;
|
||||||
|
use Joomla\Registry\Registry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form Rule (Code) class for the Joomla Platform.
|
||||||
|
*/
|
||||||
|
class JFormRuleCode extends FormRule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method to test the value.
|
||||||
|
*
|
||||||
|
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
|
||||||
|
* @param mixed $value The form field value to validate.
|
||||||
|
* @param string $group The field name group control value. This acts as an array container for the field.
|
||||||
|
* For example if the field has name="foo" and the group value is set to "bar" then the
|
||||||
|
* full field name would end up being "bar[foo]".
|
||||||
|
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
|
||||||
|
* @param Form $form The form object for which the field is being tested.
|
||||||
|
*
|
||||||
|
* @return boolean True if the value is valid, false otherwise.
|
||||||
|
*/
|
||||||
|
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
|
||||||
|
{
|
||||||
|
// This removes all validation (is dangerous) but needed to submit code via JCB
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* My idea is to add some kind of validation to improve JCB code (per/language)
|
||||||
|
*
|
||||||
|
* So at this time this code validation is used for JavaScript,CSS,HTML and PHP.
|
||||||
|
* We can see what language is being worked on with the syntax property in the $element. (in JCB)
|
||||||
|
* What complicates things is the placeholders, of both custom code, component, and view names.
|
||||||
|
* Ideally we could strip them and then validate the code to being syntactically correct.
|
||||||
|
* But since some of the placeholders form part of the class/function names and the more, it seems like we are pressed for a much more advance solution.
|
||||||
|
* If you have any ideas to how we can go about to do this, then please open an issue on github and lets begin. (this is a nice to have, so don't break a leg...)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
1
rules/index.html
Normal file
1
rules/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');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content - Componentbuilder Component Headers Tabs script file.
|
||||||
|
*
|
||||||
|
* @package PlgContentComponentbuilderComponentHeadersTabs
|
||||||
|
*/
|
||||||
|
class plgContentComponentbuilderComponentHeadersTabsInstallerScript
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.12.4 or higher installed
|
||||||
|
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 2 && (($jcbVersion[1] == 12 && $jcbVersion[2] >= 4) || $jcbVersion[1] > 12))
|
||||||
|
{
|
||||||
|
$blockInstall = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// allow install if all conditions are met
|
||||||
|
if ($blockInstall)
|
||||||
|
{
|
||||||
|
$app->enqueueMessage('Please upgrade to JCB 2.12.4 or higher before installing this plugin.', 'error');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user