diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-07 07:20:01 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-07 07:20:01 +0000 |
commit | af2ff07a8174ac2796fa45337bcc5c70d870e0b1 (patch) | |
tree | 9ebaecb008ef72d3b07cc1984de6e8249a13719a | |
parent | 96334a0e8c1c59077e6f9c067dbdee14f6b07be7 (diff) | |
download | ampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.tar.gz ampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.tar.bz2 ampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.zip |
- Fixed Ratings
- Tweaked RSS, still needs work
- Show Single artist mostly finished
-rw-r--r-- | artists.php | 87 | ||||
-rw-r--r-- | lib/class/artist.class.php | 39 | ||||
-rw-r--r-- | lib/class/rating.class.php | 39 | ||||
-rw-r--r-- | lib/rss.php | 10 | ||||
-rw-r--r-- | rss.php | 19 | ||||
-rw-r--r-- | server/ajax.server.php | 3 | ||||
-rw-r--r-- | templates/show_artist.inc | 88 | ||||
-rw-r--r-- | templates/show_artist.inc.php | 76 | ||||
-rw-r--r-- | templates/show_artist_box.inc.php | 26 |
9 files changed, 164 insertions, 223 deletions
diff --git a/artists.php b/artists.php index 8e3241e8..276c02d7 100644 --- a/artists.php +++ b/artists.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or @@ -20,71 +20,40 @@ */ -/* - - Do most of the dirty work of displaying the mp3 catalog - -*/ - -require_once('lib/init.php'); - -if (!isset($_REQUEST['match'])) { $_REQUEST['match'] = "Browse"; } -if (!isset($_REQUEST['action'])) { $_REQUEST['action'] = "match"; } -$action = scrub_in($_REQUEST['action']); - -show_template('header'); - +require_once 'lib/init.php'; -switch($action) { - case 'show': - case 'Show': - show_box_top(); - show_alphabet_list('artists','artists.php'); - show_box_bottom(); +show_header(); - // Setup the View Ojbect - $view = new View(); - $view->import_session_view(); +/** + * Doing Switch + */ +switch($_REQUEST['action']) { - $artist = new Artist($_REQUEST['artist']); - $sql = "SELECT DISTINCT(album.id) FROM song,album WHERE song.album=album.id AND song.artist='$artist->id'"; +} // end display switch - if ($_REQUEST['keep_view']) { - $view->initialize(); - } - // If we aren't keeping the view then initlize it - elseif ($sql) { - if (!$sort_order) { $sort_order = 'album.name'; } - $db_results = mysql_query($sql, dbh()); - $total_items = mysql_num_rows($db_results); - $offset_limit = $total_items; - $view = new View($sql, 'artists.php',$sort_order,$total_items,$offset_limit); - } - - else { $view = false; } - - if ($view->base_sql) { - $artist->show_albums($view->sql); - } - - - - //$artist->show_albums(); +/** + * Display Switch + */ +switch($_REQUEST['action']) { + case 'show': + $artist = new Artist($_REQUEST['artist']); + $artist->format(); + $albums = $artist->get_albums(); + require_once Config::get('prefix') . '/templates/show_artist.inc.php'; break; - - case 'show_all_songs': - $artist = new Artist($_REQUEST['artist']); - $artist->format_artist(); - $song_ids = $artist->get_song_ids(); - $artist_id = $artist->id; - require(conf('prefix') . '/templates/show_artist_box.inc.php'); - show_songs($song_ids,''); + case 'show_all_songs': + $artist = new Artist($_REQUEST['artist']); + $artist->format_artist(); + $song_ids = $artist->get_song_ids(); + $artist_id = $artist->id; + require(conf('prefix') . '/templates/show_artist_box.inc.php'); + show_songs($song_ids,''); break; - case 'update_from_tags': + case 'update_from_tags': $artist = new Artist($_REQUEST['artist']); @@ -246,12 +215,6 @@ switch($action) { } } break; - default: - //FIXME: This is being moved to browse - show_alphabet_list('artists','artists.php'); - show_alphabet_form('',_("Show Artists starting with"),"artists.php?action=match"); - show_artists('A'); - break; } // end switch show_footer(); diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 7a07785d..7de2f62d 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -71,20 +71,21 @@ class Artist { } // _get_info - /*! - @function get_albums - @discussion gets the albums for this artist - //FIXME: Appears to not be used? - */ - function get_albums($sql) { + /** + * get_albums + * gets the album ids that this artist is a part + * of + */ + public function get_albums() { $results = array(); -// $sql = "SELECT DISTINCT(album.id) FROM song,album WHERE song.album=album.id AND song.artist='$this->id' ORDER BY album.name"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` " . + "WHERE `song`.`artist`='$this->id' GROUP BY `album`.`id` ORDER BY `album`.`name`,`album`.`year`"; + $db_results = Dba::query($sql); - while ($r = mysql_fetch_object($db_results)) { - $results[] = new Album($r->id); + while ($r = Dba::fetch_assoc($db_results)) { + $results[] = $r['id']; } return $results; @@ -287,24 +288,6 @@ class Artist { } } // merge - - /*! - @function show_albums - @discussion displays the show albums by artist page - */ - function show_albums($sql = 0) { - - /* Set Vars */ - $web_path = conf('web_path'); - - $albums = $this->get_albums($sql); - $this->format_artist(); - $artist = $this; - - require (conf('prefix') . "/templates/show_artist.inc"); - - } // show_albums - /*! @function get_similar_artists @discussion returns an array of artist (id,name) arrays that are similar in name diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 43200f90..99fa7612 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -38,13 +38,13 @@ class Rating { * This is run every time a new object is created, it requires * the id and type of object that we need to pull the raiting for */ - function Rating($id,$type) { + public function __construct($id,$type) { $this->id = intval($id); $this->type = Dba::escape($type); // Check for the users rating - if ($rating = $this->get_user($GLOBALS['user']->id)) { + if ($rating == $this->get_user($GLOBALS['user']->id)) { $this->rating = $rating; } else { @@ -53,23 +53,23 @@ class Rating { return true; - } // Rating + } // Constructor /** * get_user * Get the user's rating this is based off the currently logged * in user. It returns the value */ - function get_user($user_id) { + public function get_user($user_id) { $user_id = Dba::escape($user_id); - $sql = "SELECT rating FROM ratings WHERE user='$user_id' AND object_id='$this->id' AND object_type='$this->type'"; + $sql = "SELECT `user_rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); - - return $results['rating']; + + return $results['user_rating']; } // get_user @@ -80,9 +80,9 @@ class Rating { * is no personal rating, and used for random play mojo. It sets * $this->average_rating and returns the value */ - function get_average() { + public function get_average() { - $sql = "SELECT user_rating as rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'"; + $sql = "SELECT `user_rating` AS `rating` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $i = 0; @@ -113,22 +113,23 @@ class Rating { * This uses the currently logged in user for the 'user' who is rating * the object. Returns true on success, false on failure */ - function set_rating($score) { + public function set_rating($score) { - $score = sql_escape($score); + $score = Dba::escape($score); /* Check if it exists */ - $sql = "SELECT id FROM ratings WHERE object_id='$this->id' AND object_type='$this->type' AND `user`='" . sql_escape($GLOBALS['user']->username) . "'"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " . + "AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'"; + $db_results = Dba::query($sql); - if ($existing = mysql_fetch_assoc($db_results)) { - $sql = "UPDATE ratings SET user_rating='$score' WHERE id='" . $existing['id'] . "'"; - $db_results = mysql_query($sql, dbh()); + if ($existing = Dba::fetch_assoc($db_results)) { + $sql = "UPDATE `rating` SET `user_rating`='$score' WHERE `id`='" . $existing['id'] . "'"; + $db_results = Dba::query($sql); } else { - $sql = "INSERT INTO ratings (`object_id`,`object_type`,`user_rating`,`user`) VALUES " . - " ('$this->id','$this->type','$score','" . sql_escape($GLOBALS['user']->username) . "')"; - $db_results = mysql_query($sql, dbh()); + $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`user_rating`,`user`) VALUES " . + " ('$this->id','$this->type','$score','" . $GLOBALS['user']->id . "')"; + $db_results = Dba::query($sql); } return true; diff --git a/lib/rss.php b/lib/rss.php index 0252aa6a..9801f092 100644 --- a/lib/rss.php +++ b/lib/rss.php @@ -28,9 +28,8 @@ function show_RSS ($type = 'artist',$username = 0) { header ("Content-Type: application/xml"); - $dbh = dbh(); - $web_path = conf('web_path'); - $rss_main_title = conf('rss_main_title'); + $web_path = Config::get('web_path'); + $rss_main_title = "Ampache :: Pour l'Amour de la Musique - RSS"; $rss_latestartist_title = "Ampache Latest Artists"; $rss_latestalbum_title = "Ampache Latest Albums"; @@ -39,9 +38,6 @@ function show_RSS ($type = 'artist',$username = 0) { $rss_popularsong_title = "Ampache Most Popular Songs"; $rss_recentlyplayed_title = "Ampache Recently Played"; - $rss_main_description = conf('rss_main_description'); - $rss_main_copyright = conf('rss_main_copyright'); - $rss_description = conf('rss_song_description'); $today = date("d-m-Y"); echo "<rss version=\"2.0\">\n"; @@ -57,7 +53,7 @@ switch ($type) { " WHERE object_type='album' AND date >= '$date'" . " GROUP BY object_id ORDER BY `count` DESC LIMIT 10"; - $db_result = mysql_query($sql, $dbh); + $db_result = Dba::query($sql); echo " <channel>\n <title>$rss_popularalbum_title</title>\n"; echo " <link>$web_path</link>\n <description>$rss_main_description</description>\n"; @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -21,13 +21,26 @@ */ define('NO_SESSION','1'); -require('lib/init.php'); +require 'lib/init.php'; /* Check Perms */ -if (!conf('use_rss') || conf('demo_mode')) { +if (!Config::get('use_rss') || Config::get('demo_mode')) { access_denied(); + exit; } + +switch ($_REQUEST['action']) { + case 'user': + + break; + case 'catalog_add': + + default: + + break; +} // end data collection + #show_now_playingRSS($_REQUEST['username']); show_RSS($_REQUEST['type'],$_REQUEST['username']); diff --git a/server/ajax.server.php b/server/ajax.server.php index 50368e9b..407a5f3c 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -169,8 +169,7 @@ switch ($action) { $key = "rating_" . $_REQUEST['object_id'] . "_" . $_REQUEST['rating_type']; $results[$key] = ob_get_contents(); ob_end_clean(); - $xml_doc = xml_from_array($results); - echo $xml_doc; + echo xml_from_array($results); break; /* Activate the Democratic Instance */ case 'tv_activate': diff --git a/templates/show_artist.inc b/templates/show_artist.inc deleted file mode 100644 index f47b8894..00000000 --- a/templates/show_artist.inc +++ /dev/null @@ -1,88 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2005 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. - -*/ - -//FIXME: I don't like having to re-create this friggin object.. :( -$artist_id = $artist->id; -$web_path = conf('web_path'); -?> -<?php require (conf('prefix') . '/templates/show_artist_box.inc.php'); ?> -<!-- *** Multi-Album Art Display Thx MrBlahh Updated by clader *** --> -<?php show_box_top(); ?> -<form id="songs" method="post" enctype="multipart/form-data" action="artists.php"> -<table class="tabledata" cellspacing="0" cellpadding="0" border="0"> -<tr class="table-header"> - <th align="center"> - <a href="#" onclick="check_select('song'); return false;"><?php echo _('Select'); ?></a> - </th> - <th><?php echo _('Cover'); ?></th> - <th><a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&artist=<?php echo $artist->id ?>&keep_view=true&sort_type=album.name&sort_order=0"><?php echo _('Album Name'); ?></th> - <th><a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&artist=<?php echo $artist->id ?>&keep_view=true&sort_type=album.year&sort_order=0"><?php echo _('Album Year'); ?></th> - <th><?php echo _('Tracks'); ?></th> - <th><?php echo _('Action'); ?></th> -</tr> -<?php -foreach ($albums as $album) { - $id = $album->id; - $album_name = $album->name; - $count = $album->songs; -?> - <tr class="<?php echo flip_class(); ?>"> - <td align="center"> - <input name="song[]" value="<?php echo $id; ?>" type="checkbox" /> - </td> - <td height="87"> - <a href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $id; ?>&artist=<?php echo $artist->id; ?>"> - <img border="0" src="<?php echo $web_path; ?>/image.php?id=<?php echo $id; ?>&thumb=1&sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($album_name); ?>" title="<?php echo scrub_out($album_name); ?>" height="75" width="75" /> - </a> - </td> - <td> - <a href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $id; ?>&artist=<?php echo $artist->id; ?>"><?php echo $album_name; ?></a> - </td> - <td><?php echo $album->year; ?></td> - <td><?php echo $count; ?></td> - <td> - <a href="<?php echo $web_path; ?>/song.php?action=album&album_id=<?php echo $id; ?>"> - <?php echo get_user_icon('all'); ?> - </a> - <a href="<?php echo $web_path; ?>/song.php?action=album_random&album_id=<?php echo $album->id; ?>"> - <?php echo get_user_icon('random'); ?> - </a> - <?php if (batch_ok()) { ?> - <a href="<?php echo $web_path; ?>/batch.php?action=alb&id=<?php echo $album->id; ?>"> - <?php echo get_user_icon('batch_download'); ?> - </a> - <?php } ?> - <?php if ($GLOBALS['user']->has_access('100')) { ?> - <a href="<?php echo $web_path; ?>/admin/flag.php?action=show_edit_album&album_id=<?php echo $album->id; ?>"> - <?php echo get_user_icon('edit'); ?> - </a> - <?php } ?> - </td> - </tr> -<?php } //end foreach ($albums as $album)?> -</table> -<br /><br /> - -<?php show_play_selected(); ?> -<input type="hidden" name="type" value="album" /> -<input type="hidden" name="artist_id" value="<?php echo $artist_id; ?>" /> -</form> -<?php show_box_bottom(); ?> diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php new file mode 100644 index 00000000..0e7613a1 --- /dev/null +++ b/templates/show_artist.inc.php @@ -0,0 +1,76 @@ +<?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 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. + +*/ + +$web_path = Config::get('web_path'); + +require Config::get('prefix') . '/templates/show_artist_box.inc.php'; + +show_box_top(); +?> +<table class="tabledata" cellspacing="0" cellpadding="0" border="0"> +<tr class="table-header"> + <th align="center"><?php echo _('Add'); ?></th> + <th><?php echo _('Cover'); ?></th> + <th><?php echo _('Album Name'); ?></th> + <th><?php echo _('Album Year'); ?></th> + <th><?php echo _('Tracks'); ?></th> + <th><?php echo _('Action'); ?></th> +</tr> +<?php +foreach ($albums as $album_id) { + $album = new Album($album_id); + $album->format(); +?> +<tr class="<?php echo flip_class(); ?>"> + <td align="center"> + <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&type=album&id=<?php echo $album->id; ?>');return true;" > + <?php echo get_user_icon('add','',_('Add')); ?> + </span> + <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&type=album_random&id=<?php echo $album->id; ?>');return true;" > + <?php echo get_user_icon('random','',_('Random')); ?> + </span> + </td> + <td height="87"> + <a href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $album->id; ?>&artist=<?php echo $artist->id; ?>"> + <img border="0" src="<?php echo $web_path; ?>/image.php?id=<?php echo $album->id; ?>&thumb=1&sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($album->name); ?>" title="<?php echo scrub_out($album->name); ?>" height="75" width="75" /> + </a> + </td> + <td> + <?php echo $album->f_name_link; ?> + </td> + <td><?php echo $album->year; ?></td> + <td><?php echo $album->song_count; ?></td> + <td> + <?php if (Access::check_function('batch_download')) { ?> + <a href="<?php echo $web_path; ?>/batch.php?action=album&id=<?php echo $album->id; ?>"> + <?php echo get_user_icon('batch_download'); ?> + </a> + <?php } ?> + <?php if ($GLOBALS['user']->has_access('100')) { ?> + <a href="<?php echo $web_path; ?>/admin/flag.php?action=show_edit_album&album_id=<?php echo $album->id; ?>"> + <?php echo get_user_icon('edit'); ?> + </a> + <?php } ?> + </td> +</tr> +<?php } //end foreach ($albums as $album)?> +</table> +<?php show_box_bottom(); ?> diff --git a/templates/show_artist_box.inc.php b/templates/show_artist_box.inc.php index 20feacaa..cf3d71e6 100644 --- a/templates/show_artist_box.inc.php +++ b/templates/show_artist_box.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or @@ -19,24 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -$web_path = conf('web_path'); +$web_path = Config::get('web_path'); $title = _('Albums by') . " " . $artist->full_name; -?> -<?php require (conf('prefix') . '/templates/show_box_top.inc.php'); ?> -<?php -if (conf('ratings')) { + +show_box_top(_('Albums by') . ' ' . $artist->full_name); +if (Config::get('ratings')) { echo "<span id=\"rating_" . $artist->id . "_artist\" style=\"display:inline;\">"; show_rating($artist->id, 'artist'); echo "</span>"; } // end if ratings ?> <strong><?php echo _('Actions'); ?>:</strong><br /> - <a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&artist=<?php echo $artist_id; ?>"><?php echo _("Show All Songs By") . " " . $artist->full_name; ?></a><br /> - <a href="<?php echo $web_path; ?>/song.php?action=artist&artist_id=<?php echo $artist_id; ?>"><?php echo _("Play All Songs By") . " " . $artist->full_name; ?></a><br /> - <a href="<?php echo $web_path; ?>/song.php?action=artist_random&artist_id=<?php echo $artist_id; ?>"><?php echo _("Play Random Songs By") . " " . $artist->full_name; ?></a><br /> +<a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&artist=<?php echo $artist_id; ?>"><?php echo _("Show All Songs By") . " " . $artist->full_name; ?></a><br /> +<a href="<?php echo $web_path; ?>/song.php?action=artist&artist_id=<?php echo $artist_id; ?>"><?php echo _("Play All Songs By") . " " . $artist->full_name; ?></a><br /> +<a href="<?php echo $web_path; ?>/song.php?action=artist_random&artist_id=<?php echo $artist_id; ?>"><?php echo _("Play Random Songs By") . " " . $artist->full_name; ?></a><br /> <?php if ($GLOBALS['user']->has_access('100')) { ?> - <a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&artist=<?php echo $artist_id; ?>"><?php echo _("Update from tags"); ?></a><br /> - <a href="<?php echo $web_path; ?>/artists.php?action=show_rename&artist=<?php echo $artist_id; ?>"><?php echo _("Rename Artist"); ?></a><br /> - <a href="<?php echo $web_path; ?>/artists.php?action=show_similar&artist=<?php echo $artist_id; ?>"><?php echo _("Find duplicate artists"); ?></a><br /> + <a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&artist=<?php echo $artist_id; ?>"><?php echo _("Update from tags"); ?></a><br /> + <a href="<?php echo $web_path; ?>/artists.php?action=show_rename&artist=<?php echo $artist_id; ?>"><?php echo _("Rename Artist"); ?></a><br /> + <a href="<?php echo $web_path; ?>/artists.php?action=show_similar&artist=<?php echo $artist_id; ?>"><?php echo _("Find duplicate artists"); ?></a><br /> <?php } ?> -<?php require (conf('prefix') . '/templates/show_box_bottom.inc.php'); ?> -<?php unset($title); ?> +<?php show_box_bottom(); ?> |