Index: modules/filestore2/filestore2.module
===================================================================
RCS file: /home/cvsroot/drupal-4.5/modules/filestore2/filestore2.module,v
retrieving revision 1.1
diff -u -r1.1 filestore2.module
--- modules/filestore2/filestore2.module	17 Oct 2004 05:30:26 -0000	1.1
+++ modules/filestore2/filestore2.module	18 Oct 2004 08:36:15 -0000
@@ -1,6 +1,6 @@
 <?php
 
-/* $Id: filestore2.module,v 1.1 2004/10/17 05:30:26 jeff Exp $ */
+/* $Id: filestore2.module,v 1.16 2004/09/13 01:38:31 gordon Exp $ */
 
 /*
  * Filestore2 drupal _hooks()
@@ -97,7 +97,12 @@
         watchdog("user", t("file %filename downloaded.", array("%filename" => $node->filename)));
       }
       break;
+	case 'browse':
+      print theme("page",_filestore2_browse(arg(2)));
+	  break;
     default:
+	  $output .= theme('box','',theme('filestore2alpha', ' '));
+	
       $result = pager_query("SELECT n.nid, n.type FROM {node} n JOIN {filestore2} f WHERE n.status = '1' AND n.nid = f.nid ORDER BY ". ($_GET["order"] ? $_GET["order"]. " ". $_GET["sort"] : "n.sticky DESC, n.created DESC"), variable_get("default_nodes_main", 10));
 
       while ($node = db_fetch_object($result)) {
@@ -479,5 +484,66 @@
         return substr($size, 0, -1);
     }
   }
+}
+
+function _filestore2_browse($letter) {
+  $breadcrumb[] = l(t("Home"), NULL);
+  $breadcrumb[] = l(t("Files"),"filestore2");
+  $breadcrumb[] = $letter;
+  drupal_set_breadcrumb($breadcrumb);
+
+  $output = theme('box','',theme('filestore2alpha', $letter));
+  
+  $output .= theme('filestore2_page_browse',$letter);
+
+  return $output;
+}
+
+//Theme functions
+/*
+* artistalpha($letter)
+* $letter is were we are now
+* returns htmlstring
+* 
+* TODO: it would make sense to cache this, since the alphabet will not change often :).
+* this can be achieved in a couple of ways:
+* * make it a string that can be t()-ed
+* * use the drupal cache, and call db.
+*/
+function theme_filestore2alpha($letter = '') {
+  $alphabet = 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");
+  $num = count($alphabet) - 1;
+  $output = "<div class=\"artist-aplha\">[ ";
+  
+  foreach($alphabet as $char) {
+    if (strcmp($letter,$char)) { 
+      $output .= l("$char", "filestore2/browse/".$char, array("title" => t("browse files starting with %char", array("%char" => $char))));
+    }
+    else { //dont make a link for the one we are looking at right now
+      $output .= "<span class=\"artist-activeletter\">".$char."</span>";
+    }
+    if(strcmp($char, $alphabet[$num])) {//dont show the pipe after the  last letter
+      $output .= " | ";
+    }
+  } 
+
+  $output .= " ]</div><br />\n";
+  return $output;
+}
+
+/*
+* returns a pager with artsits sorted by date of creation
+*/
+function theme_filestore2_page_browse($letter) {
+  global $user;
+  
+  $result = pager_query("SELECT n.nid, n.type FROM {node} n JOIN {filestore2} f WHERE n.status = '1' AND n.nid = f.nid AND LOWER(title) LIKE '".strtolower($letter)."%' ORDER BY ". ($_GET["order"] ? $_GET["order"]. " ". $_GET["sort"] : "n.sticky DESC, n.created DESC"), variable_get("default_nodes_main", 10));
+
+  while ($node = db_fetch_object($result)) {
+    $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
+  }
+
+  return $output ? $output : "No result.";
 }
 ?>