From 76e0c0ac06caa4f2ef1fd0bfe7bd823eb6c38742 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 28 Jun 2021 18:03:59 +0900 Subject: [PATCH] Update and add class test pages, minor updates for CoreLibs Some code clean up in smarty class (check if $cms object is actually set) Logger/Support Debug clean up for some minor logic with debug prefixes DB IO update debug prefix for log line so we can have a HTML formatted prefix for echo output --- 4dev/lang/admin/messages_en_utf8.po | 6 + www/admin/class_test.admin.backend.php | 52 ++++++++ www/admin/class_test.array.php | 93 ++++++++++++- www/admin/class_test.colors.php | 3 +- www/admin/class_test.db.php | 132 ++++++++++--------- www/admin/class_test.debug.php | 20 +++ www/admin/class_test.html.php | 11 +- www/admin/class_test.lang.php | 58 ++++++++ www/admin/class_test.output.form.php | 47 +++++++ www/admin/class_test.php | 18 ++- www/admin/class_test.smarty.php | 94 +++++++++++++ www/admin/l10n_test.php | 29 ---- www/admin/namespace_test.php | 41 ------ www/admin/other_test.php | 34 ----- www/admin/smarty_test.php | 59 --------- www/admin/various_class_test.php | 111 ---------------- www/configs/config.db.php | 6 +- www/includes/admin_footer.php | 1 + www/includes/edit_base.php | 14 +- www/includes/lang/admin/en_utf8.mo | Bin 472 -> 643 bytes www/includes/templates/admin/smarty_test.tpl | 5 +- www/lib/CoreLibs/Admin/Backend.php | 11 +- www/lib/CoreLibs/Check/Email.php | 1 - www/lib/CoreLibs/DB/IO.php | 65 ++++----- www/lib/CoreLibs/Debug/Logging.php | 22 +++- www/lib/CoreLibs/Debug/Support.php | 6 + www/lib/CoreLibs/Template/SmartyExtend.php | 26 ++-- 27 files changed, 568 insertions(+), 397 deletions(-) create mode 100644 www/admin/class_test.admin.backend.php create mode 100644 www/admin/class_test.lang.php create mode 100644 www/admin/class_test.output.form.php create mode 100644 www/admin/class_test.smarty.php delete mode 100755 www/admin/l10n_test.php delete mode 100755 www/admin/namespace_test.php delete mode 100755 www/admin/other_test.php delete mode 100755 www/admin/smarty_test.php delete mode 100755 www/admin/various_class_test.php diff --git a/4dev/lang/admin/messages_en_utf8.po b/4dev/lang/admin/messages_en_utf8.po index fa3b2d7b..dbae943e 100644 --- a/4dev/lang/admin/messages_en_utf8.po +++ b/4dev/lang/admin/messages_en_utf8.po @@ -27,3 +27,9 @@ msgstr "Month" msgid "INPUT TEST" msgstr "OUTPUT TEST EN" + +msgid "I should be translated" +msgstr "I should be translated: I WAS TRANSLATED" + +msgid "Are we translated?" +msgstr "Are we translated? Yes, we are!" diff --git a/www/admin/class_test.admin.backend.php b/www/admin/class_test.admin.backend.php new file mode 100644 index 00000000..00be130f --- /dev/null +++ b/www/admin/class_test.admin.backend.php @@ -0,0 +1,52 @@ +TEST CLASS: ADMIN BACKEND"; +print ""; +print '
Class Test Master
'; + +// set acl, from eg login acl +print "SETACL[]: ".$backend->setACL([])."
"; +print "ADBEDITLOG: ".$backend->adbEditLog('CLASSTEST-ADMIN', 'Some info stirng')."
"; +print "ADBTOPMENU(0): ".\CoreLibs\Debug\Support::printAr($backend->adbTopMenu())."
"; +print "ADBMSG: ".$backend->adbMsg('info', 'Message: %1$d', [1])."
"; +print "Messaes: ".\CoreLibs\Debug\Support::printAr($this->messages)."
"; +print "ADBPRINTDATETIME:
".$backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test')."
"; + +// error message +print $basic->log->printErrorMsg(); + +print ""; + +// __END__ diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php index 3dcc7412..b9d986b6 100644 --- a/www/admin/class_test.array.php +++ b/www/admin/class_test.array.php @@ -1,4 +1,5 @@ -arrayMergeRecursive($array_1, $array_2, $array_3))."
"; +/** + * attach key/value to an array so it becomes nested + * + * @param string $pre Attach to new (empty for new root node) + * @param string $cur New node + * @param array $node Previous created array + * @return array Updated array + */ +function rec(string $pre, string $cur, array $node = []) +{ + if (!is_array($node)) { + $node = []; + } + print "
#### PRE: ".$pre.", CUR: ".$cur.", N-c: ".count($node)." [".join('|', array_keys($node))."]
"; + if (!$pre) { + print "** NEW
"; + $node[$cur] = []; + } else { + if (array_key_exists($pre, $node)) { + print "+ KEY FOUND: ".$pre.", add: ".$cur."
"; + $node[$pre][$cur] = []; + } else { + print "- NOT FOUND: loop
"; + foreach ($node as $_pre => $_cur) { + print "> TRY: ".$_pre." => ".count($_cur)." [".join('|', array_keys($_cur))."]
"; + if (count($_cur) > 0) { + $node[$_pre] = rec($pre, $cur, $_cur); + } + } + } + } + return $node; +} + +/** + * flatten array down to own level + * + * @param array $array + * @param array $return + * @return array + */ +function flattenArrayKey(array $array, array $return = []) +{ + foreach ($array as $key => $sub) { + $return[] = $key; + if (count($sub) > 0) { + $return = flattenArrayKey($sub, $return); + } + } + return $return; +} + +// $test = [ +// 'A' => [ +// 'B' => [], +// 'C' => [ +// 'D' => [], +// 'E' => [ +// 'F' => [] +// ] +// ] +// ], +// '1' => [], +// '2' => [], +// '3' => [ +// 'G' => [] +// ] +// ]; + +// build a tested array for flatten +$test = []; +// core +$test = rec('', 'A', $test); +$test = rec('', '1', $test); +$test = rec('', '2', $test); +$test = rec('', '3', $test); +$test = rec('3', 'G', $test); +$test = rec('A', 'B', $test); +$test = rec('A', 'C', $test); +$test = rec('C', 'D', $test); +$test = rec('C', 'E', $test); +$test = rec('E', 'F', $test); +// new +$test = rec('C', 'U', $test); +$test = rec('F', 'U', $test); +$test = rec('', 'Al', $test); +$test = rec('B', 'B1', $test); +print "ORIGINAL: ".\CoreLibs\Debug\Support::printAr($test)."
"; +print "FLATTEN: ".\CoreLibs\Debug\Support::printAr(flattenArrayKey($test))."
"; + // error message print $basic->log->printErrorMsg(); diff --git a/www/admin/class_test.colors.php b/www/admin/class_test.colors.php index d4d8b742..f28768a2 100644 --- a/www/admin/class_test.colors.php +++ b/www/admin/class_test.colors.php @@ -1,4 +1,5 @@ -log = $logger; +// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log); print "TEST CLASS: DB"; print ""; print '
Class Test Master
'; -print "DBINFO: ".$basic->dbInfo()."
"; +print "DBINFO: ".$db->dbInfo()."
"; echo "DB_CONFIG_SET constant:
".print_r(DB_CONFIG, true)."

