update 2024-03-14

This commit is contained in:
Robot 2024-03-14 14:31:34 +02:00
parent 0c664e2d5a
commit 0f50f40925
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
8 changed files with 263 additions and 146 deletions

View File

@ -75,24 +75,24 @@ abstract class FormHelper
// element was not returned
return;
}
switch (get_class($node))
if ($node instanceof \stdClass)
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
break;
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
}
elseif ($node instanceof \SimpleXMLElement)
{
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
}
}
@ -127,7 +127,7 @@ abstract class FormHelper
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
$xml->addAttribute($key, $value ?? '');
}
}
@ -145,7 +145,7 @@ abstract class FormHelper
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption->addAttribute('value', $key ?? '');
$addOption[] = $value;
}
}

View File

@ -50,24 +50,24 @@
// element was not returned
return;
}
switch (get_class($node))
if ($node instanceof \stdClass)
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
break;
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
}
elseif ($node instanceof \SimpleXMLElement)
{
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
}
}
@ -102,7 +102,7 @@
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
$xml->addAttribute($key, $value ?? '');
}
}
@ -120,7 +120,7 @@
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption->addAttribute('value', $key ?? '');
$addOption[] = $value;
}
}

View File

@ -12,12 +12,13 @@
@startuml
abstract Helper #Orange {
+ {static} getParams(?string $option = null) : Registry
+ {static} getOption(string $default = 'empty') : ?string
+ {static} setOption(?string $option) : void
+ {static} getOption(?string $default = 'empty') : ?string
+ {static} getCode(?string $option = null, ?string $default = null) : ?string
+ {static} get(string $option = null, string $default = null) : ?string
+ {static} get(?string $option = null, ?string $default = null) : ?string
+ {static} getNamespace(?string $option = null) : ?string
+ {static} getManifest(?string $option = null) : ?object
+ {static} methodExists(string $method, string $option = null) : bool
+ {static} methodExists(string $method, ?string $option = null) : bool
+ {static} _(string $method, array $arguments = [], ...) : mixed
}
@ -28,49 +29,56 @@ note right of Helper::getParams
return: Registry
end note
note left of Helper::getOption
Gets the component option
note left of Helper::setOption
Set the component option
since: 3.2.0
return: void
end note
note right of Helper::getOption
Get the component option
since: 3.0.11
return: ?string
end note
note right of Helper::getCode
note left of Helper::getCode
Gets the component code name
since: 3.0.11
return: ?string
end note
note left of Helper::get
note right of Helper::get
Gets the component abstract helper class
since: 3.0.11
return: ?string
end note
note right of Helper::getNamespace
note left of Helper::getNamespace
Gets the component namespace if set
since: 3.0.11
return: ?string
end note
note left of Helper::getManifest
note right of Helper::getManifest
Gets the component abstract helper class
since: 3.0.11
return: ?object
end note
note right of Helper::methodExists
note left of Helper::methodExists
Check if the helper class of this component has a method
since: 3.0.11
return: bool
end note
note left of Helper::_
note right of Helper::_
Check if the helper class of this component has a method, and call it with the arguments
since: 3.2.0

View File

