Ejemplo n.º 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);
 }