"; // DB client encoding -print "DB Client encoding: ".$basic->dbGetEncoding()."
"; +print "DB Client encoding: ".$db->dbGetEncoding()."
"; -while ($res = $basic->dbReturn("SELECT * FROM max_test", 0, true)) { +while ($res = $db->dbReturn("SELECT * FROM max_test", 0, true)) { print "TIME: ".$res['time']."
"; } -print "CACHED DATA:
".print_r($basic->cursor_ext, true)."

"; -while ($res = $basic->dbReturn("SELECT * FROM max_test")) { +print "CACHED DATA:
".print_r($db->cursor_ext, true)."

"; +while ($res = $db->dbReturn("SELECT * FROM max_test")) { print "[CACHED] TIME: ".$res['time']."
"; } print "
";
-$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
+$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
 print "DIRECT INSERT STATUS: $status | "
-	."PRIMARY KEY: ".$basic->dbGetInsertPK()." | "
-	."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
-	."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."
"; + ."PRIMARY KEY: ".$db->dbGetInsertPK()." | " + ."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | " + ."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."
"; // should throw deprecated error -// $basic->getReturningExt(); -print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->dbGetInsertPK()), true)."
"; -$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); -$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time())); +// $db->getReturningExt(); +print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->dbGetInsertPK()), true)."
"; +$db->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); +$status = $db->dbExecute("ins_foo", array('BAR TEST '.time())); print "PREPARE INSERT STATUS: $status | " - ."PRIMARY KEY: ".$basic->dbGetInsertPK()." | " - ."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | " - ."RETURNING RETURN: ".print_r($basic->dbGetReturningArray(), true)."
"; + ."PRIMARY KEY: ".$db->dbGetInsertPK()." | " + ."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | " + ."RETURNING RETURN: ".print_r($db->dbGetReturningArray(), true)."
"; -print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->dbGetInsertPK()), true)."
"; +print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->dbGetInsertPK()), true)."
"; // returning test with multiple entries -// $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id"); -$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test"); +// $status = $db->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id"); +$status = $db->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test"); print "DIRECT MULTIPLE INSERT STATUS: $status | " - ."PRIMARY KEYS: ".print_r($basic->dbGetInsertPK(), true)." | " - ."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | " - ."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."
"; + ."PRIMARY KEYS: ".print_r($db->dbGetInsertPK(), true)." | " + ."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | " + ."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."
"; // no returning, but not needed ; -$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');"); +$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');"); print "DIRECT INSERT STATUS: $status | " - ."PRIMARY KEY: ".$basic->dbGetInsertPK()." | " - ."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | " - ."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."
"; + ."PRIMARY KEY: ".$db->dbGetInsertPK()." | " + ."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | " + ."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."
"; // UPDATE WITH RETURNING -$status = $basic->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test"); +$status = $db->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test"); print "UPDATE STATUS: $status | " - ."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | " - ."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."
"; + ."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | " + ."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."
"; print "
"; // REEAD PREPARE -if ($basic->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time FROM foo ORDER BY foo_id DESC LIMIT 5") === false) { +if ($db->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time FROM foo ORDER BY foo_id DESC LIMIT 5") === false) { print "Error in sel_foo prepare
"; } else { $max_rows = 6; // do not run this in dbFetchArray directly as // dbFetchArray(dbExecute(...)) // this will end in an endless loop - $cursor = $basic->dbExecute('sel_foo', []); + $cursor = $db->dbExecute('sel_foo', []); $i = 1; - while (($res = $basic->dbFetchArray($cursor, true)) !== false) { + while (($res = $db->dbFetchArray($cursor, true)) !== false) { print "DB PREP EXEC FETCH ARR: ".$i.":
".print_r($res, true)."

"; $i ++; } @@ -107,35 +117,35 @@ if ($basic->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, numb # db write class test $table = 'foo'; -print "TABLE META DATA: ".DgS::printAr($basic->dbShowTableMetaData($table))."
"; +print "TABLE META DATA: ".DgS::printAr($db->dbShowTableMetaData($table))."
"; $primary_key = ''; # unset $db_write_table = array('test', 'string_a', 'number_a', 'some_bool'); // $db_write_table = array('test'); $object_fields_not_touch = array(); $object_fields_not_update = array(); $data = array('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5); -$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1); -$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0); -$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array('test' => 'BOOL TEST UNSET '.time()); -$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; // return Array Test $query = "SELECT type, sdate, integer FROM foobar"; -$data = $basic->dbReturnArray($query, true); +$data = $db->dbReturnArray($query, true); print "Full foobar list:
".print_r($data, true)."

"; # async test queries -/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)"); +/* $db->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)"); echo "WAITING FOR ASYNC: "; $chars = array('|', '/', '-', '\\'); -while (($ret = $basic->dbCheckAsync()) === true) +while (($ret = $db->dbCheckAsync()) === true) { if ((list($_, $char) = each($chars)) === FALSE) { @@ -147,37 +157,37 @@ while (($ret = $basic->dbCheckAsync()) === true) flush(); } print "
END STATUS: ".$ret."
"; -// while ($res = $basic->dbFetchArray($ret)) -while ($res = $basic->dbFetchArray()) +// while ($res = $db->dbFetchArray($ret)) +while ($res = $db->dbFetchArray()) { echo "RES: ".$res['test']."
"; } # test async insert -$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')"); +$db->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')"); echo "WAITING FOR ASYNC INSERT: "; -while (($ret = $basic->dbCheckAsync()) === true) +while (($ret = $db->dbCheckAsync()) === true) { print "."; sleep(1); flush(); } -print "
END STATUS: ".$ret." | PK: ".$basic->insert_id."
"; -print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), true)."
"; */ +print "
END STATUS: ".$ret." | PK: ".$db->insert_id."
"; +print "ASYNC PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->insert_id), true)."
"; */ $to_db_version = '9.1.9'; -print "VERSION DB: ".$basic->dbVersion()."
"; -print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."
"; -print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."
"; -print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."
"; -print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."
"; -print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."
"; +print "VERSION DB: ".$db->dbVersion()."
"; +print "DB Version smaller $to_db_version: ".$db->dbCompareVersion('<'.$to_db_version)."
"; +print "DB Version smaller than $to_db_version: ".$db->dbCompareVersion('<='.$to_db_version)."
"; +print "DB Version equal $to_db_version: ".$db->dbCompareVersion('='.$to_db_version)."
"; +print "DB Version bigger than $to_db_version: ".$db->dbCompareVersion('>='.$to_db_version)."
"; +print "DB Version bigger $to_db_version: ".$db->dbCompareVersion('>'.$to_db_version)."
"; /* $q = "SELECT FOO FRO BAR"; // $q = "Select * from foo"; -$foo = $basic->dbExecAsync($q); +$foo = $db->dbExecAsync($q); print "[ERR] Query: ".$q."
"; print "[ERR] RESOURCE: $foo
"; -while (($ret = $basic->dbCheckAsync()) === true) +while (($ret = $db->dbCheckAsync()) === true) { print "[ERR]: $ret
"; sleep(5); @@ -185,17 +195,17 @@ while (($ret = $basic->dbCheckAsync()) === true) // search path check $q = "SHOW search_path"; -$cursor = $basic->dbExec($q); -$data = $basic->dbFetchArray($cursor)['search_path']; +$cursor = $db->dbExec($q); +$data = $db->dbFetchArray($cursor)['search_path']; print "RETURN DATA FOR search_path: ".$data."
"; // print "RETURN DATA FOR search_path: ".DgS::printAr($data)."
"; // insert something into test.schema_test and see if we get the PK back -$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); -print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."
"; +$status = $db->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); +print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$db->pk_name.", PRIMARY KEY: ".$db->insert_id."
"; print "NULL TEST DB READ
"; $q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'"; -$res = $basic->dbReturnRow($q); +$res = $db->dbReturnRow($q); var_dump($res); print "RES: ".DgS::printAr($res)."
"; print "ISSET: ".isset($res['null_varchar'])."
"; diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index 490c5863..7571552c 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -121,6 +121,26 @@ class AttachOutside $ao = new AttachOutside($basic->log); print "AO-CLASS: DEBUG: ".$ao->test()."
"; +// @codingStandardsIgnoreLine +class AttachFull +{ + public $main; + public function __construct(object $class) + { + $this->main = $class; + } + public function test() + { + // should trigger deprecated + return $this->main->rgb2hex(2, 3, 4); + } +} + +$af = new AttachFull($basic); +// should trigger deprecated +print "DEPREACTEDTEST: ".$af->test()."
"; + + print "GETCALLERCLASS(NON CLASS): ".\CoreLibs\Debug\Support::getCallerClass()."
"; // fdebug diff --git a/www/admin/class_test.html.php b/www/admin/class_test.html.php index 4827a21a..b7190046 100644 --- a/www/admin/class_test.html.php +++ b/www/admin/class_test.html.php @@ -1,4 +1,5 @@ -magicLinks($magic_link))."
"; */ +$text = 'I am some text +with some +line breaks +in there. Theis +is sucky'; + +print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text)."
"; +print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text, '##BR##')."
"; // error message print $basic->log->printErrorMsg(); diff --git a/www/admin/class_test.lang.php b/www/admin/class_test.lang.php new file mode 100644 index 00000000..71ead5c5 --- /dev/null +++ b/www/admin/class_test.lang.php @@ -0,0 +1,58 @@ +TEST CLASS: LANG"; +print ""; +print '
Class Test Master
'; + +$string = 'INPUT TEST'; + +echo "LANGUAGE SET: ".$l->__getLang()."
"; +echo "LANGUAGE FILE: ".$l->__getMoFile()."
"; +echo "INPUT TEST: ".$string." => ".$l->__($string)."
"; + +// switch to other language +$lang = 'ja_utf8'; +$l->l10nReloadMOfile($lang); + +echo "LANGUAGE SET: ".$l->__getLang()."
"; +echo "LANGUAGE FILE: ".$l->__getMoFile()."
"; +echo "INPUT TEST: ".$string." => ".$l->__($string)."
"; +// TODO: run compare check input must match output + +// error message +print $basic->log->printErrorMsg(); + +print ""; + +// __END__ diff --git a/www/admin/class_test.output.form.php b/www/admin/class_test.output.form.php new file mode 100644 index 00000000..f90455f2 --- /dev/null +++ b/www/admin/class_test.output.form.php @@ -0,0 +1,47 @@ +log); + +print "TEST CLASS: FORM GENERATE"; +print ""; +print '
Class Test Master
'; + +print "TODO
"; + +// error message +print $basic->log->printErrorMsg(); + +print ""; + +// __END__ diff --git a/www/admin/class_test.php b/www/admin/class_test.php index cac7bd43..66e75369 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -1,4 +1,5 @@ -Class Test: RANDOM KEY' print '
Class Test: SYSTEM
'; print '
Class Test: RUNNING TIME
'; print '
Class Test: DEBUG
'; +print '
Class Test: FORM
'; +print '
Class Test: BACKEND ADMIN CLASS
'; +print '
Class Test: LANG/L10n
'; +print '
Class Test: SMARTY
'; // set + check edit access id $edit_access_id = 3; @@ -104,6 +109,17 @@ if (is_object($login)) { // $basic->adbSetACL($login->acl); } +print "THIS HOST: ".HOST_NAME.", with PROTOCOL: ".HOST_PROTOCOL." is running SSL: ".HOST_SSL."
"; +print "DIR: ".DIR."
"; +print "BASE: ".BASE."
"; +print "ROOT: ".ROOT."
"; +print "HOST: ".HOST_NAME." => DB HOST: ".DB_CONFIG_NAME." => ".print_r(DB_CONFIG, true)."
"; + +$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR; +$du = DS ?? DIRECTORY_SEPARATOR; +print "DS is: ".$ds."
"; +print "SERVER HOST: ".$_SERVER['HTTP_HOST']."
"; + // print error messages // print $login->log->printErrorMsg(); print $basic->log->printErrorMsg(); diff --git a/www/admin/class_test.smarty.php b/www/admin/class_test.smarty.php new file mode 100644 index 00000000..ea337dea --- /dev/null +++ b/www/admin/class_test.smarty.php @@ -0,0 +1,94 @@ +TEST CLASS: SMARTY"; +print ""; +print '
Class Test Master
'; + +$smarty->DATA['JS_DEBUG'] = DEBUG; +$smarty->MASTER_TEMPLATE_NAME = 'main_body.tpl'; +$smarty->TEMPLATE_NAME = 'smarty_test.tpl'; +$smarty->CSS_SPECIAL_TEMPLATE_NAME = 'smart_test.css'; +$smarty->USE_PROTOTYPE = false; +$smarty->USE_JQUERY = true; +$smarty->JS_DATEPICKR = false; +if ($smarty->USE_PROTOTYPE) { + $smarty->ADMIN_JAVASCRIPT = 'edit.pt.js'; + $smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js'; +} elseif ($smarty->USE_JQUERY) { + $smarty->ADMIN_JAVASCRIPT = 'edit.jq.js'; + $smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js'; +} +$smarty->PAGE_WIDTH = '100%'; +// require BASE.INCLUDES.'admin_set_paths.php'; +$smarty->setSmartyPaths(); + +// smarty test +$smarty->DATA['SMARTY_TEST'] = 'Test Data'; +$smarty->DATA['TRANSLATE_TEST'] = $l->__('Are we translated?'); +$smarty->DATA['TRANSLATE_TEST_SMARTY'] = $smarty->l10n->__('Are we translated?'); + +// drop down test with optgroups +$options = [ + '' => '選択してください', + '4/25(木)' => [ + '4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50', + '4/25(木) 12:20-13:00' => '4/25(木) 12:20-13:00' + ], + '4/26(金)' => [ + '4/26(金) 11:00-11:50' => '4/26(金) 11:00-11:50', + '4/26(金) 12:20-13:00' => '4/26(金) 12:20-13:00' + ], + '4/27(土)' => [ + '4/27(土) 11:00-11:50' => '4/27(土) 11:00-11:50', + '4/27(土) 12:20-13:00' => '4/27(土) 12:20-13:00' + ], +]; + +$smarty->DATA['drop_down_test'] = $options; +$smarty->DATA['loop_start'] = 2; +// require BASE.INCLUDES.'admin_smarty.php'; +$smarty->setSmartyVarsAdmin(); + +// error message +print $basic->log->printErrorMsg(); + +print ""; + +// __END__ diff --git a/www/admin/l10n_test.php b/www/admin/l10n_test.php deleted file mode 100755 index 014d66b7..00000000 --- a/www/admin/l10n_test.php +++ /dev/null @@ -1,29 +0,0 @@ -__getLang()."
"; -echo "LANGUAGE FILE: ".$l->__getMoFile()."
"; -echo "INPUT TEST: ".$string." => ".$l->__($string)."
"; - -// switch to other language -$lang = 'ja_utf8'; -$l->l10nReloadMOfile($lang); - -echo "LANGUAGE SET: ".$l->__getLang()."
"; -echo "LANGUAGE FILE: ".$l->__getMoFile()."
"; -echo "INPUT TEST: ".$string." => ".$l->__($string)."
"; - -// __END__ diff --git a/www/admin/namespace_test.php b/www/admin/namespace_test.php deleted file mode 100755 index 8975562c..00000000 --- a/www/admin/namespace_test.php +++ /dev/null @@ -1,41 +0,0 @@ -ROOT: ".ROOT."
BASE: ".BASE."
"; - -$base = new CoreLibs\Admin\Backend(DB_CONFIG); -ob_end_flush(); -if ($base->getConnectionStatus()) { - die("Cannot connect to database"); -} - -print "Start time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; -print "HumanReadableByteFormat: ".\CoreLibs\Convert\Byte::HumanReadableByteFormat(1234567.12)."
"; -print "humanReadableByteFormat: ".\CoreLibs\Convert\Byte::humanReadableByteFormat(1234567.12)."
"; -print "getPageName: ". \CoreLibs\Get\System::getPageName()."
"; - -print "DB Info: ".$base->dbInfo(true)."
"; - - -print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; -print "Start Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; - -print "Lang: ".$base->l->__getLang().", MO File: ".$base->l->__getMoFile()."
"; -print "Translate test: Year -> ".$base->l->__('Year')."
"; - -print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; -// end error print -print $base->log->printErrorMsg(); - -# __END__ diff --git a/www/admin/other_test.php b/www/admin/other_test.php deleted file mode 100755 index cf34cade..00000000 --- a/www/admin/other_test.php +++ /dev/null @@ -1,34 +0,0 @@ -foo = 'BAR'; - } - - public function otherBarBar($wrong) - { - echo "B: $wrong
"; - } - - public function barBar($wrong) - { - echo "B: $wrong
"; - } -} - -$foo = $bar ?? 'EMPTY'; -echo "BAR: ".$foo."
"; -// define('DS', DIRECTORY_SEPARATOR); -$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR; -$du = DS ?? DIRECTORY_SEPARATOR; -echo "DS is: ".$ds."
"; - -echo "SERVER HOST: ".$_SERVER['HTTP_HOST']."
"; - -// __END__ diff --git a/www/admin/smarty_test.php b/www/admin/smarty_test.php deleted file mode 100755 index 6be829e4..00000000 --- a/www/admin/smarty_test.php +++ /dev/null @@ -1,59 +0,0 @@ -MASTER_TEMPLATE_NAME = 'main_body.tpl'; - $smarty->TEMPLATE_NAME = 'smarty_test.tpl'; - $smarty->CSS_SPECIAL_TEMPLATE_NAME = 'smart_test.css'; - $smarty->USE_PROTOTYPE = false; - $smarty->USE_JQUERY = true; - $smarty->JS_DATEPICKR = false; - if ($smarty->USE_PROTOTYPE) { - $smarty->ADMIN_JAVASCRIPT = 'edit.pt.js'; - $smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js'; - } elseif ($smarty->USE_JQUERY) { - $smarty->ADMIN_JAVASCRIPT = 'edit.jq.js'; - $smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js'; - } - $smarty->PAGE_WIDTH = '100%'; - // require BASE.INCLUDES.'admin_set_paths.php'; - $smarty->setSmartyPaths(); - - // smarty test - $smarty->DATA['SMARTY_TEST'] = 'Test Data'; - $smarty->DATA['TRANSLATE_TEST'] = $cms->l->__('Are we translated?'); -} - -// drop down test with optgroups -$options = array ( - '' => '選択してください', - '4/25(木)' => array ( - '4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50', - '4/25(木) 12:20-13:00' => '4/25(木) 12:20-13:00' - ), - '4/26(金)' => array ( - '4/26(金) 11:00-11:50' => '4/26(金) 11:00-11:50', - '4/26(金) 12:20-13:00' => '4/26(金) 12:20-13:00' - ), - '4/27(土)' => array ( - '4/27(土) 11:00-11:50' => '4/27(土) 11:00-11:50', - '4/27(土) 12:20-13:00' => '4/27(土) 12:20-13:00' - ) -); - -if (is_object($smarty)) { - $smarty->DATA['drop_down_test'] = $options; - $smarty->DATA['loop_start'] = 2; - // require BASE.INCLUDES.'admin_smarty.php'; - $smarty->setSmartyVarsAdmin(); -} -require BASE.INCLUDES.'admin_footer.php'; diff --git a/www/admin/various_class_test.php b/www/admin/various_class_test.php deleted file mode 100755 index e8de0c47..00000000 --- a/www/admin/various_class_test.php +++ /dev/null @@ -1,111 +0,0 @@ -"; -print "DIR: ".DIR."
"; -print "BASE: ".BASE."
"; -print "ROOT: ".ROOT."
"; -print "HOST: ".HOST_NAME." => DB HOST: ".DB_CONFIG_NAME." => ".print_r(DB_CONFIG, true)."
"; - -$text = 'I am some text -with some -line breaks -in there. Theis -is sucky'; - -print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text)."
"; -print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text, '##BR##')."
"; - -// $test = array ( -// 'A' => array ( -// 'B' => array (), -// 'C' => array ( -// 'D' => array (), -// 'E' => array ( -// 'F' => array () -// ) -// ) -// ), -// '1' => array (), -// '2' => array (), -// '3' => array ( -// 'G' => array () -// ) -// ); - -// $base->log->debug('ARRAY', \CoreLibs\Debug\Support::printAr($test)); - -function rec($pre, $cur, $node = array ()) -{ - if (!is_array($node)) { - $node = array (); - } - print "
#### PRE: ".$pre.", CUR: ".$cur.", N-c: ".count($node)." [".join('|', array_keys($node))."]
"; - if (!$pre) { - print "** NEW
"; - $node[$cur] = array (); - } else { - if (array_key_exists($pre, $node)) { - print "+ KEY FOUND: ".$pre.", add: ".$cur."
"; - $node[$pre][$cur] = array (); - } else { - print "- NOT FOUND: loop
"; - foreach ($node as $_pre => $_cur) { - print "> TRY: ".$_pre." => ".count($_cur)." [".join('|', array_keys($_cur))."]
"; - if (count($_cur) > 0) { - $node[$_pre] = rec($pre, $cur, $_cur); - } - } - } - } - return $node; -} - -function flattenArrayKey(array $array, array $return = array ()) -{ - foreach ($array as $key => $sub) { - $return[] = $key; - if (count($sub) > 0) { - $return = flattenArrayKey($sub, $return); - } - } - return $return; -} - -$test = array (); -// core -$test = rec('', 'A', $test); -$test = rec('', '1', $test); -$test = rec('', '2', $test); -$test = rec('', '3', $test); -$test = rec('3', 'G', $test); -$test = rec('A', 'B', $test); -$test = rec('A', 'C', $test); -$test = rec('C', 'D', $test); -$test = rec('C', 'E', $test); -$test = rec('E', 'F', $test); -// new -$test = rec('C', 'U', $test); -$test = rec('F', 'U', $test); -$test = rec('', 'Al', $test); -$test = rec('B', 'B1', $test); -$base->log->debug('REC', \CoreLibs\Debug\Support::printAr($test)); -print "FLATTEN: ".\CoreLibs\Debug\Support::printAr(flattenArrayKey($test))."
"; - -print $base->log->printErrorMsg(); - -// __END__ diff --git a/www/configs/config.db.php b/www/configs/config.db.php index 1c963bf0..b5f51467 100755 --- a/www/configs/config.db.php +++ b/www/configs/config.db.php @@ -10,9 +10,9 @@ // please be VERY carefull only to change the right side $DB_CONFIG = [ 'test' => [ - 'db_name' => 'gullevek', - 'db_user' => 'gullevek', - 'db_pass' => 'gullevek', + 'db_name' => 'clemens', + 'db_user' => 'clemens', + 'db_pass' => 'clemens', 'db_host' => 'db.tokyo.tequila.jp', 'db_port' => 5432, 'db_schema' => 'public', diff --git a/www/includes/admin_footer.php b/www/includes/admin_footer.php index 3e4cb7ab..96c50d9e 100644 --- a/www/includes/admin_footer.php +++ b/www/includes/admin_footer.php @@ -10,5 +10,6 @@ // print debug messages echo $login->log->printErrorMsg(); echo $cms->log->printErrorMsg(); +$cms->log->debug('DEBUGEND', '==================================== [END]'); // __END__ diff --git a/www/includes/edit_base.php b/www/includes/edit_base.php index ad225bda..9127bde3 100644 --- a/www/includes/edit_base.php +++ b/www/includes/edit_base.php @@ -17,9 +17,9 @@ * 2003-06-10: creation of this page *********************************************************************/ -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; // TODO: only extract _POST data that is needed extract($_POST, EXTR_SKIP); @@ -30,10 +30,10 @@ require 'config.php'; $SET_SESSION_NAME = EDIT_SESSION_NAME; // overrride debug flags if (!DEBUG) { - $DEBUG_ALL = 0; - $PRINT_ALL = 0; - $DB_DEBUG = 0; - $ECHO_ALL = 0; + $DEBUG_ALL = false; + $PRINT_ALL = false; + $DB_DEBUG = false; + $ECHO_ALL = false; } // should be utf8 diff --git a/www/includes/lang/admin/en_utf8.mo b/www/includes/lang/admin/en_utf8.mo index ce0b0578005ff5478879329155db4f37d58503c9..e4bc893dde283e625aec708d90a33e60cd806586 100644 GIT binary patch delta 297 zcmcb?+{{{kPl#nI0}!wQu?!IV05LZZ*8njHtN>ymAYKW?VnDnHh`E6HG7z%@@jW1B z0pce>Y{tmI@DfPN1F-@V1A_*Tb^y|RKspmhgVa|5X^{FlAPrO=3}hkz$Ppj_QpgNu zK@y}?|6Pl#nI0}!wPu?!H~05K~N#{e-16aX<75ElY5NW2D!L28?T*o={Zp&dx` z0r5T{8zg@gNQ2}r18E=vvw;)?GY~U@7@mFsp&<$(uE8M;zWI3@AKEiY`G
- TRANSLATION CLASS: {$TRANSLATE_TEST} + TRANSLATION CLASS (OUT): {$TRANSLATE_TEST} +
+
+ TRANSLATION CLASS (SMARTY): {$TRANSLATE_TEST_SMARTY}