From 07c3629606ce5ca179d96a2d91342c994fed22db Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 15 Apr 2015 20:14:38 +0200 Subject: [PATCH] calculate missing ids and default to default language when requesting texts by tag, saimod todo force reload on close all --- page/text.php | 12 +++++++++++- sai/modules/saimod_sys_todo/js/saimod_sys_todo.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/page/text.php b/page/text.php index 0ee98a3..9147384 100644 --- a/page/text.php +++ b/page/text.php @@ -2,7 +2,7 @@ namespace SYSTEM\PAGE; class 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){ $lang = \SYSTEM\locale::get();} @@ -13,6 +13,16 @@ class text { $res = \SYSTEM\DBD\SYS_TEXT_GET_TAG::QQ(array($tag,$lang)); while($row = $res->next()){ $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 textstring with certain id and lang diff --git a/sai/modules/saimod_sys_todo/js/saimod_sys_todo.js b/sai/modules/saimod_sys_todo/js/saimod_sys_todo.js index cc0d1ba..b8344e7 100644 --- a/sai/modules/saimod_sys_todo/js/saimod_sys_todo.js +++ b/sai/modules/saimod_sys_todo/js/saimod_sys_todo.js @@ -11,7 +11,7 @@ function init_saimod_sys_todo() { url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=close_all', success : function(data) { if(data.status){ - system.load('todo'); + system.load('todo',true); }else{ alert('Problem: '+data);} }