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


PHP CLanguage::Add方法代码示例

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


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

示例1: Add

 /**
  * Добавление языка
  *
  * @param $fields
  * @return array|bool
  * @throws BimException
  */
 public static function Add($fields)
 {
     $arReqFields = array('LID', 'SORT', 'NAME', 'FORMAT_DATE', 'FORMAT_DATETIME', 'CHARSET');
     foreach ($arReqFields as $key) {
         if (empty($fields[$key])) {
             throw new BimException('Field ' . $key . ' is empty.');
         }
     }
     if (!isset($fields['ACTIVE']) || empty($fields['ACTIVE'])) {
         $fields['ACTIVE'] = "N";
     }
     if (!isset($fields['DIRECTION']) || empty($fields['DIRECTION'])) {
         $fields['DIRECTION'] = "Y";
     }
     if (!isset($fields['DEF']) || empty($fields['DEF'])) {
         $fields['DEF'] = "N";
     }
     if (!isset($fields['FORMAT_NAME']) || empty($fields['FORMAT_NAME'])) {
         $fields['FORMAT_NAME'] = "#NOBR##NAME# #LAST_NAME##/NOBR#";
     }
     $obLang = new \CLanguage();
     $ID = $obLang->Add($fields);
     if ($ID) {
         return $ID;
     } else {
         throw new BimException($obLang->LAST_ERROR);
     }
 }
开发者ID:cjp2600,项目名称:bim-core,代码行数:35,代码来源:LanguageIntegrate.php

