diff options
-rw-r--r-- | lib/artist.lib.php | 131 | ||||
-rw-r--r-- | lib/class/scrobbler.class.php | 2 | ||||
-rw-r--r-- | lib/class/vainfo.class.php | 2 | ||||
-rw-r--r-- | lib/class/view.class.php | 232 | ||||
-rw-r--r-- | lib/init.php | 1 |
5 files changed, 2 insertions, 366 deletions
diff --git a/lib/artist.lib.php b/lib/artist.lib.php deleted file mode 100644 index b3fe9ac1..00000000 --- a/lib/artist.lib.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All Rights Reserved - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License v2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - - This library handles all artist mojo - -*/ - -/*! - @function get_artists - @discussion run a search, takes string,field,type and returns an array - of results of the correct type (song, album, artist) -*/ -function get_artists($sql, $action=0) { - - $db_results = mysql_query($sql, dbh()); - - while ($r = mysql_fetch_array($db_results)) { - $artist_info = get_artist_info($r['id']); - if ($action ==='format') { $artist = format_artist($artist_info); } - else { $artist = $artist_info; } - $artists[] = $artist; - } // end while - - return $artists; - -} // get_artists - -/*! - @function format_artist - @discussion this function takes an array of artist - information and reformats the relevent values - so they can be displayed in a table for example - it changes the title into a full link. -*/ -function format_artist($artist) { - - $web_path = conf('web_path'); - $artist['name'] = "<a href=\"$web_path/artists.php?action=show&artist=" . $artist['id'] . "\">" . htmlspecialchars($artist['prefix']) . " " . htmlspecialchars($artist['name']) . "</a>"; - - return $artist; - -} // format_artist - -/*! - @function show_artists - @discussion takes a match and accounts for the possiblity of a view - then displays _many_ artists -*/ -function show_artists ($match = '') { - - $dbh = dbh(); - - $view = new View(); - $view->import_session_view(); - - // Check for the view object... - if ($_REQUEST['keep_view']) { - $view->initialize(); - } - - // If there isn't a view object we need to create a new one.. - else { - - // Pull in the min object count - $min_object_count = conf('min_object_count'); - $min_join = " LEFT JOIN song ON song.artist=artist.id"; - $min_group = "GROUP BY song.artist HAVING COUNT(song.id) > $min_object_count"; - - - if ( isset($match) && $match != '' ) { - $query = "SELECT artist.id,artist.name FROM artist $min_join" . - " WHERE artist.name LIKE '$match%' $min_group"; - } - else { - $query = "SELECT artist.id FROM `artist` $min_join $min_group"; - } - - $db_results = mysql_query($query, $dbh); - $total_items = mysql_num_rows($db_results); - if ($_REQUEST['match'] === "Show_all") { - $offset_limit = 999999; - } - else { - $offset_limit = $user->prefs['offset_limit']; - } - $view = new View($query,'artists.php','name',$total_items,$offset_limit); - - } // end if creating view object - - if (is_array($match)) { - $artists = $match; - $_SESSION['view_script'] = false; - } - $db_results = mysql_query($view->sql, $dbh); - - // Get the artist object - while ($r = mysql_fetch_assoc($db_results)) { - $artist = new Artist($r['id']); - $artist->format(); - $artists[] = $artist; - } - - if (count($artists)) { - /* Ack horrible hack :( */ - $GLOBALS['view'] = $view; - require conf('prefix') . '/templates/show_artists.inc.php'; - } - -} // show_artists - - - - -?> diff --git a/lib/class/scrobbler.class.php b/lib/class/scrobbler.class.php index 43a62016..7806085c 100644 --- a/lib/class/scrobbler.class.php +++ b/lib/class/scrobbler.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2007 Ampache.org + Copyright (c) Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php index 3b08ebfa..bc7f551d 100644 --- a/lib/class/vainfo.class.php +++ b/lib/class/vainfo.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/view.class.php b/lib/class/view.class.php deleted file mode 100644 index 41531b60..00000000 --- a/lib/class/view.class.php +++ /dev/null @@ -1,232 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All rights reserved. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License v2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/*! - @header View Object of crappyness - View object that is thrown into their session - -*/ - - -class View { - - //Basic Componets - var $base_sql; - var $offset; - var $offset_limit; - var $sort_order; //asc or desc - var $sort_type; - var $action; - var $total_items; - - //generate a new view - function View($base_sql=0,$script=0,$sort_type=0,$total_items=0,$offset_limit=0) { - global $conf; - - // If we don't have a base sql, stop here - if (!is_string($base_sql)) { - return true; - } - - //Convert all 's into "s - $base_sql = str_replace("'",'"',$base_sql); - - $this->base_sql = $base_sql; - if ($offset_limit) { $this->offset_limit = $offset_limit; } - else { $this->offset_limit = $_SESSION['offset_limit']; } - if ($this->offset_limit < '1') { $this->offset_limit = '50'; } - $this->script = $script; - $this->sort_type = $sort_type; - $this->sort_order = "ASC"; - $this->offset = 0; - $this->total_items = $total_items; - - // Set the session - $_SESSION['view_offset_limit'] = $this->offset_limit; - $_SESSION['view_sort_type'] = $this->sort_type; - $_SESSION['view_offset'] = $this->offset; - $_SESSION['view_base_sql'] = $this->base_sql; - $_SESSION['view_sort_order'] = $this->sort_order; - $_SESSION['view_script'] = $this->script; - $_SESSION['view_total_items'] = $this->total_items; - $this->sql = $this->generate_sql(); - - } //constructor - - //takes all the parts and makes a full blown sql statement - function generate_sql() { - global $conf; - - $sql = $this->base_sql . " ORDER BY " . $this->sort_type ." ". $this->sort_order ." LIMIT " . $this->offset . "," . $this->offset_limit; - - return $sql; - - } //generate_sql - - //change the sort order from asc to desc or vise versa - function change_sort($new_sort=0) { - global $conf; - - if ($new_sort) { - $this->sort_order = $new_sort; - } - elseif ($this->sort_order == "DESC") { - $this->sort_order = "ASC"; - } - else { - $this->sort_order = "DESC"; - } - - $_SESSION['view_sort_order'] = $this->sort_order; - - $this->sql = $this->generate_sql(); - - return; - - } //change_sort - - //change the base sql - function change_sql($base_sql) { - global $conf; - - //Convert all 's into "s - $base_sql = str_replace("'",'"',$base_sql); - - $this->base_sql = $base_sql; - - $_SESSION['view_base_sql'] = $this->base_sql; - - $this->sql = $this->generate_sql(); - - } //change_sql - - //change offset - function change_offset($offset=0) { - global $conf; - - if (isset($offset)) { - $this->offset = $offset; - } - else { - $this->offset = $this->offset + $this->offset_limit; - } - - $_SESSION['view_offset'] = $this->offset; - - $this->sql = $this->generate_sql(); - - } //change_offset - - //change sort_type - function change_sort_type($sort_type) { - - $this->sort_type = $sort_type; - - $_SESSION['view_sort_type'] = $this->sort_type; - - $this->sql = $this->generate_sql(); - - } //change_sort_type - - /*! - @function change_offset_limit - @discussion changes the offset limit, sets the session - var and generates the sql statement - */ - function change_offset_limit($offset_limit) { - - $this->offset_limit = $offset_limit; - - $_SESSION['view_offset_limit'] = $this->offset_limit; - - $this->sql = $this->generate_sql(); - - } // change_offset_limit - - /*! - @function initialize - @discussion initializes the view object, checks $_REQUEST - for changes to the view object - */ - function initialize($sql='') { - - /* From time to time we need to change the SQL statement while - * maintaining the paging - */ - if ($sql) { - $this->change_sql($sql); - } - - if ($_REQUEST['sort_type']) { - $this->change_sort_type($_REQUEST['sort_type']); - } - - if (isset($_REQUEST['offset'])) { - $this->change_offset($_REQUEST['offset']); - } - - if ($_REQUEST['base_sql']) { - $this->change_sql($_REQUEST['base_sql']); - } - - if (isset($_REQUEST['sort_order'])) { - $this->change_sort($_REQUEST['sort_order']); - } - - if ($_REQUEST['offset_limit']) { - $this->change_offset_limit($_REQUEST['offset_limit']); - } - - } // initialize - - - /*! - @function import_session_view - @discussion this imports the view from the session for use.. - this keeps us from having to globalize anything - wohoo! - */ - function import_session_view() { - - $this->sort_type = $_SESSION['view_sort_type']; - $this->offset = $_SESSION['view_offset']; - $this->base_sql = $_SESSION['view_base_sql']; - $this->sort_order = $_SESSION['view_sort_order']; - $this->script = $_SESSION['view_script']; - $this->total_items = $_SESSION['view_total_items']; - - - if ($_SESSION['view_offset_limit']) { - $this->offset_limit = $_SESSION['view_offset_limit']; - } - else { - $this->offset_limit = $_SESSION['offset_limit']; - } - - - $this->sql = $this->generate_sql(); - - } // import_session_view - - - -} //end class -?> diff --git a/lib/init.php b/lib/init.php index b55bfa63..71297258 100644 --- a/lib/init.php +++ b/lib/init.php @@ -118,7 +118,6 @@ define('INIT_LOADED','1'); // Library and module includes we can't do with the autoloader require_once $prefix . '/lib/album.lib.php'; -require_once $prefix . '/lib/artist.lib.php'; require_once $prefix . '/lib/search.php'; require_once $prefix . '/lib/preferences.php'; require_once $prefix . '/lib/rss.php'; |