示例#1
0
 private static function compileTemplate($template, $sectionId, $propertyValues)
 {
     $section = SectionTable::getList(['filter' => ['ID' => $sectionId]])->fetch();
     $search = ['#SECTION_NAME#'];
     $replace = [strtolower($section['NAME'])];
     $obPropertiesValues = PropertyEnumerationTable::getList(['order' => ['SEOFILTER_PROPERTY_TABLE.SORT' => 'ASC'], 'select' => ['ID', 'VALUE', 'VALUE_ALT' => 'VALUE_ALT_TABLE.VALUE'], 'filter' => ['ID' => array_values($propertyValues)], 'runtime' => [new \Bitrix\Main\Entity\ReferenceField('VALUE_ALT_TABLE', '\\Xpage\\Seofilter\\PropertyValueAlt', ['this.ID' => 'ref.ENUM_ID']), new \Bitrix\Main\Entity\ReferenceField('SEOFILTER_PROPERTY_TABLE', '\\Xpage\\Seofilter\\Property', ['this.PROPERTY_ID' => 'ref.PROPERTY_ID'])]]);
     $arPropertyValues = [];
     while ($arPropertyValue = $obPropertiesValues->fetch()) {
         $arPropertyValue['VALUE'] = $arPropertyValue['VALUE_ALT'] ?: strtolower($arPropertyValue['VALUE']);
         $arPropertyValues[] = $arPropertyValue;
     }
     $strPropertyValues = implode(" ", \Xpage\Helper::array_pluck($arPropertyValues, 'VALUE'));
     $search[] = "#PROPERTY_VALUES#";
     $replace[] = $strPropertyValues;
     $compiledTemplate = preg_replace('/#.+#/', '', str_replace($search, $replace, $template));
     return \Xpage\Helper::ucfirst($compiledTemplate);
 }
示例#2
0
 protected function isOrderRight($order)
 {
     $rightOrder = \Xpage\Helper::array_pluck($this->properties, 'PROPERTY_ID');
     $lastKey = 0;
     foreach ($order as $id => $prop) {
         $key = array_search($prop, $rightOrder);
         if ($key === false || $key < $lastKey) {
             return false;
         }
         $lastKey = $key;
     }
     return true;
 }