Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04b47574eb | ||
|
|
ecc52e2dbd | ||
|
|
12e335c69c | ||
|
|
3ae3b1b761 | ||
|
|
3c9ca025f5 |
@@ -24,12 +24,10 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
}
|
}
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest';
|
$LOG_FILE_ID = 'classTest';
|
||||||
// set language for l10n
|
|
||||||
$lang = 'en_utf8';
|
|
||||||
|
|
||||||
// init login & backend class
|
// init login & backend class
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG, $lang);
|
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
||||||
$basic = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
|
$basic = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||||
$basic->dbInfo(true);
|
$basic->dbInfo(true);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ $SET_SESSION_NAME = EDIT_SESSION_NAME;
|
|||||||
|
|
||||||
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
||||||
|
|
||||||
$lang = 'ja_utf8';
|
$base = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||||
$base = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
|
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
if ($base->getConnectionStatus()) {
|
if ($base->getConnectionStatus()) {
|
||||||
die("Cannot connect to database");
|
die("Cannot connect to database");
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ if ($DEBUG_ALL && $ENABLE_ERROR_HANDLING) {
|
|||||||
include BASE.LIBS."Error.Handling.php";
|
include BASE.LIBS."Error.Handling.php";
|
||||||
}
|
}
|
||||||
// predefine vars
|
// predefine vars
|
||||||
$LANG = '';
|
|
||||||
$messages = array();
|
$messages = array();
|
||||||
// import all POST vars
|
// import all POST vars
|
||||||
// extract($_POST, EXTR_SKIP);
|
// extract($_POST, EXTR_SKIP);
|
||||||
@@ -38,12 +37,6 @@ if (!isset($ZIP_STREAM)) {
|
|||||||
if (!isset($ENCODING) || !$ENCODING) {
|
if (!isset($ENCODING) || !$ENCODING) {
|
||||||
$ENCODING = DEFAULT_ENCODING;
|
$ENCODING = DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
// set the default lang, if not given
|
|
||||||
if (session_id() && isset($_SESSION['DEFAULT_LANG']) && $_SESSION['DEFAULT_LANG']) {
|
|
||||||
$LANG = $_SESSION['DEFAULT_LANG'];
|
|
||||||
} else {
|
|
||||||
$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 (isset($_POST['action']) && $_POST['action'] != 'download_csv' && !$AJAX_PAGE) {
|
if (isset($_POST['action']) && $_POST['action'] != 'download_csv' && !$AJAX_PAGE) {
|
||||||
header("Content-type: text/html; charset=".$ENCODING);
|
header("Content-type: text/html; charset=".$ENCODING);
|
||||||
@@ -55,15 +48,11 @@ if ($AJAX_PAGE && !$ZIP_STREAM) {
|
|||||||
|
|
||||||
//------------------------------ class init start
|
//------------------------------ class init start
|
||||||
// login & page access check
|
// login & page access check
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG, $LANG);
|
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
||||||
// post login lang check
|
|
||||||
if (isset($_SESSION['DEFAULT_LANG'])) {
|
|
||||||
$LANG = $_SESSION['DEFAULT_LANG'];
|
|
||||||
}
|
|
||||||
// create smarty object
|
// create smarty object
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend($LANG);
|
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||||
// create new DB class
|
// create new DB class
|
||||||
$cms = new CoreLibs\Admin\Backend(DB_CONFIG, $LANG);
|
$cms = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||||
// the menu show flag (what menu to show)
|
// the menu show flag (what menu to show)
|
||||||
$cms->menu_show_flag = 'main';
|
$cms->menu_show_flag = 'main';
|
||||||
// db nfo
|
// db nfo
|
||||||
|
|||||||
@@ -36,23 +36,19 @@ if (!DEBUG) {
|
|||||||
$ECHO_ALL = 0;
|
$ECHO_ALL = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default lang if not set otherwise
|
|
||||||
if (!isset($lang)) {
|
|
||||||
$lang = DEFAULT_LANG;
|
|
||||||
}
|
|
||||||
// should be utf8
|
// should be utf8
|
||||||
header("Content-type: text/html; charset=".DEFAULT_ENCODING);
|
header("Content-type: text/html; charset=".DEFAULT_ENCODING);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG, $lang);
|
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
||||||
|
|
||||||
// create form class
|
// create form class
|
||||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $lang);
|
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG);
|
||||||
if ($form->mobile_phone) {
|
if ($form->mobile_phone) {
|
||||||
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// smarty template engine (extended Translation version)
|
// smarty template engine (extended Translation version)
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend($lang);
|
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||||
|
|
||||||
// $form->debug('POST', $form->printAr($_POST));
|
// $form->debug('POST', $form->printAr($_POST));
|
||||||
|
|
||||||
@@ -453,7 +449,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, 'editAdmin_'.$lang, 'editAdmin_'.$lang);
|
$smarty->display($EDIT_TEMPLATE, 'editAdmin_'.$smarty->lang, 'editAdmin_'.$smarty->lang);
|
||||||
|
|
||||||
// debug output
|
// debug output
|
||||||
echo $login->printErrorMsg();
|
echo $login->printErrorMsg();
|
||||||
|
|||||||
@@ -115,10 +115,9 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
/**
|
/**
|
||||||
* constructor, does ALL, opens db, works through connection checks, closes itself
|
* constructor, does ALL, opens db, works through connection checks, closes itself
|
||||||
* @param array $db_config db config array
|
* @param array $db_config db config array
|
||||||
* @param string $lang language string (default en_utf8)
|
|
||||||
* @param int $set_control_flag class variable check flags
|
* @param int $set_control_flag class variable check flags
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config, string $lang = 'en_utf8', int $set_control_flag = 0)
|
public function __construct(array $db_config, int $set_control_flag = 0)
|
||||||
{
|
{
|
||||||
// log login data for this class only
|
// log login data for this class only
|
||||||
$this->log_per_class = 1;
|
$this->log_per_class = 1;
|
||||||
@@ -151,7 +150,13 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
// set global is ajax page for if we show the data directly, or need to pass it back
|
// set global is ajax page for if we show the data directly, or need to pass it back
|
||||||
// to the continue AJAX class for output back to the user
|
// to the continue AJAX class for output back to the user
|
||||||
$this->login_is_ajax_page = isset($GLOBALS['AJAX_PAGE']) && $GLOBALS['AJAX_PAGE'] ? true : false;
|
$this->login_is_ajax_page = isset($GLOBALS['AJAX_PAGE']) && $GLOBALS['AJAX_PAGE'] ? true : false;
|
||||||
|
// set the default lang
|
||||||
|
$lang = 'en_utf8';
|
||||||
|
if (session_id() && isset($_SESSION['DEFAULT_LANG']) && $_SESSION['DEFAULT_LANG']) {
|
||||||
|
$lang = $_SESSION['DEFAULT_LANG'];
|
||||||
|
} else {
|
||||||
|
$lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||||
|
}
|
||||||
$this->l = new \CoreLibs\Language\L10n($lang);
|
$this->l = new \CoreLibs\Language\L10n($lang);
|
||||||
|
|
||||||
// if we have a search path we need to set it, to use the correct DB to login
|
// if we have a search path we need to set it, to use the correct DB to login
|
||||||
|
|||||||
@@ -57,26 +57,25 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
public $lang;
|
public $lang;
|
||||||
public $lang_short;
|
public $lang_short;
|
||||||
public $encoding;
|
public $encoding;
|
||||||
|
// language
|
||||||
|
public $l;
|
||||||
// smarty publics [end processing in smarty class]
|
// smarty publics [end processing in smarty class]
|
||||||
public $DATA;
|
public $DATA;
|
||||||
public $HEADER;
|
public $HEADER;
|
||||||
public $DEBUG_DATA;
|
public $DEBUG_DATA;
|
||||||
public $CONTENT_DATA;
|
public $CONTENT_DATA;
|
||||||
// language
|
|
||||||
public $l;
|
|
||||||
|
|
||||||
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
||||||
/**
|
/**
|
||||||
* main class constructor
|
* main class constructor
|
||||||
* @param array $db_config db config array
|
* @param array $db_config db config array
|
||||||
* @param string $lang language string
|
|
||||||
* @param int|integer $set_control_flag class variable check flag
|
* @param int|integer $set_control_flag class variable check flag
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config, string $lang, int $set_control_flag = 0)
|
public function __construct(array $db_config, int $set_control_flag = 0)
|
||||||
{
|
{
|
||||||
$this->setLangEncoding();
|
$this->setLangEncoding();
|
||||||
// get the language sub class & init it
|
// get the language sub class & init it
|
||||||
$this->l = new \CoreLibs\Language\L10n($lang);
|
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
||||||
|
|
||||||
// init the database class
|
// init the database class
|
||||||
parent::__construct($db_config, $set_control_flag);
|
parent::__construct($db_config, $set_control_flag);
|
||||||
@@ -104,11 +103,9 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
|
|
||||||
// INTERNAL METHODS |===============================================>
|
// INTERNAL METHODS |===============================================>
|
||||||
|
|
||||||
|
|
||||||
// PUBLIC METHODS |=================================================>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the language encoding and language settings
|
* set the language encoding and language settings
|
||||||
|
* use $OVERRIDE_LANG to override all language settings
|
||||||
* the default charset from _SESSION login or from
|
* the default charset from _SESSION login or from
|
||||||
* config DEFAULT ENCODING
|
* config DEFAULT ENCODING
|
||||||
* the lang full name for mo loading from _SESSION login
|
* the lang full name for mo loading from _SESSION login
|
||||||
@@ -116,7 +113,7 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
* creates short lang (only first two chars) from the lang
|
* creates short lang (only first two chars) from the lang
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setLangEncoding(): void
|
private function setLangEncoding(): void
|
||||||
{
|
{
|
||||||
// just emergency fallback for language
|
// just emergency fallback for language
|
||||||
// set encoding
|
// set encoding
|
||||||
@@ -125,10 +122,14 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
} else {
|
} else {
|
||||||
$this->encoding = DEFAULT_ENCODING;
|
$this->encoding = DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
// just emergency fallback for language
|
// gobal override
|
||||||
if (isset($_SESSION['DEFAULT_LANG'])) {
|
if (isset($GLOBALS['OVERRIDE_LANG'])) {
|
||||||
|
$this->lang = $GLOBALS['OVERRIDE_LANG'];
|
||||||
|
} elseif (isset($_SESSION['DEFAULT_LANG'])) {
|
||||||
|
// session (login)
|
||||||
$this->lang = $_SESSION['DEFAULT_LANG'];
|
$this->lang = $_SESSION['DEFAULT_LANG'];
|
||||||
} else {
|
} else {
|
||||||
|
// mostly default SITE LANG or DEFAULT LANG
|
||||||
$this->lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
$this->lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||||
}
|
}
|
||||||
// create the char lang encoding
|
// create the char lang encoding
|
||||||
@@ -137,6 +138,8 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
$this->lang_dir = BASE.INCLUDES.LANG.CONTENT_PATH;
|
$this->lang_dir = BASE.INCLUDES.LANG.CONTENT_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PUBLIC METHODS |=================================================>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set internal ACL from login ACL
|
* set internal ACL from login ACL
|
||||||
* @param array $acl login acl array
|
* @param array $acl login acl array
|
||||||
@@ -206,42 +209,6 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
$this->dbExec($q, 'NULL');
|
$this->dbExec($q, 'NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* helper function for PHP file upload error messgaes to messge string
|
|
||||||
* @param int $error_code integer _FILE upload error code
|
|
||||||
* @return string message string, translated
|
|
||||||
*/
|
|
||||||
public function fileUploadErrorMessage(int $error_code): string
|
|
||||||
{
|
|
||||||
switch ($error_code) {
|
|
||||||
case UPLOAD_ERR_INI_SIZE:
|
|
||||||
$message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_FORM_SIZE:
|
|
||||||
$message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_PARTIAL:
|
|
||||||
$message = 'The uploaded file was only partially uploaded';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_NO_FILE:
|
|
||||||
$message = 'No file was uploaded';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_NO_TMP_DIR:
|
|
||||||
$message = 'Missing a temporary folder';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_CANT_WRITE:
|
|
||||||
$message = 'Failed to write file to disk';
|
|
||||||
break;
|
|
||||||
case UPLOAD_ERR_EXTENSION:
|
|
||||||
$message = 'File upload stopped by extension';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$message = 'Unknown upload error';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $this->l->__($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* menu creater (from login menu session pages)
|
* menu creater (from login menu session pages)
|
||||||
* @param int $flag visible flag trigger
|
* @param int $flag visible flag trigger
|
||||||
|
|||||||
@@ -891,6 +891,42 @@ class Basic
|
|||||||
return "<pre>".print_r($array, true)."</pre>";
|
return "<pre>".print_r($array, true)."</pre>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* helper function for PHP file upload error messgaes to messge string
|
||||||
|
* @param int $error_code integer _FILE upload error code
|
||||||
|
* @return string message string, translated
|
||||||
|
*/
|
||||||
|
public function fileUploadErrorMessage(int $error_code): string
|
||||||
|
{
|
||||||
|
switch ($error_code) {
|
||||||
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
|
$message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
|
$message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_PARTIAL:
|
||||||
|
$message = 'The uploaded file was only partially uploaded';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_NO_FILE:
|
||||||
|
$message = 'No file was uploaded';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_NO_TMP_DIR:
|
||||||
|
$message = 'Missing a temporary folder';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_CANT_WRITE:
|
||||||
|
$message = 'Failed to write file to disk';
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_EXTENSION:
|
||||||
|
$message = 'File upload stopped by extension';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$message = 'Unknown upload error';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
// ****** DEBUG/ERROR FUNCTIONS ******
|
// ****** DEBUG/ERROR FUNCTIONS ******
|
||||||
|
|
||||||
// ****** RANDOM KEY GEN ******
|
// ****** RANDOM KEY GEN ******
|
||||||
@@ -1200,12 +1236,22 @@ class Basic
|
|||||||
$path[] = $key_lookin;
|
$path[] = $key_lookin;
|
||||||
} else {
|
} else {
|
||||||
foreach ($haystack as $key => $val) {
|
foreach ($haystack as $key => $val) {
|
||||||
if (is_scalar($val) && $val === $needle && empty($key_lookin)) {
|
if (is_scalar($val) &&
|
||||||
break;
|
$val === $needle &&
|
||||||
} elseif (is_scalar($val) && !empty($key_lookin) && $key === $key_lookin && $val == $needle) {
|
empty($key_lookin)
|
||||||
|
) {
|
||||||
$path[] = $key;
|
$path[] = $key;
|
||||||
break;
|
break;
|
||||||
} elseif (is_array($val) && $path = Basic::arraySearchRecursive($needle, $val, $key_lookin)) {
|
} elseif (is_scalar($val) &&
|
||||||
|
!empty($key_lookin) &&
|
||||||
|
$key === $key_lookin &&
|
||||||
|
$val == $needle
|
||||||
|
) {
|
||||||
|
$path[] = $key;
|
||||||
|
break;
|
||||||
|
} elseif (is_array($val) &&
|
||||||
|
$path = Basic::arraySearchRecursive($needle, $val, $key_lookin)
|
||||||
|
) {
|
||||||
array_unshift($path, $key);
|
array_unshift($path, $key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1344,6 +1390,21 @@ class Basic
|
|||||||
return $merged;
|
return $merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* correct array_diff that does an actualy difference between two arrays.
|
||||||
|
* array_diff only checks elements from A that are not in B, but not the
|
||||||
|
* other way around.
|
||||||
|
* Note that like array_diff this only checks first level values not keys
|
||||||
|
* @param array $a array to compare a
|
||||||
|
* @param array $b array to compare b
|
||||||
|
* @return array array with missing elements from a & b
|
||||||
|
*/
|
||||||
|
public static function arrayDiff(array $a, array $b): array
|
||||||
|
{
|
||||||
|
$intersect = array_intersect($a, $b);
|
||||||
|
return array_merge(array_diff($a, $intersect), array_diff($b, $intersect));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search for the needle array elements in haystack and return the ones found as an array,
|
* search for the needle array elements in haystack and return the ones found as an array,
|
||||||
* is there nothing found, it returns FALSE (boolean)
|
* is there nothing found, it returns FALSE (boolean)
|
||||||
|
|||||||
@@ -242,6 +242,11 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
public $security_level;
|
public $security_level;
|
||||||
// layout publics
|
// layout publics
|
||||||
public $table_width;
|
public $table_width;
|
||||||
|
// internal lang & encoding vars
|
||||||
|
public $lang_dir = '';
|
||||||
|
public $lang;
|
||||||
|
public $lang_short;
|
||||||
|
public $encoding;
|
||||||
// language
|
// language
|
||||||
public $l;
|
public $l;
|
||||||
|
|
||||||
@@ -251,15 +256,15 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
/**
|
/**
|
||||||
* construct form generator
|
* construct form generator
|
||||||
* @param array $db_config db config array
|
* @param array $db_config db config array
|
||||||
* @param string $lang interface language
|
|
||||||
* @param int|integer $table_width table/div width (default 750)
|
* @param int|integer $table_width table/div width (default 750)
|
||||||
* @param int|integer $set_control_flag basic class set/get variable error flags
|
* @param int|integer $set_control_flag basic class set/get variable error flags
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config, string $lang, int $table_width = 750, int $set_control_flag = 0)
|
public function __construct(array $db_config, int $table_width = 750, int $set_control_flag = 0)
|
||||||
{
|
{
|
||||||
$this->my_page_name = $this->getPageName(1);
|
$this->my_page_name = $this->getPageName(1);
|
||||||
|
$this->setLangEncoding();
|
||||||
// init the language class
|
// init the language class
|
||||||
$this->l = new \CoreLibs\Language\L10n($lang);
|
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
||||||
// load config array
|
// load config array
|
||||||
// get table array definitions for current page name
|
// get table array definitions for current page name
|
||||||
// WARNING: auto spl load does not work with this as it is an array and not a function/object
|
// WARNING: auto spl load does not work with this as it is an array and not a function/object
|
||||||
@@ -348,6 +353,45 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
parent::__destruct();
|
parent::__destruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INTERNAL METHODS |===============================================>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ORIGINAL in \CoreLibs\Admin\Backend
|
||||||
|
* set the language encoding and language settings
|
||||||
|
* the default charset from _SESSION login or from
|
||||||
|
* config DEFAULT ENCODING
|
||||||
|
* the lang full name for mo loading from _SESSION login
|
||||||
|
* or SITE LANG or DEFAULT LANG from config
|
||||||
|
* creates short lang (only first two chars) from the lang
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function setLangEncoding(): void
|
||||||
|
{
|
||||||
|
// just emergency fallback for language
|
||||||
|
// set encoding
|
||||||
|
if (isset($_SESSION['DEFAULT_CHARSET'])) {
|
||||||
|
$this->encoding = $_SESSION['DEFAULT_CHARSET'];
|
||||||
|
} else {
|
||||||
|
$this->encoding = DEFAULT_ENCODING;
|
||||||
|
}
|
||||||
|
// gobal override
|
||||||
|
if (isset($GLOBALS['OVERRIDE_LANG'])) {
|
||||||
|
$this->lang = $GLOBALS['OVERRIDE_LANG'];
|
||||||
|
} elseif (isset($_SESSION['DEFAULT_LANG'])) {
|
||||||
|
// session (login)
|
||||||
|
$this->lang = $_SESSION['DEFAULT_LANG'];
|
||||||
|
} else {
|
||||||
|
// mostly default SITE LANG or DEFAULT LANG
|
||||||
|
$this->lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||||
|
}
|
||||||
|
// create the char lang encoding
|
||||||
|
$this->lang_short = substr($this->lang, 0, 2);
|
||||||
|
// set the language folder
|
||||||
|
$this->lang_dir = BASE.INCLUDES.LANG.CONTENT_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC METHODS |=================================================>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dumps all values into output (for error msg)
|
* dumps all values into output (for error msg)
|
||||||
* @return string full table array data output as string html formatted
|
* @return string full table array data output as string html formatted
|
||||||
|
|||||||
@@ -89,10 +89,9 @@ class SmartyExtend extends SmartyBC
|
|||||||
/**
|
/**
|
||||||
* constructor class, just sets the language stuff
|
* constructor class, just sets the language stuff
|
||||||
* calls L10 for pass on internaly in smarty
|
* calls L10 for pass on internaly in smarty
|
||||||
* also registers the getvar caller pliugin
|
* also registers the getvar caller plugin
|
||||||
* @param string $lang language string to set
|
|
||||||
*/
|
*/
|
||||||
public function __construct(string $lang)
|
public function __construct()
|
||||||
{
|
{
|
||||||
// call basic smarty
|
// call basic smarty
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@@ -121,7 +120,7 @@ class SmartyExtend extends SmartyBC
|
|||||||
* creates short lang (only first two chars) from the lang
|
* creates short lang (only first two chars) from the lang
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setLangEncoding(): void
|
private function setLangEncoding(): void
|
||||||
{
|
{
|
||||||
// just emergency fallback for language
|
// just emergency fallback for language
|
||||||
// set encoding
|
// set encoding
|
||||||
@@ -130,10 +129,14 @@ class SmartyExtend extends SmartyBC
|
|||||||
} else {
|
} else {
|
||||||
$this->encoding = DEFAULT_ENCODING;
|
$this->encoding = DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
// just emergency fallback for language
|
// gobal override
|
||||||
if (isset($_SESSION['DEFAULT_LANG'])) {
|
if (isset($GLOBALS['OVERRIDE_LANG'])) {
|
||||||
|
$this->lang = $GLOBALS['OVERRIDE_LANG'];
|
||||||
|
} elseif (isset($_SESSION['DEFAULT_LANG'])) {
|
||||||
|
// session (login)
|
||||||
$this->lang = $_SESSION['DEFAULT_LANG'];
|
$this->lang = $_SESSION['DEFAULT_LANG'];
|
||||||
} else {
|
} else {
|
||||||
|
// mostly default SITE LANG or DEFAULT LANG
|
||||||
$this->lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
$this->lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||||
}
|
}
|
||||||
// create the char lang encoding
|
// create the char lang encoding
|
||||||
@@ -277,12 +280,7 @@ class SmartyExtend extends SmartyBC
|
|||||||
private function setSmartyVars($admin_call = false): void
|
private function setSmartyVars($admin_call = false): void
|
||||||
{
|
{
|
||||||
global $cms;
|
global $cms;
|
||||||
// array merge HEADER, DATA, DEBUG DATA
|
$this->mergeCmsSmartyVars($cms);
|
||||||
foreach (array('HEADER', 'DATA', 'DEBUG_DATA') as $ext_smarty) {
|
|
||||||
if (is_array($cms->{$ext_smarty})) {
|
|
||||||
$this->{$ext_smarty} = array_merge($this->{$ext_smarty}, $cms->{$ext_smarty});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// trigger flags
|
// trigger flags
|
||||||
$this->HEADER['USE_PROTOTYPE'] = $this->USE_PROTOTYPE;
|
$this->HEADER['USE_PROTOTYPE'] = $this->USE_PROTOTYPE;
|
||||||
@@ -389,7 +387,31 @@ class SmartyExtend extends SmartyBC
|
|||||||
$this->DATA['CONTENT_INCLUDE'] = $this->CONTENT_INCLUDE;
|
$this->DATA['CONTENT_INCLUDE'] = $this->CONTENT_INCLUDE;
|
||||||
$this->DATA['TEMPLATE_TRANSLATE'] = isset($this->TEMPLATE_TRANSLATE) ? $this->TEMPLATE_TRANSLATE : null;
|
$this->DATA['TEMPLATE_TRANSLATE'] = isset($this->TEMPLATE_TRANSLATE) ? $this->TEMPLATE_TRANSLATE : null;
|
||||||
$this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name).'.tpl';
|
$this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name).'.tpl';
|
||||||
|
// render page
|
||||||
|
$this->renderSmarty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* merge outside object HEADER/DATA/DEBUG_DATA vars into the smarty class
|
||||||
|
* @param object $cms object that has header/data/debug_data
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function mergeCmsSmartyVars(object $cms): void
|
||||||
|
{
|
||||||
|
// array merge HEADER, DATA, DEBUG DATA
|
||||||
|
foreach (array('HEADER', 'DATA', 'DEBUG_DATA') as $ext_smarty) {
|
||||||
|
if (is_array($cms->{$ext_smarty})) {
|
||||||
|
$this->{$ext_smarty} = array_merge($this->{$ext_smarty}, $cms->{$ext_smarty});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* render smarty data (can be called sepparate)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function renderSmarty(): void
|
||||||
|
{
|
||||||
// create main data array
|
// create main data array
|
||||||
$this->CONTENT_DATA = array_merge($this->HEADER, $this->DATA, $this->DEBUG_DATA);
|
$this->CONTENT_DATA = array_merge($this->HEADER, $this->DATA, $this->DEBUG_DATA);
|
||||||
// data is 1:1 mapping (all vars, values, etc)
|
// data is 1:1 mapping (all vars, values, etc)
|
||||||
|
|||||||
Reference in New Issue
Block a user