public function tagAction($tagName, $page = 1)
{
$page = $this->filter->sanitize($page, 'int');
if ($page < 1) {
$page = 1;
}
$tagItem = Tags::findFirst(array('name = ?0', 'bind' => array($tagName)));
if ($tagItem == false) {
return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
}
$key = 'tag' . $tagItem->id . 'p' . $page;
$exists = $this->view->getCache()->exists($key);
if (!$exists) {
//Top albums
$phql = 'SELECT
al.id,
al.name,
ar.uri,
ar.id as artist_id,
ar.name as artist,
ap.url
FROM AlbumOrama\\Models\\Albums al
JOIN AlbumOrama\\Models\\Artists ar
JOIN AlbumOrama\\Models\\AlbumsTags at
JOIN AlbumOrama\\Models\\AlbumsPhotos ap
WHERE
ap.type = "large" AND
at.tags_id = ' . $tagItem->id . '
ORDER BY al.playcount DESC
LIMIT 30
OFFSET ' . ($page - 1) * 30;
$albums = $this->modelsManager->executeQuery($phql);
$this->view->setVar('tagItem', $tagItem);
$this->view->setVar('albums', $albums);
$this->view->setVar('page', $page);
$this->view->setVar('prev', $page == 1 ? 0 : $page - 1);
$this->view->setVar('next', count($albums) == 30 ? $page + 1 : 0);
}
$this->view->cache(array("key" => $key));
}