[28943] trunk/www/downloads.php
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 12 09:57:04 PDT 2007
Revision: 28943
http://trac.macosforge.org/projects/macports/changeset/28943
Author: jmpp at macports.org
Date: 2007-09-12 09:57:04 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
Refactor the downloads.php file to be xhtml complaint even if there are no available files. That is, check
the $files array's lenght and don't print the table if 0.
Also clean up whitespace... sorry for the mixed commit!
Modified Paths:
--------------
trunk/www/downloads.php
Modified: trunk/www/downloads.php
===================================================================
--- trunk/www/downloads.php 2007-09-12 16:55:41 UTC (rev 28942)
+++ trunk/www/downloads.php 2007-09-12 16:57:04 UTC (rev 28943)
@@ -5,33 +5,37 @@
print_header('MacPorts -- Downloads', 'utf-8');
?>
- <div id="content">
- <h2 class="hdr">Available Downloads</h2>
- <table>
+<div id="content">
+ <h2 class="hdr">Available Downloads</h2>
<?php
- $dir=".";
- // Read files from the dirctory
- $files = array();
- $rep=opendir($dir);
- while ($file = readdir($rep)) {
- if (preg_match('/^(\..*)|(.*\.(php|css|html|js))$/', $file) || is_dir($file)) { continue; }
- // Add file to array, as key, with modtime as value
- $files[$file] = filemtime($file);
- }
- closedir($rep);
+ $dir=".";
+ // Read files from the dirctory
+ $files = array();
+ $rep=opendir($dir);
+ while ($file = readdir($rep)) {
+ if (preg_match('/^(\..*)|(.*\.(php|css|html|js))$/', $file) || is_dir($file)) {
+ continue;
+ }
+ // Add file to array, as key, with modtime as value
+ $files[$file] = filemtime($file);
+ }
+ closedir($rep);
- // Sort the array in reverse order by value (modtime)
- arsort($files);
-
- // Emit the files, with dates
- foreach ($files as $f => $t) {
- echo "<tr>";
- echo "<td>".date("d-M-Y G:i", $t)."</td><td><a href=\"/macports/downloads/$f\">$f</a></td>\n";
- echo "</tr>";
- }
+ // Print the table only if the $files array is non-emtpy
+ if (count($files)) {
+ // Sort the array in reverse order by value (modtime)
+ arsort($files);
+ // Emit the files, with dates
+ echo "<table>";
+ foreach ($files as $f => $t) {
+ echo "<tr>";
+ echo "<td>".date("d-M-Y G:i", $t)."</td><td><a href=\"downloads/$f\">$f</a></td>\n";
+ echo "</tr>";
+ }
+ echo "</table>";
+ }
?>
- </table>
- </div>
+</div>
<?php
print_footer();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070912/8a70fd1d/attachment.html
More information about the macports-changes
mailing list