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


PHP CIBlockPropertyEnum::getlist方法代码示例

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


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

示例1: 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


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