"Fossies" - the Fresh Open Source Software Archive

Member "tiki-21.2/vendor_bundled/vendor/pear/pear/PEAR/REST/14.php" (19 Apr 2020, 3789 Bytes) of package /linux/www/tiki-21.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "14.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 /**
    3  * PEAR_REST_14
    4  *
    5  * PHP versions 4 and 5
    6  *
    7  * @category   pear
    8  * @package    PEAR
    9  * @author     Helgi Þormar Þorbjörnsson <helgi@php.net>
   10  * @copyright  1997-2009 The Authors
   11  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
   12  * @version    CVS: $Id: $
   13  * @link       http://pear.php.net/package/PEAR
   14  * @since      File available since Release 1.9
   15  */
   16 
   17 /**
   18  * For downloading REST xml/txt files
   19  */
   20 require_once 'PEAR/REST.php';
   21 require_once 'PEAR/REST/13.php';
   22 
   23 /**
   24  * Implement REST 1.4
   25  *
   26  * @category   pear
   27  * @package    PEAR
   28  * @author     Helgi Þormar Þorbjörnsson <helgi@php.net>
   29  * @copyright  1997-2009 The Authors
   30  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
   31  * @version    Release: @package_version@
   32  * @link       http://pear.php.net/package/PEAR
   33  * @since      Class available since Release 1.9
   34  */
   35 class PEAR_REST_14  extends PEAR_REST_13
   36 {
   37     function listLatestUpgrades($base, $pref_state, $installed, $channel, &$reg)
   38     {
   39         $packagelist = $this->_rest->retrieveData($base . 'p/latestpackages.xml', false, false, $channel);
   40         if (PEAR::isError($packagelist)) {
   41             return $packagelist;
   42         }
   43 
   44         $ret = array();
   45         if (!is_array($packagelist) || !isset($packagelist['p'])) {
   46             return $ret;
   47         }
   48 
   49         if (isset($packagelist['p']['n'])) {
   50             $packagelist['p'] = array($packagelist['p']);
   51         }
   52 
   53         foreach ($packagelist['p'] as $package) {
   54             if (!isset($installed[strtolower($package['n'])])) {
   55                 continue;
   56             }
   57 
   58             $inst_version = $reg->packageInfo($package['n'], 'version',       $channel);
   59             $inst_state   = $reg->packageInfo($package['n'], 'release_state', $channel);
   60 
   61 
   62             $release = $found = false;
   63             $data = array();
   64             if (isset($package['alpha'])) {
   65                 $data['alpha'] = $package['alpha'];
   66             }
   67 
   68             if (isset($package['beta'])) {
   69                 $data['beta'] = $package['beta'];
   70             }
   71 
   72             if (isset($package['stable'])) {
   73                 $data['stable'] = $package['stable'];
   74             }
   75 
   76             foreach ($data as $state => $release) {
   77                 if ($inst_version && version_compare($release['v'], $inst_version, '<=')) {
   78                     // not newer than the one installed
   79                     break;
   80                 }
   81 
   82                 // new version > installed version
   83                 if (!$pref_state) {
   84                     // every state is a good state
   85                     $found = true;
   86                     $release['state'] = $state;
   87                     break;
   88                 } else {
   89                     $new_state = $state;
   90                     // if new state >= installed state: go
   91                     if (in_array($new_state, $this->betterStates($inst_state, true))) {
   92                         $found = true;
   93                         $release['state'] = $state;
   94                         break;
   95                     } else {
   96                         // only allow to lower the state of package,
   97                         // if new state >= preferred state: go
   98                         if (in_array($new_state, $this->betterStates($pref_state, true))) {
   99                             $found = true;
  100                             $release['state'] = $state;
  101                             break;
  102                         }
  103                     }
  104                 }
  105             }
  106 
  107             if (!$found) {
  108                 continue;
  109             }
  110 
  111             $ret[$package] = array(
  112                 'version'  => $release['v'],
  113                 'state'    => $release['s'],
  114                 'filesize' => $release['f'],
  115             );
  116         }
  117 
  118         return $ret;
  119     }
  120 }