Release of v3.2.1-rc3

Improved the Schema Table update engine (more). Fix autoloader timing, and loading. Implement the Joomla Powers in JCB code, to move away from JClasses. Remove many of the SQL updates, to only use the Schema updates of table columns to avoid collusion. Fix the admin.css file loading on dashboard. #1112.
This commit is contained in:
Robot 2024-04-30 19:11:27 +02:00
parent 0df47e7e69
commit a9fe531c6a
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
12 changed files with 187 additions and 52 deletions

View File

@ -1,9 +1,10 @@
# v3.2.1-rc2
# v3.2.1-rc3
- Improved the Schema Table update engine (more)
- Fix autoloader timing, and loading.
- Implement the Joomla Powers in JCB code, to move away from JClasses.
- Remove many of the SQL updates, to only use the Schema updates of table columns to avoid collusion.
- Remove many of the SQL updates, to only use the Schema updates of table columns to avoid collusion.
- Fix the admin.css file loading on dashboard. #1112
# v3.2.1-beta

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.2.1-rc2) 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.2.1-rc3) 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)
@ -145,10 +145,10 @@ TODO
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 30th April, 2024
+ *Version*: 3.2.1-rc2
+ *Version*: 3.2.1-rc3
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **761457**
+ *Line count*: **761639**
+ *Field count*: **2097**
+ *File count*: **5294**
+ *Folder count*: **471**

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.2.1-rc2) 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.2.1-rc3) 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)
@ -145,10 +145,10 @@ TODO
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 30th April, 2024
+ *Version*: 3.2.1-rc2
+ *Version*: 3.2.1-rc3
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **761457**
+ *Line count*: **761639**
+ *Field count*: **2097**
+ *File count*: **5294**
+ *Folder count*: **471**

View File

@ -27,6 +27,27 @@ namespace ###NAMESPACEPREFIX###\Component\###ComponentNamespace###\Administrator
*/
class ###Component###Model extends ListModel
{
/**
* The styles array.
*
* @var array
* @since 4.3
*/
protected array $styles = [
'administrator/components/com_###component###/assets/css/admin.css',
'administrator/components/com_###component###/assets/css/dashboard.css'
];
/**
* The scripts array.
*
* @var array
* @since 4.3
*/
protected array $scripts = [
'administrator/components/com_###component###/assets/js/admin.js'
];
public function getIcons()
{
// load user for access menus
@ -221,5 +242,49 @@ class ###Component###Model extends ListModel
}
}
return $icons;
}
/**
* Method to get the styles that have to be included on the view
*
* @return array styles files
* @since 4.3
*/
public function getStyles(): array
{
return $this->styles;
}
/**
* Method to set the styles that have to be included on the view
*
* @return void
* @since 4.3
*/
public function setStyles(string $path): void
{
$this->styles[] = $path;
}
/**
* Method to get the script that have to be included on the view
*
* @return array script files
* @since 4.3
*/
public function getScripts(): array
{
return $this->scripts;
}
/**
* Method to set the script that have to be included on the view
*
* @return void
* @since 4.3
*/
public function setScript(string $path): void
{
$this->scripts[] = $path;
}###DASH_MODEL_METHODS###
}

View File

@ -35,6 +35,8 @@ class HtmlView extends BaseHtmlView
{
// Assign data to the view
$this->icons = $this->get('Icons');
$this->styles = $this->get('Styles');
$this->scripts = $this->get('Scripts');
$this->contributors = ###Component###Helper::getContributors();
// get the manifest details of the component
@ -90,11 +92,17 @@ class HtmlView extends BaseHtmlView
{
// set page title
$this->getDocument()->setTitle(Text::_('COM_###COMPONENT###_DASHBOARD'));
// add manifest to page JavaScript
$this->getDocument()->addScriptDeclaration("var manifest = JSON.parse('" . json_encode($this->manifest) . "');", "text/javascript");
// add dashboard style sheets
Html::_('stylesheet', "administrator/components/com_###component###/assets/css/dashboard.css", ['version' => 'auto']);
// add styles
foreach ($this->styles as $style)
{
Html::_('stylesheet', $style, ['version' => 'auto']);
}
// add scripts
foreach ($this->scripts as $script)
{
Html::_('script', $script, ['version' => 'auto']);
}
}
}

View File

@ -143,25 +143,30 @@ class JFormFieldDynamicget extends JFormFieldList
*/
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','dynamic_get_name','type')));
$query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a'));
$query->where($db->quoteName('a.published') . ' = 1');
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '', 'Select an option');
$model = ComponentbuilderHelper::getModel('dynamic_gets');
foreach($items as $item)
{
$type = $model->selectionTranslation($item->type,'gettype');
$options[] = JHtml::_('select.option', $item->id, $item->dynamic_get_name . ' (' . JText::_($type) . ')' );
}
}
// Get the user object.
$user = Factory::getUser();
// Get the databse object.
$db = Factory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','dynamic_get_name','type')));
$query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a'));
$query->where($db->quoteName('a.published') . ' = 1');
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = [];
if ($items)
{
if ($this->multiple === false)
{
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION'));
}
foreach($items as $item)
{
$type = $model->selectionTranslation($item->type,'gettype');
$options[] = Html::_('select.option', $item->id, $item->dynamic_get_name . ' (' . Text::_($type) . ')' );
}
}
return $options;
}
}

