diff --git a/api/lang.php b/api/lang.php index e48bd0e9ab..5963833dfb 100644 --- a/api/lang.php +++ b/api/lang.php @@ -2,9 +2,7 @@ /** * API: loading translation from server * - * Usage: - * - /egroupware/api/lang.php?app=infolog&lang=de - * - /egroupware/api/lang.php?app=infolog&lang=de&debug=1 gives pretty-printed JSON + * Usage: /egroupware/api/lang.php?app=infolog&lang=de * * @link www.egroupware.org * @author Ralf Becker @@ -45,7 +43,7 @@ $etag = '"'.$_GET['app'].'-'.$_GET['lang'].'-'. Api\Translation::etag($_GET['ap // headers to allow caching, we specify etag on url to force reload, even with Expires header Api\Session::cache_control(864000); // cache for 10 days -Header('Content-Type: '.(empty($_GET['debug'])?'text/javascript':'application/json').'; charset=utf-8'); +Header('Content-Type: text/javascript; charset=utf-8'); Header('ETag: '.$etag); // if servers send a If-None-Match header, response with 304 Not Modified, if etag matches @@ -63,12 +61,7 @@ if (!count(Api\Translation::$lang_arr)) } // fix for phrases containing \n -$content = str_replace('\\\\n', '\\n', json_encode(Api\Translation::$lang_arr, - JSON_UNESCAPED_UNICODE | // send utf-8 unencoded, smaller and better readable - JSON_UNESCAPED_SLASHES | // do not escape slashes, smaller and better readable - (!empty($_GET['debug']) ? JSON_PRETTY_PRINT : 0))); - -if (empty($_GET['debug'])) $content = 'egw.set_lang_arr("'.$_GET['app'].'", '.$content.', egw && egw.window !== window);'; +$content = 'egw.set_lang_arr("'.$_GET['app'].'", '.str_replace('\\\\n', '\\n', json_encode(Api\Translation::$lang_arr)).', egw && egw.window !== window);'; // we run our own gzip compression, to set a correct Content-Length of the encoded content if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index e47a48b039..8b6b298025 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -159,7 +159,7 @@ class Etemplate extends Etemplate\Widget\Template // not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes $template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via); if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id."); -// Translation::add_app('etemplate'); + Translation::add_app('etemplate'); $template->run('beforeSendToClient', array('', array('cont'=>$content))); // some apps (eg. InfoLog) set app_header only in get_rows depending on filter settings diff --git a/api/src/Framework/Login.php b/api/src/Framework/Login.php index 186f22e248..1a00327f19 100644 --- a/api/src/Framework/Login.php +++ b/api/src/Framework/Login.php @@ -49,9 +49,15 @@ class Login Api\Header\ContentSecurityPolicy::add('frame-src', array()); // array() no external frame-sources //error_log(__METHOD__."() this->template=$this->framework->template, this->template_dir=$this->framework->template_dir, get_class(this)=".get_class($this)); - $tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir); - - $tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile()?'login_mobile.tpl':'login.tpl')); + try { + $tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir); + $tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile()?'login_mobile.tpl':'login.tpl')); + } + catch(Api\Exception\WrongParameter $e) { + unset($e); + $tmpl = new Template(EGW_SERVER_ROOT.'/api/templates/default'); + $tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile()?'login_mobile.tpl':'login.tpl')); + } $tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']); @@ -224,11 +230,15 @@ class Login */ function denylogin_screen() { - $tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir); - - $tmpl->set_file(array( - 'login_form' => 'login_denylogin.tpl' - )); + try { + $tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir); + $tmpl->set_file(array('login_form' => 'login_denylogin.tpl')); + } + catch(Api\Exception\WrongParameter $e) { + unset($e); + $tmpl = new Template(EGW_SERVER_ROOT.'/api/templates/default'); + $tmpl->set_file(array('login_form' => 'login_denylogin.tpl')); + } $tmpl->set_var(array( 'template_set' => 'default',