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

Source for file Info.php

Documentation is available at Info.php

  1. <?php
  2. /**
  3.  * This package generate phpinfo() style PEAR information.
  4.  *
  5.  * PHP versions 4 and 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.01 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category PEAR
  14.  * @package  PEAR_Info
  15.  * @author   Davey Shafik <davey@pixelated-dreams.com>
  16.  * @author   Laurent Laville <pear@laurent-laville.org>
  17.  * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
  18.  * @version  CVS: $Id: Info.php,v 1.54 2007/12/30 17:08:19 farell Exp $
  19.  * @link     http://pear.php.net/package/PEAR_Info
  20.  * @since    File available since Release 1.0.1
  21.  */
  22.  
  23. require_once 'PEAR/Config.php';
  24.  
  25. /**
  26.  * PEAR_INFO_* is a bit-field. Or each number up to get desired information.
  27.  *
  28.  * Examples:
  29.  * <code>
  30.  * <?php
  31.  * require_once 'PEAR/Info.php';
  32.  * // will display for each channel (list displayed),
  33.  * // a quick package list with only its name and version
  34.  * $options = array('resume' => PEAR_INFO_CHANNELS | PEAR_INFO_PACKAGES_VERSION);
  35.  * $info = new PEAR_Info('', 'c:\wamp\php\pear.ini', '', $options);
  36.  * $info->display();
  37.  * ?>
  38.  * </code>
  39.  *
  40.  * - Show all informations, except for credits
  41.  *
  42.  *   $options = array('resume' => PEAR_INFO_ALL & ~PEAR_INFO_CREDITS);
  43.  *
  44.  * - Show only credits and configuration
  45.  *
  46.  *   $options = array('resume' => PEAR_INFO_CONFIGURATION | PEAR_INFO_CREDITS);
  47.  */
  48. /**
  49.  * The configuration line, pear.ini | .pearrc location, and more.
  50.  *
  51.  * @var        integer 
  52.  * @since      1.7.0RC1
  53.  */
  54. define('PEAR_INFO_GENERAL'1);
  55. /**
  56.  * PEAR Credits
  57.  *
  58.  * @var        integer 
  59.  * @since      1.7.0RC1
  60.  */
  61. define('PEAR_INFO_CREDITS'2);
  62. /**
  63.  * All PEAR settings.
  64.  *
  65.  * @var        integer 
  66.  * @since      1.7.0RC1
  67.  */
  68. define('PEAR_INFO_CONFIGURATION'4);
  69. /**
  70.  * Information on PEAR channels.
  71.  *
  72.  * @var        integer 
  73.  * @since      1.7.0RC1
  74.  */
  75. define('PEAR_INFO_CHANNELS'8);
  76. /**#@+
  77.  * Information on PEAR packages.
  78.  *
  79.  * @var        integer
  80.  * @since      1.7.0RC1
  81.  */
  82. define('PEAR_INFO_PACKAGES'4080);
  83. define('PEAR_INFO_PACKAGES_CHANNEL'2048);
  84. define('PEAR_INFO_PACKAGES_SUMMARY'1024);
  85. define('PEAR_INFO_PACKAGES_VERSION'512);
  86. define('PEAR_INFO_PACKAGES_LICENSE'256);
  87. define('PEAR_INFO_PACKAGES_DESCRIPTION'128);
  88. define('PEAR_INFO_PACKAGES_DEPENDENCIES'64);
  89. define('PEAR_INFO_PACKAGES_XML'32);
  90. define('PEAR_INFO_PACKAGES_UPDATE'16);
  91. /**#@-*/
  92. /**
  93.  * Shows all of the above. This is the default value.
  94.  *
  95.  * @var        integer 
  96.  * @since      1.7.0RC1
  97.  */
  98. define('PEAR_INFO_ALL'4095);
  99. /**#@+
  100.  * Information on PEAR credits.
  101.  *
  102.  * @var        integer
  103.  * @since      1.7.0RC3
  104.  */
  105. define('PEAR_INFO_CREDITS_GROUP'4096);
  106. define('PEAR_INFO_CREDITS_DOCS'8192);
  107. define('PEAR_INFO_CREDITS_WEBSITE'16384);
  108. define('PEAR_INFO_CREDITS_PACKAGES'32768);
  109. define('PEAR_INFO_CREDITS_ALL'61440);
  110. /**#@-*/
  111. /**
  112.  * Indicates that a complete stand-alone HTML page needs to be printed
  113.  * including the information indicated by the other flags.
  114.  *
  115.  * @var        integer 
  116.  * @since      1.7.0RC3
  117.  */
  118. define('PEAR_INFO_FULLPAGE'65536);
  119.  
  120. /**
  121.  * The PEAR_Info class generate phpinfo() style PEAR information.
  122.  *
  123.  * @category PEAR
  124.  * @package  PEAR_Info
  125.  * @author   Davey Shafik <davey@pixelated-dreams.com>
  126.  * @author   Laurent Laville <pear@laurent-laville.org>
  127.  * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
  128.  * @version  Release: @package_version@
  129.  * @link     http://pear.php.net/package/PEAR_Info
  130.  * @since    Class available since Release 1.0.1
  131.  */
  132.  
  133. class PEAR_Info
  134. {
  135.     /**
  136.      * Html code for phpinfo() style PEAR information
  137.      *
  138.      * @var    string 
  139.      * @access public
  140.      * @since  1.0.1
  141.      */
  142.     var $info;
  143.  
  144.     /**
  145.      * Style sheet for the custom layout
  146.      *
  147.      * @var    string 
  148.      * @access public
  149.      * @since  1.7.0RC1
  150.      */
  151.     var $css;
  152.  
  153.     /**
  154.      * instance of PEAR_config
  155.      *
  156.      * @var    object 
  157.      * @access public
  158.      * @since  1.0.1
  159.      */
  160.     var $config;
  161.  
  162.     /**
  163.      * instance of PEAR_Registry
  164.      *
  165.      * @var    object 
  166.      * @access public
  167.      * @since  1.0.1
  168.      */
  169.     var $reg;
  170.  
  171.     /**
  172.      * PHP 4 style constructor (ZE1)
  173.      *
  174.      * @param string $pear_dir    (optional) The PEAR base install directory
  175.      * @param string $user_file   (optional) file to read PEAR user-defined
  176.      *                             options from
  177.      * @param string $system_file (optional) file to read PEAR system-wide
  178.      *                             defaults from
  179.      * @param array  $options     (optional) configure PEAR information output
  180.      *
  181.      * @return void 
  182.      * @access public
  183.      * @since  version 1.0.1 (2003-04-24)
  184.      */
  185.     function PEAR_Info($pear_dir ''$user_file ''$system_file '',
  186.         $options = null)
  187.     {
  188.         $this->__construct($pear_dir$user_file$system_file$options);
  189.     }
  190.  
  191.     /**
  192.      * PHP 5 style constructor (ZE2)
  193.      *
  194.      * @param string $pear_dir    (optional) The PEAR base install directory
  195.      * @param string $user_file   (optional) file to read PEAR user-defined
  196.      *                             options from
  197.      * @param string $system_file (optional) file to read PEAR system-wide
  198.      *                             defaults from
  199.      * @param array  $options     (optional) configure PEAR information output
  200.      *
  201.      * @return void 
  202.      * @access private
  203.      * @since  version 1.7.0RC1 (2007-07-01)
  204.      */
  205.     function __construct($pear_dir ''$user_file ''$system_file '',
  206.         $options = null)
  207.     {
  208.         // options defined at run-time (default)
  209.         $this->options = array('channels' => array('pear.php.net'),
  210.             'resume' => PEAR_INFO_ALL | PEAR_INFO_FULLPAGE);
  211.         if (isset($options)) {
  212.             // overwrite one to all defaults
  213.             $this->options array_merge($this->options$options);
  214.         }
  215.  
  216.         // to keep compatibility with version less or equal than 1.6.1
  217.         if (!empty($pear_dir&& empty($user_file&& empty($system_file)) {
  218.             // try to find a PEAR user-defined config file into $pear_dir
  219.             $user_file $pear_dir . DIRECTORY_SEPARATOR;
  220.             if (OS_WINDOWS{
  221.                 $user_file .= 'pear.ini';
  222.             else {
  223.                 $user_file .= '.pearrc';
  224.             }
  225.             if (!file_exists($user_file)) {
  226.                 // try to find a PEAR system-wide config file into $pear_dir
  227.                 $system_file $pear_dir . DIRECTORY_SEPARATOR;
  228.                 if (OS_WINDOWS{
  229.                     $system_file .= 'pearsys.ini';
  230.                 else {
  231.                     $system_file .= 'pear.conf';
  232.                 }
  233.  
  234.                 if (!file_exists($system_file)) {
  235.                     $e '<p class="error">No PEAR configuration files ('
  236.                         . basename($user_file' or ' basename($system_file)
  237.                         . ") found into '$pear_dir' directory</p>";
  238.  
  239.                     $this->info = $e;
  240.                     return;
  241.                 }
  242.                 $user_file '';
  243.             }
  244.         }
  245.  
  246.         $this->config =PEAR_Config::singleton($user_file$system_file);
  247.  
  248.         // to keep compatibility with version less or equal than 1.6.1
  249.         if (defined('PEAR_INFO_PROXY')) {
  250.             $this->config->set('http_proxy'PEAR_INFO_PROXY);
  251.         }
  252.  
  253.         if (empty($user_file|| !file_exists($user_file)) {
  254.             if (empty($system_file|| !file_exists($system_file)) {
  255.                 $user_file $this->config->getConfFile('user');
  256.                 if (file_exists($user_file)) {
  257.                     $layer 'user';
  258.                 else {
  259.                     $system_file $this->config->getConfFile('system');
  260.                     $layer       'system';
  261.                 }
  262.             else {
  263.                 $layer 'system';
  264.             }
  265.         else {
  266.             $layer 'user';
  267.         }
  268.         // prevent unexpected result if PEAR config file does not exist
  269.         if (!file_exists($user_file&& !file_exists($system_file)) {
  270.             $e '<p class="error">PEAR configuration files "'
  271.                 . $user_file '", "' $system_file '" does not exist</p>';
  272.  
  273.             $this->info = $e;
  274.             return;
  275.         }
  276.         // Get the config's registry object.
  277.         $this->reg = &$this->config->getRegistry();
  278.  
  279.         // Get list of all channels in your PEAR install,
  280.         // when 'channels' option is empty
  281.         if (isset($this->options['channels'])
  282.             && empty($this->options['channels'])) {
  283.             $channels $this->reg->listChannels();
  284.             if (PEAR::isError($channels)) {
  285.                 $this->options['channels'= array('pear.php.net');
  286.             else {
  287.                 $this->options['channels'$channels;
  288.             }
  289.         }
  290.  
  291.         // show general informations such as PEAR version, PEAR logo,
  292.         // and config file used
  293.         if ($this->options['resume'PEAR_INFO_GENERAL{
  294.             $pear         $this->reg->getPackage("PEAR");
  295.             $pear_version $pear->getVersion();
  296.             $this->info   = '
  297. <table>
  298. <tr class="h">
  299.     <td>
  300.         <a href="http://pear.php.net/">
  301.             <img src="{phpself}?pear_image=true" alt="PEAR Logo" />
  302.         </a>
  303.         <h1 class="p">PEAR {pearversion}</h1>
  304.     </td>
  305. </tr>
  306. </table>
  307. ';
  308.             $this->info   = str_replace(array('{phpself}''{pearversion}'),
  309.                 array(htmlentities($_SERVER['PHP_SELF'])$pear_version),
  310.                 $this->info);
  311.  
  312.             // Loaded configuration file
  313.             $this->info .= '
  314. <table>
  315. <tr class="v">
  316.     <td class="e">Loaded Configuration File</td>
  317.     <td>{value}</td>
  318. </tr>
  319. </table>
  320.  
  321. ';
  322.             $this->info  = str_replace('{value}',
  323.                 $this->config->getConfFile($layer),
  324.                 $this->info);
  325.         }
  326.  
  327.         if (($this->options['resume'PEAR_INFO_CREDITS_ALL||
  328.             isset($_GET['credits'])) {
  329.             $this->info .= $this->getCredits();
  330.         else {
  331.             if ($this->options['resume'PEAR_INFO_CREDITS{
  332.                 $this->info .= '
  333. <h1><a href="{phpself}?credits=true">PEAR Credits</a></h1>
  334. ';
  335.                 $this->info  = str_replace('{phpself}',
  336.                     htmlentities($_SERVER['PHP_SELF']),
  337.                     $this->info);
  338.             }
  339.             if ($this->options['resume'PEAR_INFO_CONFIGURATION{
  340.                 $this->info .= $this->getConfig();
  341.             }
  342.             if ($this->options['resume'PEAR_INFO_CHANNELS{
  343.                 $this->info .= $this->getChannels();
  344.             }
  345.             if ($this->options['resume'PEAR_INFO_PACKAGES{
  346.                 $this->info .= $this->getPackages();
  347.             }
  348.         }
  349.     }
  350.  
  351.     /**
  352.      * Sets PEAR HTTP Proxy Server Address
  353.      *
  354.      * Sets http_proxy config setting at runtime
  355.      *
  356.      * @param string $proxy PEAR HTTP Proxy Server Address
  357.      *
  358.      * @static
  359.      * @return bool 
  360.      * @access public
  361.      * @since  version 1.0.6 (2003-05-11)
  362.      */
  363.     function setProxy($proxy)
  364.     {
  365.         $res define('PEAR_INFO_PROXY'$proxy);
  366.         return $res;
  367.     }
  368.  
  369.     /**
  370.      * Returns the custom style sheet to use for presentation
  371.      *
  372.      * Default behavior is to return css string contents.
  373.      * Sets $content parameter to false will return css filename reference
  374.      * (defined by setStyleSheet function).
  375.      * Easy for a <link rel="stylesheet" type="text/css" href="" />
  376.      * html tag integration (see example pear_info3.php).
  377.      *
  378.      * @param bool $content (optional) Either return css filename or string contents
  379.      *
  380.      * @return string 
  381.      * @access public
  382.      * @since  version 1.7.0RC1 (2007-07-01)
  383.      */
  384.     function getStyleSheet($content = true)
  385.     {
  386.         if ($content{
  387.             $styles file_get_contents($this->css);
  388.         else {
  389.             $styles $this->css;
  390.         }
  391.         return $styles;
  392.     }
  393.  
  394.     /**
  395.      * Sets the custom style sheet to use your own styles
  396.      *
  397.      * Sets the custom style sheet (colors, sizes) to applied to PEAR_Info output.
  398.      * If you don't give any parameter, you'll then apply again the default style.
  399.      *
  400.      * @param string $css (optional) File to read user-defined styles from
  401.      *
  402.      * @return bool    True if custom styles, false if default styles applied
  403.      * @access public
  404.      * @since  version 1.7.0RC1 (2007-07-01)
  405.      */
  406.     function setStyleSheet($css = null)
  407.     {
  408.         // default stylesheet is into package data directory
  409.         if (!isset($css)) {
  410.             $this->css = '@data_dir@' . DIRECTORY_SEPARATOR
  411.                  . '@package_name@' . DIRECTORY_SEPARATOR
  412.                  . 'pearinfo.css';
  413.         }
  414.  
  415.         $res = isset($css&& file_exists($css);
  416.         if ($res{
  417.             $this->css = $css;
  418.         }
  419.         return $res;
  420.     }
  421.  
  422.     /**
  423.      * Retrieve and format PEAR Packages info
  424.      *
  425.      * @return string 
  426.      * @access private
  427.      * @since  version 1.0.1 (2003-04-24)
  428.      */
  429.     function getPackages()
  430.     {
  431.         $available $this->reg->listAllPackages();
  432.         if (PEAR::isError($available)) {
  433.             $e '<p class="error">An Error occured while fetching the package list.'
  434.                . ' Please try again.</p>';
  435.             return $e;
  436.         }
  437.         if (!is_array($available)) {
  438.             $e '<p class="error">The package list could not be fetched'
  439.                . ' from the remote server. Please try again.</p>';
  440.             return $e;
  441.         }
  442.  
  443.         // list of channels to scan
  444.         $channel_allowed $this->options['channels'];
  445.  
  446.         // check if there are new versions available for packages installed
  447.         if ($this->options['resume'PEAR_INFO_PACKAGES_UPDATE{
  448.  
  449.             $latest = array();
  450.             foreach ($channel_allowed as $channel{
  451.                 // Get a channel object.
  452.                 $chan =$this->reg->getChannel($channel);
  453.                 if (PEAR::isError($chan)) {
  454.                     $e '<p class="error">An error has occured. '
  455.                        . $chan->getMessage()
  456.                        . ' Please try again.</p>';
  457.                     return $e;
  458.                 }
  459.  
  460.                 if ($chan->supportsREST($channel&&
  461.                     $base $chan->getBaseURL('REST1.0'$channel)) {
  462.  
  463.                     $rest =$this->config->getREST('1.0'array());
  464.                     if (is_object($rest)) {
  465.                         $pref_state $this->config->get('preferred_state');
  466.                         $installed  array_flip($available[$channel]);
  467.  
  468.                         $l $rest->listLatestUpgrades($base$pref_state,
  469.                                  $installed$channel$this->reg);
  470.                     else {
  471.                         $l = false;
  472.                     }
  473.                 else {
  474.                     $r =$this->config->getRemote();
  475.                     $l @$r->call('package.listLatestReleases');
  476.                 }
  477.                 if (is_array($l)) {
  478.                     $latest array_merge($latest$l);
  479.                 }
  480.             }
  481.         else {
  482.             $latest = false;
  483.         }
  484.  
  485.         if ((PEAR::isError($latest)) || (!is_array($latest))) {
  486.             $latest = false;
  487.         }
  488.  
  489.         $s             '';
  490.         $anchor_suffix = 0;  // make page XHTML compliant
  491.         foreach ($available as $channel => $pkg{
  492.             if (!in_array($channel$channel_allowed)) {
  493.                 continue;
  494.             }
  495.             // sort package by alphabetic order
  496.             sort($pkg);
  497.             //
  498.             $packages '';
  499.             $index    = array();
  500.             foreach ($pkg as $name{
  501.                 // show general package informations
  502.                 $info &$this->reg->getPackage($name$channel);
  503.                 if (!is_object($info)) {
  504.                     continue; // should never arrive, if package is really installed
  505.                 }
  506.                 $__info               $info->getArray();
  507.                 $installed['package'$info->getPackage();
  508.                 if ($this->options['resume'PEAR_INFO_PACKAGES_CHANNEL{
  509.                     $installed['channel'$channel;
  510.                 }
  511.                 if ($this->options['resume'PEAR_INFO_PACKAGES_SUMMARY{
  512.                     $installed['summary'$info->getSummary();
  513.                 }
  514.                 $installed['version'$info->getVersion();
  515.                 if ($this->options['resume'PEAR_INFO_PACKAGES_VERSION{
  516.                     $installed['current_release'$installed['version']
  517.                         . ' (' $info->getState(') was released on '
  518.                         . $info->getDate();
  519.                 }
  520.                 if ($this->options['resume'PEAR_INFO_PACKAGES_LICENSE{
  521.                     $installed['license'$info->getLicense();
  522.                 }
  523.                 if ($info->getPackagexmlVersion(== '1.0' {
  524.                     if ($this->options['resume'PEAR_INFO_PACKAGES_UPDATE{
  525.                         $installed['lastmodified']
  526.                             = $info->packageInfo('_lastmodified');
  527.                     }
  528.                     if ($this->options['resume'PEAR_INFO_PACKAGES_XML{
  529.                         $installed['packagexml'$info->getPackagexmlVersion();
  530.                         if (isset($__info['packagerversion'])) {
  531.                             $installed['packagerversion']
  532.                                 = $__info['packagerversion'];
  533.                         }
  534.                     }
  535.                 else {
  536.                     if ($this->options['resume'PEAR_INFO_PACKAGES_LICENSE{
  537.                         $uri $info->getLicenseLocation();
  538.                         if ($uri{
  539.                             if (isset($uri['uri'])) {
  540.                                 $installed['license''<a href="'
  541.                                     . $uri['uri''">'
  542.                                     . $info->getLicense('</a>';
  543.                             }
  544.                         }
  545.                     }
  546.                     if ($this->options['resume'PEAR_INFO_PACKAGES_UPDATE{
  547.                         $installed['lastmodified'$info->getLastModified();
  548.                     }
  549.                     if ($this->options['resume'PEAR_INFO_PACKAGES_XML{
  550.                         $installed['packagexml'$info->getPackagexmlVersion();
  551.                         $installed['packagerversion']
  552.                             = $__info['attribs']['packagerversion'];
  553.                     }
  554.                 }
  555.                 if ($this->options['resume'PEAR_INFO_PACKAGES_DESCRIPTION{
  556.                     $installed['description'$info->getDescription();
  557.                 }
  558.  
  559.                 // show dependency list
  560.                 $dependencies '';
  561.                 if ($this->options['resume'PEAR_INFO_PACKAGES_DEPENDENCIES{
  562.                     $deps $info->getDeps();
  563.                     if (is_array($deps)) {
  564.                         static $_deps_rel_trans = array(
  565.                                      'lt' => '<',
  566.                                      'le' => '<=',
  567.                                      'eq' => '=',
  568.                                      'ne' => '!=',
  569.                                      'gt' => '>',
  570.                                      'ge' => '>=',
  571.                                      'has' => 'has',
  572.                                      'not' => 'not'
  573.                                      );
  574.                         static $_deps_type_trans = array(
  575.                                      'pkg' => 'Package',
  576.                                      'ext' => 'Extension',
  577.                                      'php' => 'PHP',
  578.                                      'prog'=> 'Prog',
  579.                                      'os'  => 'OS',
  580.                                      'sapi'=> 'SAPI',
  581.                                      'zend'=> 'Zend'
  582.                                      );
  583.  
  584.                         $ptpl '
  585. <tr class="w">
  586.     <td>
  587.         {dep_required}
  588.     </td>
  589.     <td>
  590.         {dep_type}
  591.     </td>
  592.     <td>
  593.         {dep_name}
  594.     </td>
  595.     <td>
  596.         {dep_rel}
  597.     </td>
  598.     <td>
  599.         {dep_version}
  600.     </td>
  601. </tr>
  602. ';
  603.                         foreach ($deps as $dep{
  604.                             if (!isset($dep['optional'])) {
  605.                                 $dep['optional''';
  606.                             }
  607.                             $dependencies .= str_replace(array('{dep_required}',
  608.                                     '{dep_type}',
  609.                                     '{dep_name}',
  610.                                     '{dep_rel}',
  611.                                     '{dep_version}',
  612.                                     ),
  613.                                 array(($dep['optional'== 'no''Yes' 'No',
  614.                                     $_deps_type_trans[$dep['type']],
  615.                                     isset($dep['name']$dep['name''',
  616.                                     $_deps_rel_trans[$dep['rel']],
  617.                                     isset($dep['version']$dep['version'''
  618.                                     ),
  619.                                 $ptpl);
  620.                         }
  621.                         $ptpl '
  622. <tr class="w">
  623.     <td class="f">
  624.         Required
  625.     </td>
  626.     <td class="f">
  627.         Type
  628.     </td>
  629.     <td class="f">
  630.         Name
  631.     </td>
  632.     <td class="f">
  633.         Relation
  634.     </td>
  635.     <td class="f">
  636.         Version
  637.     </td>
  638. </tr>
  639. ';
  640.  
  641.                         $dependencies $ptpl $dependencies;
  642.                     }
  643.                 // end deps-list
  644.  
  645.                 if (!isset($old_index)) {
  646.                     $old_index '';
  647.                 }
  648.                 $current_index $name{0};
  649.                 if (strtolower($current_index!= strtolower($old_index)) {
  650.                     $packages .= '<a id="' $current_index $anchor_suffix
  651.                               . '"></a>';
  652.                     $old_index $current_index;
  653.                     $index[]   $current_index;
  654.                 }
  655.  
  656.                 // prepare package informations template
  657.                 $ptpl '
  658. <h2><a id="pkg_{package}">{package}</a></h2>
  659. <table>
  660. ';
  661.  
  662.                 $packages .= str_replace('{package}',
  663.                     trim($installed['package']),
  664.                     $ptpl);
  665.  
  666.                 if ($this->options['resume'PEAR_INFO_PACKAGES_CHANNEL{
  667.                     $ptpl '
  668. <tr class="v">
  669.     <td class="e">
  670.         Channel
  671.     </td>
  672.     <td>
  673.         {channel}
  674.     </td>
  675. </tr>
  676. ';
  677.  
  678.                     $packages .= str_replace('{channel}',
  679.                         trim($installed['channel']),
  680.                         $ptpl);
  681.                 }
  682.                 if ($this->options['resume'PEAR_INFO_PACKAGES_SUMMARY{
  683.                     $ptpl '
  684. <tr class="v">
  685.     <td class="e">
  686.         Summary
  687.     </td>
  688.     <td>
  689.         {summary}
  690.     </td>
  691. </tr>
  692. ';
  693.  
  694.                     $packages .= str_replace('{summary}',
  695.                         nl2br(htmlentities(trim($installed['summary']))),
  696.                         $ptpl);
  697.                 }
  698.                 if ($this->options['resume'PEAR_INFO_PACKAGES_VERSION{
  699.                     $ptpl '
  700. <tr class="v">
  701.     <td class="e">
  702.         Version
  703.     </td>
  704.     <td>
  705.         {version}
  706.     </td>
  707. </tr>
  708. ';
  709.  
  710.                     $packages .= str_replace('{version}',
  711.                         trim($installed['current_release']),
  712.                         $ptpl);
  713.                 }
  714.                 if ($this->options['resume'PEAR_INFO_PACKAGES_LICENSE{
  715.                     $ptpl '
  716. <tr class="v">
  717.     <td class="e">
  718.         License
  719.     </td>
  720.     <td>
  721.         {license}
  722.     </td>
  723. </tr>
  724. ';
  725.  
  726.                     $packages .= str_replace('{license}',
  727.                         trim($installed['license']),
  728.                         $ptpl);
  729.                 }
  730.                 if ($this->options['resume'PEAR_INFO_PACKAGES_DESCRIPTION{
  731.                     $ptpl '
  732. <tr class="v">
  733.     <td class="e">
  734.         Description
  735.     </td>
  736.     <td>
  737.         {description}
  738.     </td>
  739. </tr>
  740. ';
  741.  
  742.                     $packages .= str_replace('{description}',
  743.                         nl2br(htmlentities(trim($installed['description']))),
  744.                         $ptpl);
  745.                 }
  746.                 if (!empty($dependencies)) {
  747.                     $ptpl '
  748. <tr class="v">
  749.     <td class="e">
  750.         Dependencies
  751.     </td>
  752.     <td>
  753.         <table class="d">
  754.         {dependencies}
  755.         </table>
  756.     </td>
  757. </tr>';
  758.  
  759.                     $packages .= str_replace('{dependencies}',
  760.                         $dependencies,
  761.                         $ptpl);
  762.                 }
  763.  
  764.                 if ($this->options['resume'PEAR_INFO_PACKAGES_UPDATE{
  765.                     if ($latest != false{
  766.                         if (isset($latest[$installed['package']])) {
  767.                             $latestInstalledPkg $latest[$installed['package']];
  768.                             if (version_compare($latestInstalledPkg['version'],
  769.                                 $installed['version']'>')) {
  770.                                 $ptpl '
  771. <tr class="v">
  772.     <td class="e">
  773.         Latest Version
  774.     </td>
  775.     <td>
  776.         <a href="http://{channel}/get/{package}">{latest_version}</a>({latest_state})
  777.     </td>
  778. </tr>';
  779.  
  780.                                 $packages .= str_replace(array('{package}',
  781.                                         '{latest_version}',
  782.                                         '{latest_state}',
  783.                                         '{channel}'
  784.                                         ),
  785.                                     array(trim($installed['package']),
  786.                                         $latestInstalledPkg['version'],
  787.                                         $latestInstalledPkg['state'],
  788.                                         $channel
  789.                                         ),
  790.                                     $ptpl);
  791.                             }
  792.                         }
  793.                     }
  794.  
  795.                     if ($this->options['resume'PEAR_INFO_PACKAGES_XML{
  796.                         $ptpl '
  797. <tr class="v">
  798.     <td class="e">
  799.         Package XML version
  800.     </td>
  801.     <td>
  802.         {packagexml}
  803.     </td>
  804. </tr>';
  805.  
  806.                         $packagexml $installed['packagexml'];
  807.                         if (isset($installed['packagerversion'])) {
  808.                             $packagexml .= ' packaged with PEAR version '
  809.                                 . $installed['packagerversion'];
  810.                         }
  811.                         $packages .= str_replace('{packagexml}',
  812.                             $packagexml,
  813.                             $ptpl);
  814.                     }
  815.                     $ptpl '
  816. <tr class="v">
  817.     <td class="e">
  818.         Last Modified
  819.     </td>
  820.     <td>
  821.         {lastmodified}
  822.     </td>
  823. </tr>';
  824.  
  825.                     $packages .= str_replace('{lastmodified}',
  826.                         date('Y-m-d'$installed['lastmodified']),
  827.                         $ptpl);
  828.  
  829.                 }
  830.  
  831.                 $packages .= '
  832. <tr>
  833.     <td colspan="2" class="v"><a href="#{top}">Top</a></td>
  834. </tr>
  835. </table>
  836. ';
  837.                 $packages  str_replace('{top}''top'.$anchor_suffix$packages);
  838.             }
  839.  
  840.             $index_header '
  841. <h2><a id="{top}">Installed Packages, Channel {channel}</a></h2>
  842. <table>
  843. <tr>
  844.     <td class="e">
  845.         Index
  846.     </td>
  847. </tr>
  848. <tr>
  849.     <td class ="v" style="text-align: center">
  850. ';
  851.             $index_header str_replace(array('{channel}''{top}'),
  852.                 array($channel'top'.$anchor_suffix)$index_header);
  853.             foreach ($index as $i{
  854.                 $index_header .= ' | <a href="#'.$i.$anchor_suffix.'">'
  855.                               . strtoupper($i'</a>';
  856.             }
  857.             $index_header .= ' |
  858.     </td>
  859. </tr>
  860. </table>
  861.  
  862. ';
  863.  
  864.             $s .= $index_header $packages;
  865.             $anchor_suffix++;
  866.         }
  867.         return $s;
  868.     }
  869.  
  870.     /**
  871.      * Retrieves and formats the PEAR Config data
  872.      *
  873.      * @return string 
  874.      * @access private
  875.      * @since  version 1.0.1 (2003-04-24)
  876.      */
  877.     function getConfig()
  878.     {
  879.         $keys $this->config->getKeys();
  880.         sort($keys);
  881.  
  882.         $html_pear_config '
  883. <h2>PEAR Configuration</h2>
  884. <table>';
  885.         foreach ($keys as $key{
  886.             if (   ($key != 'password')
  887.                 && ($key != 'username')
  888.                 && ($key != 'sig_keyid')
  889.                 && ($key != 'http_proxy')) {
  890.                 $html_config '
  891. <tr class="v">
  892.     <td class="e">{key}</td>
  893.     <td>{value}</td>
  894. </tr>';
  895.  
  896.                 $html_config str_replace(array('{key}''{value}'),
  897.                     array($key$this->config->get($key)),
  898.                     $html_config);
  899.  
  900.                 $html_pear_config .= $html_config;
  901.             }
  902.         }
  903.         $html_pear_config .= '
  904. </table>
  905.  
  906. ';
  907.         return $html_pear_config;
  908.     }
  909.  
  910.     /**
  911.      * Retrieves and formats the PEAR Channel data
  912.      *
  913.      * @return string 
  914.      * @access private
  915.      * @since  version 1.7.0RC1 (2007-07-01)
  916.      */
  917.     function getChannels()
  918.     {
  919.         $channels $this->reg->listChannels();
  920.         if (PEAR::isError($channels)) {
  921.             $e '<p class="error">An Error occured while fetching the channel list.'
  922.                . ' Please try again.</p>';
  923.             return $e;
  924.         }
  925.         $channel_allowed $this->options['channels'];
  926.  
  927.         $html_pear_channel '
  928. <h2>PEAR Channels</h2>';
  929.  
  930.         $anchor_suffix = 0;
  931.         foreach ($channels as $channel{
  932.             if (!in_array($channel$channel_allowed)) {
  933.                 continue;
  934.             }
  935.             $html_pear_channel .= '
  936. <table>';
  937.  
  938.             $info $this->reg->channelInfo($channel);
  939.             if (PEAR::isError($info|| is_null($info)) {
  940.                 $e '<p class="error">An Error occured while fetching '
  941.                    . $channel ' channel data.'
  942.                    . ' Please try again.</p>';
  943.                 return $e;
  944.             }
  945.  
  946.             $data = array('name' => $info['name']);
  947.             if (isset($info['suggestedalias'])) {
  948.                 $data['alias'$info['suggestedalias'];
  949.             }
  950.             $data['summary'$info['summary'];
  951.  
  952.             foreach ($data as $key => $value{
  953.                 $html_channel '
  954. <tr class="v">
  955.     <td class="e">{key}</td>
  956.     <td>{value}</td>
  957. </tr>';
  958.                 if ($key == 'name'{
  959.                     $value '<a href="#top' $anchor_suffix '">'
  960.                         . $value '</a>';
  961.                 }
  962.                 $html_channel str_replace(array('{key}''{value}'),
  963.                     array(ucfirst($key)$value),
  964.                     $html_channel);
  965.  
  966.                 $html_pear_channel .= $html_channel;
  967.             }
  968.             $html_pear_channel .= '
  969. </table>
  970. <br />
  971.  
  972. ';
  973.             $anchor_suffix++;
  974.         }
  975.  
  976.         return $html_pear_channel;
  977.     }
  978.  
  979.     /**
  980.      * Retrieves and formats the PEAR Credits
  981.      *
  982.      * @return string 
  983.      * @access private
  984.      * @since  version 1.0.1 (2003-04-24)
  985.      */
  986.     function getCredits()
  987.     {
  988.         $html_pear_credits '<h1>PEAR Credits</h1>';
  989.  
  990.         $teams PEAR_Info::getMembers();
  991.  
  992.         if (($this->options['resume'PEAR_INFO_CREDITS_GROUP||
  993.             isset($_GET['credits'])) {
  994.             $html_pear_credits .= '
  995. <table>
  996.     <tr class="hc">
  997.         <td colspan="2">
  998.             PEAR Group
  999.         </td>
  1000.     </tr>
  1001.     <tr class="v">
  1002.         <td class="e">
  1003.             President
  1004.         </td>
  1005.         <td>
  1006.             {president}
  1007.         </td>
  1008.     </tr>
  1009.     <tr class="v">
  1010.         <td colspan="2">
  1011. ';
  1012.             foreach ($teams['president'as $handle => $name{
  1013.                 $html_member
  1014.                     = '<a href="http://pear.php.net/account-info.php?handle='
  1015.                     . $handle .'">'$name .'</a>,';
  1016.  
  1017.                 $html_pear_credits str_replace('{president}',
  1018.                     $html_member$html_pear_credits);
  1019.             }
  1020.  
  1021.             foreach ($teams['group'as $handle => $name{
  1022.                 $html_member
  1023.                     = '<a href="http://pear.php.net/account-info.php?handle='
  1024.                     . $handle .'">'$name .'</a>,';
  1025.  
  1026.                 $html_pear_credits .= $html_member;
  1027.             }
  1028.  
  1029.             $html_pear_credits .= '
  1030.         </td>
  1031.     </tr>
  1032. </table>
  1033. <br />
  1034. ';
  1035.         }
  1036.  
  1037.         if (($this->options['resume'PEAR_INFO_CREDITS_DOCS||
  1038.             isset($_GET['credits'])) {
  1039.             if (count($teams['docs']> 0{
  1040.                 $html_pear_credits .= '
  1041. <table>
  1042.     <tr class="hc">
  1043.         <td>
  1044.             PEAR Documentation Team
  1045.         </td>
  1046.     </tr>
  1047.     <tr class="v">
  1048.         <td>
  1049. ';
  1050.                 foreach ($teams['docs'as $handle => $name{
  1051.                     $html_member
  1052.                         = '<a href="http://pear.php.net/account-info.php?handle='
  1053.                         . $handle .'">'$name .'</a>,';
  1054.  
  1055.                     $html_pear_credits .= $html_member;
  1056.                 }
  1057.  
  1058.                 $html_pear_credits .= '
  1059.         </td>
  1060.     </tr>
  1061. </table>
  1062. <br />
  1063. ';
  1064.             }
  1065.         }
  1066.  
  1067.         if (($this->options['resume'PEAR_INFO_CREDITS_WEBSITE||
  1068.             isset($_GET['credits'])) {
  1069.             if (count($teams['website']> 0{
  1070.                 $html_pear_credits .= '
  1071. <table>
  1072.     <tr class="hc">
  1073.         <td>
  1074.             PEAR Website Team
  1075.         </td>
  1076.     </tr>
  1077.     <tr class="v">
  1078.         <td>
  1079. ';
  1080.                 foreach ($teams['website'as $handle => $name{
  1081.                     $html_member
  1082.                         = '<a href="http://pear.php.net/account-info.php?handle='
  1083.                         . $handle .'">'$name .'</a>,';
  1084.  
  1085.                     $html_pear_credits .= $html_member;
  1086.                 }
  1087.  
  1088.                 $html_pear_credits .= '
  1089.         </td>
  1090.     </tr>
  1091. </table>
  1092. <br />
  1093. ';
  1094.             }
  1095.         }
  1096.  
  1097.         if (!($this->options['resume'PEAR_INFO_CREDITS_PACKAGES&&
  1098.             !isset($_GET['credits'])) {
  1099.             return $html_pear_credits;
  1100.         }
  1101.  
  1102.         // Credits authors of packages group by channels
  1103.         $channel_allowed $this->options['channels'];
  1104.  
  1105.         $available $this->reg->listAllPackages();
  1106.         if (PEAR::isError($available)) {
  1107.             $e '<p class="error">An Error occured while fetching the credits'
  1108.                . ' from the remote server. Please try again.</p>';
  1109.             return $e;
  1110.         }
  1111.         if (!is_array($available)) {
  1112.             $e '<p class="error">The credits could not be fetched'
  1113.                . ' from the remote server. Please try again.</p>';
  1114.             return $e;
  1115.         }
  1116.  
  1117.         foreach ($available as $channel => $pkg{
  1118.             if (!in_array($channel$channel_allowed)) {
  1119.                 continue;
  1120.             }
  1121.             $html_pear_credits .= '
  1122. <br />
  1123. <table border="0" cellpadding="3" width="600">
  1124. <tr class="hc"><td colspan="2">Channel {channel}</td></tr>
  1125. <tr class="h"><td>Package</td><td>Maintainers</td></tr>';
  1126.  
  1127.             $html_pear_credits str_replace('{channel}'$channel,
  1128.                                      $html_pear_credits);
  1129.  
  1130.             // sort package by alphabetic order
  1131.             sort($pkg);
  1132.             //
  1133.             foreach ($pkg as $name{
  1134.                 $info &$this->reg->getPackage($name$channel);
  1135.                 if (is_object($info)) {
  1136.                     $installed['package']     $info->getPackage();
  1137.                     $installed['maintainers'$info->getMaintainers();
  1138.                 else {
  1139.                     $installed $info;
  1140.                 }
  1141.  
  1142.                 $ptpl '
  1143. <tr>
  1144.     <td class="e">
  1145.         <a href="http://{channel}/{packageURI}">{package}</a>
  1146.     </td>
  1147.     <td class="v">
  1148.         {maintainers}
  1149.     </td>
  1150. </tr>';
  1151.  
  1152.                 $maintainers = array();
  1153.                 foreach ($installed['maintainers'as $i{
  1154.                     $maintainers[]
  1155.                         = '<a href="http://pear.php.net/account-info.php?handle='
  1156.                         . $i['handle']'">'
  1157.                         . htmlentities($i['name'])
  1158.                         . '</a>'
  1159.                         .' (' $i['role']
  1160.                         . (isset($i['active']&& $i['active'=== 'no'
  1161.                             ? ', inactive' '')
  1162.                         . ')';
  1163.                 }
  1164.                 $maintainers implode(', '$maintainers);
  1165.  
  1166.                 $html_pear_credits .= str_replace(array('{packageURI}',
  1167.                         '{package}',
  1168.                         '{channel}',
  1169.                         '{maintainers}'
  1170.                         ),
  1171.                     array(trim(strtolower($installed['package'])),
  1172.                         trim($installed['package']),
  1173.                         $channel,
  1174.                         $maintainers
  1175.                         ),
  1176.                     $ptpl);
  1177.             }
  1178.             $html_pear_credits .= '
  1179. </table>
  1180. ';
  1181.         }
  1182.         return $html_pear_credits;
  1183.     }
  1184.  
  1185.     /**
  1186.      * Display the PEAR logo
  1187.      *
  1188.      * Display the PEAR logo (gif image) on browser output
  1189.      *
  1190.      * @return void 
  1191.      * @access public
  1192.      * @since  version 1.0.1 (2003-04-24)
  1193.      */
  1194.     function pearImage()
  1195.     {
  1196.         $pear_image
  1197.             = 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEek'
  1198.             . 'FluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls'
  1199.             . '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/IC'
  1200.             . 'COZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4'
  1201.             . 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1A'
  1202.             . 'uiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS'
  1203.             . 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIW'
  1204.             . 'WQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFE'
  1205.             . 'AWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSK'
  1206.             . 'kbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEp'
  1207.             . 'ypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQ'
  1208.             . 's+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzc'
  1209.             . 'YpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3w'
  1210.             . 'QAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDV'
  1211.             . 'KwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBE'
  1212.             . 'T9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BP'
  1213.             . 'PZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhB'
  1214.             . 'dAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYi'
  1215.             . 'WHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAW'
  1216.             . 'dgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO9'
  1217.             . '06ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgU'
  1218.             . 'A3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH'
  1219.             . '7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GG'
  1220.             . 'KW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRq'
  1221.             . 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQ'
  1222.             . 'GHcs/RRdiUDPHA33oADEAIAOw==';
  1223.         header('content-type: image/gif');
  1224.         echo base64_decode($pear_image);
  1225.     }
  1226.  
  1227.     /**
  1228.      * Returns a members list depending of its category (group, docs, website)
  1229.      *
  1230.      * Retrieve the members list of PEAR group, PEAR doc team, or PEAR website team
  1231.      *
  1232.      * @param string $group (optional) Member list category.
  1233.      *                       Either president, group, docs or website
  1234.      * @param bool   $sort  (optional) Return a member list sorted
  1235.      *                       in alphabetic order
  1236.      *
  1237.      * @static
  1238.      * @return array 
  1239.      * @access public
  1240.      * @since  version 1.7.0RC3 (2007-07-10)
  1241.      */
  1242.     function getMembers($group 'all'$sort = true)
  1243.     {
  1244.         $members = array(
  1245.             'president' => array('cellog' => 'Gregory Beaver'),
  1246.             'group'     => array(
  1247.                 'mj' => 'Martin Jansen',
  1248.                 'davidc' => 'David Coallier',
  1249.                 'arnaud' => 'Arnaud Limbourg',
  1250.                 'jeichorn' => 'Joshua Eichorn',
  1251.                 'cweiske' => 'Christian Weiske',
  1252.                 'dufuz' => 'Helgi &thorn;ormar',
  1253.                 'pmjones' => 'Paul M. Jones',
  1254.                 ),
  1255.             'docs'      => array(
  1256.                 ),
  1257.             'website'   => array(
  1258.                 )
  1259.             );
  1260.  
  1261.         if ($group === 'all'{
  1262.             $list $members;
  1263.             if ($sort === true{
  1264.                 asort($list['group']);
  1265.                 asort($list['docs']);
  1266.                 asort($list['website']);
  1267.             }
  1268.         elseif (in_array($grouparray_keys($members))) {
  1269.             $list $members[$group];
  1270.             if ($sort === true{
  1271.                 asort($list);
  1272.             }
  1273.         else {
  1274.             $list = false;
  1275.         }
  1276.         return $list;
  1277.     }
  1278.  
  1279.     /**
  1280.      * Shows PEAR_Info output
  1281.      *
  1282.      * Displays PEAR_Info output depending of style applied (style sheet).
  1283.      *
  1284.      * @return void 
  1285.      * @access public
  1286.      * @since  version 1.0.1 (2003-04-24)
  1287.      * @see    setStyleSheet()
  1288.      * @deprecated  use display() instead
  1289.      */
  1290.     function show()
  1291.     {
  1292.          $this->display();
  1293.     }
  1294.  
  1295.     /**
  1296.      * Displays PEAR_Info output
  1297.      *
  1298.      * Displays PEAR_Info output depending of style applied (style sheet).
  1299.      *
  1300.      * @return void 
  1301.      * @access public
  1302.      * @since  version 1.7.0RC1 (2007-07-01)
  1303.      * @see    setStyleSheet()
  1304.      */
  1305.     function display()
  1306.     {
  1307.          echo $this->toHtml();
  1308.     }
  1309.  
  1310.     /**
  1311.      * Returns PEAR_Info output (html code)
  1312.      *
  1313.      * Returns html code. This code is XHTML 1.1 compliant since version 1.7.0
  1314.      * A stand-alone HTML page will be printed only if PEAR_INFO_FULLPAGE
  1315.      * resume options is set.
  1316.      *
  1317.      * @return string 
  1318.      * @access public
  1319.      * @since  version 1.7.0RC1 (2007-07-01)
  1320.      * @see    setStyleSheet(), getStyleSheet()
  1321.      */
  1322.     function toHtml()
  1323.     {
  1324.         $body $this->info;
  1325.  
  1326.         if (!($this->options['resume'PEAR_INFO_FULLPAGE)) {
  1327.             return $body;
  1328.         }
  1329.  
  1330.         if (!isset($this->css)) {
  1331.             // when no user-styles defined, used the default values
  1332.             $this->setStyleSheet();
  1333.         }
  1334.         $styles $this->getStyleSheet();
  1335.  
  1336.         $html = <<<HTML
  1337. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  1338.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  1339. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  1340. <head>
  1341. <title>PEAR :: PEAR_Info()</title>
  1342. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  1343. <style type="text/css">
  1344. <!--
  1345. $styles
  1346.  -->
  1347. </style>
  1348. </head>
  1349. <body>
  1350. <div>
  1351. $body
  1352. </div>
  1353. </body>
  1354. </html>
  1355. HTML;
  1356.         return $html;
  1357.     }
  1358.  
  1359.     /**
  1360.      * Check if a package is installed
  1361.      *
  1362.      * Simple function to check if a package is installed under user
  1363.      * or system PEAR installation. Minimal version and channel info are supported.
  1364.      *
  1365.      * @param string $name        Package name
  1366.      * @param string $version     (optional) The minimal version
  1367.      *                             that should be installed
  1368.      * @param string $channel     (optional) The package channel distribution
  1369.      * @param string $user_file   (optional) file to read PEAR user-defined
  1370.      *                             options from
  1371.      * @param string $system_file (optional) file to read PEAR system-wide
  1372.      *                             defaults from
  1373.      *
  1374.      * @static
  1375.      * @return bool 
  1376.      * @access public
  1377.      * @since  version 1.6.0 (2005-01-03)
  1378.      */
  1379.     function packageInstalled($name$version = null$channel = null,
  1380.         $user_file ''$system_file '')
  1381.     {
  1382.         $config =PEAR_Config::singleton($user_file$system_file);
  1383.         $reg    =$config->getRegistry();
  1384.  
  1385.         if (is_null($version)) {
  1386.             return $reg->packageExists($name$channel);
  1387.         else {
  1388.             $info &$reg->getPackage($name$channel);
  1389.             if (is_object($info)) {
  1390.                 $installed['version'$info->getVersion();
  1391.             else {
  1392.                 $installed $info;
  1393.             }
  1394.             return version_compare($version$installed['version']'<=');
  1395.         }
  1396.     }
  1397. }
  1398.  
  1399. if (isset($_GET['pear_image'])) {
  1400.     PEAR_Info::pearImage();
  1401.     exit();
  1402. }
  1403. ?>

Documentation generated on Fri, 18 Apr 2008 16:30:08 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.