本文整理汇总了PHP中CIBlockType类的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockType类的具体用法?PHP CIBlockType怎么用?PHP CIBlockType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIBlockType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetIBlockTypes
public function GetIBlockTypes($lid, $catalogOnly = true, $hideOffers = true)
{
CModule::IncludeModule("iblock");
$arTypeAll = array();
$dbIBlock = CIBlock::GetList(array("IBLOCK_TYPE" => "ASC", "NAME" => "ASC"), array("LID" => $lid));
while ($arIBlock = $dbIBlock->Fetch()) {
if (true == $catalogOnly) {
if (CModule::IncludeModule("catalog") && CCatalog::GetByID($arIBlock["ID"])) {
if ($hideOffers == true && CCatalogSKU::GetInfoByOfferIBlock($arIBlock["ID"])) {
continue;
}
$arTypeIblock[] = $arIBlock;
}
} else {
$arTypeIblock[] = $arIBlock;
}
}
unset($dbIBlock);
foreach ($arTypeIblock as $arIBlock) {
$arType = CIBlockType::GetByIDLang($arIBlock["IBLOCK_TYPE_ID"], LANG);
$arTypeAll[$arType["ID"]]["ID"] = $arType["ID"];
$arTypeAll[$arType["ID"]]["NAME"] = "{$arType["NAME"]} [{$arType["ID"]}]";
$arTypeAll[$arType["ID"]]["IBLOCK"][$arIBlock["ID"]] = "{$arIBlock["NAME"]} [{$arIBlock["ID"]}]";
unset($arType);
}
unset($arTypeIblock);
return $arTypeAll;
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
\CModule::IncludeModule('iblock');
$resTypes = \CIBlockType::GetList(array('id' => 'asc'));
while ($arType = $resTypes->Fetch()) {
$output->writeln("<info>" . $arType['ID'] . "</info>");
}
}
示例3: deleteIblockType
public function deleteIblockType($typeId)
{
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
if (\CIBlockType::Delete($typeId)) {
return true;
}
$this->throwException(__METHOD__, 'Could not delete iblock type %s', $typeId);
}
示例4: testAdd
public function testAdd()
{
$this->_injectDutyCollector();
$ibType = \CIBlockType::GetList()->Fetch();
$ib = new \CIBlock();
$ibId = $ib->Add(array('IBLOCK_TYPE_ID' => $ibType['ID'], 'NAME' => 'New Iblock', 'SITE_ID' => 's1'));
$this->assertNotEmpty($ibId, $this->errorMessage('not create iblock id', array(':lastError' => $ib->LAST_ERROR)));
$prop = new \CIBlockProperty();
$propId = $prop->Add(array('IBLOCK_ID' => $ibId, 'CODE' => 'propCode', 'NAME' => 'Property NAME'));
$this->assertNotEmpty($propId, $this->errorMessage('not create property iblock id', array(':lastError' => $ib->LAST_ERROR)));
$sec = new \CIBlockSection();
$secId = $sec->Add(array('IBLOCK_ID' => $ibId, 'NAME' => 'Iblock Section'));
$this->assertNotEmpty($secId, $this->errorMessage('not create section iblock id', array(':lastError' => $ib->LAST_ERROR)));
// ¬ итоге должны получитс¤
// данные по добавлению »Ѕ
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockHandler::className()));
// данные по добавлению свойства
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockPropertyHandler::className()));
// данные по добавлению секции
$this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockSectionHandler::className()));
$refFixes = $this->_getCollectorFixes('reference');
// фиксаци¤ изменений
Module::getInstance()->commitDutyChanges();
// добавлены записи журнала обновлений (в базу)
/** @var $logRecords AppliedChangesLogModel[] */
$logRecords = AppliedChangesLogModel::find(array('order' => array('id' => 'desc'), 'limit' => 10));
$this->assertTrue(count($logRecords) > 3);
$iterationsCount = 0;
foreach ($logRecords as $logRecord) {
if ($logRecord->processName == Module::SPECIAL_PROCESS_FIX_REFERENCE) {
continue;
}
if ($logRecord->processName != AddProcess::className()) {
$this->throwError($this->errorMessage('last log records need been update process'), $logRecord->processName);
}
if (++$iterationsCount > 3) {
break;
}
$data = $logRecord->updateData;
switch ($logRecord->subjectName) {
case IblockHandler::className():
(!$data['iblock'] || $data['iblock']['ID'] != $ibId) && $this->throwError($this->errorMessage('iblock not registered after update', array(':actual' => $data['iblock']['ID'], ':need' => $ibId)));
break;
case IblockPropertyHandler::className():
$data['ID'] != $propId && $this->throwError($this->errorMessage('property iblock not registered after update', array(':original' => $propId, ':actual' => $data['ID'])));
break;
case IblockSectionHandler::className():
$data['ID'] != $secId && $this->throwError($this->errorMessage('section iblock not registered after update', array(':original' => $secId, ':actual' => $data['ID'])));
break;
}
}
// добавлены три вида ссылок в фиксаци¤х
$this->assertEquals(3, count($refFixes), $this->errorMessage('links expected count', array(':count' => 3)));
$this->_iblockId = $ibId;
$this->_propertyId = $propId;
$this->_sectionId = $secId;
}
示例5: getTypesFormatted
function getTypesFormatted() {
$out = '';
$rResuls = CIBlockType::GetList();
while (false !== ($type = $rResuls->GetNext())) {
$arType = CIBlockType::GetByIDLang($type['ID'], LANGUAGE_ID, true);
$out .= sprintf('<option value="%s">%s</option>', $type['ID'], $arType['NAME']);
}
return $out;
}
示例6: showIblockTypesSelect
static function showIblockTypesSelect()
{
$res = CIBlockType::GetList();
echo '<select name="IBLOCK_TYPE">';
while ($ar_res = $res->Fetch()) {
echo "<option value='{$ar_res['ID']}'>{$ar_res['ID']}</option>";
}
echo '</select>';
}
示例7: 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;
}
示例8: 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;
}
}
}
示例9: get_iblock_types
function get_iblock_types()
{
$rIBlockTypeList = CIBlockType::GetList(array('SORT' => 'ASC'), array());
$arIBlockTypeList = array();
while ($iblock_type = $rIBlockTypeList->GetNext()) {
$arIBlockTypeList[] = $iblock_type;
}
foreach ($arIBlockTypeList as $i => $iblock_type) {
$iblock_lang_settings = CIBlockType::GetByIDLang($iblock_type['ID'], LANGUAGE_ID, true);
$arIBlockTypeList[$i]['NAME'] = $iblock_lang_settings['NAME'];
}
return $arIBlockTypeList;
}
示例10: 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);
}
示例11: deleteIBlockType
/**
* @param string $id
*
* @throws MigrationException
*/
protected function deleteIBlockType($id)
{
/** @global $APPLICATION \CMain */
/** @global $DB \CDatabase */
global $APPLICATION;
global $DB;
$DB->StartTransaction();
if (\CIBlockType::Delete($id)) {
$DB->Commit();
} else {
$DB->Rollback();
throw new MigrationException($APPLICATION->GetException());
}
}
示例12: GetIBlockTypes
function GetIBlockTypes($arTop = false)
{
if (is_array($arTop)) {
$arIBlockType = $arTop;
} else {
$arIBlockType = array();
}
$rsIBlockType = CIBlockType::GetList(array("sort" => "asc"), array("ACTIVE" => "Y"));
while ($arr = $rsIBlockType->Fetch()) {
if ($ar = CIBlockType::GetByIDLang($arr["ID"], LANGUAGE_ID)) {
$arIBlockType[$arr["ID"]] = "[" . $arr["ID"] . "] " . $ar["~NAME"];
}
}
return $arIBlockType;
}
示例13: Delete
/**
* Delete
* @param $IblockTypeCode
* @return bool
* @throws \Exception
*/
public static function Delete($IblockTypeCode)
{
$Iblock = new \CIBlock();
$iblockEl = new \CIBlockElement();
$dbIblock = $Iblock->GetList(array(), array('TYPE' => $IblockTypeCode));
while ($dbRow = $dbIblock->Fetch()) {
$iblockElDbRes = $iblockEl->GetList(array(), array('IBLOCK_ID' => $dbRow['ID']));
if ($iblockElDbRes !== false && $iblockElDbRes->SelectedRowsCount()) {
throw new BimException('Can not delete iblock type: iblock id =' . $dbRow['ID'] . ' have elements');
}
}
if (!\CIBlockType::Delete($IblockTypeCode)) {
throw new BimException('Delete iblock type error!');
}
return true;
}
示例14: GetFilterDropDown
function GetFilterDropDown($bFilter = false)
{
if($bFilter)
$arrDropdown = array(
"no" => GetMessage("SEARCH_CP_NO_LIMIT"),
"main" => "[main] ".GetMessage("SEARCH_CP_STATIC"),
);
else
$arrDropdown = array();
if(IsModuleInstalled("forum"))
$arrDropdown["forum"] = "[forum] ".GetMessage("SEARCH_CP_FORUM");
if(CModule::IncludeModule("iblock"))
{
$rsType = CIBlockType::GetList(array("sort"=>"asc"), array("ACTIVE"=>"Y"));
while ($arr=$rsType->Fetch())
{
if($ar=CIBlockType::GetByIDLang($arr["ID"], LANGUAGE_ID))
$arrDropdown["iblock_".$arr["ID"]] = "[iblock_".$arr["ID"]."] ".$ar["~NAME"];
}
}
if(IsModuleInstalled("blog"))
{
$arrDropdown["blog"] = "[blog] ".GetMessage("SEARCH_CP_BLOG");
if($bFilter)
$arrDropdown["microblog"] = "[microblog] ".GetMessage("SEARCH_CP_MICROBLOG");
}
if(IsModuleInstalled("socialnetwork"))
{
$arrDropdown["socialnetwork"] = "[socialnetwork] ".GetMessage("SEARCH_CP_SOCNET");
$arrDropdown["socialnetwork_user"] = "[socialnetwork_user] ".GetMessage("SEARCH_CP_SOCNET_USER");
}
if(IsModuleInstalled("intranet"))
$arrDropdown["intranet"] = "[intranet] ".GetMessage("SEARCH_CP_INTRANET_USERS");
if(IsModuleInstalled("crm"))
$arrDropdown["crm"] = "[crm] ".GetMessage("SEARCH_CP_CRM");
return $arrDropdown;
}
示例15: checkParams
/**
* Абстрактный метод проверки передаваемых параметров
*
* checkParams
* @param array $params
* @return mixed|void
* @throws \Exception
*/
public function checkParams($params)
{
$CIblockType = new \CIBlockType();
if (!isset($params['iblockTypeId']) || !strlen($params['iblockTypeId'])) {
throw new BimException('В параметрах не найден iblockTypeId');
}
$iblockTypeDbRes = $CIblockType->GetByID($params['iblockTypeId']);
if ($iblockTypeDbRes === false || !$iblockTypeDbRes->SelectedRowsCount()) {
throw new BimException('В системе не найден тип инфоблока с id = ' . $params['iblockTypeId']);
}
$this->ownerItemDbData = $iblockTypeDbRes->Fetch();
}