diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php
index 7571552c..624cc86e 100644
--- a/www/admin/class_test.debug.php
+++ b/www/admin/class_test.debug.php
@@ -52,6 +52,9 @@ print "S::GETCALLERMETHOD: ".DebugSupport::getCallerMethod(0)."
";
print "S::GETCALLERMETHOD: ".test()."
";
print "S::PRINTAR: ".DebugSupport::printAr(['Foo', 'Bar'])."
";
print "V-S::PRINTAR: ".$debug_support_class::printAr(['Foo', 'Bar'])."
";
+print "S::DEBUSTRING(s): ".DebugSupport::debugString('SET')."
";
+print "S::DEBUSTRING(''): ".DebugSupport::debugString('')."
";
+print "S::DEBUSTRING(,s): ".DebugSupport::debugString(null, '{-}')."
";
// debug
print "C->DEBUG: ".$debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug')."
";
diff --git a/www/admin/class_test.output.form.php b/www/admin/class_test.output.form.php
index f90455f2..3646e90f 100644
--- a/www/admin/class_test.output.form.php
+++ b/www/admin/class_test.output.form.php
@@ -29,6 +29,31 @@ if (!defined('SET_SESSION_NAME')) {
$LOG_FILE_ID = 'classTest-form';
ob_end_flush();
+// define an array for page use
+$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
+ // form fields mtaching up with db fields
+ 'table_array' => [
+ ],
+ // laod query
+ 'load_query' => '',
+ // database table to load from
+ 'table_name' => '',
+ // for load dro pdown, format output
+ 'show_fields' => [
+ [
+ 'name' => 'name'
+ ],
+ [
+ 'name' => 'enabled',
+ 'binary' => ['Yes', 'No'],
+ 'before_value' => 'Enabled: '
+ ],
+ ],
+ // a multi reference entry
+ 'element_list' => [
+ ]
+];
+
$basic = new CoreLibs\Basic();
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG);
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
@@ -37,7 +62,8 @@ print "
entries
- .preg_replace("/{##HTMLPRE##}((.|\n)*?){##\/HTMLPRE##}/m", "\\1
", \CoreLibs\Convert\Html::htmlent($string))
+ .str_replace(
+ ['##HTMLPRE##', '##/HTMLPRE##'],
+ ['', '
'],
+ \CoreLibs\Convert\Html::htmlent($string)
+ )
."";
}
return true;
diff --git a/www/lib/CoreLibs/Debug/Support.php b/www/lib/CoreLibs/Debug/Support.php
index 358bccd3..e77fc5c3 100644
--- a/www/lib/CoreLibs/Debug/Support.php
+++ b/www/lib/CoreLibs/Debug/Support.php
@@ -78,6 +78,21 @@ class Support
}
return $class ?? '';
}
+
+ /**
+ * If a string is empty, sets '-' for return, or if given any other string
+ *
+ * @param string|null $string The string to check
+ * @param string $replace [default '-'] What to replace the empty string with
+ * @return string String itself or the replaced value
+ */
+ public static function debugString(?string $string, string $replace = '-'): string
+ {
+ if (empty($string)) {
+ return $replace;
+ }
+ return $string;
+ }
}
// __END__
diff --git a/www/lib/CoreLibs/Get/System.php b/www/lib/CoreLibs/Get/System.php
index a7450afa..283cbc10 100644
--- a/www/lib/CoreLibs/Get/System.php
+++ b/www/lib/CoreLibs/Get/System.php
@@ -80,6 +80,16 @@ class System
return $page_temp['basename'];
}
}
+
+ /**
+ * similar to getPageName, but it retuns the raw array
+ *
+ * @return array pathinfo array from PHP SELF
+ */
+ public static function getPageNameArray(): array
+ {
+ return pathinfo($_SERVER['PHP_SELF']);
+ }
}
// __END__
diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php
index d7444aea..0bdefea9 100644
--- a/www/lib/CoreLibs/Output/Form/Generate.php
+++ b/www/lib/CoreLibs/Output/Form/Generate.php
@@ -260,31 +260,45 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
*/
public function __construct(array $db_config, int $table_width = 750)
{
- $this->my_page_name = \CoreLibs\Get\System::getPageName(1);
+ // replace any non valid variable names
+ $this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1));
$this->setLangEncoding();
// init the language class
$this->l = new \CoreLibs\Language\L10n($this->lang);
// load config array
// get table array definitions for current page name
- // WARNING: auto spl load does not work with this as it is an array and not a function/object
- // check if this is the old path or the new path
- if (is_dir(TABLE_ARRAYS)) {
- if (is_file(TABLE_ARRAYS.'array_'.$this->my_page_name.'.php')) {
- include(TABLE_ARRAYS.'array_'.$this->my_page_name.'.php');
- }
+
+ // first check if we have a in page override as $table_arrays[page name]
+ if (isset($_GLOBALS['table_arrays']) &&
+ is_array($_GLOBALS['table_arrays']) &&
+ isset($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
+ is_array($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)])
+ ) {
+ $config_array = $_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)];
} else {
- if (is_file(BASE.INCLUDES.TABLE_ARRAYS.'array_'.$this->my_page_name.'.php')) {
+ // WARNING: auto spl load does not work with this as it is an array and not a function/object
+ // check if this is the old path or the new path
+ // check local folder in current path
+ // then check general global folder
+ if (is_dir(TABLE_ARRAYS) &&
+ is_file(TABLE_ARRAYS.'array_'.$this->my_page_name.'.php')
+ ) {
+ include(TABLE_ARRAYS.'array_'.$this->my_page_name.'.php');
+ } elseif (is_dir(BASE.INCLUDES.TABLE_ARRAYS) &&
+ is_file(BASE.INCLUDES.TABLE_ARRAYS.'array_'.$this->my_page_name.'.php')
+ ) {
include(BASE.INCLUDES.TABLE_ARRAYS.'array_'.$this->my_page_name.'.php');
}
- }
- if (isset(${$this->my_page_name}) && is_array(${$this->my_page_name})) {
- $config_array = ${$this->my_page_name};
- } else {
- // dummy created
- $config_array = [
- 'table_array' => [],
- 'table_name' => '',
- ];
+ // in the include file there must be a variable with the page name matching
+ if (isset(${$this->my_page_name}) && is_array(${$this->my_page_name})) {
+ $config_array = ${$this->my_page_name};
+ } else {
+ // dummy created
+ $config_array = [
+ 'table_array' => [],
+ 'table_name' => '',
+ ];
+ }
}
// start the array_io class which will start db_io ...