2011-08-21 22:09:14 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* API: loading translation from from browser
|
|
|
|
*
|
|
|
|
* Usage: /egroupware/phpgwapi/lang.php?app=infolog&lang=de
|
|
|
|
*
|
|
|
|
* @link www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @package addressbook
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2012-03-01 10:30:49 +01:00
|
|
|
// just to be sure, noone tries something nasty ...
|
|
|
|
if (!preg_match('/^[a-z0-9_]+$/i', $_GET['app'])) die('No valid application-name given!');
|
|
|
|
if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/i', $_GET['lang'])) die('No valid lang-name given!');
|
|
|
|
|
2011-08-21 22:09:14 +02:00
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
2012-03-01 10:30:49 +01:00
|
|
|
'currentapp' => in_array($_GET['app'],array('etemplate','common','custom')) ? 'home' : $_GET['app'],
|
2011-08-21 22:09:14 +02:00
|
|
|
'noheader' => true,
|
|
|
|
'load_translations' => false, // do not automatically load translations
|
|
|
|
'nocachecontrol' => true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
include '../header.inc.php';
|
|
|
|
|
|
|
|
// use an etag with app, lang and a hash over the creation-times of all lang-files
|
2011-08-28 14:48:31 +02:00
|
|
|
$etag = '"'.$_GET['app'].'-'.$_GET['lang'].'-'.md5(serialize($GLOBALS['egw_info']['server']['lang_ctimes'])).'"';
|
2011-08-21 22:09:14 +02:00
|
|
|
|
|
|
|
// headers to allow caching of one month
|
|
|
|
Header('Content-Type: text/javascript; charset=utf-8');
|
|
|
|
Header('Cache-Control: public, no-transform');
|
|
|
|
Header('Pragma: cache');
|
|
|
|
Header('ETag: '.$etag);
|
|
|
|
|
|
|
|
// if servers send a If-None-Match header, response with 304 Not Modified, if etag matches
|
|
|
|
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag)
|
|
|
|
{
|
|
|
|
header("HTTP/1.1 304 Not Modified");
|
|
|
|
common::egw_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
translation::add_app($_GET['app'], $_GET['lang']);
|
|
|
|
if (!count(translation::$lang_arr))
|
|
|
|
{
|
|
|
|
translation::add_app($_GET['app'], 'en');
|
|
|
|
}
|
|
|
|
|
2011-08-23 18:15:54 +02:00
|
|
|
echo 'egw.set_lang_arr("'.$_GET['app'].'", '.json_encode(translation::$lang_arr).');';
|
2011-08-21 22:09:14 +02:00
|
|
|
|
|
|
|
// Content-Lenght header is important, otherwise browsers dont cache!
|
|
|
|
Header('Content-Length: '.ob_get_length());
|