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


PHP CIBlockType::Add方法代码示例

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


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

示例1: Add

 /**
  * Add
  * @param $arFields
  * @return bool
  * @throws \Exception
  */
 public static function Add($arFields)
 {
     if (!isset($arFields['SECTIONS']) || empty($arFields['SECTIONS'])) {
         $arFields['SECTIONS'] = 'Y';
     }
     if (!isset($arFields['IN_RSS']) || empty($arFields['IN_RSS'])) {
         $arFields['IN_RSS'] = 'N';
     }
     if (isset($arFields['SORT'])) {
         if (!is_int($arFields['SORT'])) {
             if (intval($arFields['SORT'])) {
                 $arFields['SORT'] = intval($arFields['SORT']);
             } else {
                 $arFields['SORT'] = 500;
             }
         }
     } else {
         $arFields['SORT'] = 500;
     }
     if (!isset($arFields['LANG']) || empty($arFields['LANG'])) {
         $langDefaults = array('ru' => array('NAME' => 'Название', 'SECTION_NAME' => 'Разделы', 'ELEMENT_NAME' => 'Элементы'), 'en' => array('NAME' => 'Common', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements'));
         $l = \CLanguage::GetList($lby = "sort", $lorder = "asc");
         while ($arIBTLang = $l->GetNext()) {
             if (array_key_exists($arIBTLang["LID"], $langDefaults)) {
                 $arFields["LANG"][$arIBTLang["LID"]] = $langDefaults[$arIBTLang["LID"]];
             }
         }
     }
     $CIblockType = new \CIBlockType();
     if ($CIblockType->Add($arFields)) {
         return true;
     } else {
         throw new BimException($CIblockType->LAST_ERROR);
     }
 }
开发者ID:cjp2600,项目名称:bim-core,代码行数:41,代码来源:IblockTypeIntegrate.php

示例2: addIblockType

 public function addIblockType($fields = array())
 {
     $default = array('ID' => '', 'SECTIONS' => 'Y', 'IN_RSS' => 'N', 'SORT' => 100, 'LANG' => array('ru' => array('NAME' => 'Catalog', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements'), 'en' => array('NAME' => 'Catalog', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements')));
     $fields = array_replace_recursive($default, $fields);
     $ib = new \CIBlockType();
     if ($ib->Add($fields)) {
         return $fields['ID'];
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
开发者ID:andreyryabin,项目名称:sprint.migration,代码行数:10,代码来源:IblockHelper.php

示例3: addNewType

 /**
  * @throws \TAOAddTypeException
  */
 protected static function addNewType($data)
 {
     global $DB;
     $DB->StartTransaction();
     $o = new \CIBlockType();
     $res = $o->Add($data);
     if (!$res) {
         $DB->Rollback();
         throw new \TAOAddTypeException("Error create type " . $data['ID']);
     } else {
         $DB->Commit();
     }
 }
开发者ID:techart,项目名称:bitrix.tao,代码行数:16,代码来源:type.php

示例4: addIblockTypeIfNotExists

 public function addIblockTypeIfNotExists($fields)
 {
     $this->checkRequiredKeys(__METHOD__, $fields, array('ID'));
     $id = $fields['ID'];
     if ($this->getIblockTypeId($id)) {
         return $id;
     }
     $default = array('ID' => '', 'SECTIONS' => 'Y', 'IN_RSS' => 'N', 'SORT' => 100, 'LANG' => array('ru' => array('NAME' => 'Catalog', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements'), 'en' => array('NAME' => 'Catalog', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements')));
     $fields = array_merge($default, $fields);
     $ib = new \CIBlockType();
     if ($ib->Add($fields)) {
         return $id;
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
开发者ID:Hawkart,项目名称:megatv,代码行数:15,代码来源:IblockHelper.php

示例5: CheckIBlockTypeID

function CheckIBlockTypeID($strIBlockTypeID, $strNewIBlockTypeID, $strNeedAdd)
{
    $arResult = false;
    $strNeedAdd = 'Y' == $strNeedAdd ? 'Y' : 'N';
    $strNewIBlockTypeID = trim($strNewIBlockTypeID);
    $strIBlockTypeID = trim($strIBlockTypeID);
    if ('Y' == $strNeedAdd) {
        $obIBlockType = new CIBlockType();
        if ('' != $strNewIBlockTypeID) {
            $rsIBlockTypes = CIBlockType::GetByID($strNewIBlockTypeID);
            if ($arIBlockType = $rsIBlockTypes->Fetch()) {
                $arResult = array('RESULT' => 'OK', 'VALUE' => $strNewIBlockTypeID);
            } else {
                $arFields = array('ID' => $strNewIBlockTypeID, 'SECTIONS' => 'N', 'IN_RSS' => 'N', 'SORT' => 500);
                $rsLanguages = CLanguage::GetList($by = "sort", $order = "desc", array('ACTIVE' => 'Y'));
                while ($arLanguage = $rsLanguages->Fetch()) {
                    $arFields['LANG'][$arLanguage['LID']]['NAME'] = $strNewIBlockTypeID;
                }
                $mxOffersType = $obIBlockType->Add($arFields);
                if (false == $mxOffersType) {
                    $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => $obIBlockType->LAST_ERROR);
                } else {
                    $arResult = array('RESULT' => 'OK', 'VALUE' => $strNewIBlockTypeID);
                }
            }
        } else {
            $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => GetMessage('IB_E_OF_ERR_NEW_IBLOCK_TYPE_ABSENT'));
        }
    } else {
        if ('' == $strIBlockTypeID) {
            $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => GetMessage('IB_E_OF_ERR_IBLOCK_TYPE_ABSENT'));
        } else {
            $rsIBlockTypes = CIBlockType::GetByID($strIBlockTypeID);
            if (!($arIBlockType = $rsIBlockTypes->Fetch())) {
                $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => GetMessage('IB_E_OF_ERR_IBLOCK_TYPE_BAD'));
            } else {
                $arResult = array('RESULT' => 'OK', 'VALUE' => $strIBlockTypeID);
            }
        }
    }
    return $arResult;
}
开发者ID:Satariall,项目名称:izurit,代码行数:42,代码来源:iblock_edit.php

示例6: CheckIBlockType

function CheckIBlockType($ID, $SECTIONS = "Y")
{
    $obType = new CIBlockType();
    $rsType = $obType->GetByID($ID);
    if ($arType = $rsType->Fetch()) {
        return $arType["ID"];
    } else {
        $arFields = array("ID" => $ID, "SECTIONS" => $SECTIONS, "LANG" => array());
        $rsLanguages = CLanguage::GetList($by = "sort", $order = "asc");
        while ($arLanguage = $rsLanguages->Fetch()) {
            $MY_MESS = IncludeModuleLangFile(__FILE__, $arLanguage["LID"], true);
            $arFields["LANG"][$arLanguage["LID"]] = array("NAME" => $MY_MESS["IBLOCK_INSTALL_" . strtoupper($ID) . "_NAME"], "SECTION_NAME" => $MY_MESS["IBLOCK_INSTALL_" . strtoupper($ID) . "_SECTIONS_NAME"], "ELEMENT_NAME" => $MY_MESS["IBLOCK_INSTALL_" . strtoupper($ID) . "_ELEMENTS_NAME"]);
        }
        $result = $obType->Add($arFields);
        if ($result) {
            return $result;
        } else {
            return false;
        }
    }
}
开发者ID:Satariall,项目名称:izurit,代码行数:21,代码来源:step2.php

示例7: applySnapshot

 public function applySnapshot($data, $dbVersion = null)
 {
     $iblockData = $this->handleNullValues($data['iblock']);
     $typeData = $this->handleNullValues($data['type']);
     $res = new ApplyResult();
     $type = new \CIBlockType();
     if (!\CIBlockType::GetByID($typeData['ID'])->Fetch()) {
         $res->setSuccess($type->Add($typeData));
     } else {
         $res->setSuccess($type->Update($typeData['ID'], $typeData));
     }
     if (!$res->isSuccess()) {
         return $res->setMessage($type->LAST_ERROR);
     }
     $extId = $iblockData['ID'];
     if ($dbVersion) {
         $id = $this->getCurrentVersionId($extId, $dbVersion);
     } else {
         $id = $extId;
     }
     if (!$dbVersion && !IblockTable::getById($id)->fetch()) {
         $addRes = IblockTable::add(array('ID' => $id, 'IBLOCK_TYPE_ID' => $typeData['ID'], 'NAME' => 'add'));
         if (!$addRes->isSuccess()) {
             throw new \Exception('add iblock error ' . implode(', ', $addRes->getErrorMessages()));
         }
     }
     $iblock = new \CIBlock();
     if ($id && ($currentData = IblockTable::getById($id)->fetch())) {
         $iblockData['PICTURE'] = $currentData['PICTURE'];
         $res->setSuccess((bool) $iblock->Update($id, $iblockData));
     } else {
         unset($iblockData['PICTURE']);
         $res->setSuccess((bool) ($id = $iblock->Add($iblockData)));
         $this->registerCurrentVersionId($id, $this->getReferenceValue($extId, $dbVersion));
     }
     $res->setId($id);
     return $res->setMessage($iblock->LAST_ERROR);
 }
开发者ID:ASDAFF,项目名称:bitrix-module-migrations,代码行数:38,代码来源:iblockhandler.php

示例8: InstallIblockType

 private function InstallIblockType()
 {
     if ($this->arResult["INSTALLATION"]["IBLOCK_TYPE_INSTALL"]) {
         $arFields = array("ID" => $this->ModuleIblockType, "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 100, "LANG" => array());
         foreach ($this->arResult["SETTINGS"]["LANG"] as $Lang) {
             $m = IncludeModuleLangFile(__FILE__, $Lang["LANGUAGE_ID"], true);
             $arFields["LANG"][$Lang["LANGUAGE_ID"]] = array("NAME" => strlen($m["IDEA_INSTALL_IBLOCK_TYPE"]) == 0 ? "Idea Management" : $m["IDEA_INSTALL_IBLOCK_TYPE"], "SECTION_NAME" => strlen($m["IDEA_INSTALL_IBLOCK_SECTION_NAME"]) == 0 ? "Category" : $m["IDEA_INSTALL_IBLOCK_SECTION_NAME"]);
         }
         $IBT = new CIBlockType();
         if (!($IblockTypeId = $IBT->Add($arFields))) {
             $this->arResult["ERRORS"][] = $IBT->LAST_ERROR;
         }
         $this->arResult["INSTALLATION"]["IBLOCK_TYPE_ID"] = $IblockTypeId;
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:15,代码来源:step1.php

示例9: getTestIBlockType

 public function getTestIBlockType()
 {
     if (self::$_arTestIBlockType !== null) {
         return self::$_arTestIBlockType;
     }
     $testIBlockType = 'obx_test_type';
     $rsIBlockType = \CIBlockType::GetByID($testIBlockType);
     self::$_arTestIBlockType = $rsIBlockType->Fetch();
     if (!self::$_arTestIBlockType) {
         $arIBlockTypeFields = array('ID' => $testIBlockType, 'SECTIONS' => 'Y', 'IN_RSS' => 'N', 'SORT' => 1000, 'LANG' => array('en' => array('NAME' => 'OpenBX: Test info blocks', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements'), 'ru' => array('NAME' => 'OpenBX: Test info blocks', 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements')));
         $obBlockType = new \CIBlockType();
         global $DB;
         /** @global \CDatabase $DB */
         $DB->StartTransaction();
         $res = $obBlockType->Add($arIBlockTypeFields);
         if (!$res) {
             $DB->Rollback();
             $this->fail('Error: ' . $obBlockType->LAST_ERROR);
         } else {
             $DB->Commit();
             $rsIBlockType = \CIBlockType::GetByID($testIBlockType);
             self::$_arTestIBlockType = $rsIBlockType->Fetch();
         }
     }
     return self::$_arTestIBlockType;
 }
开发者ID:OpenBX,项目名称:obx.core,代码行数:26,代码来源:testcase.php

示例10: CIBlockType

 * Файл импорта структуры инфоблоков административной чавсти модуля greensight_utils
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_before.php';
IncludeModuleLangFile(__FILE__);
$APPLICATION->SetTitle(GetMessage('GREENSIGHT_IBLOCK_IMPORT_TITLE'));
if (!$USER->IsAdmin()) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog_admin_after.php";
if ($_POST) {
    do {
        $DB->StartTransaction();
        // создание инфоблока, если надо
        if ($_POST['iblock_type'] == '0') {
            $cibt = new CIBlockType();
            if ($cibt->Add(array('ID' => $_POST['newiblocktype_id'], 'SECTIONS' => 'Y', 'EDIT_FILE_BEFORE' => '', 'EDIT_FILE_AFTER' => '', 'IN_RSS' => 'N', 'SORT' => 500, 'LANG' => array('en' => array('NAME' => $_POST['newiblocktype_id'], 'SECTION_NAME' => 'Sections', 'ELEMENT_NAME' => 'Elements'), 'ru' => array('NAME' => $_POST['newiblocktype_name'], 'SECTION_NAME' => 'Секции', 'ELEMENT_NAME' => 'Элементы'))))) {
                $iBlockTypeID = $_POST['newiblocktype_id'];
            } else {
                $DB->Rollback();
                ShowError(GetMessage('GREENSIGHT_IBLOCK_IMPORT_ERROR_TYPE_CREATE'));
                break;
            }
        }
        // выбрать нужный тип инфоблока
        if (!$iBlockTypeID) {
            $rsIBlockType = CIBlockType::GetByID($_POST['iblock_type']);
            $iBlockTypeID = $rsIBlockType->Fetch();
            $iBlockTypeID = $iBlockTypeID['ID'];
        }
        if (!$iBlockTypeID) {
            $DB->Rollback();
开发者ID:RosYama,项目名称:rosyama.ru,代码行数:31,代码来源:greensight_iblock_import.php

示例11: DoInstall

	function DoInstall()
	{
		global $APPLICATION;
		if(!CModule::IncludeModule('iblock')) return false;
		
		//получаем тип инфоблока
    	$iblockType = CIBlockType::GetList(
    		array(),
    		array(
    			"ID" => "kaycom_ONEPLACESEO"
    		)
    	);
		//создаем, если такого нет
    	if(!$iblockType = $iblockType->GetNext()){
			$iT = new CIBlockType();
    		$iblockType["ID"] =  $iT->Add(
    			array(
    				"ID" 		=> "kaycom_ONEPLACESEO",
    				"SECTIONS" 	=> "N",
					"LANG" => array(
						"ru" => array(
							'NAME' => GetMessage("kaycom.oneplaceseo_IBLOCK_TYPE_NAME"),
						)
					)
    			)
    		);
    	}
    	
		//если не создался, выходим
    	if(!$iblockType["ID"]){
    		return false;
    	}
		//получаем список всех сайтов
    	$arSites = array();
    	$rsSites = CSite::GetList($by="sort", $order="desc", Array("ACTIVE" => "Y"));
		while ($arSite = $rsSites->Fetch()){
			$arSites[] = $arSite["ID"]; 
		}
    	
		//пытаемся найти инфоблок в нашем типе инфоблока
    	$iblocks = CIBlock::GetList(
    		array(),
    		array(
    			"TYPE" => "kaycom_ONEPLACESEO",
    			"CODE" => "kaycom_ONEPLACESEO"
    		)
    	);
		//если нет - создаем инфоблок с заданным набором полей
    	if(!$iblock = $iblocks->GetNext()){
			$ib = new CIBlock();
			$iblock["ID"] = $ib->Add(
				array(
					"ACTIVE" => "Y",
					"NAME" => GetMessage("kaycom.oneplaceseo_IBLOCK_TYPE_NAME"),
					"CODE" => "kaycom_ONEPLACESEO",
					"LIST_PAGE_URL" => "",
					"DETAIL_PAGE_URL" => "",
					"IBLOCK_TYPE_ID" => "kaycom_ONEPLACESEO",
					"SITE_ID" => $arSites,
					"SORT" => 10,
					"WORKFLOW" => "N",
					"EDIT_FILE_AFTER" => (strpos (SM_VERSION, '12')!==false ? "/bitrix/modules/".$this->MODULE_ID."/admin/iblock_element_edit.php" : "") // TODO: добавить файл редактирования для 11 версии
				)
			);
			
			$ibp = new CIBlockProperty;
			
			foreach(array("TITLE", "KEYWORDS", "DESCRIPTION") as $PROP_CODE){
				$ibp->Add(
					Array(
						"NAME" => GetMessage("kaycom.oneplaceseo_PROP_".$PROP_CODE),
						"ACTIVE" => "Y",
						"SORT" => 10 * $cnt++,
						"CODE" => $PROP_CODE,
						"PROPERTY_TYPE" => "S",
						"MULTIPLE" => "N",
						"IBLOCK_ID" => $iblock["ID"]
					)
				);
			}
		}
		
		
		$this->InstallFiles();
		$this->InstallDB();
		RegisterModule(self::MODULE_ID);
		
		
		
		RegisterModuleDependences("main", "OnEpilog", "kaycom.oneplaceseo",  "CKaycomOneplaceseo", "onPageLoad");
	}
开发者ID:akniyev,项目名称:itprom.ru,代码行数:91,代码来源:index.php

示例12: array

<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("iblock")) {
    return;
}
$arTypes = array(array(), array("ID" => "news", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 50, "LANG" => array()), array("ID" => "portfolio", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 100, "LANG" => array()), array("ID" => "price", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 150, "LANG" => array()), array("ID" => "reviews", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 200, "LANG" => array()), array("ID" => "services", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 250, "LANG" => array()), array("ID" => "slider", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 300, "LANG" => array()));
$arLanguages = array();
$rsLanguage = CLanguage::GetList($by, $order, array());
while ($arLanguage = $rsLanguage->Fetch()) {
    $arLanguages[] = $arLanguage["LID"];
}
$iblockType = new CIBlockType();
foreach ($arTypes as $arType) {
    $dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"]));
    if ($dbType->Fetch()) {
        continue;
    }
    foreach ($arLanguages as $languageID) {
        WizardServices::IncludeServiceLang("type.php", $languageID);
        $code = strtoupper($arType["ID"]);
        $arType["LANG"][$languageID]["NAME"] = GetMessage($code . "_TYPE_NAME");
        $arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code . "_ELEMENT_NAME");
        if ($arType["SECTIONS"] == "Y") {
            $arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code . "_SECTION_NAME");
        }
    }
    $iblockType->Add($arType);
}
开发者ID:sharapudinov,项目名称:arenda-yamobura.com,代码行数:31,代码来源:types.php

示例13: array

// ------------------ PHOTO -------------------------------
$photoIBlockTypeID = "car_gallery_demo";
$photoUserIBlockID = 0;
$photoGroupIBlockID = 0;
if (CModule::IncludeModule("iblock")) {
    $dbIBlockType = CIBlockType::GetList(array(), array("=ID" => $photoIBlockTypeID));
    if ($arIBlockType = $dbIBlockType->Fetch()) {
        $photoIBlockTypeID = $arIBlockType["ID"];
    } else {
        $arFieldsLang = array();
        foreach ($arLanguages as $arLang) {
            $arFieldsLang[$arLang["LID"]] = array("NAME" => GetSocNetMessageLocal("SONET_I_PHOTO_IBLOCK_TYPE_NAME", $arLang["LID"]));
        }
        $arFields = array("ID" => $photoIBlockTypeID, "LANG" => $arFieldsLang, "SECTIONS" => "Y");
        $iblockType = new CIBlockType();
        $photoIBlockTypeID = $iblockType->Add($arFields);
        if (strLen($photoIBlockTypeID) <= 0) {
            $errorString .= $iblockType->LAST_ERROR;
        }
    }
    if (StrLen($photoIBlockTypeID) > 0) {
        $iblockCode = "car_photo_user_demo";
        $photoUserIBlockID = 0;
        $dbIBlock = CIBlock::GetList(array(), array("SITE_ID" => $arSite["SITE_ID"], "TYPE" => $photoIBlockTypeID, "CODE" => $iblockCode));
        if ($arIBlock = $dbIBlock->Fetch()) {
            $photoUserIBlockID = IntVal($arIBlock["ID"]);
        } else {
            $arFields = array("ACTIVE" => "Y", "NAME" => GetSocNetMessageLocal("SONET_I_IBLOCK_PHOTO_USER_NAME", $arSite["LANGUAGE_ID"]), "IBLOCK_TYPE_ID" => $photoIBlockTypeID, "CODE" => $iblockCode, "RSS_ACTIVE" => "N", "WORKFLOW" => "N", "INDEX_ELEMENT" => "N", "LID" => array($arSite["SITE_ID"]));
            $iblock = new CIBlock();
            $dbUGroups = CGroup::GetList($by = "c_sort", $order = "asc");
            while ($arUGroups = $dbUGroups->Fetch()) {
开发者ID:k-kalashnikov,项目名称:geekcon.local,代码行数:31,代码来源:install_demo.php

示例14: DEMO_IBlock_CreateType

function DEMO_IBlock_CreateType($IBLOCK_TYPES = false)
{
    if (!is_array($IBLOCK_TYPES)) {
        $IBLOCK_TYPES = array("news", "services", "photo", "books", "articles", "paid", "xmlcatalog");
    }
    $arTypes = array("news" => array("ID" => "news", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 10, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_NEWS_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_NEWS_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_NEWS_ELEMENT_NAME")))), "articles" => array("ID" => "articles", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 20, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_ARTICLES_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_ARTICLES_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_ARTICLES_ELEMENT_NAME")))), "photo" => array("ID" => "photo", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 40, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_PHOTO_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_PHOTO_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_PHOTO_ELEMENT_NAME")))), "services" => array("ID" => "services", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 50, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_SERVICES_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_SERVICES_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_SERVICES_ELEMENT_NAME")))), "books" => array("ID" => "books", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 60, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_BOOKS_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_BOOKS_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_BOOKS_ELEMENT_NAME")))), "paid" => array("ID" => "paid", "SECTIONS" => "N", "IN_RSS" => "N", "SORT" => 70, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_PAID_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_PAID_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_PAID_ELEMENT_NAME")))), "xmlcatalog" => array("ID" => "xmlcatalog", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 80, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_XMLCATALOG_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_XMLCATALOG_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_XMLCATALOG_ELEMENT_NAME")))), "lists" => array("ID" => "lists", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 90, "LANG" => array(LANGUAGE_ID => array("NAME" => GetMessage("DEMO_IBLOCK_TYPE_LISTS_NAME"), "SECTION_NAME" => GetMessage("DEMO_IBLOCK_TYPE_LISTS_SECTION_NAME"), "ELEMENT_NAME" => GetMessage("DEMO_IBLOCK_TYPE_LISTS_ELEMENT_NAME")))));
    foreach ($IBLOCK_TYPES as $TYPE_ID) {
        if (array_key_exists($TYPE_ID, $arTypes)) {
            $obType = new CIBlockType();
            $arFields = $arTypes[$TYPE_ID];
            $rsType = $obType->GetList(array(), array("=ID" => $arFields["ID"]));
            if ($arType = $rsType->Fetch()) {
                continue;
            } else {
                $obType->Add($arFields);
            }
        }
    }
}
开发者ID:webgksupport,项目名称:alpina,代码行数:19,代码来源:iblock_tools.php

示例15: CreateCatalog

 public static function CreateCatalog($originatorID = '', $name = '', $siteID = null)
 {
     if (!is_string($originatorID) || strlen($originatorID) == 0) {
         $originatorID = null;
     }
     if ($siteID == null) {
         $siteID = SITE_ID;
     }
     $langID = LANGUAGE_ID;
     $dbSite = CSite::GetById($siteID);
     if ($arSite = $dbSite->Fetch()) {
         $langID = $arSite['LANGUAGE_ID'];
     }
     $result = true;
     //check type type
     $typeID = self::GetCatalogTypeID();
     //$rsIBlockTypes = CIBlockType::GetByID($typeID); // CIBlockType::GetByID() is unstable
     $rsIBlockTypes = CIBlockType::GetList(array(), array("=ID" => $typeID));
     if (!$rsIBlockTypes->Fetch()) {
         $iblocktype = new CIBlockType();
         $result = $iblocktype->Add(array('ID' => $typeID, 'SECTIONS' => 'Y', 'IN_RSS' => 'N', 'SORT' => 100, 'LANG' => array($langID => array('NAME' => GetMessage('CRM_PRODUCT_CATALOG_TYPE_TITLE'), 'SECTION_NAME' => GetMessage('CRM_PRODUCT_CATALOG_SECTION_NAME'), 'ELEMENT_NAME' => GetMessage('CRM_PRODUCT_CATALOG_PRODUCT_NAME')))));
         if (!$result) {
             self::RegisterError($iblocktype->LAST_ERROR);
             return false;
         }
     }
     //echo 'Error: '.$obBlocktype->LAST_ERROR.'<br/>';
     $arSite = array();
     $sites = CSite::GetList($by = 'sort', $order = 'desc', array('ACTIVE' => 'Y'));
     while ($site = $sites->Fetch()) {
         $arSite[] = $site['LID'];
     }
     //creation of iblock
     $iblock = new CIBlock();
     $iblockID = $iblock->Add(array('NAME' => isset($name[0]) ? $name : GetMessage('CRM_PRODUCT_CATALOG_TITLE'), 'ACTIVE' => 'Y', 'IBLOCK_TYPE_ID' => $typeID, 'LID' => $siteID, 'SORT' => 100, 'XML_ID' => 'crm_external_' . $originatorID, 'INDEX_ELEMENT' => 'N', 'WORKFLOW' => 'N', 'BIZPROC' => 'N', 'VERSION' => 1, 'GROUP_ID' => array(2 => 'R')));
     if ($iblockID === false) {
         self::RegisterError($iblock->LAST_ERROR);
         return false;
     }
     //echo 'Error: '.$iblock->LAST_ERROR.'<br/>';
     //creation of catalog
     $result = CCrmCatalog::Add(array('ID' => $iblockID, 'ORIGINATOR_ID' => $originatorID));
     if ($result === false) {
         self::RegisterError('Catalog creation error');
         return false;
     }
     return $iblockID;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:48,代码来源:crm_catalog.php


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