$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]);
$value = isset($lang2[$key]) ? htmlspecialchars($lang2[$key]) : "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');
?>