/** * @return \MetaModels\IItems */ public function fetchMetaModelsItems() { $filter = $this->metaModel->getEmptyFilter(); if ($this->filter) { $this->filter->addRules($filter, array()); } $sortBy = ''; if ($this->sortBy) { $attribute = $this->metaModel->getAttributeById($this->sortBy); if ($attribute) { $sortBy = $attribute->getColName(); } } // TODO: Should we limit the attributes? What about translated ones? Con: Conditions need access to other attributes return $this->metaModel->findByFilter($filter, $sortBy, 0, 0, $this->sortDirection); }
/** * Prepare the rendering. * * @return ItemList */ public function prepare() { if ($this->objItems) { return $this; } // Create an empty filter object if not done before. if (!$this->objFilter) { $this->objFilter = $this->objMetaModel->getEmptyFilter(); } if ($this->objFilterSettings) { $this->objFilterSettings->addRules($this->objFilter, $this->arrParam); } $this->modifyFilter(); $intTotal = $this->objMetaModel->getCount($this->objFilter); $calculator = $this->paginationLimitCalculator; $calculator->setTotalAmount($intTotal); $curPage = (int) \Input::get('page'); if ($curPage > 1) { $calculator->setCurrentPage($curPage); } $this->objTemplate->total = $intTotal; $this->objItems = $this->objMetaModel->findByFilter($this->objFilter, $this->strSortBy, $calculator->getCalculatedOffset(), $calculator->getCalculatedLimit(), $this->strSortDirection, $this->getAttributeNames()); return $this; }
/** * Get all MetaModel items. * * @param MetaModel $metaModel The MetaModel. * @param LayerModel $model The layer model. * @param Filter $filter Optional request filter. * * @return Items * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ private function getItems(MetaModel $metaModel, LayerModel $model, Filter $filter = null) { $metaModelFilter = $metaModel->getEmptyFilter(); $filterSetting = FilterSettingFactory::byId($model->metamodel_filtering); $filterSetting->addRules($metaModelFilter, array_merge(deserialize($model->metamodel_filteraprams, true), $this->getFilterParameters($filterSetting))); return $metaModel->findByFilter($metaModelFilter, $model->metamodel_sortby, 0, $model->metamodel_use_limit ? $model->metamodel_limit ?: 0 : 0, $model->metamodel_sortby_direction); }