Add database internal edit_* tables CUID, CSS loading style

all edit_* have CUID random alphanumeric unique id with 12 characters
length.
automatically created on INSERT and not touched on update.
but can be udpated manually on UPDATE command.
on INSERT cuid is ALWAYS overwritten with auto create

Add CSS loading style sheet
This commit is contained in:
Clemens Schwaighofer
2018-06-22 18:31:02 +09:00
parent bfe3fdcff4
commit 34f33772d0
17 changed files with 271 additions and 24 deletions

View File

@@ -139,8 +139,11 @@ $PAGES = $_SESSION["PAGES"];
//$form->debug('menu', $form->printAr($PAGES));
// baue nav aus $PAGES ...
for ($i = 0; $i < count($PAGES); $i ++) {
// build nav from $PAGES ...
if (!is_array($PAGES)) {
$PAGES = array ();
}
for ($i = 0, $i_max = count($PAGES); $i < $i_max; $i ++) {
if ($PAGES[$i]["menu"] && $PAGES[$i]["online"]) {
$menuarray[] = $PAGES[$i];
}

View File

@@ -367,6 +367,30 @@ input[type="text"]:focus, textarea:focus, select:focus {
font-size: 8px;
}
/* NEW VERSION with CSS key frame animation */
.progress {
width: 100px;
height: 100px;
background: rgba(255, 255, 255, 0.6);
border: 20px solid rgba(255, 255, 255 ,0.25);
border-left-color: rgba(3, 155, 229 ,1);
border-top-color: rgba(3, 155, 229 ,1);
border-radius: 50%;
display: inline-block;
animation: rotate 600ms infinite linear;
/* align */
left: 0;
top: 0;
position: absolute;
z-index: 100;
}
/* Animation for above progress */
@keyframes rotate {
to {
transform: rotate(1turn)
}
}
/* ***************************** ADMIN EDIT INTERFACE COLORS ********************************* */
/* set all colors here and not in the config file */
/* for edit interface */

View File

@@ -2,6 +2,8 @@
code is taken and adapted from dokuwiki
*/
/* jshint esversion: 6 */
/**
* Some browser detection
*/
@@ -207,3 +209,116 @@ function formatBytes(bytes)
return parseFloat(Math.round(bytes * Math.pow(10, 2)) / Math.pow(10, 2)) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
}
// *** DOM MANAGEMENT FUNCTIONS
// METHOD: cel [create element]
// PARAMS: tag: must set tag (div, span, etc)
// id: optional set for id, if input, select will be used for name
// content: text content inside, is skipped if sub elements exist
// css: array for css tags
// options: anything else (value, placeholder, OnClick, style)
// RETURN: object
// DESC : creates object for DOM element creation flow
const cel = (tag, id = '', content = '', css = [], options = {}) =>
element = {
tag: tag,
id: id,
content: content,
css: css,
options: options,
sub: []
};
// METHOD: ael [attach element]
// PARAMS: base: object where to attach/search
// attach: the object to be attached
// id: optional id, if given search in base for this id and attach there
// RETURN: "none", technically there is no return needed
// DESC : attach a cel created object to another to create a basic DOM tree
function ael(base, attach, id = '')
{
if (id) {
// base id match already
if (base.id == id) {
base.sub.push(attach);
} else {
// sub check
if (base.sub.length > 0) {
base.sub.each(function(t) {
// recursive call to sub element
ael(t, attach, id);
});
}
}
} else {
base.sub.push(attach);
}
return base;
}
// METHOD: rel [rese element]
// PARAMS: cel created element
// RETURN: "none", is self change, but returns base.sub
// DESC : resets the sub elements of the base element given
const rel = (base) => base.sub = [];
// METHOD: phfo [produce html from object]
// PARAMS: object tree with dom element declarations
// RETURN: HTML string that can be used as innerHTML
// DESC : parses the object tree created with cel/ael
// and converts it into an HTML string that can
// be inserted into the page
function phfo(tree)
{
// holds the elements
let content = [];
// main part line
let line = '<' + tree.tag;
// first id, if set
if (tree.id) {
line += ' id="' + tree.id + '"';
// if anything input (input, textarea, select then add name too)
if (['input', 'textarea', 'select'].includes(tree.tag)) {
line += ' name="' + tree.id + '"';
}
}
// second CSS
if (tree.css.length > 0) {
line += ' class="';
tree.css.each(function(t) {
line += t + ' ';
});
// strip last space
line = line.slice(0, -1);
line += '"';
}
// options is anything key = "data"
if (tree.options) {
// ignores id, name, class as key
for (const [key, item] of Object.entries(tree.options)) {
if (!['id', 'name', 'class'].includes(key)) {
line += ' ' + key + '="' + item + '"';
}
}
}
// finish open tag
line += '>';
// push finished line
content.push(line);
// dive into sub tree to attach sub nodes
// NOTES: we cannot have content (text) AND sub nodes at the same level
// NODE takes preference over content
if (tree.sub.length > 0) {
tree.sub.each(function(t) {
content.push(phfo(t));
});
} else if (tree.content) {
content.push(tree.content);
}
// if not input close
if (tree.tag != 'input') {
content.push('</' + tree.tag + '>');
}
// combine to string
return content.join('');
}

View File

@@ -3,3 +3,27 @@
color: #a4a4a4;
font-size: 8px;
}
/* NEW VERSION with CSS key frame animation */
.progress {
width: 100px;
height: 100px;
background: rgba(255, 255, 255, 0.6);
border: 20px solid rgba(255, 255, 255 ,0.25);
border-left-color: rgba(3, 155, 229 ,1);
border-top-color: rgba(3, 155, 229 ,1);
border-radius: 50%;
display: inline-block;
animation: rotate 600ms infinite linear;
/* align */
left: 0;
top: 0;
position: absolute;
z-index: 100;
}
/* Animation for above progress */
@keyframes rotate {
to {
transform: rotate(1turn)
}
}

