summaryrefslogtreecommitdiffstats
path: root/FedoraClient.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-05-23 17:12:20 +0200
committerRemi Collet <fedora@famillecollet.com>2010-05-23 17:12:20 +0200
commitbc796fd68e1faae3260c186ac446c3a75ac1ecf5 (patch)
tree778ca8c2177b81c229f9c9520704cd4b43d01a0d /FedoraClient.php
parent9cc3e2d35597302a3c831c5787cd18b90218b434 (diff)
Add FedoraPkgdb->getBranch(), improves fedcli.php
Diffstat (limited to 'FedoraClient.php')
-rw-r--r--FedoraClient.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/FedoraClient.php b/FedoraClient.php
index 891b7f3..1a33ac9 100644
--- a/FedoraClient.php
+++ b/FedoraClient.php
@@ -41,7 +41,7 @@ abstract class FedoraClient {
if (isset($options['agent']) && !empty($options['agent'])) {
$this->agent = $options['agent'];
} else {
- $this->agent = 'PHP FedoraClient/'.FEDORACLIENT_VERSION;
+ $this->agent = 'Fedora PHPClient/'.FEDORACLIENT_VERSION;
}
if (isset($options['debug']) && intval($options['debug'])>0) {
$this->debug = intval($options['debug']);
@@ -74,7 +74,7 @@ abstract class FedoraClient {
curl_setopt($curl, CURLOPT_HTTPHEADER, array('User-agent: '.$this->agent, 'Accept: application/json'));
# run the request
- $this->logDebug(1,__CLASS__."::".__FUNCTION__.": call '$url'");
+ $this->logDebug(2,__CLASS__."::".__FUNCTION__.": call '$url'");
curl_exec($curl);
@@ -93,7 +93,7 @@ abstract class FedoraClient {
$this->logDebug(2,__CLASS__."::".__FUNCTION__.": http_status '$http_status'");
}
- $this->logDebug(1,__CLASS__."::".__FUNCTION__.": close connexion");
+ $this->logDebug(2,__CLASS__."::".__FUNCTION__.": close connexion");
curl_close($curl);
return json_decode($this->data, true);
@@ -116,7 +116,7 @@ class FedoraPkgdb extends FedoraClient {
}
function getBranches($refresh=false) {
- $rep = $this->cache->get(__FUNCTION__,__CLASS__);
+ $rep = ($refresh ? false : $this->cache->get(__FUNCTION__,__CLASS__));
if ($rep) {
$this->logDebug(2,__CLASS__."::".__FUNCTION__." get from cache");
} else {
@@ -125,13 +125,22 @@ class FedoraPkgdb extends FedoraClient {
$this->logDebug(2,__CLASS__."::".__FUNCTION__." save to cache");
}
- $this->branches = array();
+ $branches = array();
if (isset($rep['collections'])) {
foreach ($rep['collections'] as $coll) if (isset($coll[0]['branchname'])) {
- $this->branches[$coll[0]['branchname']] = $coll[0];
+ $branches[$coll[0]['branchname']] = $coll[0];
}
}
- return $this->branches;
+ return $branches;
+ }
+
+ function getBranch($name, $refresh=false) {
+ $branches = $this->getBranches($refresh);
+
+ if (isset($branches[$name])) {
+ return $branches[$name];
+ }
+ return false;
}
}
?>