From 436025dd223f8a504ad5d5145934884de4919482 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 25 Jun 2019 17:07:47 +0900 Subject: [PATCH] admin includes updates, Class L10n fix - Class L10n had wrong default path to the language file, so the file load failed - Fix some default admin includes file for template settings --- www/includes/admin_set_paths.inc | 62 ++++++++------ www/includes/admin_smarty.inc | 2 +- www/includes/templates/admin/index.tpl | 108 ------------------------- www/lib/CoreLibs/Language/L10n.inc | 4 +- 4 files changed, 40 insertions(+), 136 deletions(-) delete mode 100644 www/includes/templates/admin/index.tpl diff --git a/www/includes/admin_set_paths.inc b/www/includes/admin_set_paths.inc index cd180498..c32209d4 100644 --- a/www/includes/admin_set_paths.inc +++ b/www/includes/admin_set_paths.inc @@ -29,7 +29,11 @@ if (isset($_SESSION['DEFAULT_LANG'])) { $lang_short = substr($lang, 0, 2); // set include & template names -$CONTENT_INCLUDE = str_replace(".php", ".tpl", $cms->page_name); +$PAGE_FILE_NAME = str_replace(".php", "", $cms->page_name); +// set include & template names +if (!isset($CONTENT_INCLUDE)) { + $CONTENT_INCLUDE = $PAGE_FILE_NAME.'.tpl'; +} $FORM_NAME = !isset($FORM_NAME) || !$FORM_NAME ? str_replace(".php", "", $cms->page_name) : $FORM_NAME; // set local page title $L_TITLE = ucfirst(str_replace('_', ' ', $cms->getPageName(1))).' - '.$G_TITLE; @@ -52,7 +56,7 @@ if ($smarty) { $smarty->setTemplateDir($cms->template_path); } if (isset($LANGUAGE_FOLDER)) { - $cms->kang_dir = $LANGUAGE_FOLDER; + $cms->lang_dir = $LANGUAGE_FOLDER; } else { $cms->lang_dir = BASE.INCLUDES.LANG.CONTENT_PATH; // no outside } @@ -64,14 +68,20 @@ $cms->cache_pictures_root = ROOT.$cms->cache_pictures; if (!is_dir($cms->cache_pictures_root)) { mkdir($cms->cache_pictures_root); } - -// check if template names exist -if (!file_exists($smarty->getTemplateDir()[0].DS.$MASTER_TEMPLATE_NAME)) { - // abort if master template could not be found - exit('MASTER TEMPLATE: '.$MASTER_TEMPLATE_NAME.' could not be found'); +// check for template include +if (isset($USE_INCLUDE_TEMPLATE) && $USE_INCLUDE_TEMPLATE === true && !isset($TEMPLATE_NAME)) { + $TEMPLATE_NAME = $CONTENT_INCLUDE; } -if (isset($TEMPLATE_NAME) && !file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { - exit('INCLUDE TEMPLATE: '.$TEMPLATE_NAME.' could not be found'); + +if (!$AJAX_PAGE) { + // check if template names exist + if (!file_exists($smarty->getTemplateDir()[0].DS.$MASTER_TEMPLATE_NAME)) { + // abort if master template could not be found + exit('MASTER TEMPLATE: '.$MASTER_TEMPLATE_NAME.' could not be found'); + } + if (isset($TEMPLATE_NAME) && !file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { + exit('INCLUDE TEMPLATE: '.$TEMPLATE_NAME.' could not be found'); + } } // if the lang folder is different to the default one @@ -91,24 +101,26 @@ if (false === strstr(BASE.INCLUDES.LANG.CONTENT_PATH, $cms->lang_dir) || } } -// javascript translate data as template for auto translate -if (!$TEMPLATE_TRANSLATE) { - $TEMPLATE_TRANSLATE = 'jsTranslate_'.$lang.'.tpl'; - $cms->debug('LANG', 'Load lang: '.$lang.', for page file '.$TEMPLATE_TRANSLATE); -} else { - // we assume we have some fixed set - // we must add _<$lang> - // if .tpl, put before .tpl - // if not .tpl, add _<$lang>.tpl - if (strpos($TEMPLATE_TRANSLATE, '.tpl')) { - $TEMPLATE_TRANSLATE = str_replace('.tpl', '_'.$lang.'.tpl', $TEMPLATE_TRANSLATE); +if (!$AJAX_PAGE) { + // javascript translate data as template for auto translate + if (!$TEMPLATE_TRANSLATE) { + $TEMPLATE_TRANSLATE = 'jsTranslate_'.$lang.'.tpl'; + $cms->debug('LANG', 'Load lang: '.$lang.', for page file '.$TEMPLATE_TRANSLATE); } else { - $TEMPLATE_TRANSLATE .= '_'.$lang.'.tpl'; + // we assume we have some fixed set + // we must add _<$lang> + // if .tpl, put before .tpl + // if not .tpl, add _<$lang>.tpl + if (strpos($TEMPLATE_TRANSLATE, '.tpl')) { + $TEMPLATE_TRANSLATE = str_replace('.tpl', '_'.$lang.'.tpl', $TEMPLATE_TRANSLATE); + } else { + $TEMPLATE_TRANSLATE .= '_'.$lang.'.tpl'; + } + } + // if we can't find it, dump it + if (!file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_TRANSLATE)) { + unset($TEMPLATE_TRANSLATE); } -} -// if we can't find it, dump it -if (!file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_TRANSLATE)) { - unset($TEMPLATE_TRANSLATE); } // $cms->debug("LANGUAGE", "L: $lang | ".$cms->lang_dir." | MO File: ".$cms->l->mofile); diff --git a/www/includes/admin_smarty.inc b/www/includes/admin_smarty.inc index 2f417b31..8da9abcc 100644 --- a/www/includes/admin_smarty.inc +++ b/www/includes/admin_smarty.inc @@ -99,6 +99,6 @@ if (is_dir(BASE.TEMPLATES_C)) { if (is_dir(BASE.CACHE)) { $smarty->setCacheDir(BASE.CACHE); } -$smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang); +$smarty->display($MASTER_TEMPLATE_NAME, $CACHE_ID.($CACHE_ID ? '_' : '').$lang, $COMPILE_ID.($COMPILE_ID ? '_' : '').$lang); // __END__ diff --git a/www/includes/templates/admin/index.tpl b/www/includes/templates/admin/index.tpl deleted file mode 100644 index bb58ec53..00000000 --- a/www/includes/templates/admin/index.tpl +++ /dev/null @@ -1,108 +0,0 @@ -{* - ******************************************************************** - * AUTHOR: Clemens Schwaighofer - * DATE: 2005/06/23 - * DESCRIPTION: - * edit body part - * HISTORY: - ******************************************************************** -*} - -
-{*
- -left - -
*} -
-
-
- Status -
-
- Shops
- Shops Flagged Delete: {$shop_delete_flagged}
- Shops Flagged Offline: {$shop_offline_flagged}
- Shops Flagged Online: {$shop_online_flagged}
- Shops without any categories: {$shop_no_category}
-
- Products
- Products Flagged no image: {$products_no_image_flagged}
- Products Flagged offline: {$products_offline_flagged}
- Products Flagged online: {$products_online_flagged}
- Products without any color tags: {$products_no_color_tags}
-
- Categories
- Categories without Products: {$categories_no_products}
-
-
- { * shows shops to be uploaded *} - {if $queued_items} -
-
-
-
- Items to push live -
-
- - -
-
-
-
-
del
-
GK
-
Date
-
Type
-
Action
-
Target
-
Key
-
Key ID
-
Asc
-
Lock
-
- {foreach from=$queued_items key=key item=item} -
{if $item.checkbox}{else} {/if}
-
{$item.group_key}
-
{$item.date_created}
-
{$item.type}
-
{$item.action}
-
{$item.target}
-
{$item.key_name}
-
{$item.key_value}
-
{$item.associate}
-
{$item.locked}
-
- {/foreach} -
-
- - - -
- {/if} -
-
- Issues -
-
- {$issue_data} -
-
- -
-
-
- Quick Search -
-
- Search for Key / String: -
-
-
- Enter something to search into the search field -
-
-
-
diff --git a/www/lib/CoreLibs/Language/L10n.inc b/www/lib/CoreLibs/Language/L10n.inc index 20faa623..81ad1f3e 100644 --- a/www/lib/CoreLibs/Language/L10n.inc +++ b/www/lib/CoreLibs/Language/L10n.inc @@ -45,7 +45,7 @@ class L10n extends \CoreLibs\Basic // override path check if (!is_dir($path)) { - $path = INCLUDES.LANG.CONTENT_PATH; + $path = BASE.INCLUDES.LANG.CONTENT_PATH; } $this->mofile = $path.$this->lang.".mo"; @@ -70,7 +70,7 @@ class L10n extends \CoreLibs\Basic // override path check if (!is_dir($path)) { - $path = INCLUDES.LANG.CONTENT_PATH; + $path = BASE.INCLUDES.LANG.CONTENT_PATH; } $this->mofile = $path.$this->lang.".mo";