本文整理汇总了PHP中ilLanguage::replaceLangModule方法的典型用法代码示例。如果您正苦于以下问题:PHP ilLanguage::replaceLangModule方法的具体用法?PHP ilLanguage::replaceLangModule怎么用?PHP ilLanguage::replaceLangModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilLanguage
的用法示例。
在下文中一共展示了ilLanguage::replaceLangModule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertLanguage
/**
* insert language data from file in database
*
* @param string $lang_key international language key (2 digits)
* @param string $scope empty (global) or "local"
* @return void
*/
function insertLanguage($lang_key, $scope = '')
{
$ilDB =& $this->db;
$lang_array = array();
if (!empty($scope)) {
if ($scope == 'global') {
$scope = '';
} else {
$scopeExtension = '.' . $scope;
}
}
$path = $this->lang_path;
if ($scope == "local") {
$path = $this->cust_lang_path;
}
$tmpPath = getcwd();
chdir($path);
$lang_file = "ilias_" . $lang_key . ".lang" . $scopeExtension;
if ($lang_file) {
// initialize the array for updating lng_modules below
$lang_array = array();
$lang_array["common"] = array();
// remove header first
if ($content = $this->cut_header(file($lang_file))) {
// get the local changes from the database
if (empty($scope)) {
$local_changes = $this->getLocalChanges($lang_key);
} else {
if ($scope == 'local') {
$change_date = date("Y-m-d H:i:s", time());
$min_date = date("Y-m-d H:i:s", filemtime($lang_file));
$local_changes = $this->getLocalChanges($lang_key, $min_date);
}
}
foreach ($content as $key => $val) {
$separated = explode($this->separator, trim($val));
//get position of the comment_separator
$pos = strpos($separated[2], $this->comment_separator);
if ($pos !== false) {
//cut comment of
$separated[2] = substr($separated[2], 0, $pos);
}
// check if the value has a local change
$local_value = $local_changes[$separated[0]][$separated[1]];
if (empty($scope)) {
if ($local_value != "" and $local_value != $separated[2]) {
// keep the locally changed value
$lang_array[$separated[0]][$separated[1]] = $local_value;
} else {
// insert a new value if no local value exists
// reset local_change if the values are equal
ilLanguage::replaceLangEntry($separated[0], $separated[1], $lang_key, $separated[2]);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
} else {
if ($scope == 'local') {
if ($local_value != "") {
// keep a locally changed value that is newer than the local file
$lang_array[$separated[0]][$separated[1]] = $local_value;
} else {
// UPDATE because the global values have already been INSERTed
ilLanguage::updateLangEntry($separated[0], $separated[1], $lang_key, $separated[2], $change_date);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
}
}
}
}
foreach ($lang_array as $module => $lang_arr) {
if ($scope == "local") {
$q = "SELECT * FROM lng_modules WHERE " . " lang_key = " . $ilDB->quote($this->key, "text") . " AND module = " . $ilDB->quote($module, "text");
$set = $ilDB->query($q);
$row = $ilDB->fetchAssoc($set);
$arr2 = unserialize($row["lang_array"]);
if (is_array($arr2)) {
$lang_arr = array_merge($arr2, $lang_arr);
}
}
ilLanguage::replaceLangModule($lang_key, $module, $lang_arr);
}
}
chdir($tmpPath);
}