/**
  * @test
  * @dataProvider sectionIndexQueriesWithDifferentColPosDataProvider
  * @param array $configuration
  * @param string $whereClausePrefix
  */
 public function sectionIndexQueriesWithDifferentColPos($configuration, $whereClausePrefix)
 {
     $this->prepareSectionIndexTest();
     $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array()));
     $this->fixture->mconf['sectionIndex.'] = $configuration;
     $queryConfiguration = array('pidInList' => 12, 'orderBy' => 'field', 'languageField' => 'sys_language_uid', 'where' => $whereClausePrefix);
     $this->fixture->parent_cObj->expects($this->once())->method('exec_getQuery')->with('tt_content', $queryConfiguration)->will($this->returnValue(1));
     $this->fixture->_call('sectionIndex', 'field', 12);
 }
Esempio n. 2
0
 /**
  * Collects all pages for the selected categories, sorted according to configuration.
  *
  * @param string $selectedCategories Comma-separated list of system categories primary keys
  * @param array $configuration TypoScript configuration for the "special." keyword
  * @param \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject $parentObject Back-reference to the calling object
  * @return string List of selected pages
  */
 public function collectPages($selectedCategories, $configuration, $parentObject)
 {
     $selectedPages = array();
     $categoriesPerPage = array();
     // Determine the name of the relation field
     $relationField = '';
     if (isset($configuration['relation.'])) {
         $relationField = $parentObject->parent_cObj->stdWrap($configuration['relation'], $configuration['relation.']);
     } elseif (isset($configuration['relation'])) {
         $relationField = $configuration['relation'];
     }
     // Get the pages for each selected category
     $selectedCategories = GeneralUtility::intExplode(',', $selectedCategories, TRUE);
     foreach ($selectedCategories as $aCategory) {
         $collection = CategoryCollection::load($aCategory, TRUE, 'pages', $relationField);
         $categoryUid = 0;
         if ($collection instanceof AbstractRecordCollection) {
             $categoryUid = $collection->getUid();
         }
         // Loop on the results, overlay each page record found
         foreach ($collection as $pageItem) {
             $parentObject->getSysPage()->versionOL('pages', $pageItem, TRUE);
             if (is_array($pageItem)) {
                 $selectedPages[$pageItem['uid']] = $parentObject->getSysPage()->getPageOverlay($pageItem);
                 // Keep a list of the categories each page belongs to
                 if (!isset($categoriesPerPage[$pageItem['uid']])) {
                     $categoriesPerPage[$pageItem['uid']] = array();
                 }
                 $categoriesPerPage[$pageItem['uid']][] = $categoryUid;
             }
         }
     }
     // Loop on the selected pages to add the categories they belong to, as comma-separated list of category uid's)
     // (this makes them available for rendering, if needed)
     foreach ($selectedPages as $uid => $pageRecord) {
         $selectedPages[$uid]['_categories'] = implode(',', $categoriesPerPage[$uid]);
     }
     // Sort the pages according to the sorting property
     self::$sortingField = isset($configuration['sorting.']) ? $parentObject->getParentContentObject()->stdWrap($configuration['sorting'], $configuration['sorting.']) : $configuration['sorting'];
     $order = isset($configuration['order.']) ? $parentObject->getParentContentObject()->stdWrap($configuration['order'], $configuration['order.']) : $configuration['order'];
     $selectedPages = $this->sortPages($selectedPages, $order);
     return $selectedPages;
 }
 /**
  * @test
  * @dataProvider ifsubHasToCheckExcludeUidListDataProvider
  * @param array $menuItems
  * @param string $excludeUidList
  * @param bool $expectedResult
  */
 public function ifsubHasToCheckExcludeUidList($menuItems, $excludeUidList, $expectedResult)
 {
     $menu = array();
     foreach ($menuItems as $page) {
         $menu[] = array('uid' => $page);
     }
     $this->prepareSectionIndexTest();
     $this->subject->parent_cObj = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array());
     $this->subject->sys_page->expects($this->once())->method('getMenu')->will($this->returnValue($menu));
     $this->subject->menuArr = array(0 => array('uid' => 1));
     $this->subject->conf['excludeUidList'] = $excludeUidList;
     $this->assertEquals($expectedResult, $this->subject->isItemState('IFSUB', 0));
 }