get( 'n_songs', 5 ); $criteria = $params->get( 'criteria' ); $songs = $params->get( 'songs' ); $where_clause = array(); switch($criteria){ case 'featured': $where_clause[] = ' s.id IN ('.$songs.') ' ; $order = ' ' ; break; case 'random': $order = ' ORDER BY RAND() ' ; break; case 'latest': $order = ' ORDER BY s.added DESC ' ; break; } if($params->get( 'artist_id' )) $where_clause[] = " s.artist_id = " . $params->get( 'artist_id' ) . " " ; if ($params->get( 'genre_id' )) { $genre_id = $params->get( 'genre_id' ); $model->getDescendantsId($genre_id); $descendants = $model->descendantsId; $descendants[] = $genre_id ; $genre_clause = ' ( s.genre_id = ' . implode(' OR s.genre_id = ',$descendants) . ' ) '; $where_clause[] = $genre_clause; } $where_clause = (count($where_clause) ? ' WHERE '.implode(' AND ', $where_clause) : ''); $query = ' SELECT s.*,al.name AS album_name, al.image, ar.artist_name FROM #__muscol_songs as s '. ' LEFT JOIN #__muscol_albums as al ON al.id = s.album_id '. ' LEFT JOIN #__muscol_artists as ar ON ar.id = s.artist_id '. $where_clause . $order. ' LIMIT '. $limit; $_db->setQuery( $query ); $recent_songs = $_db->loadObjectList(); $recent_songs = MusColHelper::prepareSongsData($recent_songs); return $recent_songs; } static function getModel() { if (!class_exists( 'ArtistsModelSearch' )) { // Build the path to the model based upon a supplied base path $path = JPATH_SITE.DS.'components'.DS.'com_muscol'.DS.'models'.DS.'search.php'; $false = false; // If the model file exists include it and try to instantiate the object if (file_exists( $path )) { require_once( $path ); if (!class_exists( 'ArtistsModelSearch' )) { JError::raiseWarning( 0, 'Model class ArtistsModelSearch not found in file.' ); return $false; } } else { JError::raiseWarning( 0, 'Model ArtistsModelSearch not supported. File not found.' ); return $false; } } $model = new ArtistsModelSearch(); return $model; } }