[mythtv] [PATCH] mythweb feature add: browse by artist name

Shermann Min shermannmin at comcast.net
Tue Mar 1 21:00:37 UTC 2005


I'm a novice with php, but included below is a (hopefully innocuous) patch that adds the alphabet to the offset menu in mythmusic--clicking on a letter will jump you to the first artist in your collection whose name starts with that letter.

This my first patch submission, so if I've performed anything incorrectly, please let me know!

Shermann

-----------------------

Index: music.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/music.php,v
retrieving revision 1.2
diff -u -r1.2 music.php
--- music.php 8 Feb 2005 05:53:20 -0000 1.2
+++ music.php 1 Mar 2005 19:42:05 -0000
@@ -39,6 +39,9 @@
     var $rating;
     var $filename;
     var $urlfilename;
+    
+    var $alphalink;
+    var $alphaoffset;
 
     function mythMusic()
     {
@@ -47,7 +50,15 @@
         else
             $this->offset=0;
 
-
+        /**** If alphalink set, then change offset to new value ****/ 
+        if($_GET['alphalink']) {
+            $alphalink = $_GET['alphalink'];
+            $result=mysql_query("select count(1) from musicmetadata where upper(artist) < $alphalink");
+            $alphaoffset=mysql_fetch_row($result);
+            $this->offset=$alphaoffset[0];
+            mysql_free_result($result);
+        ;
+        }
 
         if($_GET['filterPlaylist'])
         {
Index: themes/Default/music.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/themes/Default/music.php,v
retrieving revision 1.1
diff -u -r1.1 music.php
--- themes/Default/music.php 7 Feb 2005 05:00:04 -0000 1.1
+++ themes/Default/music.php 1 Mar 2005 19:42:21 -0000
@@ -16,6 +16,8 @@
     var $statusMessage;
     var $filterPlaylist;
 
+    var $alphacount;
+
     function getMaxPerPage()
     {
         return($this->maxPerPage);
@@ -37,6 +39,7 @@
 
         if($queryResults)
         {
+            printf("<td align=\"center\">");
             $row=mysql_fetch_row($queryResults);
             printf("<select name=\"filterPlaylist\">\n");
             printf("\t<option value=\"_All_\" ");
@@ -76,7 +79,6 @@
     {
 
         $pageCount=($this->totalCount / $this->maxPerPage) +1;
-        printf("<table class=\"musicTable\" width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
         printf("<tr class=\"menu\">\n");
         if($this->offset > 0)
         {
@@ -91,15 +93,19 @@
 
             printf("%s<a href=\"music.php?offset=%d%s\" >%s</a>","&nbsp;|&nbsp;",
                    $this->offset - $this->maxPerPage,$this->keepFilters, "Previous");
-            printf("</td>");
-
         } else {
             printf("<td align=\"left\"><a href=\"music.php\" >%s</a>","All Music");
             printf("%s","&nbsp;|&nbsp;Top");
             printf("%s","&nbsp;|&nbsp;-" . (5 * $this->maxPerPage));
             printf("%s","&nbsp;|&nbsp;Previous");
-            printf("</td>");
         }
+     
+        /**** Print out alphabet links ****/
+        printf("</td><td align=\"center\">\n");
+        for ($alphacount = 65; $alphacount <= 90; $alphacount++)
+            printf("<a href=\"music.php?alphalink='%s'\" >%s</a> \n", chr($alphacount), chr($alphacount));
+
+        printf("</td>");
 
         if($this->totalCount > ($this->maxPerPage + $this->offset))
         {
@@ -163,10 +169,6 @@
             printf("%s\n","<td align=\"left\" >" . $this->totalCount . " Unfiltered</td>");
 
 
-
-
-        printf("<td align=\"center\" >");
-
         $this->playListSelector();
         $this->actionSelector();
         printf("<input TYPE=\"SUBMIT\" NAME=\"updateButton\" VALUE=\"Update\">");
@@ -186,8 +188,7 @@
         }
 
         printf("</tr>");
-        printf("</table>");
-        $this->printNavBar();
+        $this->printNavBar(); 
         printf("<table class=\"list small\" width=\"100%%\" border=\"0\" cellpadding=\"4\" cellspacing=\"2\">\n");
         printf("<tr class=\"menu\">");
         printf("<td>Track Name</td>\n");
@@ -211,6 +212,7 @@
     function print_footer()
     {
         printf("</table>\n");
+        printf("<table class=\"musicTable\" width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
         $this->printNavBar();
 
         printf("</form>");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20050301/9d73cb2d/attachment.htm


More information about the mythtv-dev mailing list