calculate missing ids and default to default language when requesting texts by tag, saimod todo force reload on close all

This commit is contained in:
Ulf Gebhardt 2015-04-15 20:14:38 +02:00
parent 9a98a08291
commit 07c3629606
2 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,7 @@
namespace SYSTEM\PAGE; namespace SYSTEM\PAGE;
class text { class text {
//return all text values with certain tag and lang - array(id => text) //return all text values with certain tag and lang - array(id => text)
public static function tag($tag, $lang = NULL) { public static function tag($tag, $lang = NULL,$fallback = true) {
if($lang == NULL){ if($lang == NULL){
$lang = \SYSTEM\locale::get();} $lang = \SYSTEM\locale::get();}
@ -13,6 +13,16 @@ class text {
$res = \SYSTEM\DBD\SYS_TEXT_GET_TAG::QQ(array($tag,$lang)); $res = \SYSTEM\DBD\SYS_TEXT_GET_TAG::QQ(array($tag,$lang));
while($row = $res->next()){ while($row = $res->next()){
$result[$row['id']] = $row['text'];} $result[$row['id']] = $row['text'];}
if($fallback){
$result2 = array();
$res = \SYSTEM\DBD\SYS_TEXT_GET_TAG::QQ(array($tag,\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)));
while($row = $res->next()){
$result2[$row['id']] = $row['text'];}
if(count($result) < count($result2)){
new \SYSTEM\LOG\WARNING('Texts with tag: '.$tag.' '.(count($result2)-count($result)).' - ids not found for lang: '.$lang.' - fallback to default lang.');}
$result = array_merge($result2,$result);
}
return $result; return $result;
} }
//return textstring with certain id and lang //return textstring with certain id and lang

View File

@ -11,7 +11,7 @@ function init_saimod_sys_todo() {
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=close_all', url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=close_all',
success : function(data) { success : function(data) {
if(data.status){ if(data.status){
system.load('todo'); system.load('todo',true);
}else{ }else{
alert('Problem: '+data);} alert('Problem: '+data);}
} }