/**
  * @param MetaModelsFilterCollection $filter
  * @return array
  */
 private function createFilterParams(MetaModelsFilterCollection $filter)
 {
     $names = $filter->getParameterFilterNames();
     $values = array();
     foreach (array_keys($names) as $name) {
         $varValue = \Input::get($name);
         if (is_string($varValue)) {
             $values[$name] = $varValue;
         }
     }
     return $values;
 }
 /**
  * @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);
 }
Exemplo n.º 3
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;
 }
 /**
  * Retrieve all filter parameters from the input class for the specified filter setting.
  *
  * @param ICollection $filterSettings The filter settings.
  *
  * @return string[]
  */
 protected function getFilterParameters(ICollection $filterSettings)
 {
     $params = array();
     foreach (array_keys($filterSettings->getParameterFilterNames()) as $strName) {
         $varValue = \Input::getInstance()->get($strName);
         if (is_string($varValue)) {
             $params[$strName] = $varValue;
         }
     }
     return $params;
 }