From 19a44d93401572ab6454b8e343048acf5fa451a3 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 27 Jun 2019 14:41:56 +0900 Subject: [PATCH] Clean up edit_* pages, some config changes, bug fixes - Class Basic convert string to bytes fix - admin edit_* pages do not need JS except pop call, moved that into the template and do not load any other JS anymore - changed the EDIT_STYLESHEET/JAVACSRIPT names to ADMIN_ to give them the proper name that they are admin based functions - paths are in an extra config file - plan on moving edit_* css rules into a special CSS file just for this --- www/configs/config.inc | 24 +++++++++----------- www/configs/config.path.inc | 17 ++++++++++++++ www/includes/admin_header.inc | 8 +++++-- www/includes/admin_set_paths.inc | 8 ++++--- www/includes/admin_smarty.inc | 8 +++---- www/includes/edit_base.inc | 26 ++++++++-------------- www/includes/templates/admin/edit_body.tpl | 14 +++++++----- www/layout/admin/javascript/edit.pt.js | 2 +- www/lib/CoreLibs/Basic.inc | 2 +- 9 files changed, 62 insertions(+), 47 deletions(-) create mode 100755 www/configs/config.path.inc diff --git a/www/configs/config.inc b/www/configs/config.inc index f4444fa6..db1dc3f9 100644 --- a/www/configs/config.inc +++ b/www/configs/config.inc @@ -26,6 +26,8 @@ DEFINE('LIBS', 'lib'.DS); DEFINE('CONFIGS', 'configs'.DS); // includes (strings, arrays for static, etc) DEFINE('INCLUDES', 'includes'.DS); +// data folder (mostly in includes) +DEFINE('DATA', 'data'.DS); // layout base path DEFINE('LAYOUT', 'layout'.DS); // pic-root (compatible to CMS) @@ -153,13 +155,6 @@ DEFINE('DEV_SCHEMA', 'public'); DEFINE('TEST_SCHEMA', 'public'); DEFINE('LIVE_SCHEMA', 'public'); -/************* OTHER PATHS *****************/ -// File and Folder paths -// ID is TARGET (first array element) -// $PATHS['test']['csv_path'] = ''; -// $PATHS['test']['perl_bin'] = ''; -// $PATHS['test']['redirect_url'] = ''; - /************* DB ACCESS *****************/ if (file_exists(BASE.CONFIGS.'config.db.inc')) { require BASE.CONFIGS.'config.db.inc'; @@ -168,6 +163,10 @@ if (file_exists(BASE.CONFIGS.'config.db.inc')) { if (file_exists(BASE.CONFIGS.'config.host.inc')) { require BASE.CONFIGS.'config.host.inc'; } +/************* OTHER PATHS *****************/ +if (file_exists(BASE.CONFIGS.'config.path.inc')) { + require BASE.CONFIGS.'config.path.inc'; +} // set the USE_DATABASE var, if there is nothing set, we assume TRUE $USE_DATABASE = defined('USE_DATABASE') ? USE_DATABASE : true; @@ -213,14 +212,13 @@ DEFINE('SITE_LANG', $SITE_LANG[$HOST_NAME]); DEFINE('SHOW_ALL_ERRORS', true); // show all errors if debug_all & show_error_handling are enabled /************* GENERAL PAGE TITLE ********/ -$G_TITLE = ''; +DEFINE('G_TITLE', ''); /************ STYLE SHEETS / JS **********/ -$EDIT_STYLESHEET = 'edit.css'; -$EDIT_JAVASCRIPT = 'edit.js'; - -$STYLESHEET = 'frontend.css'; -$JAVASCRIPT = 'frontend.js'; +DEFINE('ADMIN_STYLESHEET', 'edit.css'); +DEFINE('ADMIN_JAVASCRIPT', 'edit.js'); +DEFINE('STYLESHEET', 'frontend.css'); +DEFINE('JAVASCRIPT', 'frontend.js'); // anything optional /************* INTERNAL ******************/ diff --git a/www/configs/config.path.inc b/www/configs/config.path.inc new file mode 100755 index 00000000..6bd569f9 --- /dev/null +++ b/www/configs/config.path.inc @@ -0,0 +1,17 @@ +menu_show_flag = 'main'; $cms->dbInfo(); // set acl $cms->acl = $login->acl; +// flush +ob_end_flush(); //------------------------------ class init end //------------------------------ logging start diff --git a/www/includes/admin_set_paths.inc b/www/includes/admin_set_paths.inc index c32209d4..1911d561 100644 --- a/www/includes/admin_set_paths.inc +++ b/www/includes/admin_set_paths.inc @@ -91,7 +91,7 @@ if (false === strstr(BASE.INCLUDES.LANG.CONTENT_PATH, $cms->lang_dir) || ) { $cms->debug('LANG', 'Orig: '.BASE.INCLUDES.LANG.CONTENT_PATH.', New: '.$cms->lang_dir.' | Orig Lang: '.(defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG).', New Lang: '.$lang); $cms->l->l10nReloadMOfile($lang, $cms->lang_dir); - // if we have login class + // if we have login class if ($login) { $login->l->l10nReloadMOfile($lang, $cms->lang_dir); } @@ -118,13 +118,15 @@ if (!$AJAX_PAGE) { } } // if we can't find it, dump it - if (!file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_TRANSLATE)) { + if ($smarty && !file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_TRANSLATE)) { unset($TEMPLATE_TRANSLATE); } } // $cms->debug("LANGUAGE", "L: $lang | ".$cms->lang_dir." | MO File: ".$cms->l->mofile); $cms->debug("LANGUAGE", "SL: ".$_SESSION['DEFAULT_CHARSET']." | ".$_SESSION['LANG']." | ".$_SESSION['DEFAULT_LANG']); -$cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]); +if ($smarty) { + $cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]); +} // __END__ diff --git a/www/includes/admin_smarty.inc b/www/includes/admin_smarty.inc index 8da9abcc..17d638d8 100644 --- a/www/includes/admin_smarty.inc +++ b/www/includes/admin_smarty.inc @@ -61,11 +61,11 @@ $cms->HEADER['CSS'] = CSS; $cms->HEADER['JS'] = JS; $cms->HEADER['ENCODING'] = $encoding; $cms->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; -$cms->HEADER['STYLESHEET'] = $EDIT_STYLESHEET; -$cms->HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; +$cms->HEADER['STYLESHEET'] = isset($ADMIN_STYLESHEET) ? $ADMIN_STYLESHEET : ADMIN_STYLESHEET; +$cms->HEADER['JAVASCRIPT'] = isset($ADMIN_JAVASCRIPT) ? $ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT; // html title -$cms->HEADER['HTML_TITLE'] = (!isset($L_TITLE) || !$L_TITLE) ? $cms->l->__($G_TITLE) : $cms->l->__($L_TITLE); -$cms->DATA['table_width'] = $PAGE_WIDTH ? $PAGE_WIDTH : PAGE_WIDTH; +$cms->HEADER['HTML_TITLE'] = isset($L_TITLE) ? $cms->l->__($L_TITLE) : $cms->l->__(G_TITLE); +$cms->DATA['table_width'] = isset($PAGE_WIDTH) ? $PAGE_WIDTH : PAGE_WIDTH; // messages = array('msg' =>, 'class' => 'error/warning/...') $cms->DATA['messages'] = $cms->messages; diff --git a/www/includes/edit_base.inc b/www/includes/edit_base.inc index 3906da6c..2dfc2517 100644 --- a/www/includes/edit_base.inc +++ b/www/includes/edit_base.inc @@ -106,6 +106,11 @@ $data = array ( // log action EditLog('Edit Submit', serialize($data)); +// define all needed smarty stuff for the general HTML/page building +$HEADER['CSS'] = CSS; +$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; +$HEADER['STYLESHEET'] = isset($ADMIN_STYLESHEET) ? $ADMIN_STYLESHEET : ADMIN_STYLESHEET; + if ($form->my_page_name == 'edit_order') { // get is for "table_name" and "where" only $table_name = isset($_GET['table_name']) ? $_GET['table_name'] : ''; @@ -176,18 +181,12 @@ if ($form->my_page_name == 'edit_order') { ); } // while read data ... - // define all needed smarty stuff for the general HTML/page building - $HEADER['CSS'] = CSS; - $HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; - $HEADER['JS'] = JS; - $HEADER['STYLESHEET'] = $EDIT_STYLESHEET; - $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; // html title - $HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE); + $HEADER['HTML_TITLE'] = $form->l->__('Edit Order'); // error msg if ($error) { - $messages[] = array('msg' => $msg, 'class' => 'error', 'width' => '100%'); + $messages[] = array ('msg' => $msg, 'class' => 'error', 'width' => '100%'); } $DATA['form_error_msg'] = $messages; @@ -235,13 +234,6 @@ if ($form->my_page_name == 'edit_order') { $form->formProcedureDelete(); $form->formProcedureDeleteFromElementList($element_list, $remove_name); - // define all needed smarty stuff for the general HTML/page building - $HEADER['CSS'] = CSS; - $HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; - $HEADER['JS'] = JS; - $HEADER['STYLESHEET'] = $EDIT_STYLESHEET; - $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; - $DATA['table_width'] = $table_width; // write out error / status messages @@ -314,7 +306,7 @@ if ($form->my_page_name == 'edit_order') { $DATA['page_name'] = $menuarray[$position]["page_name"]; $L_TITLE = $DATA['page_name']; // html title - $HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE)); + $HEADER['HTML_TITLE'] = $form->l->__($L_TITLE); // END MENU // LOAD AND NEW $DATA['load'] = $form->formCreateLoad(); @@ -445,7 +437,7 @@ if (is_dir(BASE.TEMPLATES_C)) { if (is_dir(BASE.CACHE)) { $smarty->setCacheDir(BASE.CACHE); } -$smarty->display($EDIT_TEMPLATE, $lang, $lang); +$smarty->display($EDIT_TEMPLATE, 'editAdmin_'.$lang, 'editAdmin_'.$lang); // debug output echo $login->printErrorMsg(); diff --git a/www/includes/templates/admin/edit_body.tpl b/www/includes/templates/admin/edit_body.tpl index e50e369a..c2d1074f 100644 --- a/www/includes/templates/admin/edit_body.tpl +++ b/www/includes/templates/admin/edit_body.tpl @@ -15,12 +15,14 @@ {if $STYLESHEET} {/if} - {if $JAVASCRIPT} - - {/if} - {if $DATE_JAVASCRIPT} - - {/if} + diff --git a/www/layout/admin/javascript/edit.pt.js b/www/layout/admin/javascript/edit.pt.js index c38e0675..4af20ca1 100644 --- a/www/layout/admin/javascript/edit.pt.js +++ b/www/layout/admin/javascript/edit.pt.js @@ -14,7 +14,7 @@ if (!DEBUG) { // METHOD: pop // PARAMS: url, window name, features // RETURN: none -// DESC : opens a popup window with winNAme and given features (string) +// DESC : opens a popup window with winName and given features (string) function pop(theURL, winName, features) { winName = window.open(theURL, winName, features); winName.focus(); diff --git a/www/lib/CoreLibs/Basic.inc b/www/lib/CoreLibs/Basic.inc index 1c5dd540..a5bfdfe2 100644 --- a/www/lib/CoreLibs/Basic.inc +++ b/www/lib/CoreLibs/Basic.inc @@ -1241,8 +1241,8 @@ class Basic // DESC : calculates the bytes based on a string with nnG, nnM, etc public static function stringByteFormat($number) { - $number = (int)trim($number); $last = strtolower($number[strlen($number) - 1]); + $number = (int)trim($number); switch ($last) { case 't': $number *= 1024;