public function fetchSitemapUrls()
 {
     $this->addUrl('news/index/index');
     foreach ($this->newsRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
     }
 }
Пример #2
0
 /**
  * @param int $categoryId
  * @param array $settings
  * @return array
  */
 private function fetchNews($categoryId, array $settings)
 {
     if (!empty($categoryId)) {
         $news = $this->newsRepository->getAllByCategoryId((int) $categoryId, $this->date->getCurrentDateTime(), $settings['sidebar']);
     } else {
         $news = $this->newsRepository->getAll($this->date->getCurrentDateTime(), $settings['sidebar']);
     }
     return $news;
 }
 /**
  * @return array
  */
 public function fetchFeedItems()
 {
     $items = [];
     $results = $this->newsRepository->getAll($this->date->getCurrentDateTime(), 10);
     $cResults = count($results);
     for ($i = 0; $i < $cResults; ++$i) {
         $items[] = ['title' => $results[$i]['title'], 'date' => $this->date->timestamp($results[$i]['start']), 'description' => $this->formatter->shortenEntry($results[$i]['text'], 300, 0), 'link' => $this->router->route('news/index/details/id_' . $results[$i]['id'], true)];
     }
     return $items;
 }
Пример #4
0
 /**
  * @param int $categoryId
  *
  * @return array
  */
 public function execute($categoryId = 0)
 {
     $settings = $this->config->getSettings(News\Installer\Schema::MODULE_NAME);
     if (!empty($categoryId)) {
         $news = $this->newsRepository->getLatestByCategoryId((int) $categoryId, $this->date->getCurrentDateTime());
     } else {
         $news = $this->newsRepository->getLatest($this->date->getCurrentDateTime());
     }
     return ['sidebar_news_latest' => $news, 'dateformat' => $settings['dateformat']];
 }
Пример #5
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->newsRepository->resultExists($id, $this->date->getCurrentDateTime()) == 1) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $news = $this->newsCache->getCache($id);
         $this->breadcrumb->append($this->translator->t('news', 'news'), 'news');
         if ($this->newsSettings['category_in_breadcrumb'] == 1) {
             $this->breadcrumb->append($news['category_title'], 'news/index/index/cat_' . $news['category_id']);
         }
         $this->breadcrumb->append($news['title']);
         $news['text'] = $this->view->fetchStringAsTemplate($news['text']);
         $news['target'] = $news['target'] == 2 ? ' target="_blank"' : '';
         return ['news' => $news, 'dateformat' => $this->newsSettings['dateformat'], 'comments_allowed' => $this->commentsActive === true && $news['comments'] == 1];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Пример #6
0
 /**
  * @param int $categoryId
  * @param string $time
  *
  * @return array
  */
 private function fetchNews($categoryId, $time)
 {
     if (!empty($categoryId)) {
         $news = $this->newsRepository->getAllByCategoryId($categoryId, $time, $this->pagination->getResultsStartOffset(), $this->resultsPerPage->getResultsPerPage(News\Installer\Schema::MODULE_NAME));
     } else {
         $news = $this->newsRepository->getAll($time, $this->pagination->getResultsStartOffset(), $this->resultsPerPage->getResultsPerPage(News\Installer\Schema::MODULE_NAME));
     }
     return $news;
 }
Пример #7
0
 /**
  * Erstellt den Cache einer News anhand der angegebenen ID
  *
  * @param integer $newsId
  *
  * @return boolean
  */
 public function saveCache($newsId)
 {
     return $this->cache->save(self::CACHE_ID . $newsId, $this->newsRepository->getOneById($newsId));
 }