svn: /pear2/Pyrus/trunk/src/Pyrus/ Channel/RemoteMaintainers.php ChannelFile/v1.php
| From: | Brett Bieber | Date: | Fri, 05 Mar 2010 16:44:19 +0000 |
| Subject: | svn: /pear2/Pyrus/trunk/src/Pyrus/ Channel/RemoteMaintainers.php ChannelFile/v1.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-9270@lists.php.net to get a copy of this message | ||
saltybeagle Fri, 05 Mar 2010 16:44:19 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=295855
Log:
Add remote channel maintainer info support. Clean up magic __get var checks.
Changed paths:
A pear2/Pyrus/trunk/src/Pyrus/Channel/RemoteMaintainers.php
U pear2/Pyrus/trunk/src/Pyrus/ChannelFile/v1.php
Added: pear2/Pyrus/trunk/src/Pyrus/Channel/RemoteMaintainers.php
===================================================================
--- pear2/Pyrus/trunk/src/Pyrus/Channel/RemoteMaintainers.php (rev 0)
+++ pear2/Pyrus/trunk/src/Pyrus/Channel/RemoteMaintainers.php 2010-03-05 16:44:19 UTC (rev 295855)
@@ -0,0 +1,104 @@
+<?php
+/**
+ * \pear2\Pyrus\Channel\RemoteMaintainers
+ *
+ * PHP version 5
+ *
+ * @category PEAR2
+ * @package PEAR2_Pyrus
+ * @author Brett Bieber <saltybeagle@php.net>
+ * @copyright 2010 The PEAR Group
+ * @license http://www.opensource.org/licenses/bsd-license.php
New BSD License
+ * @version SVN: $Id$
+ * @link http://svn.php.net/viewvc/pear2/Pyrus/
+ */
+
+/**
+ * Remote REST iteration handler for maitainer listing
+ *
+ * @category PEAR2
+ * @package PEAR2_Pyrus
+ * @author Brett Bieber <saltybeagle@php.net>
+ * @copyright 2010 The PEAR Group
+ * @license http://www.opensource.org/licenses/bsd-license.php
New BSD License
+ * @link http://svn.php.net/viewvc/pear2/Pyrus/
+ */
+namespace pear2\Pyrus\Channel;
+class RemoteMaintainers implements \ArrayAccess, \Iterator
+{
+ protected $parent;
+ protected $rest;
+ protected $maintainerList;
+
+ function __construct(\pear2\Pyrus\ChannelFileInterface $channelinfo)
+ {
+ $this->parent = $channelinfo;
+ if (!isset($this->parent->protocols->rest['REST1.1'])) {
+ throw new Exception('Cannot access remote categories without REST1.1
protocol');
+ }
+
+ $this->rest = new \pear2\Pyrus\REST;
+ $this->rewind();
+ }
+
+ function offsetGet($var)
+ {
+ $url = $this->parent->protocols->rest['REST1.1']->baseurl .
'm/' . urlencode($var) . '/info.xml';
+ $info = $this->rest->retrieveCacheFirst($url);
+ return $info;
+ }
+
+ function offsetSet($var, $value)
+ {
+ throw new Exception('remote channel info is read-only');
+ }
+
+ function offsetUnset($var)
+ {
+ throw new Exception('remote channel info is read-only');
+ }
+
+ function offsetExists($var)
+ {
+ foreach ($this->maintainerList as $maintainer) {
+ if ($maintainer['_content'] == $var) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function valid()
+ {
+ return current($this->maintainerList);
+ }
+
+ function current()
+ {
+ $handle = $this->key();
+ $url = $this->parent->protocols->rest['REST1.1']->baseurl .
'm/' . urlencode($handle) . '/info.xml';
+ $info = $this->rest->retrieveCacheFirst($url);
+ return $info['m'];
+ }
+
+ function key()
+ {
+ $cur = current($this->maintainerList);
+ return urldecode($cur['_content']);
+ }
+
+ function next()
+ {
+ return next($this->maintainerList);
+ }
+
+ function rewind()
+ {
+ $url = $this->parent->protocols->rest['REST1.1']->baseurl .
'm/allmaintainers.xml';
+ $this->maintainerList = $this->rest->retrieveCacheFirst($url);
+ $this->maintainerList = $this->maintainerList['h'];
+ if (!isset($this->maintainerList[0])) {
+ $this->maintainerList = array($this->maintainerList);
+ }
+ }
+}
\ No newline at end of file
Modified: pear2/Pyrus/trunk/src/Pyrus/ChannelFile/v1.php
===================================================================
--- pear2/Pyrus/trunk/src/Pyrus/ChannelFile/v1.php 2010-03-05 15:57:10 UTC (rev 295854)
+++ pear2/Pyrus/trunk/src/Pyrus/ChannelFile/v1.php 2010-03-05 16:44:19 UTC (rev 295855)
@@ -184,12 +184,16 @@
if (isset($this->getMap[$var])) {
return $this->{$this->getMap[$var]}($var);
}
- if ($var == 'remotepackages') {
- return new \pear2\Pyrus\Channel\RemotePackages($this);
- } elseif ($var == 'remotepackage') {
- return new \pear2\Pyrus\Channel\RemotePackage($this, false);
- } elseif ($var == 'remotecategories') {
- return new \pear2\Pyrus\Channel\RemoteCategories($this);
+
+ switch($var) {
+ case 'remotepackages':
+ return new \pear2\Pyrus\Channel\RemotePackages($this);
+ case 'remotepackage':
+ return new \pear2\Pyrus\Channel\RemotePackage($this, false);
+ case 'remotecategories':
+ return new \pear2\Pyrus\Channel\RemoteCategories($this);
+ case 'remotemaintainers':
+ return new \pear2\Pyrus\Channel\RemoteMaintainers($this);
}
if (!isset($this->channelInfo[$var])) {