示例#1
0
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $iblockId = (int) $parameters->get('ID');
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockData = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('ID' => $iblockId))->setOrder(array())->exec()->fetch();
     if (empty($iblockData)) {
         throw new BuilderException(sprintf('Not found iblock with id = %d', $iblockId));
     }
     // Get settings iblock
     $iblockDataFields = \CIBlock::GetArrayByID($iblockData['ID']);
     $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
     $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec();
     $propertyList = array();
     while ($property = $propertyResult->fetch()) {
         if (!empty($property['USER_TYPE_SETTINGS'])) {
             $property['USER_TYPE_SETTINGS'] = ($unserialize = @unserialize($property['USER_TYPE_SETTINGS'])) === false ? $property['USER_TYPE_SETTINGS'] : $unserialize;
         }
         $propertyList[$property['CODE']] = $property;
     }
     $this->iblockProperty = $propertyList;
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     $sectionValueList = array();
     if (in_array($iblockData['ID'], $this->getListByType('G'))) {
         foreach ($this->iblockProperty as $field) {
             if ($field['PROPERTY_TYPE'] == 'G' && $field['LINK_IBLOCK_ID'] == $iblockData['ID']) {
                 $sectionValueList = isset($field['VALUE_LIST']) ? $field['VALUE_LIST'] : array();
                 break;
             }
         }
     } else {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionValueList = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec()->fetchAll();
     }
     $upperLevel[] = array('ID' => 0, 'NAME' => GetMessage('IBLOCK_UPPER_LEVEL'));
     $sectionValueList = $upperLevel + $sectionValueList;
     return array('DATA' => $iblockData, 'DEFAULT_FIELDS' => $this->getDefaultFields($iblockDataFields, $sectionValueList), 'FIELDS' => $this->iblockProperty);
 }
 /**
  * Parses the filter, we describe the properties of the
  * filter type and description price
  *
  * @return $this
  */
 public function parse()
 {
     if (sizeof($this->filterList) <= 0) {
         return array();
     }
     $property = $price = array();
     foreach ($this->filterList as $key => $items) {
         foreach ($items as $filterQuery => $filterValue) {
             if (preg_match($this->pattern['property'], $filterQuery, $match)) {
                 $property[] = $match[2];
             } elseif (preg_match($this->pattern['price'], $filterQuery, $match)) {
                 $price[] = $match[2];
             }
             if (is_array($match)) {
                 unset($this->filterList[$key][$filterQuery]);
                 $this->filterList[$key][$match[1]] = $filterValue;
             }
         }
     }
     if (sizeof($property)) {
         $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
         $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $property))->exec();
         while ($property = $propertyResult->fetch()) {
             $key = sprintf('PROPERTY_%d', $property['ID']);
             $this->propertyList[$key] = $property;
         }
     }
     if (sizeof($price)) {
         $priceTypeResult = \CCatalogGroup::GetList(array('SORT' => 'ASC'), array('ID' => $price));
         while ($price = $priceTypeResult->Fetch()) {
             $key = sprintf('CATALOG_PRICE_%d', $price['ID']);
             $this->priceTypeList[$key] = $price;
         }
     }
     $this->getValueList();
     return $this;
 }
        $navyParams['PAGEN'] = (int) $navyParams['PAGEN'];
        $navyParams['SIZEN'] = (int) $navyParams['SIZEN'];
    }
}
if ($selectFields['PROPERTY_TYPE']) {
    $selectFields['USER_TYPE'] = true;
}
$selectFields = array_keys($selectFields);
$getListParams = array('select' => $selectFields, 'filter' => $arFilter, 'order' => $propertyOrder);
if ($usePageNavigation) {
    $getListParams['limit'] = $navyParams['SIZEN'];
    $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
}
$totalPages = 0;
if ($usePageNavigation) {
    $countQuery = new Main\Entity\Query(Iblock\PropertyTable::getEntity());
    $countQuery->addSelect(new Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
    $countQuery->setFilter($getListParams['filter']);
    $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
    unset($countQuery);
    $totalCount = (int) $totalCount['CNT'];
    if ($totalCount > 0) {
        $totalPages = ceil($totalCount / $navyParams['SIZEN']);
        if ($navyParams['PAGEN'] > $totalPages) {
            $navyParams['PAGEN'] = $totalPages;
        }
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
    } else {
        $navyParams['PAGEN'] = 1;
        $getListParams['limit'] = $navyParams['SIZEN'];