cvs: phpweb / download-docs.php
| From: | Gabor Hojtsy | Date: | Mon, 27 Oct 2003 17:29:54 +0000 |
| Subject: | cvs: phpweb / download-docs.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-21677@lists.php.net to get a copy of this message | ||
goba Mon Oct 27 12:29:54 2003 EDT
Modified files:
/phpweb download-docs.php
Log:
Rewrite the download table code to print out an error if no format
is available for download, and omit columns and rows if no file
is available in that format / language. TODO: cleanup :)
Index: phpweb/download-docs.php
diff -u phpweb/download-docs.php:1.59 phpweb/download-docs.php:1.60
--- phpweb/download-docs.php:1.59 Mon Oct 27 05:20:44 2003
+++ phpweb/download-docs.php Mon Oct 27 12:29:54 2003
@@ -1,5 +1,5 @@
<?php
-// $Id: download-docs.php,v 1.59 2003/10/27 10:20:44 goba Exp $
+// $Id: download-docs.php,v 1.60 2003/10/27 17:29:54 goba Exp $
$_SERVER['BASE_PAGE'] = 'download-docs.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
@@ -59,28 +59,12 @@
use does otherwise.
</p>
-<table border="0" cellpadding="3" cellspacing="2"
class="standard">
- <tr>
- <th> </th>
-<?php
-
-// Print out the name of the formats
-foreach ($formats as $formatname => $extension) {
- echo " <th valign=\"bottom\">$formatname</th>\n";
-}
+<?php
+$files = array(); $found_formats = array();
-echo " </tr>\n";
-
// Go through all possible manual languages
foreach ($LANGUAGES as $langcode => $language) {
- // See if current language is the preferred one
- if ($langcode == $LANG) { $preflang = TRUE; }
- else { $preflang = FALSE; }
-
- // Reset files array and format counter
- $files = array(); $formatnum = 0;
-
// Go through all possible manual formats
foreach ($formats as $formatname => $extension) {
@@ -99,33 +83,44 @@
$changed = @filemtime($actual_file);
// Size available, collect information
- if ($size) {
- $files[] = array(
+ if ($size !== FALSE) {
+ $files[$langcode][$extension] = array(
$link_to,
(int) ($size/1024),
date("j M Y", $changed),
$extension
);
- $formatnum++;
- }
-
- // Size is not available, we won't list the file
- else {
- $files[] = '';
+ if (!in_array($extension, array_keys($found_formats))) {
+ $found_formats[$formatname] = $extension;
+ }
}
}
-
- // Unable to find file
- else {
- $files[] = '';
- }
}
-
- // At least one format is found for this
- // language => write out table row
- if ($formatnum > 0) {
+}
+if (count($found_formats) == 0) {
+ echo "<p class=\"tip\">This mirror has no documentation files for
download.</p>";
+} else {
+
+ echo '<table border="0" cellpadding="3" cellspacing="2"
class="standard">' . "\n" .
+ "<tr>\n <th> </th>\n";
+
+ // Print out the name of the formats
+ foreach ($formats as $formatname => $extension) {
+ if (!in_array($extension, array_values($found_formats))) { continue; }
+ echo " <th valign=\"bottom\">$formatname</th>\n";
+ }
+
+ echo " </tr>\n";
+
+ foreach ($files as $langcode => $lang_files) {
+
+ // See if current language is the preferred one
+ if ($langcode == $LANG) { $preflang = TRUE; }
+ else { $preflang = FALSE; }
+
// Additional link for special French version of the manual
+ $language = $LANGUAGES[$langcode];
if ($langcode == "fr") {
$language .= '<br /><a href="http://dev.nexen.net/docs/php/chargement.html">[Special
French]</a>';
}
@@ -138,26 +133,24 @@
}
echo "<tr>\n<th class=\"subl\">$language</td>\n";
+
+ foreach ($formats as $formatname => $extension) {
- // Print out a table cell for all formats
- foreach ($files as $fileinfo) {
-
+ // Skip if no file found
+ if (!in_array($extension, array_values($found_formats))) { continue; }
+
echo "<td align=\"center\"$cellclass>";
- // Missing format
- if ($fileinfo == '') {
+ if (!isset($lang_files[$extension])) {
echo " ";
- }
-
- // Format found, write out link
- else {
-
- // Start link tag
+ } else {
+
+ $fileinfo = $lang_files[$extension];
echo "<a href=\"$fileinfo[0]\"";
// Only print out tooltip, if explicit information is not printed
if (!$sizes && !$preflang) {
- echo " title=\" Size: $fileinfo[1]Kb\n Date:
$fileinfo[2]\"";
+ echo " title=\" Size: $fileinfo[1]Kb -- Date:
$fileinfo[2]\"";
}
// End link tag
@@ -170,20 +163,21 @@
}
// Quite bad looking code tweak to add a link to the extended CHM (en only!)
- if (strpos($fileinfo[0], "_en.chm/from")) {
+ if ($langcode == "en" && $extension == "chm") {
echo '<br /><a href="http://weblabor.hu/php-doc-chm">extended
chm</a>';
}
// End table cell
echo "</td>\n";
+
}
// End table row
echo "</tr>\n";
}
+ echo "</table>\n";
}
?>
-</table>
<hr />