View File

@ -133,7 +133,7 @@
label="COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL"
description="COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_DESCRIPTION"
multiple="false"
default=""
default="0"
required="false"
button="true"
/>

View File

@ -133,7 +133,7 @@
label="COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL"
description="COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_DESCRIPTION"
multiple="false"
default=""
default="0"
required="false"
button="true"
/>

View File

@ -7,9 +7,9 @@
<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>3.2.1-rc2</version>
<version>3.2.1-rc3</version>
<description><![CDATA[
<h1>Component Builder (v.3.2.1-rc2)</h1>
<h1>Component Builder (v.3.2.1-rc3)</h1>
<div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.

View File

@ -166,10 +166,10 @@
<element>pkg_component_builder</element>
<type>package</type>
<client>site</client>
<version>3.2.1-rc2</version>
<version>3.2.1-rc3</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.1-rc2.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.1-rc3.zip</downloadurl>
</downloads>
<tags>
<tag>releasecandidate</tag>

View File

@ -342,9 +342,16 @@ abstract class Schema implements SchemaInterface
'current' => $current->Type,
'expected' => $expected['type']
];
}
// check if update of default values is needed
$this->checkDefault($table, $column);
// check if update of default values is needed
if ($this->checkDefault($table, $column) && !isset($requireUpdate[$column]))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
}
@ -402,29 +409,23 @@ abstract class Schema implements SchemaInterface
* @param string $table The table to update.
* @param string $column The column/field to check.
*
* @return void
* @return bool
* @since 3.2.1
*/
protected function checkDefault(string $table, string $column): void
protected function checkDefault(string $table, string $column): bool
{
// Retrieve the expected column configuration
$expected = $this->table->get($table, $column, 'db');
// Skip updates if the column is auto_increment
if (isset($expected['auto_increment']) && $expected['auto_increment'])
if (isset($expected['auto_increment']) && $expected['auto_increment'] === true)
{
return;
return false;
}
// Retrieve the current column configuration
$current = $this->columns[$column];
// Check if default should be empty and current default is null, skip processing
if (strtoupper($expected['default']) === 'EMPTY' && $current->Default === NULL)
{
return;
}
// Determine the new default value based on the expected settings
$type = $expected['type'] ?? 'TEXT';
$db_default = isset($expected['default']) ? $expected['default'] : null;
@ -434,7 +435,17 @@ abstract class Schema implements SchemaInterface
if (is_numeric($newDefault) && $this->adjustExistingDefaults($table, $column, $current->Default, $newDefault))
{
$this->success[] = "Success: updated the ($column) defaults in $table table.";
return true;
}
if (is_string($expected['default']) && strtoupper($expected['default']) === 'EMPTY' &&
is_string($current->Default) && strpos($current->Default, 'EMPTY') !== false)
{
return true; // little fix
}
return false;
}
/**
@ -680,7 +691,7 @@ abstract class Schema implements SchemaInterface
*/
protected function getDefaultValue(string $type, ?string $defaultValue, bool $pure = false): string
{
if ($defaultValue === null || strtoupper($defaultValue) === 'EMPTY')
if ($defaultValue === null)
{
return '';
}
@ -692,7 +703,52 @@ abstract class Schema implements SchemaInterface
}
// Apply and quote the default value
return $pure ? $defaultValue : " DEFAULT " . $this->db->quote($defaultValue);
$sql_default = $this->quote($defaultValue);
return $pure ? $defaultValue : " DEFAULT $sql_default";
}
/**
* Set a value based on data type
*
* @param mixed $value The value to set
*
* @return mixed
* @since 3.2.0
**/
protected function quote($value)
{
if ($value === null) // hmm the null does pose an issue (will keep an eye on this)
{
return 'NULL';
}
if (is_string($value) && strtoupper($value) === 'EMPTY')
{
return "''";
}
elseif (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
return (int) $value;
}
elseif (filter_var($value, FILTER_VALIDATE_FLOAT))
{
return (float) $value;
}
}
elseif (is_bool($value)) // not sure if this will work well (but its correct)
{
return $value ? 'TRUE' : 'FALSE';
}
// For date and datetime values
elseif ($value instanceof \DateTime)
{
return $this->db->quote($value->format('Y-m-d H:i:s'));
}
// For other data types, just escape it
return $this->db->quote($value);
}
}

View File

@ -9810,7 +9810,7 @@ class Com_ComponentbuilderInstallerScript
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 3.2.1-rc2 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 3.2.1-rc3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already.
if (!isset($db))