diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-06 21:07:03 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-06 21:07:03 +0000 |
commit | 691c838e90e759a7461cec657d95a4f1af9f46c6 (patch) | |
tree | a979b7a7a67ac22a4119ad9e7311163be50bae24 /lib | |
parent | b1f2bacf4499a3768cf8b64f425110d0616d0154 (diff) | |
download | ampache-691c838e90e759a7461cec657d95a4f1af9f46c6.tar.gz ampache-691c838e90e759a7461cec657d95a4f1af9f46c6.tar.bz2 ampache-691c838e90e759a7461cec657d95a4f1af9f46c6.zip |
basic browse concept added to sidebar and start of the browse logic
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/album.class.php | 113 | ||||
-rw-r--r-- | lib/class/browse.class.php | 90 | ||||
-rw-r--r-- | lib/class/update.class.php | 8 | ||||
-rw-r--r-- | lib/init.php | 5 | ||||
-rw-r--r-- | lib/ui.lib.php | 22 |
5 files changed, 176 insertions, 62 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 72abfab4..fbd55255 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -27,33 +27,48 @@ class Album { /* Variables from DB */ - var $id; - var $name; - var $year; - var $prefix; + public $id; + public $name; + public $year; + public $prefix; /* Art Related Fields */ - var $art; - var $art_mime; + public $art; + public $art_mime; + public $thumb; + public $thumb_mime; // cached information - var $_songs=array(); + public $_songs=array(); - /*! - @function Album - @discussion Album class, for modifing a song. - @param $album_id The ID of the song + /** + * __construct + * Album constructor it loads everything relating + * to this album from the database it does not + * pull the album or thumb art by default or + * get any of the counts. */ - function Album($album_id = 0) { + function __construct($album_id = 0) { if (!$album_id) { return false; } /* Assign id for use in get_info() */ - $this->id = $album_id; + $this->id = intval($album_id); /* Get the information from the db */ - if ($info = $this->_get_info()) { - $this->name = trim($info['prefix'] . " " . $info['album_name']); + $info = $this->_get_info(); + + // Foreach what we've got + foreach ($info as $key=>$value) { + $this->$key = $value; + } + + // Little bit of formating here + $this->f_name = trim($info['prefix'] . ' ' . $info['name']); + + // Additional data that we are going to need + + /* $this->songs = $info['song_count']; $this->artist_count = $info['artist_count']; $this->year = $info['year']; @@ -62,40 +77,40 @@ class Album { $this->album = $info['album_name']; $this->has_art = $info['has_art']; $this->prefix = $info['prefix']; - } // if info + */ return true; } //constructor - /*! - @function get_info - @discussion get's the vars for $this out of the database - @param $this->id Taken from the object - */ + /** + * _get_info + * This is a private function that pulls the album + * from the database + */ private function _get_info() { - $this->id = intval($this->id); - - /* Grab the basic information from the catalog and return it */ + // Just get the album information + $sql = "SELECT * FROM `album` WHERE `id`='" . $this->id . "'"; + + /* Grab the basic information from the catalog and return it $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,album.prefix,album.year,album.name AS album_name,COUNT(song.id) AS song_count," . "artist.name AS artist_name,artist.id AS art_id,artist.prefix AS artist_prefix,album.art AS has_art ". "FROM song,artist,album WHERE album.id='$this->id' AND song.album=album.id AND song.artist=artist.id GROUP BY song.album"; + */ $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); - // If there is art then set it to 1, if not set it to 0, we don't want to cary - // around the full blob with every object because it can be pretty big - $results['has_art'] = strlen($results['has_art']) ? '1' : '0'; - return $results; } // _get_info /** * get_songs - * gets the songs for this album + * gets the songs for this album takes an optional limit + * and an optional artist, if artist is passed it only gets + * songs with this album + specified artist */ public function get_songs($limit = 0,$artist='') { @@ -118,12 +133,31 @@ class Album { } // get_songs /** + * has_art + * This returns true or false depending on if we find any art for this + * album. + */ + public function has_art() { + + $sql = "SELECT `album_id` FROM `album_data` WHERE `album_id`='" . $this->id . "' AND art IS NOT NULL"; + $db_results = Dba::query($sql); + + if (Dba::fetch_assoc($db_results)) { + $this->has_art = true; + return true; + } + + return false; + + } // has_art + + /** * format * This is the format function for this object. It sets cleaned up * albumĀ information with the base required * f_link, f_name */ - function format() { + public function format() { $web_path = Config::get('web_path'); @@ -148,23 +182,12 @@ class Album { } // format /** - * format_album - * DEPRECIATED DO NOT USE! - */ - function format_album() { - - // Call the real function - $this->format(); - - } // format_album - - /** * get_art * This function only pulls art from the database, if thumb is passed * it trys to pull the resized art instead, if resized art is found then * it returns an additional resized=true in the array */ - function get_art() { + public function get_art() { // Attempt to get the resized art first $art = $this->get_resized_db_art(); @@ -187,7 +210,7 @@ class Album { * ['artist'] = STRING * ['album_name'] = STRING */ - function find_art($options=array(),$limit='') { + public function find_art($options=array(),$limit='') { /* Create Base Vars */ $results = array(); @@ -365,7 +388,7 @@ class Album { $id = Dba::escape($this->id); - $sql = "SELECT `thumb` AS `art`,`thumb_mime` AS `art_mime` FROM `album` WHERE `id`='$id'"; + $sql = "SELECT `thumb` AS `art`,`thumb_mime` AS `art_mime` FROM `album_data` WHERE `album_id`='$id'"; $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); @@ -384,7 +407,7 @@ class Album { */ public function get_db_art() { - $sql = "SELECT `art`,`art_mime` FROM `album` WHERE `id`='$this->id'"; + $sql = "SELECT `art`,`art_mime` FROM `album_data` WHERE `album_id`='$this->id'"; $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php new file mode 100644 index 00000000..eaa540bb --- /dev/null +++ b/lib/class/browse.class.php @@ -0,0 +1,90 @@ +<?php +/* + + Copyright (c) 2001 - 2007 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 + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + +*/ + +/** + * Browse Class + * This handles all of the sql/filtering + * on the data before it's thrown out to the templates + * it also handles pulling back the object_ids and then + * calling the correct template for the object we are displaying + */ +class Browse { + + + /** + * constructor + * This should never be called + */ + private __construct() { + + // Rien a faire + + } // __construct + + + /** + * set_filter + * This saves the filter data we pass it into the session + * This is done here so that it's easy to modify where the data + * is saved should I change my mind in the future. It also makes + * a single point for whitelist tweaks etc + */ + public static function set_filter($key,$value) { + + switch ($key) { + case 'show_art': + case 'min_count': + case 'unplayed': + case 'rated': + $key = $_REQUEST['key']; + $_SESSION['browse']['filter'][$key] = make_bool($_REQUEST['value']); + break; + default + // Rien a faire + break; + } // end switch + + } // set_filter + + /** + * set_type + * This sets the type of object that we want to browse by + * we do this here so we only have to maintain a single whitelist + * and if I want to change the location I only have to do it here + */ + public static function set_type($type) { + + switch($type) { + case 'song': + case 'album': + case 'artist': + case 'genre': + $_SESSION['browse']['type'] = $type; + break; + default: + // Rien a faire + break; + } // end type whitelist + + } // set_type + +} // browse diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 5d8805f3..55d32d31 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -604,6 +604,14 @@ class Update { $sql = "ALTER TABLE `album` DROP `art`, DROP `art_mime`, DROP `thumb`, DROP `thumb_mime`"; $db_results = Dba::query($sql); + // We need to fix the user_vote table + $sql = "ALTER TABLE `user_vote` CHANGE `user` `user` INT( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::query($sql); + + // Remove offset limit from the user + $sql = "ALTER TABLE `user` DROP `offset_limit`"; + $db_results = Dba::query($sql); + self::set_version('db_version','340003'); } // update_340003 diff --git a/lib/init.php b/lib/init.php index 477b525e..68a6db21 100644 --- a/lib/init.php +++ b/lib/init.php @@ -226,10 +226,7 @@ else { init_preferences(); /* Add in some variables for ajax done here because we need the user */ -$ajax_info['ajax_url'] = $results['web_path'] . '/server/ajax.server.php'; -$ajax_info['ajax_info'] = '&user_id=' . $GLOBALS['user']->id; -Config::set_by_array($ajax_info); -unset($ajax_info); +Config::set('ajax_url',Config::get('web_path') . '/server/ajax.server.php',1); // Load gettext mojo load_gettext(); diff --git a/lib/ui.lib.php b/lib/ui.lib.php index af88b29e..6746226a 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -141,29 +141,25 @@ function return_referer() { /** * show_alphabet_list - * shows the A-Z,0-9 lists for - * albums and artist pages + * shows the A-Z,0-9 lists for albums and artist page + * It takes a selected and an action */ -function show_alphabet_list ($type,$script="artist.php",$selected="false",$action='match') { +function show_alphabet_list () { $list = array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,"0"); $style_name = "style_" . strtolower($selected); ${$style_name} = "style=\"font-weight:bold;\""; - unset($title); + echo "<div class=\"alphabet\">"; foreach ($list as $l) { $style_name = "style_" . strtolower($l); - echo "<a href=\"". conf('web_path') ."/$script?action=$action&match=$l\" " . ${$style_name} . ">$l</a> | \n"; + echo "<span style=\"width:3px;\" onclick=\"ajaxPut('". Config::get('ajax_url') ."?action=browse&key=alpha_match&value=$l');return true;\">" . + $l . "</span>\n"; + $i++; + if ($i/11 == intval($i/11)) { echo "<br />"; } } - - echo " <a href=\"". conf('web_path') ."/$script?action=$action&match=Browse\" $style_browse>" . _("Browse") . "</a> | \n"; - if ($script == "albums.php") { - echo " <a href=\"". conf('web_path') ."/$script?action=$action&match=Show_missing_art\" $style_show_missing_art>" . _("Show w/o art") . "</a> | \n"; - } // if we are on the albums page - - echo " <a href=\"". conf('web_path') ."/$script?action=$action&match=Show_all\" $style_show_all>" . _("Show all") . "</a>"; - echo "</div>\n"; + echo "</div>"; } // show_alphabet_list |