コード例 #1
0
ファイル: indexer.php プロジェクト: DarneoStudio/bitrix
 /**
  * Returns all relevant information for the element in section context.
  *
  * @param Element $element Loaded from the database element information.
  *
  * @return array
  */
 protected function getSectionIndexEntries(Element $element)
 {
     $result = array(1 => array(array("VALUE" => 0, "VALUE_NUM" => 0.0)));
     foreach ($this->getFilterProperty(Storage::DICTIONARY) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $value = intval($value);
             $result[$facetId][$value] = array("VALUE" => $value, "VALUE_NUM" => 0.0);
         }
     }
     foreach ($this->getFilterProperty(Storage::STRING) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $valueId = $this->dictionary->getStringId($value);
             $result[$facetId][$valueId] = array("VALUE" => $valueId, "VALUE_NUM" => 0.0);
         }
     }
     foreach ($this->getFilterProperty(Storage::NUMERIC) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $value = doubleval($value);
             $result[$facetId][md5($value)] = array("VALUE" => 0, "VALUE_NUM" => $value);
         }
     }
     foreach ($this->getFilterProperty(Storage::DATETIME) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             //Save date only based on server time.
             $timestamp = MakeTimeStamp($value, "YYYY-MM-DD HH:MI:SS");
             $value = date('Y-m-d', $timestamp);
             $timestamp = MakeTimeStamp($value, "YYYY-MM-DD");
             $valueId = $this->dictionary->getStringId($value);
             $result[$facetId][$valueId] = array("VALUE" => $valueId, "VALUE_NUM" => $timestamp);
         }
     }
     foreach ($this->getFilterPrices() as $priceId) {
         $facetId = $this->storage->priceIdToFacetId($priceId);
         $result[$facetId] = array();
         $elementPrices = $element->getPriceValues($priceId);
         if ($elementPrices) {
             foreach ($elementPrices as $currency => $priceValues) {
                 $currencyId = $this->dictionary->getStringId($currency);
                 foreach ($priceValues as $price) {
                     $result[$facetId][$currencyId . ":" . $price] = array("VALUE" => $currencyId, "VALUE_NUM" => $price);
                 }
             }
         }
     }
     return array_filter($result, "count");
 }
コード例 #2
0
 /**
  * Returns all relevant information for the element in section context.
  *
  * @param Element $element Loaded from the database element information.
  * @param integer $sectionId Section identifier.
  *
  * @return array
  */
 protected function getSectionIndexEntries(Element $element, $sectionId)
 {
     $result = array(1 => array(array("VALUE" => 0, "VALUE_NUM" => 0.0)));
     foreach ($this->getFilterProperty(Storage::DICTIONARY) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $value = intval($value);
             $result[$facetId][$value] = array("VALUE" => $value, "VALUE_NUM" => 0.0);
         }
     }
     foreach ($this->getFilterProperty(Storage::STRING) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $valueId = $this->dictionary->getStringId($value);
             $result[$facetId][$valueId] = array("VALUE" => $valueId, "VALUE_NUM" => 0.0);
         }
     }
     foreach ($this->getFilterProperty(Storage::NUMERIC) as $propertyId) {
         $facetId = $this->storage->propertyIdToFacetId($propertyId);
         $result[$facetId] = array();
         $propertyValues = $element->getPropertyValues($propertyId);
         foreach ($propertyValues as $value) {
             $value = doubleval($value);
             $result[$facetId][md5($value)] = array("VALUE" => 0, "VALUE_NUM" => $value);
         }
     }
     foreach ($this->getFilterPrices($sectionId) as $priceId) {
         $facetId = $this->storage->priceIdToFacetId($priceId);
         $result[$facetId] = array();
         $elementPrices = $element->getPriceValues($priceId);
         if ($elementPrices) {
             foreach ($elementPrices as $currency => $priceValues) {
                 $currencyId = $this->dictionary->getStringId($currency);
                 foreach ($priceValues as $price) {
                     $result[$facetId][$currencyId . ":" . $price] = array("VALUE" => $currencyId, "VALUE_NUM" => $price);
                 }
             }
         }
     }
     return array_filter($result, "count");
 }