Source for file find-documentation.php
Documentation is available at find-documentation.php
* Trying to find documentation URLs for PEAR packages in the peardoc Docbook sources.
* Updates the package doc links in database if they are empty.
* --debug Display debugging data
* @author Martin Jansen <mj@php.net>
require_once dirname (dirname (__FILE__ )) . '/include/pear-config.php';
require_once 'VFS/file.php';
require_once 'HTTP/Request2.php';
echo "Please cd into peardoc checkout\n";
$basepath = getcwd() . '/en/package/';
$vfs = new VFS_file (array ('vfsroot' => $basepath));
'portability' => DB_PORTABILITY_ALL ,
$dbh = & DB ::connect (PEAR_DATABASE_DSN , $options);
print $dbh->getMessage () . "\n" . $dbh->getUserInfo () . "\n";
$host = 'http://' . PEAR_CHANNELNAME;
(doc_link IS NULL OR doc_link NOT LIKE 'http://%' OR doc_link LIKE '" . $host . "/%')";
$update = $dbh->prepare ($sql);
//our xml file contains entities that include other files
// we need to remove them since loading them would take really really long
$document->registerXPathNamespace ('db', 'http://docbook.org/ns/docbook');
$titles = $document->xpath ("//db:title");
$books = $document->xpath ("//db:book");
throw new Exception ("No //title element");
throw new Exception ("No //book element");
$attributes = $books[0 ]->attributes ('http://www.w3.org/XML/1998/namespace');
if (empty ($attributes['id'])) {
throw new Exception ('Missing package xml:id attribute');
return array ((string) $titles[0 ], $attributes['id']);
$GLOBALS['debug'] && print ($msg . "\n");
global $vfs, $basepath, $dbh, $update, $host;
if (substr($folder, -5 ) == '/.svn') {
$result = $vfs->listFolder ($folder);
foreach ($result as $file) {
if (is_dir($basepath . $folder . '/' . $file['name'])) {
$newfolder = $file['name'];
$newfolder = $folder . '/' . $file['name'];
if ($level == 2 && preg_match("/\.xml$/", $file['name'])) {
$path = $basepath . $folder . '/' . $file['name'];
$url = '/manual/en/' . $package . '.php';
$request = new HTTP_Request2 ($host . $url);
$response = $request->send ();
if ($response->getStatus () >= 400 ) {
$new_url = preg_replace("=\.([^\.]+)\.php$=", ".php", $url);
$request->setURL ($host . $new_url);
$response = $request->send ();
$url = $response->getStatus () > 400 ? '' : $new_url;
checkDocLog('Found doc url: ' . $url . ', title: ' . $title);
$res = $dbh->execute ($update, array ($url, $title));
print $e->getMessage () . "\n";
//checkDocumentation(dirname(__FILE__) . '/sample.xml');
Documentation generated on Mon, 11 Mar 2019 16:04:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|