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


PHP CIBlockElement::GetIBVersion方法代码示例

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


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

示例1: Add

 /**
  * <p>Метод добавляет новое свойство. Отменить добавление или изменить поля свойства можно в обработчике события <a href="http://dev.1c-bitrix.ru/api_help/iblock/events/onbeforeiblockpropertyadd.php">OnBeforeIBlockPropertyAdd</a>. После добавления нового свойства вызываются обработчики события <a href="http://dev.1c-bitrix.ru/api_help/iblock/events/onafteriblockpropertyadd.php">OnAfterIBlockPropertyAdd</a>. Метод динамичный.</p>
  *
  *
  * @param array $arFields  Массив Array("поле"=&gt;"значение", ...). Содержит значения <a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/fields.php#fproperty">всех полей</a> свойства. Кроме
  * того, с помощью поля "VALUES", значением которого должен быть массив
  * структуры array(array("VALUE"=&gt;"значение", "DEF"=&gt;"по умолчанию (Y/N)",
  * "SORT"=&gt;"индекс сортировки"),...), можно установить варианты выбора
  * для свойств типа "список" (подробнее смотрите метод <a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/index.php">CIBlockProperty</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/updateenum.php">UpdateEnum()</a>).
  *
  * @return int 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?<br>$arFields = Array(<br>  "NAME" =&gt; "Цвет",<br>  "ACTIVE" =&gt; "Y",<br>  "SORT" =&gt; "100",<br>  "CODE" =&gt; "color",<br>  "PROPERTY_TYPE" =&gt; "L",<br>  "IBLOCK_ID" =&gt; 11<br>  );<br><br>$arFields["VALUES"][0] = Array(<br>  "VALUE" =&gt; "Красный",<br>  "DEF" =&gt; "N",<br>  "SORT" =&gt; "100"<br>);<br><br>$arFields["VALUES"][1] = Array(<br>  "VALUE" =&gt; "Желтый",<br>  "DEF" =&gt; "N",<br>  "SORT" =&gt; "200"<br>);<br><br>$arFields["VALUES"][2] = Array(<br>  "VALUE" =&gt; "Зеленый",<br>  "DEF" =&gt; "Y",<br>  "SORT" =&gt; "300"<br>);<br><br>$ibp = new CIBlockProperty;<br>$PropID = $ibp-&gt;Add($arFields);<br>?&gt;<br>
  * 
  * 
  * 
  * //добавление свойства типа "HTML"
  *  $arFields = Array(
  *         "NAME" =&gt; "Итог",
  *         "ACTIVE" =&gt; "Y",
  *         "SORT" =&gt; "600",
  *         "CODE" =&gt; "ITOG",
  *         "PROPERTY_TYPE" =&gt; "S",
  *         "USER_TYPE" =&gt; "HTML" 
  *         "IBLOCK_ID" =&gt; $arParams["IBLOCK_ID"],
  *         );
  *       
  *       $ibp = new CIBlockProperty;
  *       $PropID = $ibp-&gt;Add($arFields);
  * 
  * 
  * //для добавления свойства типа "Видео" в массиве arFields должно быть указано:
  * "PROPERTY_TYPE" =&gt; "S",
  * "USER_TYPE" =&gt; "video",
  * 
  * 
  * 
  * //установка параметра "Выводить поле для описания значения" для свойства инфоблока ("WITH_DESCRIPTION" =&gt; "Y") - доступно только для типов свойств:  S - строка, N - число и F - файл
  *   $arFields = Array(
  *       "NAME" =&gt; "Прочее",
  *       "ACTIVE" =&gt; "Y",
  *       "SORT" =&gt; "1700",
  *       "CODE" =&gt; "F_OTHER",
  *       "PROPERTY_TYPE" =&gt; "S",
  *       "IBLOCK_ID" =&gt; $IBLOCK_ID,
  *       "WITH_DESCRIPTION" =&gt; "Y",
  *       );
  * 
  *    $iblockproperty = new CIBlockProperty;
  *    $PropertyID = $iblockproperty-&gt;Add($arFields);
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/update.php">CIBlockProperty::Update</a> </li>
  * <li><a href="http://dev.1c-bitrix.ru/api_help/iblock/fields.php#fproperty">Поля свойства</a></li> <li><a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/events/onbeforeiblockpropertyadd.php">OnBeforeIBlockPropertyAdd</a></li>
  * <li><a
  * href="http://dev.1c-bitrix.ru/api_help/iblock/events/onafteriblockpropertyadd.php">OnAfterIBlockPropertyAdd</a></li>
  * </ul> <a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/add.php
  * @author Bitrix
  */
 public function Add($arFields)
 {
     global $DB;
     if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     if (!isset($arFields["SEARCHABLE"]) || $arFields["SEARCHABLE"] != "Y") {
         $arFields["SEARCHABLE"] = "N";
     }
     if (!isset($arFields["FILTRABLE"]) || $arFields["FILTRABLE"] != "Y") {
         $arFields["FILTRABLE"] = "N";
     }
     if (is_set($arFields, "MULTIPLE") && $arFields["MULTIPLE"] != "Y") {
         $arFields["MULTIPLE"] = "N";
     }
     if (is_set($arFields, "LIST_TYPE") && $arFields["LIST_TYPE"] != "C") {
         $arFields["LIST_TYPE"] = "L";
     }
     if (!$this->CheckFields($arFields)) {
         $Result = false;
         $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR;
     } else {
         $arFields["VERSION"] = CIBlockElement::GetIBVersion($arFields["IBLOCK_ID"]);
         unset($arFields["ID"]);
         if (isset($arFields["USER_TYPE"])) {
             $arUserType = CIBlockProperty::GetUserType($arFields["USER_TYPE"]);
             if (array_key_exists("ConvertToDB", $arUserType)) {
                 $arValue = array("VALUE" => $arFields["DEFAULT_VALUE"]);
//.........这里部分代码省略.........
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:iblockproperty.php

示例2: GetProperty

 public static function GetProperty($IBLOCK_ID, $ELEMENT_ID, $by = "sort", $order = "asc", $arFilter = array())
 {
     global $DB;
     if (is_array($by)) {
         if ($order != "asc") {
             $arFilter = $order;
         }
         $arOrder = $by;
     } else {
         $arOrder = false;
     }
     $IBLOCK_ID = intval($IBLOCK_ID);
     $ELEMENT_ID = intval($ELEMENT_ID);
     $VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     $strSqlSearch = "";
     foreach ($arFilter as $key => $val) {
         switch (strtoupper($key)) {
             case "ACTIVE":
                 if ($val == "Y" || $val == "N") {
                     $strSqlSearch .= "AND BP.ACTIVE='" . $val . "'\n";
                 }
                 break;
             case "SEARCHABLE":
                 if ($val == "Y" || $val == "N") {
                     $strSqlSearch .= "AND BP.SEARCHABLE='" . $val . "'\n";
                 }
                 break;
             case "NAME":
                 if (strlen($val) > 0) {
                     $strSqlSearch .= "AND " . CIBLock::_Upper("BP.NAME") . " LIKE " . CIBlock::_Upper("'" . $DB->ForSql($val) . "'") . "\n";
                 }
                 break;
             case "ID":
                 if (is_array($val)) {
                     if (!empty($val)) {
                         $strSqlSearch .= "AND BP.ID in (" . implode(", ", array_map("intval", $val)) . ")\n";
                     }
                 } elseif (strlen($val) > 0) {
                     $strSqlSearch .= "AND BP.ID=" . IntVal($val) . "\n";
                 }
                 break;
             case "PROPERTY_TYPE":
                 if (strlen($val) > 0) {
                     $strSqlSearch .= "AND BP.PROPERTY_TYPE='" . $DB->ForSql($val) . "'\n";
                 }
                 break;
             case "CODE":
                 if (strlen($val) > 0) {
                     $strSqlSearch .= "AND " . CIBLock::_Upper("BP.CODE") . " LIKE " . CIBLock::_Upper("'" . $DB->ForSql($val) . "'") . "\n";
                 }
                 break;
             case "EMPTY":
                 if (strlen($val) > 0) {
                     if ($val == "Y") {
                         $strSqlSearch .= "AND BEP.ID IS NULL\n";
                     } elseif ($VERSION != 2) {
                         $strSqlSearch .= "AND BEP.ID IS NOT NULL\n";
                     }
                 }
                 break;
         }
     }
     $arSqlOrder = array();
     if ($arOrder) {
         foreach ($arOrder as $by => $order) {
             $order = strtolower($order);
             if ($order != "desc") {
                 $order = "asc";
             }
             $by = strtolower($by);
             if ($by == "sort") {
                 $arSqlOrder["BP.SORT"] = $order;
             } elseif ($by == "id") {
                 $arSqlOrder["BP.ID"] = $order;
             } elseif ($by == "name") {
                 $arSqlOrder["BP.NAME"] = $order;
             } elseif ($by == "active") {
                 $arSqlOrder["BP.ACTIVE"] = $order;
             } elseif ($by == "value_id") {
                 $arSqlOrder["BEP.ID"] = $order;
             } elseif ($by == "enum_sort") {
                 $arSqlOrder["BEPE.SORT"] = $order;
             } else {
                 $arSqlOrder["BP.SORT"] = $order;
             }
         }
     } else {
         if ($by == "id") {
             $arSqlOrder["BP.ID"] = "asc";
         } elseif ($by == "name") {
             $arSqlOrder["BP.NAME"] = "asc";
         } elseif ($by == "active") {
             $arSqlOrder["BP.ACTIVE"] = "asc";
         } elseif ($by == "value_id") {
             $arSqlOrder["BEP.ID"] = $order;
         } elseif ($by == "enum_sort") {
             $arSqlOrder["BEPE.SORT"] = $order;
         } else {
             $arSqlOrder["BP.SORT"] = "asc";
             $by = "sort";
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockelement.php

示例3: setIBlock

	public function setIBlock($IBLOCK_ID)
	{
		$this->VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);

		$this->arProperties = array();
		$rsProperty = CIBlockProperty::GetList(array("ID" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID));
		while($arProp = $rsProperty->Fetch())
			$this->arProperties[$arProp["ID"]] = $arProp;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:9,代码来源:iblockpropresult.php

示例4: setIBlock

 function setIBlock($IBLOCK_ID, $propertyID = array())
 {
     $this->VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     if (!empty($propertyID)) {
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     $this->arProperties = array();
     if (!empty($propertyID) || empty($propertyID) && !isset(self::$propertiesCache[$IBLOCK_ID])) {
         $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS'), 'filter' => empty($propertyID) ? array('IBLOCK_ID' => $IBLOCK_ID) : array('ID' => $propertyID, 'IBLOCK_ID' => $IBLOCK_ID), 'order' => array('ID' => 'ASC')));
         while ($property = $propertyIterator->fetch()) {
             if ($property['USER_TYPE']) {
                 $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
                 if (isset($userType["ConvertFromDB"])) {
                     if (array_key_exists("DEFAULT_VALUE", $property)) {
                         $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                         $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                         $property["DEFAULT_VALUE"] = $value["VALUE"];
                     }
                 }
             }
             if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
                 $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
             }
             $this->arProperties[$property['ID']] = $property;
         }
         unset($property, $propertyIterator);
         if (empty($propertyID)) {
             self::$propertiesCache[$IBLOCK_ID] = $this->arProperties;
         }
     } else {
         $this->arProperties = self::$propertiesCache[$IBLOCK_ID];
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:33,代码来源:iblockpropresult.php

示例5: migrateCustomElementProperties

 protected function migrateCustomElementProperties($iblockId, $entityNewName)
 {
     $iblockId = (int) $iblockId;
     $VERSION = \CIBlockElement::GetIBVersion($iblockId);
     if ($VERSION == 2) {
         $strTable = "b_iblock_element_prop_m" . $iblockId;
     } else {
         $strTable = "b_iblock_element_property";
     }
     $tableNameUf = "b_utm_" . strtolower($entityNewName);
     $tableNameSingleUf = "b_uts_" . strtolower($entityNewName);
     $sqlHelper = $this->connection->getSqlHelper();
     $listElementAll = array();
     $objectQuery = $this->connection->query("\n\t\t\tSELECT obj.ID, prop.VALUE, prop.IBLOCK_PROPERTY_ID\n\t\t\tFROM b_disk_object obj\n\t\t\tINNER JOIN {$strTable} prop ON obj.WEBDAV_ELEMENT_ID = prop.IBLOCK_ELEMENT_ID\n\t\t\tWHERE obj.WEBDAV_IBLOCK_ID = {$iblockId} AND obj.TYPE = 3\n\t\t");
     while ($listObject = $objectQuery->fetch()) {
         $listElementAll[$listObject['ID']][$listObject['IBLOCK_PROPERTY_ID']]['FIELD_VALUE'][] = $listObject['VALUE'];
     }
     $listElement = array();
     foreach ($this->getIblockProperties($iblockId) as $prop) {
         $propId = $prop['ID'];
         $mappedUfType = $this->mapTypeElementPropertyToUfType($prop);
         if (!$mappedUfType) {
             $this->log(array('Unknown property of element', $prop));
             continue;
         }
         $userTypeEntity = new \CUserTypeEntity();
         $symbolicName = empty($prop['CODE']) ? $propId : strtoupper($prop['CODE']);
         $xmlId = empty($prop['CODE']) ? $propId : $prop['CODE'];
         $fieldName = substr('UF_' . $symbolicName, 0, 20);
         if ($mappedUfType == 'iblock_section' || $mappedUfType == 'iblock_element') {
             $settingsArray = array('IBLOCK_ID' => $prop['LINK_IBLOCK_ID'], 'DISPLAY' => 'LIST');
         } else {
             $settingsArray = array();
         }
         $id = $userTypeEntity->add(array('ENTITY_ID' => $entityNewName, 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $mappedUfType, 'XML_ID' => 'PROPERTY_' . $xmlId, 'MULTIPLE' => $prop['MULTIPLE'], 'MANDATORY' => $prop['IS_REQUIRED'], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => null, 'EDIT_IN_LIST' => null, 'IS_SEARCHABLE' => $prop['SEARCHABLE'], 'SETTINGS' => $settingsArray, 'EDIT_FORM_LABEL' => array('en' => $prop['NAME'], 'ru' => $prop['NAME'], 'de' => $prop['NAME'])));
         if ($id) {
             if ($mappedUfType == 'enumeration') {
                 $i = 0;
                 $enumValues = array();
                 $queryEnum = \CIBlockPropertyEnum::getlist(array("SORT" => "ASC", "VALUE" => "ASC"), array('PROPERTY_ID' => $propId));
                 while ($queryEnum && ($rowEnum = $queryEnum->fetch())) {
                     $enumValues['n' . $i] = array('SORT' => $rowEnum['SORT'], 'VALUE' => $rowEnum['VALUE'], 'XML_ID' => $rowEnum['XML_ID'], 'DEF' => $rowEnum['DEF']);
                     $i++;
                 }
                 $userTypeEnum = new \CUserFieldEnum();
                 $userTypeEnum->setEnumValues($id, $enumValues);
             }
             foreach ($listElementAll as $newId => $propArray) {
                 if (array_key_exists($propId, $propArray)) {
                     $listElement[$newId][$propId]['FIELD_VALUE'] = $listElementAll[$newId][$propId]['FIELD_VALUE'];
                     $listElement[$newId][$propId]['FIELD_NAME'] = $fieldName;
                     if ($prop['MULTIPLE'] == 'Y') {
                         $listElement[$newId][$propId]['FIELD_ID'] = $id;
                         $listElement[$newId][$propId]['PROPERTY_TYPE'] = $mappedUfType;
                     }
                 }
             }
         }
     }
     if (!empty($listElement)) {
         foreach ($listElement as $newId => $propArray) {
             $fieldArray = array();
             $valueArray = array();
             foreach ($propArray as $prop) {
                 $fieldArray[] = $prop['FIELD_NAME'];
                 if (count($prop['FIELD_VALUE']) > 1) {
                     $valueArray[] = "'" . $sqlHelper->forSql(serialize($prop['FIELD_VALUE'])) . "'";
                     foreach ($prop['FIELD_VALUE'] as $utmValue) {
                         if ($prop['PROPERTY_TYPE'] == 'integer') {
                             $utmValue = (int) $utmValue;
                             $this->connection->queryExecute("\n\t\t\t\t\t\t\t\t\tINSERT INTO {$tableNameUf} (VALUE_ID, FIELD_ID, VALUE_INT)\n\t\t\t\t\t\t\t\t\tVALUES ({$newId}, {$prop['FIELD_ID']}, {$utmValue})\n\t\t\t\t\t\t\t\t");
                         } else {
                             $utmValueStr = "'" . $sqlHelper->forSql($utmValue) . "'";
                             $this->connection->queryExecute("\n\t\t\t\t\t\t\t\t\tINSERT INTO {$tableNameUf} (VALUE_ID, FIELD_ID, VALUE)\n\t\t\t\t\t\t\t\t\tVALUES ({$newId}, {$prop['FIELD_ID']}, {$utmValueStr})\n\t\t\t\t\t\t\t\t");
                         }
                     }
                 } else {
                     $valueArray[] = "'" . $sqlHelper->forSql($prop['FIELD_VALUE'][0]) . "'";
                 }
             }
             if (!empty($fieldArray)) {
                 if ($this->isMysql) {
                     $sql = "\n\t\t\t\t\t\t\tINSERT IGNORE INTO {$tableNameSingleUf} (VALUE_ID, " . implode(', ', $fieldArray) . ")\n\t\t\t\t\t\t\tVALUES ({$newId}, " . implode(', ', $valueArray) . ")\n\t\t\t\t\t\t";
                 } elseif ($this->isOracle) {
                     $sql = "\n\t\t\t\t\t\t\tINSERT INTO {$tableNameSingleUf} (VALUE_ID, " . implode(', ', $fieldArray) . ")\n\t\t\t\t\t\t\tSELECT {$newId}, " . implode(', ', $valueArray) . " FROM dual\n\t\t\t\t\t\t\tWHERE NOT EXISTS(SELECT 'x' FROM {$tableNameSingleUf} WHERE VALUE_ID = {$newId})\n\t\t\t\t\t\t";
                 } elseif ($this->isMssql) {
                     $sql = "\n\t\t\t\t\t\t\tINSERT INTO {$tableNameSingleUf} (VALUE_ID, " . implode(', ', $fieldArray) . ")\n\t\t\t\t\t\t\tSELECT * FROM (SELECT {$newId}, " . implode(', ', $valueArray) . ") AS tmp\n\t\t\t\t\t\t\tWHERE NOT EXISTS(SELECT 'x' FROM {$tableNameSingleUf} WHERE VALUE_ID = {$newId})\n\t\t\t\t\t\t";
                 }
                 $this->connection->queryExecute($sql);
             }
         }
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:93,代码来源:smart_migration_webdav.php


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