xref: /web-php/download-docs.php (revision c093fb53)
1<?php
2$_SERVER['BASE_PAGE'] = 'download-docs.php';
3include_once __DIR__ . '/include/prepend.inc';
4
5if (!empty($_GET['active_langs'])) {
6    echo serialize($ACTIVE_ONLINE_LANGUAGES);
7    exit;
8}
9
10$SIDEBAR_DATA = '
11<div class="panel">
12    <div class="headline">Online documentation</div>
13    <div class="body">
14        <p>
15            You can read the
16            <a href="/docs.php">documentation online</a>
17            in various languages. The Documentation HOWTO,
18            and archive manuals are also available
19            from our <a href="/docs.php">documentation page</a>.
20        </p>
21    </div>
22</div>
23
24<div class="panel">
25    <div class="headline">Other formats</div>
26    <div class="body">
27        <p>
28            The manual is also available via *nix style man pages. To
29            install and use:
30        </p>
31        <ul class="toc">
32            <li>Install: <code>pear install doc.php.net/pman</code></li>
33            <li>Upgrade: <code>pear upgrade doc.php.net/pman</code></li>
34            <li>Example usage: <code>pman strlen</code></li>
35        </ul>
36    </div>
37</div>
38';
39
40site_header("Download documentation", ["current" => "docs"]);
41
42// Format to look for
43$formats = [
44    "Single HTML file" => "html.gz",
45    "Many HTML files" => "tar.gz",
46    "HTML Help file" => "chm",
47    "HTML Help file (with user notes)" => "chm",
48];
49?>
50
51<h1>Download documentation</h1>
52
53<p>
54 The PHP manual is available in a selection of languages and
55 formats. Pick a language and format from the table below to start
56 downloading.
57</p>
58
59<h2>Notes to read before you download</h2>
60
61<ul>
62 <li>
63  The English version should be considered the most accurate, since
64  translations are based on that version. Most of the translations
65  are not complete, and contain English parts.
66 </li>
67 <li>
68  If you are looking for PHP 5 documentation, please read
69  <a href="/manual/php5.php">this explanation</a>.
70 </li>
71 <li>
72  If you are looking for PHP 4 documentation, please read
73  <a href="/manual/php4.php">this explanation</a>.
74 </li>
75</ul>
76
77<p class="warn">
78  If you are using Windows XP SP2 or later and you are going to download the
79  documentation in CHM format, you <strong>need</strong> to &quot;unblock&quot;
80  the file after downloading it by right-clicking on it in Windows Explorer and
81  selecting the &quot;Properties&quot; menu item, then clicking on the
82  &quot;Unblock&quot; button (on Windows Vista this is within the
83  &quot;Security&quot; options).  Failure to unblock the documentation file may
84  result in error messages including &quot;Navigation to the webpage was
85  canceled&quot; due to Windows security restrictions.
86</p>
87
88<?php
89$files = []; $found_formats = [];
90$filepath = $filename = '';
91
92// Go through all possible manual languages
93foreach ($LANGUAGES as $langcode => $language) {
94    if (isset($INACTIVE_ONLINE_LANGUAGES[$langcode]) && $MYSITE !== 'http://docs.php.net/') {
95       continue;
96    }
97
98    // Go through all possible manual formats
99    foreach ($formats as $formatname => $extension) {
100
101        $filepath = $_SERVER['DOCUMENT_ROOT'] . '/distributions/manual/';
102        if ($formatname === 'HTML Help file (with user notes)') {
103            $filename = "php_enhanced_$langcode.$extension";
104        } else {
105            $filename = "php_manual_$langcode.$extension";
106        }
107
108        $filepath .= $filename;
109
110        // File named after the language and format exists
111        if (file_exists($filepath)) {
112
113            // Mirror selection download URL
114            $link_to = "/distributions/manual/$filename";
115
116            // Try to get size and changed date
117            $size = @filesize($filepath);
118            $changed = @filemtime($filepath);
119
120            // Size available, collect information
121            if ($size !== false) {
122                $files[$langcode][$formatname] = [
123                    $link_to,
124                    (int) ($size / 1024),
125                    date("j M Y", $changed),
126                    $extension,
127                ];
128                $found_formats[$formatname] = 1;
129            }
130        }
131    }
132}
133/* {{{ FIXME: Special handling for the extended html help format since it doesn't follow the "naming rules"
134 * (mostly copy&paste from the loop above)
135 * Feb 20, 2009: Commenting this out as we currently don't build or work on it
136
137$formats['<a href="/docs-echm.php">Extended HTML Help</a>'] = "zip"; // Add a link to the xchm docs in the table header
138$actual_file = $_SERVER['DOCUMENT_ROOT'] . "/distributions/manual/php_manual_chm.zip";
139if (file_exists($actual_file)) {
140    $link_to = "/get/php_manual_chm.zip/from/a/mirror";
141    $size    = @filesize($actual_file);
142    $changed = @filemtime($actual_file);
143    if ($size !== FALSE) {
144        $files["en"]["zip"] = array(
145            $link_to,
146            (int) ($size/1024),
147            date("j M Y", $changed),
148            "zip"
149        );
150        $found_formats["xchm"] = "zip";
151    }
152}
153}}} */
154
155if (count($found_formats) == 0) {
156    echo "<p class=\"tip\">This site has no documentation files for download.</p>";
157} else {
158
159    echo '<table border="0" cellpadding="4" cellspacing="2" class="standard">' . "\n" .
160         "<tr>\n  <th>&nbsp;</th>\n";
161
162    // Print out the name of the formats
163    foreach ($formats as $formatname => $extension) {
164        if (!isset($found_formats[$formatname])) { continue; }
165        echo "  <th valign=\"bottom\">$formatname</th>\n";
166    }
167
168    echo " </tr>\n";
169
170    foreach ($files as $langcode => $lang_files) {
171
172        // See if current language is the preferred one
173        if ($langcode == $LANG) { $preflang = true; }
174        else { $preflang = false; }
175
176        // Highlight manual in preferred language
177        if ($preflang) {
178            $cellclass = ' class="highlight"';
179        } else {
180            $cellclass = "";
181        }
182
183        echo "<tr>\n<th class=\"subl\">" . $LANGUAGES[$langcode] . "</th>\n";
184
185        foreach ($formats as $formatname => $extension) {
186
187            // Skip if no file found
188            if (!isset($found_formats[$formatname])) { continue; }
189
190            echo "<td align=\"center\"$cellclass>";
191            if (!isset($lang_files[$formatname])) {
192                echo "&nbsp;";
193            } else {
194
195                $fileinfo = $lang_files[$formatname];
196                echo "<a href=\"$fileinfo[0]\"";
197
198                // Only print out tooltip, if explicit information is not printed
199                if (!isset($_GET['sizes']) && !$preflang) {
200                    echo " title=\" Size: $fileinfo[1]Kb -- Date: $fileinfo[2]\"";
201                }
202
203                // End link tag
204                echo ">$fileinfo[3]</a>";
205
206                // Sizes required to be printed out (URL parameter or preferred language)
207                if (isset($_GET['sizes']) || $preflang) {
208                    echo "<br><small>Size: $fileinfo[1]Kb<br>Date: $fileinfo[2]</small>";
209                }
210            }
211
212            // End table cell
213            echo "</td>\n";
214
215        }
216
217        // End table row
218        echo "</tr>\n";
219    }
220    echo "</table>\n";
221}
222?>
223
224<?php site_footer(['sidebar' => $SIDEBAR_DATA]);
225