@ -77,14 +77,27 @@ abstract class Helper
}
/**
* Gets the component option
* Set the component option
*
* @param string|null $option The option
*
* @return void
* @since 3.2.0
*/
public static function setOption(?string $option): void
{
self::$option = $option;
}
/**
* Get the component option
*
* @param string|null $default The default return value if none is found
*
* @return string|null A component option
* @since 3.0.11
*/
public static function getOption(string $default = 'empty'): ?string
public static function getOption(?string $default = 'empty'): ?string
{
if (empty(self::$option))
{
@ -147,7 +160,7 @@ abstract class Helper
*
* @since 3.0.11
*/
public static function get(string $option = null, string $default = null): ?string
public static function get(?string $option = null, ?string $default = null): ?string
{
// check that we have an option
// and get the code name from it
@ -247,7 +260,7 @@ abstract class Helper
*
* @since 3.0.11
*/
public static function methodExists(string $method, string $option = null): bool
public static function methodExists(string $method, ?string $option = null): bool
{
// get the helper class
return ($helper = self::get($option, null)) !== null &&

View File

@ -49,14 +49,27 @@
}
/**
* Gets the component option
* Set the component option
*
* @param string|null $option The option
*
* @return void
* @since 3.2.0
*/
public static function setOption(?string $option): void
{
self::$option = $option;
}
/**
* Get the component option
*
* @param string|null $default The default return value if none is found
*
* @return string|null A component option
* @since 3.0.11
*/
public static function getOption(string $default = 'empty'): ?string
public static function getOption(?string $default = 'empty'): ?string
{
if (empty(self::$option))
{
@ -119,7 +132,7 @@
*
* @since 3.0.11
*/
public static function get(string $option = null, string $default = null): ?string
public static function get(?string $option = null, ?string $default = null): ?string
{
// check that we have an option
// and get the code name from it
@ -219,7 +232,7 @@
*
* @since 3.0.11
*/
public static function methodExists(string $method, string $option = null): bool
public static function methodExists(string $method, ?string $option = null): bool
{
// get the helper class
return ($helper = self::get($option, null)) !== null &&

View File

@ -67,23 +67,14 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'debug_linenr' => [
'name' => 'debug_linenr',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEBUG_LINENR_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'php_site_event' => [
'name' => 'php_site_event',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_SITE_EVENT_LABEL',
'type' => 'editor',
'buildcompsql' => [
'name' => 'buildcompsql',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMPSQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
'tab_name' => 'Dynamic Build (beta)',
],
'translation_tool' => [
'name' => 'translation_tool',
@ -94,15 +85,6 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Dynamic Integration',
],
'buildcompsql' => [
'name' => 'buildcompsql',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMPSQL_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dynamic Build (beta)',
],
'add_sales_server' => [
'name' => 'add_sales_server',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SALES_SERVER_LABEL',
@ -112,18 +94,18 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Dynamic Integration',
],
'php_preflight_install' => [
'name' => 'php_preflight_install',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_INSTALL_LABEL',
'php_method_uninstall' => [
'name' => 'php_method_uninstall',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_UNINSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
],
'php_method_uninstall' => [
'name' => 'php_method_uninstall',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_UNINSTALL_LABEL',
'php_preflight_install' => [
'name' => 'php_preflight_install',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_INSTALL_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
@ -166,6 +148,24 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'debug_linenr' => [
'name' => 'debug_linenr',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEBUG_LINENR_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'php_site_event' => [
'name' => 'php_site_event',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_SITE_EVENT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'description' => [
'name' => 'description',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DESCRIPTION_LABEL',
@ -175,6 +175,15 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'author' => [
'name' => 'author',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'php_postflight_install' => [
'name' => 'php_postflight_install',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_INSTALL_LABEL',
@ -184,9 +193,9 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'Dash & Install',
],
'author' => [
'name' => 'author',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL',
'email' => [
'name' => 'email',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_components',
@ -202,19 +211,19 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'MySQL',
],
'email' => [
'name' => 'email',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_LABEL',
'type' => 'text',
'website' => [
'name' => 'website',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WEBSITE_LABEL',
'type' => 'url',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'website' => [
'name' => 'website',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WEBSITE_LABEL',
'type' => 'url',
'add_license' => [
'name' => 'add_license',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_LICENSE_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
@ -256,10 +265,10 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'add_license' => [
'name' => 'add_license',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_LICENSE_LABEL',
'type' => 'radio',
'license_type' => [
'name' => 'license_type',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_LICENSE_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
@ -283,15 +292,6 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'license_type' => [
'name' => 'license_type',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_LICENSE_TYPE_LABEL',
'type' => 'list',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'php_helper_site' => [
'name' => 'php_helper_site',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_SITE_LABEL',
@ -301,15 +301,6 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'javascript' => [
'name' => 'javascript',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JAVASCRIPT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'whmcs_key' => [
'name' => 'whmcs_key',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WHMCS_KEY_LABEL',
@ -319,9 +310,9 @@ class Table extends BaseTable implements Tableinterface
'store' => 'basic_encryption',
'tab_name' => 'Details',
],
'css_site' => [
'name' => 'css_site',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_SITE_LABEL',
'javascript' => [
'name' => 'javascript',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JAVASCRIPT_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
@ -337,6 +328,15 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'css_site' => [
'name' => 'css_site',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_SITE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Libs & Helpers',
],
'whmcs_buy_link' => [
'name' => 'whmcs_buy_link',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WHMCS_BUY_LINK_LABEL',
@ -346,15 +346,6 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'php_preflight_update' => [
'name' => 'php_preflight_update',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
],
'license' => [
'name' => 'license',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_LICENSE_LABEL',
@ -364,9 +355,9 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'php_postflight_update' => [
'name' => 'php_postflight_update',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_UPDATE_LABEL',
'php_preflight_update' => [
'name' => 'php_preflight_update',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
@ -382,6 +373,24 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Details',
],
'php_postflight_update' => [
'name' => 'php_postflight_update',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_UPDATE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'joomla_components',
'store' => 'base64',
'tab_name' => 'Dash & Install',
],
'image' => [
'name' => 'image',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_IMAGE_LABEL',
'type' => 'media',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
'tab_name' => 'Details',
],
'sql' => [
'name' => 'sql',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SQL_LABEL',
@ -391,10 +400,10 @@ class Table extends BaseTable implements Tableinterface
'store' => 'base64',
'tab_name' => 'MySQL',
],
'image' => [
'name' => 'image',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_IMAGE_LABEL',
'type' => 'media',
'copyright' => [
'name' => 'copyright',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COPYRIGHT_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
@ -409,10 +418,10 @@ class Table extends BaseTable implements Tableinterface
'store' => NULL,
'tab_name' => 'Readme',
],
'copyright' => [
'name' => 'copyright',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COPYRIGHT_LABEL',
'type' => 'textarea',
'preferred_joomla_version' => [
'name' => 'preferred_joomla_version',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PREFERRED_JOOMLA_VERSION_LABEL',
'type' => 'number',
'title' => false,
'list' => 'joomla_components',
'store' => NULL,
@ -5145,6 +5154,80 @@ class Table extends BaseTable implements Tableinterface
'tab_name' => 'Menus',
],
],
'component_router' => [
'joomla_component' => [
'name' => 'joomla_component',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_JOOMLA_COMPONENT_LABEL',
'type' => 'joomlacomponents',
'title' => true,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
],
'mode_constructor_before_parent' => [
'name' => 'mode_constructor_before_parent',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_BEFORE_PARENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
],
'mode_constructor_after_parent' => [
'name' => 'mode_constructor_after_parent',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_AFTER_PARENT_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
],
'mode_methods' => [
'name' => 'mode_methods',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_METHODS_LABEL',
'type' => 'radio',
'title' => false,
'list' => 'components_routers',
'store' => NULL,
'tab_name' => 'Settings',
],
'methods_code' => [
'name' => 'methods_code',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_METHODS_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
],
'constructor_after_parent_code' => [
'name' => 'constructor_after_parent_code',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_AFTER_PARENT_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
],
'constructor_before_parent_manual' => [
'name' => 'constructor_before_parent_manual',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_MANUAL_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'components_routers',
'store' => 'json',
'tab_name' => 'Settings',
],
'constructor_before_parent_code' => [
'name' => 'constructor_before_parent_code',
'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_CODE_LABEL',
'type' => 'editor',
'title' => false,
'list' => 'components_routers',
'store' => 'base64',
'tab_name' => 'Settings',
],
],
'component_config' => [
'joomla_component' => [
'name' => 'joomla_component',

View File

@ -113,14 +113,14 @@ abstract class GetHelper
$where = Factory::getUser()->id;
}
if(is_null($main))
if($main === null)
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = array($where);
$where = [$where];
}
if (ArrayHelper::check($where))

View File

@ -88,14 +88,14 @@
$where = Factory::getUser()->id;
}
if(is_null($main))
if($main === null)
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = array($where);
$where = [$where];
}
if (ArrayHelper::check($where))