コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
ファイル: ItemList.php プロジェクト: zonky2/core
 /**
  * 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;
 }
コード例 #3
0
ファイル: SearchablePages.php プロジェクト: Haus-E/mm-core
 /**
  * Get the list of jumpTos based on the items.
  *
  * @param array                                  $availableLanguages List of languages to be used.
  *
  * @param IMetaModel                             $metaModels         The MetaModels to be used.
  *
  * @param IFilter                                $filter             The filter to be used.
  *
  * @param \MetaModels\Render\Setting\ICollection $view               The view to be used.
  *
  * @param string|null                            $rootPage           The root page id or null if there is no root
  *                                                                   page.
  *
  * @return array A list of urls for the jumpTos
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function getJumpTosFor($availableLanguages, $metaModels, $filter, $view, $rootPage = null)
 {
     $entries = array();
     foreach ($availableLanguages as $language) {
         // Set the language.
         $GLOBALS['TL_LANGUAGE'] = $language;
         // Get the object.
         $items = $metaModels->findByFilter($filter);
         /** @var Item $item */
         foreach ($items as $item) {
             $jumpTo = $item->buildJumpToLink($view);
             $event = new GetPageDetailsEvent($jumpTo['page']);
             $this->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event);
             $pageDetails = $event->getPageDetails();
             // If there is a root page check the context.
             if ($rootPage !== null && $pageDetails['rootId'] != $rootPage) {
                 continue;
             }
             // Build the url.
             $url = $this->getBaseUrl($pageDetails, $jumpTo['url']);
             $entries[] = $url->getUrl();
         }
     }
     return $entries;
 }
コード例 #4
0
 /**
  * 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);
 }