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
This commit is contained in:
Clemens Schwaighofer
2019-06-27 14:41:56 +09:00
parent 436025dd22
commit 19a44d9340
9 changed files with 62 additions and 47 deletions

View File

@@ -26,6 +26,8 @@ DEFINE('LIBS', 'lib'.DS);
DEFINE('CONFIGS', 'configs'.DS); DEFINE('CONFIGS', 'configs'.DS);
// includes (strings, arrays for static, etc) // includes (strings, arrays for static, etc)
DEFINE('INCLUDES', 'includes'.DS); DEFINE('INCLUDES', 'includes'.DS);
// data folder (mostly in includes)
DEFINE('DATA', 'data'.DS);
// layout base path // layout base path
DEFINE('LAYOUT', 'layout'.DS); DEFINE('LAYOUT', 'layout'.DS);
// pic-root (compatible to CMS) // pic-root (compatible to CMS)
@@ -153,13 +155,6 @@ DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public'); DEFINE('TEST_SCHEMA', 'public');
DEFINE('LIVE_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 *****************/ /************* DB ACCESS *****************/
if (file_exists(BASE.CONFIGS.'config.db.inc')) { if (file_exists(BASE.CONFIGS.'config.db.inc')) {
require 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')) { if (file_exists(BASE.CONFIGS.'config.host.inc')) {
require 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 // set the USE_DATABASE var, if there is nothing set, we assume TRUE
$USE_DATABASE = defined('USE_DATABASE') ? USE_DATABASE : 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 DEFINE('SHOW_ALL_ERRORS', true); // show all errors if debug_all & show_error_handling are enabled
/************* GENERAL PAGE TITLE ********/ /************* GENERAL PAGE TITLE ********/
$G_TITLE = '<OVERALL PAGE TITLE>'; DEFINE('G_TITLE', '<OVERALL FALLBACK PAGE TITLE>');
/************ STYLE SHEETS / JS **********/ /************ STYLE SHEETS / JS **********/
$EDIT_STYLESHEET = 'edit.css'; DEFINE('ADMIN_STYLESHEET', 'edit.css');
$EDIT_JAVASCRIPT = 'edit.js'; DEFINE('ADMIN_JAVASCRIPT', 'edit.js');
DEFINE('STYLESHEET', 'frontend.css');
$STYLESHEET = 'frontend.css'; DEFINE('JAVASCRIPT', 'frontend.js');
$JAVASCRIPT = 'frontend.js';
// anything optional // anything optional
/************* INTERNAL ******************/ /************* INTERNAL ******************/

17
www/configs/config.path.inc Executable file
View File

@@ -0,0 +1,17 @@
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2018/10/11
* SHORT DESCRIPTION:
* configuration file for core path settings
* CSV target paths, and other download access URLS or paths needed
* HISTORY:
*********************************************************************/
// File and Folder paths
// ID is TARGET (first array element)
// $PATHS['test']['csv_path'] = '';
// $PATHS['test']['perl_bin'] = '';
// $PATHS['test']['redirect_url'] = '';
// __END__

View File

@@ -33,12 +33,14 @@ if (!isset($encoding)) {
if (session_id() && $_SESSION['DEFAULT_LANG']) { if (session_id() && $_SESSION['DEFAULT_LANG']) {
$lang = $_SESSION['DEFAULT_LANG']; $lang = $_SESSION['DEFAULT_LANG'];
} elseif (!$lang) { } elseif (!$lang) {
$lang = DEFAULT_LANG; $lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
} }
// end the stop of the output flow, but only if we didn't request a csv file download // end the stop of the output flow, but only if we didn't request a csv file download
if (array_key_exists('action', $_POST) && $_POST['action'] != 'download_csv') { if (array_key_exists('action', $_POST) && $_POST['action'] != 'download_csv') {
header("Content-type: text/html; charset=".$encoding); header("Content-type: text/html; charset=".$encoding);
ob_end_flush(); }
if ($AJAX_PAGE && !$ZIP_STREAM) {
header("Content-Type: application/json; charset=UTF-8");
} }
//------------------------------ basic variable settings start //------------------------------ basic variable settings start
@@ -59,6 +61,8 @@ $cms->menu_show_flag = 'main';
$cms->dbInfo(); $cms->dbInfo();
// set acl // set acl
$cms->acl = $login->acl; $cms->acl = $login->acl;
// flush
ob_end_flush();
//------------------------------ class init end //------------------------------ class init end
//------------------------------ logging start //------------------------------ logging start

View File

@@ -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->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); $cms->l->l10nReloadMOfile($lang, $cms->lang_dir);
// if we have login class // if we have login class
if ($login) { if ($login) {
$login->l->l10nReloadMOfile($lang, $cms->lang_dir); $login->l->l10nReloadMOfile($lang, $cms->lang_dir);
} }
@@ -118,13 +118,15 @@ if (!$AJAX_PAGE) {
} }
} }
// if we can't find it, dump it // 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); unset($TEMPLATE_TRANSLATE);
} }
} }
// $cms->debug("LANGUAGE", "L: $lang | ".$cms->lang_dir." | MO File: ".$cms->l->mofile); // $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("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__ // __END__

View File

