52
0

update - v1.0.1

This commit is contained in:
Llewellyn van der Merwe 2021-12-16 11:22:04 +02:00
parent 3b3e59d2ad
commit 337746671f
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
8 changed files with 304 additions and 51 deletions

View File

@ -3,8 +3,8 @@
* @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>
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder-Pro>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
@ -21,7 +21,7 @@ JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/c
* Content - Componentbuilder Component Headers Tabs plugin.
*
* @package ComponentbuilderComponentHeadersTabs
* @since 1.0.0
* @since 1.0.1
*/
class PlgContentComponentbuilderComponentHeadersTabs extends CMSPlugin
{

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.8" group="content" method="upgrade">
<extension type="plugin" version="4" group="content" method="upgrade">
<name>PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS</name>
<creationDate>20th February, 2021</creationDate>
<creationDate>16th December, 2021</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</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>
<version>1.0.1</version>
<description>PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_XML_DESCRIPTION</description>
<!-- Scripts to run on installation -->

184
fields/powers.php Normal file
View File

@ -0,0 +1,184 @@
<?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-Pro>
* @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');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Powers Form Field class for the Componentbuilder component
*/
class JFormFieldPowers extends JFormFieldList
{
/**
* The powers field type.
*
* @var string
*/
public $type = 'powers';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$set_button = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($set_button === 'true')
{
$button = array();
$script = array();
$button_code_name = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) && strlen($values['view']))
{
// only load referral if not new item.
$ref = '&amp;ref=' . $values['view'] . '&amp;refid=' . $values['id'];
$refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
// get the return value.
$_uri = (string) JUri::getInstance();
$_return = urlencode(base64_encode($_uri));
// load return value.
$ref .= '&amp;return=' . $_return;
$refJ .= '&return=' . $_return;
}
// get button label
$button_label = trim($button_code_name);
$button_label = preg_replace('/_+/', ' ', $button_label);
$button_label = preg_replace('/\s+/', ' ', $button_label);
$button_label = preg_replace("/[^A-Za-z ]/", '', $button_label);
$button_label = ucfirst(strtolower($button_label));
// get user object
$user = JFactory::getUser();
// only add if user allowed to create power
if ($user->authorise('power.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build Create button
$button[] = '<a id="'.$button_code_name.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_CREATE_NEW_S', $button_label).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
href="index.php?option=com_componentbuilder&amp;view=power&amp;layout=edit'.$ref.'" >
<span class="icon-new icon-white"></span></a>';
}
// only add if user allowed to edit power
if ($user->authorise('power.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$button[] = '<a id="'.$button_code_name.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_EDIT_S', $button_label).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) {
e.preventDefault();
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
function ".$button_code_name."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$button_code_name."Create').hide();
// show edit button
jQuery('#".$button_code_name."Edit').show();
var url = 'index.php?option=com_componentbuilder&view=powers&task=power.edit&id='+value+'".$refJ."';
jQuery('#".$button_code_name."Edit').attr('href', url);
} else {
// show the create button
jQuery('#".$button_code_name."Create').show();
// hide edit button
jQuery('#".$button_code_name."Edit').hide();
}
}";
}
// check if button was created for power field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html . implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.system_name','a.name','a.type','a.power_version'),array('id','power_admin_component_system_name','name','type','version')));
$query->from($db->quoteName('#__componentbuilder_power', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
$query->order('a.system_name ASC');
$query->order('a.type ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options', 'com_componentbuilder'))
{
$columns = $db->getTableColumns('#__componentbuilder_power');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
// if none was found, we add this to set an alternative to set custom
if (!$items)
{
$options[] = JHtml::_('select.option', '', JText::_('PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NONE_FOUND'));
}
if ($items)
{
if ($this->multiple === false)
{
$options[] = JHtml::_('select.option', '', JText::_('PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SELECT_AN_OPTION'));
}
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->power_admin_component_system_name . ' [' . $item->type . ' ' . $item->name . '] (v' . $item->version . ')');
}
}
return $options;
}
}

View File

