public function getSelectFilter($searchTerm) { // create initial index if (0 && !SearchableItem::getRecordCount()) { $app = ActiveRecordModel::getApplication(); $sc = new SearchableConfigurationIndexing($app->getConfig(), $app); $sc->buildIndex(null); } $c = new ARExpressionHandle($this->getWeighedSearchCondition(array('value' => 1), $searchTerm)); $app = ActiveRecordModel::getApplication(); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->mergeCondition(new OrChainCondition(array(eq(f('SearchableItem.locale'), $app->getDefaultLanguageCode()), eq(f('SearchableItem.locale'), $app->getLocaleCode()), isnull(f('SearchableItem.locale'))))); $f->setOrder(f('SearchableItem.sort'), 'DESC'); $f->setOrder($c, 'DESC'); return $f; }
private function buildList($tree = null, $id) { if ($tree === null) { $tree = $this->config->getTree(); } foreach ($tree as $sectionID => &$node) { if ($id == null || $sectionID == $id) { $sectionTitle = $this->config->getSectionTitle($sectionID); $sectionMeta = array('section_id' => $sectionID); $this->addItem($sectionMeta, $this->translationArray($sectionTitle)); foreach ($this->config->getSectionLayout($sectionID) as $layoutKey => $data) { $this->addItem(array_merge($sectionMeta, array('section_layout' => true)), $this->translationArray($layoutKey)); } foreach ($this->config->getSettingsBySection($sectionID) as $configKey => $meta) { $key = $meta['title']; // add field label. $this->addItem(array_merge($sectionMeta, $meta, array('field_label' => true)), $this->translationArray($configKey)); if (array_key_exists('type', $meta)) { if (is_array($meta['type'])) { if ($meta['extra'] == 'multi') { // multiple checkboxes, translate and add all keys with value true if (is_array($this->_values[$key])) { foreach ($this->_values[$key] as $checkboxKey => $checkboxValue) { if ($checkboxValue == true) { $this->addItem(array_merge($sectionMeta, $meta, array('checkbox_label' => true)), $this->translationArray($checkboxKey)); } } } } else { // dropdown, add only selected value (not every possible option) $this->addItem(array_merge($sectionMeta, $meta, array('field_value' => true)), $this->translationArray($this->_values[$key])); } } else { if (in_array($meta['type'], array('string', 'image', 'num', 'float', 'longtext'))) { $this->addItem(array_merge($sectionMeta, $meta, array('field_value' => true)), $this->_values[$key]); } } } } } if (array_key_exists('subs', $node)) { $node['subs'] = $this->buildList($node['subs'], $id); } // translating to all languages makes list *very* long // add by one section. if (array_key_exists($sectionID, $this->list)) { SearchableItem::bulkAddIndex($this->list[$sectionID]); unset($this->list[$sectionID]); } } return $tree; }