Author: Greg Beaver (cellog@php.net)
コード例 #1
0
ファイル: Remote.php プロジェクト: hbustun/agilebill
 function _checkChannelForStatus($channel, $chan)
 {
     $rest = new PEAR_REST($this->config);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $a = $rest->downloadHttp('http://' . $channel . '/channel.xml', $chan->lastModified());
     PEAR::staticPopErrorHandling();
     if (!PEAR::isError($a) && $a) {
         $this->ui->outputData('WARNING: channel "' . $channel . '" has ' . 'updated its protocols, use "channel-update ' . $channel . '" to update');
     }
 }
コード例 #2
0
 function _checkChannelForStatus($channel, $chan)
 {
     if (PEAR::isError($chan)) {
         $this->raiseError($chan);
     }
     if (!is_a($chan, 'PEAR_ChannelFile')) {
         return $this->raiseError('Internal corruption error: invalid channel "' . $channel . '"');
     }
     $rest = new PEAR_REST($this->config);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $a = $rest->downloadHttp('http://' . $channel . '/channel.xml', $chan->lastModified());
     PEAR::staticPopErrorHandling();
     if (!PEAR::isError($a) && $a) {
         $this->ui->outputData('WARNING: channel "' . $channel . '" has ' . 'updated its protocols, use "channel-update ' . $channel . '" to update');
     }
 }
コード例 #3
0
ファイル: 11.php プロジェクト: rjsmelo/tiki
 /**
  * List packages in a category of a REST server
  *
  * @param string $base base URL of the server
  * @param string $category name of the category
  * @param boolean $info also download full package info
  * @return array of packagenames
  */
 function listCategory($base, $category, $info = false, $channel = false)
 {
     if ($info == false) {
         $url = '%s' . 'c/%s/packages.xml';
     } else {
         $url = '%s' . 'c/%s/packagesinfo.xml';
     }
     $url = sprintf($url, $base, urlencode($category));
     // gives '404 Not Found' error when category doesn't exist
     $packagelist = $this->_rest->retrieveData($url, false, false, $channel);
     if (PEAR::isError($packagelist)) {
         return $packagelist;
     }
     if (!is_array($packagelist)) {
         return array();
     }
     if ($info == false) {
         if (!isset($packagelist['p'])) {
             return array();
         }
         if (!is_array($packagelist['p']) || !isset($packagelist['p'][0])) {
             // only 1 pkg
             $packagelist = array($packagelist['p']);
         } else {
             $packagelist = $packagelist['p'];
         }
         return $packagelist;
     } else {
         // info == true
         if (!isset($packagelist['pi'])) {
             return array();
         }
         if (!is_array($packagelist['pi']) || !isset($packagelist['pi'][0])) {
             // only 1 pkg
             $packagelist_pre = array($packagelist['pi']);
         } else {
             $packagelist_pre = $packagelist['pi'];
         }
         $packagelist = array();
         foreach ($packagelist_pre as $i => $item) {
             // compatibility with r/<latest.txt>.xml
             if (isset($item['a']['r'][0])) {
                 // multiple releases
                 $item['p']['v'] = $item['a']['r'][0]['v'];
                 $item['p']['st'] = $item['a']['r'][0]['s'];
             } elseif (isset($item['a'])) {
                 // first and only release
                 $item['p']['v'] = $item['a']['r']['v'];
                 $item['p']['st'] = $item['a']['r']['s'];
             }
             $packagelist[$i] = array('attribs' => $item['p']['r'], '_content' => $item['p']['n'], 'info' => $item['p']);
         }
     }
     return $packagelist;
 }
コード例 #4
0
ファイル: 10.php プロジェクト: kaz6120/Loggix
 function packageInfo($base, $package, $channel = false)
 {
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml', false, false, $channel);
     if (PEAR::isError($pinfo)) {
         PEAR::popErrorHandling();
         return PEAR::raiseError('Unknown package: "' . $package . '" in channel "' . $channel . '"' . "\n" . 'Debug: ' . $pinfo->getMessage());
     }
     $releases = array();
     $allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml', false, false, $channel);
     if (!PEAR::isError($allreleases)) {
         if (!class_exists('PEAR_PackageFile_v2')) {
             require_once 'PEAR/PackageFile/v2.php';
         }
         if (!is_array($allreleases['r']) || !isset($allreleases['r'][0])) {
             $allreleases['r'] = array($allreleases['r']);
         }
         $pf = new PEAR_PackageFile_v2();
         foreach ($allreleases['r'] as $release) {
             $ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $release['v'] . '.txt', false, false, $channel);
             if (PEAR::isError($ds)) {
                 continue;
             }
             if (!isset($latest)) {
                 $latest = $release['v'];
             }
             $pf->setDeps(unserialize($ds));
             $ds = $pf->getDeps();
             $info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . $release['v'] . '.xml', false, false, $channel);
             if (PEAR::isError($info)) {
                 continue;
             }
             $releases[$release['v']] = array('doneby' => $info['m'], 'license' => $info['l'], 'summary' => $info['s'], 'description' => $info['d'], 'releasedate' => $info['da'], 'releasenotes' => $info['n'], 'state' => $release['s'], 'deps' => $ds ? $ds : array());
         }
     } else {
         $latest = '';
     }
     PEAR::popErrorHandling();
     if (isset($pinfo['dc']) && isset($pinfo['dp'])) {
         if (is_array($pinfo['dp'])) {
             $deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']['_content']));
         } else {
             $deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']));
         }
     } else {
         $deprecated = false;
     }
     if (!isset($latest)) {
         $latest = '';
     }
     return array('name' => $pinfo['n'], 'channel' => $pinfo['c'], 'category' => $pinfo['ca']['_content'], 'stable' => $latest, 'license' => $pinfo['l'], 'summary' => $pinfo['s'], 'description' => $pinfo['d'], 'releases' => $releases, 'deprecated' => $deprecated);
 }
