1 : <?php
2 : /**
3 : * XMLRPC-based adapter for PEAR_PackageUpdate
4 : *
5 : * PHP versions 4 and 5
6 : *
7 : * LICENSE: This source file is subject to version 3.01 of the PHP license
8 : * that is available through the world-wide-web at the following URI:
9 : * http://www.php.net/license/3_01.txt. If you did not receive a copy of
10 : * the PHP License and are unable to obtain it through the web, please
11 : * send a note to license@php.net so we can mail you a copy immediately.
12 : *
13 : * @category PEAR
14 : * @package PEAR_PackageUpdate
15 : * @author Laurent Laville <pear@laurent-laville.org>
16 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
17 : * @version CVS: $Id: XmlRPC.php,v 1.1 2009/02/28 11:29:17 farell Exp $
18 : * @link http://pear.php.net/package/PEAR_PackageUpdate
19 : * @since File available since Release 1.1.0a1
20 : */
21 :
22 1 : require_once 'PEAR/PackageUpdate/Adapter.php';
23 :
24 : /**
25 : * XMLRPC-based adapter for PEAR_PackageUpdate
26 : *
27 : * @category PEAR
28 : * @package PEAR_PackageUpdate
29 : * @author Laurent Laville <pear@laurent-laville.org>
30 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
31 : * @version Release: 1.1.0a1
32 : * @link http://pear.php.net/package/PEAR_PackageUpdate
33 : * @since Class available since Release 1.1.0a1
34 : */
35 :
36 1 : class PEAR_PackageUpdate_Adapter_XmlRPC extends PEAR_PackageUpdate_Adapter
37 : {
38 : var $channel;
39 : var $config;
40 : var $ppu;
41 :
42 : function PEAR_PackageUpdate_Adapter_XmlRPC(&$config, &$ppu)
43 : {
44 1 : $this->config =&$config;
45 1 : $this->ppu =&$ppu;
46 1 : $this->channel = null;
47 1 : }
48 :
49 : /**
50 : * Check if the protocol asked is supported
51 : *
52 : * Check if the protocol asked is supported by default or package channel
53 : *
54 : * @access public
55 : * @return bool
56 : * @since version 1.1.0a1 (2009-02-28)
57 : */
58 : function supports()
59 : {
60 : // Get the config's registry object
61 1 : $reg = &$this->config->getRegistry();
62 1 : if ($reg === false) {
63 0 : return false;
64 : }
65 :
66 : // Get the registry's channel object
67 1 : $chan = &$reg->getChannel($this->ppu->channel);
68 1 : if (PEAR::isError($chan)) {
69 0 : return false;
70 : }
71 1 : $this->channel = $chan;
72 :
73 1 : $mirror = $this->config->get('preferred_mirror');
74 1 : return $chan->supports('xmlrpc', 'package.info', $mirror);
75 : }
76 :
77 : /**
78 : * Sends request to the remote server
79 : *
80 : * Sends request to the remote server and returns its response
81 : *
82 : * @param string $request Remote request id to proceed
83 : *
84 : * @access public
85 : * @return mixed
86 : * @since version 1.1.0a1 (2009-02-28)
87 : */
88 : function sendRequest($request)
89 : {
90 : switch ($request) {
91 0 : case 'package.info' :
92 0 : if (!isset($this->channel)) {
93 0 : if ($this->supports() == false) {
94 0 : return false;
95 : }
96 0 : }
97 0 : $r =& $this->config->getRemote();
98 0 : $info = $r->call('package.info', $this->ppu->packageName);
99 0 : return $info;
100 : }
101 :
102 0 : return false;
103 : }
104 : }
|