@@ -61,11 +61,11 @@ $cms->HEADER['CSS'] = CSS;
$cms->HEADER['JS'] = JS; $cms->HEADER['JS'] = JS;
$cms->HEADER['ENCODING'] = $encoding; $cms->HEADER['ENCODING'] = $encoding;
$cms->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; $cms->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
$cms->HEADER['STYLESHEET'] = $EDIT_STYLESHEET; $cms->HEADER['STYLESHEET'] = isset($ADMIN_STYLESHEET) ? $ADMIN_STYLESHEET : ADMIN_STYLESHEET;
$cms->HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; $cms->HEADER['JAVASCRIPT'] = isset($ADMIN_JAVASCRIPT) ? $ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT;
// html title // html title
$cms->HEADER['HTML_TITLE'] = (!isset($L_TITLE) || !$L_TITLE) ? $cms->l->__($G_TITLE) : $cms->l->__($L_TITLE); $cms->HEADER['HTML_TITLE'] = isset($L_TITLE) ? $cms->l->__($L_TITLE) : $cms->l->__(G_TITLE);
$cms->DATA['table_width'] = $PAGE_WIDTH ? $PAGE_WIDTH : PAGE_WIDTH; $cms->DATA['table_width'] = isset($PAGE_WIDTH) ? $PAGE_WIDTH : PAGE_WIDTH;
// messages = array('msg' =>, 'class' => 'error/warning/...') // messages = array('msg' =>, 'class' => 'error/warning/...')
$cms->DATA['messages'] = $cms->messages; $cms->DATA['messages'] = $cms->messages;

View File

@@ -106,6 +106,11 @@ $data = array (
// log action // log action
EditLog('Edit Submit', serialize($data)); 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') { if ($form->my_page_name == 'edit_order') {
// get is for "table_name" and "where" only // get is for "table_name" and "where" only
$table_name = isset($_GET['table_name']) ? $_GET['table_name'] : ''; $table_name = isset($_GET['table_name']) ? $_GET['table_name'] : '';
@@ -176,18 +181,12 @@ if ($form->my_page_name == 'edit_order') {
); );
} // while read data ... } // 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 // html title
$HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE); $HEADER['HTML_TITLE'] = $form->l->__('Edit Order');
// error msg // error msg
if ($error) { if ($error) {
$messages[] = array('msg' => $msg, 'class' => 'error', 'width' => '100%'); $messages[] = array ('msg' => $msg, 'class' => 'error', 'width' => '100%');
} }
$DATA['form_error_msg'] = $messages; $DATA['form_error_msg'] = $messages;
@@ -235,13 +234,6 @@ if ($form->my_page_name == 'edit_order') {
$form->formProcedureDelete(); $form->formProcedureDelete();
$form->formProcedureDeleteFromElementList($element_list, $remove_name); $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; $DATA['table_width'] = $table_width;
// write out error / status messages // write out error / status messages
@@ -314,7 +306,7 @@ if ($form->my_page_name == 'edit_order') {
$DATA['page_name'] = $menuarray[$position]["page_name"]; $DATA['page_name'] = $menuarray[$position]["page_name"];
$L_TITLE = $DATA['page_name']; $L_TITLE = $DATA['page_name'];
// html title // html title
$HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE)); $HEADER['HTML_TITLE'] = $form->l->__($L_TITLE);
// END MENU // END MENU
// LOAD AND NEW // LOAD AND NEW
$DATA['load'] = $form->formCreateLoad(); $DATA['load'] = $form->formCreateLoad();
@@ -445,7 +437,7 @@ if (is_dir(BASE.TEMPLATES_C)) {
if (is_dir(BASE.CACHE)) { if (is_dir(BASE.CACHE)) {
$smarty->setCacheDir(BASE.CACHE); $smarty->setCacheDir(BASE.CACHE);
} }
$smarty->display($EDIT_TEMPLATE, $lang, $lang); $smarty->display($EDIT_TEMPLATE, 'editAdmin_'.$lang, 'editAdmin_'.$lang);
// debug output // debug output
echo $login->printErrorMsg(); echo $login->printErrorMsg();

View File

@@ -15,12 +15,14 @@
{if $STYLESHEET} {if $STYLESHEET}
<link rel=stylesheet type="text/css" href="{$css}{$STYLESHEET}"> <link rel=stylesheet type="text/css" href="{$css}{$STYLESHEET}">
{/if} {/if}
{if $JAVASCRIPT} <script language="JavaScript">
<script language="JavaScript" src="{$js}{$JAVASCRIPT}"></script> <!--
{/if} function pop(theURL, winName, features) {
{if $DATE_JAVASCRIPT} winName = window.open(theURL, winName, features);
<script language="JavaScript" src="{$JS}{$DATE_JAVASCRIPT}"></script> winName.focus();
{/if} }
//-->
</script>
</head> </head>
<body> <body>
<table width="{$table_width}" border="0" cellpadding="0" cellspacing="1"> <table width="{$table_width}" border="0" cellpadding="0" cellspacing="1">

View File

@@ -14,7 +14,7 @@ if (!DEBUG) {
// METHOD: pop // METHOD: pop
// PARAMS: url, window name, features // PARAMS: url, window name, features
// RETURN: none // 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) { function pop(theURL, winName, features) {
winName = window.open(theURL, winName, features); winName = window.open(theURL, winName, features);
winName.focus(); winName.focus();

View File

@@ -1241,8 +1241,8 @@ class Basic
// DESC : calculates the bytes based on a string with nnG, nnM, etc // DESC : calculates the bytes based on a string with nnG, nnM, etc
public static function stringByteFormat($number) public static function stringByteFormat($number)
{ {
$number = (int)trim($number);
$last = strtolower($number[strlen($number) - 1]); $last = strtolower($number[strlen($number) - 1]);
$number = (int)trim($number);
switch ($last) { switch ($last) {
case 't': case 't':
$number *= 1024; $number *= 1024;