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


PHP getLanguagePackName函数代码示例

本文整理汇总了PHP中getLanguagePackName函数的典型用法代码示例。如果您正苦于以下问题:PHP getLanguagePackName函数的具体用法?PHP getLanguagePackName怎么用?PHP getLanguagePackName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getLanguagePackName函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: commitLanguagePack

/**
 * copies the temporary unzip'd files to their final destination
 * removes unzip'd files from system if $uninstall=true
 * @param bool uninstall true if uninstalling a language pack
 * @return array sugar_config
 */
function commitLanguagePack($uninstall = false)
{
    global $sugar_config;
    global $mod_strings;
    global $base_upgrade_dir;
    global $base_tmp_upgrade_dir;
    $errors = array();
    $manifest = urldecode($_REQUEST['manifest']);
    $zipFile = urldecode($_REQUEST['zipFile']);
    $version = "";
    $show_files = true;
    $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
    $zip_from_dir = ".";
    $zip_to_dir = ".";
    $zip_force_copy = array();
    if ($uninstall == false && isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($zipFile, $_SESSION['INSTALLED_LANG_PACKS'])) {
        return;
    }
    // unzip lang pack to temp dir
    if (isset($zipFile) && !empty($zipFile)) {
        if (is_file($zipFile)) {
            unzip($zipFile, $unzip_dir);
        } else {
            echo $mod_strings['ERR_LANG_MISSING_FILE'] . $zipFile;
            die;
            // no point going any further
        }
    }
    // filter for special to/from dir conditions (langpacks generally don't have them)
    if (isset($manifest) && !empty($manifest)) {
        if (is_file($manifest)) {
            include $manifest;
            if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
                $zip_from_dir = $manifest['copy_files']['from_dir'];
            }
            if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
                $zip_to_dir = $manifest['copy_files']['to_dir'];
            }
            if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
                $zip_force_copy = $manifest['copy_files']['force_copy'];
            }
            if (isset($manifest['version'])) {
                $version = $manifest['version'];
            }
        } else {
            $errors[] = $mod_strings['ERR_LANG_MISSING_FILE'] . $manifest;
        }
    }
    // find name of language pack: find single file in include/language/xx_xx.lang.php
    $d = dir("{$unzip_dir}/{$zip_from_dir}/include/language");
    while ($f = $d->read()) {
        if ($f == "." || $f == "..") {
            continue;
        } else {
            if (preg_match("/(.*)\\.lang\\.php\$/", $f, $match)) {
                $new_lang_name = $match[1];
            }
        }
    }
    if ($new_lang_name == "") {
        die($mod_strings['ERR_LANG_NO_LANG_FILE'] . $zipFile);
    }
    $new_lang_desc = getLanguagePackName("{$unzip_dir}/{$zip_from_dir}/include/language/{$new_lang_name}.lang.php");
    if ($new_lang_desc == "") {
        die("No language pack description found at include/language/{$new_lang_name}.lang.php inside {$install_file}.");
    }
    // add language to available languages
    $sugar_config['languages'][$new_lang_name] = $new_lang_desc;
    // get an array of all files to be moved
    $filesFrom = array();
    $filesFrom = findAllFiles($unzip_dir, $filesFrom);
    ///////////////////////////////////////////////////////////////////////////
    ////    FINALIZE
    if ($uninstall) {
        // unlink all pack files
        foreach ($filesFrom as $fileFrom) {
            //echo "deleting: ".getcwd().substr($fileFrom, strlen($unzip_dir), strlen($fileFrom))."<br>";
            @unlink(getcwd() . substr($fileFrom, strlen($unzip_dir), strlen($fileFrom)));
        }
        // remove session entry
        if (isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS'])) {
            foreach ($_SESSION['INSTALLED_LANG_PACKS'] as $k => $langPack) {
                if ($langPack == $zipFile) {
                    unset($_SESSION['INSTALLED_LANG_PACKS'][$k]);
                    unset($_SESSION['INSTALLED_LANG_PACKS_VERSION'][$k]);
                    unset($_SESSION['INSTALLED_LANG_PACKS_MANIFEST'][$k]);
                    $removedLang = $k;
                }
            }
            // remove language from config
            $new_langs = array();
            $old_langs = $sugar_config['languages'];
            foreach ($old_langs as $key => $value) {
                if ($key != $removedLang) {
//.........这里部分代码省略.........
开发者ID:stefano6310,项目名称:SuiteCRM,代码行数:101,代码来源:install_utils.php

示例2: dir

     // find name of language pack: find single file in include/language/xx_xx.lang.php
     $d = dir("{$unzip_dir}/{$zip_from_dir}/include/language");
     while ($f = $d->read()) {
         if ($f == "." || $f == "..") {
             continue;
         } else {
             if (preg_match("/(.*)\\.lang\\.php\$/", $f, $match)) {
                 $new_lang_name = $match[1];
             }
         }
     }
     if ($new_lang_name == "") {
         die($mod_strings['ERR_UW_NO_LANGPACK'] . $install_file);
     }
     $hidden_fields .= "<input type=hidden name=\"new_lang_name\" value=\"{$new_lang_name}\"/>";
     $new_lang_desc = getLanguagePackName("{$unzip_dir}/{$zip_from_dir}/include/language/{$new_lang_name}.lang.php");
     if ($new_lang_desc == "") {
         die($mod_strings['ERR_UW_NO_LANG_DESC_1'] . "include/language/{$new_lang_name}.lang.php" . $mod_strings['ERR_UW_NO_LANG_DESC_2'] . "{$install_file}.");
     }
     $hidden_fields .= "<input type=hidden name=\"new_lang_desc\" value=\"{$new_lang_desc}\"/>";
     if (!is_writable("config.php")) {
         die($mod_strings['ERR_UW_CONFIG']);
     }
     break;
 case "module":
     $previous_install = array();
     if (!empty($id_name) & !empty($version)) {
         $previous_install = $uh->determineIfUpgrade($id_name, $version);
     }
     $previous_version = empty($previous_install['version']) ? '' : $previous_install['version'];
     $previous_id = empty($previous_install['id']) ? '' : $previous_install['id'];
开发者ID:klr2003,项目名称:sourceread,代码行数:31,代码来源:UpgradeWizard_prepare.php


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