installed();// Bugfix - don't use e_LANLIST as it's cached (SESSION)
$message = '';
if (e_QUERY)
{
$tmp = explode('.', e_QUERY);
$action = varset($tmp[0]);
$sub_action = varset($tmp[1]);
$id = varset($tmp[2]);
unset($tmp);
}
if (isset($_POST['submit_prefs']) && isset($_POST['mainsitelanguage']))
{
unset($temp);
$changes = array();
$temp['multilanguage'] = $_POST['multilanguage'];
$temp['multilanguage_subdomain'] = $_POST['multilanguage_subdomain'];
$temp['multilanguage_domain'] = $_POST['multilanguage_domain'];
$temp['sitelanguage'] = $_POST['mainsitelanguage'];
$temp['noLanguageSubs'] = $_POST['noLanguageSubs'];
if ($admin_log->logArrayDiffs($temp, $pref, 'LANG_01'))
{
save_prefs(); // Only save if changes
//$mes->addSuccess(LAN_SETSAVED, E_MESSAGE_SUCCESS);
}
else
{
$mes->addInfo(LAN_NO_CHANGE);
}
}
// ----------------- delete tables ---------------------------------------------
if (isset($_POST['del_existing']) && $_POST['lang_choices'])
{
$lang = strtolower($_POST['lang_choices']);
foreach ($tabs as $del_table)
{
if ($sql->db_Table_exists($lang."_".$del_table,TRUE))
{
echo $del_table." exists
";
$qry = "DROP TABLE ".$mySQLprefix."lan_".$lang."_".$del_table;
if (mysql_query($qry))
{
$message .= sprintf(LANG_LAN_28, $_POST['lang_choices'].' '.$del_table).'[!br!]'; // can be removed?
$mes->addSuccess(sprintf(LANG_LAN_28, $_POST['lang_choices'].' '.$del_table));
}
else
{
$message .= sprintf(LANG_LAN_29, $_POST['lang_choices'].' '.$del_table).'[!br!]'; // can be removed?
$mes->addWarning(sprintf(LANG_LAN_29, $_POST['lang_choices'].' '.$del_table));
}
}
}
$admin_log->log_event('LANG_02', $message, E_LOG_INFORMATIVE, '');
$sql->db_ResetTableList();
if ($action == 'modify')
$action = 'db';//FIX - force db action when deleting all lan tables
}
// ----------create tables -----------------------------------------------------
if (isset($_POST['create_tables']) && $_POST['language'])
{
$table_to_copy = array();
$lang_to_create = array();
foreach ($tabs as $value)
{
$lang = strtolower($_POST['language']);
if (isset($_POST[$value]))
{
$copdata = ($_POST['copydata_'.$value]) ? 1 : 0;
if ($sql->db_CopyTable($value, "lan_".$lang."_".$value, $_POST['drop'], $copdata))
{
$message .= sprintf(LANG_LAN_30, $_POST['language'].' '.$value).'[!br!]'; // can be removed?
$mes->addSuccess(sprintf(LANG_LAN_30, $_POST['language'].' '.$value));
}
else
{
if (!$_POST['drop'])
{
$message .= sprintf(LANG_LAN_00, $_POST['language'].' '.$value).'[!br!]'; // can be removed?
$mes->addWarning(sprintf(LANG_LAN_00, $_POST['language'].' '.$value));
}
else
{
$message .= sprintf(LANG_LAN_01, $_POST['language'].' '.$value).'[!br!]'; // can be removed?
$mes->addWarning(sprintf(LANG_LAN_01, $_POST['language'].' '.$value));
}
}
}
elseif ($sql->db_Table_exists($value,$_POST['language']))
{
if ($_POST['remove'])
{
// Remove table.
if (mysql_query("DROP TABLE ".$mySQLprefix."lan_".$lang."_".$value))
{
$message .= $_POST['language'].' '.$value.' '.LAN_DELETED.'[!br!]'; // can be removed?
$mes->addSuccess($_POST['language'].' '.$value.' '.LAN_DELETED);
}
else
{
$message .= sprintf(LANG_LAN_02, $_POST['language'].' '.$value).'[!br!]'; // can be removed?
$mes->addWarning(sprintf(LANG_LAN_02, $_POST['language'].' '.$value));
}
}
else
{
// leave table. LANG_LAN_32
$message .= sprintf(LANG_LAN_32, $_POST['language'].' '.$value).'[!br!]'; // can be removed?
$mes->addInfo(sprintf(LANG_LAN_32, $_POST['language'].' '.$value));
}
}
}
$admin_log->log_event('LANG_03', $message, E_LOG_INFORMATIVE, '');
$sql->db_ResetTableList();
}
/*
if(isset($message) && $message)
{
$ns->tablerender(LAN_OK, $message);
}
*/
unset($text);
if (!e_QUERY || $action == 'main' && !$_POST['language'] && !$_POST['edit_existing'])
{
multilang_prefs();
}
if (varset($action) == 'db')
{
multilang_db();
}
if (varset($_POST['ziplang']) && varset($_POST['language']))
{
if(varset($pref['lancheck'][$_POST['language']]) == 1)
{
$text = zip_up_lang($_POST['language']);
$admin_log->log_event('LANG_04', $_POST['language'], E_LOG_INFORMATIVE, '');
$mes->addInfo(LANG_LAN_25.': '.$text);
}
else
{
$mes->addWarning(LANG_LAN_36);
}
}
if (varset($action) == "tools")
{
show_tools();
if($languagePacks = available_langpacks() )
{
e107::getRender()->tablerender(LANG_LAN_34,$languagePacks );
}
}
function findIncludedFiles($script,$reverse=false)
{
$data = file_get_contents($script);
if(strpos($data, 'e_admin_dispatcher')!==false)
{
$reverse = false;
}
$dir = dirname($script);
$dir = str_replace("/includes","",$dir);
$plugin = basename($dir);
if(strpos($script,'admin')!==false || strpos($script,'includes')!==false) // Admin Language files.
{
$newLangs = array(
0 => $dir."/languages/English/English_admin_".$plugin.".php",
1 => $dir."/languages/English_admin_".$plugin.".php",
2 => $dir."/languages/English_admin.php",
3 => $dir."/languages/English/English_admin.php"
);
}
else
{
$newLangs = array(
0 => $dir."/languages/English/English_".$plugin.".php",
1 => $dir."/languages/English_admin_".$plugin.".php",
2 => $dir."/languages/English_front.php",
3 => $dir."/languages/English/English_front.php",
4 => $dir."/languages/English_front.php",
5 => $dir."/languages/English/English_front.php"
);
}
// if(strpos($data, 'e_admin_dispatcher')!==false)
{
foreach($newLangs as $path)
{
if(file_exists($path) && $reverse == false)
{
return $path;
}
}
}
preg_match_all("/.*(include_lan|require_once|include|include_once) ?\((.*e_LANGUAGE.*?\.php)/i",$data,$match);
$srch = array(" ",'e_PLUGIN.', 'e_LANGUAGEDIR', '.e_LANGUAGE.', "'", '"', "'.");
$repl = array("", e_PLUGIN, e_LANGUAGEDIR, "English", "", "", "");
foreach($match[2] as $lanFile)
{
$arrt = str_replace($srch,$repl,$lanFile);
// if(strpos($arrt,'admin'))
{
//return $arrt;
$arr[] = $arrt;
}
}
return implode(",",$arr);
// return $arr[0];
}
if(vartrue($_POST['disabled-unused']) && vartrue($_POST['disable-unused-lanfile']))
{
$mes = e107::getMessage();
$data = file_get_contents($_POST['disable-unused-lanfile']);
$new = disableUnused($data);
if(file_put_contents($_POST['disable-unused-lanfile'],$new))
{
$mes->addSuccess("Overwriting ".$_POST['disable-unused-lanfile']);
}
else
{
$mes->addError("Couldn't overwrite ".$_POST['disable-unused-lanfile']);
}
$ns->tablerender("Processed".SEP.$_POST['disable-unused-lanfile'],$mes->render()."
".htmlentities($new).""); } function disableUnused($data) { $data = str_replace("2008-2010","2008-2013", $data); $data = str_replace(' * $URL$ * $Revision$ * $Id$ * $Author$',"",$data); // TODO FIXME ? $tmp = explode("\n",$data); foreach($tmp as $line) { $ret = getDefined($line); $newline[] = (in_array($ret['define'],$_SESSION['language-tools-unused']) && substr($line,0,2) !='//') ? "// ".$line : $line; } return implode("\n",$newline); } if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans'])) { $mes = e107::getMessage(); // $lanfile = $_POST['deprecatedLans']; $script = $_POST['deprecatedLans']; if(strpos($script,e_ADMIN)!==false) // CORE { $mes->addDebug("Mode: Core Admin Calculated"); //$scriptname = str_replace("lan_","",basename($lanfile)); $lanfile = e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".basename($script); } else // Plugin { $mes->addDebug("Mode: Search Plugins"); $lanfile = findIncludedFiles($script,vartrue($_POST['deprecatedLansReverse'])); } if(!is_readable($script)) { $mes->addError("Not Readable: ".$script); // $script = $scriptname; // matching files. lan_xxxx.php and xxxx.php } $found = findIncludedFiles($script,vartrue($_POST['deprecatedLansReverse'])); // print_a($found); // Exceptions - same language loaded by several scripts. if($lanfile == e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php") { $script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php"; } if($res = unused($lanfile, $script, vartrue($_POST['deprecatedLansReverse']))) { $ns -> tablerender($res['caption'],$mes->render(). $res['text']); } } //FIX - create or edit check if (isset($_POST['create_edit_existing'])) $_POST['edit_existing'] = true; // Grab Language configuration. --- if (isset($_POST['edit_existing'])) { //XXX - JS ok with the current functionality? $text .= " "; $ns->tablerender($_POST['lang_choices'], $mes->render().$text); } require_once (e_ADMIN."footer.php"); // --------------------------------------------------------------------------- function multilang_prefs() { global $lanlist; $pref = e107::getPref(); $mes = e107::getMessage(); $frm = e107::getForm(); //XXX Remove later. // Enable only for developers - SetEnv E_ENVIRONMENT develop if(!isset($_SERVER['E_ENVIRONMENT']) || $_SERVER['E_ENVIRONMENT'] !== 'develop') { $lanlist = array('English'); $mes->addInfo("Alpha version currently supports only the English language. After most features are stable and English terms are optimized - translation will be possible."); } $text = " \n"; e107::getRender()->tablerender(ADLAN_132.SEP.LAN_PREFS, $mes->render().$text); // "Language Preferences"; } // ---------------------------------------------------------------------------- function table_list() { // grab default language lists. $exclude = array(); $exclude[] = "banlist"; $exclude[] = "banner"; $exclude[] = "cache"; $exclude[] = "core"; $exclude[] = "online"; $exclude[] = "parser"; $exclude[] = "plugin"; $exclude[] = "user"; $exclude[] = "upload"; $exclude[] = "userclass_classes"; $exclude[] = "rbinary"; $exclude[] = "session"; $exclude[] = "tmp"; $exclude[] = "flood"; $exclude[] = "stat_info"; $exclude[] = "stat_last"; $exclude[] = "submit_news"; $exclude[] = "rate"; $exclude[] = "stat_counter"; $exclude[] = "user_extended"; $exclude[] = "user_extended_struct"; $exclude[] = "pm_messages"; $exclude[] = "pm_blocks"; $tables = e107::getDb()->db_TableList('nolan'); // db table list without language tables. return array_diff($tables,$exclude); } // ------------- render form --------------------------------------------------- function multilang_db() { global $lanlist, $tabs; $sql = e107::getDb(); $frm = e107::getForm(); $tp = e107::getParser(); $mes = e107::getMessage(); $pref = e107::getPref(); if (isset($pref['multilanguage']) && $pref['multilanguage']) { // Choose Language to Edit: $text = " "; e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_16, $mes->render().$text); // Languages -> Tables } } // ---------------------------------------------------------------------------- function show_tools() { $frm = e107::getForm(); $mes = e107::getMessage(); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_lancheck.php"); $text = " "; $text .= " "; e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_21, $mes->render().$text); } // ---------------------------------------------------------------------------- function available_langpacks() { $xml = e107::getXml(); $feed = e107::getPref('xmlfeed_languagepacks'); if($rawData = $xml -> loadXMLfile($feed, TRUE)) { if(!varset($rawData['language'])) { return FALSE; } $text .= "
Name | Version | Author | Release-date | Compatible | Download |
---|---|---|---|---|---|
".$value['name']." | ".$value['version']." | ".$value['author']." | ".$value['date']." | ".$value['compatibility']." | Download Pack |
".$lanfile." | "; foreach($compare as $k=>$val) { $text .= "".$k." | "; } $text .= "";
$count = 1;
foreach($lines as $ln)
{
if(preg_match("/\b".$needle."\b/i",$ln))
{
if($disabled)
{
$text .= ADMIN_WARNING_ICON;
}
elseif($reverse == true)
{
$text .= ADMIN_TRUE_ICON;
}
$text .= " Line:".$count." "; // "' Found";
$found = TRUE;
}
$count++;
}
if(!$found)
{
// echo " Unused: ".$needle; if($reverse == true) { if(in_array($needle,$commonArray)) { $color = "background-color:#E9EAF2"; $text .= ADMIN_TRUE_ICON; $value = "Common Term"; } else { $color = "background-color:yellow"; $text .= "".ADMIN_WARNING_ICON.""; $value = "Missing from language file"; } } else { $color = "background-color:pink"; $text .= "-"; } if(!$disabled) { $_SESSION['language-tools-unused'][] = $needle; } } $text .= " | ";
}
// $color = $found ? "" : "background-color:pink";
if($foundCommon && $found)
{
$color = "background-color:yellow";
$disabled .= "
---|---|
".$needle .$disabled. " | |
".$needle .$disabled. " | ".$text."