*/ class syntax_plugin_newsfeed_carousel extends AbstractStream { public function connectTo($mode): void { $this->Lexer->addSpecialPattern('{{news-carousel>.+?}}', $mode, 'plugin_newsfeed_carousel'); } public function handle($match, $state, $pos, Doku_Handler $handler): array { preg_match_all('/([a-z]+)="([^".]*)"/', substr($match, 16, -2), $matches); $parameters = []; foreach ($matches[1] as $index => $match) { $parameters[$match] = $matches[2][$index]; } return [$state, [$parameters]]; } public function render($format, Doku_Renderer $renderer, $data): bool { if ($format !== 'xhtml') { return true; } [$state, $match] = $data; switch ($state) { case DOKU_LEXER_SPECIAL: [$param] = $match; $renderer->nocache(); $stream = $this->helper->serviceStream->findByName($param['stream']); $allNews = $stream->getNews(); if (count($allNews)) { $this->renderCarousel($renderer, $allNews, $param); } } return true; } private function renderCarousel(Doku_Renderer $renderer, array $news, array $params): void { $id = uniqid(); $indicators = []; $items = []; $noFeeds = 5; for ($i = 0; $i < $noFeeds; $i++) { if (!isset($news[$i])) { break; }; /** * @var $feed ModelNews; */ $feed = $news[$i]; $indicators[] = '
'; $items[] = $this->getCarouselItem($feed, !$i); } $renderer->doc .= ' '; } private function renderCarouselIndicators(Doku_Renderer $renderer, array $indicators): void { $renderer->doc .= '' . $feed->renderText() . '
'; } private function getHeadline(ModelNews $feed): string { return '