diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aeaba2a4..0741c59f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 007047036..d4fa893cc 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/admin/README.txt b/admin/README.txt index 007047036..d4fa893cc 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -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** diff --git a/admin/compiler/joomla_4/DASH_MODEL.php b/admin/compiler/joomla_4/DASH_MODEL.php index 5e14fff76..4cbaf38a2 100644 --- a/admin/compiler/joomla_4/DASH_MODEL.php +++ b/admin/compiler/joomla_4/DASH_MODEL.php @@ -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### } diff --git a/admin/compiler/joomla_4/DASH_VIEW_HTML.php b/admin/compiler/joomla_4/DASH_VIEW_HTML.php index 8e6decf8b..db91cf460 100644 --- a/admin/compiler/joomla_4/DASH_VIEW_HTML.php +++ b/admin/compiler/joomla_4/DASH_VIEW_HTML.php @@ -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']); + } } } diff --git a/admin/models/fields/dynamicget.php b/admin/models/fields/dynamicget.php index 65fdfcf0f..166f127f5 100644 --- a/admin/models/fields/dynamicget.php +++ b/admin/models/fields/dynamicget.php @@ -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; } } diff --git a/admin/models/forms/layout.xml b/admin/models/forms/layout.xml index 8ee45a3d5..b8362c3e2 100644 --- a/admin/models/forms/layout.xml +++ b/admin/models/forms/layout.xml @@ -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" /> diff --git a/admin/models/forms/template.xml b/admin/models/forms/template.xml index 52bfea9bd..5506909cb 100644 --- a/admin/models/forms/template.xml +++ b/admin/models/forms/template.xml @@ -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" /> diff --git a/componentbuilder.xml b/componentbuilder.xml index 27df935ec..3244129dc 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -7,9 +7,9 @@ https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 3.2.1-rc2 + 3.2.1-rc3 Component Builder (v.3.2.1-rc2) +

Component Builder (v.3.2.1-rc3)

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. diff --git a/componentbuilder_update_server.xml b/componentbuilder_update_server.xml index 177813f40..960e30648 100644 --- a/componentbuilder_update_server.xml +++ b/componentbuilder_update_server.xml @@ -166,10 +166,10 @@ pkg_component_builder package site - 3.2.1-rc2 + 3.2.1-rc3 https://dev.vdm.io - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.1-rc2.zip + https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.1-rc3.zip releasecandidate diff --git a/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php b/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php index 95d427abf..694bbc927 100644 --- a/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php +++ b/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php @@ -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); } } diff --git a/script.php b/script.php index 6b5554254..5f4a24af4 100644 --- a/script.php +++ b/script.php @@ -9810,7 +9810,7 @@ class Com_ComponentbuilderInstallerScript echo '

-

Upgrade to Version 3.2.1-rc2 Was Successful! Let us know if anything is not working as expected.

'; +

Upgrade to Version 3.2.1-rc3 Was Successful! Let us know if anything is not working as expected.

'; // Set db if not set already. if (!isset($db))