{* progresss indicator *}
diff --git a/www/layout/admin/javascript/edit.jq.js b/www/layout/admin/javascript/edit.jq.js
index 610cde22..7272c0fd 100644
--- a/www/layout/admin/javascript/edit.jq.js
+++ b/www/layout/admin/javascript/edit.jq.js
@@ -114,8 +114,8 @@ function setCenter(id, left, top)
/**
* goes to an element id position
- * @param {String} element element id to move to
- * @param {Number} [offset=0] offset from top, default is 0 (px)
+ * @param {String} element element id to move to
+ * @param {Number} offset offset from top, default is 0 (px)
*/
function goToPos(element, offset = 0)
{
@@ -172,11 +172,12 @@ if (!String.prototype.format) {
* @param {Number} x number to be formated
* @return {String} formatted with , in thousands
*/
-const numberWithCommas = (x) => {
+function numberWithCommas(x)
+{
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
-};
+}
/**
* converts line breaks to br
@@ -289,17 +290,25 @@ function isObject(val) {
return ((typeof val === 'function') || (typeof val === 'object'));
}
+/**
+ * get the length of an object (entries)
+ * @param {Object} object object to check
+ * @return {Number} number of entry
+ */
+function getObjectCount(object) {
+ return Object.keys(object).length;
+}
+
/**
* checks if a key exists in a given object
* @param {String} key key name
* @param {Object} object object to search key in
* @return {Boolean} true/false if key exists in object
*/
-const keyInObject = (key, object) => (Object.prototype.hasOwnProperty.call(object, key)) ? true : false;
-/*function keyInObject(key, object)
+function keyInObject(key, object)
{
return (Object.prototype.hasOwnProperty.call(object, key)) ? true : false;
-}*/
+}
/**
* returns matching key of value
@@ -307,11 +316,13 @@ const keyInObject = (key, object) => (Object.prototype.hasOwnProperty.call(objec
* @param {Mixed} value any value (String, Number, etc)
* @return {String} the key found for the first matching value
*/
-const getKeyByValue = (obj, value) => Object.keys(obj).find(key => obj[key] === value);
-// function getKeyByValue(object, value)
-// {
-// return Object.keys(object).find(key => object[key] === value);
-// }
+function getKeyByValue(object, value)
+{
+ return Object.keys(object).find(key => object[key] === value);
+ // return Object.keys(object).find(function (key) {
+ // return object[key] === value;
+ // });
+}
/**
* returns true if value is found in object with a key
@@ -319,18 +330,23 @@ const getKeyByValue = (obj, value) => Object.keys(obj).find(key => obj[key] ===
* @param {Mixed} value any value (String, Number, etc)
* @return {Boolean} true on value found, false on not found
*/
-const valueInObject = (obj, value) => (Object.keys(obj).find(key => obj[key] === value)) ? true : false;
+function valueInObject(object, value)
+{
+ return (Object.keys(object).find(key => object[key] === value)) ? true : false;
+ // return Object.keys(object).find(function (key) {
+ // return object[key] === value;
+ // }) ? true : false;
+}
/**
* checks if a DOM element actually exists
* @param {String} id Element id to check for
* @return {Boolean} true if element exists, false on failure
*/
-const exists = (id) => $('#' + id).length > 0 ? true : false;
-/*function exists(id)
+function exists(id)
{
return $('#' + id).length > 0 ? true : false;
-}*/
+}
/**
* converts a int number into bytes with prefix in two decimals precision
@@ -345,7 +361,6 @@ function formatBytes(bytes)
bytes = bytes / 1024;
i++;
} while (bytes > 99);
-
return parseFloat(Math.round(bytes * Math.pow(10, 2)) / Math.pow(10, 2)) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
}
@@ -380,42 +395,52 @@ function errorCatch(err)
/**
* show or hide the "do" overlay
- * @param {String} [loc=''] location name for action indicator, default empty. for console.log
+ * @param {String} loc location name for action indicator
+ * default empty. for console.log
+ * @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
*/
-function actionIndicator(loc = '')
+function actionIndicator(loc, overlay = true)
{
if ($('#overlayBox').is(':visible')) {
- actionIndicatorHide(loc);
+ actionIndicatorHide(loc, overlay);
} else {
- actionIndicatorShow(loc);
+ actionIndicatorShow(loc, overlay);
}
}
/**
* explicit show for action Indicator
* instead of automatically show or hide, do on command show
- * @param {String} [loc=''] optional location name, empty if not set. for console.log
+ * @param {String} loc location name for action indicator
+ * default empty. for console.log
+ * @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
*/
-function actionIndicatorShow(loc = '')
+function actionIndicatorShow(loc, overlay = true)
{
console.log('Indicator: SHOW [%s]', loc);
$('#indicator').addClass('progress');
setCenter('indicator', true, true);
$('#indicator').show();
- overlayBoxShow();
+ if (overlay === true) {
+ overlayBoxShow();
+ }
}
/**
* explicit hide for action Indicator
* instead of automatically show or hide, do on command hide
- * @param {String} [loc=''] optional location name, empty if not set. for console.log
+ * @param {String} loc location name for action indicator
+ * default empty. for console.log
+ * @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
*/
-function actionIndicatorHide(loc = '')
+function actionIndicatorHide(loc, overlay = true)
{
console.log('Indicator: HIDE [%s]', loc);
$('#indicator').hide();
$('#indicator').removeClass('progress');
- overlayBoxHide();
+ if (overlay === true) {
+ overlayBoxHide();
+ }
}
/**
@@ -477,8 +502,9 @@ function ClearCall()
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
* @return {Object} created element as an object
*/
-const cel = (tag, id = '', content = '', css = [], options = {}) =>
- _element = {
+function cel(tag, id = '', content = '', css = [], options = {})
+{
+ return {
tag: tag,
id: id,
name: options.name, // override name if set [name gets ignored in tree build anyway]
@@ -487,6 +513,7 @@ const cel = (tag, id = '', content = '', css = [], options = {}) =>
options: options,
sub: []
};
+}
/**
* attach a cel created object to another to create a basic DOM tree
@@ -536,10 +563,11 @@ function aelx(base, ...attach)
* @param {Object} base cel created element
* @return {Object} returns reset base element
*/
-const rel = (base) => {
+function rel(base)
+{
base.sub = [];
return base;
-};
+}
/**
* searches and removes style from css array
@@ -878,4 +906,80 @@ function loginLogout()
form.submit();
}
+/**
+ * create login string and logout button elements
+ * @param {String} login_string the login string to show on the left
+ * @param {String} [header_id='mainHeader'] the target for the main element block
+ * if not set mainHeader is assumed
+ * this is the target div for the "loginRow"
+ */
+function createLoginRow(login_string, header_id = 'mainHeader')
+{
+ // if header does not exist, we do nothing
+ if (exists(header_id)) {
+ // that row must exist already, if not it must be the first in the "mainHeader"
+ if (!exists('loginRow')) {
+ $('#' + header_id).html(phfo(cel('div', 'loginRow', '', ['loginRow', 'flx-spbt'])));
+ }
+ // clear out just in case for first entry
+ // fill with div name & login/logout button
+ $('#loginRow').html(phfo(cel('div', '', login_string)));
+ $('#loginRow').append(phfo(
+ aelx(
+ // outer div
+ cel('div'),
+ // inner element
+ cel('input', 'logout', '', [], {
+ value: __('Logout'),
+ type: 'button',
+ onClick: 'loginLogout()'
+ })
+ )
+ ));
+ }
+}
+
+/**
+ * create the top nav menu that switches physical between pages
+ * (edit access data based)
+ * @param {Object} nav_menu the built nav menu with highlight info
+ * @param {String} [header_id='mainHeader'] the target for the main element block
+ * if not set mainHeader is assumed
+ * this is the target div for the "menuRow"
+ */
+function createNavMenu(nav_menu, header_id = 'mainHeader') {
+ // must be an object
+ if (isObject(nav_menu) && getObjectCount(nav_menu) > 1) {
+ // do we have more than one entry, if not, do not show (single page)
+ if (!exists('menuRow')) {
+ $('#' + header_id).html(phfo(cel('div', 'menuRow', '', ['menuRow', 'flx-s'])));
+ }
+ var content = [];
+ $.each(nav_menu, function(key, item) {
+ // key is number
+ // item is object with entries
+ if (key != 0) {
+ content.push(phfo(cel('div', '', '·', ['pd-2'])));
+ }
+ // ignore item.popup for now
+ if (item.enabled) {
+ // set selected based on window.location.href as the php set will not work
+ if (window.location.href.indexOf(item.url) != -1) {
+ item.selected = 1;
+ }
+ // create the entry
+ content.push(phfo(
+ aelx(
+ cel('div'),
+ cel('a', '', item.name, ['pd-2'].concat(item.selected ? 'highlight': ''), {
+ href: item.url
+ })
+ )
+ ));
+ }
+ });
+ $('#menuRow').html(content.join(''));
+ }
+}
+
/* END */
diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php
index a672a13e..4c764939 100644
--- a/www/lib/CoreLibs/ACL/Login.php
+++ b/www/lib/CoreLibs/ACL/Login.php
@@ -150,7 +150,7 @@ class Login extends \CoreLibs\DB\IO
// 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
- $this->login_is_ajax_page = $this->ajax_page_flag;
+ $this->login_is_ajax_page = isset($GLOBALS['AJAX_PAGE']) && $GLOBALS['AJAX_PAGE'] ? true : false;
$this->l = new \CoreLibs\Language\L10n($lang);
@@ -696,6 +696,9 @@ class Login extends \CoreLibs\DB\IO
{
// only set acl if we have permission okay
if ($this->permission_okay) {
+ // username (login), group name
+ $this->acl['user_name'] = $_SESSION['USER_NAME'];
+ $this->acl['group_name'] = $_SESSION['GROUP_NAME'];
// we start with the default acl
$this->acl['base'] = DEFAULT_ACL_LEVEL;
diff --git a/www/lib/CoreLibs/Admin/Backend.php b/www/lib/CoreLibs/Admin/Backend.php
index c27c68b9..7dbe594f 100644
--- a/www/lib/CoreLibs/Admin/Backend.php
+++ b/www/lib/CoreLibs/Admin/Backend.php
@@ -52,31 +52,16 @@ class Backend extends \CoreLibs\DB\IO
public $error = 0;
public $warning = 0;
public $info = 0;
- // smarty publics
+ // internal lang & encoding vars
+ public $lang_dir = '';
+ public $lang;
+ public $lang_short;
+ public $encoding;
+ // smarty publics [end processing in smarty class]
public $DATA;
public $HEADER;
public $DEBUG_DATA;
public $CONTENT_DATA;
- // smarty include/set var
- public $INC_TEMPLATE_NAME;
- public $JS_TEMPLATE_NAME;
- public $CSS_TEMPLATE_NAME;
- public $CSS_SPECIAL_TEMPLATE_NAME;
- public $JS_SPECIAL_TEMPLATE_NAME;
- public $CACHE_ID;
- public $COMPILE_ID;
- public $includes;
- public $template_path;
- public $lang_dir = '';
- public $javascript;
- public $css;
- public $pictures;
- public $cache_pictures;
- public $cache_pictures_root;
- public $JS_INCLUDE;
- public $JS_SPECIAL_INCLUDE;
- public $CSS_INCLUDE;
- public $CSS_SPECIAL_INCLUDE;
// language
public $l;
@@ -89,6 +74,7 @@ class Backend extends \CoreLibs\DB\IO
*/
public function __construct(array $db_config, string $lang, int $set_control_flag = 0)
{
+ $this->setLangEncoding();
// get the language sub class & init it
$this->l = new \CoreLibs\Language\L10n($lang);
@@ -121,6 +107,45 @@ class Backend extends \CoreLibs\DB\IO
// PUBLIC METHODS |=================================================>
+ /**
+ * 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
+ */
+ public 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;
+ }
+ // just emergency fallback for language
+ if (isset($_SESSION['DEFAULT_LANG'])) {
+ $this->lang = $_SESSION['DEFAULT_LANG'];
+ } else {
+ $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;
+ }
+
+ /**
+ * set internal ACL from login ACL
+ * @param array $acl login acl array
+ */
+ public function setACL(array $acl): void
+ {
+ $this->acl = $acl;
+ }
+
/**
* writes all action vars plus other info into edit_log tabl
* @param string $event any kind of event description,
@@ -157,7 +182,7 @@ class Backend extends \CoreLibs\DB\IO
$q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, ";
$q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) ";
$q .= "VALUES ";
- $q .= "(".$this->dbEscapeString(isset($_SESSION['EUID']) ? $_SESSION['EUID'] : '').", ";
+ $q .= "(".$this->dbEscapeString(isset($_SESSION['EUID']) && is_numeric($_SESSION['EUID']) ? $_SESSION['EUID'] : 'NULL').", ";
$q .= "NOW(), ";
$q .= "'".$this->dbEscapeString((string)$event)."', '".$data."', '".$data_binary."', '".$this->dbEscapeString($this->page_name)."', ";
$q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->dbEscapeString(@$_SERVER['HTTP_USER_AGENT'])."', ";
@@ -181,6 +206,42 @@ class Backend extends \CoreLibs\DB\IO
$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)
* @param int $flag visible flag trigger
diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php
index abe22e74..3b0d9b80 100644
--- a/www/lib/CoreLibs/Basic.php
+++ b/www/lib/CoreLibs/Basic.php
@@ -1850,8 +1850,15 @@ class Basic
* @param bool $clear_cache if set to true, will create thumb all the tame
* @return string|bool thumbnail name, or false for error
*/
- public static function createThumbnail(string $pic, int $size_x, int $size_y, string $dummy = '', string $path = '', string $cache_source = '', bool $clear_cache = false)
- {
+ public static function createThumbnail(
+ string $pic,
+ int $size_x,
+ int $size_y,
+ string $dummy = '',
+ string $path = '',
+ string $cache_source = '',
+ bool $clear_cache = false
+ ) {
// get image type flags
$image_types = array(
1 => 'gif',
@@ -1991,7 +1998,7 @@ class Basic
int $thumb_width = 0,
int $thumb_height = 0,
?string $thumbnail_path = null,
- bool $create_dummy = false,
+ bool $create_dummy = true,
bool $use_cache = true,
bool $high_quality = true,
int $jpeg_quality = 80
@@ -2137,6 +2144,13 @@ class Basic
if ($use_cache === false ||
!file_exists($thumbnail_write_path.$thumbnail)
) {
+ // if both are unset, set to 250
+ if ($thumb_height == 0) {
+ $thumb_height = 250;
+ }
+ if ($thumb_width == 0) {
+ $thumb_width = 250;
+ }
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
// add outside border px = 5% (rounded up)
// eg 50px -> 2.5px
diff --git a/www/lib/CoreLibs/DB/SQL/PgSQL.php b/www/lib/CoreLibs/DB/SQL/PgSQL.php
index faa85d68..a69a2d16 100644
--- a/www/lib/CoreLibs/DB/SQL/PgSQL.php
+++ b/www/lib/CoreLibs/DB/SQL/PgSQL.php
@@ -448,10 +448,10 @@ class PgSQL
}
if ('{}' != $text) {
do {
- if ('{' != $text{$offset}) {
+ if ('{' != $text[$offset]) {
preg_match("/(\\{?\"([^\"\\\\]|\\\\.)*\"|[^,{}]+)+([,}]+)/", $text, $match, 0, $offset);
$offset += strlen($match[0]);
- $output[] = ('"' != $match[1]{0} ? $match[1] : stripcslashes(substr($match[1], 1, -1)));
+ $output[] = ('"' != $match[1][0] ? $match[1] : stripcslashes(substr($match[1], 1, -1)));
if ('},' == $match[3]) {
return $offset;
}
diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php
index 2879a4c2..0cf82815 100644
--- a/www/lib/CoreLibs/Template/SmartyExtend.php
+++ b/www/lib/CoreLibs/Template/SmartyExtend.php
@@ -22,8 +22,67 @@ use SmartyBC;
class SmartyExtend extends SmartyBC
{
+ // internal translation engine
public $l10n;
+ // lang & encoding
+ public $lang_dir = '';
+ public $lang;
+ public $lang_short;
+ public $encoding;
+ // page name
+ public $page_name;
+
+ // array for data parsing
+ public $HEADER = array();
+ public $DATA = array();
+ public $DEBUG_DATA = array();
+ private $CONTENT_DATA = array();
+ // control vars
+ public $USE_PROTOTYPE = USE_PROTOTYPE;
+ public $USE_JQUERY = USE_JQUERY;
+ public $USE_SCRIPTACULOUS = USE_SCRIPTACULOUS;
+ // sub content input vars
+ public $USE_TINY_MCE = false;
+ public $JS_DATEPICKR = false;
+ public $JS_FLATPICKR = false;
+ public $DEBUG_TMPL = false;
+ // cache & compile
+ public $CACHE_ID = '';
+ public $COMPILE_ID = '';
+ // template vars
+ public $MASTER_TEMPLATE_NAME;
+ public $PAGE_FILE_NAME;
+ public $CONTENT_INCLUDE;
+ public $FORM_NAME;
+ public $L_TITLE;
+ public $PAGE_WIDTH;
+ // smarty include/set var
+ public $TEMPLATE_PATH;
+ public $TEMPLATE_NAME;
+ public $INC_TEMPLATE_NAME;
+ public $JS_TEMPLATE_NAME;
+ public $CSS_TEMPLATE_NAME;
+ public $TEMPLATE_TRANSLATE;
+ // local names
+ public $JS_SPECIAL_TEMPLATE_NAME = '';
+ public $CSS_SPECIAL_TEMPLATE_NAME = '';
+ public $JS_INCLUDE;
+ public $CSS_INCLUDE;
+ public $JS_SPECIAL_INCLUDE;
+ public $CSS_SPECIAL_INCLUDE;
+ public $ADMIN_JAVASCRIPT;
+ public $ADMIN_STYLESHEET;
+ public $FRONTEND_JAVASCRIPT;
+ public $FRONTEND_STYLESHEET;
+ // other smarty folder vars
+ public $INCLUDES;
+ public $JAVASCRIPT;
+ public $CSS;
+ public $PICTURES;
+ public $CACHE_PICTURES;
+ public $CACHE_PICTURES_ROOT;
+
// constructor class, just sets the language stuff
/**
* constructor class, just sets the language stuff
@@ -33,11 +92,304 @@ class SmartyExtend extends SmartyBC
*/
public function __construct(string $lang)
{
+ // call basic smarty
parent::__construct();
- $this->l10n = new \CoreLibs\Language\L10n($lang);
+ // set lang vars
+ $this->setLangEncoding();
+ // iinit lang
+ $this->l10n = new \CoreLibs\Language\L10n($this->lang);
// variable variable register
// $this->register_modifier('getvar', array(&$this, 'get_template_vars'));
$this->registerPlugin('modifier', 'getvar', array(&$this, 'get_template_vars'));
+
+ $this->page_name = pathinfo($_SERVER["PHP_SELF"])['basename'];
+
+ // set internal settings
+ $this->CACHE_ID = defined('CACHE_ID') ? CACHE_ID : '';
+ $this->COMPILE_ID = defined('COMPILE_ID') ? COMPILE_ID : '';
+ }
+
+ /**
+ * 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
+ */
+ public 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;
+ }
+ // just emergency fallback for language
+ if (isset($_SESSION['DEFAULT_LANG'])) {
+ $this->lang = $_SESSION['DEFAULT_LANG'];
+ } else {
+ $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 function setSmartyVarsFrontend()
+ {
+ $this->setSmartyVars();
+ }
+
+ public function setSmartyVarsAdmin()
+ {
+ $this->setSmartyVars(true);
+ }
+
+ private function setSmartyVars($admin_call = false)
+ {
+ global $cms;
+ // 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});
+ }
+ }
+
+ // trigger flags
+ $this->HEADER['USE_PROTOTYPE'] = $this->USE_PROTOTYPE;
+ // scriptacolous, can only be used with prototype
+ if ($this->HEADER['USE_PROTOTYPE']) {
+ $this->HEADER['USE_SCRIPTACULOUS'] = $this->USE_SCRIPTACULOUS;
+ }
+ // jquery and prototype should not be used together
+ $this->HEADER['USE_JQUERY'] = $this->USE_JQUERY;
+
+ // additional per page Javascript include
+ $this->JS_INCLUDE = '';
+ if (file_exists($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME) &&
+ is_file($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME)
+ ) {
+ $this->JS_INCLUDE = $this->JAVASCRIPT.$this->JS_TEMPLATE_NAME;
+ }
+ // per page css file
+ $this->CSS_INCLUDE = '';
+ if (file_exists($this->CSS.$this->CSS_TEMPLATE_NAME) &&
+ is_file($this->CSS.$this->CSS_TEMPLATE_NAME)
+ ) {
+ $this->CSS_INCLUDE = $this->CSS.$this->CSS_TEMPLATE_NAME;
+ }
+ // optional CSS file
+ $this->CSS_SPECIAL_INCLUDE = '';
+ if (file_exists($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME) &&
+ is_file($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME)
+ ) {
+ $this->CSS_SPECIAL_INCLUDE = $this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME;
+ }
+ // optional JS file
+ $this->JS_SPECIAL_INCLUDE = '';
+ if (file_exists($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME) &&
+ is_file($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME)
+ ) {
+ $this->JS_SPECIAL_INCLUDE = $this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME;
+ }
+
+ // the actual include files for javascript (per page)
+ $this->HEADER['JS_INCLUDE'] = $this->JS_INCLUDE;
+ $this->HEADER['CSS_INCLUDE'] = $this->CSS_INCLUDE;
+ $this->HEADER['CSS_SPECIAL_INCLUDE'] = $this->CSS_SPECIAL_INCLUDE;
+ $this->HEADER['JS_SPECIAL_INCLUDE'] = $this->JS_SPECIAL_INCLUDE;
+ // paths to the files
+ $this->DATA['includes'] = $this->INCLUDES;
+ $this->DATA['js'] = $this->JAVASCRIPT;
+ $this->DATA['css'] = $this->CSS;
+ $this->DATA['pictures'] = $this->PICTURES;
+
+ // default CMS settings
+ // define all needed smarty stuff for the general HTML/page building
+ $this->HEADER['CSS'] = CSS;
+ $this->HEADER['JS'] = JS;
+ $this->HEADER['ENCODING'] = $this->encoding;
+ $this->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
+
+ // special for admin
+ if ($admin_call === true) {
+ // set ACL extra show
+ $this->DATA['show_ea_extra'] = isset($cms->acl['show_ea_extra']) ? $cms->acl['show_ea_extra'] : false;
+ $this->DATA['ADMIN'] = !empty($cms->acl['admin']) ? $cms->acl['admin'] : 0;
+ // set style sheets
+ $this->HEADER['STYLESHEET'] = $this->ADMIN_STYLESHEET ? $this->ADMIN_STYLESHEET : ADMIN_STYLESHEET;
+ $this->HEADER['JAVASCRIPT'] = $this->ADMIN_JAVASCRIPT ? $this->ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT;
+ // top menu
+ $this->DATA['nav_menu'] = $cms->adbTopMenu();
+ $this->DATA['nav_menu_count'] = is_array($this->DATA['nav_menu']) ? count($this->DATA['nav_menu']) : 0;
+ // messages = array('msg' =>, 'class' => 'error/warning/...')
+ $this->DATA['messages'] = isset($cms->messages) ? $cms->messages : $cms->messages;
+ // the page name
+ $this->DATA['page_name'] = $this->page_name;
+ $this->DATA['table_width'] = isset($this->PAGE_WIDTH) ? $this->PAGE_WIDTH : PAGE_WIDTH;
+ // for tinymce special
+ $this->DATA['TINYMCE_LANG'] = $this->lang_short;
+ // include flags
+ $this->DATA['USE_TINY_MCE'] = $this->USE_TINY_MCE;
+ // debug data, if DEBUG flag is on, this data is print out
+ $this->DEBUG_DATA['DEBUG'] = $this->DEBUG_TMPL;
+ } else {
+ $this->HEADER['STYLESHEET'] = $this->FRONTEND_STYLESHEET ? $this->FRONTEND_STYLESHEET : STYLESHEET;
+ $this->HEADER['JAVASCRIPT'] = $this->FRONTEND_JAVASCRIPT ? $this->FRONTEND_JAVASCRIPT : JAVASCRIPT;
+ }
+ // html title
+ // set local page title
+ $this->HEADER['HTML_TITLE'] = !$this->L_TITLE ?
+ ucfirst(str_replace('_', ' ', $cms->getPageName(1))).(defined(G_TITLE) ? ' - '.$this->l10n->__(G_TITLE) : '') :
+ $this->l10n->__($this->L_TITLE);
+
+ // LANG
+ $this->DATA['LANG'] = $this->lang;
+ // form name
+ $this->DATA['FORM_NAME'] = !$this->FORM_NAME ?
+ str_replace('.php', '', $this->page_name) :
+ $this->FORM_NAME;
+ // include flags
+ $this->DATA['JS_DATEPICKR'] = $this->JS_DATEPICKR;
+ $this->DATA['JS_FLATPICKR'] = $this->JS_FLATPICKR;
+ // user name
+ $this->DATA['USER_NAME'] = !empty($_SESSION['USER_NAME']) ? $_SESSION['USER_NAME'] : '';
+ // the template part to include into the body
+ $this->DATA['TEMPLATE_NAME'] = $this->TEMPLATE_NAME;
+ $this->DATA['CONTENT_INCLUDE'] = $this->CONTENT_INCLUDE;
+ $this->DATA['TEMPLATE_TRANSLATE'] = isset($this->TEMPLATE_TRANSLATE) ? $this->TEMPLATE_TRANSLATE : null;
+ $this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name).'.tpl';
+
+ // create main data array
+ $this->CONTENT_DATA = array_merge($this->HEADER, $this->DATA, $this->DEBUG_DATA);
+ // data is 1:1 mapping (all vars, values, etc)
+ foreach ($this->CONTENT_DATA as $key => $value) {
+ $this->assign($key, $value);
+ }
+ if (is_dir(BASE.TEMPLATES_C)) {
+ $this->setCompileDir(BASE.TEMPLATES_C);
+ }
+ if (is_dir(BASE.CACHE)) {
+ $this->setCacheDir(BASE.CACHE);
+ }
+ $this->display(
+ $this->MASTER_TEMPLATE_NAME,
+ $this->CACHE_ID.($this->CACHE_ID ? '_' : '').$this->lang,
+ $this->COMPILE_ID.($this->COMPILE_ID ? '_' : '').$this->lang
+ );
+ }
+
+ public function setSmartyPaths()
+ {
+ global $AJAX_PAGE, $USE_INCLUDE_TEMPLATE;
+ // master template
+ if (!isset($this->MASTER_TEMPLATE_NAME)) {
+ $this->MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME;
+ }
+
+ // set include & template names
+ if (!isset($this->CONTENT_INCLUDE)) {
+ $this->CONTENT_INCLUDE = str_replace('.php', '', $this->page_name).'.tpl';
+ }
+ // strip tpl and replace it with php
+ // php include file per page
+ $this->INC_TEMPLATE_NAME = str_replace('.tpl', '.php', $this->CONTENT_INCLUDE);
+ // javascript include per page
+ $this->JS_TEMPLATE_NAME = str_replace('.tpl', '.js', $this->CONTENT_INCLUDE);
+ // css per page
+ $this->CSS_TEMPLATE_NAME = str_replace('.tpl', '.css', $this->CONTENT_INCLUDE);
+
+ // set basic template path (tmp)
+ $this->INCLUDES = BASE.INCLUDES; // no longer in templates, only global
+ $this->TEMPLATE_PATH = BASE.INCLUDES.TEMPLATES.CONTENT_PATH;
+ $this->setTemplateDir($this->TEMPLATE_PATH);
+ $this->JAVASCRIPT = LAYOUT.JS;
+ $this->CSS = LAYOUT.CSS;
+ $this->PICTURES = LAYOUT.IMAGES;
+ $this->CACHE_PICTURES = LAYOUT.CACHE;
+ $this->CACHE_PICTURES_ROOT = ROOT.$this->CACHE_PICTURES;
+ // check if we have an external file with the template name
+ if (file_exists($this->INCLUDES.$this->INC_TEMPLATE_NAME) &&
+ is_file($this->INCLUDES.$this->INC_TEMPLATE_NAME)
+ ) {
+ include($this->INCLUDES.$this->INC_TEMPLATE_NAME);
+ }
+ // only CSS/JS/etc include stuff if we have non AJAX page
+ if (isset($AJAX_PAGE) && !$AJAX_PAGE) {
+ // check for template include
+ if (isset($USE_INCLUDE_TEMPLATE) &&
+ $USE_INCLUDE_TEMPLATE === true &&
+ !$this->TEMPLATE_NAME
+ ) {
+ $this->TEMPLATE_NAME = $this->CONTENT_INCLUDE;
+ // add to cache & compile id
+ $this->COMPILE_ID .= '_'.$this->TEMPLATE_NAME;
+ $this->CACHE_ID .= '_'.$this->TEMPLATE_NAME;
+ }
+ // additional per page Javascript include
+ $this->JS_INCLUDE = '';
+ if (file_exists($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME) &&
+ is_file($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME)
+ ) {
+ $this->JS_INCLUDE = $this->JAVASCRIPT.$this->JS_TEMPLATE_NAME;
+ }
+ // per page css file
+ $this->CSS_INCLUDE = '';
+ if (file_exists($this->CSS.$this->CSS_TEMPLATE_NAME) &&
+ is_file($this->CSS.$this->CSS_TEMPLATE_NAME)
+ ) {
+ $this->CSS_INCLUDE = $this->CSS.$this->CSS_TEMPLATE_NAME;
+ }
+ // optional CSS file
+ $this->CSS_SPECIAL_INCLUDE = '';
+ if (file_exists($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME) &&
+ is_file($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME)
+ ) {
+ $this->CSS_SPECIAL_INCLUDE = $this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME;
+ }
+ // optional JS file
+ $this->JS_SPECIAL_INCLUDE = '';
+ if (file_exists($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME) &&
+ is_file($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME)
+ ) {
+ $this->JS_SPECIAL_INCLUDE = $this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME;
+ }
+ // check if template names exist
+ if (!$this->MASTER_TEMPLATE_NAME) {
+ exit('MASTER TEMPLATE is not set');
+ } elseif (!file_exists($this->getTemplateDir()[0].DS.$this->MASTER_TEMPLATE_NAME)) {
+ // abort if master template could not be found
+ exit('MASTER TEMPLATE: '.$this->MASTER_TEMPLATE_NAME.' could not be found');
+ }
+ if ($this->TEMPLATE_NAME &&
+ !file_exists($this->getTemplateDir()[0].DS.$this->TEMPLATE_NAME)
+ ) {
+ exit('INCLUDE TEMPLATE: '.$this->TEMPLATE_NAME.' could not be found');
+ }
+ // javascript translate data as template for auto translate
+ if (empty($this->TEMPLATE_TRANSLATE)) {
+ $this->TEMPLATE_TRANSLATE = 'jsTranslate_'.$this->lang.'.tpl';
+ } else {
+ // we assume we have some fixed set
+ // we must add _<$this->lang>
+ // if .tpl, put before .tpl
+ // if not .tpl, add _<$this->lang>.tpl
+ if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
+ $this->TEMPLATE_TRANSLATE = str_replace('.tpl', '_'.$this->lang.'.tpl', $this->TEMPLATE_TRANSLATE);
+ } else {
+ $this->TEMPLATE_TRANSLATE .= '_'.$this->lang.'.tpl';
+ }
+ }
+ // if we can't find it, dump it
+ if (!file_exists($this->getTemplateDir()[0].DS.$this->TEMPLATE_TRANSLATE)) {
+ $this->TEMPLATE_TRANSLATE = null;
+ }
+ }
}
}