當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PEAR_REST::retrieveData方法代碼示例

本文整理匯總了PHP中PEAR_REST::retrieveData方法的典型用法代碼示例。如果您正苦於以下問題:PHP PEAR_REST::retrieveData方法的具體用法?PHP PEAR_REST::retrieveData怎麽用?PHP PEAR_REST::retrieveData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PEAR_REST的用法示例。


在下文中一共展示了PEAR_REST::retrieveData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: listCategory

 /**
  * 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;
 }
開發者ID:rjsmelo,項目名稱:tiki,代碼行數:63,代碼來源:11.php

示例2: packageInfo

 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);
 }
開發者ID:kaz6120,項目名稱:Loggix,代碼行數:52,代碼來源:10.php

示例3: listAll

 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']);
                     }
                 }
//.........這裏部分代碼省略.........
開發者ID:kjy112,項目名稱:TempestAlert,代碼行數:101,代碼來源:11.php


注:本文中的PEAR_REST::retrieveData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。