示例2: InstallDB

 function InstallDB()
 {
     /** @global string $DBType */
     global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $APPLICATION;
     if (!is_object($APPLICATION)) {
         $APPLICATION = new CMain();
     }
     $DB = new CDatabase();
     $DB->DebugToFile = false;
     $DB->debug = true;
     if (!defined("DBPersistent")) {
         define("DBPersistent", false);
     }
     if (!$DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) {
         $APPLICATION->ThrowException(GetMessage("MAIN_INSTALL_DB_ERROR"));
         return false;
     }
     $result = $DB->Query("SELECT * FROM b_module WHERE ID='main'", true, "", array("fixed_connection" => true));
     $success = $result && $result->Fetch();
     if ($success) {
         return true;
     }
     if ($DBType == "mysql" && defined("MYSQL_TABLE_TYPE") && strlen(MYSQL_TABLE_TYPE) > 0) {
         $DB->Query("SET storage_engine = '" . MYSQL_TABLE_TYPE . "'", true);
     }
     $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/install/" . $DBType . "/install.sql");
     if ($errors !== false) {
         $APPLICATION->ThrowException(implode("", $errors));
         return false;
     }
     $this->InstallTasks();
     $group = new CGroup();
     $arGroups = array(array("~ID" => 1, "ACTIVE" => "Y", "C_SORT" => 1, "NAME" => GetMessage("MAIN_ADMIN_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_ADMIN_GROUP_DESC")), array("~ID" => 2, "ACTIVE" => "Y", "C_SORT" => 2, "NAME" => GetMessage("MAIN_EVERYONE_GROUP_NAME"), "ANONYMOUS" => "Y", "DESCRIPTION" => GetMessage("MAIN_EVERYONE_GROUP_DESC")), array("~ID" => 3, "ACTIVE" => "Y", "C_SORT" => 3, "NAME" => GetMessage("MAIN_VOTE_RATING_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_VOTE_RATING_GROUP_DESC"), "STRING_ID" => "RATING_VOTE"), array("~ID" => 4, "ACTIVE" => "Y", "C_SORT" => 4, "NAME" => GetMessage("MAIN_VOTE_AUTHORITY_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_VOTE_AUTHORITY_GROUP_DESC"), "STRING_ID" => "RATING_VOTE_AUTHORITY"));
     foreach ($arGroups as $arGroup) {
         $rsGroup = CGroup::GetByID($arGroup["~ID"]);
         if ($rsGroup->Fetch()) {
             continue;
         }
         //mssql does not allow insert identity by default
         if (strtolower($DB->type) == "mssql") {
             unset($arGroup["~ID"]);
         }
         $success = (bool) $group->Add($arGroup);
         if (!$success) {
             $APPLICATION->ThrowException($group->LAST_ERROR);
             return false;
         }
     }
     self::InstallRatings();
     $arLanguages = array(array("LID" => LANGUAGE_ID, "ACTIVE" => "Y", "SORT" => 1, "DEF" => "Y", "NAME" => GetMessage("MAIN_DEFAULT_LANGUAGE_NAME"), "FORMAT_DATE" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_DATE"), "FORMAT_DATETIME" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_DATETIME"), "FORMAT_NAME" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_NAME"), "CHARSET" => defined("BX_UTF") ? "UTF-8" : GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_CHARSET")));
     if (LANGUAGE_ID != "en") {
         $arLanguages[] = array("LID" => "en", "ACTIVE" => "Y", "SORT" => 2, "DEF" => "N", "NAME" => "English", "FORMAT_DATE" => "MM/DD/YYYY", "FORMAT_DATETIME" => "MM/DD/YYYY H:MI:SS T", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "iso-8859-1");
     }
     if (LANGUAGE_ID != "de" && file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/lang/de/install/index.php')) {
         $arLanguages[] = array("LID" => "de", "ACTIVE" => "Y", "SORT" => 3, "DEF" => "N", "NAME" => "German", "FORMAT_DATE" => "DD.MM.YYYY", "FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "iso-8859-1");
     }
     if (LANGUAGE_ID != "ru" && file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/lang/ru/install/index.php')) {
         $arLanguages[] = array("LID" => "ru", "ACTIVE" => "Y", "SORT" => 3, "DEF" => "N", "NAME" => "Russian", "FORMAT_DATE" => "DD.MM.YYYY", "FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "windows-1251");
     }
     $lang = new CLanguage();
     foreach ($arLanguages as $arLanguage) {
         $rsLang = CLanguage::GetByID($arLanguage["LID"]);
         if ($rsLang->Fetch()) {
             continue;
         }
         $success = (bool) $lang->Add($arLanguage);
         if (!$success) {
             $APPLICATION->ThrowException($lang->LAST_ERROR);
             return false;
         }
     }
     $arSite = array("LID" => "s1", "ACTIVE" => "Y", "SORT" => 1, "DEF" => "Y", "NAME" => GetMessage("MAIN_DEFAULT_SITE_NAME"), "DIR" => "/", "FORMAT_DATE" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_DATE"), "FORMAT_DATETIME" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_DATETIME"), "FORMAT_NAME" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_NAME"), "CHARSET" => defined("BX_UTF") ? "UTF-8" : GetMessage("MAIN_DEFAULT_SITE_FORMAT_CHARSET"), "LANGUAGE_ID" => LANGUAGE_ID);
     $rsSites = CSite::GetByID($arSite["LID"]);
     if (!$rsSites->Fetch()) {
         $site = new CSite();
         $success = (bool) $site->Add($arSite);
         if (!$success) {
             $APPLICATION->ThrowException($site->LAST_ERROR);
             return false;
         }
     }
     RegisterModule("main");
     RegisterModuleDependences('iblock', 'OnIBlockPropertyBuildList', 'main', 'CIBlockPropertyUserID', 'GetUserTypeDescription', 100, '/modules/main/tools/prop_userid.php');
     RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CFavorites', 'OnUserDelete', 100, "/modules/main/classes/" . strtolower($GLOBALS["DB"]->type) . "/favorites.php");
     RegisterModuleDependences('main', 'OnLanguageDelete', 'main', 'CFavorites', 'OnLanguageDelete', 100, "/modules/main/classes/" . strtolower($GLOBALS["DB"]->type) . "/favorites.php");
     RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CUserOptions', 'OnUserDelete');
     RegisterModuleDependences('main', 'OnChangeFile', 'main', 'CMain', 'OnChangeFileComponent');
     RegisterModuleDependences('main', 'OnUserTypeRightsCheck', 'main', 'CUser', 'UserTypeRightsCheck');
     RegisterModuleDependences('main', 'OnUserLogin', 'main', 'UpdateTools', 'CheckUpdates');
     RegisterModuleDependences('main', 'OnModuleUpdate', 'main', 'UpdateTools', 'SetUpdateResult');
     RegisterModuleDependences('main', 'OnUpdateCheck', 'main', 'UpdateTools', 'SetUpdateError');
     RegisterModuleDependences('main', 'OnPanelCreate', 'main', 'CUndo', 'CheckNotifyMessage');
     RegisterModuleDependences('main', 'OnAfterAddRating', 'main', 'CRatingsComponentsMain', 'OnAfterAddRating');
     RegisterModuleDependences('main', 'OnAfterUpdateRating', 'main', 'CRatingsComponentsMain', 'OnAfterUpdateRating');
     RegisterModuleDependences('main', 'OnSetRatingsConfigs', 'main', 'CRatingsComponentsMain', 'OnSetRatingConfigs');
     RegisterModuleDependences('main', 'OnGetRatingsConfigs', 'main', 'CRatingsComponentsMain', 'OnGetRatingConfigs');
     RegisterModuleDependences('main', 'OnGetRatingsObjects', 'main', 'CRatingsComponentsMain', 'OnGetRatingObject');
     RegisterModuleDependences('main', 'OnGetRatingContentOwner', 'main', 'CRatingsComponentsMain', 'OnGetRatingContentOwner');
     RegisterModuleDependences('main', 'OnAfterAddRatingRule', 'main', 'CRatingRulesMain', 'OnAfterAddRatingRule');
     RegisterModuleDependences('main', 'OnAfterUpdateRatingRule', 'main', 'CRatingRulesMain', 'OnAfterUpdateRatingRule');
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:101,代码来源:index.php

示例3: array

IncludeModuleLangFile(__FILE__);
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIN_PARAM"), "ICON" => "lang_edit", "TITLE" => GetMessage("MAIN_PARAM_TITLE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$message = null;
$bVarsFromForm = false;
$ID = IntVal($ID);
if ($REQUEST_METHOD == "POST" && (strlen($save) > 0 || strlen($apply) > 0) && $isAdmin && check_bitrix_sessid()) {
    $arFields = array("ACTIVE" => $_REQUEST['ACTIVE'], "SORT" => $_REQUEST['SORT'], "DEF" => $_REQUEST['DEF'], "NAME" => $_REQUEST['NAME'], "FORMAT_DATE" => $_REQUEST['FORMAT_DATE'], "FORMAT_DATETIME" => $_REQUEST['FORMAT_DATETIME'], "WEEK_START" => intval($_REQUEST["WEEK_START"]), "FORMAT_NAME" => CSite::GetNameFormatByValue($_REQUEST["FORMAT_NAME"]), "CHARSET" => $_REQUEST['CHARSET'], "DIRECTION" => $_REQUEST['DIRECTION']);
    if ($ID <= 0) {
        $arFields["LID"] = $LID;
    }
    $langs = new CLanguage();
    if ($ID > 0) {
        $res = $langs->Update($LID, $arFields);
    } else {
        $res = strlen($langs->Add($arFields)) > 0;
        $new = "Y";
    }
    if (!$res) {
        $bVarsFromForm = true;
    } else {
        if (strlen($save) > 0) {
            LocalRedirect(BX_ROOT . "/admin/lang_admin.php?lang=" . LANGUAGE_ID);
        } elseif ($new == "Y") {
            LocalRedirect(BX_ROOT . "/admin/lang_edit.php?lang=" . LANGUAGE_ID . "&LID=" . $LID . "&" . $tabControl->ActiveTabParam());
        } else {
            LocalRedirect(BX_ROOT . "/admin/lang_edit.php?lang=" . LANGUAGE_ID . "&LID=" . $LID . "&" . $tabControl->ActiveTabParam());
        }
    }
}
$str_ACTIVE = "Y";
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:lang_edit.php

示例4: array

             echo "ERR" . $errorMessage;
         } else {
             if (isset($arStepUpdateInfo["DATA"]["#"]["ITEM"])) {
                 $ar = array();
                 $dbRes = CLanguage::GetList($by = "sort", $order = "asc", array("ACTIVE" => "Y"));
                 while ($arRes = $dbRes->Fetch()) {
                     $ar[] = $arRes["ID"];
                 }
                 for ($i = 0, $cnt = count($arStepUpdateInfo["DATA"]["#"]["ITEM"]); $i < $cnt; $i++) {
                     if (isset($arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["ID"]) && !in_array($arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["ID"], $ar)) {
                         $arF = array("LID" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["ID"], "NAME" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["NAME_EN"], "FORMAT_DATE" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["FORMAT_DATE"], "FORMAT_DATETIME" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["FORMAT_DATETIME"], "CHARSET" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["ENC"], "DIRECTION" => $arStepUpdateInfo["DATA"]["#"]["ITEM"][$i]["@"]["DIRECTION"], "ACTIVE" => "Y");
                         if (defined('BX_UTF')) {
                             $arF["CHARSET"] = "utf-8";
                         }
                         $l = new CLanguage();
                         $l->Add($arF);
                     }
                 }
             }
             echo "STP";
             echo count($arItemsUpdated) . "|";
             $bFirst = True;
             foreach ($arItemsUpdated as $key => $value) {
                 CUpdateClient::AddMessage2Log("Updated: " . $key . (StrLen($value) > 0 ? "(" . $value . ")" : ""), "UPD_SUCCESS");
                 echo ($bFirst ? "" : ", ") . $key . (StrLen($value) > 0 ? "(" . $value . ")" : "");
                 $bFirst = False;
             }
         }
     }
 } else {
     CUpdateClient::AddMessage2Log("Error: " . $errorMessage, "UPD_ERROR");
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:update_system_call.php


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