@ -39,6 +39,18 @@
validate="code"
showon="add_admin_component:1"
/>
<!-- Power_admin_component Field. Type: Powers. (custom) -->
<field
type="powers"
name="power_admin_component"
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_ADMIN_COMPONENT_LABEL"
class="list_class span12"
multiple="true"
default="0"
required="false"
showon="add_admin_component:1"
button="true"
/>
<!-- Add_site_component Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -70,6 +82,18 @@
validate="code"
showon="add_site_component:1"
/>
<!-- Power_site_component Field. Type: Powers. (custom) -->
<field
type="powers"
name="power_site_component"
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_SITE_COMPONENT_LABEL"
class="list_class span12"
multiple="true"
default="0"
required="false"
showon="add_site_component:1"
button="true"
/>
<!-- Add_admin_helper Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -101,6 +125,18 @@
validate="code"
showon="add_admin_helper:1"
/>
<!-- Power_admin_helper Field. Type: Powers. (custom) -->
<field
type="powers"
name="power_admin_helper"
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_ADMIN_HELPER_LABEL"
class="list_class span12"
multiple="true"
default="0"
required="false"
showon="add_admin_helper:1"
button="true"
/>
<!-- Add_site_helper Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -132,6 +168,18 @@
validate="code"
showon="add_site_helper:1"
/>
<!-- Power_site_helper Field. Type: Powers. (custom) -->
<field
type="powers"
name="power_site_helper"
label="PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_SITE_HELPER_LABEL"
class="list_class span12"
multiple="true"
default="0"
required="false"
showon="add_site_helper:1"
button="true"
/>
</fields>
</fieldset>
</fields>

View File

@ -1,18 +1,28 @@
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_XML_DESCRIPTION="<h1>Content - Componentbuilder Component Headers Tabs (v.1.0.1)</h1> <div style='clear: both;'></div><p>This plugin is used to set component class custom headers.</p><p>Created by <a href='https://dev.vdm.io' 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_POWER_ADMIN_COMPONENT_LABEL="Power Header<br />
<small>(admin.component)</small>"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NONE_FOUND="None found"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SELECT_AN_OPTION="Select an option"
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_POWER_SITE_COMPONENT_LABEL="Powers 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_POWER_ADMIN_HELPER_LABEL="Power 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>"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_SITE_HELPER_LABEL="Power Header<br />
<small>(site.helper)</small>"

View File

@ -1,18 +1,28 @@
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_XML_DESCRIPTION="<h1>Content - Componentbuilder Component Headers Tabs (v.1.0.1)</h1> <div style='clear: both;'></div><p>This plugin is used to set component class custom headers.</p><p>Created by <a href='https://dev.vdm.io' 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_POWER_ADMIN_COMPONENT_LABEL="Power Header<br />
<small>(admin.component)</small>"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_NONE_FOUND="None found"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_SELECT_AN_OPTION="Select an option"
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_POWER_SITE_COMPONENT_LABEL="Powers 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_POWER_ADMIN_HELPER_LABEL="Power 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>"
PLG_CONTENT_COMPONENTBUILDERCOMPONENTHEADERSTABS_POWER_SITE_HELPER_LABEL="Power Header<br />
<small>(site.helper)</small>"

View File

@ -3,8 +3,8 @@
* @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>
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder-Pro>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

View File

@ -3,8 +3,8 @@
* @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>
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder-Pro>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
@ -43,11 +43,12 @@ class plgContentComponentbuilderComponentHeadersTabsInstallerScript
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');
$app->enqueueMessage('JCB must first be installed from <a href="https://git.vdm.dev/joomla/Component-Builder-Pro/" target="_blank">Joomla Component Builder</a>.', 'error');
return false;
}
// load the helper class
@ -60,8 +61,8 @@ class plgContentComponentbuilderComponentHeadersTabsInstallerScript
{
// 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))
// check that we have JCB 3 or higher installed
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3)
{
$blockInstall = false;
}
@ -69,7 +70,7 @@ class plgContentComponentbuilderComponentHeadersTabsInstallerScript
// 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');
$app->enqueueMessage('Please upgrade to JCB-Pro v3.0.0 or higher before installing this plugin.', 'error');
return false;
}
}