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

Source for file v1.php

Documentation is available at v1.php

  1. <?php
  2. /**
  3.  * package.xml generation class, package.xml version 1.0
  4.  *
  5.  * PHP versions 4 and 5
  6.  *
  7.  * @category   pear
  8.  * @package    PEAR
  9.  * @author     Greg Beaver <cellog@php.net>
  10.  * @copyright  1997-2009 The Authors
  11.  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
  12.  * @version    CVS: $Id: v1.php 313023 2011-07-06 19:17:11Z dufuz $
  13.  * @link       http://pear.php.net/package/PEAR
  14.  * @since      File available since Release 1.4.0a1
  15.  */
  16. /**
  17.  * needed for PEAR_VALIDATE_* constants
  18.  */
  19. require_once 'PEAR/Validate.php';
  20. require_once 'System.php';
  21. require_once 'PEAR/PackageFile/v2.php';
  22. /**
  23.  * This class converts a PEAR_PackageFile_v1 object into any output format.
  24.  *
  25.  * Supported output formats include array, XML string, and a PEAR_PackageFile_v2
  26.  * object, for converting package.xml 1.0 into package.xml 2.0 with no sweat.
  27.  * @category   pear
  28.  * @package    PEAR
  29.  * @author     Greg Beaver <cellog@php.net>
  30.  * @copyright  1997-2009 The Authors
  31.  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
  32.  * @version    Release: 1.9.4
  33.  * @link       http://pear.php.net/package/PEAR
  34.  * @since      Class available since Release 1.4.0a1
  35.  */
  36. {
  37.     /**
  38.      * @var PEAR_PackageFile_v1 
  39.      */
  40.     var $_packagefile;
  41.     function PEAR_PackageFile_Generator_v1(&$packagefile)
  42.     {
  43.         $this->_packagefile &$packagefile;
  44.     }
  45.  
  46.     function getPackagerVersion()
  47.     {
  48.         return '1.9.4';
  49.     }
  50.  
  51.     /**
  52.      * @param PEAR_Packager 
  53.      * @param bool if true, a .tgz is written, otherwise a .tar is written
  54.      * @param string|nulldirectory in which to save the .tgz
  55.      * @return string|PEAR_Errorlocation of package or error object
  56.      */
  57.     function toTgz(&$packager$compress = true$where = null)
  58.     {
  59.         require_once 'Archive/Tar.php';
  60.         if ($where === null{
  61.             if (!($where System::mktemp(array('-d')))) {
  62.                 return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: mktemp failed');
  63.             }
  64.         elseif (!@System::mkDir(array('-p'$where))) {
  65.             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' $where '" could' .
  66.                 ' not be created');
  67.         }
  68.         if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml'&&
  69.               !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
  70.             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' .
  71.                 ' "' $where . DIRECTORY_SEPARATOR . 'package.xml"');
  72.         }
  73.         if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) {
  74.             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file');
  75.         }
  76.         $pkginfo $this->_packagefile->getArray();
  77.         $ext $compress '.tgz' '.tar';
  78.         $pkgver $pkginfo['package''-' $pkginfo['version'];
  79.         $dest_package getcwd(. DIRECTORY_SEPARATOR . $pkgver $ext;
  80.         if (file_exists(getcwd(. DIRECTORY_SEPARATOR . $pkgver $ext&&
  81.               !is_file(getcwd(. DIRECTORY_SEPARATOR . $pkgver $ext)) {
  82.             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' .
  83.                 getcwd(. DIRECTORY_SEPARATOR . $pkgver $ext '"');
  84.         }
  85.         if ($pkgfile $this->_packagefile->getPackageFile()) {
  86.             $pkgdir dirname(realpath($pkgfile));
  87.             $pkgfile basename($pkgfile);
  88.         else {
  89.             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' .
  90.                 'be created from a real file');
  91.         }
  92.         // {{{ Create the package file list
  93.         $filelist = array();
  94.         $i = 0;
  95.  
  96.         foreach ($this->_packagefile->getFilelist(as $fname => $atts{
  97.             $file $pkgdir . DIRECTORY_SEPARATOR . $fname;
  98.             if (!file_exists($file)) {
  99.                 return PEAR::raiseError("File does not exist: $fname");
  100.             else {
  101.                 $filelist[$i++$file;
  102.                 if (!isset($atts['md5sum'])) {
  103.                     $this->_packagefile->setFileAttribute($fname'md5sum'md5_file($file));
  104.                 }
  105.                 $packager->log(2"Adding file $fname");
  106.             }
  107.         }
  108.         // }}}
  109.         $packagexml $this->toPackageFile($wherePEAR_VALIDATE_PACKAGING'package.xml'true);
  110.         if ($packagexml{
  111.             $tar =new Archive_Tar($dest_package$compress);
  112.             $tar->setErrorHandling(PEAR_ERROR_RETURN)// XXX Don't print errors
  113.             // ----- Creates with the package.xml file
  114.             $ok $tar->createModify(array($packagexml)''$where);
  115.             if (PEAR::isError($ok)) {
  116.                 return $ok;
  117.             elseif (!$ok{
  118.                 return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
  119.             }
  120.             // ----- Add the content of the package
  121.             if (!$tar->addModify($filelist$pkgver$pkgdir)) {
  122.                 return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
  123.             }
  124.             return $dest_package;
  125.         }
  126.     }
  127.  
  128.     /**
  129.      * @param string|nulldirectory to place the package.xml in, or null for a temporary dir
  130.      * @param int one of the PEAR_VALIDATE_* constants
  131.      * @param string name of the generated file
  132.      * @param bool if true, then no analysis will be performed on role="php" files
  133.      * @return string|PEAR_Errorpath to the created file on success
  134.      */
  135.     function toPackageFile($where = null$state = PEAR_VALIDATE_NORMAL$name 'package.xml',
  136.                            $nofilechecking = false)
  137.     {
  138.         if (!$this->_packagefile->validate($state$nofilechecking)) {
  139.             return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: invalid package.xml',
  140.                 nullnullnull$this->_packagefile->getValidationWarnings());
  141.         }
  142.         if ($where === null{
  143.             if (!($where System::mktemp(array('-d')))) {
  144.                 return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: mktemp failed');
  145.             }
  146.         elseif (!@System::mkDir(array('-p'$where))) {
  147.             return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: "' $where '" could' .
  148.                 ' not be created');
  149.         }
  150.         $newpkgfile $where . DIRECTORY_SEPARATOR . $name;
  151.         $np @fopen($newpkgfile'wb');
  152.         if (!$np{
  153.             return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: unable to save ' .
  154.                "$name as $newpkgfile");
  155.         }
  156.         fwrite($np$this->toXml($statetrue));
  157.         fclose($np);
  158.         return $newpkgfile;
  159.     }
  160.  
  161.     /**
  162.      * fix both XML encoding to be UTF8, and replace standard XML entities < > " & '
  163.      *
  164.      * @param string $string 
  165.      * @return string 
  166.      * @access private
  167.      */
  168.     function _fixXmlEncoding($string)
  169.     {
  170.         if (version_compare(phpversion()'5.0.0''lt')) {
  171.             $string utf8_encode($string);
  172.         }
  173.         return strtr($stringarray(
  174.                                           '&'  => '&amp;',
  175.                                           '>'  => '&gt;',
  176.                                           '<'  => '&lt;',
  177.                                           '"'  => '&quot;',
  178.                                           '\'' => '&apos;' ));
  179.     }
  180.  
  181.     /**
  182.      * Return an XML document based on the package info (as returned
  183.      * by the PEAR_Common::infoFrom* methods).
  184.      *
  185.      * @return string XML data
  186.      */
  187.     function toXml($state = PEAR_VALIDATE_NORMAL$nofilevalidation = false)
  188.     {
  189.         $this->_packagefile->setDate(date('Y-m-d'));
  190.         if (!$this->_packagefile->validate($state$nofilevalidation)) {
  191.             return false;
  192.         }
  193.         $pkginfo $this->_packagefile->getArray();
  194.         static $maint_map = array(
  195.             "handle" => "user",
  196.             "name" => "name",
  197.             "email" => "email",
  198.             "role" => "role",
  199.             );
  200.         $ret "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
  201.         $ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">\n";
  202.         $ret .= "<package version=\"1.0\" packagerversion=\"1.9.4\">\n" .
  203. " <name>$pkginfo[package]</name>";
  204.         if (isset($pkginfo['extends'])) {
  205.             $ret .= "\n<extends>$pkginfo[extends]</extends>";
  206.         }
  207.         $ret .=
  208.  "\n <summary>".$this->_fixXmlEncoding($pkginfo['summary'])."</summary>\n" .
  209. " <description>".trim($this->_fixXmlEncoding($pkginfo['description']))."\n </description>\n" .
  210. " <maintainers>\n";
  211.         foreach ($pkginfo['maintainers'as $maint{
  212.             $ret .= "  <maintainer>\n";
  213.             foreach ($maint_map as $idx => $elm{
  214.                 $ret .= "   <$elm>";
  215.                 $ret .= $this->_fixXmlEncoding($maint[$idx]);
  216.                 $ret .= "</$elm>\n";
  217.             }
  218.             $ret .= "  </maintainer>\n";
  219.         }
  220.         $ret .= "  </maintainers>\n";
  221.         $ret .= $this->_makeReleaseXml($pkginfofalse$state);
  222.         if (isset($pkginfo['changelog']&& count($pkginfo['changelog']> 0{
  223.             $ret .= " <changelog>\n";
  224.             foreach ($pkginfo['changelog'as $oldrelease{
  225.                 $ret .= $this->_makeReleaseXml($oldreleasetrue);
  226.             }
  227.             $ret .= " </changelog>\n";
  228.         }
  229.         $ret .= "</package>\n";
  230.         return $ret;
  231.     }
  232.  
  233.     // }}}
  234.     // {{{ _makeReleaseXml()
  235.  
  236.     /**
  237.      * Generate part of an XML description with release information.
  238.      *
  239.      * @param array  $pkginfo    array with release information
  240.      * @param bool   $changelog  whether the result will be in a changelog element
  241.      *
  242.      * @return string XML data
  243.      *
  244.      * @access private
  245.      */
  246.     function _makeReleaseXml($pkginfo$changelog = false$state = PEAR_VALIDATE_NORMAL)
  247.     {
  248.         // XXX QUOTE ENTITIES IN PCDATA, OR EMBED IN CDATA BLOCKS!!
  249.         $indent $changelog "  " "";
  250.         $ret = "$indent <release>\n";
  251.         if (!empty($pkginfo['version'])) {
  252.             $ret .= "$indent  <version>$pkginfo[version]</version>\n";
  253.         }
  254.         if (!empty($pkginfo['release_date'])) {
  255.             $ret .= "$indent  <date>$pkginfo[release_date]</date>\n";
  256.         }
  257.         if (!empty($pkginfo['release_license'])) {
  258.             $ret .= "$indent  <license>$pkginfo[release_license]</license>\n";
  259.         }
  260.         if (!empty($pkginfo['release_state'])) {
  261.             $ret .= "$indent  <state>$pkginfo[release_state]</state>\n";
  262.         }
  263.         if (!empty($pkginfo['release_notes'])) {
  264.             $ret .= "$indent  <notes>".trim($this->_fixXmlEncoding($pkginfo['release_notes']))
  265.             ."\n$indent  </notes>\n";
  266.         }
  267.         if (!empty($pkginfo['release_warnings'])) {
  268.             $ret .= "$indent  <warnings>".$this->_fixXmlEncoding($pkginfo['release_warnings'])."</warnings>\n";
  269.         }
  270.         if (isset($pkginfo['release_deps']&& sizeof($pkginfo['release_deps']> 0{
  271.             $ret .= "$indent  <deps>\n";
  272.             foreach ($pkginfo['release_deps'as $dep{
  273.                 $ret .= "$indent   <dep type=\"$dep[type]\" rel=\"$dep[rel]\"";
  274.                 if (isset($dep['version'])) {
  275.                     $ret .= " version=\"$dep[version]\"";
  276.                 }
  277.                 if (isset($dep['optional'])) {
  278.                     $ret .= " optional=\"$dep[optional]\"";
  279.                 }
  280.                 if (isset($dep['name'])) {
  281.                     $ret .= ">$dep[name]</dep>\n";
  282.                 else {
  283.                     $ret .= "/>\n";
  284.                 }
  285.             }
  286.             $ret .= "$indent  </deps>\n";
  287.         }
  288.         if (isset($pkginfo['configure_options'])) {
  289.             $ret .= "$indent  <configureoptions>\n";
  290.             foreach ($pkginfo['configure_options'as $c{
  291.                 $ret .= "$indent   <configureoption name=\"".
  292.                     $this->_fixXmlEncoding($c['name']"\"";
  293.                 if (isset($c['default'])) {
  294.                     $ret .= " default=\"" $this->_fixXmlEncoding($c['default']"\"";
  295.                 }
  296.                 $ret .= " prompt=\"" $this->_fixXmlEncoding($c['prompt']"\"";
  297.                 $ret .= "/>\n";
  298.             }
  299.             $ret .= "$indent  </configureoptions>\n";
  300.         }
  301.         if (isset($pkginfo['provides'])) {
  302.             foreach ($pkginfo['provides'as $key => $what{
  303.                 $ret .= "$indent  <provides type=\"$what[type]\" ";
  304.                 $ret .= "name=\"$what[name]\" ";
  305.                 if (isset($what['extends'])) {
  306.                     $ret .= "extends=\"$what[extends]\" ";
  307.                 }
  308.                 $ret .= "/>\n";
  309.             }
  310.         }
  311.         if (isset($pkginfo['filelist'])) {
  312.             $ret .= "$indent  <filelist>\n";
  313.             if ($state PEAR_VALIDATE_PACKAGING{
  314.                 $ret .= $this->recursiveXmlFilelist($pkginfo['filelist']);
  315.             else {
  316.                 foreach ($pkginfo['filelist'as $file => $fa{
  317.                     if (!isset($fa['role'])) {
  318.                         $fa['role''';
  319.                     }
  320.                     $ret .= "$indent   <file role=\"$fa[role]\"";
  321.                     if (isset($fa['baseinstalldir'])) {
  322.                         $ret .= ' baseinstalldir="' .
  323.                             $this->_fixXmlEncoding($fa['baseinstalldir']'"';
  324.                     }
  325.                     if (isset($fa['md5sum'])) {
  326.                         $ret .= " md5sum=\"$fa[md5sum]\"";
  327.                     }
  328.                     if (isset($fa['platform'])) {
  329.                         $ret .= " platform=\"$fa[platform]\"";
  330.                     }
  331.                     if (!empty($fa['install-as'])) {
  332.                         $ret .= ' install-as="' .
  333.                             $this->_fixXmlEncoding($fa['install-as']'"';
  334.                     }
  335.                     $ret .= ' name="' $this->_fixXmlEncoding($file'"';
  336.                     if (empty($fa['replacements'])) {
  337.                         $ret .= "/>\n";
  338.                     else {
  339.                         $ret .= ">\n";
  340.                         foreach ($fa['replacements'as $r{
  341.                             $ret .= "$indent    <replace";
  342.                             foreach ($r as $k => $v{
  343.                                 $ret .= " $k=\"" . $this->_fixXmlEncoding($v.'"';
  344.                             }
  345.                             $ret .= "/>\n";
  346.                         }
  347.                         $ret .= "$indent   </file>\n";
  348.                     }
  349.                 }
  350.             }
  351.             $ret .= "$indent  </filelist>\n";
  352.         }
  353.         $ret .= "$indent </release>\n";
  354.         return $ret;
  355.     }
  356.  
  357.     /**
  358.      * @param array 
  359.      * @access protected
  360.      */
  361.     function recursiveXmlFilelist($list)
  362.     {
  363.         $this->_dirs = array();
  364.         foreach ($list as $file => $attributes{
  365.             $this->_addDir($this->_dirsexplode('/'dirname($file))$file$attributes);
  366.         }
  367.         return $this->_formatDir($this->_dirs);
  368.     }
  369.  
  370.     /**
  371.      * @param array 
  372.      * @param array 
  373.      * @param string|null
  374.      * @param array|null
  375.      * @access private
  376.      */
  377.     function _addDir(&$dirs$dir$file = null$attributes = null)
  378.     {
  379.         if ($dir == array(|| $dir == array('.')) {
  380.             $dirs['files'][basename($file)$attributes;
  381.             return;
  382.         }
  383.         $curdir array_shift($dir);
  384.         if (!isset($dirs['dirs'][$curdir])) {
  385.             $dirs['dirs'][$curdir= array();
  386.         }
  387.         $this->_addDir($dirs['dirs'][$curdir]$dir$file$attributes);
  388.     }
  389.  
  390.     /**
  391.      * @param array 
  392.      * @param string 
  393.      * @param string 
  394.      * @access private
  395.      */
  396.     function _formatDir($dirs$indent ''$curdir '')
  397.     {
  398.         $ret '';
  399.         if (!count($dirs)) {
  400.             return '';
  401.         }
  402.         if (isset($dirs['dirs'])) {
  403.             uksort($dirs['dirs']'strnatcasecmp');
  404.             foreach ($dirs['dirs'as $dir => $contents{
  405.                 $usedir = "$curdir/$dir";
  406.                 $ret .= "$indent   <dir name=\"$dir\">\n";
  407.                 $ret .= $this->_formatDir($contents"$indent "$usedir);
  408.                 $ret .= "$indent   </dir> <!-- $usedir -->\n";
  409.             }
  410.         }
  411.         if (isset($dirs['files'])) {
  412.             uksort($dirs['files']'strnatcasecmp');
  413.             foreach ($dirs['files'as $file => $attribs{
  414.                 $ret .= $this->_formatFile($file$attribs$indent);
  415.             }
  416.         }
  417.         return $ret;
  418.     }
  419.  
  420.     /**
  421.      * @param string 
  422.      * @param array 
  423.      * @param string 
  424.      * @access private
  425.      */
  426.     function _formatFile($file$attributes$indent)
  427.     {
  428.         $ret = "$indent   <file role=\"$attributes[role]\"";
  429.         if (isset($attributes['baseinstalldir'])) {
  430.             $ret .= ' baseinstalldir="' .
  431.                 $this->_fixXmlEncoding($attributes['baseinstalldir']'"';
  432.         }
  433.         if (isset($attributes['md5sum'])) {
  434.             $ret .= " md5sum=\"$attributes[md5sum]\"";
  435.         }
  436.         if (isset($attributes['platform'])) {
  437.             $ret .= " platform=\"$attributes[platform]\"";
  438.         }
  439.         if (!empty($attributes['install-as'])) {
  440.             $ret .= ' install-as="' .
  441.                 $this->_fixXmlEncoding($attributes['install-as']'"';
  442.         }
  443.         $ret .= ' name="' $this->_fixXmlEncoding($file'"';
  444.         if (empty($attributes['replacements'])) {
  445.             $ret .= "/>\n";
  446.         else {
  447.             $ret .= ">\n";
  448.             foreach ($attributes['replacements'as $r{
  449.                 $ret .= "$indent    <replace";
  450.                 foreach ($r as $k => $v{
  451.                     $ret .= " $k=\"" . $this->_fixXmlEncoding($v.'"';
  452.                 }
  453.                 $ret .= "/>\n";
  454.             }
  455.             $ret .= "$indent   </file>\n";
  456.         }
  457.         return $ret;
  458.     }
  459.  
  460.     // {{{ _unIndent()
  461.  
  462.     /**
  463.      * Unindent given string (?)
  464.      *
  465.      * @param string $str The string that has to be unindented.
  466.      * @return string 
  467.      * @access private
  468.      */
  469.     function _unIndent($str)
  470.     {
  471.         // remove leading newlines
  472.         $str preg_replace('/^[\r\n]+/'''$str);
  473.         // find whitespace at the beginning of the first line
  474.         $indent_len strspn($str" \t");
  475.         $indent substr($str0$indent_len);
  476.         $data '';
  477.         // remove the same amount of whitespace from following lines
  478.         foreach (explode("\n"$stras $line{
  479.             if (substr($line0$indent_len== $indent{
  480.                 $data .= substr($line$indent_len"\n";
  481.             }
  482.         }
  483.         return $data;
  484.     }
  485.  
  486.     /**
  487.      * @return array 
  488.      */
  489.     function dependenciesToV2()
  490.     {
  491.         $arr = array();
  492.         $this->_convertDependencies2_0($arr);
  493.         return $arr['dependencies'];
  494.     }
  495.  
  496.     /**
  497.      * Convert a package.xml version 1.0 into version 2.0
  498.      *
  499.      * Note that this does a basic conversion, to allow more advanced
  500.      * features like bundles and multiple releases
  501.      * @param string the classname to instantiate and return.  This must be
  502.      *                PEAR_PackageFile_v2 or a descendant
  503.      * @param boolean if true, only valid, deterministic package.xml 1.0 as defined by the
  504.      *                 strictest parameters will be converted
  505.      * @return PEAR_PackageFile_v2|PEAR_Error
  506.      */
  507.     function &toV2($class 'PEAR_PackageFile_v2'$strict = false)
  508.     {
  509.         if ($strict{
  510.             if (!$this->_packagefile->validate()) {
  511.                 $a PEAR::raiseError('invalid package.xml version 1.0 cannot be converted' .
  512.                     ' to version 2.0'nullnullnull,
  513.                     $this->_packagefile->getValidationWarnings(true));
  514.                 return $a;
  515.             }
  516.         }
  517.  
  518.         $arr = array(
  519.             'attribs' => array(
  520.                              'version' => '2.0',
  521.                              'xmlns' => 'http://pear.php.net/dtd/package-2.0',
  522.                              'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
  523.                              'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
  524.                              'xsi:schemaLocation' => "http://pear.php.net/dtd/tasks-1.0\n" .
  525. "http://pear.php.net/dtd/tasks-1.0.xsd\n" .
  526. "http://pear.php.net/dtd/package-2.0\n" .
  527. 'http://pear.php.net/dtd/package-2.0.xsd',
  528.                          ),
  529.             'name' => $this->_packagefile->getPackage(),
  530.             'channel' => 'pear.php.net',
  531.         );
  532.         $arr['summary'$this->_packagefile->getSummary();
  533.         $arr['description'$this->_packagefile->getDescription();
  534.         $maintainers $this->_packagefile->getMaintainers();
  535.         foreach ($maintainers as $maintainer{
  536.             if ($maintainer['role'!= 'lead'{
  537.                 continue;
  538.             }
  539.             $new = array(
  540.                 'name' => $maintainer['name'],
  541.                 'user' => $maintainer['handle'],
  542.                 'email' => $maintainer['email'],
  543.                 'active' => 'yes',
  544.             );
  545.             $arr['lead'][$new;
  546.         }
  547.  
  548.         if (!isset($arr['lead'])) // some people... you know?
  549.             $arr['lead'= array(
  550.                 'name' => 'unknown',
  551.                 'user' => 'unknown',
  552.                 'email' => 'noleadmaintainer@example.com',
  553.                 'active' => 'no',
  554.             );
  555.         }
  556.  
  557.         if (count($arr['lead']== 1{
  558.             $arr['lead'$arr['lead'][0];
  559.         }
  560.  
  561.         foreach ($maintainers as $maintainer{
  562.             if ($maintainer['role'== 'lead'{
  563.                 continue;
  564.             }
  565.             $new = array(
  566.                 'name' => $maintainer['name'],
  567.                 'user' => $maintainer['handle'],
  568.                 'email' => $maintainer['email'],
  569.                 'active' => 'yes',
  570.             );
  571.             $arr[$maintainer['role']][$new;
  572.         }
  573.  
  574.         if (isset($arr['developer']&& count($arr['developer']== 1{
  575.             $arr['developer'$arr['developer'][0];
  576.         }
  577.  
  578.         if (isset($arr['contributor']&& count($arr['contributor']== 1{
  579.             $arr['contributor'$arr['contributor'][0];
  580.         }
  581.  
  582.         if (isset($arr['helper']&& count($arr['helper']== 1{
  583.             $arr['helper'$arr['helper'][0];
  584.         }
  585.  
  586.         $arr['date'$this->_packagefile->getDate();
  587.         $arr['version'=
  588.             array(
  589.                 'release' => $this->_packagefile->getVersion(),
  590.                 'api' => $this->_packagefile->getVersion(),
  591.             );
  592.         $arr['stability'=
  593.             array(
  594.                 'release' => $this->_packagefile->getState(),
  595.                 'api' => $this->_packagefile->getState(),
  596.             );
  597.         $licensemap =
  598.             array(
  599.                 'php' => 'http://www.php.net/license',
  600.                 'php license' => 'http://www.php.net/license',
  601.                 'lgpl' => 'http://www.gnu.org/copyleft/lesser.html',
  602.                 'bsd' => 'http://www.opensource.org/licenses/bsd-license.php',
  603.                 'bsd style' => 'http://www.opensource.org/licenses/bsd-license.php',
  604.                 'bsd-style' => 'http://www.opensource.org/licenses/bsd-license.php',
  605.                 'mit' => 'http://www.opensource.org/licenses/mit-license.php',
  606.                 'gpl' => 'http://www.gnu.org/copyleft/gpl.html',
  607.                 'apache' => 'http://www.opensource.org/licenses/apache2.0.php'
  608.             );
  609.  
  610.         if (isset($licensemap[strtolower($this->_packagefile->getLicense())])) {
  611.             $arr['license'= array(
  612.                 'attribs' => array('uri' =>
  613.                     $licensemap[strtolower($this->_packagefile->getLicense())]),
  614.                 '_content' => $this->_packagefile->getLicense()
  615.                 );
  616.         else {
  617.             // don't use bogus uri
  618.             $arr['license'$this->_packagefile->getLicense();
  619.         }
  620.  
  621.         $arr['notes'$this->_packagefile->getNotes();
  622.         $temp = array();
  623.         $arr['contents'$this->_convertFilelist2_0($temp);
  624.         $this->_convertDependencies2_0($arr);
  625.         $release ($this->_packagefile->getConfigureOptions(|| $this->_isExtension?
  626.             'extsrcrelease' 'phprelease';
  627.         if ($release == 'extsrcrelease'{
  628.             $arr['channel''pecl.php.net';
  629.             $arr['providesextension'$arr['name']// assumption
  630.         }
  631.  
  632.         $arr[$release= array();
  633.         if ($this->_packagefile->getConfigureOptions()) {
  634.             $arr[$release]['configureoption'$this->_packagefile->getConfigureOptions();
  635.             foreach ($arr[$release]['configureoption'as $i => $opt{
  636.                 $arr[$release]['configureoption'][$i= array('attribs' => $opt);
  637.             }
  638.             if (count($arr[$release]['configureoption']== 1{
  639.                 $arr[$release]['configureoption'$arr[$release]['configureoption'][0];
  640.             }
  641.         }
  642.  
  643.         $this->_convertRelease2_0($arr[$release]$temp);
  644.         if ($release == 'extsrcrelease' && count($arr[$release]> 1{
  645.             // multiple extsrcrelease tags added in PEAR 1.4.1
  646.             $arr['dependencies']['required']['pearinstaller']['min''1.4.1';
  647.         }
  648.  
  649.         if ($cl $this->_packagefile->getChangelog()) {
  650.             foreach ($cl as $release{
  651.                 $rel = array();
  652.                 $rel['version'=
  653.                     array(
  654.                         'release' => $release['version'],
  655.                         'api' => $release['version'],
  656.                     );
  657.                 if (!isset($release['release_state'])) {
  658.                     $release['release_state''stable';
  659.                 }
  660.  
  661.                 $rel['stability'=
  662.                     array(
  663.                         'release' => $release['release_state'],
  664.                         'api' => $release['release_state'],
  665.                     );
  666.                 if (isset($release['release_date'])) {
  667.                     $rel['date'$release['release_date'];
  668.                 else {
  669.                     $rel['date'date('Y-m-d');
  670.                 }
  671.  
  672.                 if (isset($release['release_license'])) {
  673.                     if (isset($licensemap[strtolower($release['release_license'])])) {
  674.                         $uri $licensemap[strtolower($release['release_license'])];
  675.                     else {
  676.                         $uri 'http://www.example.com';
  677.                     }
  678.                     $rel['license'= array(
  679.                             'attribs' => array('uri' => $uri),
  680.                             '_content' => $release['release_license']
  681.                         );
  682.                 else {
  683.                     $rel['license'$arr['license'];
  684.                 }
  685.  
  686.                 if (!isset($release['release_notes'])) {
  687.                     $release['release_notes''no release notes';
  688.                 }
  689.  
  690.                 $rel['notes'$release['release_notes'];
  691.                 $arr['changelog']['release'][$rel;
  692.             }
  693.         }
  694.  
  695.         $ret = new $class;
  696.         $ret->setConfig($this->_packagefile->_config);
  697.         if (isset($this->_packagefile->_logger&& is_object($this->_packagefile->_logger)) {
  698.             $ret->setLogger($this->_packagefile->_logger);
  699.         }
  700.  
  701.         $ret->fromArray($arr);
  702.         return $ret;
  703.     }
  704.  
  705.     /**
  706.      * @param array 
  707.      * @param bool 
  708.      * @access private
  709.      */
  710.     function _convertDependencies2_0(&$release$internal = false)
  711.     {
  712.         $peardep = array('pearinstaller' =>
  713.             array('min' => '1.4.0b1'))// this is a lot safer
  714.         $required $optional = array();
  715.         $release['dependencies'= array('required' => array());
  716.         if ($this->_packagefile->hasDeps()) {
  717.             foreach ($this->_packagefile->getDeps(as $dep{
  718.                 if (!isset($dep['optional']|| $dep['optional'== 'no'{
  719.                     $required[$dep;
  720.                 else {
  721.                     $optional[$dep;
  722.                 }
  723.             }
  724.             foreach (array('required''optional'as $arr{
  725.                 $deps = array();
  726.                 foreach ($$arr as $dep{
  727.                     // organize deps by dependency type and name
  728.                     if (!isset($deps[$dep['type']])) {
  729.                         $deps[$dep['type']] = array();
  730.                     }
  731.                     if (isset($dep['name'])) {
  732.                         $deps[$dep['type']][$dep['name']][$dep;
  733.                     else {
  734.                         $deps[$dep['type']][$dep;
  735.                     }
  736.                 }
  737.                 do {
  738.                     if (isset($deps['php'])) {
  739.                         $php = array();
  740.                         if (count($deps['php']> 1{
  741.                             $php $this->_processPhpDeps($deps['php']);
  742.                         else {
  743.                             if (!isset($deps['php'][0])) {
  744.                                 list($key$blaheach ($deps['php'])// stupid buggy versions
  745.                                 $deps['php'= array($blah[0]);
  746.                             }
  747.                             $php $this->_processDep($deps['php'][0]);
  748.                             if (!$php{
  749.                                 break; // poor mans throw
  750.                             }
  751.                         }
  752.                         $release['dependencies'][$arr]['php'$php;
  753.                     }
  754.                 while (false);
  755.                 do {
  756.                     if (isset($deps['pkg'])) {
  757.                         $pkg = array();
  758.                         $pkg $this->_processMultipleDepsName($deps['pkg']);
  759.                         if (!$pkg{
  760.                             break; // poor mans throw
  761.                         }
  762.                         $release['dependencies'][$arr]['package'$pkg;
  763.                     }
  764.                 while (false);
  765.                 do {
  766.                     if (isset($deps['ext'])) {
  767.                         $pkg = array();
  768.                         $pkg $this->_processMultipleDepsName($deps['ext']);
  769.                         $release['dependencies'][$arr]['extension'$pkg;
  770.                     }
  771.                 while (false);
  772.                 // skip sapi - it's not supported so nobody will have used it
  773.                 // skip os - it's not supported in 1.0
  774.             }
  775.         }
  776.         if (isset($release['dependencies']['required'])) {
  777.             $release['dependencies']['required'=
  778.                 array_merge($peardep$release['dependencies']['required']);
  779.         else {
  780.             $release['dependencies']['required'$peardep;
  781.         }
  782.         if (!isset($release['dependencies']['required']['php'])) {
  783.             $release['dependencies']['required']['php'=
  784.                 array('min' => '4.0.0');
  785.         }
  786.         $order = array();
  787.         $bewm $release['dependencies']['required'];
  788.         $order['php'$bewm['php'];
  789.         $order['pearinstaller'$bewm['pearinstaller'];
  790.         isset($bewm['package']$order['package'$bewm['package':0;
  791.         isset($bewm['extension']$order['extension'$bewm['extension':0;
  792.         $release['dependencies']['required'$order;
  793.     }
  794.  
  795.     /**
  796.      * @param array 
  797.      * @access private
  798.      */
  799.     function _convertFilelist2_0(&$package)
  800.     {
  801.         $ret = array('dir' =>
  802.                     array(
  803.                         'attribs' => array('name' => '/'),
  804.                         'file' => array()
  805.                         )
  806.                     );
  807.         $package['platform'=
  808.         $package['install-as'= array();
  809.         $this->_isExtension = false;
  810.         foreach ($this->_packagefile->getFilelist(as $name => $file{
  811.             $file['name'$name;
  812.             if (isset($file['role']&& $file['role'== 'src'{
  813.                 $this->_isExtension = true;
  814.             }
  815.             if (isset($file['replacements'])) {
  816.                 $repl $file['replacements'];
  817.                 unset($file['replacements']);
  818.             else {
  819.                 unset($repl);
  820.             }
  821.             if (isset($file['install-as'])) {
  822.                 $package['install-as'][$name$file['install-as'];
  823.                 unset($file['install-as']);
  824.             }
  825.             if (isset($file['platform'])) {
  826.                 $package['platform'][$name$file['platform'];
  827.                 unset($file['platform']);
  828.             }
  829.             $file = array('attribs' => $file);
  830.             if (isset($repl)) {
  831.                 foreach ($repl as $replace {
  832.                     $file['tasks:replace'][= array('attribs' => $replace);
  833.                 }
  834.                 if (count($repl== 1{
  835.                     $file['tasks:replace'$file['tasks:replace'][0];
  836.                 }
  837.             }
  838.             $ret['dir']['file'][$file;
  839.         }
  840.         return $ret;
  841.     }
  842.  
  843.     /**
  844.      * Post-process special files with install-as/platform attributes and
  845.      * make the release tag.
  846.      *
  847.      * This complex method follows this work-flow to create the release tags:
  848.      *
  849.      * <pre>
  850.      * - if any install-as/platform exist, create a generic release and fill it with
  851.      *   o <install as=..> tags for <file name=... install-as=...>
  852.      *   o <install as=..> tags for <file name=... platform=!... install-as=..>
  853.      *   o <ignore> tags for <file name=... platform=...>
  854.      *   o <ignore> tags for <file name=... platform=... install-as=..>
  855.      * - create a release for each platform encountered and fill with
  856.      *   o <install as..> tags for <file name=... install-as=...>
  857.      *   o <install as..> tags for <file name=... platform=this platform install-as=..>
  858.      *   o <install as..> tags for <file name=... platform=!other platform install-as=..>
  859.      *   o <ignore> tags for <file name=... platform=!this platform>
  860.      *   o <ignore> tags for <file name=... platform=other platform>
  861.      *   o <ignore> tags for <file name=... platform=other platform install-as=..>
  862.      *   o <ignore> tags for <file name=... platform=!this platform install-as=..>
  863.      * </pre>
  864.      *
  865.      * It does this by accessing the $package parameter, which contains an array with
  866.      * indices:
  867.      *
  868.      *  - platform: mapping of file => OS the file should be installed on
  869.      *  - install-as: mapping of file => installed name
  870.      *  - osmap: mapping of OS => list of files that should be installed
  871.      *    on that OS
  872.      *  - notosmap: mapping of OS => list of files that should not be
  873.      *    installed on that OS
  874.      *
  875.      * @param array 
  876.      * @param array 
  877.      * @access private
  878.      */
  879.     function _convertRelease2_0(&$release$package)
  880.     {
  881.         //- if any install-as/platform exist, create a generic release and fill it with
  882.         if (count($package['platform']|| count($package['install-as'])) {
  883.             $generic = array();
  884.             $genericIgnore = array();
  885.             foreach ($package['install-as'as $file => $as{
  886.                 //o <install as=..> tags for <file name=... install-as=...>
  887.                 if (!isset($package['platform'][$file])) {
  888.                     $generic[$file;
  889.                     continue;
  890.                 }
  891.                 //o <install as=..> tags for <file name=... platform=!... install-as=..>
  892.                 if (isset($package['platform'][$file]&&
  893.                       $package['platform'][$file]{0== '!'{
  894.                     $generic[$file;
  895.                     continue;
  896.                 }
  897.                 //o <ignore> tags for <file name=... platform=... install-as=..>
  898.                 if (isset($package['platform'][$file]&&
  899.                       $package['platform'][$file]{0!= '!'{
  900.                     $genericIgnore[$file;
  901.                     continue;
  902.                 }
  903.             }
  904.             foreach ($package['platform'as $file => $platform{
  905.                 if (isset($package['install-as'][$file])) {
  906.                     continue;
  907.                 }
  908.                 if ($platform{0!= '!'{
  909.                     //o <ignore> tags for <file name=... platform=...>
  910.                     $genericIgnore[$file;
  911.                 }
  912.             }
  913.             if (count($package['platform'])) {
  914.                 $oses $notplatform $platform = array();
  915.                 foreach ($package['platform'as $file => $os{
  916.                     // get a list of oses
  917.                     if ($os{0== '!'{
  918.                         if (isset($oses[substr($os1)])) {
  919.                             continue;
  920.                         }
  921.                         $oses[substr($os1)count($oses);
  922.                     else {
  923.                         if (isset($oses[$os])) {
  924.                             continue;
  925.                         }
  926.                         $oses[$oscount($oses);
  927.                     }
  928.                 }
  929.                 //- create a release for each platform encountered and fill with
  930.                 foreach ($oses as $os => $releaseNum{
  931.                     $release[$releaseNum]['installconditions']['os']['name'$os;
  932.                     $release[$releaseNum]['filelist'= array('install' => array(),
  933.                         'ignore' => array());
  934.                     foreach ($package['install-as'as $file => $as{
  935.                         //o <install as=..> tags for <file name=... install-as=...>
  936.                         if (!isset($package['platform'][$file])) {
  937.                             $release[$releaseNum]['filelist']['install'][=
  938.                                 array(
  939.                                     'attribs' => array(
  940.                                         'name' => $file,
  941.                                         'as' => $as,
  942.                                     ),
  943.                                 );
  944.                             continue;
  945.                         }
  946.                         //o <install as..> tags for
  947.                         //  <file name=... platform=this platform install-as=..>
  948.                         if (isset($package['platform'][$file]&&
  949.                               $package['platform'][$file== $os{
  950.                             $release[$releaseNum]['filelist']['install'][=
  951.                                 array(
  952.                                     'attribs' => array(
  953.                                         'name' => $file,
  954.                                         'as' => $as,
  955.                                     ),
  956.                                 );
  957.                             continue;
  958.                         }
  959.                         //o <install as..> tags for
  960.                         //  <file name=... platform=!other platform install-as=..>
  961.                         if (isset($package['platform'][$file]&&
  962.                               $package['platform'][$file!= "!$os" &&
  963.                               $package['platform'][$file]{0== '!'{
  964.                             $release[$releaseNum]['filelist']['install'][=
  965.                                 array(
  966.                                     'attribs' => array(
  967.                                         'name' => $file,
  968.                                         'as' => $as,
  969.                                     ),
  970.                                 );
  971.                             continue;
  972.                         }
  973.                         //o <ignore> tags for
  974.                         //  <file name=... platform=!this platform install-as=..>
  975.                         if (isset($package['platform'][$file]&&
  976.                               $package['platform'][$file== "!$os"{
  977.                             $release[$releaseNum]['filelist']['ignore'][=
  978.                                 array(
  979.                                     'attribs' => array(
  980.                                         'name' => $file,
  981.                                     ),
  982.                                 );
  983.                             continue;
  984.                         }
  985.                         //o <ignore> tags for
  986.                         //  <file name=... platform=other platform install-as=..>
  987.                         if (isset($package['platform'][$file]&&
  988.                               $package['platform'][$file]{0!= '!' &&
  989.                               $package['platform'][$file!= $os{
  990.                             $release[$releaseNum]['filelist']['ignore'][=
  991.                                 array(
  992.                                     'attribs' => array(
  993.                                         'name' => $file,
  994.                                     ),
  995.                                 );
  996.                             continue;
  997.                         }
  998.                     }
  999.                     foreach ($package['platform'as $file => $platform{
  1000.                         if (isset($package['install-as'][$file])) {
  1001.                             continue;
  1002.                         }
  1003.                         //o <ignore> tags for <file name=... platform=!this platform>
  1004.                         if ($platform == "!$os"{
  1005.                             $release[$releaseNum]['filelist']['ignore'][=
  1006.                                 array(
  1007.                                     'attribs' => array(
  1008.                                         'name' => $file,
  1009.                                     ),
  1010.                                 );
  1011.                             continue;
  1012.                         }
  1013.                         //o <ignore> tags for <file name=... platform=other platform>
  1014.                         if ($platform{0!= '!' && $platform != $os{
  1015.                             $release[$releaseNum]['filelist']['ignore'][=
  1016.                                 array(
  1017.                                     'attribs' => array(
  1018.                                         'name' => $file,
  1019.                                     ),
  1020.                                 );
  1021.                         }
  1022.                     }
  1023.                     if (!count($release[$releaseNum]['filelist']['install'])) {
  1024.                         unset($release[$releaseNum]['filelist']['install']);
  1025.                     }
  1026.                     if (!count($release[$releaseNum]['filelist']['ignore'])) {
  1027.                         unset($release[$releaseNum]['filelist']['ignore']);
  1028.                     }
  1029.                 }
  1030.                 if (count($generic|| count($genericIgnore)) {
  1031.                     $release[count($oses)= array();
  1032.                     if (count($generic)) {
  1033.                         foreach ($generic as $file{
  1034.                             if (isset($package['install-as'][$file])) {
  1035.                                 $installas $package['install-as'][$file];
  1036.                             else {
  1037.                                 $installas $file;
  1038.                             }
  1039.                             $release[count($oses)]['filelist']['install'][=
  1040.                                 array(
  1041.                                     'attribs' => array(
  1042.                                         'name' => $file,
  1043.                                         'as' => $installas,
  1044.                                     )
  1045.                                 );
  1046.                         }
  1047.                     }
  1048.                     if (count($genericIgnore)) {
  1049.                         foreach ($genericIgnore as $file{
  1050.                             $release[count($oses)]['filelist']['ignore'][=
  1051.                                 array(
  1052.                                     'attribs' => array(
  1053.                                         'name' => $file,
  1054.                                     )
  1055.                                 );
  1056.                         }
  1057.                     }
  1058.                 }
  1059.                 // cleanup
  1060.                 foreach ($release as $i => $rel{
  1061.                     if (isset($rel['filelist']['install']&&
  1062.                           count($rel['filelist']['install']== 1{
  1063.                         $release[$i]['filelist']['install'=
  1064.                             $release[$i]['filelist']['install'][0];
  1065.                     }
  1066.                     if (isset($rel['filelist']['ignore']&&
  1067.                           count($rel['filelist']['ignore']== 1{
  1068.                         $release[$i]['filelist']['ignore'=
  1069.                             $release[$i]['filelist']['ignore'][0];
  1070.                     }
  1071.                 }
  1072.                 if (count($release== 1{
  1073.                     $release $release[0];
  1074.                 }
  1075.             else {
  1076.                 // no platform atts, but some install-as atts
  1077.                 foreach ($package['install-as'as $file => $value{
  1078.                     $release['filelist']['install'][=
  1079.                         array(
  1080.                             'attribs' => array(
  1081.                                 'name' => $file,
  1082.                                 'as' => $value
  1083.                             )
  1084.                         );
  1085.                 }
  1086.                 if (count($release['filelist']['install']== 1{
  1087.                     $release['filelist']['install'$release['filelist']['install'][0];
  1088.                 }
  1089.             }
  1090.         }
  1091.     }
  1092.  
  1093.     /**
  1094.      * @param array 
  1095.      * @return array 
  1096.      * @access private
  1097.      */
  1098.     function _processDep($dep)
  1099.     {
  1100.         if ($dep['type'== 'php'{
  1101.             if ($dep['rel'== 'has'{
  1102.                 // come on - everyone has php!
  1103.                 return false;
  1104.             }
  1105.         }
  1106.         $php = array();
  1107.         if ($dep['type'!= 'php'{
  1108.             $php['name'$dep['name'];
  1109.             if ($dep['type'== 'pkg'{
  1110.                 $php['channel''pear.php.net';
  1111.             }
  1112.         }
  1113.         switch ($dep['rel']{
  1114.             case 'gt' :
  1115.                 $php['min'$dep['version'];
  1116.                 $php['exclude'$dep['version'];
  1117.             break;
  1118.             case 'ge' :
  1119.                 if (!isset($dep['version'])) {
  1120.                     if ($dep['type'== 'php'{
  1121.                         if (isset($dep['name'])) {
  1122.                             $dep['version'$dep['name'];
  1123.                         }
  1124.                     }
  1125.                 }
  1126.                 $php['min'$dep['version'];
  1127.             break;
  1128.             case 'lt' :
  1129.                 $php['max'$dep['version'];
  1130.                 $php['exclude'$dep['version'];
  1131.             break;
  1132.             case 'le' :
  1133.                 $php['max'$dep['version'];
  1134.             break;
  1135.             case 'eq' :
  1136.                 $php['min'$dep['version'];
  1137.                 $php['max'$dep['version'];
  1138.             break;
  1139.             case 'ne' :
  1140.                 $php['exclude'$dep['version'];
  1141.             break;
  1142.             case 'not' :
  1143.                 $php['conflicts''yes';
  1144.             break;
  1145.         }
  1146.         return $php;
  1147.     }
  1148.  
  1149.     /**
  1150.      * @param array 
  1151.      * @return array 
  1152.      */
  1153.     function _processPhpDeps($deps)
  1154.     {
  1155.         $test = array();
  1156.         foreach ($deps as $dep{
  1157.             $test[$this->_processDep($dep);
  1158.         }
  1159.         $min = array();
  1160.         $max = array();
  1161.         foreach ($test as $dep{
  1162.             if (!$dep{
  1163.                 continue;
  1164.             }
  1165.             if (isset($dep['min'])) {
  1166.                 $min[$dep['min']] count($min);
  1167.             }
  1168.             if (isset($dep['max'])) {
  1169.                 $max[$dep['max']] count($max);
  1170.             }
  1171.         }
  1172.         if (count($min> 0{
  1173.             uksort($min'version_compare');
  1174.         }
  1175.         if (count($max> 0{
  1176.             uksort($max'version_compare');
  1177.         }
  1178.         if (count($min)) {
  1179.             // get the highest minimum
  1180.             $min array_pop($a array_flip($min));
  1181.         else {
  1182.             $min = false;
  1183.         }
  1184.         if (count($max)) {
  1185.             // get the lowest maximum
  1186.             $max array_shift($a array_flip($max));
  1187.         else {
  1188.             $max = false;
  1189.         }
  1190.         if ($min{
  1191.             $php['min'$min;
  1192.         }
  1193.         if ($max{
  1194.             $php['max'$max;
  1195.         }
  1196.         $exclude = array();
  1197.         foreach ($test as $dep{
  1198.             if (!isset($dep['exclude'])) {
  1199.                 continue;
  1200.             }
  1201.             $exclude[$dep['exclude'];
  1202.         }
  1203.         if (count($exclude)) {
  1204.             $php['exclude'$exclude;
  1205.         }
  1206.         return $php;
  1207.     }
  1208.  
  1209.     /**
  1210.      * process multiple dependencies that have a name, like package deps
  1211.      * @param array 
  1212.      * @return array 
  1213.      * @access private
  1214.      */
  1215.     function _processMultipleDepsName($deps)
  1216.     {
  1217.         $ret $tests = array();
  1218.         foreach ($deps as $name => $dep{
  1219.             foreach ($dep as $d{
  1220.                 $tests[$name][$this->_processDep($d);
  1221.             }
  1222.         }
  1223.  
  1224.         foreach ($tests as $name => $test{
  1225.             $max $min $php = array();
  1226.             $php['name'$name;
  1227.             foreach ($test as $dep{
  1228.                 if (!$dep{
  1229.                     continue;
  1230.                 }
  1231.                 if (isset($dep['channel'])) {
  1232.                     $php['channel''pear.php.net';
  1233.                 }
  1234.                 if (isset($dep['conflicts']&& $dep['conflicts'== 'yes'{
  1235.                     $php['conflicts''yes';
  1236.                 }
  1237.                 if (isset($dep['min'])) {
  1238.                     $min[$dep['min']] count($min);
  1239.                 }
  1240.                 if (isset($dep['max'])) {
  1241.                     $max[$dep['max']] count($max);
  1242.                 }
  1243.             }
  1244.             if (count($min> 0{
  1245.                 uksort($min'version_compare');
  1246.             }
  1247.             if (count($max> 0{
  1248.                 uksort($max'version_compare');
  1249.             }
  1250.             if (count($min)) {
  1251.                 // get the highest minimum
  1252.                 $min array_pop($a array_flip($min));
  1253.             else {
  1254.                 $min = false;
  1255.             }
  1256.             if (count($max)) {
  1257.                 // get the lowest maximum
  1258.                 $max array_shift($a array_flip($max));
  1259.             else {
  1260.                 $max = false;
  1261.             }
  1262.             if ($min{
  1263.                 $php['min'$min;
  1264.             }
  1265.             if ($max{
  1266.                 $php['max'$max;
  1267.             }
  1268.             $exclude = array();
  1269.             foreach ($test as $dep{
  1270.                 if (!isset($dep['exclude'])) {
  1271.                     continue;
  1272.                 }
  1273.                 $exclude[$dep['exclude'];
  1274.             }
  1275.             if (count($exclude)) {
  1276.                 $php['exclude'$exclude;
  1277.             }
  1278.             $ret[$php;
  1279.         }
  1280.         return $ret;
  1281.     }
  1282. }
  1283. ?>

Documentation generated on Wed, 06 Jul 2011 23:31:30 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.