Release of v4.0.0-beta4
Add fallback option to ensure that all JCB tables and fields exist. Move the powers autoloader to its own file.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\IsString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@@ -24,6 +25,13 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
*/
|
||||
class ContentOne extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Is String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use IsString;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@@ -693,6 +693,8 @@ final class Builders
|
||||
$field['settings']->null_switch);
|
||||
// set index types
|
||||
$_guid = true;
|
||||
$databaseuniquekey = false;
|
||||
$databasekey = false;
|
||||
if ($field['settings']->indexes == 1
|
||||
&& !in_array(
|
||||
$field['settings']->datatype, $textKeys
|
||||
@@ -700,6 +702,7 @@ final class Builders
|
||||
{
|
||||
// build unique keys of this view for db
|
||||
$this->databaseuniquekeys->add($nameSingleCode, $name, true);
|
||||
$databaseuniquekey = true;
|
||||
// prevent guid from being added twice
|
||||
if ('guid' === $name)
|
||||
{
|
||||
@@ -715,6 +718,7 @@ final class Builders
|
||||
{
|
||||
// build keys of this view for db
|
||||
$this->databasekeys->add($nameSingleCode, $name, true);
|
||||
$databasekey = true;
|
||||
}
|
||||
// special treatment for GUID
|
||||
if ('guid' === $name && $_guid)
|
||||
@@ -1300,10 +1304,61 @@ final class Builders
|
||||
'title' => (is_string($title_) && $name === $title_) ? true : false,
|
||||
'list' => $nameListCode,
|
||||
'store' => (isset($field['store'])) ? $field['store'] : null,
|
||||
'tab_name' => $tabName
|
||||
'tab_name' => $tabName,
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes database values by adjusting the 'length' and 'default' fields based on specific conditions.
|
||||
* This function modifies the database values by replacing placeholder texts and appending specifications
|
||||
* to types based on the 'length' field. It removes unnecessary fields from the result array.
|
||||
*
|
||||
* @param string $nameSingleCode The code for naming single entries.
|
||||
* @param string $name The name of the database entry.
|
||||
* @param string $uniquekey Is this field a uniquekey
|
||||
* @param string $iskey Is this field a key
|
||||
*
|
||||
* @return array|null Returns the modified database values array or null if no values are found.
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private function normalizeDatabaseValues($nameSingleCode, $name, $uniquekey, $iskey): ?array
|
||||
{
|
||||
$db_values = $this->databasetables->get($nameSingleCode . '.' . $name, null);
|
||||
if ($db_values === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($db_values['lenght']))
|
||||
{
|
||||
if ($db_values['lenght'] === 'Other' && isset($db_values['lenght_other']))
|
||||
{
|
||||
$db_values['lenght'] = $db_values['lenght_other'];
|
||||
}
|
||||
$db_values['lenght'] = trim($db_values['lenght']);
|
||||
if (strlen($db_values['lenght']))
|
||||
{
|
||||
$db_values['type'] .= '(' . $db_values['lenght'] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($db_values['default']))
|
||||
{
|
||||
if ($db_values['default'] === 'Other' && isset($db_values['other']))
|
||||
{
|
||||
$db_values['default'] = $db_values['other'];
|
||||
}
|
||||
}
|
||||
|
||||
$db_values['unique_key'] = $uniquekey;
|
||||
$db_values['key'] = $iskey;
|
||||
|
||||
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
|
||||
|
||||
return $db_values;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1206,11 +1206,6 @@ class Infusion extends Interpretation
|
||||
);
|
||||
}
|
||||
|
||||
// all fields stored in database
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS',
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1)
|
||||
);
|
||||
|
||||
// setup the layouts
|
||||
$this->setCustomViewLayouts();
|
||||
|
||||
@@ -2082,11 +2077,16 @@ class Infusion extends Interpretation
|
||||
// UNINSTALLSCRIPT
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('UNINSTALLSCRIPT', $this->setUninstallScript());
|
||||
|
||||
// INSTALLERMETHODS
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS', CFactory::_('Customcode.Dispenser')->get(
|
||||
'php_method', 'install', PHP_EOL
|
||||
));
|
||||
|
||||
// MOVEFOLDERSSCRIPT
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSSCRIPT', $this->setMoveFolderScript());
|
||||
|
||||
// MOVEFOLDERSMETHOD
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSMETHOD', $this->setMoveFolderMethod());
|
||||
// INSTALLERMETHODS2
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS', $this->setMoveFolderMethod());
|
||||
|
||||
// HELPER_UIKIT
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_UIKIT', $this->setUikitHelperMethods());
|
||||
@@ -2144,6 +2144,11 @@ class Infusion extends Interpretation
|
||||
);
|
||||
}
|
||||
|
||||
// all fields stored in database
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS',
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1)
|
||||
);
|
||||
|
||||
// set the autoloader for Powers (first time)
|
||||
CFactory::_('Power.Autoloader')->set();
|
||||
|
||||
|
@@ -10346,7 +10346,7 @@ class Interpretation extends Fields
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.params'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "`params` text NULL,";
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "`params` TEXT NULL,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.published'))
|
||||
@@ -10432,6 +10432,23 @@ class Interpretation extends Fields
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`access` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.access',
|
||||
[
|
||||
'name' => 'access',
|
||||
'label' => 'Access',
|
||||
'type' => 'accesslevel',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.ordering'))
|
||||
@@ -10468,6 +10485,49 @@ class Interpretation extends Fields
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT NOT NULL,";
|
||||
}
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metakey',
|
||||
[
|
||||
'name' => 'metakey',
|
||||
'label' => 'Meta Keywords',
|
||||
'type' => 'textarea',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metadesc',
|
||||
[
|
||||
'name' => 'metadesc',
|
||||
'label' => 'Meta Description',
|
||||
'type' => 'textarea',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metadata',
|
||||
[
|
||||
'name' => 'metadata',
|
||||
'label' => 'Meta Data',
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'store' => 'json',
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
// TODO (we may want this to be dynamicly set)
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "PRIMARY KEY (`id`)";
|
||||
|
@@ -15,15 +15,15 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as SuperPower;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
|
||||
|
||||
|
||||
|
@@ -88,7 +88,8 @@ class Autoloader
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
if (ArrayHelper::check($this->power->namespace))
|
||||
// make sure we only load this once
|
||||
if (ArrayHelper::check($this->power->namespace) && !$this->content->isString('CUSTOM_POWER_AUTOLOADER'))
|
||||
{
|
||||
/************************* IMPORTANT SORT NOTICE ***********************************************
|
||||
* make sure the name space values are sorted from the longest string to the shortest
|
||||
|
@@ -16,6 +16,7 @@ use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface as Grep;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
|
||||
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ use VDM\Joomla\Utilities\GuidHelper;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Super
|
||||
class Super implements SuperInterface
|
||||
{
|
||||
/**
|
||||
* The Power Search Tool
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Table;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Table as Table;
|
||||
use VDM\Joomla\Interfaces\SchemaInterface;
|
||||
use VDM\Joomla\Abstraction\Schema as ExtendingSchema;
|
||||
|
||||
|
||||
/**
|
||||
* JCB Tables Schema
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
final class Schema extends ExtendingSchema implements SchemaInterface
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Table $table The Table Class.
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function __construct(?Table $table = null)
|
||||
{
|
||||
$table ??= new Table;
|
||||
|
||||
parent::__construct($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targeted component code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getCode(): string
|
||||
{
|
||||
return 'componentbuilder';
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user