public function chartsAction()
{
$key = 'charts';
$exists = $this->view->getCache()->exists($key);
if (!$exists) {
$tagGenres = array('pop', 'rock', 'rap', 'rnb', 'electronic', 'alternative', 'folk', 'country', 'hip-hop', 'dance', 'chillout', 'trip-hop', 'metal', 'ambient', 'soul', 'jazz', 'latin', 'punk');
$charts = array();
foreach ($tagGenres as $genre) {
$tag = Tags::findFirst(array('name = ?0', 'bind' => array($genre)));
if ($tag == false) {
continue;
}
//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 = "small" AND
at.tags_id = ' . $tag->id . '
ORDER BY al.playcount DESC
LIMIT 10';
$charts[$tag->name] = $this->modelsManager->executeQuery($phql);
}
$this->view->setVar('charts', $charts);
}
$this->view->cache(array("key" => $key));
}