Source for file pear-manual.php
Documentation is available at pear-manual.php
+----------------------------------------------------------------------+
| PEAR Web site version 1.0 |
+----------------------------------------------------------------------+
| Copyright (c) 2001-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Michael Gauthier <mike@silverorange.com> |
+----------------------------------------------------------------------+
$NEXT = $PREV = $UP = $HOME = array (false , false );
* Fills global variables with navigational links.
* @param array $data Array containing home, next, prev, up and toc keys.
global $NEXT, $PREV, $UP, $HOME, $TOC, $tstamp;
$title = trim($title, "\t\n :");
$wrapped = array ($title);
$maxLength = ($indent) ? 22 : 24;
if (strlen($title) > $maxLength && strpos($title, '::') !== false ) {
// break long titles on scope operator
$partCount = count($wrapped);
foreach ($wrapped as $i => $piece) {
if ($i !== ($partCount - 1 )) {
$wrapped[$i] = $wrapped[$i] . '::';
} elseif (strlen($title) > $maxLength) {
while (strlen($title) > $maxLength) {
$chunk = substr($title, 0 , $maxLength);
global $NEXT, $PREV, $UP, $HOME, $TOC, $DOCUMENT_ROOT;
echo "\n\n<!-- START MANUAL SIDEBAR -->\n";
echo "<div class=\"manual-sidebar\" id=\"manual-sidebar\">\n";
echo " <div class=\"manual-sidebar-top\">\n";
echo " <li>" . make_link ('./', $HOME[1 ]) . "</li>\n";
if (($HOME[1 ] != $UP[1 ]) && $UP[1 ]) {
echo " <div class=\"manual-sidebar-up\">\n";
echo " <li>" . make_link ($UP[0 ], $UP[1 ]) . "</li>\n";
echo " <div class=\"manual-sidebar-pages\">\n";
$toc_count = count($TOC);
for ($i = 0; $i < $toc_count; $i++ ) {
list ($url, $title) = $TOC[$i];
// trim unnecessary duplication of package name in title
$title_fmt = preg_replace('/^\s*' . $package_name . '[_\w]*::/', '', $title_fmt);
// word wrap it, get each line as an array element
// encode XML special chars for each line
foreach ($title_parts as $j => $part) {
// implode it back to a single string
$title_fmt = implode('<br />', $title_parts);
// if we're in indentation mode for methods, we have to stop the
// indentation when we find 'Class Summary'
if ($indent && substr($title_fmt, 0 , 13 ) == 'Class Summary') {
// No need to spell out the constructor, lets just keep it short
if (substr($title_fmt, 0 , 11 ) == 'constructor') {
$title_fmt = 'Constructor';
$class = ($indent) ? 'manual-sidebar-page-nested' : 'manual-sidebar-page';
echo "\n" . ' <li class="' . $class . '">'
. (($url == $id) ? " <strong>$title_fmt</strong>"
: make_link ($url, $title_fmt)) . '</li>';
// after 'Class Summary' (or 'constructor', if 'Class Summary' doesn't
// exist, we want to indent the methods
if ( substr($title_fmt, 0 , 13 ) == 'Class Summary'
|| ($title_fmt == 'Constructor' && !$indent)
echo '<ol class="manual-sidebar-pages-nested">';
// if we have a package name, add links to the package and the API docs
echo " <div class=\"manual-sidebar-info\">\n";
echo " <li>" . make_link ('/package/' . $package_name, 'Package Info') . "</li>\n";
echo " <li>" . make_link ('/package/' . $package_name . '/docs/latest/', 'API Documentation') . "</li>\n";
echo "<!-- END MANUAL SIDEBAR -->\n\n";
global $NEXT, $PREV, $tstamp, $CHARSET;
$navClass = ($NEXT[1 ] || $PREV[1 ]) ?
'manual-navigation' : 'manual-navigation manual-navigation-no-nav';
echo "<!-- START MANUAL NAVIGATION -->\n";
echo " <div class=\"{$navClass}\" id=\"manual-navigation-{$loc}\">\n";
// not using make_link because of embedded <span>
$accesskey = ($loc == 'top') ? ' accesskey="r"' : '';
echo " <a class=\"manual-previous\" href=\"{$PREV[0]}\"{$accesskey}>";
echo '<span class="title">(P<span class="accesskey">r</span>evious)</span>';
// not using make_link because of embedded <span>
$accesskey = ($loc == 'top') ? ' accesskey="x"' : '';
echo " <a class=\"manual-next\" href=\"{$NEXT[0]}\"{$accesskey}>";
echo '<span class="title">(Ne<span class="accesskey">x</span>t)</span>';
echo " <div class=\"manual-clear\"></div>\n";
// info and download links
echo " <div class=\"manual-info\">";
echo " Last updated: {$tstamp}";
echo " \xe2\x80\x94 " . make_link ('/manual/', 'Download Documentation');
echo " <div class=\"manual-bug\">\n";
echo ' Do you think that something on this page is wrong?';
echo ' Please <a href="' . getBugReportLink($package_name) . '">file a bug report</a> ';
echo ' or <a href="/notes/add-note-form.php?redirect=' . htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES , 'UTF-8') . '&uri=' . htmlspecialchars(urlencode($id)) . '">add a note</a>. ';
global $LANGUAGES, $LANG;
foreach ($LANGUAGES as $code => $name) {
'link' => make_link (" ../$code/$id" , $name)
'link' => make_link (" html/{$file}.html" , 'Plain HTML')
echo " <div class=\"manual-languages\">\n";
echo 'View this page in:';
echo " <ul class=\"manual-language-list\">\n";
foreach ($langs as $lang) {
echo " <li class=\"manual-language\">";
echo " \xe2\x80\xa2 ";
if ($lang['code'] == $LANG) {
echo '<strong>' . $lang['title'] . '</strong>';
echo " <div class=\"manual-notes\" id=\"user-notes\">\n";
echo " <h3>User Notes:</h3>\n";
echo "</div>\n<!-- END MANUAL NAVIGATION -->\n\n";
* Extracts the package name from a given manual page id.
* @param string $id Docbook chunk id (Manual page id)
* @return string Package name, null if not found
static $package_name = null; // static variable to avoid multiple queries
if (is_null ($package_name)) {
$res = preg_match ('/^package\.[\w-]+\.([\w-]+).*\.php$/', $id, $matches);
$query = 'SELECT name FROM packages WHERE LCASE(name) = LCASE(?)';
$package_name = $dbh->getOne ($query, $package);
* Returns the URI to report a bug for the package
* @param string $package_name Package name, may be NULL for
$bug_report_link = '/bugs/report.php?package=Documentation';
$bug_report_link = '/bugs/report.php?package=' . $package_name;
* Generates and returns the notes comments HTML.
* @param string $uri Manual page id
require_once 'notes/ManualNotes.class.php';
$comments = $manualNotes->getPageComments ($uri, auth_check ('pear.dev'));
$output .= 'There are no user contributed notes for this page.';
foreach ($comments as $comment) {
$manualNotes->display ($comment);
* Sends HTTP headers for the manual.
* Sets global $LANG and $CHARSET parameters to the values passed
* @param string $charset Charset (encoding) to send
* @param string $lang 2-letter language code
Header ('Cache-Control: public, max-age=600');
Header ('Content-Type: text/html;charset=' . $charset);
Header ('Content-Language: ' . $lang);
* Displays HTML headers suitable to display a manual page.
* @param string $id ID of the docbook chunk (manual page id)
* @param string $title Manual page title
* @param string $extraHeaders Additional HTML header tags
function manualHeader($id, $title = '', $extraHeaders = null )
header('Content-Type: text/html; charset=' . $CHARSET);
//create links to plain html and other languages
// start main manual content
echo "<div class=\"manual-content\" id=\"manual-content\">\n";
* Display html footer and closing html tag
* @param string $id ID of docbook chunk (manual page id)
* @param string $title Manual page title
* Creates HTML <link rel..> tags that are used by user agents
* Utilizes global $NEXT, $PREV, $UP, $HOME variables
* @return string HTML code that should be included in
global $NEXT, $PREV, $UP, $HOME;
$eh .= ' <link rel="next" href="' . $NEXT[0 ] . '" title="' . $NEXT[1 ] . '"/>' . "\n";
$eh .= ' <link rel="prev" href="' . $PREV[0 ] . '" title="' . $PREV[1 ] . '"/>' . "\n";
$eh .= ' <link rel="up" href="' . $UP[0 ] . '" title="' . $UP[1 ] . '"/>' . "\n";
$eh .= ' <link rel="home" href="' . $HOME[0 ] . '" title="' . $HOME[1 ] . '"/>' . "\n";
Documentation generated on Mon, 11 Mar 2019 16:04:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|