Adds licensing template option to the powers area.

This commit is contained in:
2022-09-20 13:06:03 +02:00
parent f4fccfe761
commit 5537a868e3
119 changed files with 1244 additions and 1069 deletions

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.5) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.6) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -140,13 +140,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 19th September, 2022
+ *Version*: 3.1.5
+ *Last Build*: 20th September, 2022
+ *Version*: 3.1.6
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **331435**
+ *Field count*: **2002**
+ *File count*: **2167**
+ *Line count*: **331597**
+ *Field count*: **2004**
+ *File count*: **2169**
+ *Folder count*: **375**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -514,11 +514,16 @@ class Structure extends Get
. $power->file_name . '.php',
'name' => $power->file_name . '.php',
'zip' => $power->file_name . '.php');
$bom = '<?php' . PHP_EOL . '// A POWER FILE' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL;
// add custom override if found
if ($power->add_licensing_template == 2)
{
$bom = '<?php' . PHP_EOL . $power->licensing_template;
}
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// A POWER FILE' .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . Placefix::_h('POWERCODE')
$bom . PHP_EOL . Placefix::_h('POWERCODE')
);
$this->newFiles[$power->key][] = $fileDetails;
// count the file created

View File

@ -7999,6 +7999,8 @@ COM_COMPONENTBUILDER_POWERS_SUBMENU_DESC="Allows the users in this group to subm
COM_COMPONENTBUILDER_POWER_ABSTRACT_CLASS="abstract class"
COM_COMPONENTBUILDER_POWER_ADD_HEAD_DESCRIPTION="You can add your own custom header script, combined with the default header script that make the extended class work."
COM_COMPONENTBUILDER_POWER_ADD_HEAD_LABEL="Add Custom Class Header"
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION="The option to override the licensing template."
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL="Add Licensing Template"
COM_COMPONENTBUILDER_POWER_AS_LABEL="as"
COM_COMPONENTBUILDER_POWER_CLASS="class"
COM_COMPONENTBUILDER_POWER_CODE="Code"
@ -8029,6 +8031,17 @@ COM_COMPONENTBUILDER_POWER_IMPLEMENTS_CUSTOM_MESSAGE="Error! Please add the cust
COM_COMPONENTBUILDER_POWER_IMPLEMENTS_DESCRIPTION="The interface(s), this class should implement."
COM_COMPONENTBUILDER_POWER_IMPLEMENTS_LABEL="Implements interface(s)"
COM_COMPONENTBUILDER_POWER_INTERFACE="interface"
COM_COMPONENTBUILDER_POWER_LICENSING="Licensing"
COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_HINT="/**
* @package Joomla.Component.Builder
*
* @created 3rd September, 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
*/"
COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_LABEL="Licensing Template"
COM_COMPONENTBUILDER_POWER_LOAD="Load"
COM_COMPONENTBUILDER_POWER_LOAD_LABEL="load"
COM_COMPONENTBUILDER_POWER_LOAD_POWERS_NOTE_DESCRIPTION="<p>When you would like to load a power to the project, but you do not want that power to be part of the <b>use namespace declarations</b> in the header of this power.</p>
@ -8084,6 +8097,7 @@ COM_COMPONENTBUILDER_POWER_NOTE_LINKED_TO_NOTICE_DESCRIPTION="<div id='display_l
COM_COMPONENTBUILDER_POWER_NOTE_LINKED_TO_NOTICE_LABEL="Linked To"
COM_COMPONENTBUILDER_POWER_NOT_REQUIRED="Not Required"
COM_COMPONENTBUILDER_POWER_ORDERING_LABEL="Ordering"
COM_COMPONENTBUILDER_POWER_OVERRIDE="Override"
COM_COMPONENTBUILDER_POWER_PERMISSION="Permissions"
COM_COMPONENTBUILDER_POWER_POWER_VERSION_DESCRIPTION="Add Version Number Here"
COM_COMPONENTBUILDER_POWER_POWER_VERSION_HINT="1.0.0"
@ -8106,6 +8120,7 @@ COM_COMPONENTBUILDER_POWER_TRAIT="trait"
COM_COMPONENTBUILDER_POWER_TYPE_DESCRIPTION="The type of power being build"
COM_COMPONENTBUILDER_POWER_TYPE_LABEL="Type of Power"
COM_COMPONENTBUILDER_POWER_USE="Use"
COM_COMPONENTBUILDER_POWER_USE_GLOBAL="Use Global"
COM_COMPONENTBUILDER_POWER_USE_LABEL="use"
COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION="Select namespace you want to use in your power."
COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL="Use Selection"

View File

@ -0,0 +1,45 @@
<?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');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'add_licensing_template',
'licensing_template'
);
$hiddenFields = $displayData->get('hidden_fields') ?: array();
?>
<?php if ($fields && count((array) $fields)) :?>
<div class="form-vertical">
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>

View File

