Beispiel #1
0
 /**
  * List categories
  *
  * @param array $overwriteDemand
  * @return void
  */
 public function listAction(array $overwriteDemand = NULL)
 {
     // Default value is wrong for tags
     if ($this->settings['orderBy'] === 'datetime') {
         unset($this->settings['orderBy']);
     }
     $demand = $this->createDemandObjectFromSettings($this->settings);
     if ($this->settings['disableOverrideDemand'] != 1 && $overwriteDemand !== NULL) {
         $demand = $this->overwriteDemandObject($demand, $overwriteDemand);
     }
     $assignedValues = array('tags' => $this->tagRepository->findDemanded($demand), 'overwriteDemand' => $overwriteDemand, 'demand' => $demand);
     $this->emitActionSignal('TagController', self::SIGNAL_TAG_LIST_ACTION, $assignedValues);
     $this->view->assignMultiple($assignedValues);
 }
 /**
  * Test for creating correct demand call
  *
  * @test
  * @return void
  */
 public function listActionFindsDemandedTagsByDemandFromSettings()
 {
     $demand = new Tx_MooxNews_Domain_Model_Dto_NewsDemand();
     $settings = array('list' => 'foo', 'orderBy' => 'datetime');
     $mockedSignalSlotDispatcher = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher', array('dispatch'));
     $configurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $fixture = $this->getAccessibleMock('Tx_MooxNews_Controller_TagController', array('createDemandObjectFromSettings'));
     $fixture->_set('signalSlotDispatcher', $mockedSignalSlotDispatcher);
     $fixture->injectTagRepository($this->tagRepository);
     $fixture->injectConfigurationManager($configurationManager);
     $fixture->setView($this->getMock('Tx_Fluid_View_TemplateView', array(), array(), '', FALSE));
     $fixture->_set('settings', $settings);
     $fixture->expects($this->once())->method('createDemandObjectFromSettings')->will($this->returnValue($demand));
     $this->tagRepository->expects($this->once())->method('findDemanded')->with($demand);
     $fixture->listAction();
     // datetime must be removed
     $this->assertEquals($fixture->_get('settings'), array('list' => 'foo'));
 }
Beispiel #3
0
 /**
  * Output a list view of news
  *
  * @param array $overwriteDemand
  * @return void
  */
 public function listAction(array $overwriteDemand = NULL)
 {
     // Extension manager configuration
     $configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
     $demand = $this->createDemandObjectFromSettings($this->settings);
     // get extended filter
     $extendedFilters = array();
     if (!$this->settings['hideAllFilter']) {
         $extendedFilters = $this->getExtendedFilters($demand, $overwriteDemand);
     }
     $years = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideYearFilter']) {
         $allyears = $this->newsRepository->findAllYears($demand->getStoragePage());
         $latestYear = 0;
         $newsWithoutDatetime = 0;
         foreach ($allyears as $year) {
             if ($year['year'] > 1970) {
                 $years[$year['year']] = $year['year'];
                 if ($year['year'] > $latestYear) {
                     $latestYear = $year['year'];
                 }
             } else {
                 $newsWithoutDatetime = 1;
             }
         }
         if ($newsWithoutDatetime) {
             $years['0'] = "Ohne Jahresangabe";
         }
         if (count($years) > 1 && !$overwriteDemand['year'] && $latestYear > 0) {
             //$overwriteDemand['year'] = $latestYear;
         }
     }
     if (($this->settings['disableOverrideDemand'] != 1 || $this->isAjaxRequest) && $overwriteDemand !== NULL) {
         $resetFields = array("type", "types", "categories", "target", "targets", "years", "year", "tag", "tags", "char");
         foreach ($resetFields as $resetField) {
             if (isset($overwriteDemand[$resetField]) && $overwriteDemand[$resetField] == "all") {
                 unset($overwriteDemand[$resetField]);
             }
         }
         foreach ($extendedFilters as $resetField) {
             if ($resetField['type'] == "select" && isset($overwriteDemand[$resetField['name']]) && $overwriteDemand[$resetField['name']] == "all") {
                 unset($overwriteDemand[$resetField['name']]);
             }
         }
         $demand = $this->overwriteDemandObject($demand, $overwriteDemand);
     }
     if (!$demand->getCategories() && !$overwriteDemand['categories'] && $this->settings['categories']) {
         $demand->setCategories($this->settings['categories']);
     }
     $newsRecords = $this->newsRepository->findDemanded($demand);
     $categories = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideCategoryFilter']) {
         $allcategories = $this->categoryRepository->findAllCategories();
         $selectedCategories = explode(",", $this->settings['categories']);
         foreach ($allcategories as $cat) {
             if ($this->settings['categoryConjunction'] == "") {
                 $categories[$cat->getUid()] = $cat->getTitle();
             } elseif (in_array($this->settings['categoryConjunction'], array("and", "or")) && in_array($cat->getUid(), $selectedCategories)) {
                 $categories[$cat->getUid()] = $cat->getTitle();
             } elseif (in_array($this->settings['categoryConjunction'], array("notand", "notor")) && !in_array($cat->getUid(), $selectedCategories)) {
                 $categories[$cat->getUid()] = $cat->getTitle();
             }
         }
         $idList = array();
         foreach ($allcategories as $c) {
             $idList[] = $c->getUid();
         }
     }
     $tags = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTagFilter']) {
         $alltags = $this->tagRepository->findAll(FALSE);
         foreach ($alltags as $tag) {
             $tags[$tag->getUid()] = $tag->getTitle();
         }
     }
     $targets = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTargetFilter']) {
         $alltargets = $this->targetRepository->findAll(FALSE);
         foreach ($alltargets as $target) {
             $targets[$target->getUid()] = $target->getTitle();
         }
     }
     $types = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTypeFilter']) {
         $types = $this->getTypes();
     }
     if ($this->isAjaxRequest) {
         $allDemand = $demand;
         $allDemand->setLimit(NULL);
         $allDemand->setOffset(NULL);
         $count = $this->newsRepository->findDemanded($allDemand)->count();
         $pages = ceil($count / $this->settings['list']['paginate']['itemsPerPage']);
     } else {
         $count = $newsRecords->count();
         $pages = ceil($count / $this->settings['list']['paginate']['itemsPerPage']);
     }
     $assignedValues = array('news' => $newsRecords, 'count' => $count, 'pages' => $pages, 'years' => count($years) > 1 ? $years : NULL, 'categories' => count($categories) > 1 ? $categories : NULL, 'categoriesTree' => count($idList) || $configuration->getCategoryRestriction() != "current_pid" ? $this->categoryRepository->findTree($idList) : array(), 'tags' => count($tags) > 1 ? $tags : NULL, 'targets' => count($targets) > 1 ? $targets : NULL, 'showFilter' => count($categories) > 1 || count($types) > 1 || count($targets) > 1 || count($years) > 1 ? TRUE : FALSE, 'overwriteDemand' => $overwriteDemand, 'demand' => $demand, 'types' => count($types) > 1 ? $types : NULL, 'charList' => $this->charList, 'extendedFilters' => $extendedFilters, 'extendedFields' => $this->getExtendedFields("list"));
     if ($this->isAjaxRequest) {
         $assignedValues['settings'] = $this->settings;
     }
     $this->emitActionSignal('NewsController', self::SIGNAL_NEWS_LIST_ACTION, $assignedValues);
     $this->view->assignMultiple($assignedValues);
 }