Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78e1d73cd9 | ||
|
|
620a5878c1 | ||
|
|
5a0b09a916 | ||
|
|
98c6033c75 | ||
|
|
6dcebc9b67 | ||
|
|
c97520e186 |
@@ -118,7 +118,9 @@ return [
|
|||||||
'www/admin/qq_file_upload_front.php',
|
'www/admin/qq_file_upload_front.php',
|
||||||
'www/admin/qq_file_upload_ajax.php',
|
'www/admin/qq_file_upload_ajax.php',
|
||||||
// symlink ignore
|
// symlink ignore
|
||||||
'www/lib/smarty-4.3.0/libs/Smarty.class.php'
|
'www/lib/smarty-4.3.0/libs/Smarty.class.php',
|
||||||
|
// legacy edit base (until removal)
|
||||||
|
'www/includes/edit_base.LEGACY.php'
|
||||||
],
|
],
|
||||||
|
|
||||||
// what not to show as problem
|
// what not to show as problem
|
||||||
|
|||||||
169
4dev/bin/mo_to_js.sh
Executable file
169
4dev/bin/mo_to_js.sh
Executable file
@@ -0,0 +1,169 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# read source mo files and writes target js files in object form
|
||||||
|
|
||||||
|
# check for ARG 1 is "mv"
|
||||||
|
# then move the files directly and don't do manual check (don't create temp files)
|
||||||
|
FILE_MOVE=0;
|
||||||
|
if [ "${1}" = "mv" ]; then
|
||||||
|
echo "*** Direct write ***";
|
||||||
|
FILE_MOVE=1;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
target='';
|
||||||
|
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
|
||||||
|
# Assume script is in 4dev/bin
|
||||||
|
base_folder="${BASE_FOLDER}../../www/";
|
||||||
|
po_folder='../4dev/locale/'
|
||||||
|
mo_folder='includes/locale/';
|
||||||
|
target_folder='';
|
||||||
|
template_file_stump='##SUFFIX##translate-##LANGUAGE##.TMP.js';
|
||||||
|
# for output file names
|
||||||
|
source_list=(iw);
|
||||||
|
language_list=(en ja);
|
||||||
|
# set target names
|
||||||
|
if [ "${target}" == '' ]; then
|
||||||
|
echo "*** Non smarty ***";
|
||||||
|
TEXTDOMAINDIR=${base_folder}${mo_folder}.
|
||||||
|
# default is admin
|
||||||
|
TEXTDOMAIN=admin;
|
||||||
|
fi;
|
||||||
|
js_folder="layout/${TEXTDOMAIN}/javascript/";
|
||||||
|
|
||||||
|
error=0;
|
||||||
|
# this checks if the TEXTDOMAIN target actually exists
|
||||||
|
if [ ! -d "${base_folder}${js_folder}" ]; then
|
||||||
|
echo "Cannot find target javascript folder ${base_folder}${js_folder}";
|
||||||
|
error=1;
|
||||||
|
else
|
||||||
|
target_folder="${base_folder}${js_folder}";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ ${error} -eq 1 ]; then
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# locale gettext po to mo translator master
|
||||||
|
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
||||||
|
file=$(basename $file .po);
|
||||||
|
echo "Translate language ${file}";
|
||||||
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
|
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
||||||
|
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
||||||
|
fi;
|
||||||
|
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}${po_folder}${locale}-${domain}.po;
|
||||||
|
done;
|
||||||
|
|
||||||
|
rx_msgid_empty="^msgid \"\"";
|
||||||
|
rx_msgid="^msgid \"";
|
||||||
|
rx_msgstr="^msgstr \""
|
||||||
|
|
||||||
|
# quick copy string at the end
|
||||||
|
quick_copy='';
|
||||||
|
|
||||||
|
for language in ${language_list[*]}; do
|
||||||
|
# I don't know which one must be set, but I think at least LANGUAGE
|
||||||
|
case ${language} in
|
||||||
|
ja)
|
||||||
|
LANG=ja_JP.UTF-8;
|
||||||
|
ENCODING=UTF-8;
|
||||||
|
LANGUAGE=ja;
|
||||||
|
;;
|
||||||
|
en)
|
||||||
|
# was en_JP.UTF-8
|
||||||
|
LANG=en_US.UTF-8;
|
||||||
|
ENCODING=UTF-8;
|
||||||
|
LANGUAGE=en;
|
||||||
|
;;
|
||||||
|
esac;
|
||||||
|
# write only one for language and then symlink files
|
||||||
|
template_file=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##//" | sed -e "s/##LANGUAGE##/${LANG}/");
|
||||||
|
original_file=$(echo ${template_file} | sed -e 's/\.TMP//g');
|
||||||
|
if [ "${FILE_MOVE}" -eq 0 ]; then
|
||||||
|
file=${target_folder}${template_file};
|
||||||
|
else
|
||||||
|
file=${target_folder}${original_file};
|
||||||
|
fi;
|
||||||
|
echo "===> Write translation file ${file}";
|
||||||
|
echo ". = normal, : = escape, x = skip";
|
||||||
|
# init line [aka don't touch this file]
|
||||||
|
echo "// AUTO FILL, changes will be overwritten" > $file;
|
||||||
|
echo "// source: ${suffix}, language: ${language}" >> $file;
|
||||||
|
echo "// Translation strings in the format" >> $file;
|
||||||
|
echo "// \"Original\":\"Translated\""$'\n' >> $file;
|
||||||
|
echo "var i18n = {" >> $file;
|
||||||
|
# translations stuff
|
||||||
|
# read the po file
|
||||||
|
pos=0; # do we add a , for the next line
|
||||||
|
cat "${base_folder}${po_folder}${language}-${TEXTDOMAIN}.po" |
|
||||||
|
while read str; do
|
||||||
|
# echo "S: ${str}";
|
||||||
|
# skip empty
|
||||||
|
if [[ "${str}" =~ ${rx_msgid_empty} ]]; then
|
||||||
|
# skip on empty
|
||||||
|
echo -n "x";
|
||||||
|
# msgid is left, msgstr is right
|
||||||
|
elif [[ "${str}" =~ ${rx_msgid} ]]; then
|
||||||
|
echo -n ".";
|
||||||
|
# open left side
|
||||||
|
# TODO: how to handle multi line strings: or don't use them
|
||||||
|
# extract from between ""
|
||||||
|
str_source=$(echo "${str}" | sed -e "s/^msgid \"//" | sed -e "s/\"$//");
|
||||||
|
# close right side, if not last add ,
|
||||||
|
if [ "${pos}" -eq 1 ]; then
|
||||||
|
echo -n "," >> $file;
|
||||||
|
fi;
|
||||||
|
# all " inside string need to be escaped
|
||||||
|
str_source=$(echo "${str_source}" | sed -e 's/"/\\"/g');
|
||||||
|
# fix with proper layout
|
||||||
|
echo -n "\"$str_source\":\"$(TEXTDOMAINDIR=${TEXTDOMAINDIR} LANGUAGE=${language} LANG=${LANG} gettext ${TEXTDOMAIN} "${str_source}")\"" >> $file;
|
||||||
|
pos=1;
|
||||||
|
elif [[ "${str}" =~ ${rx_msgstr} ]]; then
|
||||||
|
# open right side (ignore)
|
||||||
|
echo -n "";
|
||||||
|
else
|
||||||
|
# general ignore (anything between or comments)
|
||||||
|
echo -n "";
|
||||||
|
fi;
|
||||||
|
done;
|
||||||
|
|
||||||
|
echo "" >> $file;
|
||||||
|
echo "};" >> $file;
|
||||||
|
echo " [DONE]";
|
||||||
|
|
||||||
|
# on no move
|
||||||
|
if [ "${FILE_MOVE}" -eq 0 ]; then
|
||||||
|
echo "===> Confirm all changes in ${file} and then move data to original";
|
||||||
|
echo "";
|
||||||
|
quick_copy=${quick_copy}"mv ${template_file} ${original_file}"$'\n';
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# symlink to master file
|
||||||
|
for suffix in ${source_list[*]}; do
|
||||||
|
# symlink with full lang name
|
||||||
|
symlink_file[0]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANG}/" | sed -e 's/\.TMP//g');
|
||||||
|
# create second one with lang (no country) + encoding
|
||||||
|
symlink_file[1]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANGUAGE}\.${ENCODING}/" | sed -e 's/\.TMP//g');
|
||||||
|
for template_file in ${symlink_file[@]}; do
|
||||||
|
# if this is not symlink, create them
|
||||||
|
if [ ! -h "${template_file}" ]; then
|
||||||
|
echo "Create symlink: ${template_file}";
|
||||||
|
# symlik to original
|
||||||
|
cd "${target_folder}";
|
||||||
|
ln -sf "${original_file}" "${template_file}";
|
||||||
|
cd - >/dev/null;
|
||||||
|
fi;
|
||||||
|
done;
|
||||||
|
done;
|
||||||
|
done;
|
||||||
|
|
||||||
|
if [ "${FILE_MOVE}" -eq 0 ]; then
|
||||||
|
echo "";
|
||||||
|
echo "-- IN FOLDER: ${target_folder}";
|
||||||
|
echo "-- START: copy lines below to copy created over original --";
|
||||||
|
echo "${quick_copy}";
|
||||||
|
echo "-- END ----------------------------------------------------";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# __END__
|
||||||
47
4dev/tests/CoreLibsAdminEditPageTest.php
Normal file
47
4dev/tests/CoreLibsAdminEditPageTest.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace tests;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for Admin\EditPage
|
||||||
|
* @coversDefaultClass \CoreLibs\Admin\EditPage
|
||||||
|
* @testdox \CoreLibs\Admin\EditPage method tests
|
||||||
|
*/
|
||||||
|
final class CoreLibsAdminEditPageTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
if (!extension_loaded('pgsql')) {
|
||||||
|
$this->markTestSkipped(
|
||||||
|
'The PgSQL extension is not available.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @testdox Admin\EditPage Class tests
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAdminEditPage()
|
||||||
|
{
|
||||||
|
/* $this->assertTrue(true, 'ACL Login Tests not implemented');
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'ACL\Login Tests have not yet been implemented'
|
||||||
|
); */
|
||||||
|
$this->markTestSkipped('No implementation for Admin\EditPage at the moment');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -2770,7 +2770,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// - prepared query execute
|
// - prepared query execute
|
||||||
// dbPrepare, dbExecute, dbFetchArray
|
// dbPrepare, dbExecute, dbFetchArray, dbGetPrepareCursorValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
@@ -2795,6 +2795,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
// 11: read query (if insert/update)
|
// 11: read query (if insert/update)
|
||||||
// 11: execute data to check (array)
|
// 11: execute data to check (array)
|
||||||
// 12: insert data
|
// 12: insert data
|
||||||
|
// 13: prepated cursor array data match values
|
||||||
return [
|
return [
|
||||||
// insert
|
// insert
|
||||||
'prepare query insert' => [
|
'prepare query insert' => [
|
||||||
@@ -2818,6 +2819,14 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
],
|
],
|
||||||
// insert data (for select)
|
// insert data (for select)
|
||||||
'',
|
'',
|
||||||
|
// get prepared data
|
||||||
|
[
|
||||||
|
'pk_name' => 'table_with_primary_key_id',
|
||||||
|
'count' => 2,
|
||||||
|
'query' => 'INSERT INTO table_with_primary_key (row_int, uid) '
|
||||||
|
. 'VALUES ($1, $2) RETURNING table_with_primary_key_id',
|
||||||
|
'returning_id' => true,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// update
|
// update
|
||||||
'prepare query update' => [
|
'prepare query update' => [
|
||||||
@@ -2844,6 +2853,14 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
//
|
//
|
||||||
"INSERT INTO table_with_primary_key (row_int, uid) VALUES "
|
"INSERT INTO table_with_primary_key (row_int, uid) VALUES "
|
||||||
. "(111, 'TEST A')",
|
. "(111, 'TEST A')",
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 3,
|
||||||
|
'query' => 'UPDATE table_with_primary_key SET row_int = $1, '
|
||||||
|
. 'row_varchar = $2 WHERE uid = $3',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// select
|
// select
|
||||||
'prepare select query' => [
|
'prepare select query' => [
|
||||||
@@ -2865,7 +2882,14 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
//
|
//
|
||||||
$insert_query
|
$insert_query,
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 1,
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key WHERE uid = $1',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// any query but with no parameters
|
// any query but with no parameters
|
||||||
'prepare select query no parameter' => [
|
'prepare select query no parameter' => [
|
||||||
@@ -2890,7 +2914,14 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
//
|
//
|
||||||
$insert_query
|
$insert_query,
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 0,
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// no statement name (25)
|
// no statement name (25)
|
||||||
'empty statement' => [
|
'empty statement' => [
|
||||||
@@ -2907,6 +2938,13 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
//
|
//
|
||||||
'',
|
'',
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 0,
|
||||||
|
'query' => '',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// no query (prepare 11)
|
// no query (prepare 11)
|
||||||
// no prepared cursor found with statement name (execute 24)
|
// no prepared cursor found with statement name (execute 24)
|
||||||
@@ -2924,6 +2962,13 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
//
|
//
|
||||||
'',
|
'',
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 0,
|
||||||
|
'query' => '',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// no db connection (prepare/execute 16)
|
// no db connection (prepare/execute 16)
|
||||||
// TODO no db connection test
|
// TODO no db connection test
|
||||||
@@ -2944,8 +2989,15 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
// no query but data for data only compare
|
// no query but data for data only compare
|
||||||
'',
|
'',
|
||||||
[],
|
[],
|
||||||
//,
|
//
|
||||||
$insert_query
|
$insert_query,
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => '',
|
||||||
|
'count' => 0,
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'returning_id' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// insert wrong data count compared to needed (execute 23)
|
// insert wrong data count compared to needed (execute 23)
|
||||||
'wrong parmeter count' => [
|
'wrong parmeter count' => [
|
||||||
@@ -2962,7 +3014,15 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'',
|
'',
|
||||||
[],
|
[],
|
||||||
//
|
//
|
||||||
''
|
'',
|
||||||
|
//
|
||||||
|
[
|
||||||
|
'pk_name' => 'table_with_primary_key_id',
|
||||||
|
'count' => 2,
|
||||||
|
'query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES '
|
||||||
|
. '($1, $2) RETURNING table_with_primary_key_id',
|
||||||
|
'returning_id' => true,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// execute does not return a result (22)
|
// execute does not return a result (22)
|
||||||
// TODO execute does not return a result
|
// TODO execute does not return a result
|
||||||
@@ -2975,6 +3035,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
* @covers ::dbPrepare
|
* @covers ::dbPrepare
|
||||||
* @covers ::dbExecute
|
* @covers ::dbExecute
|
||||||
* @covers ::dbFetchArray
|
* @covers ::dbFetchArray
|
||||||
|
* @covers ::dbGetPrepareCursorValue
|
||||||
* @dataProvider preparedProvider
|
* @dataProvider preparedProvider
|
||||||
* @testdox prepared query $stm_name with $expected_prepare (warning $warning_prepare/error $error_prepare) and $expected_execute (warning $warning_execute/error $error_execute) [$_dataName]
|
* @testdox prepared query $stm_name with $expected_prepare (warning $warning_prepare/error $error_prepare) and $expected_execute (warning $warning_execute/error $error_execute) [$_dataName]
|
||||||
*
|
*
|
||||||
@@ -2991,6 +3052,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
* @param string $expected_data_query
|
* @param string $expected_data_query
|
||||||
* @param array $expected_data
|
* @param array $expected_data
|
||||||
* @param string $insert_data
|
* @param string $insert_data
|
||||||
|
* @param array $prepare_cursor
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDbPrepared(
|
public function testDbPrepared(
|
||||||
@@ -3006,7 +3068,8 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
string $error_execute,
|
string $error_execute,
|
||||||
string $expected_data_query,
|
string $expected_data_query,
|
||||||
array $expected_data,
|
array $expected_data,
|
||||||
string $insert_data
|
string $insert_data,
|
||||||
|
array $prepare_cursor,
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -3116,6 +3179,15 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check dbGetPrepareCursorValue
|
||||||
|
foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) {
|
||||||
|
$this->assertEquals(
|
||||||
|
$prepare_cursor[$key],
|
||||||
|
$db->dbGetPrepareCursorValue($stm_name, $key),
|
||||||
|
'Prepared cursor: ' . $key . ': failed assertion'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// reset all data
|
// reset all data
|
||||||
$db->dbExec("TRUNCATE table_with_primary_key");
|
$db->dbExec("TRUNCATE table_with_primary_key");
|
||||||
$db->dbExec("TRUNCATE table_without_primary_key");
|
$db->dbExec("TRUNCATE table_without_primary_key");
|
||||||
@@ -3123,6 +3195,90 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$db->dbClose();
|
$db->dbClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dedicated error checks for prepare cursor return
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function preparedProviderValue(): array
|
||||||
|
{
|
||||||
|
// 1: query (can be empty for do not set)
|
||||||
|
// 2: stm name
|
||||||
|
// 3: key
|
||||||
|
// 4: expected error return
|
||||||
|
return [
|
||||||
|
'no error' => [
|
||||||
|
"SELECT row_int, uid FROM table_with_primary_key",
|
||||||
|
'read',
|
||||||
|
'pk_name',
|
||||||
|
''
|
||||||
|
],
|
||||||
|
'statement name empty' => [
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'101',
|
||||||
|
],
|
||||||
|
'key empty' => [
|
||||||
|
'',
|
||||||
|
'read',
|
||||||
|
'',
|
||||||
|
'102',
|
||||||
|
],
|
||||||
|
'key invalid' => [
|
||||||
|
'',
|
||||||
|
'read',
|
||||||
|
'invalid',
|
||||||
|
'102',
|
||||||
|
],
|
||||||
|
'statement name not found' => [
|
||||||
|
'',
|
||||||
|
'invalid',
|
||||||
|
'pk_name',
|
||||||
|
'103',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test return prepare cursor errors
|
||||||
|
*
|
||||||
|
* @covers ::dbGetPrepareCursorValue
|
||||||
|
* @dataProvider preparedProviderValue
|
||||||
|
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $query
|
||||||
|
* @param string $stm_name
|
||||||
|
* @param string $key
|
||||||
|
* @param string $error_id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDbGetPrepareCursorValue(
|
||||||
|
string $query,
|
||||||
|
string $stm_name,
|
||||||
|
string $key,
|
||||||
|
$error_id
|
||||||
|
): void {
|
||||||
|
$db = new \CoreLibs\DB\IO(
|
||||||
|
self::$db_config['valid'],
|
||||||
|
self::$log
|
||||||
|
);
|
||||||
|
if (!empty($query)) {
|
||||||
|
$db->dbPrepare($stm_name, $query);
|
||||||
|
$db->dbExecute($stm_name);
|
||||||
|
}
|
||||||
|
$db->dbGetPrepareCursorValue($stm_name, $key);
|
||||||
|
// match check error
|
||||||
|
$last_error = $db->dbGetLastError();
|
||||||
|
$this->assertEquals(
|
||||||
|
$error_id,
|
||||||
|
$last_error,
|
||||||
|
'get prepare cursor value error check'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// - schema set/get tests
|
// - schema set/get tests
|
||||||
// dbGetSchema, dbSetSchema
|
// dbGetSchema, dbSetSchema
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Files to be changed
|
||||||
|
|
||||||
|
Change: Update edit_page and template/css
|
||||||
|
Date: 2023/1/6
|
||||||
|
|
||||||
|
## Detail
|
||||||
|
|
||||||
|
* add stripes to sub table entries (edit.css)
|
||||||
|
* fix cellspacing and cellpadding in sub tables (edit_element.tpl)
|
||||||
|
* doctype added (edit_order.tpl)
|
||||||
|
* code clean up in edit base, move to class system (edit_base.php)
|
||||||
|
|
||||||
|
## File List
|
||||||
|
|
||||||
|
```sh
|
||||||
|
includes/templates/admin/edit_elements.tpl
|
||||||
|
includes/templates/admin/edit_order.tpl
|
||||||
|
includes/edit_base.php
|
||||||
|
layout/admin/css/edit.css
|
||||||
|
```
|
||||||
@@ -36,6 +36,7 @@ parameters:
|
|||||||
# deprecated files
|
# deprecated files
|
||||||
- www/includes/admin_set_paths.php # ignore the admin include stuff
|
- www/includes/admin_set_paths.php # ignore the admin include stuff
|
||||||
- www/includes/admin_smarty.php # ignore the admin include stuff
|
- www/includes/admin_smarty.php # ignore the admin include stuff
|
||||||
|
- www/includes/edit_base.LEGACY.php # old style
|
||||||
# folders with data no check needed
|
# folders with data no check needed
|
||||||
- www/templates_c
|
- www/templates_c
|
||||||
- www/cache
|
- www/cache
|
||||||
|
|||||||
@@ -145,6 +145,11 @@ print "PREPARE INSERT[ins_test_foo] STATUS: " . Support::printToString($status)
|
|||||||
print "PREPARE INSERT PREVIOUS INSERTED: "
|
print "PREPARE INSERT PREVIOUS INSERTED: "
|
||||||
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
||||||
. "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
. "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||||
|
|
||||||
|
print "PREPARE CURSOR RETURN:<br>";
|
||||||
|
foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) {
|
||||||
|
print "KEY: " . $key . ': ' . $db->dbGetPrepareCursorValue('ins_test_foo', $key) . "<br>";
|
||||||
|
}
|
||||||
// returning test with multiple entries
|
// returning test with multiple entries
|
||||||
// $status = $db->db_exec(
|
// $status = $db->db_exec(
|
||||||
// "INSERT INTO test_foo (test) VALUES "
|
// "INSERT INTO test_foo (test) VALUES "
|
||||||
|
|||||||
563
www/includes/edit_base.LEGACY.php
Normal file
563
www/includes/edit_base.LEGACY.php
Normal file
@@ -0,0 +1,563 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
|
||||||
|
* CREATED: 2003/06/10
|
||||||
|
* SHORT DESCRIPTION:
|
||||||
|
* central include for all edit_pages
|
||||||
|
* - edit_groups.php
|
||||||
|
* - edit_languages.php
|
||||||
|
* - edit_pages.php
|
||||||
|
* - edit_schemes.php
|
||||||
|
* - edit_users.php
|
||||||
|
* - edit_visible_group.php
|
||||||
|
* HISTORY:
|
||||||
|
* 2005/06/30 (cs) remove color settings, they are in CSS File now
|
||||||
|
* 2005/06/22 (cs) moved load of config array into form class, set lang
|
||||||
|
* and lang is must set var for form class; removed the
|
||||||
|
* page name setting, moved it into the form class,
|
||||||
|
* emove all HTML from main page
|
||||||
|
* 2004/09/30 (cs) changed layout to fit default layout & changed LIBS, etc
|
||||||
|
* 2003-06-10: creation of this page
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$DEBUG_ALL = true;
|
||||||
|
$PRINT_ALL = true;
|
||||||
|
$ECHO_ALL = false;
|
||||||
|
$DB_DEBUG = true;
|
||||||
|
|
||||||
|
// TODO: only extract _POST data that is needed
|
||||||
|
extract($_POST, EXTR_SKIP);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
require 'config.php';
|
||||||
|
// overrride debug flags
|
||||||
|
if (!DEBUG) {
|
||||||
|
$DEBUG_ALL = false;
|
||||||
|
$PRINT_ALL = false;
|
||||||
|
$DB_DEBUG = false;
|
||||||
|
$ECHO_ALL = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// should be utf8
|
||||||
|
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
||||||
|
// start session
|
||||||
|
$session = new \CoreLibs\Create\Session(EDIT_SESSION_NAME);
|
||||||
|
// init logger
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => LOG_FILE_ID . 'EditBase',
|
||||||
|
'print_file_date' => true,
|
||||||
|
'per_class' => true,
|
||||||
|
'debug_all' => $DEBUG_ALL,
|
||||||
|
'echo_all' => $ECHO_ALL,
|
||||||
|
'print_all' => $PRINT_ALL,
|
||||||
|
]);
|
||||||
|
// db connection
|
||||||
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
|
// login page
|
||||||
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
|
// lang, path, domain
|
||||||
|
// pre auto detect language after login
|
||||||
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
|
// set lang and pass to smarty/backend
|
||||||
|
$l10n = new \CoreLibs\Language\L10n(
|
||||||
|
$locale['locale'],
|
||||||
|
$locale['domain'],
|
||||||
|
$locale['path'],
|
||||||
|
);
|
||||||
|
// flush and start
|
||||||
|
ob_end_flush();
|
||||||
|
// turn off set log per class
|
||||||
|
$log->setLogPer('class', false);
|
||||||
|
// create form class
|
||||||
|
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log, $l10n, $locale);
|
||||||
|
if ($form->mobile_phone) {
|
||||||
|
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
// smarty template engine (extended Translation version)
|
||||||
|
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||||
|
|
||||||
|
// $form->log->debug('POST', $form->log->prAr($_POST));
|
||||||
|
|
||||||
|
if (TARGET == 'live' || TARGET == 'remote') {
|
||||||
|
// login
|
||||||
|
$login->log->setLogLevelAll('debug', DEBUG ? true : false);
|
||||||
|
$login->log->setLogLevelAll('echo', false);
|
||||||
|
$login->log->setLogLevelAll('print', DEBUG ? true : false);
|
||||||
|
// form
|
||||||
|
$form->log->setLogLevelAll('debug', DEBUG ? true : false);
|
||||||
|
$form->log->setLogLevelAll('echo', false);
|
||||||
|
$form->log->setLogLevelAll('print', DEBUG ? true : false);
|
||||||
|
}
|
||||||
|
// space for setting special debug flags
|
||||||
|
$login->log->setLogLevelAll('debug', true);
|
||||||
|
// set smarty arrays
|
||||||
|
$HEADER = [];
|
||||||
|
$DATA = [];
|
||||||
|
$DEBUG_DATA = [];
|
||||||
|
// set the template dir
|
||||||
|
// WARNING: this has a special check for the mailing tool layout (old layout)
|
||||||
|
if (defined('LAYOUT')) {
|
||||||
|
$smarty->setTemplateDir(BASE . INCLUDES . TEMPLATES . CONTENT_PATH);
|
||||||
|
$DATA['css'] = LAYOUT . CSS;
|
||||||
|
$DATA['js'] = LAYOUT . JS;
|
||||||
|
} else {
|
||||||
|
$smarty->setTemplateDir(TEMPLATES);
|
||||||
|
$DATA['css'] = CSS;
|
||||||
|
$DATA['js'] = JS;
|
||||||
|
}
|
||||||
|
// set table width
|
||||||
|
$table_width = '100%';
|
||||||
|
$ADMIN_STYLESHEET = 'edit.css';
|
||||||
|
// define all needed smarty stuff for the general HTML/page building
|
||||||
|
$HEADER['CSS'] = CSS;
|
||||||
|
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||||
|
/** @phpstan-ignore-next-line because ADMIN_STYLESHEET can be null */
|
||||||
|
$HEADER['STYLESHEET'] = $ADMIN_STYLESHEET ?? ADMIN_STYLESHEET;
|
||||||
|
|
||||||
|
if ($form->my_page_name == 'edit_order') {
|
||||||
|
// get is for "table_name" and "where" only
|
||||||
|
$table_name = $_GET['table_name'] ?? '';
|
||||||
|
// $where = $_GET['where'] ?? '';
|
||||||
|
// order name is _always_ order_number for the edit interface
|
||||||
|
|
||||||
|
// follwing arrays do exist here:
|
||||||
|
// $position ... has the positions of the [0..max], cause in a <select>
|
||||||
|
// I can't put an number into the array field, in this array,
|
||||||
|
// there are the POSITION stored, that should CHANGE there order (up/down)
|
||||||
|
// $row_data_id ... has ALL ids from the sorting part
|
||||||
|
// $row_data_order ... has ALL order positions from the soirting part
|
||||||
|
if (!isset($position)) {
|
||||||
|
$position = [];
|
||||||
|
}
|
||||||
|
$row_data_id = $_POST['row_data_id'] ?? [];
|
||||||
|
$original_id = $row_data_id;
|
||||||
|
if (count($position)) {
|
||||||
|
$row_data_order = $_POST['row_data_order'];
|
||||||
|
|
||||||
|
// FIRST u have to put right sort, then read again ...
|
||||||
|
// hast to be >0 or the first one is selected and then there is no move
|
||||||
|
if (isset($up) && isset($position[0]) && $position[0] > 0) {
|
||||||
|
for ($i = 0; $i < count($position); $i++) {
|
||||||
|
// change position order
|
||||||
|
// this gets temp, id before that, gets actual (moves one "down")
|
||||||
|
// this gets the old before (moves one "up")
|
||||||
|
// is done for every element in row
|
||||||
|
// echo "A: ".$row_data_id[$position[$i]]
|
||||||
|
// ." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]
|
||||||
|
// ." (".$row_data_order[$position[$i]-1].")<br>";
|
||||||
|
$temp_id = $row_data_id[$position[$i]] ?? null;
|
||||||
|
$row_data_id[$position[$i]] = $row_data_id[$position[$i] - 1] ?? null;
|
||||||
|
$row_data_id[$position[$i] - 1] = $temp_id;
|
||||||
|
// echo "A: ".$row_data_id[$position[$i]]
|
||||||
|
// ." (".$row_data_order[$position[$i]].") -- "
|
||||||
|
// .$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||||
|
} // for
|
||||||
|
} // if up
|
||||||
|
|
||||||
|
// the last position id from position array is not to be the count - 1 of
|
||||||
|
// row_data_id array, or it is the last element
|
||||||
|
if (isset($down) && ($position[count($position) - 1] != (count($row_data_id) - 1))) {
|
||||||
|
for ($i = count($position) - 1; $i >= 0; $i--) {
|
||||||
|
// same as up, just up in other way, starts from bottom (last element) and moves "up"
|
||||||
|
// element before actuel gets temp, this element, becomes element after this,
|
||||||
|
// element after this, gets this
|
||||||
|
$temp_id = $row_data_id[$position[$i] + 1] ?? null;
|
||||||
|
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]] ?? null;
|
||||||
|
$row_data_id[$position[$i]] = $temp_id;
|
||||||
|
} // for
|
||||||
|
} // if down
|
||||||
|
|
||||||
|
// write data ... (which has to be abstrackt ...)
|
||||||
|
if (
|
||||||
|
(isset($up) && $position[0] > 0) ||
|
||||||
|
(isset($down) && ($position[count($position) - 1] != (count($row_data_id) - 1)))
|
||||||
|
) {
|
||||||
|
for ($i = 0; $i < count($row_data_id); $i++) {
|
||||||
|
if (isset($row_data_order[$i]) && isset($row_data_id[$i])) {
|
||||||
|
$q = "UPDATE " . $table_name
|
||||||
|
. " SET order_number = " . $row_data_order[$i]
|
||||||
|
. " WHERE " . $table_name . "_id = " . $row_data_id[$i];
|
||||||
|
$q = $form->dbExec($q);
|
||||||
|
}
|
||||||
|
} // for all article ids ...
|
||||||
|
} // if write
|
||||||
|
} // if there is something to move
|
||||||
|
|
||||||
|
// get ...
|
||||||
|
$q = "SELECT " . $table_name . "_id, name, order_number FROM " . $table_name . " ";
|
||||||
|
if (!empty($where_string)) {
|
||||||
|
$q .= "WHERE $where_string ";
|
||||||
|
}
|
||||||
|
$q .= "ORDER BY order_number";
|
||||||
|
|
||||||
|
// init arrays
|
||||||
|
$row_data = [];
|
||||||
|
$options_id = [];
|
||||||
|
$options_name = [];
|
||||||
|
$options_selected = [];
|
||||||
|
// DB read data for menu
|
||||||
|
while (is_array($res = $form->dbReturn($q))) {
|
||||||
|
$row_data[] = [
|
||||||
|
"id" => $res[$table_name . "_id"],
|
||||||
|
"name" => $res["name"],
|
||||||
|
"order" => $res["order_number"]
|
||||||
|
];
|
||||||
|
} // while read data ...
|
||||||
|
|
||||||
|
// html title
|
||||||
|
$HEADER['HTML_TITLE'] = $form->l->__('Edit Order');
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
// error msg
|
||||||
|
if (isset($error)) {
|
||||||
|
if (!isset($msg)) {
|
||||||
|
$msg = [];
|
||||||
|
}
|
||||||
|
$messages[] = [
|
||||||
|
'msg' => $msg,
|
||||||
|
'class' => 'error',
|
||||||
|
'width' => '100%'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$DATA['form_error_msg'] = $messages;
|
||||||
|
|
||||||
|
// all the row data
|
||||||
|
for ($i = 0; $i < count($row_data); $i++) {
|
||||||
|
$options_id[] = $i;
|
||||||
|
$options_name[] = $row_data[$i]['name'];
|
||||||
|
// list of points to order
|
||||||
|
for ($j = 0; $j < count($position); $j++) {
|
||||||
|
// if matches, put into select array
|
||||||
|
if (
|
||||||
|
isset($original_id[$position[$j]]) && isset($row_data[$i]['id']) &&
|
||||||
|
$original_id[$position[$j]] == $row_data[$i]['id']
|
||||||
|
) {
|
||||||
|
$options_selected[] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$DATA['options_id'] = $options_id;
|
||||||
|
$DATA['options_name'] = $options_name;
|
||||||
|
$DATA['options_selected'] = $options_selected;
|
||||||
|
|
||||||
|
// hidden list for the data (id, order number)
|
||||||
|
$row_data_id = [];
|
||||||
|
$row_data_order = [];
|
||||||
|
for ($i = 0; $i < count($row_data); $i++) {
|
||||||
|
$row_data_id[] = $row_data[$i]['id'];
|
||||||
|
$row_data_order[] = $row_data[$i]['order'];
|
||||||
|
}
|
||||||
|
$DATA['row_data_id'] = $row_data_id;
|
||||||
|
$DATA['row_data_order'] = $row_data_order;
|
||||||
|
|
||||||
|
// hidden names for the table & where string
|
||||||
|
$DATA['table_name'] = $table_name;
|
||||||
|
$DATA['where_string'] = $where_string ?? '';
|
||||||
|
|
||||||
|
$EDIT_TEMPLATE = 'edit_order.tpl';
|
||||||
|
} else {
|
||||||
|
// load call only if id is set
|
||||||
|
if (isset(${$form->archive_pk_name})) {
|
||||||
|
$form->formProcedureLoad(${$form->archive_pk_name});
|
||||||
|
}
|
||||||
|
$form->formProcedureNew();
|
||||||
|
$form->formProcedureSave();
|
||||||
|
$form->formProcedureDelete();
|
||||||
|
// delete call only if those two are set
|
||||||
|
if (isset($element_list) && isset($remove_name)) {
|
||||||
|
$form->formProcedureDeleteFromElementList($element_list, $remove_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$DATA['table_width'] = $table_width;
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
// write out error / status messages
|
||||||
|
$messages[] = $form->formPrintMsg();
|
||||||
|
$DATA['form_error_msg'] = $messages;
|
||||||
|
|
||||||
|
// MENU START
|
||||||
|
// request some session vars
|
||||||
|
if (!isset($HEADER_COLOR)) {
|
||||||
|
$DATA['HEADER_COLOR'] = '#E0E2FF';
|
||||||
|
} else {
|
||||||
|
$DATA['HEADER_COLOR'] = $_SESSION['HEADER_COLOR'];
|
||||||
|
}
|
||||||
|
$DATA['USER_NAME'] = $_SESSION['USER_NAME'];
|
||||||
|
$DATA['EUID'] = $_SESSION['EUID'];
|
||||||
|
$DATA['GROUP_NAME'] = $_SESSION['GROUP_NAME'];
|
||||||
|
$DATA['GROUP_LEVEL'] = $_SESSION['GROUP_ACL_LEVEL'];
|
||||||
|
$PAGES = $_SESSION['PAGES'];
|
||||||
|
|
||||||
|
//$form->log->debug('menu', $form->log->prAr($PAGES));
|
||||||
|
|
||||||
|
// build nav from $PAGES ...
|
||||||
|
if (!isset($PAGES) || !is_array($PAGES)) {
|
||||||
|
$PAGES = [];
|
||||||
|
}
|
||||||
|
$menuarray = [];
|
||||||
|
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
|
||||||
|
if ($PAGE_DATA['menu'] && $PAGE_DATA['online']) {
|
||||||
|
$menuarray[] = $PAGE_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// split point for nav points
|
||||||
|
$COUNT_NAV_POINTS = count($menuarray);
|
||||||
|
$SPLIT_FACTOR = 3;
|
||||||
|
$START_SPLIT_COUNT = 3;
|
||||||
|
// WTF ?? I dunno what I am doing here ...
|
||||||
|
for ($i = 9; $i < $COUNT_NAV_POINTS; $i += $START_SPLIT_COUNT) {
|
||||||
|
if ($COUNT_NAV_POINTS > $i) {
|
||||||
|
$SPLIT_FACTOR += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$position = 0;
|
||||||
|
$menu_data = [];
|
||||||
|
// for ($i = 1; $i <= count($menuarray); $i ++) {
|
||||||
|
foreach ($menuarray as $i => $data) {
|
||||||
|
// do that for new array
|
||||||
|
$j = $i + 1;
|
||||||
|
$menu_data[$i]['pagename'] = htmlentities($data['page_name']);
|
||||||
|
$menu_data[$i]['filename'] =
|
||||||
|
// prefix folder or host name
|
||||||
|
(isset($data['hostname']) && $data['hostname'] ?
|
||||||
|
$data['hostname'] :
|
||||||
|
''
|
||||||
|
)
|
||||||
|
// filename
|
||||||
|
. ($data['filename'] ?? '')
|
||||||
|
// query string
|
||||||
|
. (isset($data['query_string']) && $data['query_string'] ?
|
||||||
|
$data['query_string'] :
|
||||||
|
''
|
||||||
|
);
|
||||||
|
if ($j == 1 || !($i % $SPLIT_FACTOR)) {
|
||||||
|
$menu_data[$i]['splitfactor_in'] = 1;
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['splitfactor_in'] = 0;
|
||||||
|
}
|
||||||
|
// on matching, we also need to check if we are in the same folder
|
||||||
|
if (
|
||||||
|
isset($data['filename']) &&
|
||||||
|
$data['filename'] == \CoreLibs\Get\System::getPageName() &&
|
||||||
|
(!isset($data['hostname']) || (
|
||||||
|
isset($data['hostname']) &&
|
||||||
|
(!$data['hostname'] || strstr($data['hostname'], CONTENT_PATH) !== false)
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
$position = $i;
|
||||||
|
$menu_data[$i]['position'] = 1;
|
||||||
|
$menu_data[$i]['popup'] = 0;
|
||||||
|
} else {
|
||||||
|
// add query stuff
|
||||||
|
// HAS TO DONE LATER ... set urlencode, etc ...
|
||||||
|
// check if popup needed
|
||||||
|
if (isset($data['popup']) && $data['popup'] == 1) {
|
||||||
|
$menu_data[$i]['popup'] = 1;
|
||||||
|
$menu_data[$i]['rand'] = uniqid((string)rand());
|
||||||
|
$menu_data[$i]['width'] = $data['popup_x'];
|
||||||
|
$menu_data[$i]['height'] = $data['popup_y'];
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['popup'] = 0;
|
||||||
|
}
|
||||||
|
$menu_data[$i]['position'] = 0;
|
||||||
|
} // highlight or not
|
||||||
|
if (!($j % $SPLIT_FACTOR) || (($j + 1) > count($menuarray))) {
|
||||||
|
$menu_data[$i]['splitfactor_out'] = 1;
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['splitfactor_out'] = 0;
|
||||||
|
}
|
||||||
|
} // for
|
||||||
|
// $form->log->debug('MENU ARRAY', $form->log->prAr($menu_data));
|
||||||
|
$DATA['menu_data'] = $menu_data;
|
||||||
|
$DATA['page_name'] = $menuarray[$position]['page_name'] ?? '-Undefined [' . $position . '] -';
|
||||||
|
$L_TITLE = $DATA['page_name'];
|
||||||
|
// html title
|
||||||
|
$HEADER['HTML_TITLE'] = $form->l->__($L_TITLE);
|
||||||
|
// END MENU
|
||||||
|
// LOAD AND NEW
|
||||||
|
$DATA['load'] = $form->formCreateLoad();
|
||||||
|
$DATA['new'] = $form->formCreateNew();
|
||||||
|
// SHOW DATA PART
|
||||||
|
if ($form->yes) {
|
||||||
|
$DATA['form_yes'] = $form->yes;
|
||||||
|
$DATA['form_my_page_name'] = $form->my_page_name;
|
||||||
|
$DATA['filename_exist'] = 0;
|
||||||
|
$DATA['drop_down_input'] = 0;
|
||||||
|
$elements = [];
|
||||||
|
// depending on the "getPageName()" I show different stuff
|
||||||
|
switch ($form->my_page_name) {
|
||||||
|
case 'edit_users':
|
||||||
|
$elements[] = $form->formCreateElement('login_error_count');
|
||||||
|
$elements[] = $form->formCreateElement('login_error_date_last');
|
||||||
|
$elements[] = $form->formCreateElement('login_error_date_first');
|
||||||
|
$elements[] = $form->formCreateElement('enabled');
|
||||||
|
$elements[] = $form->formCreateElement('deleted');
|
||||||
|
$elements[] = $form->formCreateElement('protected');
|
||||||
|
$elements[] = $form->formCreateElement('username');
|
||||||
|
$elements[] = $form->formCreateElement('password');
|
||||||
|
$elements[] = $form->formCreateElement('password_change_interval');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_set_date');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_last_revalidate');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_locked');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_revalidate_after');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_valid_from');
|
||||||
|
$elements[] = $form->formCreateElement('login_user_id_valid_until');
|
||||||
|
$elements[] = $form->formCreateElement('email');
|
||||||
|
$elements[] = $form->formCreateElement('last_name');
|
||||||
|
$elements[] = $form->formCreateElement('first_name');
|
||||||
|
$elements[] = $form->formCreateElement('edit_group_id');
|
||||||
|
$elements[] = $form->formCreateElement('edit_access_right_id');
|
||||||
|
$elements[] = $form->formCreateElement('strict');
|
||||||
|
$elements[] = $form->formCreateElement('locked');
|
||||||
|
$elements[] = $form->formCreateElement('lock_until');
|
||||||
|
$elements[] = $form->formCreateElement('lock_after');
|
||||||
|
$elements[] = $form->formCreateElement('admin');
|
||||||
|
$elements[] = $form->formCreateElement('debug');
|
||||||
|
$elements[] = $form->formCreateElement('db_debug');
|
||||||
|
$elements[] = $form->formCreateElement('edit_language_id');
|
||||||
|
$elements[] = $form->formCreateElement('edit_scheme_id');
|
||||||
|
$elements[] = $form->formCreateElementListTable('edit_access_user');
|
||||||
|
$elements[] = $form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
case 'edit_schemes':
|
||||||
|
$elements[] = $form->formCreateElement('enabled');
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
$elements[] = $form->formCreateElement('header_color');
|
||||||
|
$elements[] = $form->formCreateElement('template');
|
||||||
|
break;
|
||||||
|
case 'edit_pages':
|
||||||
|
if (!isset($form->table_array['edit_page_id']['value'])) {
|
||||||
|
$q = "DELETE FROM temp_files";
|
||||||
|
$form->dbExec($q);
|
||||||
|
// gets all files in the current dir and dirs given ending with .php
|
||||||
|
$folders = ['../admin/', '../frontend/'];
|
||||||
|
$files = ['*.php'];
|
||||||
|
$search_glob = [];
|
||||||
|
foreach ($folders as $folder) {
|
||||||
|
// make sure this folder actually exists
|
||||||
|
if (is_dir(ROOT . $folder)) {
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$search_glob[] = $folder . $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$crap = exec('ls ' . join(' ', $search_glob), $output, $status);
|
||||||
|
// now get all that are NOT in de DB
|
||||||
|
$q = "INSERT INTO temp_files (folder, filename) VALUES ";
|
||||||
|
$t_q = '';
|
||||||
|
foreach ($output as $output_file) {
|
||||||
|
// split the ouput into folder and file
|
||||||
|
$pathinfo = pathinfo($output_file);
|
||||||
|
if (!empty($pathinfo['dirname'])) {
|
||||||
|
$pathinfo['dirname'] .= DIRECTORY_SEPARATOR;
|
||||||
|
} else {
|
||||||
|
$pathinfo['dirname'] = '';
|
||||||
|
}
|
||||||
|
if ($t_q) {
|
||||||
|
$t_q .= ', ';
|
||||||
|
}
|
||||||
|
$t_q .= "('" . $form->dbEscapeString($pathinfo['dirname']) . "', '"
|
||||||
|
. $form->dbEscapeString($pathinfo['basename']) . "')";
|
||||||
|
}
|
||||||
|
$form->dbExec($q . $t_q, 'NULL');
|
||||||
|
$elements[] = $form->formCreateElement('filename');
|
||||||
|
} else {
|
||||||
|
// show file menu
|
||||||
|
// just show name of file ...
|
||||||
|
$DATA['filename_exist'] = 1;
|
||||||
|
$DATA['filename'] = $form->table_array['filename']['value'];
|
||||||
|
} // File Name View IF
|
||||||
|
$elements[] = $form->formCreateElement('hostname');
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
// $elements[] = $form->formCreateElement('tag');
|
||||||
|
// $elements[] = $form->formCreateElement('min_acl');
|
||||||
|
$elements[] = $form->formCreateElement('order_number');
|
||||||
|
$elements[] = $form->formCreateElement('online');
|
||||||
|
$elements[] = $form->formCreateElement('menu');
|
||||||
|
$elements[] = $form->formCreateElementListTable('edit_query_string');
|
||||||
|
$elements[] = $form->formCreateElement('content_alias_edit_page_id');
|
||||||
|
$elements[] = $form->formCreateElementListTable('edit_page_content');
|
||||||
|
$elements[] = $form->formCreateElement('popup');
|
||||||
|
$elements[] = $form->formCreateElement('popup_x');
|
||||||
|
$elements[] = $form->formCreateElement('popup_y');
|
||||||
|
$elements[] = $form->formCreateElementReferenceTable('edit_visible_group');
|
||||||
|
$elements[] = $form->formCreateElementReferenceTable('edit_menu_group');
|
||||||
|
break;
|
||||||
|
case 'edit_languages':
|
||||||
|
$elements[] = $form->formCreateElement('enabled');
|
||||||
|
$elements[] = $form->formCreateElement('short_name');
|
||||||
|
$elements[] = $form->formCreateElement('long_name');
|
||||||
|
$elements[] = $form->formCreateElement('iso_name');
|
||||||
|
break;
|
||||||
|
case 'edit_groups':
|
||||||
|
$elements[] = $form->formCreateElement('enabled');
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
$elements[] = $form->formCreateElement('edit_access_right_id');
|
||||||
|
$elements[] = $form->formCreateElement('edit_scheme_id');
|
||||||
|
$elements[] = $form->formCreateElementListTable('edit_page_access');
|
||||||
|
$elements[] = $form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
case 'edit_visible_group':
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
$elements[] = $form->formCreateElement('flag');
|
||||||
|
break;
|
||||||
|
case 'edit_menu_group':
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
$elements[] = $form->formCreateElement('flag');
|
||||||
|
$elements[] = $form->formCreateElement('order_number');
|
||||||
|
break;
|
||||||
|
case 'edit_access':
|
||||||
|
$elements[] = $form->formCreateElement('name');
|
||||||
|
$elements[] = $form->formCreateElement('enabled');
|
||||||
|
$elements[] = $form->formCreateElement('protected');
|
||||||
|
$elements[] = $form->formCreateElement('color');
|
||||||
|
$elements[] = $form->formCreateElement('description');
|
||||||
|
// add name/value list here
|
||||||
|
$elements[] = $form->formCreateElementListTable('edit_access_data');
|
||||||
|
$elements[] = $form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print '[No valid page definition given]';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// $form->log->debug('edit', "Elements: <pre>".$form->log->prAr($elements));
|
||||||
|
$DATA['elements'] = $elements;
|
||||||
|
$DATA['hidden'] = $form->formCreateHiddenFields();
|
||||||
|
$DATA['save_delete'] = $form->formCreateSaveDelete();
|
||||||
|
} else {
|
||||||
|
$DATA['form_yes'] = 0;
|
||||||
|
}
|
||||||
|
$EDIT_TEMPLATE = 'edit_body.tpl';
|
||||||
|
}
|
||||||
|
|
||||||
|
// debug data, if DEBUG flag is on, this data is print out
|
||||||
|
$DEBUG_DATA['DEBUG'] = $DEBUG_TMPL ?? '';
|
||||||
|
|
||||||
|
// create main data array
|
||||||
|
$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
|
||||||
|
// data is 1:1 mapping (all vars, values, etc)
|
||||||
|
foreach ($CONTENT_DATA as $key => $value) {
|
||||||
|
$smarty->assign($key, $value);
|
||||||
|
}
|
||||||
|
if (is_dir(BASE . TEMPLATES_C)) {
|
||||||
|
$smarty->setCompileDir(BASE . TEMPLATES_C);
|
||||||
|
}
|
||||||
|
if (is_dir(BASE . CACHE)) {
|
||||||
|
$smarty->setCacheDir(BASE . CACHE);
|
||||||
|
}
|
||||||
|
$smarty->display($EDIT_TEMPLATE, 'editAdmin_' . $smarty->lang, 'editAdmin_' . $smarty->lang);
|
||||||
|
|
||||||
|
$form->log->debug('DEBUGEND', '==================================== [Form END]');
|
||||||
|
// debug output
|
||||||
|
echo $login->log->printErrorMsg();
|
||||||
|
echo $form->log->printErrorMsg();
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -23,23 +23,8 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
$DEBUG_ALL = true;
|
|
||||||
$PRINT_ALL = true;
|
|
||||||
$ECHO_ALL = false;
|
|
||||||
$DB_DEBUG = true;
|
|
||||||
|
|
||||||
// TODO: only extract _POST data that is needed
|
|
||||||
extract($_POST, EXTR_SKIP);
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// overrride debug flags
|
|
||||||
if (!DEBUG) {
|
|
||||||
$DEBUG_ALL = false;
|
|
||||||
$PRINT_ALL = false;
|
|
||||||
$DB_DEBUG = false;
|
|
||||||
$ECHO_ALL = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// should be utf8
|
// should be utf8
|
||||||
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
||||||
@@ -51,14 +36,16 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
'file_id' => LOG_FILE_ID . 'EditBase',
|
'file_id' => LOG_FILE_ID . 'EditBase',
|
||||||
'print_file_date' => true,
|
'print_file_date' => true,
|
||||||
'per_class' => true,
|
'per_class' => true,
|
||||||
'debug_all' => $DEBUG_ALL,
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
'echo_all' => $ECHO_ALL,
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
'print_all' => $PRINT_ALL,
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
]);
|
]);
|
||||||
// db connection
|
// db connection
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
// login page
|
// login page
|
||||||
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
|
// space for setting special debug flags
|
||||||
|
// $login->log->setLogLevelAll('debug', true);
|
||||||
// lang, path, domain
|
// lang, path, domain
|
||||||
// pre auto detect language after login
|
// pre auto detect language after login
|
||||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
@@ -70,494 +57,14 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
);
|
);
|
||||||
// flush and start
|
// flush and start
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
// turn off set log per class
|
|
||||||
$log->setLogPer('class', false);
|
|
||||||
// create form class
|
|
||||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log, $l10n, $locale);
|
|
||||||
if ($form->mobile_phone) {
|
|
||||||
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// smarty template engine (extended Translation version)
|
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
|
||||||
|
|
||||||
// $form->log->debug('POST', $form->log->prAr($_POST));
|
// FIXME: only extract _POST data that is needed
|
||||||
|
// FIXME: update table_arrays reader to use other than $_GLOBALS
|
||||||
|
extract($_POST, EXTR_SKIP);
|
||||||
|
|
||||||
if (TARGET == 'live' || TARGET == 'remote') {
|
// init smarty and form class
|
||||||
// login
|
$edit_base = new CoreLibs\Admin\EditBase(DB_CONFIG, $log, $l10n, $locale);
|
||||||
$login->log->setLogLevelAll('debug', DEBUG ? true : false);
|
// creates edit pages and runs actions
|
||||||
$login->log->setLogLevelAll('echo', false);
|
$edit_base->editBaseRun();
|
||||||
$login->log->setLogLevelAll('print', DEBUG ? true : false);
|
|
||||||
// form
|
|
||||||
$form->log->setLogLevelAll('debug', DEBUG ? true : false);
|
|
||||||
$form->log->setLogLevelAll('echo', false);
|
|
||||||
$form->log->setLogLevelAll('print', DEBUG ? true : false);
|
|
||||||
}
|
|
||||||
// space for setting special debug flags
|
|
||||||
$login->log->setLogLevelAll('debug', true);
|
|
||||||
// set smarty arrays
|
|
||||||
$HEADER = [];
|
|
||||||
$DATA = [];
|
|
||||||
$DEBUG_DATA = [];
|
|
||||||
// set the template dir
|
|
||||||
// WARNING: this has a special check for the mailing tool layout (old layout)
|
|
||||||
if (defined('LAYOUT')) {
|
|
||||||
$smarty->setTemplateDir(BASE . INCLUDES . TEMPLATES . CONTENT_PATH);
|
|
||||||
$DATA['css'] = LAYOUT . CSS;
|
|
||||||
$DATA['js'] = LAYOUT . JS;
|
|
||||||
} else {
|
|
||||||
$smarty->setTemplateDir(TEMPLATES);
|
|
||||||
$DATA['css'] = CSS;
|
|
||||||
$DATA['js'] = JS;
|
|
||||||
}
|
|
||||||
// set table width
|
|
||||||
$table_width = '100%';
|
|
||||||
$ADMIN_STYLESHEET = 'edit.css';
|
|
||||||
// define all needed smarty stuff for the general HTML/page building
|
|
||||||
$HEADER['CSS'] = CSS;
|
|
||||||
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
|
||||||
/** @phpstan-ignore-next-line because ADMIN_STYLESHEET can be null */
|
|
||||||
$HEADER['STYLESHEET'] = $ADMIN_STYLESHEET ?? ADMIN_STYLESHEET;
|
|
||||||
|
|
||||||
if ($form->my_page_name == 'edit_order') {
|
|
||||||
// get is for "table_name" and "where" only
|
|
||||||
$table_name = $_GET['table_name'] ?? '';
|
|
||||||
// $where = $_GET['where'] ?? '';
|
|
||||||
// order name is _always_ order_number for the edit interface
|
|
||||||
|
|
||||||
// follwing arrays do exist here:
|
|
||||||
// $position ... has the positions of the [0..max], cause in a <select>
|
|
||||||
// I can't put an number into the array field, in this array,
|
|
||||||
// there are the POSITION stored, that should CHANGE there order (up/down)
|
|
||||||
// $row_data_id ... has ALL ids from the sorting part
|
|
||||||
// $row_data_order ... has ALL order positions from the soirting part
|
|
||||||
if (!isset($position)) {
|
|
||||||
$position = [];
|
|
||||||
}
|
|
||||||
$row_data_id = $_POST['row_data_id'] ?? [];
|
|
||||||
$original_id = $row_data_id;
|
|
||||||
if (count($position)) {
|
|
||||||
$row_data_order = $_POST['row_data_order'];
|
|
||||||
|
|
||||||
// FIRST u have to put right sort, then read again ...
|
|
||||||
// hast to be >0 or the first one is selected and then there is no move
|
|
||||||
if (isset($up) && isset($position[0]) && $position[0] > 0) {
|
|
||||||
for ($i = 0; $i < count($position); $i++) {
|
|
||||||
// change position order
|
|
||||||
// this gets temp, id before that, gets actual (moves one "down")
|
|
||||||
// this gets the old before (moves one "up")
|
|
||||||
// is done for every element in row
|
|
||||||
// echo "A: ".$row_data_id[$position[$i]]
|
|
||||||
// ." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]
|
|
||||||
// ." (".$row_data_order[$position[$i]-1].")<br>";
|
|
||||||
$temp_id = $row_data_id[$position[$i]] ?? null;
|
|
||||||
$row_data_id[$position[$i]] = $row_data_id[$position[$i] - 1] ?? null;
|
|
||||||
$row_data_id[$position[$i] - 1] = $temp_id;
|
|
||||||
// echo "A: ".$row_data_id[$position[$i]]
|
|
||||||
// ." (".$row_data_order[$position[$i]].") -- "
|
|
||||||
// .$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
|
||||||
} // for
|
|
||||||
} // if up
|
|
||||||
|
|
||||||
// the last position id from position array is not to be the count - 1 of
|
|
||||||
// row_data_id array, or it is the last element
|
|
||||||
if (isset($down) && ($position[count($position) - 1] != (count($row_data_id) - 1))) {
|
|
||||||
for ($i = count($position) - 1; $i >= 0; $i--) {
|
|
||||||
// same as up, just up in other way, starts from bottom (last element) and moves "up"
|
|
||||||
// element before actuel gets temp, this element, becomes element after this,
|
|
||||||
// element after this, gets this
|
|
||||||
$temp_id = $row_data_id[$position[$i] + 1] ?? null;
|
|
||||||
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]] ?? null;
|
|
||||||
$row_data_id[$position[$i]] = $temp_id;
|
|
||||||
} // for
|
|
||||||
} // if down
|
|
||||||
|
|
||||||
// write data ... (which has to be abstrackt ...)
|
|
||||||
if (
|
|
||||||
(isset($up) && $position[0] > 0) ||
|
|
||||||
(isset($down) && ($position[count($position) - 1] != (count($row_data_id) - 1)))
|
|
||||||
) {
|
|
||||||
for ($i = 0; $i < count($row_data_id); $i++) {
|
|
||||||
if (isset($row_data_order[$i]) && isset($row_data_id[$i])) {
|
|
||||||
$q = "UPDATE " . $table_name
|
|
||||||
. " SET order_number = " . $row_data_order[$i]
|
|
||||||
. " WHERE " . $table_name . "_id = " . $row_data_id[$i];
|
|
||||||
$q = $form->dbExec($q);
|
|
||||||
}
|
|
||||||
} // for all article ids ...
|
|
||||||
} // if write
|
|
||||||
} // if there is something to move
|
|
||||||
|
|
||||||
// get ...
|
|
||||||
$q = "SELECT " . $table_name . "_id, name, order_number FROM " . $table_name . " ";
|
|
||||||
if (!empty($where_string)) {
|
|
||||||
$q .= "WHERE $where_string ";
|
|
||||||
}
|
|
||||||
$q .= "ORDER BY order_number";
|
|
||||||
|
|
||||||
// init arrays
|
|
||||||
$row_data = [];
|
|
||||||
$options_id = [];
|
|
||||||
$options_name = [];
|
|
||||||
$options_selected = [];
|
|
||||||
// DB read data for menu
|
|
||||||
while (is_array($res = $form->dbReturn($q))) {
|
|
||||||
$row_data[] = [
|
|
||||||
"id" => $res[$table_name . "_id"],
|
|
||||||
"name" => $res["name"],
|
|
||||||
"order" => $res["order_number"]
|
|
||||||
];
|
|
||||||
} // while read data ...
|
|
||||||
|
|
||||||
// html title
|
|
||||||
$HEADER['HTML_TITLE'] = $form->l->__('Edit Order');
|
|
||||||
|
|
||||||
$messages = [];
|
|
||||||
// error msg
|
|
||||||
if (isset($error)) {
|
|
||||||
if (!isset($msg)) {
|
|
||||||
$msg = [];
|
|
||||||
}
|
|
||||||
$messages[] = [
|
|
||||||
'msg' => $msg,
|
|
||||||
'class' => 'error',
|
|
||||||
'width' => '100%'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$DATA['form_error_msg'] = $messages;
|
|
||||||
|
|
||||||
// all the row data
|
|
||||||
for ($i = 0; $i < count($row_data); $i++) {
|
|
||||||
$options_id[] = $i;
|
|
||||||
$options_name[] = $row_data[$i]['name'];
|
|
||||||
// list of points to order
|
|
||||||
for ($j = 0; $j < count($position); $j++) {
|
|
||||||
// if matches, put into select array
|
|
||||||
if (
|
|
||||||
isset($original_id[$position[$j]]) && isset($row_data[$i]['id']) &&
|
|
||||||
$original_id[$position[$j]] == $row_data[$i]['id']
|
|
||||||
) {
|
|
||||||
$options_selected[] = $i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$DATA['options_id'] = $options_id;
|
|
||||||
$DATA['options_name'] = $options_name;
|
|
||||||
$DATA['options_selected'] = $options_selected;
|
|
||||||
|
|
||||||
// hidden list for the data (id, order number)
|
|
||||||
$row_data_id = [];
|
|
||||||
$row_data_order = [];
|
|
||||||
for ($i = 0; $i < count($row_data); $i++) {
|
|
||||||
$row_data_id[] = $row_data[$i]['id'];
|
|
||||||
$row_data_order[] = $row_data[$i]['order'];
|
|
||||||
}
|
|
||||||
$DATA['row_data_id'] = $row_data_id;
|
|
||||||
$DATA['row_data_order'] = $row_data_order;
|
|
||||||
|
|
||||||
// hidden names for the table & where string
|
|
||||||
$DATA['table_name'] = $table_name;
|
|
||||||
$DATA['where_string'] = $where_string ?? '';
|
|
||||||
|
|
||||||
$EDIT_TEMPLATE = 'edit_order.tpl';
|
|
||||||
} else {
|
|
||||||
// load call only if id is set
|
|
||||||
if (isset(${$form->archive_pk_name})) {
|
|
||||||
$form->formProcedureLoad(${$form->archive_pk_name});
|
|
||||||
}
|
|
||||||
$form->formProcedureNew();
|
|
||||||
$form->formProcedureSave();
|
|
||||||
$form->formProcedureDelete();
|
|
||||||
// delete call only if those two are set
|
|
||||||
if (isset($element_list) && isset($remove_name)) {
|
|
||||||
$form->formProcedureDeleteFromElementList($element_list, $remove_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$DATA['table_width'] = $table_width;
|
|
||||||
|
|
||||||
$messages = [];
|
|
||||||
// write out error / status messages
|
|
||||||
$messages[] = $form->formPrintMsg();
|
|
||||||
$DATA['form_error_msg'] = $messages;
|
|
||||||
|
|
||||||
// MENU START
|
|
||||||
// request some session vars
|
|
||||||
if (!isset($HEADER_COLOR)) {
|
|
||||||
$DATA['HEADER_COLOR'] = '#E0E2FF';
|
|
||||||
} else {
|
|
||||||
$DATA['HEADER_COLOR'] = $_SESSION['HEADER_COLOR'];
|
|
||||||
}
|
|
||||||
$DATA['USER_NAME'] = $_SESSION['USER_NAME'];
|
|
||||||
$DATA['EUID'] = $_SESSION['EUID'];
|
|
||||||
$DATA['GROUP_NAME'] = $_SESSION['GROUP_NAME'];
|
|
||||||
$DATA['GROUP_LEVEL'] = $_SESSION['GROUP_ACL_LEVEL'];
|
|
||||||
$PAGES = $_SESSION['PAGES'];
|
|
||||||
|
|
||||||
//$form->log->debug('menu', $form->log->prAr($PAGES));
|
|
||||||
|
|
||||||
// build nav from $PAGES ...
|
|
||||||
if (!isset($PAGES) || !is_array($PAGES)) {
|
|
||||||
$PAGES = [];
|
|
||||||
}
|
|
||||||
$menuarray = [];
|
|
||||||
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
|
|
||||||
if ($PAGE_DATA['menu'] && $PAGE_DATA['online']) {
|
|
||||||
$menuarray[] = $PAGE_DATA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// split point for nav points
|
|
||||||
$COUNT_NAV_POINTS = count($menuarray);
|
|
||||||
$SPLIT_FACTOR = 3;
|
|
||||||
$START_SPLIT_COUNT = 3;
|
|
||||||
// WTF ?? I dunno what I am doing here ...
|
|
||||||
for ($i = 9; $i < $COUNT_NAV_POINTS; $i += $START_SPLIT_COUNT) {
|
|
||||||
if ($COUNT_NAV_POINTS > $i) {
|
|
||||||
$SPLIT_FACTOR += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$position = 0;
|
|
||||||
$menu_data = [];
|
|
||||||
// for ($i = 1; $i <= count($menuarray); $i ++) {
|
|
||||||
foreach ($menuarray as $i => $data) {
|
|
||||||
// do that for new array
|
|
||||||
$j = $i + 1;
|
|
||||||
$menu_data[$i]['pagename'] = htmlentities($data['page_name']);
|
|
||||||
$menu_data[$i]['filename'] =
|
|
||||||
// prefix folder or host name
|
|
||||||
(isset($data['hostname']) && $data['hostname'] ?
|
|
||||||
$data['hostname'] :
|
|
||||||
''
|
|
||||||
)
|
|
||||||
// filename
|
|
||||||
. ($data['filename'] ?? '')
|
|
||||||
// query string
|
|
||||||
. (isset($data['query_string']) && $data['query_string'] ?
|
|
||||||
$data['query_string'] :
|
|
||||||
''
|
|
||||||
);
|
|
||||||
if ($j == 1 || !($i % $SPLIT_FACTOR)) {
|
|
||||||
$menu_data[$i]['splitfactor_in'] = 1;
|
|
||||||
} else {
|
|
||||||
$menu_data[$i]['splitfactor_in'] = 0;
|
|
||||||
}
|
|
||||||
// on matching, we also need to check if we are in the same folder
|
|
||||||
if (
|
|
||||||
isset($data['filename']) &&
|
|
||||||
$data['filename'] == \CoreLibs\Get\System::getPageName() &&
|
|
||||||
(!isset($data['hostname']) || (
|
|
||||||
isset($data['hostname']) &&
|
|
||||||
(!$data['hostname'] || strstr($data['hostname'], CONTENT_PATH) !== false)
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
$position = $i;
|
|
||||||
$menu_data[$i]['position'] = 1;
|
|
||||||
$menu_data[$i]['popup'] = 0;
|
|
||||||
} else {
|
|
||||||
// add query stuff
|
|
||||||
// HAS TO DONE LATER ... set urlencode, etc ...
|
|
||||||
// check if popup needed
|
|
||||||
if (isset($data['popup']) && $data['popup'] == 1) {
|
|
||||||
$menu_data[$i]['popup'] = 1;
|
|
||||||
$menu_data[$i]['rand'] = uniqid((string)rand());
|
|
||||||
$menu_data[$i]['width'] = $data['popup_x'];
|
|
||||||
$menu_data[$i]['height'] = $data['popup_y'];
|
|
||||||
} else {
|
|
||||||
$menu_data[$i]['popup'] = 0;
|
|
||||||
}
|
|
||||||
$menu_data[$i]['position'] = 0;
|
|
||||||
} // highlight or not
|
|
||||||
if (!($j % $SPLIT_FACTOR) || (($j + 1) > count($menuarray))) {
|
|
||||||
$menu_data[$i]['splitfactor_out'] = 1;
|
|
||||||
} else {
|
|
||||||
$menu_data[$i]['splitfactor_out'] = 0;
|
|
||||||
}
|
|
||||||
} // for
|
|
||||||
// $form->log->debug('MENU ARRAY', $form->log->prAr($menu_data));
|
|
||||||
$DATA['menu_data'] = $menu_data;
|
|
||||||
$DATA['page_name'] = $menuarray[$position]['page_name'] ?? '-Undefined [' . $position . '] -';
|
|
||||||
$L_TITLE = $DATA['page_name'];
|
|
||||||
// html title
|
|
||||||
$HEADER['HTML_TITLE'] = $form->l->__($L_TITLE);
|
|
||||||
// END MENU
|
|
||||||
// LOAD AND NEW
|
|
||||||
$DATA['load'] = $form->formCreateLoad();
|
|
||||||
$DATA['new'] = $form->formCreateNew();
|
|
||||||
// SHOW DATA PART
|
|
||||||
if ($form->yes) {
|
|
||||||
$DATA['form_yes'] = $form->yes;
|
|
||||||
$DATA['form_my_page_name'] = $form->my_page_name;
|
|
||||||
$DATA['filename_exist'] = 0;
|
|
||||||
$DATA['drop_down_input'] = 0;
|
|
||||||
$elements = [];
|
|
||||||
// depending on the "getPageName()" I show different stuff
|
|
||||||
switch ($form->my_page_name) {
|
|
||||||
case 'edit_users':
|
|
||||||
$elements[] = $form->formCreateElement('login_error_count');
|
|
||||||
$elements[] = $form->formCreateElement('login_error_date_last');
|
|
||||||
$elements[] = $form->formCreateElement('login_error_date_first');
|
|
||||||
$elements[] = $form->formCreateElement('enabled');
|
|
||||||
$elements[] = $form->formCreateElement('deleted');
|
|
||||||
$elements[] = $form->formCreateElement('protected');
|
|
||||||
$elements[] = $form->formCreateElement('username');
|
|
||||||
$elements[] = $form->formCreateElement('password');
|
|
||||||
$elements[] = $form->formCreateElement('password_change_interval');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_set_date');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_last_revalidate');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_locked');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_revalidate_after');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_valid_from');
|
|
||||||
$elements[] = $form->formCreateElement('login_user_id_valid_until');
|
|
||||||
$elements[] = $form->formCreateElement('email');
|
|
||||||
$elements[] = $form->formCreateElement('last_name');
|
|
||||||
$elements[] = $form->formCreateElement('first_name');
|
|
||||||
$elements[] = $form->formCreateElement('edit_group_id');
|
|
||||||
$elements[] = $form->formCreateElement('edit_access_right_id');
|
|
||||||
$elements[] = $form->formCreateElement('strict');
|
|
||||||
$elements[] = $form->formCreateElement('locked');
|
|
||||||
$elements[] = $form->formCreateElement('lock_until');
|
|
||||||
$elements[] = $form->formCreateElement('lock_after');
|
|
||||||
$elements[] = $form->formCreateElement('admin');
|
|
||||||
$elements[] = $form->formCreateElement('debug');
|
|
||||||
$elements[] = $form->formCreateElement('db_debug');
|
|
||||||
$elements[] = $form->formCreateElement('edit_language_id');
|
|
||||||
$elements[] = $form->formCreateElement('edit_scheme_id');
|
|
||||||
$elements[] = $form->formCreateElementListTable('edit_access_user');
|
|
||||||
$elements[] = $form->formCreateElement('additional_acl');
|
|
||||||
break;
|
|
||||||
case 'edit_schemes':
|
|
||||||
$elements[] = $form->formCreateElement('enabled');
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
$elements[] = $form->formCreateElement('header_color');
|
|
||||||
$elements[] = $form->formCreateElement('template');
|
|
||||||
break;
|
|
||||||
case 'edit_pages':
|
|
||||||
if (!isset($form->table_array['edit_page_id']['value'])) {
|
|
||||||
$q = "DELETE FROM temp_files";
|
|
||||||
$form->dbExec($q);
|
|
||||||
// gets all files in the current dir and dirs given ending with .php
|
|
||||||
$folders = ['../admin/', '../frontend/'];
|
|
||||||
$files = ['*.php'];
|
|
||||||
$search_glob = [];
|
|
||||||
foreach ($folders as $folder) {
|
|
||||||
// make sure this folder actually exists
|
|
||||||
if (is_dir(ROOT . $folder)) {
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$search_glob[] = $folder . $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$crap = exec('ls ' . join(' ', $search_glob), $output, $status);
|
|
||||||
// now get all that are NOT in de DB
|
|
||||||
$q = "INSERT INTO temp_files (folder, filename) VALUES ";
|
|
||||||
$t_q = '';
|
|
||||||
foreach ($output as $output_file) {
|
|
||||||
// split the ouput into folder and file
|
|
||||||
$pathinfo = pathinfo($output_file);
|
|
||||||
if (!empty($pathinfo['dirname'])) {
|
|
||||||
$pathinfo['dirname'] .= DIRECTORY_SEPARATOR;
|
|
||||||
} else {
|
|
||||||
$pathinfo['dirname'] = '';
|
|
||||||
}
|
|
||||||
if ($t_q) {
|
|
||||||
$t_q .= ', ';
|
|
||||||
}
|
|
||||||
$t_q .= "('" . $form->dbEscapeString($pathinfo['dirname']) . "', '"
|
|
||||||
. $form->dbEscapeString($pathinfo['basename']) . "')";
|
|
||||||
}
|
|
||||||
$form->dbExec($q . $t_q, 'NULL');
|
|
||||||
$elements[] = $form->formCreateElement('filename');
|
|
||||||
} else {
|
|
||||||
// show file menu
|
|
||||||
// just show name of file ...
|
|
||||||
$DATA['filename_exist'] = 1;
|
|
||||||
$DATA['filename'] = $form->table_array['filename']['value'];
|
|
||||||
} // File Name View IF
|
|
||||||
$elements[] = $form->formCreateElement('hostname');
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
// $elements[] = $form->formCreateElement('tag');
|
|
||||||
// $elements[] = $form->formCreateElement('min_acl');
|
|
||||||
$elements[] = $form->formCreateElement('order_number');
|
|
||||||
$elements[] = $form->formCreateElement('online');
|
|
||||||
$elements[] = $form->formCreateElement('menu');
|
|
||||||
$elements[] = $form->formCreateElementListTable('edit_query_string');
|
|
||||||
$elements[] = $form->formCreateElement('content_alias_edit_page_id');
|
|
||||||
$elements[] = $form->formCreateElementListTable('edit_page_content');
|
|
||||||
$elements[] = $form->formCreateElement('popup');
|
|
||||||
$elements[] = $form->formCreateElement('popup_x');
|
|
||||||
$elements[] = $form->formCreateElement('popup_y');
|
|
||||||
$elements[] = $form->formCreateElementReferenceTable('edit_visible_group');
|
|
||||||
$elements[] = $form->formCreateElementReferenceTable('edit_menu_group');
|
|
||||||
break;
|
|
||||||
case 'edit_languages':
|
|
||||||
$elements[] = $form->formCreateElement('enabled');
|
|
||||||
$elements[] = $form->formCreateElement('short_name');
|
|
||||||
$elements[] = $form->formCreateElement('long_name');
|
|
||||||
$elements[] = $form->formCreateElement('iso_name');
|
|
||||||
break;
|
|
||||||
case 'edit_groups':
|
|
||||||
$elements[] = $form->formCreateElement('enabled');
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
$elements[] = $form->formCreateElement('edit_access_right_id');
|
|
||||||
$elements[] = $form->formCreateElement('edit_scheme_id');
|
|
||||||
$elements[] = $form->formCreateElementListTable('edit_page_access');
|
|
||||||
$elements[] = $form->formCreateElement('additional_acl');
|
|
||||||
break;
|
|
||||||
case 'edit_visible_group':
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
$elements[] = $form->formCreateElement('flag');
|
|
||||||
break;
|
|
||||||
case 'edit_menu_group':
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
$elements[] = $form->formCreateElement('flag');
|
|
||||||
$elements[] = $form->formCreateElement('order_number');
|
|
||||||
break;
|
|
||||||
case 'edit_access':
|
|
||||||
$elements[] = $form->formCreateElement('name');
|
|
||||||
$elements[] = $form->formCreateElement('enabled');
|
|
||||||
$elements[] = $form->formCreateElement('protected');
|
|
||||||
$elements[] = $form->formCreateElement('color');
|
|
||||||
$elements[] = $form->formCreateElement('description');
|
|
||||||
// add name/value list here
|
|
||||||
$elements[] = $form->formCreateElementListTable('edit_access_data');
|
|
||||||
$elements[] = $form->formCreateElement('additional_acl');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
print '[No valid page definition given]';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// $form->log->debug('edit', "Elements: <pre>".$form->log->prAr($elements));
|
|
||||||
$DATA['elements'] = $elements;
|
|
||||||
$DATA['hidden'] = $form->formCreateHiddenFields();
|
|
||||||
$DATA['save_delete'] = $form->formCreateSaveDelete();
|
|
||||||
} else {
|
|
||||||
$DATA['form_yes'] = 0;
|
|
||||||
}
|
|
||||||
$EDIT_TEMPLATE = 'edit_body.tpl';
|
|
||||||
}
|
|
||||||
|
|
||||||
// debug data, if DEBUG flag is on, this data is print out
|
|
||||||
$DEBUG_DATA['DEBUG'] = $DEBUG_TMPL ?? '';
|
|
||||||
|
|
||||||
// create main data array
|
|
||||||
$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
|
|
||||||
// data is 1:1 mapping (all vars, values, etc)
|
|
||||||
foreach ($CONTENT_DATA as $key => $value) {
|
|
||||||
$smarty->assign($key, $value);
|
|
||||||
}
|
|
||||||
if (is_dir(BASE . TEMPLATES_C)) {
|
|
||||||
$smarty->setCompileDir(BASE . TEMPLATES_C);
|
|
||||||
}
|
|
||||||
if (is_dir(BASE . CACHE)) {
|
|
||||||
$smarty->setCacheDir(BASE . CACHE);
|
|
||||||
}
|
|
||||||
$smarty->display($EDIT_TEMPLATE, 'editAdmin_' . $smarty->lang, 'editAdmin_' . $smarty->lang);
|
|
||||||
|
|
||||||
$form->log->debug('DEBUGEND', '==================================== [Form END]');
|
|
||||||
// debug output
|
|
||||||
echo $login->log->printErrorMsg();
|
|
||||||
echo $form->log->printErrorMsg();
|
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
{* not yet implemented *}
|
{* not yet implemented *}
|
||||||
{/if}
|
{/if}
|
||||||
{if $element.type == 'order'}
|
{if $element.type == 'order'}
|
||||||
{* <input type="button" name="order" value="{$element.data.output_name}" OnClick="pop('order.php?col_name={$element.data.col_name}&table_name={$element.data.table_name}&where={$element.data.query}','Order','status=no,scrollbars=yes,width=700,height=500');"> *}
|
|
||||||
<input type="button" name="order" value="{$element.data.output_name}" OnClick="pop('edit_order.php?table_name={$element.data.table_name}&where={$element.data.query}','Order','status=no,scrollbars=yes,width=700,height=500');">
|
<input type="button" name="order" value="{$element.data.output_name}" OnClick="pop('edit_order.php?table_name={$element.data.table_name}&where={$element.data.query}','Order','status=no,scrollbars=yes,width=700,height=500');">
|
||||||
<input type="hidden" name="{$element.data.name}" value="{$element.data.value}">
|
<input type="hidden" name="{$element.data.name}" value="{$element.data.value}">
|
||||||
{/if}
|
{/if}
|
||||||
@@ -69,8 +68,20 @@
|
|||||||
</select>
|
</select>
|
||||||
{/if}
|
{/if}
|
||||||
{if $element.type == 'element_list'}
|
{if $element.type == 'element_list'}
|
||||||
|
<script language="JavaScript">
|
||||||
|
function deleteElement(delete_name, line_item)
|
||||||
|
{
|
||||||
|
let confirm_val = confirm('{t}Do you want to remove this entry?{/t}');
|
||||||
|
if (confirm_val === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
document.getElementById(delete_name).value = line_item;
|
||||||
|
document.getElementById(delete_name + '_flag').value = confirm_val;
|
||||||
|
document.edit_form.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{* each row of data *}
|
{* each row of data *}
|
||||||
<table width="100%" border="0">
|
<table width="100%" border="0" cellspacing="0" cellpadding="2">
|
||||||
{foreach from=$element.data.content item=line key=key}
|
{foreach from=$element.data.content item=line key=key}
|
||||||
<tr>
|
<tr>
|
||||||
{* now each line of data *}
|
{* now each line of data *}
|
||||||
@@ -107,7 +118,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{* if there is a hidden key, set delete, but only if we have a delete string *}
|
{* if there is a hidden key, set delete, but only if we have a delete string *}
|
||||||
{if $element.data.type.$line_key == 'hidden' && $line_item && $element.data.delete_name}
|
{if $element.data.type.$line_key == 'hidden' && $line_item && $element.data.delete_name}
|
||||||
<input type="submit" name="remove_button" value="{t}Delete{/t}" onClick="document.edit_form.{$element.data.delete_name}.value={$line_item};document.edit_form.{$element.data.delete_name}_flag.value=confirm('{t}Do you want to remove this entry?{/t}');document.edit_form.submit();">
|
<input type="button" name="remove_button" value="{t}Delete{/t}" onClick="deleteElement('{$element.data.delete_name}', '{$line_item}');">
|
||||||
{/if}
|
{/if}
|
||||||
{if $element.data.type.$line_key == 'hidden' && $element.data.enable_name && $element.data.delete && $element.data.output_name.$line_key}
|
{if $element.data.type.$line_key == 'hidden' && $element.data.enable_name && $element.data.delete && $element.data.output_name.$line_key}
|
||||||
<input type="checkbox" name="{$element.data.enable_name}[{$key}]" value="1" {if $line_item}checked{/if}> {$element.data.output_name.$line_key}
|
<input type="checkbox" name="{$element.data.enable_name}[{$key}]" value="1" {if $line_item}checked{/if}> {$element.data.output_name.$line_key}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
********************************************************************
|
********************************************************************
|
||||||
*}
|
*}
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{$HTML_TITLE}</title>
|
<title>{$HTML_TITLE}</title>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ body {
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
font-family: Verdana,Arial,Helvetica,sans-serif;
|
font-family: Verdana,Arial,Helvetica,sans-serif;
|
||||||
font-size : 8pt;
|
font-size : 9pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
.large {
|
.large {
|
||||||
@@ -455,4 +455,11 @@ input[type="text"]:focus, textarea:focus, select:focus {
|
|||||||
background-color: #FFDF6F;
|
background-color: #FFDF6F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td.edit_fgcolor tr:nth-child(odd) {
|
||||||
|
background-color: #e2e2c5;
|
||||||
|
}
|
||||||
|
td.edit_fgcolor tr:nth-child(even) {
|
||||||
|
background-color: #ffffcd;
|
||||||
|
}
|
||||||
|
|
||||||
/* ***************************** ADMIN EDIT INTERFACE COLORS ********************************* */
|
/* ***************************** ADMIN EDIT INTERFACE COLORS ********************************* */
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||||
(global = global || self, factory(global.ja = {}));
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ja = {}));
|
||||||
}(this, function (exports) { 'use strict';
|
}(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
var fp = typeof window !== "undefined" && window.flatpickr !== undefined
|
var fp = typeof window !== "undefined" && window.flatpickr !== undefined
|
||||||
? window.flatpickr
|
? window.flatpickr
|
||||||
: {
|
: {
|
||||||
l10ns: {}
|
l10ns: {},
|
||||||
};
|
};
|
||||||
var Japanese = {
|
var Japanese = {
|
||||||
weekdays: {
|
weekdays: {
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
"木曜日",
|
"木曜日",
|
||||||
"金曜日",
|
"金曜日",
|
||||||
"土曜日",
|
"土曜日",
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
months: {
|
months: {
|
||||||
shorthand: [
|
shorthand: [
|
||||||
@@ -50,11 +50,15 @@
|
|||||||
"10月",
|
"10月",
|
||||||
"11月",
|
"11月",
|
||||||
"12月",
|
"12月",
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
time_24hr: true,
|
time_24hr: true,
|
||||||
rangeSeparator: " から ",
|
rangeSeparator: " から ",
|
||||||
firstDayOfWeek: 1
|
monthAriaLabel: "月",
|
||||||
|
amPM: ["午前", "午後"],
|
||||||
|
yearAriaLabel: "年",
|
||||||
|
hourAriaLabel: "時間",
|
||||||
|
minuteAriaLabel: "分",
|
||||||
};
|
};
|
||||||
fp.l10ns.ja = Japanese;
|
fp.l10ns.ja = Japanese;
|
||||||
var ja = fp.l10ns;
|
var ja = fp.l10ns;
|
||||||
@@ -64,4 +68,4 @@
|
|||||||
|
|
||||||
Object.defineProperty(exports, '__esModule', { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
}));
|
})));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
584
www/lib/CoreLibs/Admin/EditBase.php
Normal file
584
www/lib/CoreLibs/Admin/EditBase.php
Normal file
@@ -0,0 +1,584 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* AUTHOR: Clemens Schwaighofer
|
||||||
|
* CREATED: 2023/1/6
|
||||||
|
* DESCRIPTION:
|
||||||
|
* Original created: 2003/06/10
|
||||||
|
* This is the edit_base.php data as is moved into a class so we can
|
||||||
|
* more easy update this and also move to a different AJAX style more
|
||||||
|
* easy
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace CoreLibs\Admin;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use SmartyException;
|
||||||
|
|
||||||
|
class EditBase
|
||||||
|
{
|
||||||
|
/** @var array<mixed> */
|
||||||
|
private $HEADER = [];
|
||||||
|
/** @var array<mixed> */
|
||||||
|
private $DATA = [];
|
||||||
|
/** @var array<mixed> */
|
||||||
|
private $DEBUG_DATA = [];
|
||||||
|
|
||||||
|
/** @var string the template name */
|
||||||
|
private $EDIT_TEMPLATE = '';
|
||||||
|
|
||||||
|
/** @var \CoreLibs\Template\SmartyExtend smarty system */
|
||||||
|
private $smarty;
|
||||||
|
/** @var \CoreLibs\Output\Form\Generate form generate system */
|
||||||
|
private $form;
|
||||||
|
/** @var \CoreLibs\Debug\Logging */
|
||||||
|
public $log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct form generator
|
||||||
|
*
|
||||||
|
* @param array<mixed> $db_config db config array, mandatory
|
||||||
|
* @param \CoreLibs\Debug\Logging $log Logging class, null auto set
|
||||||
|
* @param \CoreLibs\Language\L10n $l10n l10n language class, null auto set
|
||||||
|
* @param array<string,string> $locale locale array from ::setLocale,
|
||||||
|
* null auto set
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
array $db_config,
|
||||||
|
\CoreLibs\Debug\Logging $log,
|
||||||
|
\CoreLibs\Language\L10n $l10n,
|
||||||
|
array $locale
|
||||||
|
) {
|
||||||
|
$this->log = $log;
|
||||||
|
// smarty template engine (extended Translation version)
|
||||||
|
$this->smarty = new \CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||||
|
// turn off set log per class
|
||||||
|
$log->setLogPer('class', false);
|
||||||
|
|
||||||
|
// create form class
|
||||||
|
$this->form = new \CoreLibs\Output\Form\Generate(
|
||||||
|
$db_config,
|
||||||
|
$log,
|
||||||
|
$l10n,
|
||||||
|
$locale
|
||||||
|
);
|
||||||
|
if ($this->form->mobile_phone) {
|
||||||
|
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
// $this->form->log->debug('POST', $this->form->log->prAr($_POST));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* edit order page
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function editOrderPage(): void
|
||||||
|
{
|
||||||
|
// get is for "table_name" and "where" only
|
||||||
|
$table_name = $_GET['table_name'] ?? $_POST['table_name'] ?? '';
|
||||||
|
// not in use
|
||||||
|
// $where_string = $_GET['where'] ?? $_POST['where'] ?? '';
|
||||||
|
// order name is _always_ order_number for the edit interface
|
||||||
|
|
||||||
|
// follwing arrays do exist here:
|
||||||
|
// $position ... has the positions of the [0..max], cause in a <select>
|
||||||
|
// I can't put an number into the array field, in this array,
|
||||||
|
// there are the POSITION stored,
|
||||||
|
// that should CHANGE there order (up/down)
|
||||||
|
// $row_data_id ... has ALL ids from the sorting part
|
||||||
|
// $row_data_order ... has ALL order positions from the soirting part
|
||||||
|
$position = $_POST['position'] ?? [];
|
||||||
|
$row_data_id = $_POST['row_data_id'] ?? [];
|
||||||
|
$original_id = $row_data_id;
|
||||||
|
$row_data_order = $_POST['row_data_order'] ?? [];
|
||||||
|
// direction
|
||||||
|
$up = $_POST['up'] ?? '';
|
||||||
|
$down = $_POST['down'] ?? '';
|
||||||
|
if (count($position)) {
|
||||||
|
// FIRST u have to put right sort, then read again ...
|
||||||
|
// hast to be >0 or the first one is selected and then there is no move
|
||||||
|
if (!empty($up) && isset($position[0]) && $position[0] > 0) {
|
||||||
|
for ($i = 0; $i < count($position); $i++) {
|
||||||
|
// change position order
|
||||||
|
// this gets temp, id before that, gets actual (moves one "down")
|
||||||
|
// this gets the old before (moves one "up")
|
||||||
|
// is done for every element in row
|
||||||
|
// echo "A: ".$row_data_id[$position[$i]]
|
||||||
|
// ." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]
|
||||||
|
// ." (".$row_data_order[$position[$i]-1].")<br>";
|
||||||
|
$temp_id = $row_data_id[$position[$i]] ?? null;
|
||||||
|
$row_data_id[$position[$i]] = $row_data_id[(int)$position[$i] - 1] ?? null;
|
||||||
|
$row_data_id[(int)$position[$i] - 1] = $temp_id;
|
||||||
|
// echo "A: ".$row_data_id[$position[$i]]
|
||||||
|
// ." (".$row_data_order[$position[$i]].") -- "
|
||||||
|
// .$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||||
|
} // for
|
||||||
|
} // if up
|
||||||
|
|
||||||
|
// the last position id from position array is not to be the count - 1 of
|
||||||
|
// row_data_id array, or it is the last element
|
||||||
|
if (!empty($down) && ($position[count($position) - 1] != (count($row_data_id) - 1))) {
|
||||||
|
for ($i = count($position) - 1; $i >= 0; $i--) {
|
||||||
|
// same as up, just up in other way, starts from bottom (last element) and moves "up"
|
||||||
|
// element before actuel gets temp, this element, becomes element after this,
|
||||||
|
// element after this, gets this
|
||||||
|
$temp_id = $row_data_id[(int)$position[$i] + 1] ?? null;
|
||||||
|
$row_data_id[(int)$position[$i] + 1] = $row_data_id[$position[$i]] ?? null;
|
||||||
|
$row_data_id[$position[$i]] = $temp_id;
|
||||||
|
} // for
|
||||||
|
} // if down
|
||||||
|
|
||||||
|
// write data ... (which has to be abstrackt ...)
|
||||||
|
if (
|
||||||
|
(!empty($up) && $position[0] > 0) ||
|
||||||
|
(!empty($down) && ($position[count($position) - 1] != (count($row_data_id) - 1)))
|
||||||
|
) {
|
||||||
|
for ($i = 0; $i < count($row_data_id); $i++) {
|
||||||
|
if (isset($row_data_order[$i]) && isset($row_data_id[$i])) {
|
||||||
|
$q = "UPDATE " . $table_name
|
||||||
|
. " SET order_number = " . $row_data_order[$i]
|
||||||
|
. " WHERE " . $table_name . "_id = " . $row_data_id[$i];
|
||||||
|
$q = $this->form->dbExec($q);
|
||||||
|
}
|
||||||
|
} // for all article ids ...
|
||||||
|
} // if write
|
||||||
|
} // if there is something to move
|
||||||
|
|
||||||
|
// get ...
|
||||||
|
$q = "SELECT " . $table_name . "_id, name, order_number FROM " . $table_name . " ";
|
||||||
|
// /* if (!empty($where_string)) {
|
||||||
|
// $q .= "WHERE $where_string ";
|
||||||
|
// } */
|
||||||
|
$q .= "ORDER BY order_number";
|
||||||
|
|
||||||
|
// init arrays
|
||||||
|
$row_data = [];
|
||||||
|
$options_id = [];
|
||||||
|
$options_name = [];
|
||||||
|
$options_selected = [];
|
||||||
|
// DB read data for menu
|
||||||
|
while (is_array($res = $this->form->dbReturn($q))) {
|
||||||
|
$row_data[] = [
|
||||||
|
"id" => $res[$table_name . "_id"],
|
||||||
|
"name" => $res["name"],
|
||||||
|
"order" => $res["order_number"]
|
||||||
|
];
|
||||||
|
} // while read data ...
|
||||||
|
|
||||||
|
// html title
|
||||||
|
$this->HEADER['HTML_TITLE'] = $this->form->l->__('Edit Order');
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
$error = $_POST['error'] ?? 0;
|
||||||
|
// error msg
|
||||||
|
if (!empty($error)) {
|
||||||
|
$msg = $_POST['msg'] ?? [];
|
||||||
|
if (!is_array($msg)) {
|
||||||
|
$msg = [];
|
||||||
|
}
|
||||||
|
$messages[] = [
|
||||||
|
'msg' => $msg,
|
||||||
|
'class' => 'error',
|
||||||
|
'width' => '100%'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$this->DATA['form_error_msg'] = $messages;
|
||||||
|
|
||||||
|
// all the row data
|
||||||
|
for ($i = 0; $i < count($row_data); $i++) {
|
||||||
|
$options_id[] = $i;
|
||||||
|
$options_name[] = $row_data[$i]['name'];
|
||||||
|
// list of points to order
|
||||||
|
for ($j = 0; $j < count($position); $j++) {
|
||||||
|
// if matches, put into select array
|
||||||
|
if (
|
||||||
|
isset($original_id[$position[$j]]) && isset($row_data[$i]['id']) &&
|
||||||
|
$original_id[$position[$j]] == $row_data[$i]['id']
|
||||||
|
) {
|
||||||
|
$options_selected[] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->DATA['options_id'] = $options_id;
|
||||||
|
$this->DATA['options_name'] = $options_name;
|
||||||
|
$this->DATA['options_selected'] = $options_selected;
|
||||||
|
|
||||||
|
// hidden list for the data (id, order number)
|
||||||
|
$row_data_id = [];
|
||||||
|
$row_data_order = [];
|
||||||
|
for ($i = 0; $i < count($row_data); $i++) {
|
||||||
|
$row_data_id[] = $row_data[$i]['id'];
|
||||||
|
$row_data_order[] = $row_data[$i]['order'];
|
||||||
|
}
|
||||||
|
$this->DATA['row_data_id'] = $row_data_id;
|
||||||
|
$this->DATA['row_data_order'] = $row_data_order;
|
||||||
|
|
||||||
|
// hidden names for the table & where string
|
||||||
|
$this->DATA['table_name'] = $table_name;
|
||||||
|
$this->DATA['where_string'] = '';
|
||||||
|
// $this->DATA['where_string'] = $where_string ?? '';
|
||||||
|
|
||||||
|
$this->EDIT_TEMPLATE = 'edit_order.tpl';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* all edit pages
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function editPageFlow(): void
|
||||||
|
{
|
||||||
|
// set table width
|
||||||
|
$table_width = '100%';
|
||||||
|
// load call only if id is set
|
||||||
|
if (!empty($_POST[$this->form->archive_pk_name])) {
|
||||||
|
$this->form->formProcedureLoad($_POST[$this->form->archive_pk_name]);
|
||||||
|
}
|
||||||
|
$this->form->formProcedureNew();
|
||||||
|
$this->form->formProcedureSave();
|
||||||
|
$this->form->formProcedureDelete();
|
||||||
|
// delete call only if those two are set
|
||||||
|
if (
|
||||||
|
!empty($_POST['element_list']) &&
|
||||||
|
!empty($_POST['remove_name'])
|
||||||
|
) {
|
||||||
|
$this->form->formProcedureDeleteFromElementList(
|
||||||
|
$_POST['element_list'],
|
||||||
|
$_POST['remove_name']
|
||||||
|
);
|
||||||
|
// run a load post element delete to not end up with empty page
|
||||||
|
$this->form->formLoadTableArray($_POST[$this->form->archive_pk_name]);
|
||||||
|
$this->form->yes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->DATA['table_width'] = $table_width;
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
// write out error / status messages
|
||||||
|
$messages[] = $this->form->formPrintMsg();
|
||||||
|
$this->DATA['form_error_msg'] = $messages;
|
||||||
|
|
||||||
|
// MENU START
|
||||||
|
// request some session vars
|
||||||
|
if (empty($_SESSION['HEADER_COLOR'])) {
|
||||||
|
$this->DATA['HEADER_COLOR'] = '#E0E2FF';
|
||||||
|
} else {
|
||||||
|
$this->DATA['HEADER_COLOR'] = $_SESSION['HEADER_COLOR'];
|
||||||
|
}
|
||||||
|
$this->DATA['USER_NAME'] = $_SESSION['USER_NAME'];
|
||||||
|
$this->DATA['EUID'] = $_SESSION['EUID'];
|
||||||
|
$this->DATA['GROUP_NAME'] = $_SESSION['GROUP_NAME'];
|
||||||
|
$this->DATA['GROUP_LEVEL'] = $_SESSION['GROUP_ACL_LEVEL'];
|
||||||
|
$PAGES = $_SESSION['PAGES'];
|
||||||
|
|
||||||
|
//$this->form->log->debug('menu', $this->form->log->prAr($PAGES));
|
||||||
|
|
||||||
|
// build nav from $PAGES ...
|
||||||
|
if (!isset($PAGES) || !is_array($PAGES)) {
|
||||||
|
$PAGES = [];
|
||||||
|
}
|
||||||
|
$menuarray = [];
|
||||||
|
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
|
||||||
|
if ($PAGE_DATA['menu'] && $PAGE_DATA['online']) {
|
||||||
|
$menuarray[] = $PAGE_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// split point for nav points
|
||||||
|
$COUNT_NAV_POINTS = count($menuarray);
|
||||||
|
$SPLIT_FACTOR = 3;
|
||||||
|
$START_SPLIT_COUNT = 3;
|
||||||
|
// WTF ?? I dunno what I am doing here ...
|
||||||
|
for ($i = 9; $i < $COUNT_NAV_POINTS; $i += $START_SPLIT_COUNT) {
|
||||||
|
if ($COUNT_NAV_POINTS > $i) {
|
||||||
|
$SPLIT_FACTOR += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$position = 0;
|
||||||
|
$menu_data = [];
|
||||||
|
// for ($i = 1; $i <= count($menuarray); $i ++) {
|
||||||
|
foreach ($menuarray as $i => $menu_element) {
|
||||||
|
// do that for new array
|
||||||
|
$j = $i + 1;
|
||||||
|
$menu_data[$i]['pagename'] = htmlentities($menu_element['page_name']);
|
||||||
|
$menu_data[$i]['filename'] =
|
||||||
|
// prefix folder or host name
|
||||||
|
(isset($menu_element['hostname']) && $menu_element['hostname'] ?
|
||||||
|
$menu_element['hostname'] :
|
||||||
|
''
|
||||||
|
)
|
||||||
|
// filename
|
||||||
|
. ($menu_element['filename'] ?? '')
|
||||||
|
// query string
|
||||||
|
. (isset($menu_element['query_string']) && $menu_element['query_string'] ?
|
||||||
|
$menu_element['query_string'] :
|
||||||
|
''
|
||||||
|
);
|
||||||
|
if ($j == 1 || !($i % $SPLIT_FACTOR)) {
|
||||||
|
$menu_data[$i]['splitfactor_in'] = 1;
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['splitfactor_in'] = 0;
|
||||||
|
}
|
||||||
|
// on matching, we also need to check if we are in the same folder
|
||||||
|
if (
|
||||||
|
isset($menu_element['filename']) &&
|
||||||
|
$menu_element['filename'] == \CoreLibs\Get\System::getPageName() &&
|
||||||
|
(!isset($menu_element['hostname']) || (
|
||||||
|
isset($menu_element['hostname']) &&
|
||||||
|
(!$menu_element['hostname'] || strstr($menu_element['hostname'], CONTENT_PATH) !== false)
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
$position = $i;
|
||||||
|
$menu_data[$i]['position'] = 1;
|
||||||
|
$menu_data[$i]['popup'] = 0;
|
||||||
|
} else {
|
||||||
|
// add query stuff
|
||||||
|
// HAS TO DONE LATER ... set urlencode, etc ...
|
||||||
|
// check if popup needed
|
||||||
|
if (isset($menu_element['popup']) && $menu_element['popup'] == 1) {
|
||||||
|
$menu_data[$i]['popup'] = 1;
|
||||||
|
$menu_data[$i]['rand'] = uniqid((string)rand());
|
||||||
|
$menu_data[$i]['width'] = $menu_element['popup_x'];
|
||||||
|
$menu_data[$i]['height'] = $menu_element['popup_y'];
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['popup'] = 0;
|
||||||
|
}
|
||||||
|
$menu_data[$i]['position'] = 0;
|
||||||
|
} // highlight or not
|
||||||
|
if (!($j % $SPLIT_FACTOR) || (($j + 1) > count($menuarray))) {
|
||||||
|
$menu_data[$i]['splitfactor_out'] = 1;
|
||||||
|
} else {
|
||||||
|
$menu_data[$i]['splitfactor_out'] = 0;
|
||||||
|
}
|
||||||
|
} // for
|
||||||
|
// $this->form->log->debug('MENU ARRAY', $this->form->log->prAr($menu_data));
|
||||||
|
$this->DATA['menu_data'] = $menu_data;
|
||||||
|
$this->DATA['page_name'] = $menuarray[$position]['page_name'] ?? '-Undefined [' . $position . '] -';
|
||||||
|
$L_TITLE = $this->DATA['page_name'];
|
||||||
|
// html title
|
||||||
|
$this->HEADER['HTML_TITLE'] = $this->form->l->__($L_TITLE);
|
||||||
|
// END MENU
|
||||||
|
// LOAD AND NEW
|
||||||
|
$this->DATA['load'] = $this->form->formCreateLoad();
|
||||||
|
$this->DATA['new'] = $this->form->formCreateNew();
|
||||||
|
// SHOW DATA PART
|
||||||
|
if ($this->form->yes) {
|
||||||
|
$this->DATA['form_yes'] = $this->form->yes;
|
||||||
|
$this->DATA['form_my_page_name'] = $this->form->my_page_name;
|
||||||
|
$this->DATA['filename_exist'] = 0;
|
||||||
|
$this->DATA['drop_down_input'] = 0;
|
||||||
|
$elements = [];
|
||||||
|
// depending on the "getPageName()" I show different stuff
|
||||||
|
switch ($this->form->my_page_name) {
|
||||||
|
case 'edit_users':
|
||||||
|
$elements[] = $this->form->formCreateElement('login_error_count');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_error_date_last');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_error_date_first');
|
||||||
|
$elements[] = $this->form->formCreateElement('enabled');
|
||||||
|
$elements[] = $this->form->formCreateElement('deleted');
|
||||||
|
$elements[] = $this->form->formCreateElement('protected');
|
||||||
|
$elements[] = $this->form->formCreateElement('username');
|
||||||
|
$elements[] = $this->form->formCreateElement('password');
|
||||||
|
$elements[] = $this->form->formCreateElement('password_change_interval');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_set_date');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_last_revalidate');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_locked');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_revalidate_after');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_valid_from');
|
||||||
|
$elements[] = $this->form->formCreateElement('login_user_id_valid_until');
|
||||||
|
$elements[] = $this->form->formCreateElement('email');
|
||||||
|
$elements[] = $this->form->formCreateElement('last_name');
|
||||||
|
$elements[] = $this->form->formCreateElement('first_name');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_group_id');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_access_right_id');
|
||||||
|
$elements[] = $this->form->formCreateElement('strict');
|
||||||
|
$elements[] = $this->form->formCreateElement('locked');
|
||||||
|
$elements[] = $this->form->formCreateElement('lock_until');
|
||||||
|
$elements[] = $this->form->formCreateElement('lock_after');
|
||||||
|
$elements[] = $this->form->formCreateElement('admin');
|
||||||
|
$elements[] = $this->form->formCreateElement('debug');
|
||||||
|
$elements[] = $this->form->formCreateElement('db_debug');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_language_id');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_scheme_id');
|
||||||
|
$elements[] = $this->form->formCreateElementListTable('edit_access_user');
|
||||||
|
$elements[] = $this->form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
case 'edit_schemes':
|
||||||
|
$elements[] = $this->form->formCreateElement('enabled');
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
$elements[] = $this->form->formCreateElement('header_color');
|
||||||
|
$elements[] = $this->form->formCreateElement('template');
|
||||||
|
break;
|
||||||
|
case 'edit_pages':
|
||||||
|
if (!isset($this->form->table_array['edit_page_id']['value'])) {
|
||||||
|
$q = "DELETE FROM temp_files";
|
||||||
|
$this->form->dbExec($q);
|
||||||
|
// gets all files in the current dir and dirs given ending with .php
|
||||||
|
$folders = ['../admin/', '../frontend/'];
|
||||||
|
$files = ['*.php'];
|
||||||
|
$search_glob = [];
|
||||||
|
foreach ($folders as $folder) {
|
||||||
|
// make sure this folder actually exists
|
||||||
|
if (is_dir(ROOT . $folder)) {
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$search_glob[] = $folder . $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$crap = exec('ls ' . join(' ', $search_glob), $output, $status);
|
||||||
|
// now get all that are NOT in de DB
|
||||||
|
$q = "INSERT INTO temp_files (folder, filename) VALUES ";
|
||||||
|
$t_q = '';
|
||||||
|
foreach ($output as $output_file) {
|
||||||
|
// split the ouput into folder and file
|
||||||
|
$pathinfo = pathinfo($output_file);
|
||||||
|
if (!empty($pathinfo['dirname'])) {
|
||||||
|
$pathinfo['dirname'] .= DIRECTORY_SEPARATOR;
|
||||||
|
} else {
|
||||||
|
$pathinfo['dirname'] = '';
|
||||||
|
}
|
||||||
|
if ($t_q) {
|
||||||
|
$t_q .= ', ';
|
||||||
|
}
|
||||||
|
$t_q .= "('" . $this->form->dbEscapeString($pathinfo['dirname']) . "', '"
|
||||||
|
. $this->form->dbEscapeString($pathinfo['basename']) . "')";
|
||||||
|
}
|
||||||
|
$this->form->dbExec($q . $t_q, 'NULL');
|
||||||
|
$elements[] = $this->form->formCreateElement('filename');
|
||||||
|
} else {
|
||||||
|
// show file menu
|
||||||
|
// just show name of file ...
|
||||||
|
$this->DATA['filename_exist'] = 1;
|
||||||
|
$this->DATA['filename'] = $this->form->table_array['filename']['value'];
|
||||||
|
} // File Name View IF
|
||||||
|
$elements[] = $this->form->formCreateElement('hostname');
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
// $elements[] = $this->form->formCreateElement('tag');
|
||||||
|
// $elements[] = $this->form->formCreateElement('min_acl');
|
||||||
|
$elements[] = $this->form->formCreateElement('order_number');
|
||||||
|
$elements[] = $this->form->formCreateElement('online');
|
||||||
|
$elements[] = $this->form->formCreateElement('menu');
|
||||||
|
$elements[] = $this->form->formCreateElementListTable('edit_query_string');
|
||||||
|
$elements[] = $this->form->formCreateElement('content_alias_edit_page_id');
|
||||||
|
$elements[] = $this->form->formCreateElementListTable('edit_page_content');
|
||||||
|
$elements[] = $this->form->formCreateElement('popup');
|
||||||
|
$elements[] = $this->form->formCreateElement('popup_x');
|
||||||
|
$elements[] = $this->form->formCreateElement('popup_y');
|
||||||
|
$elements[] = $this->form->formCreateElementReferenceTable('edit_visible_group');
|
||||||
|
$elements[] = $this->form->formCreateElementReferenceTable('edit_menu_group');
|
||||||
|
break;
|
||||||
|
case 'edit_languages':
|
||||||
|
$elements[] = $this->form->formCreateElement('enabled');
|
||||||
|
$elements[] = $this->form->formCreateElement('short_name');
|
||||||
|
$elements[] = $this->form->formCreateElement('long_name');
|
||||||
|
$elements[] = $this->form->formCreateElement('iso_name');
|
||||||
|
break;
|
||||||
|
case 'edit_groups':
|
||||||
|
$elements[] = $this->form->formCreateElement('enabled');
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_access_right_id');
|
||||||
|
$elements[] = $this->form->formCreateElement('edit_scheme_id');
|
||||||
|
$elements[] = $this->form->formCreateElementListTable('edit_page_access');
|
||||||
|
$elements[] = $this->form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
case 'edit_visible_group':
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
$elements[] = $this->form->formCreateElement('flag');
|
||||||
|
break;
|
||||||
|
case 'edit_menu_group':
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
$elements[] = $this->form->formCreateElement('flag');
|
||||||
|
$elements[] = $this->form->formCreateElement('order_number');
|
||||||
|
break;
|
||||||
|
case 'edit_access':
|
||||||
|
$elements[] = $this->form->formCreateElement('name');
|
||||||
|
$elements[] = $this->form->formCreateElement('enabled');
|
||||||
|
$elements[] = $this->form->formCreateElement('protected');
|
||||||
|
$elements[] = $this->form->formCreateElement('color');
|
||||||
|
$elements[] = $this->form->formCreateElement('description');
|
||||||
|
// add name/value list here
|
||||||
|
$elements[] = $this->form->formCreateElementListTable('edit_access_data');
|
||||||
|
$elements[] = $this->form->formCreateElement('additional_acl');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print '[No valid page definition given]';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// $this->form->log->debug('edit', "Elements: <pre>".$this->form->log->prAr($elements));
|
||||||
|
$this->DATA['elements'] = $elements;
|
||||||
|
$this->DATA['hidden'] = $this->form->formCreateHiddenFields();
|
||||||
|
$this->DATA['save_delete'] = $this->form->formCreateSaveDelete();
|
||||||
|
} else {
|
||||||
|
$this->DATA['form_yes'] = 0;
|
||||||
|
}
|
||||||
|
$this->EDIT_TEMPLATE = 'edit_body.tpl';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main method that either calls edit order page method or general page
|
||||||
|
* builds the smarty content and runs smarty display output
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function editBaseRun()
|
||||||
|
{
|
||||||
|
// set the template dir
|
||||||
|
// WARNING: this has a special check for the mailing tool layout (old layout)
|
||||||
|
if (defined('LAYOUT')) {
|
||||||
|
$this->smarty->setTemplateDir(BASE . INCLUDES . TEMPLATES . CONTENT_PATH);
|
||||||
|
$this->DATA['css'] = LAYOUT . CSS;
|
||||||
|
$this->DATA['js'] = LAYOUT . JS;
|
||||||
|
} else {
|
||||||
|
$this->smarty->setTemplateDir(TEMPLATES);
|
||||||
|
$this->DATA['css'] = CSS;
|
||||||
|
$this->DATA['js'] = JS;
|
||||||
|
}
|
||||||
|
$ADMIN_STYLESHEET = 'edit.css';
|
||||||
|
// define all needed smarty stuff for the general HTML/page building
|
||||||
|
$this->HEADER['CSS'] = CSS;
|
||||||
|
$this->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||||
|
/** @phpstan-ignore-next-line because ADMIN_STYLESHEET can be null */
|
||||||
|
$this->HEADER['STYLESHEET'] = $ADMIN_STYLESHEET ?? ADMIN_STYLESHEET;
|
||||||
|
|
||||||
|
// main run
|
||||||
|
if ($this->form->my_page_name == 'edit_order') {
|
||||||
|
$this->editOrderPage();
|
||||||
|
} else {
|
||||||
|
$this->editPageFlow();
|
||||||
|
}
|
||||||
|
|
||||||
|
// debug data, if DEBUG flag is on, this data is print out
|
||||||
|
// $this->DEBUG_DATA['DEBUG'] = $DEBUG_TMPL ?? '';
|
||||||
|
$this->DEBUG_DATA['DEBUG'] = '';
|
||||||
|
|
||||||
|
// create main data array
|
||||||
|
$CONTENT_DATA = array_merge($this->HEADER, $this->DATA, $this->DEBUG_DATA);
|
||||||
|
// data is 1:1 mapping (all vars, values, etc)
|
||||||
|
foreach ($CONTENT_DATA as $key => $value) {
|
||||||
|
$this->smarty->assign($key, $value);
|
||||||
|
}
|
||||||
|
if (is_dir(BASE . TEMPLATES_C)) {
|
||||||
|
$this->smarty->setCompileDir(BASE . TEMPLATES_C);
|
||||||
|
}
|
||||||
|
if (is_dir(BASE . CACHE)) {
|
||||||
|
$this->smarty->setCacheDir(BASE . CACHE);
|
||||||
|
}
|
||||||
|
$this->smarty->display(
|
||||||
|
$this->EDIT_TEMPLATE,
|
||||||
|
'editAdmin_' . $this->smarty->lang,
|
||||||
|
'editAdmin_' . $this->smarty->lang
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form->log->debug('DEBUGEND', '==================================== [Form END]');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -452,6 +452,11 @@ class IO
|
|||||||
'71' => 'Failed to set search path/schema',
|
'71' => 'Failed to set search path/schema',
|
||||||
'80' => 'Trying to set an empty encoding',
|
'80' => 'Trying to set an empty encoding',
|
||||||
'81' => 'Failed to set client encoding',
|
'81' => 'Failed to set client encoding',
|
||||||
|
// for prepared cursor return
|
||||||
|
'101' => 'Statement name empty for get prepare cursor',
|
||||||
|
'102' => 'Key empty for get prepare cursir',
|
||||||
|
'103' => 'No prepared cursor with this name',
|
||||||
|
'104' => 'No Key with this name in the prepared cursor array'
|
||||||
];
|
];
|
||||||
|
|
||||||
// load the core DB functions wrapper class
|
// load the core DB functions wrapper class
|
||||||
@@ -3066,6 +3071,60 @@ class IO
|
|||||||
return $this->field_names;
|
return $this->field_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value for given key in statement
|
||||||
|
* Will write error if statemen id does not exist
|
||||||
|
* or key is invalid
|
||||||
|
*
|
||||||
|
* @param string $stm_name The name of the stored statement
|
||||||
|
* @param string $key Key field name in prepared cursor array
|
||||||
|
* Allowed are: pk_name, count, query, returning_id
|
||||||
|
* @return null|string|int|bool Entry from each of the valid keys
|
||||||
|
* Will return false on error
|
||||||
|
* Not ethat returnin_id also can return false
|
||||||
|
* but will not set an error entry
|
||||||
|
*/
|
||||||
|
public function dbGetPrepareCursorValue(string $stm_name, string $key)
|
||||||
|
{
|
||||||
|
// if no statement name
|
||||||
|
if (empty($stm_name)) {
|
||||||
|
$this->__dbError(
|
||||||
|
101,
|
||||||
|
false,
|
||||||
|
'No statement name given'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// if not a valid key
|
||||||
|
if (!in_array($key, ['pk_name', 'count', 'query', 'returning_id'])) {
|
||||||
|
$this->__dbError(
|
||||||
|
102,
|
||||||
|
false,
|
||||||
|
'Invalid key name'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// statement name not in prepared list
|
||||||
|
if (empty($this->prepare_cursor[$stm_name])) {
|
||||||
|
$this->__dbError(
|
||||||
|
103,
|
||||||
|
false,
|
||||||
|
'Statement name does not exist in prepare cursor array'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// key doest not exists, this will never hit as we filter out invalid ones
|
||||||
|
if (!isset($this->prepare_cursor[$stm_name][$key])) {
|
||||||
|
$this->__dbError(
|
||||||
|
104,
|
||||||
|
false,
|
||||||
|
'Key does not exist in prepare cursor array'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->prepare_cursor[$stm_name][$key];
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************
|
// ***************************
|
||||||
// ERROR AND WARNING DATA
|
// ERROR AND WARNING DATA
|
||||||
// ***************************
|
// ***************************
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ class DotEnv
|
|||||||
// strip ending " and EVERYTHING that follows after that
|
// strip ending " and EVERYTHING that follows after that
|
||||||
$line = $matches[1];
|
$line = $matches[1];
|
||||||
}
|
}
|
||||||
|
// just be sure it is init before we fill
|
||||||
|
if (!isset($_ENV[$var])) {
|
||||||
|
$_ENV[$var] = '';
|
||||||
|
}
|
||||||
// strip line of slashes
|
// strip line of slashes
|
||||||
$_ENV[$var] .= stripslashes($line);
|
$_ENV[$var] .= stripslashes($line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,6 +314,11 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
?\CoreLibs\Language\L10n $l10n = null,
|
?\CoreLibs\Language\L10n $l10n = null,
|
||||||
?array $locale = null
|
?array $locale = null
|
||||||
) {
|
) {
|
||||||
|
// don't log per class
|
||||||
|
if ($log !== null) {
|
||||||
|
$log->setLogPer('class', false);
|
||||||
|
}
|
||||||
|
// if set global table array variable
|
||||||
global $table_arrays;
|
global $table_arrays;
|
||||||
// replace any non valid variable names
|
// replace any non valid variable names
|
||||||
// TODO extract only alphanumeric and _ after . to _ replacement
|
// TODO extract only alphanumeric and _ after . to _ replacement
|
||||||
@@ -383,10 +388,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// don't log per class
|
// $log->debug('CONFIG ARRAY', $log->prAr($config_array));
|
||||||
if ($log !== null) {
|
|
||||||
$log->setLogPer('class', false);
|
|
||||||
}
|
|
||||||
// start the array_io class which will start db_io ...
|
// start the array_io class which will start db_io ...
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$db_config,
|
$db_config,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<directory name="media" />
|
<directory name="media" />
|
||||||
<directory name="lib/FileUpload" />
|
<directory name="lib/FileUpload" />
|
||||||
<directory name="lib/Smarty" />
|
<directory name="lib/Smarty" />
|
||||||
<directory name="lib/smarty-4.1.0" />
|
<directory name="lib/smarty-4.3.0" />
|
||||||
<file name="lib/Smarty/Smarty.class.php" />
|
<file name="lib/Smarty/Smarty.class.php" />
|
||||||
<file name="lib/CoreLibs/Template/SmartyExtend.php" />
|
<file name="lib/CoreLibs/Template/SmartyExtend.php" />
|
||||||
</ignoreFiles>
|
</ignoreFiles>
|
||||||
|
|||||||
1
www/vendor/composer/autoload_classmap.php
vendored
1
www/vendor/composer/autoload_classmap.php
vendored
@@ -10,6 +10,7 @@ return array(
|
|||||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
'CoreLibs\\ACL\\Login' => $baseDir . '/lib/CoreLibs/ACL/Login.php',
|
'CoreLibs\\ACL\\Login' => $baseDir . '/lib/CoreLibs/ACL/Login.php',
|
||||||
'CoreLibs\\Admin\\Backend' => $baseDir . '/lib/CoreLibs/Admin/Backend.php',
|
'CoreLibs\\Admin\\Backend' => $baseDir . '/lib/CoreLibs/Admin/Backend.php',
|
||||||
|
'CoreLibs\\Admin\\EditBase' => $baseDir . '/lib/CoreLibs/Admin/EditBase.php',
|
||||||
'CoreLibs\\Basic' => $baseDir . '/lib/CoreLibs/Basic.php',
|
'CoreLibs\\Basic' => $baseDir . '/lib/CoreLibs/Basic.php',
|
||||||
'CoreLibs\\Check\\Email' => $baseDir . '/lib/CoreLibs/Check/Email.php',
|
'CoreLibs\\Check\\Email' => $baseDir . '/lib/CoreLibs/Check/Email.php',
|
||||||
'CoreLibs\\Check\\Encoding' => $baseDir . '/lib/CoreLibs/Check/Encoding.php',
|
'CoreLibs\\Check\\Encoding' => $baseDir . '/lib/CoreLibs/Check/Encoding.php',
|
||||||
|
|||||||
2
www/vendor/composer/autoload_files.php
vendored
2
www/vendor/composer/autoload_files.php
vendored
@@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
|
||||||
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
|
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
|
||||||
|
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
||||||
);
|
);
|
||||||
|
|||||||
3
www/vendor/composer/autoload_static.php
vendored
3
www/vendor/composer/autoload_static.php
vendored
@@ -7,8 +7,8 @@ namespace Composer\Autoload;
|
|||||||
class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
|
class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
|
||||||
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
|
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
|
||||||
|
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $prefixLengthsPsr4 = array (
|
public static $prefixLengthsPsr4 = array (
|
||||||
@@ -43,6 +43,7 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
|
|||||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
'CoreLibs\\ACL\\Login' => __DIR__ . '/../..' . '/lib/CoreLibs/ACL/Login.php',
|
'CoreLibs\\ACL\\Login' => __DIR__ . '/../..' . '/lib/CoreLibs/ACL/Login.php',
|
||||||
'CoreLibs\\Admin\\Backend' => __DIR__ . '/../..' . '/lib/CoreLibs/Admin/Backend.php',
|
'CoreLibs\\Admin\\Backend' => __DIR__ . '/../..' . '/lib/CoreLibs/Admin/Backend.php',
|
||||||
|
'CoreLibs\\Admin\\EditBase' => __DIR__ . '/../..' . '/lib/CoreLibs/Admin/EditBase.php',
|
||||||
'CoreLibs\\Basic' => __DIR__ . '/../..' . '/lib/CoreLibs/Basic.php',
|
'CoreLibs\\Basic' => __DIR__ . '/../..' . '/lib/CoreLibs/Basic.php',
|
||||||
'CoreLibs\\Check\\Email' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Email.php',
|
'CoreLibs\\Check\\Email' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Email.php',
|
||||||
'CoreLibs\\Check\\Encoding' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Encoding.php',
|
'CoreLibs\\Check\\Encoding' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Encoding.php',
|
||||||
|
|||||||
Reference in New Issue
Block a user