get('working_mode')){ case "featured": $random_ids = $params->get('album_ids') ; $where_clause[] = " al.id IN (".$random_ids.") " ; $order_by = ' ORDER BY FIELD(al.id, '.$random_ids.') ' ; break; case "added": $order_by = ' ORDER BY al.added DESC ' ; break; case "topadmin": $order_by = ' ORDER BY points_to_display DESC ' ; break; case "topusers": $order_by = ' ORDER BY points_to_display DESC, quants DESC ' ; $where_clause[] = ' (ra.type = "album" OR ra.type = "") '; break; case "random": default: $order_by = ' ORDER BY RAND() ' ; break; } if($params->get( 'n_albums' )) $limit = $params->get( 'n_albums' ); else $limit = 5; $artist_id = $params->get( 'artist_id' ) ; if($artist_id){ if($artist_id == "CURRENT"){ $option = JRequest::getVar('option'); $view = JRequest::getVar('view'); $id = JRequest::getInt('id'); $artist_id = 0 ; if($option == "com_muscol"){ switch($view) { case "artist": case "songs": $artist_id = $id ; break; case "album": $query = " SELECT artist_id FROM #__muscol_albums WHERE id = ". $id ; $_db->setQuery($query) ; $artist_id = $_db->loadResult() ; $where_clause[] = " al.id != " . $id ; break; case "song": $query = " SELECT artist_id FROM #__muscol_songs WHERE id = ". $id ; $_db->setQuery($query) ; $artist_id = $_db->loadResult() ; break; } } if($artist_id) $where_clause[] = " al.artist_id = " . $artist_id . " " ; } else $where_clause[] = " al.artist_id = " . $artist_id . " " ; } if ($params->get( 'genre_id' )) { $genre_id = $params->get( 'genre_id' ); $model_search->getDescendantsId($genre_id); $descendants = $model_search->descendantsId; $descendants[] = $genre_id ; $genre_clause = ' ( al.genre_id = ' . implode(' OR al.genre_id = ',$descendants) . ' ) '; $where_clause[] = $genre_clause; } $format_id = $params->get( 'format_id' ); if($format_id) $where_clause[] = '(al.format_id = '.$format_id.' OR f.display_group = '.$format_id.')' ; $where_clause = (count($where_clause) ? ' WHERE '.implode(' AND ', $where_clause) : ''); $query = ' SELECT al.*,al.points as points_to_display, ar.artist_name, f.format_name '. ' FROM #__muscol_albums as al '. ' LEFT JOIN #__muscol_format as f ON f.id = al.format_id '. ' LEFT JOIN #__muscol_artists as ar ON ar.id = al.artist_id '. $where_clause . $order_by . ' LIMIT '. $limit; if( $params->get('working_mode') == "topusers"){ $query = ' SELECT al.*, ar.artist_name, AVG(ra.points) as points_to_display, count(al.id) as quants FROM #__muscol_albums as al '. ' LEFT JOIN #__muscol_format as f ON f.id = al.format_id '. ' LEFT JOIN #__muscol_artists as ar ON ar.id = al.artist_id '. ' LEFT JOIN #__muscol_ratings as ra ON ra.album_id = al.id '. $where_clause . ' GROUP BY al.id ' . $order_by . ' LIMIT '. $limit; } $_db->setQuery( $query ); $albums = $_db->loadObjectList(); $albums = MusColHelper::prepareAlbumsData($albums); return $albums; } static function getModel() { if (!class_exists( 'ArtistsModelAlbum' )) { // Build the path to the model based upon a supplied base path $path = JPATH_SITE.DS.'components'.DS.'com_muscol'.DS.'models'.DS.'album.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( 'ArtistsModelAlbum' )) { JError::raiseWarning( 0, 'Model class ArtistsModelAlbum not found in file.' ); return $false; } } else { JError::raiseWarning( 0, 'Model ArtistsModelAlbum not supported. File not found.' ); return $false; } } $model = new ArtistsModelAlbum(); return $model; } static function getModelSearch() { 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; } }