pearweb_manual
[ class tree: pearweb_manual ] [ index: pearweb_manual ] [ all elements ]

Source for file apidoc-fix-latest.php

Documentation is available at apidoc-fix-latest.php

  1. #!/usr/local/bin/php
  2. <?php
  3. /*
  4.  * +----------------------------------------------------------------------+
  5.  * | PEAR Web site version 1.0                                            |
  6.  * +----------------------------------------------------------------------+
  7.  * | Copyright (c) 2009  The PEAR Group                                   |
  8.  * +----------------------------------------------------------------------+
  9.  * | This source file is subject to version 2.02 of the PHP license,      |
  10.  * | that is bundled with this package in the file LICENSE, and is        |
  11.  * | available at through the world-wide-web at                           |
  12.  * | http://www.php.net/license/2_02.txt.                                 |
  13.  * | If you did not receive a copy of the PHP license and are unable to   |
  14.  * | obtain it through the world-wide-web, please send a note to          |
  15.  * | license@php.net so we can mail you a copy immediately.               |
  16.  * +----------------------------------------------------------------------+
  17.  * | Author: Christian Weiske <cweiske@php.net>                           |
  18.  * +----------------------------------------------------------------------+
  19.  *
  20.  * $Id$
  21.  */
  22.  
  23. require_once dirname(dirname(__FILE__)) '/include/pear-config.php';
  24. require_once 'DB.php';
  25.  
  26. $options = array(
  27.     'persistent' => false,
  28.     'portability' => DB_PORTABILITY_ALL,
  29. );
  30. $dbh =DB::connect(PEAR_DATABASE_DSN$options);
  31. if (DB::isError($dbh)) {
  32.     echo $dbh->getMessage("\n";
  33.     echo $dbh->getUserInfo("\n";
  34.     exit(1);
  35. }
  36. $dbh->setFetchMode(DB_FETCHMODE_OBJECT);
  37.  
  38. $query = <<<SQL
  39. SELECT r1.releasedate AS releasedate, r1.version AS version, packages.name AS name
  40. FROM packages, releases AS r1
  41.  LEFT JOIN releases AS r2
  42.   ON r1.releasedate < r2.releasedate
  43.   AND r1.package = r2.package
  44. WHERE packages.id = r1.package
  45.  AND packages.package_type = 'pear'
  46.  AND r2.releasedate IS NULL
  47. SQL;
  48. $res $dbh->query($query);
  49.  
  50. $errors = 0;
  51. $fixed  = 0;
  52. $ok     = 0;
  53. while ($row $res->fetchRow()) {
  54.     $pkg       $row->name;
  55.     $version   $row->version;
  56.     $dir       = PEAR_APIDOC_DIR . $pkg '-' $version;
  57.     $latestdir = PEAR_APIDOC_DIR . $pkg '-latest';
  58.  
  59.     //check if apidoc of current version exists
  60.     if (file_exists($latestdir)) {
  61.         if (realpath($latestdir!= $dir{
  62.             //latest is not correctly symlinked
  63.             echo 'Unlinking incorrectly linked ' $latestdir ' -> ' realpath($latestdir"\n";
  64.             unlink($latestdir);
  65.         else {
  66.             'ok: ' $latestdir ' -> ' $dir "\n";
  67.             ++$ok;
  68.             continue;
  69.         }
  70.     }
  71.     if (!file_exists($dir)) {
  72.         echo 'No apidoc for current version: ' $dir "\n";
  73.         ++$errors;
  74.         continue;
  75.     }
  76.     echo 'Making latest: ' $dir "\n";
  77.     symlink($dir$latestdir);
  78.     ++$fixed;
  79. }
  80.  
  81. echo sprintf("%d errors, %d fixed, %d already ok\n"$errors$fixed$ok);
  82. ?>

Documentation generated on Mon, 11 Mar 2019 16:04:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.