@ -202,44 +202,6 @@
filter="raw"
validate="code"
/>
<!-- Use_selection Field. Type: Subform. (joomla) -->
<field
type="subform"
name="use_selection"
label="COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
icon="list"
max="30"
min="0"
showon="type!:interface">
<form hidden="true" name="list_use_selection_modal" repeat="true">
<!-- Use Field. Type: Namespaces. (custom) -->
<field
type="namespaces"
name="use"
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
class="list_class span12"
multiple="false"
default="0"
button="false"
/>
<!-- As Field. Type: Text. (joomla) -->
<field
type="text"
name="as"
label="COM_COMPONENTBUILDER_POWER_AS_LABEL"
size="10"
maxlength="50"
default="default"
class="text_area"
filter="STRING"
autocomplete="on"
/>
</form>
</field>
<!-- Description Field. Type: Textarea. (joomla) -->
<field
type="textarea"
@ -252,6 +214,19 @@
filter="HTML"
hint="COM_COMPONENTBUILDER_POWER_DESCRIPTION_HINT"
/>
<!-- Licensing_template Field. Type: Textarea. (joomla) -->
<field
type="textarea"
name="licensing_template"
label="COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_LABEL"
rows="10"
cols="10"
class="text_area span12"
filter="RAW"
hint="COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_HINT"
validate="code"
showon="add_licensing_template:2"
/>
<!-- Property_selection Field. Type: Subform. (joomla) -->
<field
type="subform"
@ -397,6 +372,59 @@
required="false"
validate="code"
/>
<!-- Add_licensing_template Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_licensing_template"
label="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL"
description="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_POWER_USE_GLOBAL</option>
<option value="2">
COM_COMPONENTBUILDER_POWER_OVERRIDE</option>
</field>
<!-- Use_selection Field. Type: Subform. (joomla) -->
<field
type="subform"
name="use_selection"
label="COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
icon="list"
max="30"
min="0"
showon="type!:interface">
<form hidden="true" name="list_use_selection_modal" repeat="true">
<!-- Use Field. Type: Namespaces. (custom) -->
<field
type="namespaces"
name="use"
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
class="list_class span12"
multiple="false"
default="0"
button="false"
/>
<!-- As Field. Type: Text. (joomla) -->
<field
type="text"
name="as"
label="COM_COMPONENTBUILDER_POWER_AS_LABEL"
size="10"
maxlength="50"
default="default"
class="text_area"
filter="STRING"
autocomplete="on"
/>
</form>
</field>
<!-- Guid Field. Type: Text. (joomla) -->
<field
type="text"

View File

@ -58,6 +58,12 @@ class ComponentbuilderModelPower extends AdminModel
'type',
'power_version'
)
),
'licensing' => array(
'fullwidth' => array(
'add_licensing_template',
'licensing_template'
)
)
);
@ -178,6 +184,12 @@ class ComponentbuilderModelPower extends AdminModel
$item->main_class_code = base64_decode($item->main_class_code);
}
if (!empty($item->licensing_template))
{
// base64 Decode licensing_template.
$item->licensing_template = base64_decode($item->licensing_template);
}
if (!empty($item->head))
{
// base64 Decode head.
@ -192,14 +204,6 @@ class ComponentbuilderModelPower extends AdminModel
$item->load_selection = $load_selection->toArray();
}
if (!empty($item->use_selection))
{
// Convert the use_selection field to an array.
$use_selection = new Registry;
$use_selection->loadString($item->use_selection);
$item->use_selection = $use_selection->toArray();
}
if (!empty($item->property_selection))
{
// Convert the property_selection field to an array.
@ -224,6 +228,14 @@ class ComponentbuilderModelPower extends AdminModel
$item->method_selection = $method_selection->toArray();
}
if (!empty($item->use_selection))
{
// Convert the use_selection field to an array.
$use_selection = new Registry;
$use_selection->loadString($item->use_selection);
$item->use_selection = $use_selection->toArray();
}
if (empty($item->id))
{
@ -1038,19 +1050,6 @@ class ComponentbuilderModelPower extends AdminModel
$data['load_selection'] = '';
}
// Set the use_selection items to data.
if (isset($data['use_selection']) && is_array($data['use_selection']))
{
$use_selection = new JRegistry;
$use_selection->loadArray($data['use_selection']);
$data['use_selection'] = (string) $use_selection;
}
elseif (!isset($data['use_selection']))
{
// Set the empty use_selection to data
$data['use_selection'] = '';
}
// Set the property_selection items to data.
if (isset($data['property_selection']) && is_array($data['property_selection']))
{
@ -1090,12 +1089,31 @@ class ComponentbuilderModelPower extends AdminModel
$data['method_selection'] = '';
}
// Set the use_selection items to data.
if (isset($data['use_selection']) && is_array($data['use_selection']))
{
$use_selection = new JRegistry;
$use_selection->loadArray($data['use_selection']);
$data['use_selection'] = (string) $use_selection;
}
elseif (!isset($data['use_selection']))
{
// Set the empty use_selection to data
$data['use_selection'] = '';
}
// Set the main_class_code string to base64 string.
if (isset($data['main_class_code']))
{
$data['main_class_code'] = base64_encode($data['main_class_code']);
}
// Set the licensing_template string to base64 string.
if (isset($data['licensing_template']))
{
$data['licensing_template'] = base64_encode($data['licensing_template']);
}
// Set the head string to base64 string.
if (isset($data['head']))
{

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
ALTER TABLE `#__componentbuilder_power` ADD `add_licensing_template` TINYINT(1) NOT NULL DEFAULT 1 AFTER `add_head`;
ALTER TABLE `#__componentbuilder_power` ADD `licensing_template` TEXT NOT NULL AFTER `implements_custom`;

View File

@ -64,6 +64,16 @@ $componentParams = $this->params; // will be removed just use $this->params inst
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'powerTab', 'licensing', JText::_('COM_COMPONENTBUILDER_POWER_LICENSING', true)); ?>
<div class="row-fluid form-horizontal-desktop">
</div>
<div class="row-fluid form-horizontal-desktop">
<div class="span12">
<?php echo JLayoutHelper::render('power.licensing_fullwidth', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
<?php $this->tab_name = 'powerTab'; ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>