com web/php: - Enabled the new enhanced chm format (chm with user notes) - This script now bases format type on 'formatname' instead of 'extension' as
we now have two .chm files - This script needs refactoring, and caching: download-docs.php
| From: | Paul Dragoonis | Date: | Wed, 23 Feb 2011 01:06:51 +0000 |
| Subject: | com web/php: - Enabled the new enhanced chm format (chm with user notes) - This script now bases format type on 'formatname' instead of 'extension' as we now have two .chm files - This script needs refactoring, and caching: download-docs.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-23588@lists.php.net to get a copy of this message | ||
Commit: 4015ca8c1f109845982c2d7b1246edf117a8cf48
Author: Philip Olson <philip@php.net> Wed, 23 Feb 2011 01:06:51 +0000
Parents: 2d349f2f1bdd1042e8dee95abc044f7e1c8c5a66
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=4015ca8c1f109845982c2d7b1246edf117a8cf48
Log:
- Enabled the new enhanced chm format (chm with user notes)
- This script now bases format type on 'formatname' instead of 'extension' as we
now have two .chm files
- This script needs refactoring, and caching
Changed paths:
M download-docs.php
Diff:
diff --git a/download-docs.php b/download-docs.php
index 5be38bb..87bc909 100644
--- a/download-docs.php
+++ b/download-docs.php
@@ -54,6 +54,7 @@ $formats = array(
# "Many PDF files" => "pdf.tar..gz",
# "PDF" => "pdf",
"HTML Help file" => "chm",
+ "HTML Help file (with user notes)" => "chm",
);
?>
@@ -95,6 +96,7 @@ $formats = array(
<?php
$files = array(); $found_formats = array();
+$filepath = $filename = '';
// Go through all possible manual languages
foreach ($LANGUAGES as $langcode => $language) {
@@ -105,31 +107,34 @@ foreach ($LANGUAGES as $langcode => $language) {
// Go through all possible manual formats
foreach ($formats as $formatname => $extension) {
- // Actual filename of the file
- $actual_file = $_SERVER['DOCUMENT_ROOT'] .
- "/distributions/manual/php_manual_$langcode.$extension";
+ $filepath = $_SERVER['DOCUMENT_ROOT'] . '/distributions/manual/';
+ if ($formatname === 'HTML Help file (with user notes)') {
+ $filename = "php_enhanced_$langcode..$extension";
+ } else {
+ $filename = "php_manual_$langcode.$extension";
+ }
+
+ $filepath .= $filename;
// File named after the language and format exists
- if (file_exists($actual_file)) {
+ if (file_exists($filepath)) {
// Mirror selection download URL
- $link_to = "/get/php_manual_$langcode.$extension/from/a/mirror";
+ $link_to = "/get/$filename/from/a/mirror";
// Try to get size and changed date
- $size = @filesize($actual_file);
- $changed = @filemtime($actual_file);
+ $size = @filesize($filepath);
+ $changed = @filemtime($filepath);
// Size available, collect information
if ($size !== FALSE) {
- $files[$langcode][$extension] = array(
+ $files[$langcode][$formatname] = array(
$link_to,
(int) ($size/1024),
date("j M Y", $changed),
$extension
);
- if (!in_array($extension, array_keys($found_formats))) {
- $found_formats[$formatname] = $extension;
- }
+ $found_formats[$formatname] = 1;
}
}
}
@@ -165,7 +170,7 @@ if (count($found_formats) == 0) {
// Print out the name of the formats
foreach ($formats as $formatname => $extension) {
- if (!in_array($extension, array_values($found_formats))) { continue; }
+ if (!isset($found_formats[$formatname])) { continue; }
echo " <th valign=\"bottom\">$formatname</th>\n";
}
@@ -189,15 +194,14 @@ if (count($found_formats) == 0) {
foreach ($formats as $formatname => $extension) {
// Skip if no file found
- if (!in_array($extension, array_values($found_formats))) { continue; }
+ if (!isset($found_formats[$formatname])) { continue; }
echo "<td align=\"center\"$cellclass>";
-
- if (!isset($lang_files[$extension])) {
+ if (!isset($lang_files[$formatname])) {
echo " ";
} else {
- $fileinfo = $lang_files[$extension];
+ $fileinfo = $lang_files[$formatname];
echo "<a href=\"$fileinfo[0]\"";
// Only print out tooltip, if explicit information is not printed