diff options
Diffstat (limited to 'class')
-rw-r--r-- | class/CommonTable.php | 8 | ||||
-rw-r--r-- | class/TableIterator.php | 1 | ||||
-rw-r--r-- | class/TablePearRepo.php | 67 | ||||
-rw-r--r-- | class/TableRRepo.php | 9 |
4 files changed, 64 insertions, 21 deletions
diff --git a/class/CommonTable.php b/class/CommonTable.php index e049188..8fd0471 100644 --- a/class/CommonTable.php +++ b/class/CommonTable.php @@ -194,13 +194,15 @@ abstract class CommonTable * * @param string $fieldkey name of the field to use as index * @param string $fieldvalue name of the field to use as value + * @param array $crit for request * * @return hashtable */ - public function getHashtable($fieldkey, $fieldvalue) + public function getHashtable($fieldkey, $fieldvalue, array $crit=array()) { - $crit = array('FIELDS' => array($fieldkey, $fieldvalue), - 'ORDER' => $fieldkey); + $crit['FIELDS'] = array($fieldkey, $fieldvalue); + $crit['ORDER'] = $fieldkey; + $tab = array(); foreach ($this->request($crit) as $data) { $tab[$data[$fieldkey]] = $data[$fieldvalue]; diff --git a/class/TableIterator.php b/class/TableIterator.php index 5c42d24..0903f37 100644 --- a/class/TableIterator.php +++ b/class/TableIterator.php @@ -115,7 +115,6 @@ class TableIterator implements Iterator } // WHERE criteria list if (!empty($crit)) { - print_r($crit); $this->sql .= " WHERE ".$this->_analyseCrit($crit); } // ORDER BY diff --git a/class/TablePearRepo.php b/class/TablePearRepo.php index 6ff3eaa..34a0c17 100644 --- a/class/TablePearRepo.php +++ b/class/TablePearRepo.php @@ -58,38 +58,77 @@ class TablePearRepo extends CommonTable `id` int(11) NOT NULL AUTO_INCREMENT, `alias` varchar(30) NOT NULL, `url` varchar(255) NOT NULL, + `active` tinyint NOT NULL default 1, PRIMARY KEY (`id`), - UNIQUE KEY `alias` (`alias`) + UNIQUE KEY `alias` (`alias`), + KEY `active` (`active`) ) DEFAULT CHARSET=utf8"; $this->exec($sql); // Some known repo, other could be add manually - // no reply from "phpdb" => "pear.phpdb.org" + // no reply from "" => "" $channels = array( - "pear" => "pear.php.net" - ,"doctrine" => "pear.phpdoctrine.org" - ,"ezc" => "components.ez.no" - ,"pdepend" => "pear.pdepend.org" - ,"phing" => "pear.phing.info" - ,"phpmd" => "pear.phpmd.org" - ,"phpunit" => "pear.phpunit.de" - ,"swift" => "pear.swiftmailer.org" - ,"symphony" => "pear.symfony-project.com" + array( + 'alias' => 'pear', + 'url' => 'pear.php.net' + ), + array( + 'alias' => 'doctrine', + 'url' => 'pear.phpdoctrine.org' + ), + array( + 'alias' => 'ezc', + 'url' => 'components.ez.no' + ), + array( + 'alias' => 'pdepend', + 'url' => 'pear.pdepend.org' + ), + array( + 'alias' => 'phing', + 'url' => 'pear.phing.info' + ), + array( + 'alias' => 'phpmd', + 'url' => 'pear.phpmd.org' + ), + array( + 'alias' => 'phpunit', + 'url' => 'pear.phpunit.de' + ), + array( + 'alias' => 'swift', + 'url' => 'pear.swiftmailer.org' + ), + array( + 'alias' => 'symphony', + 'url' => 'pear.symfony-project.com' + ), + array( + 'alias' => 'phpdb', + 'active' => 0, + 'url' => 'pear.phpdb.org' + ) ); - foreach ($channels as $alias => $url) { - $this->add(array('alias'=>$alias, 'url'=>$url)); + foreach ($channels as $channel) { + $this->add($channel); } } /** * Retrieve all the known repository * + * @param boolean $active true for only active repo (false for all) + * * @return hastable of alias => url */ - function getAllRepo() + function getAllRepo($active=true) { + if ($active) { + return $this->getHashtable('alias', 'url', array('active'=>1)); + } return $this->getHashtable('alias', 'url'); } } diff --git a/class/TableRRepo.php b/class/TableRRepo.php index 75570c3..884b4e3 100644 --- a/class/TableRRepo.php +++ b/class/TableRRepo.php @@ -61,7 +61,8 @@ class TableRRepo extends CommonTable `url` varchar(255) NOT NULL, `active` tinyint NOT NULL default 1, PRIMARY KEY (`id`), - UNIQUE KEY `name_state` (`name`,`state`) + UNIQUE KEY `name_state` (`name`,`state`), + KEY `active` (`active`) ) DEFAULT CHARSET=utf8"; $this->exec($sql); @@ -109,11 +110,13 @@ class TableRRepo extends CommonTable /** * Retrieve all the known repository * + * @param boolean $active true for only active repo (false for all) + * * @return hastable of alias => url */ - function getAllRepo() + function getAllRepo($active=true) { - return $this->getArray(array('active'=>1)); + return $this->getArray($active ? array('active'=>1) : ''); } } |