Example #1
0
    }
    // albums return
    if (isset($_GET['artist'])) {
        // get artist by title
        $artist = $iaArtist->getArtistByTitle($_GET['artist']);
        // get artist albums
        $out['data'] = $iaAlbum->getAlbumsByArtist($artist['id']);
        $iaView->assign($out);
    }
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    iaCore::fields();
    $iaUtil = $iaCore->factory('util');
    $errorFields = array();
    $id = isset($iaCore->requestPath[0]) ? (int) $iaCore->requestPath[0] : false;
    $lyric = $id ? $iaDb->row('*, \'lyrics\' as `item`', "`id`={$id}", 0, 1, iaLyric::getTable()) : array();
    if (!empty($id) && empty($lyric)) {
        iaView::errorPage(iaView::ERROR_NOT_FOUND);
    } elseif (!empty($id) && $_SESSION['user']['id'] != $lyric['member_id']) {
        iaView::errorPage(iaView::ERROR_FORBIDDEN);
    }
    if (!empty($lyric)) {
        // get lyric artist
        $lartist = $iaArtist->getArtist($lyric['id_artist']);
        $lyric['artist'] = $lartist['title'];
        // get lyric album
        $lalbum = $iaAlbum->getAlbum($lyric['id_album']);
        $lyric['album'] = $lalbum['title'];
        // get artist albums
        $albums = $iaAlbum->getAlbumsByArtist($lartist['id']);
        $iaView->assign('albums', $albums);
 $iaItem = $iaCore->factory('item');
 // init main item classes
 $iaLyric = $iaCore->factoryPackage('lyric', 'lyrics');
 $iaArtist = $iaCore->factoryPackage('artist', 'lyrics');
 $iaAlbum = $iaCore->factoryPackage('album', 'lyrics');
 $defaultLimit = $iaCore->get('lyrics_per_block', 5);
 // generate sql query to fetch listings
 $sql = "SELECT t1.`id`, t1.`id_artist`, t1.`title`, t1.`title_alias`, t1.`date_added`, ";
 $sql .= "t1.`views_num`, t1.`artist_alias`, t1.`album_alias`, t2.`title` `artist_title`";
 $sql .= "FROM `" . iaLyric::getTable(true) . "` t1 ";
 $sql .= "LEFT JOIN `" . iaArtist::getTable(true) . "` AS t2 ";
 $sql .= "ON t1.`id_artist` = t2.`id` ";
 $sql .= "WHERE t1.`status`='active' ";
 // random lyrics
 if ($iaView->blockExists('random_lyrics')) {
     $max = (int) $iaDb->one('MAX(`id`) as `max`', null, iaLyric::getTable());
     $sql2 = $iaCore->iaDb->orderByRand($max, 't1.`id`') . " ORDER BY RAND() LIMIT 0, " . $defaultLimit;
     if ($data = $iaDb->getAll($sql . $sql2)) {
         $iaView->assign('random_lyrics', $data);
     }
 }
 // latest lyrics
 if ($iaView->blockExists('latest_lyrics')) {
     $sql2 = "ORDER BY t1.`date_added` DESC LIMIT 0, " . $defaultLimit;
     $iaView->assign('latest_lyrics', $iaDb->getAll($sql . $sql2));
 }
 // popular lyrics
 if ($iaView->blockExists('popular_lyrics')) {
     $sql2 = "ORDER BY t1.`views_num` DESC LIMIT 0, " . $defaultLimit;
     $iaView->assign('popular_lyrics', $iaDb->getAll($sql . $sql2));
 }