cvs: phpweb / docs.php download-docs.php

From: Date: Sat, 28 Dec 2002 12:02:40 +0000
Subject: cvs: phpweb / docs.php download-docs.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-14524@lists.php.net to get a copy of this message
goba Sat Dec 28 07:02:40 2002 EDT Modified files: /phpweb docs.php download-docs.php Log: Use the $LANGUAGES array in these two scripts too, so now the language listings are generic, and only one place needs modification if a new language is introduced. docs.php => detect what languages have an index.php, and only list the ones hosted on a mirror. Also integrated Special French manual to language listing. download-docs.php => detect all formats for all languages, and only list those languages, having at least one format downloadable.

Index: phpweb/docs.php diff -u phpweb/docs.php:1.117 phpweb/docs.php:1.118 --- phpweb/docs.php:1.117 Sun Sep 15 05:59:29 2002 +++ phpweb/docs.php Sat Dec 28 07:02:39 2002 @@ -1,16 +1,5 @@ <?php -$ts = getlastmod(); -$tsstring = gmdate("D, d M Y H:i:s",$ts)." GMT"; -if ($tsstring != $HTTP_IF_MODIFIED_SINCE) { - header("Last-Modified: ".$tsstring); - /* output the page here */ -} else { - header("HTTP/1.1 304 Not Modified"); - /* do nothing */ - exit(); -} - -require_once 'prepend.inc'; +include_once 'prepend.inc'; $SIDEBAR_DATA=' <h3>FAQ</h3> @@ -52,9 +41,17 @@ </p> '; +// Start page with common header commonHeader("Documentation"); -$man_languages = array('en', 'pt_BR', 'zh', 'cs', 'nl', 'fr', 'de', 'hu', 'it', 'ja', 'kr', 'pl', 'es'); +// Check for really available manual languages +$man_languages = array(); +foreach ($LANGUAGES as $code => $langname) { + if (file_exists("manual/$code/index.php")) { + $man_languages[] = $code; + } +} +$lastlang = count($man_languages) - 1; ?> @@ -77,7 +74,7 @@ <p> Note, that many languages are just under translation, and the untranslated parts are still in English. The translation -teams are open to other contributors though. +teams are open to contributions though. </p> <table border="0" cellpadding="3" cellspacing="2" width="100%"> @@ -85,21 +82,38 @@ <tr><th bgcolor="#dddddd">View Online</th><td bgcolor="#eeeeee"> <?php - $lastlang = count($man_languages) - 1; - foreach ($man_languages as $langnum => $langcode) { +// List all manual languages viewable online +foreach ($man_languages as $langnum => $langcode) { echo '<a href="/manual/' . $langcode . '/">' . $LANGUAGES[$langcode] . '</a>'; echo ($lastlang != $langnum) ? ", " : ""; - } + + // Also link to the external special French version, after the French link + if ($langcode == "fr") { + echo '<a href="http://dev.nexen.net/docs/php/annotee/">Special French</a>, '; + } +} ?> </td></tr> <tr><th bgcolor="#dddddd">Printer friendly</th><td bgcolor="#eeeeee"> <?php - foreach ($man_languages as $langnum => $langcode) { +// List printer friendly pages of all manual languages +foreach ($man_languages as $langnum => $langcode) { echo '<a href="/manual/' . $langcode . '/print/index.php">' . $LANGUAGES[$langcode] . '</a>'; echo ($lastlang != $langnum) ? ", " : ""; - } +} + +?> +</td></tr> +<tr><th bgcolor="#dddddd">Printer friendly<br />with notes</th><td bgcolor="#eeeeee"> +<?php + +// List printer friendly pages with notes of all manual languages +foreach ($man_languages as $langnum => $langcode) { + echo '<a href="/manual/' . $langcode . '/printwn/index.php">' . $LANGUAGES[$langcode] . '</a>'; + echo ($lastlang != $langnum) ? ", " : ""; +} ?> </td></tr> @@ -113,25 +127,6 @@ can be found on separate servers. </td></tr> </table> - -<?php echo hdelim(); ?> - -<h1>French PHP Manual</h1> - -<p> -The French PHP manual is also available on an external site, in differents formats. -Documentation is the official flavor, while formating and localization has -been worked some more (function and examples indexes, short version, search engine..). -Besides, those are compressed for faster download. -<a href="http://dev.nexen.net/docs/php/annotee/">Follow this link for -the annotated French manual</a> -</p> - -<p> -La documentation Fran&ccedil;aise est disponible sur un site secondaire, -dans diff&eacute;rents formats. C'est la version officielle, compl&egrave;tement -francis&eacute;e et retravaill&eacute;e. De plus, ces docs sont compress&eacute;es. -</p> <?php echo hdelim(); ?> Index: phpweb/download-docs.php diff -u phpweb/download-docs.php:1.37 phpweb/download-docs.php:1.38 --- phpweb/download-docs.php:1.37 Sun Nov 10 07:11:06 2002 +++ phpweb/download-docs.php Sat Dec 28 07:02:39 2002 @@ -1,5 +1,5 @@ <?php -require_once 'prepend.inc'; +include_once 'prepend.inc'; $SIDEBAR_DATA=' <h3>Documentation online</h3> @@ -7,7 +7,7 @@ You can read the <a href="/docs.php">documentation online</a> in various languages, even in printer -friendly HTML format. +friendly formats. </p> <h3>Tips for Windows users</h3> @@ -26,8 +26,8 @@ <h3>File sizes and dates</h3> <p> If you are using a capable browser, the file size and -date will show up when you move the mouse above the link. -If you use another browser, or would like to see all the +date will show up when you move the mouse above a link. +If you use cannot view this information, or would like to see all the information, you can <a href="/download-docs.php?sizes=1">click here to see all the file sizes and dates</a>. </p> @@ -35,9 +35,7 @@ commonHeader("Download documentation"); -$man_languages = array('en', 'pt_BR', 'zh_cn', 'cs', 'nl', 'fr', 'de', 'hu', 'it', 'ja', 'ko', 'pl', 'es'); - -# array structure: (header, link_text, show_size_for_package) +// array structure: (filename => header, extension) $formats = array( "bigmanual.html.bz2" => array("Single HTML", "html.bz2"), "manual.tar.bz2" => array("Many HTML files", "tar.bz2"), @@ -51,78 +49,127 @@ <h1>Download documentation</h1> <p> -The PHP manual is available in a selection of languages -and formats. Pick a language and format from the table below -to start downloading. + The PHP manual is available in a selection of languages + and formats. Pick a language and format from the table below + to start downloading. </p> <p> -Note that the packaged HTML version of the manual -(tar.bz2) doesn't contain any directories, -so all of the files will be dumped into your current working -directory when you expand the archive unless the tool you -use does otherwise. + Note that the packaged HTML version of the manual + (tar.bz2) doesn't contain any directories, + so all of the files will be dumped into your current working + directory when you expand the archive unless the tool you + use does otherwise. </p> <p> -<em> -Please note that due to some technical problems, we do not -distribute PDF versions of the manual right now. -</em> + <em> + Please note that due to some technical problems, we do not + distribute PDF versions of the manual right now. + </em> </p> <table border="0" cellpadding="2" cellspacing="1" width="100%"> <tr bgcolor="#cccccc"> <td>&nbsp;</td> - <?php - while (list($k,$v) = each($formats)) { - echo "<th valign=\"bottom\">$v[0]</th>\n"; - }?> +<?php +// Print out the name of the formats +foreach ($formats as $fname => $details) { + echo " <th valign=\"bottom\">$details[0]</th>\n"; +} +?> </tr> - <?php - while (list(,$langcode) = each($man_languages)) { - $language = $LANGUAGES[$langcode]; - echo "<tr>\n<td bgcolor=\"#dddddd\"><b>$language</b></td>\n"; - reset($formats); - while (list($fn,$details) = each($formats)) { - echo "<td align=\"center\" bgcolor=\"#eeeeee\">"; - - $link_to = ""; - if (file_exists("manual/$langcode/$fn")) { - $link_to = "manual/$langcode/$fn"; - } - elseif (file_exists("distributions/manual/php_manual_$langcode.$details[1]")) { - $link_to = "distributions/manual/php_manual_$langcode.$details[1]"; - } - elseif (file_exists("distributions/manual/manual-$langcode.$details[1]")) { - $link_to = "distributions/manual/manual-$langcode.$details[1]"; - } - - if (!$link_to) { - echo "&nbsp;"; - } - else { - $size = @filesize($link_to); - $changed = @filemtime($link_to); - $date_format = "j M Y"; // Part of the RFC date type (to be short) - if ($size) { - echo "<a href=\"$link_to\" title=\" Size: ", (int) ($size/1024), "Kb\n Date: ", date($date_format, $changed), "\">$details[1]</a>"; - if ($sizes) { - echo "<br><small>Size: ", (int) ($size/1024), "Kb<br>Date: ", date($date_format, $changed), "</small>"; - } - } else { - echo "&nbsp;"; - } - } +<?php + +// Go through all possible manual languages +foreach ($LANGUAGES as $langcode => $language) { + + // Reset files array and format counter + $files = array(); $formatnum = 0; + + // Go through all possible manual formats + foreach ($formats as $fname => $details) { + + // Reset link target + $link_to = ""; + + // File named after the format exists [old!] + if (file_exists("manual/$langcode/$fn")) { + $link_to = "manual/$langcode/$fn"; + } + + // File named after the language and format exists + elseif (file_exists("distributions/manual/php_manual_$langcode.$details[1]")) { + $link_to = "distributions/manual/php_manual_$langcode.$details[1]"; + } + + // File named after the language and format exists [old!] + elseif (file_exists("distributions/manual/manual-$langcode.$details[1]")) { + $link_to = "distributions/manual/manual-$langcode.$details[1]"; + } + + // Unable to find file + if (!$link_to) { + $files[] = ''; + } + + // File found + else { + + // Try to get size and changed date + $size = @filesize($link_to); + $changed = @filemtime($link_to); + + // Size available, collect information + if ($size) { + $files[] = array($link_to, (int) ($size/1024), date("j M Y", $changed), $details[1]); + $formatnum++; + } + + // Size is not available, we won't list the file + else { + $files[] = ''; + } + } + } + + // At least one format is found for this + // language => write out table row + if ($formatnum > 0) { + + echo "<tr>\n<td bgcolor=\"#dddddd\"><b>$language</b></td>\n"; + + // Print out a table cell for all formats + foreach ($files as $fileinfo) { + + echo "<td align=\"center\" bgcolor=\"#eeeeee\">"; + + // Missing format + if ($fileinfo == '') { + echo "&nbsp;"; + } + + // Format found, write out link + else { + echo "<a href=\"$fileinfo[0]\" title=\" Size: $fileinfo[1]Kb\n Date: $fileinfo[2]\">$fileinfo[3]</a>"; + + // Sizes required to be printed out (URL parameter) + if ($sizes) { + echo "<br><small>Size: $fileinfo[1]Kb<br>Date: $fileinfo[2]</small>"; + } + } + + // Quite bad looking code tweak to add a link to the extended CHM (en only!) + if ($langcode == "en" && preg_match("!.chm$!", $fileinfo[0])) { + echo ', <a href="http://weblabor.hu/php-doc-chm">extended chm</a>'; + } - // Quite bad looking code tweak to add a link to the extended CHM (en only!) - if ($langcode == "en" && $fn == "manual-LANG.chm") { - echo ', <a href="http://weblabor.hu/php-doc-chm">extended chm</a>'; - } - - echo "</td>\n"; - } - }?> + // End table cell + echo "</td>\n"; + } + } +} +?> </table> <?php echo hdelim(); ?>
« previous php.mirrors (#14524) next »