All pastes #256303 Raw Edit

Something

public text v1 · immutable
#256303 ·published 2006-11-24 00:55 UTC
rendered paste body
Index: lib/class/artist.class.php
===================================================================
--- lib/class/artist.class.php  (revision 696)
+++ lib/class/artist.class.php  (working copy)
@@ -78,11 +78,11 @@
                @function get_albums
                @discussion gets the albums for this artist
        */
-       function get_albums() {
+       function get_albums($sql) {

                $results = array();

-               $sql = "SELECT DISTINCT(album.id) FROM song,album WHERE song.album=album.id AND song.artist='$this->id' ORDER BY album.name";
+//             $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());

                while ($r = mysql_fetch_object($db_results)) {
@@ -279,12 +279,12 @@
                @function show_albums
                @discussion displays the show albums by artist page
        */
-       function show_albums() {
+       function show_albums($sql = 0) {

                /* Set Vars */
                $web_path = conf('web_path');

-               $albums = $this->get_albums();
+               $albums = $this->get_albums($sql);
                $this->format_artist();
                $artist = $this;

Index: artists.php
===================================================================
--- artists.php (revision 696)
+++ artists.php (working copy)
@@ -41,8 +41,38 @@
        show_box_top();
        show_alphabet_list('artists','artists.php');
        show_box_bottom();
+
+        // Setup the View Ojbect
+        $view = new View();
+        $view->import_session_view();
+
+
        $artist = new Artist($_REQUEST['artist']);
-       $artist->show_albums();
+
+        $sql = "SELECT DISTINCT(album.id) FROM song,album WHERE song.album=album.id AND song.artist='$artist->id'";
+
+       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);
+                if ($match != "Show_all") { $offset_limit = $_SESSION['userdata']['offset_limit']; }
+                $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();
        break;

     case 'show_all_songs':
Index: templates/show_artist.inc
===================================================================
--- templates/show_artist.inc   (revision 696)
+++ templates/show_artist.inc   (working copy)
@@ -34,8 +34,8 @@
        &nbsp;&nbsp;<a href="#" onclick="check_songs(); return false;"><?php echo _('Select'); ?></a>
        </th>
        <th><?php echo _('Cover'); ?></th>
-       <th><?php echo _('Album Name'); ?></th>
-       <th><?php echo _('Album Year'); ?></th>
+       <th><a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;artist=<?php echo $artist->id  ?>&amp;keep_view=true&amp;sort_type=album.name&amp;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']; ?>&amp;artist=<?php echo $artist->id  ?>&amp;keep_view=true&amp;sort_type=album.year&amp;sort_order=0"><?php echo _('Album Year'); ?></th>
        <th><?php echo _('Total Tracks'); ?></th>
        <th><?php echo _('Action'); ?></th>
 </tr>