View File

@@ -1656,7 +1656,7 @@ class IO extends \CoreLibs\Basic
return false;
}
$not_write_update_array = array ();
return $this->dbWriteData_ext($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data);
return $this->dbWriteDataExt($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data);
}
// METHOD: dbWriteDataExt

View File

@@ -516,8 +516,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
} elseif (is_array($this->element_list[$element_list[$i]]["read_data"]) && $this->element_list[$element_list[$i]]["delete"]) {
// $this->debug('form_clean', "ID [$id] [$prfx.$pk_name]");
// $this->debug('form_clean', "ID arr: ".$this->print_ar($_POST[$id]));
// $this->debug('form_clean', "PK arr: ".$this->print_ar($_POST[$prfx.$pk_name]));
// $this->debug('form_clean', "ID arr: ".$this->printAr($_POST[$id]));
// $this->debug('form_clean', "PK arr: ".$this->printAr($_POST[$prfx.$pk_name]));
for ($j = 0, $j_max = count($_POST[$prfx.$pk_name]); $j < $j_max; $j ++) {
if (!$_POST[$remove_name[$i]][$j] && $_POST[$prfx.$pk_name][$j]) {
$q = "DELETE FROM ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$prfx.$pk_name][$j];
@@ -975,7 +975,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// $this->debug('edit_error_chk', "KEY: $prfx$key | count: ".count($_POST[$prfx.$key])." | M: $max");
// $this->debug('edit_error_chk', "K: ".$_POST[$prfx.$key]." | ".$_POST[$prfx.$key][0]);
}
$this->debug('post_array', $this->print_ar($_POST));
$this->debug('post_array', $this->printAr($_POST));
# check each row
for ($i = 0; $i < $max; $i ++) {
// either one of the post pks is set, or the mandatory
@@ -1305,7 +1305,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
foreach ($reference_array["elements"] as $el_name => $data_array) {
// this is only for reference_data part, at least one of the text fields need to be set for writing
$blow_write = array ();
// $this->debug('edit_error_query', "QUERY: ".$this->print_ar($_POST));
// $this->debug('edit_error_query', "QUERY: ".$this->printAr($_POST));
// go through all submitted data
// for ($i = 0; $i < count($_POST[$el_name]); $i ++)
for ($i = 0; $i < $max; $i ++) {
@@ -1542,7 +1542,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// generic data read in (counts for all rows)
// visible list data output
foreach ($this->element_list[$table_name]["elements"] as $el_name => $data_array) {
$this->debug('CFG', 'El: '.$el_name.' -> '.$this->print_ar($data_array));
$this->debug('CFG', 'El: '.$el_name.' -> '.$this->printAr($data_array));
// if the element name matches the read array, then set the table as a name prefix
$q_select[] = $el_name; // this is for reading the data
// prefix the name for any further data parts
@@ -1587,9 +1587,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
// $proto[$el_name] = $this->error ? $_POST[$el_name][(count($_POST[$el_name]) - 1)] : '';
}
// $this->debug('CFG DATA', 'Data: '.$this->print_ar($data));
// $this->debug('CFG PROTO', 'Proto: '.$this->print_ar($proto));
// $this->debug('CFG SELECT', 'Proto: '.$this->print_ar($q_select));
// $this->debug('CFG DATA', 'Data: '.$this->printAr($data));
// $this->debug('CFG PROTO', 'Proto: '.$this->printAr($proto));
// $this->debug('CFG SELECT', 'Proto: '.$this->printAr($q_select));
// query for reading in the data
$this->debug('edit_error', "ERR: ".$this->error);
// if we got a read data, build the read select for the read, and read out the "selected" data