]+?>|[:]|\{\d+\}|[Mm]ibew|[Ww]ebim/", $s, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[0] as $val) {
if($val != "
") {
$res .= $val;
}
}
}
if(substr(trim($s),-1) == "." || substr(trim($s),-1) == "?") {
$res .= ".";
}
return $res;
}
$operator = check_login();
$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);
$stringid = verifyparam("key", "/^[_\.\w]+$/", "");
if(!isset($messages[$source])) {
load_messages($source);
}
$lang1 = $messages[$source];
if(!isset($messages[$target])) {
load_messages($target);
}
$lang2 = $messages[$target];
$errors = array();
$page = array(
'lang1' => $source,
'lang2' => $target,
'title1' => isset($lang1["localeid"]) ? $lang1["localeid"] : $source,
'title2' => isset($lang2["localeid"]) ? $lang2["localeid"] : $target
);
if($stringid) {
$translation = isset($lang2[$stringid]) ? $lang2[$stringid] : "";
if(isset($_POST['translation'])) {
$translation = getparam('translation');
if(!$translation) {
$errors[] = no_field("form.field.translation");
}
if(count($errors) == 0) {
save_message($target, $stringid, $translation);
$page['saved'] = true;
prepare_menu($operator, false);
start_html_output();
require('../view/translate.php');
exit;
}
}
$page['saved'] = false;
$page['key'] = $stringid;
$page['target'] = $target;
$page['formoriginal'] = isset($lang1[$stringid]) ? $lang1[$stringid] : "";
$page['formtranslation'] = $translation;
prepare_menu($operator, false);
start_html_output();
require('../view/translate.php');
exit;
}
$localesList = array();
$allLocales = get_available_locales();
foreach($allLocales as $loc) {
$localesList[] = array("id" => $loc, "name" => getlocal_("localeid", $loc));
}
$show = verifyparam("show", "/^(all|s1|s2|s3)$/", "all");
$result = array();
$allkeys = array_keys($lang1);
if($show == 's1') {
$allkeys = array_intersect($allkeys, load_idlist('level1'));
} else if($show == 's2') {
$allkeys = array_intersect($allkeys, load_idlist('level2'));
} else if($show == 's3') {
$allkeys = array_diff($allkeys, load_idlist('level1'), load_idlist('level2'));
}
foreach($allkeys as $key) {
if($key != 'output_charset') {
$tsource = htmlspecialchars($lang1[$key]);
if(isset($lang2[$key])) {
$value = htmlspecialchars($lang2[$key]);
if(get_auxiliary($lang2[$key]) != get_auxiliary($lang1[$key])) {
$value = "$value (wrong formatting)";
}
} else {
$value = "absent";
}
$result[] = array(
'id' => $key,
'l1' => $tsource,
'l2' => $value );
}
}
$order = verifyparam("sort", "/^(id|l1)$/", "id");
usort($result, "compare_localization_by_$order");
setup_pagination($result,100);
$page['formtarget'] = $target;
$page['formsource'] = $source;
$page['availableLocales'] = $localesList;
$page['availableOrders'] = array(
array("id" => "id", "name" => getlocal("translate.sort.key")),
array("id" => "l1", "name" => getlocal("translate.sort.lang")),
);
$page['formsort'] = $order;
$page['showOptions'] = array(
array("id" => "all", "name" => getlocal("translate.show.all")),
array("id" => "s1", "name" => getlocal("translate.show.forvisitor")),
array("id" => "s2", "name" => getlocal("translate.show.foroperator")),
array("id" => "s3", "name" => getlocal("translate.show.foradmin")),
);
$page['formshow'] = $show;
prepare_menu($operator);
start_html_output();
require('../view/translatelist.php');
?>