/** * Index action * * Displays a list of items with endless scrolling. Allows to filter by language. * * @param integer $page The current page * @param string $language Filter by language, NULL for all languages */ public function indexAction($page = 1, $language = NULL) { $offset = ($page - 1) * $this->perPage; $filter = new \Planetflow3\Domain\Dto\ItemFilter(); $filter->setLanguage($language); $filter->setDisabled(FALSE); $result = $this->itemRepository->findByFilter($filter); $count = $result->count(); $query = $result->getQuery(); $query->setLimit(10); $query->setOffset($offset); $items = $query->execute(); $this->view->assign('items', $items); $this->view->assign('language', $language); $this->view->assign('page', $page); $this->view->assign('count', $count); $this->view->assign('offset', $offset); $this->view->assign('perPage', $this->perPage); $this->view->assign('hasNext', $offset + $this->perPage <= $count); $this->view->assign('nextPage', $page + 1); $channels = $this->channelRepository->findAll(); $this->view->assign('channels', $channels); $this->view->assign('languages', array('en', 'de')); // TODO Send correct cache control including last modified }
/** * Index action * * @param \Planetflow3\Domain\Dto\ItemFilter $filter * @FLOW3\SkipCsrfProtection */ public function indexAction($filter = NULL) { if ($filter === NULL) { $filter = new \Planetflow3\Domain\Dto\ItemFilter(); } $items = $this->itemRepository->findByFilter($filter); $this->view->assign('items', $items); $this->view->assign('filter', $filter); $channels = $this->channelRepository->findAll(); $categories = $this->categoryRepository->findAll(); $this->view->assign('channels', $channels->toArray()); $this->view->assign('categories', $categories->toArray()); }
/** * Fetch new items from all channels * * This command should be run by a cronjob to do periodical * updates to the channel feeds. * * @param boolean $verbose TRUE if log messages should be shown on the console * @return void */ public function fetchCommand($verbose = FALSE) { if ($verbose) { echo 'Fetching feeds'; } $command = $this; $channels = $this->channelRepository->findAll(); foreach ($channels as $channel) { if ($verbose) { echo 'Fetching items for ' . $channel->getFeedUrl() . '...' . PHP_EOL; } $this->channelService->fetchItems($channel, function (Item $item, $message, $severity = LOG_INFO) use($channel, $command, $verbose) { if ($verbose) { echo $message . PHP_EOL; } $command->feedLogger->log($channel->getName() . ': ' . $item->getLink() . ' - ' . $message, $severity); }); if ($verbose) { echo "Done fetching items." . PHP_EOL; } } }
/** * Index action * * @FLOW3\SkipCsrfProtection */ public function indexAction() { $channels = $this->channelRepository->findAll(); $this->view->assign('channels', $channels); }