From a6282ca0e8a13fd53b4bea6eeff7a69f1312eef3 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 8 Jun 2010 18:39:20 +0200 Subject: autoload --- class/FedoraPkgdb.php | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 class/FedoraPkgdb.php (limited to 'class/FedoraPkgdb.php') diff --git a/class/FedoraPkgdb.php b/class/FedoraPkgdb.php new file mode 100644 index 0000000..c2085b0 --- /dev/null +++ b/class/FedoraPkgdb.php @@ -0,0 +1,142 @@ + + * + * @category Main + * @package FedoraClient + * + * @author Remi Collet + * @author Johan Cwiklinski + * @copyright 2010 Remi Collet + * @license http://www.gnu.org/licenses/lgpl-2.1.txt LGPL License 2.1 or (at your option) any later version + * @link http://github.com/remicollet/rpmphp/ + * @since The begining of times. + */ + +class FedoraPkgdb extends FedoraClient +{ + + function __construct (array $options=array()) + { + parent::__construct('https://admin.fedoraproject.org/pkgdb/', $options); + $this->logDebug( + 3, + __CLASS__."::".__FUNCTION__ + ); + } + + function getBranches($refresh=false) + { + $rep = ($refresh ? false : $this->cache->get(__FUNCTION__, __CLASS__)); + if ($rep) { + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__."() get from cache" + ); + } else { + $rep =$this->sendRequest('collections'); + $this->cache->save($rep, __FUNCTION__, __CLASS__); + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__."() save to cache" + ); + } + + $branches = array(); + if (isset($rep['collections'])) { + foreach ($rep['collections'] as $coll) { + if (isset($coll[0]['branchname'])) { + $branches[$coll[0]['branchname']] = $coll[0]; + } + } + } + return $branches; + } + + function getPackageInfo($name, $refresh=false) + { + $url="acls/name/$name"; + $rep = ($refresh ? false : $this->cache->get($url, __CLASS__)); + if ($rep) { + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__."($name) get from cache" + ); + } else { + $rep =$this->sendRequest($url); + $this->cache->save($rep, $url, __CLASS__); + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__."($name) save to cache" + ); + } + + if (isset($rep['status']) && !$rep['status']) { + $this->logDebug( + 1, + __CLASS__."::".__FUNCTION__."($name) ".$rep['message'] + ); + return false; + } + $this->logDebug(8,print_r($rep,true)); + $branches = array(); + foreach ($rep['packageListings'] as $pack) { + $branches[$pack['collection']['branchname']] = $pack; + } + $this->logDebug(7,print_r($branches,true)); + return $branches; + } + + function getBranch($name, $refresh=false) + { + $branches = $this->getBranches($refresh); + + if (isset($branches[$name])) { + return $branches[$name]; + } + return false; + } + + function getCritPath($refresh=false) + { + $url="lists/critpath"; + $rep = ($refresh ? false : $this->cache->get($url, __CLASS__)); + if ($rep) { + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__." get from cache" + ); + } else { + $rep =$this->sendRequest($url); + $this->cache->save($rep, $url, __CLASS__); + $this->logDebug( + 2, + __CLASS__."::".__FUNCTION__." save to cache" + ); + } + return $rep['pkgs']; + } +} +?> \ No newline at end of file -- cgit From e7493ab34e9db2226a5dd1d99938c04193ed88af Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 11 Jul 2010 18:23:16 +0200 Subject: urlencode package name, fixed #53 --- class/FedoraPkgdb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'class/FedoraPkgdb.php') diff --git a/class/FedoraPkgdb.php b/class/FedoraPkgdb.php index c2085b0..ee54119 100644 --- a/class/FedoraPkgdb.php +++ b/class/FedoraPkgdb.php @@ -77,7 +77,7 @@ class FedoraPkgdb extends FedoraClient function getPackageInfo($name, $refresh=false) { - $url="acls/name/$name"; + $url="acls/name/".urlencode($name); $rep = ($refresh ? false : $this->cache->get($url, __CLASS__)); if ($rep) { $this->logDebug( -- cgit From e6b48f0d645a72b2b4898f3ddc90fc8437f9b1e2 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 11 Jul 2010 18:43:12 +0200 Subject: add PkdDb link on zoom page, solves #58 --- class/FedoraPkgdb.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'class/FedoraPkgdb.php') diff --git a/class/FedoraPkgdb.php b/class/FedoraPkgdb.php index ee54119..9f2a094 100644 --- a/class/FedoraPkgdb.php +++ b/class/FedoraPkgdb.php @@ -37,10 +37,13 @@ class FedoraPkgdb extends FedoraClient { + private $suburl; function __construct (array $options=array()) { parent::__construct('https://admin.fedoraproject.org/pkgdb/', $options); + $this->suburl = 'acls/name/'; + $this->logDebug( 3, __CLASS__."::".__FUNCTION__ @@ -75,9 +78,14 @@ class FedoraPkgdb extends FedoraClient return $branches; } + function getPackageURL($name) + { + return $this->url.$this->suburl.urlencode($name); + } + function getPackageInfo($name, $refresh=false) { - $url="acls/name/".urlencode($name); + $url=$this->suburl.urlencode($name); $rep = ($refresh ? false : $this->cache->get($url, __CLASS__)); if ($rep) { $this->logDebug( -- cgit From a5fdd45528a85457821ef4739efcd3fc778affde Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 11 Jul 2010 18:56:05 +0200 Subject: fix issue with using name containing special char. --- class/FedoraPkgdb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'class/FedoraPkgdb.php') diff --git a/class/FedoraPkgdb.php b/class/FedoraPkgdb.php index 9f2a094..d170911 100644 --- a/class/FedoraPkgdb.php +++ b/class/FedoraPkgdb.php @@ -80,7 +80,7 @@ class FedoraPkgdb extends FedoraClient function getPackageURL($name) { - return $this->url.$this->suburl.urlencode($name); + return $this->url.$this->suburl.$name; } function getPackageInfo($name, $refresh=false) -- cgit