コード例 #5
0
ファイル: 11.php プロジェクト: kjy112/TempestAlert
 function listAll($base, $dostable, $basic = true)
 {
     $categorylist = $this->_rest->retrieveData($base . 'c/categories.xml');
     if (PEAR::isError($categorylist)) {
         return $categorylist;
     }
     $ret = array();
     if (!is_array($categorylist['c']) || !isset($categorylist['c'][0])) {
         $categorylist['c'] = array($categorylist['c']);
     }
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     foreach ($categorylist['c'] as $progress => $category) {
         $category = $category['_content'];
         $packagesinfo = $this->_rest->retrieveData($base . 'c/' . urlencode($category) . '/packagesinfo.xml');
         if (PEAR::isError($packagesinfo)) {
             continue;
         }
         if (!is_array($packagesinfo) || !isset($packagesinfo['pi'])) {
             continue;
         }
         if (!is_array($packagesinfo['pi']) || !isset($packagesinfo['pi'][0])) {
             $packagesinfo['pi'] = array($packagesinfo['pi']);
         }
         foreach ($packagesinfo['pi'] as $packageinfo) {
             $info = $packageinfo['p'];
             $package = $info['n'];
             $releases = isset($packageinfo['a']) ? $packageinfo['a'] : false;
             unset($latest);
             unset($unstable);
             unset($stable);
             unset($state);
             if ($releases) {
                 if (!isset($releases['r'][0])) {
                     $releases['r'] = array($releases['r']);
                 }
                 foreach ($releases['r'] as $release) {
                     if (!isset($latest)) {
                         if ($dostable && $release['s'] == 'stable') {
                             $latest = $release['v'];
                             $state = 'stable';
                         }
                         if (!$dostable) {
                             $latest = $release['v'];
                             $state = $release['s'];
                         }
                     }
                     if (!isset($stable) && $release['s'] == 'stable') {
                         $stable = $release['v'];
                         if (!isset($unstable)) {
                             $unstable = $stable;
                         }
                     }
                     if (!isset($unstable) && $release['s'] != 'stable') {
                         $latest = $unstable = $release['v'];
                         $state = $release['s'];
                     }
                     if (isset($latest) && !isset($state)) {
                         $state = $release['s'];
                     }
                     if (isset($latest) && isset($stable) && isset($unstable)) {
                         break;
                     }
                 }
             }
             if ($basic) {
                 // remote-list command
                 if (!isset($latest)) {
                     $latest = false;
                 }
                 if ($dostable) {
                     if ($state == 'stable') {
                         $ret[$package] = array('stable' => $latest);
                     } else {
                         $ret[$package] = array('stable' => '-n/a-');
                     }
                 } else {
                     $ret[$package] = array('stable' => $latest);
                 }
                 continue;
             }
             // list-all command
             $deps = array();
             if (!isset($unstable)) {
                 $unstable = false;
                 $state = 'stable';
                 if (isset($stable)) {
                     $latest = $unstable = $stable;
                 }
             } else {
                 $latest = $unstable;
             }
             if (!isset($latest)) {
                 $latest = false;
             }
             if ($latest && $packageinfo['deps'] !== null) {
                 if (isset($packageinfo['deps'])) {
                     if (!is_array($packageinfo['deps']) || !isset($packageinfo['deps'][0])) {
                         $packageinfo['deps'] = array($packageinfo['deps']);
                     }
                 }
                 $d = false;
                 foreach ($packageinfo['deps'] as $dep) {
                     if ($dep['v'] == $latest) {
                         $d = unserialize($dep['d']);
                     }
                 }
                 if ($d) {
                     if (isset($d['required'])) {
                         if (!class_exists('PEAR_PackageFile_v2')) {
                             require_once 'PEAR/PackageFile/v2.php';
                         }
                         if (!isset($pf)) {
                             $pf = new PEAR_PackageFile_v2();
                         }
                         $pf->setDeps($d);
                         $tdeps = $pf->getDeps();
                     } else {
                         $tdeps = $d;
                     }
                     foreach ($tdeps as $dep) {
                         if ($dep['type'] !== 'pkg') {
                             continue;
                         }
                         $deps[] = $dep;
                     }
                 }
             }
             $info = array('stable' => $latest, 'summary' => $info['s'], 'description' => $info['d'], 'deps' => $deps, 'category' => $info['ca']['_content'], 'unstable' => $unstable, 'state' => $state);
             $ret[$package] = $info;
         }
     }
     PEAR::popErrorHandling();
     return $ret;
 }
コード例 #6
0
 /**
  * @see PEAR_REST::downloadHttp()
  */
 public function downloadHttp($url, $lastmodified = null, $accept = false)
 {
     return parent::downloadHttp($url, $lastmodified, array_merge(false !== $accept ? $accept : array(), array("\r\nX-SYMFONY-VERSION: " . SYMFONY_VERSION)));
 }
コード例 #7
0
 /**
  * @see PEAR_REST::downloadHttp()
  */
 public function downloadHttp($url, $lastmodified = null, $accept = false)
 {
     return parent::downloadHttp($url, $lastmodified, $accept);
 }