/** * Lists all pages with given $tag * * @param string $tag An urlencoded tag string * * @return void */ public function listAction($tag) { $tag = Tag::fromUrl($tag); $pages = $this->pageRepository->findAllByTag($tag); $this->view->assign('pages', $pages); $this->view->assign('tag', $tag); }
/** * Returns a TagCloud impl * * @return TagCloudInterface */ public function getCloud() { $pages = $this->pageRepository->findAllWithTags(); foreach ($pages as $page) { $pageTags = GeneralUtility::trimExplode(',', $page->getKeywords()); foreach ($pageTags as $pageTag) { $this->tagCloud->add(Tag::fromString($pageTag)); } } return $this->tagCloud; }
/** * Finds all pages by given Tag * * @param Tag $tag Search pages with this tag * * @return Page[] */ public function findAllByTag(Tag $tag) { $query = $this->createQuery(); $sql = "\n SELECT\n *,\n FROM_UNIXTIME(crdate) as created_at,\n FROM_UNIXTIME(lastUpdated) as last_updated_at\n FROM\n pages\n WHERE\n nav_hide = 0\n AND deleted = 0\n AND hidden = 0\n AND keywords IS NOT NULL\n AND keywords <> ''\n AND (\n keywords LIKE ?\n OR keywords LIKE ?\n OR keywords LIKE ?\n OR keywords LIKE ?\n )\n "; $query->statement($this->objectManager->get(PreparedStatement::class, $sql, 'pages'), [',%' . $tag->getValue() . '%,', '%' . $tag->getValue() . '%,', ',%' . $tag->getValue() . '%', '%' . $tag->getValue() . '%']); $rawResults = $query->execute(true); return $this->hydrate($rawResults); }