/**
  * @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);
 }
Example #2
0
 /**
  * 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;
 }