cvs: phpweb /reST index.php

[email protected] ("Hannes Magnusson")
Newsgroups php.webmaster
Message-ID <cvsbjori1200048513@cvsserver>
bjori		Fri Jan 11 10:48:33 2008 UTC

  Modified files:              
    /phpweb/reST	index.php 
  Log:
  - Use a "tree-like-structure" (pecl/ or phpdoc/ files will probablly be added later)
  - Only print the "last part" of the filename (i.e. README.FOOBAR => FOOBAR)
  
  
http://cvs.php.net/viewvc.cgi/phpweb/reST/index.php?r1=1.2&r2=1.3&diff_format=u
Index: phpweb/reST/index.php
diff -u phpweb/reST/index.php:1.2 phpweb/reST/index.php:1.3
--- phpweb/reST/index.php:1.2	Wed Nov 21 10:45:52 2007
+++ phpweb/reST/index.php	Fri Jan 11 10:48:33 2008
@@ -1,5 +1,5 @@
 <?php
-// $Id: index.php,v 1.2 2007/11/21 10:45:52 bjori Exp $
+// $Id: index.php,v 1.3 2008/01/11 10:48:33 bjori Exp $
 $_SERVER['BASE_PAGE'] = 'reST/index.php';
 include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
 include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
@@ -15,20 +15,40 @@
 
 
 $SIDEBAR_DATA = '<h3>File list</h3>
-<ul class="simple">';
+<ul class="simple" id="reSTlist">';
 
 $restfiles = glob($rest_dir. "/*");
 
-$list = "";
+$list = $lastdir = "";
 foreach($restfiles as $filename) {
 	$link = basename($filename, ".rest");
-	$text = substr($link, strpos($link, "_")+1); // Remove the fs dirname
-	$link[strpos($link, "_")] = "/"; // Replace the first - with a directory seperator
-	$list .= '<li><a href="/reST/' .$link.'">'.$text.'</a></li>';
+
+	// Separate the dirname from the filename
+	list($dir, $filename) = explode("_", $link, 2);
+
+	// Create a tree-like-structure
+	if ($dir != $lastdir) {
+		if ($lastdir) {
+			$list .= "</ul>\n";
+		}
+		$list .= "<li><h4>$dir</h4><li>\n<ul class=\"simple\">\n";
+		$lastdir = $dir;
+	}
+
+	// Replace the first - with a directory seperator
+	$link[strpos($link, "_")] = "/";
+
+	// Only use the "last part" of the filename (i.e. README.FOOBAR => FOOBAR)
+	if (strpos($filename, ".") !== false) {
+		$filename = substr($filename, strpos($filename, ".")+1);
+	}
+
+	$filename = str_replace(array("-", "_"), " ", $filename);
+	$list .= '<li><a href="/reST/' .$link.'">'.$filename.'</a></li>'."\n";
 }
 
 if ($list) {
-	$SIDEBAR_DATA .= $list;
+	$SIDEBAR_DATA .= "$list</ul>";
 } else {
 	$SIDEBAR_DATA .= "<li>No files available</li>";
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.