当前位置: 首页>>代码示例>>PHP>>正文


PHP ilLanguage::replaceLangEntry方法代码示例

本文整理汇总了PHP中ilLanguage::replaceLangEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP ilLanguage::replaceLangEntry方法的具体用法?PHP ilLanguage::replaceLangEntry怎么用?PHP ilLanguage::replaceLangEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilLanguage的用法示例。


在下文中一共展示了ilLanguage::replaceLangEntry方法的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);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:90,代码来源:class.ilLanguage.php


注:本文中的ilLanguage::replaceLangEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。