Редакция 69 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 69 | Редакция 87 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * PEAR_Command_Registry (list, list-files, shell-test, info commands)
|
3 | * PEAR_Command_Registry (list, list-files, shell-test, info commands)
|
4 | *
|
4 | *
|
5 | * PHP versions 4 and 5
|
5 | * PHP versions 4 and 5
|
6 | *
|
6 | *
|
7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
8 | * that is available through the world-wide-web at the following URI:
|
8 | * that is available through the world-wide-web at the following URI:
|
9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
10 | * the PHP License and are unable to obtain it through the web, please
|
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.
|
11 | * send a note to license@php.net so we can mail you a copy immediately.
|
12 | *
|
12 | *
|
13 | * @category pear
|
13 | * @category pear
|
14 | * @package PEAR
|
14 | * @package PEAR
|
15 | * @author Stig Bakken <ssb@php.net>
|
15 | * @author Stig Bakken <ssb@php.net>
|
16 | * @author Greg Beaver <cellog@php.net>
|
16 | * @author Greg Beaver <cellog@php.net>
|
17 | * @copyright 1997-2008 The PHP Group
|
17 | * @copyright 1997-2008 The PHP Group
|
18 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
18 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
19 | * @version CVS: $Id: Registry.php,v 1.81 2008/01/03 20:26:36 cellog Exp $
|
19 | * @version CVS: $Id: Registry.php,v 1.81 2008/01/03 20:26:36 cellog Exp $
|
20 | * @link http://pear.php.net/package/PEAR
|
20 | * @link http://pear.php.net/package/PEAR
|
21 | * @since File available since Release 0.1
|
21 | * @since File available since Release 0.1
|
22 | */
|
22 | */
|
23 | 23 | ||
24 | /**
|
24 | /**
|
25 | * base class
|
25 | * base class
|
26 | */
|
26 | */
|
27 | require_once 'PEAR/Command/Common.php'; |
27 | require_once 'PEAR/Command/Common.php'; |
28 | 28 | ||
29 | /**
|
29 | /**
|
30 | * PEAR commands for registry manipulation
|
30 | * PEAR commands for registry manipulation
|
31 | *
|
31 | *
|
32 | * @category pear
|
32 | * @category pear
|
33 | * @package PEAR
|
33 | * @package PEAR
|
34 | * @author Stig Bakken <ssb@php.net>
|
34 | * @author Stig Bakken <ssb@php.net>
|
35 | * @author Greg Beaver <cellog@php.net>
|
35 | * @author Greg Beaver <cellog@php.net>
|
36 | * @copyright 1997-2008 The PHP Group
|
36 | * @copyright 1997-2008 The PHP Group
|
37 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
37 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
38 | * @version Release: 1.7.2
|
38 | * @version Release: 1.7.2
|
39 | * @link http://pear.php.net/package/PEAR
|
39 | * @link http://pear.php.net/package/PEAR
|
40 | * @since Class available since Release 0.1
|
40 | * @since Class available since Release 0.1
|
41 | */
|
41 | */
|
42 | class PEAR_Command_Registry extends PEAR_Command_Common |
42 | class PEAR_Command_Registry extends PEAR_Command_Common |
43 | {
|
43 | {
|
44 | // {{{ properties
|
44 | // {{{ properties
|
45 | 45 | ||
46 | var $commands = array( |
46 | var $commands = array( |
47 | 'list' => array( |
47 | 'list' => array( |
48 | 'summary' => 'List Installed Packages In The Default Channel', |
48 | 'summary' => 'List Installed Packages In The Default Channel', |
49 | 'function' => 'doList', |
49 | 'function' => 'doList', |
50 | 'shortcut' => 'l', |
50 | 'shortcut' => 'l', |
51 | 'options' => array( |
51 | 'options' => array( |
52 | 'channel' => array( |
52 | 'channel' => array( |
53 | 'shortopt' => 'c', |
53 | 'shortopt' => 'c', |
54 | 'doc' => 'list installed packages from this channel', |
54 | 'doc' => 'list installed packages from this channel', |
55 | 'arg' => 'CHAN', |
55 | 'arg' => 'CHAN', |
56 | ), |
56 | ), |
57 | 'allchannels' => array( |
57 | 'allchannels' => array( |
58 | 'shortopt' => 'a', |
58 | 'shortopt' => 'a', |
59 | 'doc' => 'list installed packages from all channels', |
59 | 'doc' => 'list installed packages from all channels', |
60 | ), |
60 | ), |
61 | 'channelinfo' => array( |
61 | 'channelinfo' => array( |
62 | 'shortopt' => 'i', |
62 | 'shortopt' => 'i', |
63 | 'doc' => 'output fully channel-aware data, even on failure', |
63 | 'doc' => 'output fully channel-aware data, even on failure', |
64 | ), |
64 | ), |
65 | ), |
65 | ), |
66 | 'doc' => '<package> |
66 | 'doc' => '<package> |
67 | If invoked without parameters, this command lists the PEAR packages
|
67 | If invoked without parameters, this command lists the PEAR packages
|
68 | installed in your php_dir ({config php_dir}). With a parameter, it
|
68 | installed in your php_dir ({config php_dir}). With a parameter, it
|
69 | lists the files in a package.
|
69 | lists the files in a package.
|
70 | ', |
70 | ', |
71 | ), |
71 | ), |
72 | 'list-files' => array( |
72 | 'list-files' => array( |
73 | 'summary' => 'List Files In Installed Package', |
73 | 'summary' => 'List Files In Installed Package', |
74 | 'function' => 'doFileList', |
74 | 'function' => 'doFileList', |
75 | 'shortcut' => 'fl', |
75 | 'shortcut' => 'fl', |
76 | 'options' => array(), |
76 | 'options' => array(), |
77 | 'doc' => '<package> |
77 | 'doc' => '<package> |
78 | List the files in an installed package.
|
78 | List the files in an installed package.
|
79 | '
|
79 | '
|
80 | ), |
80 | ), |
81 | 'shell-test' => array( |
81 | 'shell-test' => array( |
82 | 'summary' => 'Shell Script Test', |
82 | 'summary' => 'Shell Script Test', |
83 | 'function' => 'doShellTest', |
83 | 'function' => 'doShellTest', |
84 | 'shortcut' => 'st', |
84 | 'shortcut' => 'st', |
85 | 'options' => array(), |
85 | 'options' => array(), |
86 | 'doc' => '<package> [[relation] version] |
86 | 'doc' => '<package> [[relation] version] |
87 | Tests if a package is installed in the system. Will exit(1) if it is not.
|
87 | Tests if a package is installed in the system. Will exit(1) if it is not.
|
88 | <relation> The version comparison operator. One of:
|
88 | <relation> The version comparison operator. One of:
|
89 | <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
|
89 | <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
|
90 | <version> The version to compare with
|
90 | <version> The version to compare with
|
91 | '), |
91 | '), |
92 | 'info' => array( |
92 | 'info' => array( |
93 | 'summary' => 'Display information about a package', |
93 | 'summary' => 'Display information about a package', |
94 | 'function' => 'doInfo', |
94 | 'function' => 'doInfo', |
95 | 'shortcut' => 'in', |
95 | 'shortcut' => 'in', |
96 | 'options' => array(), |
96 | 'options' => array(), |
97 | 'doc' => '<package> |
97 | 'doc' => '<package> |
98 | Displays information about a package. The package argument may be a
|
98 | Displays information about a package. The package argument may be a
|
99 | local package file, an URL to a package file, or the name of an
|
99 | local package file, an URL to a package file, or the name of an
|
100 | installed package.'
|
100 | installed package.'
|
101 | )
|
101 | )
|
102 | ); |
102 | ); |
103 | 103 | ||
104 | // }}}
|
104 | // }}}
|
105 | // {{{ constructor
|
105 | // {{{ constructor
|
106 | 106 | ||
107 | /**
|
107 | /**
|
108 | * PEAR_Command_Registry constructor.
|
108 | * PEAR_Command_Registry constructor.
|
109 | *
|
109 | *
|
110 | * @access public
|
110 | * @access public
|
111 | */
|
111 | */
|
112 | function PEAR_Command_Registry(&$ui, &$config) |
112 | function PEAR_Command_Registry(&$ui, &$config) |
113 | {
|
113 | {
|
114 | parent::PEAR_Command_Common($ui, $config); |
114 | parent::PEAR_Command_Common($ui, $config); |
115 | }
|
115 | }
|
116 | 116 | ||
117 | // }}}
|
117 | // }}}
|
118 | 118 | ||
119 | // {{{ doList()
|
119 | // {{{ doList()
|
120 | 120 | ||
121 | function _sortinfo($a, $b) |
121 | function _sortinfo($a, $b) |
122 | {
|
122 | {
|
123 | $apackage = isset($a['package']) ? $a['package'] : $a['name']; |
123 | $apackage = isset($a['package']) ? $a['package'] : $a['name']; |
124 | $bpackage = isset($b['package']) ? $b['package'] : $b['name']; |
124 | $bpackage = isset($b['package']) ? $b['package'] : $b['name']; |
125 | return strcmp($apackage, $bpackage); |
125 | return strcmp($apackage, $bpackage); |
126 | }
|
126 | }
|
127 | 127 | ||
128 | function doList($command, $options, $params) |
128 | function doList($command, $options, $params) |
129 | {
|
129 | {
|
130 | $reg = &$this->config->getRegistry(); |
130 | $reg = &$this->config->getRegistry(); |
131 | $channelinfo = isset($options['channelinfo']); |
131 | $channelinfo = isset($options['channelinfo']); |
132 | if (isset($options['allchannels']) && !$channelinfo) { |
132 | if (isset($options['allchannels']) && !$channelinfo) { |
133 | return $this->doListAll($command, array(), $params); |
133 | return $this->doListAll($command, array(), $params); |
134 | }
|
134 | }
|
135 | if (isset($options['allchannels']) && $channelinfo) { |
135 | if (isset($options['allchannels']) && $channelinfo) { |
136 | // allchannels with $channelinfo
|
136 | // allchannels with $channelinfo
|
137 | unset($options['allchannels']); |
137 | unset($options['allchannels']); |
138 | $channels = $reg->getChannels(); |
138 | $channels = $reg->getChannels(); |
139 | $errors = array(); |
139 | $errors = array(); |
140 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
140 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
141 | foreach ($channels as $channel) { |
141 | foreach ($channels as $channel) { |
142 | $options['channel'] = $channel->getName(); |
142 | $options['channel'] = $channel->getName(); |
143 | $ret = $this->doList($command, $options, $params); |
143 | $ret = $this->doList($command, $options, $params); |
144 | 144 | ||
145 | if (PEAR::isError($ret)) { |
145 | if (PEAR::isError($ret)) { |
146 | $errors[] = $ret; |
146 | $errors[] = $ret; |
147 | }
|
147 | }
|
148 | }
|
148 | }
|
149 | PEAR::staticPopErrorHandling(); |
149 | PEAR::staticPopErrorHandling(); |
150 | if (count($errors)) { |
150 | if (count($errors)) { |
151 | // for now, only give first error
|
151 | // for now, only give first error
|
152 | return PEAR::raiseError($errors[0]); |
152 | return PEAR::raiseError($errors[0]); |
153 | }
|
153 | }
|
154 | return true; |
154 | return true; |
155 | }
|
155 | }
|
156 | 156 | ||
157 | if (count($params) == 1) { |
157 | if (count($params) == 1) { |
158 | return $this->doFileList($command, $options, $params); |
158 | return $this->doFileList($command, $options, $params); |
159 | }
|
159 | }
|
160 | if (isset($options['channel'])) { |
160 | if (isset($options['channel'])) { |
161 | if ($reg->channelExists($options['channel'])) { |
161 | if ($reg->channelExists($options['channel'])) { |
162 | $channel = $reg->channelName($options['channel']); |
162 | $channel = $reg->channelName($options['channel']); |
163 | } else { |
163 | } else { |
164 | return $this->raiseError('Channel "' . $options['channel'] .'" does not exist'); |
164 | return $this->raiseError('Channel "' . $options['channel'] .'" does not exist'); |
165 | }
|
165 | }
|
166 | } else { |
166 | } else { |
167 | $channel = $this->config->get('default_channel'); |
167 | $channel = $this->config->get('default_channel'); |
168 | }
|
168 | }
|
169 | $installed = $reg->packageInfo(null, null, $channel); |
169 | $installed = $reg->packageInfo(null, null, $channel); |
170 | usort($installed, array(&$this, '_sortinfo')); |
170 | usort($installed, array(&$this, '_sortinfo')); |
171 | 171 | ||
172 | $data = array( |
172 | $data = array( |
173 | 'caption' => 'Installed packages, channel ' . |
173 | 'caption' => 'Installed packages, channel ' . |
174 | $channel . ':', |
174 | $channel . ':', |
175 | 'border' => true, |
175 | 'border' => true, |
176 | 'headline' => array('Package', 'Version', 'State'), |
176 | 'headline' => array('Package', 'Version', 'State'), |
177 | 'channel' => $channel, |
177 | 'channel' => $channel, |
178 | ); |
178 | ); |
179 | if ($channelinfo) { |
179 | if ($channelinfo) { |
180 | $data['headline'] = array('Channel', 'Package', 'Version', 'State'); |
180 | $data['headline'] = array('Channel', 'Package', 'Version', 'State'); |
181 | }
|
181 | }
|
182 | 182 | ||
183 | if (count($installed) && !isset($data['data'])) { |
183 | if (count($installed) && !isset($data['data'])) { |
184 | $data['data'] = array(); |
184 | $data['data'] = array(); |
185 | }
|
185 | }
|
186 | 186 | ||
187 | foreach ($installed as $package) { |
187 | foreach ($installed as $package) { |
188 | $pobj = $reg->getPackage(isset($package['package']) ? |
188 | $pobj = $reg->getPackage(isset($package['package']) ? |
189 | $package['package'] : $package['name'], $channel); |
189 | $package['package'] : $package['name'], $channel); |
190 | if ($channelinfo) { |
190 | if ($channelinfo) { |
191 | $packageinfo = array($pobj->getChannel(), $pobj->getPackage(), $pobj->getVersion(), |
191 | $packageinfo = array($pobj->getChannel(), $pobj->getPackage(), $pobj->getVersion(), |
192 | $pobj->getState() ? $pobj->getState() : null); |
192 | $pobj->getState() ? $pobj->getState() : null); |
193 | } else { |
193 | } else { |
194 | $packageinfo = array($pobj->getPackage(), $pobj->getVersion(), |
194 | $packageinfo = array($pobj->getPackage(), $pobj->getVersion(), |
195 | $pobj->getState() ? $pobj->getState() : null); |
195 | $pobj->getState() ? $pobj->getState() : null); |
196 | }
|
196 | }
|
197 | $data['data'][] = $packageinfo; |
197 | $data['data'][] = $packageinfo; |
198 | }
|
198 | }
|
199 | if (count($installed) == 0) { |
199 | if (count($installed) == 0) { |
200 | if (!$channelinfo) { |
200 | if (!$channelinfo) { |
201 | $data = '(no packages installed from channel ' . $channel . ')'; |
201 | $data = '(no packages installed from channel ' . $channel . ')'; |
202 | } else { |
202 | } else { |
203 | $data = array( |
203 | $data = array( |
204 | 'caption' => 'Installed packages, channel ' . |
204 | 'caption' => 'Installed packages, channel ' . |
205 | $channel . ':', |
205 | $channel . ':', |
206 | 'border' => true, |
206 | 'border' => true, |
207 | 'channel' => $channel, |
207 | 'channel' => $channel, |
208 | 'data' => '(no packages installed)', |
208 | 'data' => '(no packages installed)', |
209 | ); |
209 | ); |
210 | }
|
210 | }
|
211 | }
|
211 | }
|
212 | $this->ui->outputData($data, $command); |
212 | $this->ui->outputData($data, $command); |
213 | return true; |
213 | return true; |
214 | }
|
214 | }
|
215 | 215 | ||
216 | function doListAll($command, $options, $params) |
216 | function doListAll($command, $options, $params) |
217 | {
|
217 | {
|
218 | // This duplicate code is deprecated over
|
218 | // This duplicate code is deprecated over
|
219 | // list --channelinfo, which gives identical
|
219 | // list --channelinfo, which gives identical
|
220 | // output for list and list --allchannels.
|
220 | // output for list and list --allchannels.
|
221 | $reg = &$this->config->getRegistry(); |
221 | $reg = &$this->config->getRegistry(); |
222 | $installed = $reg->packageInfo(null, null, null); |
222 | $installed = $reg->packageInfo(null, null, null); |
223 | foreach ($installed as $channel => $packages) { |
223 | foreach ($installed as $channel => $packages) { |
224 | usort($packages, array($this, '_sortinfo')); |
224 | usort($packages, array($this, '_sortinfo')); |
225 | $data = array( |
225 | $data = array( |
226 | 'caption' => 'Installed packages, channel ' . $channel . ':', |
226 | 'caption' => 'Installed packages, channel ' . $channel . ':', |
227 | 'border' => true, |
227 | 'border' => true, |
228 | 'headline' => array('Package', 'Version', 'State'), |
228 | 'headline' => array('Package', 'Version', 'State'), |
229 | 'channel' => $channel |
229 | 'channel' => $channel |
230 | ); |
230 | ); |
231 | foreach ($packages as $package) { |
231 | foreach ($packages as $package) { |
232 | $pobj = $reg->getPackage(isset($package['package']) ? |
232 | $pobj = $reg->getPackage(isset($package['package']) ? |
233 | $package['package'] : $package['name'], $channel); |
233 | $package['package'] : $package['name'], $channel); |
234 | $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), |
234 | $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), |
235 | $pobj->getState() ? $pobj->getState() : null); |
235 | $pobj->getState() ? $pobj->getState() : null); |
236 | }
|
236 | }
|
237 | if (count($packages)==0) { |
237 | if (count($packages)==0) { |
238 | $data = array( |
238 | $data = array( |
239 | 'caption' => 'Installed packages, channel ' . $channel . ':', |
239 | 'caption' => 'Installed packages, channel ' . $channel . ':', |
240 | 'border' => true, |
240 | 'border' => true, |
241 | 'data' => array(array('(no packages installed)')), |
241 | 'data' => array(array('(no packages installed)')), |
242 | 'channel' => $channel |
242 | 'channel' => $channel |
243 | ); |
243 | ); |
244 | }
|
244 | }
|
245 | $this->ui->outputData($data, $command); |
245 | $this->ui->outputData($data, $command); |
246 | }
|
246 | }
|
247 | return true; |
247 | return true; |
248 | }
|
248 | }
|
249 | 249 | ||
250 | function doFileList($command, $options, $params) |
250 | function doFileList($command, $options, $params) |
251 | {
|
251 | {
|
252 | if (count($params) != 1) { |
252 | if (count($params) != 1) { |
253 | return $this->raiseError('list-files expects 1 parameter'); |
253 | return $this->raiseError('list-files expects 1 parameter'); |
254 | }
|
254 | }
|
255 | $reg = &$this->config->getRegistry(); |
255 | $reg = &$this->config->getRegistry(); |
256 | $fp = false; |
256 | $fp = false; |
257 | if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], |
257 | if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], |
258 | 'r'))) { |
258 | 'r'))) { |
259 | if ($fp) { |
259 | if ($fp) { |
260 | fclose($fp); |
260 | fclose($fp); |
261 | }
|
261 | }
|
262 | if (!class_exists('PEAR_PackageFile')) { |
262 | if (!class_exists('PEAR_PackageFile')) { |
263 | require_once 'PEAR/PackageFile.php'; |
263 | require_once 'PEAR/PackageFile.php'; |
264 | }
|
264 | }
|
265 | $pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
265 | $pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
266 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
266 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
267 | $info = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
267 | $info = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
268 | PEAR::staticPopErrorHandling(); |
268 | PEAR::staticPopErrorHandling(); |
269 | $headings = array('Package File', 'Install Path'); |
269 | $headings = array('Package File', 'Install Path'); |
270 | $installed = false; |
270 | $installed = false; |
271 | } else { |
271 | } else { |
272 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
272 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
273 | $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
273 | $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
274 | PEAR::staticPopErrorHandling(); |
274 | PEAR::staticPopErrorHandling(); |
275 | if (PEAR::isError($parsed)) { |
275 | if (PEAR::isError($parsed)) { |
276 | return $this->raiseError($parsed); |
276 | return $this->raiseError($parsed); |
277 | }
|
277 | }
|
278 | $info = &$reg->getPackage($parsed['package'], $parsed['channel']); |
278 | $info = &$reg->getPackage($parsed['package'], $parsed['channel']); |
279 | $headings = array('Type', 'Install Path'); |
279 | $headings = array('Type', 'Install Path'); |
280 | $installed = true; |
280 | $installed = true; |
281 | }
|
281 | }
|
282 | if (PEAR::isError($info)) { |
282 | if (PEAR::isError($info)) { |
283 | return $this->raiseError($info); |
283 | return $this->raiseError($info); |
284 | }
|
284 | }
|
285 | if ($info === null) { |
285 | if ($info === null) { |
286 | return $this->raiseError("`$params[0]' not installed"); |
286 | return $this->raiseError("`$params[0]' not installed"); |
287 | }
|
287 | }
|
288 | $list = ($info->getPackagexmlVersion() == '1.0' || $installed) ? |
288 | $list = ($info->getPackagexmlVersion() == '1.0' || $installed) ? |
289 | $info->getFilelist() : $info->getContents(); |
289 | $info->getFilelist() : $info->getContents(); |
290 | if ($installed) { |
290 | if ($installed) { |
291 | $caption = 'Installed Files For ' . $params[0]; |
291 | $caption = 'Installed Files For ' . $params[0]; |
292 | } else { |
292 | } else { |
293 | $caption = 'Contents of ' . basename($params[0]); |
293 | $caption = 'Contents of ' . basename($params[0]); |
294 | }
|
294 | }
|
295 | $data = array( |
295 | $data = array( |
296 | 'caption' => $caption, |
296 | 'caption' => $caption, |
297 | 'border' => true, |
297 | 'border' => true, |
298 | 'headline' => $headings); |
298 | 'headline' => $headings); |
299 | if ($info->getPackagexmlVersion() == '1.0' || $installed) { |
299 | if ($info->getPackagexmlVersion() == '1.0' || $installed) { |
300 | foreach ($list as $file => $att) { |
300 | foreach ($list as $file => $att) { |
301 | if ($installed) { |
301 | if ($installed) { |
302 | if (empty($att['installed_as'])) { |
302 | if (empty($att['installed_as'])) { |
303 | continue; |
303 | continue; |
304 | }
|
304 | }
|
305 | $data['data'][] = array($att['role'], $att['installed_as']); |
305 | $data['data'][] = array($att['role'], $att['installed_as']); |
306 | } else { |
306 | } else { |
307 | if (isset($att['baseinstalldir']) && !in_array($att['role'], |
307 | if (isset($att['baseinstalldir']) && !in_array($att['role'], |
308 | array('test', 'data', 'doc'))) { |
308 | array('test', 'data', 'doc'))) { |
309 | $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . |
309 | $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . |
310 | $file; |
310 | $file; |
311 | } else { |
311 | } else { |
312 | $dest = $file; |
312 | $dest = $file; |
313 | }
|
313 | }
|
314 | switch ($att['role']) { |
314 | switch ($att['role']) { |
315 | case 'test': |
315 | case 'test': |
316 | case 'data': |
316 | case 'data': |
317 | case 'doc': |
317 | case 'doc': |
318 | $role = $att['role']; |
318 | $role = $att['role']; |
319 | if ($role == 'test') { |
319 | if ($role == 'test') { |
320 | $role .= 's'; |
320 | $role .= 's'; |
321 | }
|
321 | }
|
322 | $dest = $this->config->get($role . '_dir') . DIRECTORY_SEPARATOR . |
322 | $dest = $this->config->get($role . '_dir') . DIRECTORY_SEPARATOR . |
323 | $info->getPackage() . DIRECTORY_SEPARATOR . $dest; |
323 | $info->getPackage() . DIRECTORY_SEPARATOR . $dest; |
324 | break; |
324 | break; |
325 | case 'php': |
325 | case 'php': |
326 | default: |
326 | default: |
327 | $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . |
327 | $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . |
328 | $dest; |
328 | $dest; |
329 | }
|
329 | }
|
330 | $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; |
330 | $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; |
331 | $dest = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"), |
331 | $dest = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"), |
332 | array(DIRECTORY_SEPARATOR, |
332 | array(DIRECTORY_SEPARATOR, |
333 | DIRECTORY_SEPARATOR, |
333 | DIRECTORY_SEPARATOR, |
334 | DIRECTORY_SEPARATOR), |
334 | DIRECTORY_SEPARATOR), |
335 | $dest); |
335 | $dest); |
336 | $file = preg_replace('!/+!', '/', $file); |
336 | $file = preg_replace('!/+!', '/', $file); |
337 | $data['data'][] = array($file, $dest); |
337 | $data['data'][] = array($file, $dest); |
338 | }
|
338 | }
|
339 | }
|
339 | }
|
340 | } else { // package.xml 2.0, not installed |
340 | } else { // package.xml 2.0, not installed |
341 | if (!isset($list['dir']['file'][0])) { |
341 | if (!isset($list['dir']['file'][0])) { |
342 | $list['dir']['file'] = array($list['dir']['file']); |
342 | $list['dir']['file'] = array($list['dir']['file']); |
343 | }
|
343 | }
|
344 | foreach ($list['dir']['file'] as $att) { |
344 | foreach ($list['dir']['file'] as $att) { |
345 | $att = $att['attribs']; |
345 | $att = $att['attribs']; |
346 | $file = $att['name']; |
346 | $file = $att['name']; |
347 | $role = &PEAR_Installer_Role::factory($info, $att['role'], $this->config); |
347 | $role = &PEAR_Installer_Role::factory($info, $att['role'], $this->config); |
348 | $role->setup($this, $info, $att, $file); |
348 | $role->setup($this, $info, $att, $file); |
349 | if (!$role->isInstallable()) { |
349 | if (!$role->isInstallable()) { |
350 | $dest = '(not installable)'; |
350 | $dest = '(not installable)'; |
351 | } else { |
351 | } else { |
352 | $dest = $role->processInstallation($info, $att, $file, ''); |
352 | $dest = $role->processInstallation($info, $att, $file, ''); |
353 | if (PEAR::isError($dest)) { |
353 | if (PEAR::isError($dest)) { |
354 | $dest = '(Unknown role "' . $att['role'] . ')'; |
354 | $dest = '(Unknown role "' . $att['role'] . ')'; |
355 | } else { |
355 | } else { |
356 | list(,, $dest) = $dest; |
356 | list(,, $dest) = $dest; |
357 | }
|
357 | }
|
358 | }
|
358 | }
|
359 | $data['data'][] = array($file, $dest); |
359 | $data['data'][] = array($file, $dest); |
360 | }
|
360 | }
|
361 | }
|
361 | }
|
362 | $this->ui->outputData($data, $command); |
362 | $this->ui->outputData($data, $command); |
363 | return true; |
363 | return true; |
364 | }
|
364 | }
|
365 | 365 | ||
366 | // }}}
|
366 | // }}}
|
367 | // {{{ doShellTest()
|
367 | // {{{ doShellTest()
|
368 | 368 | ||
369 | function doShellTest($command, $options, $params) |
369 | function doShellTest($command, $options, $params) |
370 | {
|
370 | {
|
371 | if (count($params) < 1) { |
371 | if (count($params) < 1) { |
372 | return PEAR::raiseError('ERROR, usage: pear shell-test packagename [[relation] version]'); |
372 | return PEAR::raiseError('ERROR, usage: pear shell-test packagename [[relation] version]'); |
373 | }
|
373 | }
|
374 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
374 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
375 | $reg = &$this->config->getRegistry(); |
375 | $reg = &$this->config->getRegistry(); |
376 | $info = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
376 | $info = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
377 | if (PEAR::isError($info)) { |
377 | if (PEAR::isError($info)) { |
378 | exit(1); // invalid package name |
378 | exit(1); // invalid package name |
379 | }
|
379 | }
|
380 | $package = $info['package']; |
380 | $package = $info['package']; |
381 | $channel = $info['channel']; |
381 | $channel = $info['channel']; |
382 | // "pear shell-test Foo"
|
382 | // "pear shell-test Foo"
|
383 | if (!$reg->packageExists($package, $channel)) { |
383 | if (!$reg->packageExists($package, $channel)) { |
384 | if ($channel == 'pecl.php.net') { |
384 | if ($channel == 'pecl.php.net') { |
385 | if ($reg->packageExists($package, 'pear.php.net')) { |
385 | if ($reg->packageExists($package, 'pear.php.net')) { |
386 | $channel = 'pear.php.net'; // magically change channels for extensions |
386 | $channel = 'pear.php.net'; // magically change channels for extensions |
387 | }
|
387 | }
|
388 | }
|
388 | }
|
389 | }
|
389 | }
|
390 | if (sizeof($params) == 1) { |
390 | if (sizeof($params) == 1) { |
391 | if (!$reg->packageExists($package, $channel)) { |
391 | if (!$reg->packageExists($package, $channel)) { |
392 | exit(1); |
392 | exit(1); |
393 | }
|
393 | }
|
394 | // "pear shell-test Foo 1.0"
|
394 | // "pear shell-test Foo 1.0"
|
395 | } elseif (sizeof($params) == 2) { |
395 | } elseif (sizeof($params) == 2) { |
396 | $v = $reg->packageInfo($package, 'version', $channel); |
396 | $v = $reg->packageInfo($package, 'version', $channel); |
397 | if (!$v || !version_compare("$v", "{$params[1]}", "ge")) { |
397 | if (!$v || !version_compare("$v", "{$params[1]}", "ge")) { |
398 | exit(1); |
398 | exit(1); |
399 | }
|
399 | }
|
400 | // "pear shell-test Foo ge 1.0"
|
400 | // "pear shell-test Foo ge 1.0"
|
401 | } elseif (sizeof($params) == 3) { |
401 | } elseif (sizeof($params) == 3) { |
402 | $v = $reg->packageInfo($package, 'version', $channel); |
402 | $v = $reg->packageInfo($package, 'version', $channel); |
403 | if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) { |
403 | if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) { |
404 | exit(1); |
404 | exit(1); |
405 | }
|
405 | }
|
406 | } else { |
406 | } else { |
407 | PEAR::staticPopErrorHandling(); |
407 | PEAR::staticPopErrorHandling(); |
408 | $this->raiseError("$command: expects 1 to 3 parameters"); |
408 | $this->raiseError("$command: expects 1 to 3 parameters"); |
409 | exit(1); |
409 | exit(1); |
410 | }
|
410 | }
|
411 | }
|
411 | }
|
412 | 412 | ||
413 | // }}}
|
413 | // }}}
|
414 | // {{{ doInfo
|
414 | // {{{ doInfo
|
415 | 415 | ||
416 | function doInfo($command, $options, $params) |
416 | function doInfo($command, $options, $params) |
417 | {
|
417 | {
|
418 | if (count($params) != 1) { |
418 | if (count($params) != 1) { |
419 | return $this->raiseError('pear info expects 1 parameter'); |
419 | return $this->raiseError('pear info expects 1 parameter'); |
420 | }
|
420 | }
|
421 | $info = $fp = false; |
421 | $info = $fp = false; |
422 | $reg = &$this->config->getRegistry(); |
422 | $reg = &$this->config->getRegistry(); |
423 | if ((file_exists($params[0]) && is_file($params[0]) && !is_dir($params[0])) || $fp = @fopen($params[0], 'r')) { |
423 | if ((file_exists($params[0]) && is_file($params[0]) && !is_dir($params[0])) || $fp = @fopen($params[0], 'r')) { |
424 | if ($fp) { |
424 | if ($fp) { |
425 | fclose($fp); |
425 | fclose($fp); |
426 | }
|
426 | }
|
427 | if (!class_exists('PEAR_PackageFile')) { |
427 | if (!class_exists('PEAR_PackageFile')) { |
428 | require_once 'PEAR/PackageFile.php'; |
428 | require_once 'PEAR/PackageFile.php'; |
429 | }
|
429 | }
|
430 | $pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
430 | $pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
431 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
431 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
432 | $obj = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
432 | $obj = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
433 | PEAR::staticPopErrorHandling(); |
433 | PEAR::staticPopErrorHandling(); |
434 | if (PEAR::isError($obj)) { |
434 | if (PEAR::isError($obj)) { |
435 | $uinfo = $obj->getUserInfo(); |
435 | $uinfo = $obj->getUserInfo(); |
436 | if (is_array($uinfo)) { |
436 | if (is_array($uinfo)) { |
437 | foreach ($uinfo as $message) { |
437 | foreach ($uinfo as $message) { |
438 | if (is_array($message)) { |
438 | if (is_array($message)) { |
439 | $message = $message['message']; |
439 | $message = $message['message']; |
440 | }
|
440 | }
|
441 | $this->ui->outputData($message); |
441 | $this->ui->outputData($message); |
442 | }
|
442 | }
|
443 | }
|
443 | }
|
444 | return $this->raiseError($obj); |
444 | return $this->raiseError($obj); |
445 | }
|
445 | }
|
446 | if ($obj->getPackagexmlVersion() == '1.0') { |
446 | if ($obj->getPackagexmlVersion() == '1.0') { |
447 | $info = $obj->toArray(); |
447 | $info = $obj->toArray(); |
448 | } else { |
448 | } else { |
449 | return $this->_doInfo2($command, $options, $params, $obj, false); |
449 | return $this->_doInfo2($command, $options, $params, $obj, false); |
450 | }
|
450 | }
|
451 | } else { |
451 | } else { |
452 | $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
452 | $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
453 | if (PEAR::isError($parsed)) { |
453 | if (PEAR::isError($parsed)) { |
454 | return $this->raiseError($parsed); |
454 | return $this->raiseError($parsed); |
455 | }
|
455 | }
|
456 | $package = $parsed['package']; |
456 | $package = $parsed['package']; |
457 | $channel = $parsed['channel']; |
457 | $channel = $parsed['channel']; |
458 | $info = $reg->packageInfo($package, null, $channel); |
458 | $info = $reg->packageInfo($package, null, $channel); |
459 | if (isset($info['old'])) { |
459 | if (isset($info['old'])) { |
460 | $obj = $reg->getPackage($package, $channel); |
460 | $obj = $reg->getPackage($package, $channel); |
461 | return $this->_doInfo2($command, $options, $params, $obj, true); |
461 | return $this->_doInfo2($command, $options, $params, $obj, true); |
462 | }
|
462 | }
|
463 | }
|
463 | }
|
464 | if (PEAR::isError($info)) { |
464 | if (PEAR::isError($info)) { |
465 | return $info; |
465 | return $info; |
466 | }
|
466 | }
|
467 | if (empty($info)) { |
467 | if (empty($info)) { |
468 | $this->raiseError("No information found for `$params[0]'"); |
468 | $this->raiseError("No information found for `$params[0]'"); |
469 | return; |
469 | return; |
470 | }
|
470 | }
|
471 | unset($info['filelist']); |
471 | unset($info['filelist']); |
472 | unset($info['dirtree']); |
472 | unset($info['dirtree']); |
473 | unset($info['changelog']); |
473 | unset($info['changelog']); |
474 | if (isset($info['xsdversion'])) { |
474 | if (isset($info['xsdversion'])) { |
475 | $info['package.xml version'] = $info['xsdversion']; |
475 | $info['package.xml version'] = $info['xsdversion']; |
476 | unset($info['xsdversion']); |
476 | unset($info['xsdversion']); |
477 | }
|
477 | }
|
478 | if (isset($info['packagerversion'])) { |
478 | if (isset($info['packagerversion'])) { |
479 | $info['packaged with PEAR version'] = $info['packagerversion']; |
479 | $info['packaged with PEAR version'] = $info['packagerversion']; |
480 | unset($info['packagerversion']); |
480 | unset($info['packagerversion']); |
481 | }
|
481 | }
|
482 | $keys = array_keys($info); |
482 | $keys = array_keys($info); |
483 | $longtext = array('description', 'summary'); |
483 | $longtext = array('description', 'summary'); |
484 | foreach ($keys as $key) { |
484 | foreach ($keys as $key) { |
485 | if (is_array($info[$key])) { |
485 | if (is_array($info[$key])) { |
486 | switch ($key) { |
486 | switch ($key) { |
487 | case 'maintainers': { |
487 | case 'maintainers': { |
488 | $i = 0; |
488 | $i = 0; |
489 | $mstr = ''; |
489 | $mstr = ''; |
490 | foreach ($info[$key] as $m) { |
490 | foreach ($info[$key] as $m) { |
491 | if ($i++ > 0) { |
491 | if ($i++ > 0) { |
492 | $mstr .= "\n"; |
492 | $mstr .= "\n"; |
493 | }
|
493 | }
|
494 | $mstr .= $m['name'] . " <"; |
494 | $mstr .= $m['name'] . " <"; |
495 | if (isset($m['email'])) { |
495 | if (isset($m['email'])) { |
496 | $mstr .= $m['email']; |
496 | $mstr .= $m['email']; |
497 | } else { |
497 | } else { |
498 | $mstr .= $m['handle'] . '@php.net'; |
498 | $mstr .= $m['handle'] . '@php.net'; |
499 | }
|
499 | }
|
500 | $mstr .= "> ($m[role])"; |
500 | $mstr .= "> ($m[role])"; |
501 | }
|
501 | }
|
502 | $info[$key] = $mstr; |
502 | $info[$key] = $mstr; |
503 | break; |
503 | break; |
504 | }
|
504 | }
|
505 | case 'release_deps': { |
505 | case 'release_deps': { |
506 | $i = 0; |
506 | $i = 0; |
507 | $dstr = ''; |
507 | $dstr = ''; |
508 | foreach ($info[$key] as $d) { |
508 | foreach ($info[$key] as $d) { |
509 | if (isset($this->_deps_rel_trans[$d['rel']])) { |
509 | if (isset($this->_deps_rel_trans[$d['rel']])) { |
510 | $rel = $this->_deps_rel_trans[$d['rel']]; |
510 | $rel = $this->_deps_rel_trans[$d['rel']]; |
511 | } else { |
511 | } else { |
512 | $rel = $d['rel']; |
512 | $rel = $d['rel']; |
513 | }
|
513 | }
|
514 | if (isset($this->_deps_type_trans[$d['type']])) { |
514 | if (isset($this->_deps_type_trans[$d['type']])) { |
515 | $type = ucfirst($this->_deps_type_trans[$d['type']]); |
515 | $type = ucfirst($this->_deps_type_trans[$d['type']]); |
516 | } else { |
516 | } else { |
517 | $type = $d['type']; |
517 | $type = $d['type']; |
518 | }
|
518 | }
|
519 | if (isset($d['name'])) { |
519 | if (isset($d['name'])) { |
520 | $name = $d['name'] . ' '; |
520 | $name = $d['name'] . ' '; |
521 | } else { |
521 | } else { |
522 | $name = ''; |
522 | $name = ''; |
523 | }
|
523 | }
|
524 | if (isset($d['version'])) { |
524 | if (isset($d['version'])) { |
525 | $version = $d['version'] . ' '; |
525 | $version = $d['version'] . ' '; |
526 | } else { |
526 | } else { |
527 | $version = ''; |
527 | $version = ''; |
528 | }
|
528 | }
|
529 | if (isset($d['optional']) && $d['optional'] == 'yes') { |
529 | if (isset($d['optional']) && $d['optional'] == 'yes') { |
530 | $optional = ' (optional)'; |
530 | $optional = ' (optional)'; |
531 | } else { |
531 | } else { |
532 | $optional = ''; |
532 | $optional = ''; |
533 | }
|
533 | }
|
534 | $dstr .= "$type $name$rel $version$optional\n"; |
534 | $dstr .= "$type $name$rel $version$optional\n"; |
535 | }
|
535 | }
|
536 | $info[$key] = $dstr; |
536 | $info[$key] = $dstr; |
537 | break; |
537 | break; |
538 | }
|
538 | }
|
539 | case 'provides' : { |
539 | case 'provides' : { |
540 | $debug = $this->config->get('verbose'); |
540 | $debug = $this->config->get('verbose'); |
541 | if ($debug < 2) { |
541 | if ($debug < 2) { |
542 | $pstr = 'Classes: '; |
542 | $pstr = 'Classes: '; |
543 | } else { |
543 | } else { |
544 | $pstr = ''; |
544 | $pstr = ''; |
545 | }
|
545 | }
|
546 | $i = 0; |
546 | $i = 0; |
547 | foreach ($info[$key] as $p) { |
547 | foreach ($info[$key] as $p) { |
548 | if ($debug < 2 && $p['type'] != "class") { |
548 | if ($debug < 2 && $p['type'] != "class") { |
549 | continue; |
549 | continue; |
550 | }
|
550 | }
|
551 | // Only print classes when verbosity mode is < 2
|
551 | // Only print classes when verbosity mode is < 2
|
552 | if ($debug < 2) { |
552 | if ($debug < 2) { |
553 | if ($i++ > 0) { |
553 | if ($i++ > 0) { |
554 | $pstr .= ", "; |
554 | $pstr .= ", "; |
555 | }
|
555 | }
|
556 | $pstr .= $p['name']; |
556 | $pstr .= $p['name']; |
557 | } else { |
557 | } else { |
558 | if ($i++ > 0) { |
558 | if ($i++ > 0) { |
559 | $pstr .= "\n"; |
559 | $pstr .= "\n"; |
560 | }
|
560 | }
|
561 | $pstr .= ucfirst($p['type']) . " " . $p['name']; |
561 | $pstr .= ucfirst($p['type']) . " " . $p['name']; |
562 | if (isset($p['explicit']) && $p['explicit'] == 1) { |
562 | if (isset($p['explicit']) && $p['explicit'] == 1) { |
563 | $pstr .= " (explicit)"; |
563 | $pstr .= " (explicit)"; |
564 | }
|
564 | }
|
565 | }
|
565 | }
|
566 | }
|
566 | }
|
567 | $info[$key] = $pstr; |
567 | $info[$key] = $pstr; |
568 | break; |
568 | break; |
569 | }
|
569 | }
|
570 | case 'configure_options' : { |
570 | case 'configure_options' : { |
571 | foreach ($info[$key] as $i => $p) { |
571 | foreach ($info[$key] as $i => $p) { |
572 | $info[$key][$i] = array_map(null, array_keys($p), array_values($p)); |
572 | $info[$key][$i] = array_map(null, array_keys($p), array_values($p)); |
573 | $info[$key][$i] = array_map(create_function('$a', |
573 | $info[$key][$i] = array_map(create_function('$a', |
574 | 'return join(" = ",$a);'), $info[$key][$i]); |
574 | 'return join(" = ",$a);'), $info[$key][$i]); |
575 | $info[$key][$i] = implode(', ', $info[$key][$i]); |
575 | $info[$key][$i] = implode(', ', $info[$key][$i]); |
576 | }
|
576 | }
|
577 | $info[$key] = implode("\n", $info[$key]); |
577 | $info[$key] = implode("\n", $info[$key]); |
578 | break; |
578 | break; |
579 | }
|
579 | }
|
580 | default: { |
580 | default: { |
581 | $info[$key] = implode(", ", $info[$key]); |
581 | $info[$key] = implode(", ", $info[$key]); |
582 | break; |
582 | break; |
583 | }
|
583 | }
|
584 | }
|
584 | }
|
585 | }
|
585 | }
|
586 | if ($key == '_lastmodified') { |
586 | if ($key == '_lastmodified') { |
587 | $hdate = date('Y-m-d', $info[$key]); |
587 | $hdate = date('Y-m-d', $info[$key]); |
588 | unset($info[$key]); |
588 | unset($info[$key]); |
589 | $info['Last Modified'] = $hdate; |
589 | $info['Last Modified'] = $hdate; |
590 | } elseif ($key == '_lastversion') { |
590 | } elseif ($key == '_lastversion') { |
591 | $info['Previous Installed Version'] = $info[$key] ? $info[$key] : '- None -'; |
591 | $info['Previous Installed Version'] = $info[$key] ? $info[$key] : '- None -'; |
592 | unset($info[$key]); |
592 | unset($info[$key]); |
593 | } else { |
593 | } else { |
594 | $info[$key] = trim($info[$key]); |
594 | $info[$key] = trim($info[$key]); |
595 | if (in_array($key, $longtext)) { |
595 | if (in_array($key, $longtext)) { |
596 | $info[$key] = preg_replace('/ +/', ' ', $info[$key]); |
596 | $info[$key] = preg_replace('/ +/', ' ', $info[$key]); |
597 | }
|
597 | }
|
598 | }
|
598 | }
|
599 | }
|
599 | }
|
600 | $caption = 'About ' . $info['package'] . '-' . $info['version']; |
600 | $caption = 'About ' . $info['package'] . '-' . $info['version']; |
601 | $data = array( |
601 | $data = array( |
602 | 'caption' => $caption, |
602 | 'caption' => $caption, |
603 | 'border' => true); |
603 | 'border' => true); |
604 | foreach ($info as $key => $value) { |
604 | foreach ($info as $key => $value) { |
605 | $key = ucwords(trim(str_replace('_', ' ', $key))); |
605 | $key = ucwords(trim(str_replace('_', ' ', $key))); |
606 | $data['data'][] = array($key, $value); |
606 | $data['data'][] = array($key, $value); |
607 | }
|
607 | }
|
608 | $data['raw'] = $info; |
608 | $data['raw'] = $info; |
609 | 609 | ||
610 | $this->ui->outputData($data, 'package-info'); |
610 | $this->ui->outputData($data, 'package-info'); |
611 | }
|
611 | }
|
612 | 612 | ||
613 | // }}}
|
613 | // }}}
|
614 | 614 | ||
615 | /**
|
615 | /**
|
616 | * @access private
|
616 | * @access private
|
617 | */
|
617 | */
|
618 | function _doInfo2($command, $options, $params, &$obj, $installed) |
618 | function _doInfo2($command, $options, $params, &$obj, $installed) |
619 | {
|
619 | {
|
620 | $reg = &$this->config->getRegistry(); |
620 | $reg = &$this->config->getRegistry(); |
621 | $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' . |
621 | $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' . |
622 | $obj->getVersion(); |
622 | $obj->getVersion(); |
623 | $data = array( |
623 | $data = array( |
624 | 'caption' => $caption, |
624 | 'caption' => $caption, |
625 | 'border' => true); |
625 | 'border' => true); |
626 | switch ($obj->getPackageType()) { |
626 | switch ($obj->getPackageType()) { |
627 | case 'php' : |
627 | case 'php' : |
628 | $release = 'PEAR-style PHP-based Package'; |
628 | $release = 'PEAR-style PHP-based Package'; |
629 | break; |
629 | break; |
630 | case 'extsrc' : |
630 | case 'extsrc' : |
631 | $release = 'PECL-style PHP extension (source code)'; |
631 | $release = 'PECL-style PHP extension (source code)'; |
632 | break; |
632 | break; |
633 | case 'zendextsrc' : |
633 | case 'zendextsrc' : |
634 | $release = 'PECL-style Zend extension (source code)'; |
634 | $release = 'PECL-style Zend extension (source code)'; |
635 | break; |
635 | break; |
636 | case 'extbin' : |
636 | case 'extbin' : |
637 | $release = 'PECL-style PHP extension (binary)'; |
637 | $release = 'PECL-style PHP extension (binary)'; |
638 | break; |
638 | break; |
639 | case 'zendextbin' : |
639 | case 'zendextbin' : |
640 | $release = 'PECL-style Zend extension (binary)'; |
640 | $release = 'PECL-style Zend extension (binary)'; |
641 | break; |
641 | break; |
642 | case 'bundle' : |
642 | case 'bundle' : |
643 | $release = 'Package bundle (collection of packages)'; |
643 | $release = 'Package bundle (collection of packages)'; |
644 | break; |
644 | break; |
645 | }
|
645 | }
|
646 | $extends = $obj->getExtends(); |
646 | $extends = $obj->getExtends(); |
647 | $extends = $extends ? |
647 | $extends = $extends ? |
648 | $obj->getPackage() . ' (extends ' . $extends . ')' : $obj->getPackage(); |
648 | $obj->getPackage() . ' (extends ' . $extends . ')' : $obj->getPackage(); |
649 | if ($src = $obj->getSourcePackage()) { |
649 | if ($src = $obj->getSourcePackage()) { |
650 | $extends .= ' (source package ' . $src['channel'] . '/' . $src['package'] . ')'; |
650 | $extends .= ' (source package ' . $src['channel'] . '/' . $src['package'] . ')'; |
651 | }
|
651 | }
|
652 | $info = array( |
652 | $info = array( |
653 | 'Release Type' => $release, |
653 | 'Release Type' => $release, |
654 | 'Name' => $extends, |
654 | 'Name' => $extends, |
655 | 'Channel' => $obj->getChannel(), |
655 | 'Channel' => $obj->getChannel(), |
656 | 'Summary' => preg_replace('/ +/', ' ', $obj->getSummary()), |
656 | 'Summary' => preg_replace('/ +/', ' ', $obj->getSummary()), |
657 | 'Description' => preg_replace('/ +/', ' ', $obj->getDescription()), |
657 | 'Description' => preg_replace('/ +/', ' ', $obj->getDescription()), |
658 | ); |
658 | ); |
659 | $info['Maintainers'] = ''; |
659 | $info['Maintainers'] = ''; |
660 | foreach (array('lead', 'developer', 'contributor', 'helper') as $role) { |
660 | foreach (array('lead', 'developer', 'contributor', 'helper') as $role) { |
661 | $leads = $obj->{"get{$role}s"}(); |
661 | $leads = $obj->{"get{$role}s"}(); |
662 | if (!$leads) { |
662 | if (!$leads) { |
663 | continue; |
663 | continue; |
664 | }
|
664 | }
|
665 | if (isset($leads['active'])) { |
665 | if (isset($leads['active'])) { |
666 | $leads = array($leads); |
666 | $leads = array($leads); |
667 | }
|
667 | }
|
668 | foreach ($leads as $lead) { |
668 | foreach ($leads as $lead) { |
669 | if (!empty($info['Maintainers'])) { |
669 | if (!empty($info['Maintainers'])) { |
670 | $info['Maintainers'] .= "\n"; |
670 | $info['Maintainers'] .= "\n"; |
671 | }
|
671 | }
|
672 | $info['Maintainers'] .= $lead['name'] . ' <'; |
672 | $info['Maintainers'] .= $lead['name'] . ' <'; |
673 | $info['Maintainers'] .= $lead['email'] . "> ($role)"; |
673 | $info['Maintainers'] .= $lead['email'] . "> ($role)"; |
674 | }
|
674 | }
|
675 | }
|
675 | }
|
676 | $info['Release Date'] = $obj->getDate(); |
676 | $info['Release Date'] = $obj->getDate(); |
677 | if ($time = $obj->getTime()) { |
677 | if ($time = $obj->getTime()) { |
678 | $info['Release Date'] .= ' ' . $time; |
678 | $info['Release Date'] .= ' ' . $time; |
679 | }
|
679 | }
|
680 | $info['Release Version'] = $obj->getVersion() . ' (' . $obj->getState() . ')'; |
680 | $info['Release Version'] = $obj->getVersion() . ' (' . $obj->getState() . ')'; |
681 | $info['API Version'] = $obj->getVersion('api') . ' (' . $obj->getState('api') . ')'; |
681 | $info['API Version'] = $obj->getVersion('api') . ' (' . $obj->getState('api') . ')'; |
682 | $info['License'] = $obj->getLicense(); |
682 | $info['License'] = $obj->getLicense(); |
683 | $uri = $obj->getLicenseLocation(); |
683 | $uri = $obj->getLicenseLocation(); |
684 | if ($uri) { |
684 | if ($uri) { |
685 | if (isset($uri['uri'])) { |
685 | if (isset($uri['uri'])) { |
686 | $info['License'] .= ' (' . $uri['uri'] . ')'; |
686 | $info['License'] .= ' (' . $uri['uri'] . ')'; |
687 | } else { |
687 | } else { |
688 | $extra = $obj->getInstalledLocation($info['filesource']); |
688 | $extra = $obj->getInstalledLocation($info['filesource']); |
689 | if ($extra) { |
689 | if ($extra) { |
690 | $info['License'] .= ' (' . $uri['filesource'] . ')'; |
690 | $info['License'] .= ' (' . $uri['filesource'] . ')'; |
691 | }
|
691 | }
|
692 | }
|
692 | }
|
693 | }
|
693 | }
|
694 | $info['Release Notes'] = $obj->getNotes(); |
694 | $info['Release Notes'] = $obj->getNotes(); |
695 | if ($compat = $obj->getCompatible()) { |
695 | if ($compat = $obj->getCompatible()) { |
696 | if (!isset($compat[0])) { |
696 | if (!isset($compat[0])) { |
697 | $compat = array($compat); |
697 | $compat = array($compat); |
698 | }
|
698 | }
|
699 | $info['Compatible with'] = ''; |
699 | $info['Compatible with'] = ''; |
700 | foreach ($compat as $package) { |
700 | foreach ($compat as $package) { |
701 | $info['Compatible with'] .= $package['channel'] . '/' . $package['name'] . |
701 | $info['Compatible with'] .= $package['channel'] . '/' . $package['name'] . |
702 | "\nVersions >= " . $package['min'] . ', <= ' . $package['max']; |
702 | "\nVersions >= " . $package['min'] . ', <= ' . $package['max']; |
703 | if (isset($package['exclude'])) { |
703 | if (isset($package['exclude'])) { |
704 | if (is_array($package['exclude'])) { |
704 | if (is_array($package['exclude'])) { |
705 | $package['exclude'] = implode(', ', $package['exclude']); |
705 | $package['exclude'] = implode(', ', $package['exclude']); |
706 | }
|
706 | }
|
707 | if (!isset($info['Not Compatible with'])) { |
707 | if (!isset($info['Not Compatible with'])) { |
708 | $info['Not Compatible with'] = ''; |
708 | $info['Not Compatible with'] = ''; |
709 | } else { |
709 | } else { |
710 | $info['Not Compatible with'] .= "\n"; |
710 | $info['Not Compatible with'] .= "\n"; |
711 | }
|
711 | }
|
712 | $info['Not Compatible with'] .= $package['channel'] . '/' . |
712 | $info['Not Compatible with'] .= $package['channel'] . '/' . |
713 | $package['name'] . "\nVersions " . $package['exclude']; |
713 | $package['name'] . "\nVersions " . $package['exclude']; |
714 | }
|
714 | }
|
715 | }
|
715 | }
|
716 | }
|
716 | }
|
717 | $usesrole = $obj->getUsesrole(); |
717 | $usesrole = $obj->getUsesrole(); |
718 | if ($usesrole) { |
718 | if ($usesrole) { |
719 | if (!isset($usesrole[0])) { |
719 | if (!isset($usesrole[0])) { |
720 | $usesrole = array($usesrole); |
720 | $usesrole = array($usesrole); |
721 | }
|
721 | }
|
722 | foreach ($usesrole as $roledata) { |
722 | foreach ($usesrole as $roledata) { |
723 | if (isset($info['Uses Custom Roles'])) { |
723 | if (isset($info['Uses Custom Roles'])) { |
724 | $info['Uses Custom Roles'] .= "\n"; |
724 | $info['Uses Custom Roles'] .= "\n"; |
725 | } else { |
725 | } else { |
726 | $info['Uses Custom Roles'] = ''; |
726 | $info['Uses Custom Roles'] = ''; |
727 | }
|
727 | }
|
728 | if (isset($roledata['package'])) { |
728 | if (isset($roledata['package'])) { |
729 | $rolepackage = $reg->parsedPackageNameToString($roledata, true); |
729 | $rolepackage = $reg->parsedPackageNameToString($roledata, true); |
730 | } else { |
730 | } else { |
731 | $rolepackage = $roledata['uri']; |
731 | $rolepackage = $roledata['uri']; |
732 | }
|
732 | }
|
733 | $info['Uses Custom Roles'] .= $roledata['role'] . ' (' . $rolepackage . ')'; |
733 | $info['Uses Custom Roles'] .= $roledata['role'] . ' (' . $rolepackage . ')'; |
734 | }
|
734 | }
|
735 | }
|
735 | }
|
736 | $usestask = $obj->getUsestask(); |
736 | $usestask = $obj->getUsestask(); |
737 | if ($usestask) { |
737 | if ($usestask) { |
738 | if (!isset($usestask[0])) { |
738 | if (!isset($usestask[0])) { |
739 | $usestask = array($usestask); |
739 | $usestask = array($usestask); |
740 | }
|
740 | }
|
741 | foreach ($usestask as $taskdata) { |
741 | foreach ($usestask as $taskdata) { |
742 | if (isset($info['Uses Custom Tasks'])) { |
742 | if (isset($info['Uses Custom Tasks'])) { |
743 | $info['Uses Custom Tasks'] .= "\n"; |
743 | $info['Uses Custom Tasks'] .= "\n"; |
744 | } else { |
744 | } else { |
745 | $info['Uses Custom Tasks'] = ''; |
745 | $info['Uses Custom Tasks'] = ''; |
746 | }
|
746 | }
|
747 | if (isset($taskdata['package'])) { |
747 | if (isset($taskdata['package'])) { |
748 | $taskpackage = $reg->parsedPackageNameToString($taskdata, true); |
748 | $taskpackage = $reg->parsedPackageNameToString($taskdata, true); |
749 | } else { |
749 | } else { |
750 | $taskpackage = $taskdata['uri']; |
750 | $taskpackage = $taskdata['uri']; |
751 | }
|
751 | }
|
752 | $info['Uses Custom Tasks'] .= $taskdata['task'] . ' (' . $taskpackage . ')'; |
752 | $info['Uses Custom Tasks'] .= $taskdata['task'] . ' (' . $taskpackage . ')'; |
753 | }
|
753 | }
|
754 | }
|
754 | }
|
755 | $deps = $obj->getDependencies(); |
755 | $deps = $obj->getDependencies(); |
756 | $info['Required Dependencies'] = 'PHP version ' . $deps['required']['php']['min']; |
756 | $info['Required Dependencies'] = 'PHP version ' . $deps['required']['php']['min']; |
757 | if (isset($deps['required']['php']['max'])) { |
757 | if (isset($deps['required']['php']['max'])) { |
758 | $info['Required Dependencies'] .= '-' . $deps['required']['php']['max'] . "\n"; |
758 | $info['Required Dependencies'] .= '-' . $deps['required']['php']['max'] . "\n"; |
759 | } else { |
759 | } else { |
760 | $info['Required Dependencies'] .= "\n"; |
760 | $info['Required Dependencies'] .= "\n"; |
761 | }
|
761 | }
|
762 | if (isset($deps['required']['php']['exclude'])) { |
762 | if (isset($deps['required']['php']['exclude'])) { |
763 | if (!isset($info['Not Compatible with'])) { |
763 | if (!isset($info['Not Compatible with'])) { |
764 | $info['Not Compatible with'] = ''; |
764 | $info['Not Compatible with'] = ''; |
765 | } else { |
765 | } else { |
766 | $info['Not Compatible with'] .= "\n"; |
766 | $info['Not Compatible with'] .= "\n"; |
767 | }
|
767 | }
|
768 | if (is_array($deps['required']['php']['exclude'])) { |
768 | if (is_array($deps['required']['php']['exclude'])) { |
769 | $deps['required']['php']['exclude'] = |
769 | $deps['required']['php']['exclude'] = |
770 | implode(', ', $deps['required']['php']['exclude']); |
770 | implode(', ', $deps['required']['php']['exclude']); |
771 | }
|
771 | }
|
772 | $info['Not Compatible with'] .= "PHP versions\n " . |
772 | $info['Not Compatible with'] .= "PHP versions\n " . |
773 | $deps['required']['php']['exclude']; |
773 | $deps['required']['php']['exclude']; |
774 | }
|
774 | }
|
775 | $info['Required Dependencies'] .= 'PEAR installer version'; |
775 | $info['Required Dependencies'] .= 'PEAR installer version'; |
776 | if (isset($deps['required']['pearinstaller']['max'])) { |
776 | if (isset($deps['required']['pearinstaller']['max'])) { |
777 | $info['Required Dependencies'] .= 's ' . |
777 | $info['Required Dependencies'] .= 's ' . |
778 | $deps['required']['pearinstaller']['min'] . '-' . |
778 | $deps['required']['pearinstaller']['min'] . '-' . |
779 | $deps['required']['pearinstaller']['max']; |
779 | $deps['required']['pearinstaller']['max']; |
780 | } else { |
780 | } else { |
781 | $info['Required Dependencies'] .= ' ' . |
781 | $info['Required Dependencies'] .= ' ' . |
782 | $deps['required']['pearinstaller']['min'] . ' or newer'; |
782 | $deps['required']['pearinstaller']['min'] . ' or newer'; |
783 | }
|
783 | }
|
784 | if (isset($deps['required']['pearinstaller']['exclude'])) { |
784 | if (isset($deps['required']['pearinstaller']['exclude'])) { |
785 | if (!isset($info['Not Compatible with'])) { |
785 | if (!isset($info['Not Compatible with'])) { |
786 | $info['Not Compatible with'] = ''; |
786 | $info['Not Compatible with'] = ''; |
787 | } else { |
787 | } else { |
788 | $info['Not Compatible with'] .= "\n"; |
788 | $info['Not Compatible with'] .= "\n"; |
789 | }
|
789 | }
|
790 | if (is_array($deps['required']['pearinstaller']['exclude'])) { |
790 | if (is_array($deps['required']['pearinstaller']['exclude'])) { |
791 | $deps['required']['pearinstaller']['exclude'] = |
791 | $deps['required']['pearinstaller']['exclude'] = |
792 | implode(', ', $deps['required']['pearinstaller']['exclude']); |
792 | implode(', ', $deps['required']['pearinstaller']['exclude']); |
793 | }
|
793 | }
|
794 | $info['Not Compatible with'] .= "PEAR installer\n Versions " . |
794 | $info['Not Compatible with'] .= "PEAR installer\n Versions " . |
795 | $deps['required']['pearinstaller']['exclude']; |
795 | $deps['required']['pearinstaller']['exclude']; |
796 | }
|
796 | }
|
797 | foreach (array('Package', 'Extension') as $type) { |
797 | foreach (array('Package', 'Extension') as $type) { |
798 | $index = strtolower($type); |
798 | $index = strtolower($type); |
799 | if (isset($deps['required'][$index])) { |
799 | if (isset($deps['required'][$index])) { |
800 | if (isset($deps['required'][$index]['name'])) { |
800 | if (isset($deps['required'][$index]['name'])) { |
801 | $deps['required'][$index] = array($deps['required'][$index]); |
801 | $deps['required'][$index] = array($deps['required'][$index]); |
802 | }
|
802 | }
|
803 | foreach ($deps['required'][$index] as $package) { |
803 | foreach ($deps['required'][$index] as $package) { |
804 | if (isset($package['conflicts'])) { |
804 | if (isset($package['conflicts'])) { |
805 | $infoindex = 'Not Compatible with'; |
805 | $infoindex = 'Not Compatible with'; |
806 | if (!isset($info['Not Compatible with'])) { |
806 | if (!isset($info['Not Compatible with'])) { |
807 | $info['Not Compatible with'] = ''; |
807 | $info['Not Compatible with'] = ''; |
808 | } else { |
808 | } else { |
809 | $info['Not Compatible with'] .= "\n"; |
809 | $info['Not Compatible with'] .= "\n"; |
810 | }
|
810 | }
|
811 | } else { |
811 | } else { |
812 | $infoindex = 'Required Dependencies'; |
812 | $infoindex = 'Required Dependencies'; |
813 | $info[$infoindex] .= "\n"; |
813 | $info[$infoindex] .= "\n"; |
814 | }
|
814 | }
|
815 | if ($index == 'extension') { |
815 | if ($index == 'extension') { |
816 | $name = $package['name']; |
816 | $name = $package['name']; |
817 | } else { |
817 | } else { |
818 | if (isset($package['channel'])) { |
818 | if (isset($package['channel'])) { |
819 | $name = $package['channel'] . '/' . $package['name']; |
819 | $name = $package['channel'] . '/' . $package['name']; |
820 | } else { |
820 | } else { |
821 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
821 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
822 | }
|
822 | }
|
823 | }
|
823 | }
|
824 | $info[$infoindex] .= "$type $name"; |
824 | $info[$infoindex] .= "$type $name"; |
825 | if (isset($package['uri'])) { |
825 | if (isset($package['uri'])) { |
826 | $info[$infoindex] .= "\n Download URI: $package[uri]"; |
826 | $info[$infoindex] .= "\n Download URI: $package[uri]"; |
827 | continue; |
827 | continue; |
828 | }
|
828 | }
|
829 | if (isset($package['max']) && isset($package['min'])) { |
829 | if (isset($package['max']) && isset($package['min'])) { |
830 | $info[$infoindex] .= " \n Versions " . |
830 | $info[$infoindex] .= " \n Versions " . |
831 | $package['min'] . '-' . $package['max']; |
831 | $package['min'] . '-' . $package['max']; |
832 | } elseif (isset($package['min'])) { |
832 | } elseif (isset($package['min'])) { |
833 | $info[$infoindex] .= " \n Version " . |
833 | $info[$infoindex] .= " \n Version " . |
834 | $package['min'] . ' or newer'; |
834 | $package['min'] . ' or newer'; |
835 | } elseif (isset($package['max'])) { |
835 | } elseif (isset($package['max'])) { |
836 | $info[$infoindex] .= " \n Version " . |
836 | $info[$infoindex] .= " \n Version " . |
837 | $package['max'] . ' or older'; |
837 | $package['max'] . ' or older'; |
838 | }
|
838 | }
|
839 | if (isset($package['recommended'])) { |
839 | if (isset($package['recommended'])) { |
840 | $info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
840 | $info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
841 | }
|
841 | }
|
842 | if (isset($package['exclude'])) { |
842 | if (isset($package['exclude'])) { |
843 | if (!isset($info['Not Compatible with'])) { |
843 | if (!isset($info['Not Compatible with'])) { |
844 | $info['Not Compatible with'] = ''; |
844 | $info['Not Compatible with'] = ''; |
845 | } else { |
845 | } else { |
846 | $info['Not Compatible with'] .= "\n"; |
846 | $info['Not Compatible with'] .= "\n"; |
847 | }
|
847 | }
|
848 | if (is_array($package['exclude'])) { |
848 | if (is_array($package['exclude'])) { |
849 | $package['exclude'] = implode(', ', $package['exclude']); |
849 | $package['exclude'] = implode(', ', $package['exclude']); |
850 | }
|
850 | }
|
851 | $package['package'] = $package['name']; // for parsedPackageNameToString |
851 | $package['package'] = $package['name']; // for parsedPackageNameToString |
852 | if (isset($package['conflicts'])) { |
852 | if (isset($package['conflicts'])) { |
853 | $info['Not Compatible with'] .= '=> except '; |
853 | $info['Not Compatible with'] .= '=> except '; |
854 | }
|
854 | }
|
855 | $info['Not Compatible with'] .= 'Package ' . |
855 | $info['Not Compatible with'] .= 'Package ' . |
856 | $reg->parsedPackageNameToString($package, true); |
856 | $reg->parsedPackageNameToString($package, true); |
857 | $info['Not Compatible with'] .= "\n Versions " . $package['exclude']; |
857 | $info['Not Compatible with'] .= "\n Versions " . $package['exclude']; |
858 | }
|
858 | }
|
859 | }
|
859 | }
|
860 | }
|
860 | }
|
861 | }
|
861 | }
|
862 | if (isset($deps['required']['os'])) { |
862 | if (isset($deps['required']['os'])) { |
863 | if (isset($deps['required']['os']['name'])) { |
863 | if (isset($deps['required']['os']['name'])) { |
864 | $dep['required']['os']['name'] = array($dep['required']['os']['name']); |
864 | $dep['required']['os']['name'] = array($dep['required']['os']['name']); |
865 | }
|
865 | }
|
866 | foreach ($dep['required']['os'] as $os) { |
866 | foreach ($dep['required']['os'] as $os) { |
867 | if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
867 | if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
868 | if (!isset($info['Not Compatible with'])) { |
868 | if (!isset($info['Not Compatible with'])) { |
869 | $info['Not Compatible with'] = ''; |
869 | $info['Not Compatible with'] = ''; |
870 | } else { |
870 | } else { |
871 | $info['Not Compatible with'] .= "\n"; |
871 | $info['Not Compatible with'] .= "\n"; |
872 | }
|
872 | }
|
873 | $info['Not Compatible with'] .= "$os[name] Operating System"; |
873 | $info['Not Compatible with'] .= "$os[name] Operating System"; |
874 | } else { |
874 | } else { |
875 | $info['Required Dependencies'] .= "\n"; |
875 | $info['Required Dependencies'] .= "\n"; |
876 | $info['Required Dependencies'] .= "$os[name] Operating System"; |
876 | $info['Required Dependencies'] .= "$os[name] Operating System"; |
877 | }
|
877 | }
|
878 | }
|
878 | }
|
879 | }
|
879 | }
|
880 | if (isset($deps['required']['arch'])) { |
880 | if (isset($deps['required']['arch'])) { |
881 | if (isset($deps['required']['arch']['pattern'])) { |
881 | if (isset($deps['required']['arch']['pattern'])) { |
882 | $dep['required']['arch']['pattern'] = array($dep['required']['os']['pattern']); |
882 | $dep['required']['arch']['pattern'] = array($dep['required']['os']['pattern']); |
883 | }
|
883 | }
|
884 | foreach ($dep['required']['arch'] as $os) { |
884 | foreach ($dep['required']['arch'] as $os) { |
885 | if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
885 | if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
886 | if (!isset($info['Not Compatible with'])) { |
886 | if (!isset($info['Not Compatible with'])) { |
887 | $info['Not Compatible with'] = ''; |
887 | $info['Not Compatible with'] = ''; |
888 | } else { |
888 | } else { |
889 | $info['Not Compatible with'] .= "\n"; |
889 | $info['Not Compatible with'] .= "\n"; |
890 | }
|
890 | }
|
891 | $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'"; |
891 | $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'"; |
892 | } else { |
892 | } else { |
893 | $info['Required Dependencies'] .= "\n"; |
893 | $info['Required Dependencies'] .= "\n"; |
894 | $info['Required Dependencies'] .= "OS/Arch matching pattern '/$os[pattern]/'"; |
894 | $info['Required Dependencies'] .= "OS/Arch matching pattern '/$os[pattern]/'"; |
895 | }
|
895 | }
|
896 | }
|
896 | }
|
897 | }
|
897 | }
|
898 | if (isset($deps['optional'])) { |
898 | if (isset($deps['optional'])) { |
899 | foreach (array('Package', 'Extension') as $type) { |
899 | foreach (array('Package', 'Extension') as $type) { |
900 | $index = strtolower($type); |
900 | $index = strtolower($type); |
901 | if (isset($deps['optional'][$index])) { |
901 | if (isset($deps['optional'][$index])) { |
902 | if (isset($deps['optional'][$index]['name'])) { |
902 | if (isset($deps['optional'][$index]['name'])) { |
903 | $deps['optional'][$index] = array($deps['optional'][$index]); |
903 | $deps['optional'][$index] = array($deps['optional'][$index]); |
904 | }
|
904 | }
|
905 | foreach ($deps['optional'][$index] as $package) { |
905 | foreach ($deps['optional'][$index] as $package) { |
906 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
906 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
907 | $infoindex = 'Not Compatible with'; |
907 | $infoindex = 'Not Compatible with'; |
908 | if (!isset($info['Not Compatible with'])) { |
908 | if (!isset($info['Not Compatible with'])) { |
909 | $info['Not Compatible with'] = ''; |
909 | $info['Not Compatible with'] = ''; |
910 | } else { |
910 | } else { |
911 | $info['Not Compatible with'] .= "\n"; |
911 | $info['Not Compatible with'] .= "\n"; |
912 | }
|
912 | }
|
913 | } else { |
913 | } else { |
914 | $infoindex = 'Optional Dependencies'; |
914 | $infoindex = 'Optional Dependencies'; |
915 | if (!isset($info['Optional Dependencies'])) { |
915 | if (!isset($info['Optional Dependencies'])) { |
916 | $info['Optional Dependencies'] = ''; |
916 | $info['Optional Dependencies'] = ''; |
917 | } else { |
917 | } else { |
918 | $info['Optional Dependencies'] .= "\n"; |
918 | $info['Optional Dependencies'] .= "\n"; |
919 | }
|
919 | }
|
920 | }
|
920 | }
|
921 | if ($index == 'extension') { |
921 | if ($index == 'extension') { |
922 | $name = $package['name']; |
922 | $name = $package['name']; |
923 | } else { |
923 | } else { |
924 | if (isset($package['channel'])) { |
924 | if (isset($package['channel'])) { |
925 | $name = $package['channel'] . '/' . $package['name']; |
925 | $name = $package['channel'] . '/' . $package['name']; |
926 | } else { |
926 | } else { |
927 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
927 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
928 | }
|
928 | }
|
929 | }
|
929 | }
|
930 | $info[$infoindex] .= "$type $name"; |
930 | $info[$infoindex] .= "$type $name"; |
931 | if (isset($package['uri'])) { |
931 | if (isset($package['uri'])) { |
932 | $info[$infoindex] .= "\n Download URI: $package[uri]"; |
932 | $info[$infoindex] .= "\n Download URI: $package[uri]"; |
933 | continue; |
933 | continue; |
934 | }
|
934 | }
|
935 | if ($infoindex == 'Not Compatible with') { |
935 | if ($infoindex == 'Not Compatible with') { |
936 | // conflicts is only used to say that all versions conflict
|
936 | // conflicts is only used to say that all versions conflict
|
937 | continue; |
937 | continue; |
938 | }
|
938 | }
|
939 | if (isset($package['max']) && isset($package['min'])) { |
939 | if (isset($package['max']) && isset($package['min'])) { |
940 | $info[$infoindex] .= " \n Versions " . |
940 | $info[$infoindex] .= " \n Versions " . |
941 | $package['min'] . '-' . $package['max']; |
941 | $package['min'] . '-' . $package['max']; |
942 | } elseif (isset($package['min'])) { |
942 | } elseif (isset($package['min'])) { |
943 | $info[$infoindex] .= " \n Version " . |
943 | $info[$infoindex] .= " \n Version " . |
944 | $package['min'] . ' or newer'; |
944 | $package['min'] . ' or newer'; |
945 | } elseif (isset($package['max'])) { |
945 | } elseif (isset($package['max'])) { |
946 | $info[$infoindex] .= " \n Version " . |
946 | $info[$infoindex] .= " \n Version " . |
947 | $package['min'] . ' or older'; |
947 | $package['min'] . ' or older'; |
948 | }
|
948 | }
|
949 | if (isset($package['recommended'])) { |
949 | if (isset($package['recommended'])) { |
950 | $info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
950 | $info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
951 | }
|
951 | }
|
952 | if (isset($package['exclude'])) { |
952 | if (isset($package['exclude'])) { |
953 | if (!isset($info['Not Compatible with'])) { |
953 | if (!isset($info['Not Compatible with'])) { |
954 | $info['Not Compatible with'] = ''; |
954 | $info['Not Compatible with'] = ''; |
955 | } else { |
955 | } else { |
956 | $info['Not Compatible with'] .= "\n"; |
956 | $info['Not Compatible with'] .= "\n"; |
957 | }
|
957 | }
|
958 | if (is_array($package['exclude'])) { |
958 | if (is_array($package['exclude'])) { |
959 | $package['exclude'] = implode(', ', $package['exclude']); |
959 | $package['exclude'] = implode(', ', $package['exclude']); |
960 | }
|
960 | }
|
961 | $info['Not Compatible with'] .= "Package $package\n Versions " . |
961 | $info['Not Compatible with'] .= "Package $package\n Versions " . |
962 | $package['exclude']; |
962 | $package['exclude']; |
963 | }
|
963 | }
|
964 | }
|
964 | }
|
965 | }
|
965 | }
|
966 | }
|
966 | }
|
967 | }
|
967 | }
|
968 | if (isset($deps['group'])) { |
968 | if (isset($deps['group'])) { |
969 | if (!isset($deps['group'][0])) { |
969 | if (!isset($deps['group'][0])) { |
970 | $deps['group'] = array($deps['group']); |
970 | $deps['group'] = array($deps['group']); |
971 | }
|
971 | }
|
972 | foreach ($deps['group'] as $group) { |
972 | foreach ($deps['group'] as $group) { |
973 | $info['Dependency Group ' . $group['attribs']['name']] = $group['attribs']['hint']; |
973 | $info['Dependency Group ' . $group['attribs']['name']] = $group['attribs']['hint']; |
974 | $groupindex = $group['attribs']['name'] . ' Contents'; |
974 | $groupindex = $group['attribs']['name'] . ' Contents'; |
975 | $info[$groupindex] = ''; |
975 | $info[$groupindex] = ''; |
976 | foreach (array('Package', 'Extension') as $type) { |
976 | foreach (array('Package', 'Extension') as $type) { |
977 | $index = strtolower($type); |
977 | $index = strtolower($type); |
978 | if (isset($group[$index])) { |
978 | if (isset($group[$index])) { |
979 | if (isset($group[$index]['name'])) { |
979 | if (isset($group[$index]['name'])) { |
980 | $group[$index] = array($group[$index]); |
980 | $group[$index] = array($group[$index]); |
981 | }
|
981 | }
|
982 | foreach ($group[$index] as $package) { |
982 | foreach ($group[$index] as $package) { |
983 | if (!empty($info[$groupindex])) { |
983 | if (!empty($info[$groupindex])) { |
984 | $info[$groupindex] .= "\n"; |
984 | $info[$groupindex] .= "\n"; |
985 | }
|
985 | }
|
986 | if ($index == 'extension') { |
986 | if ($index == 'extension') { |
987 | $name = $package['name']; |
987 | $name = $package['name']; |
988 | } else { |
988 | } else { |
989 | if (isset($package['channel'])) { |
989 | if (isset($package['channel'])) { |
990 | $name = $package['channel'] . '/' . $package['name']; |
990 | $name = $package['channel'] . '/' . $package['name']; |
991 | } else { |
991 | } else { |
992 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
992 | $name = '__uri/' . $package['name'] . ' (static URI)'; |
993 | }
|
993 | }
|
994 | }
|
994 | }
|
995 | if (isset($package['uri'])) { |
995 | if (isset($package['uri'])) { |
996 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
996 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
997 | $info[$groupindex] .= "Not Compatible with $type $name"; |
997 | $info[$groupindex] .= "Not Compatible with $type $name"; |
998 | } else { |
998 | } else { |
999 | $info[$groupindex] .= "$type $name"; |
999 | $info[$groupindex] .= "$type $name"; |
1000 | }
|
1000 | }
|
1001 | $info[$groupindex] .= "\n Download URI: $package[uri]"; |
1001 | $info[$groupindex] .= "\n Download URI: $package[uri]"; |
1002 | continue; |
1002 | continue; |
1003 | }
|
1003 | }
|
1004 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
1004 | if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
1005 | $info[$groupindex] .= "Not Compatible with $type $name"; |
1005 | $info[$groupindex] .= "Not Compatible with $type $name"; |
1006 | continue; |
1006 | continue; |
1007 | }
|
1007 | }
|
1008 | $info[$groupindex] .= "$type $name"; |
1008 | $info[$groupindex] .= "$type $name"; |
1009 | if (isset($package['max']) && isset($package['min'])) { |
1009 | if (isset($package['max']) && isset($package['min'])) { |
1010 | $info[$groupindex] .= " \n Versions " . |
1010 | $info[$groupindex] .= " \n Versions " . |
1011 | $package['min'] . '-' . $package['max']; |
1011 | $package['min'] . '-' . $package['max']; |
1012 | } elseif (isset($package['min'])) { |
1012 | } elseif (isset($package['min'])) { |
1013 | $info[$groupindex] .= " \n Version " . |
1013 | $info[$groupindex] .= " \n Version " . |
1014 | $package['min'] . ' or newer'; |
1014 | $package['min'] . ' or newer'; |
1015 | } elseif (isset($package['max'])) { |
1015 | } elseif (isset($package['max'])) { |
1016 | $info[$groupindex] .= " \n Version " . |
1016 | $info[$groupindex] .= " \n Version " . |
1017 | $package['min'] . ' or older'; |
1017 | $package['min'] . ' or older'; |
1018 | }
|
1018 | }
|
1019 | if (isset($package['recommended'])) { |
1019 | if (isset($package['recommended'])) { |
1020 | $info[$groupindex] .= "\n Recommended version: $package[recommended]"; |
1020 | $info[$groupindex] .= "\n Recommended version: $package[recommended]"; |
1021 | }
|
1021 | }
|
1022 | if (isset($package['exclude'])) { |
1022 | if (isset($package['exclude'])) { |
1023 | if (!isset($info['Not Compatible with'])) { |
1023 | if (!isset($info['Not Compatible with'])) { |
1024 | $info['Not Compatible with'] = ''; |
1024 | $info['Not Compatible with'] = ''; |
1025 | } else { |
1025 | } else { |
1026 | $info[$groupindex] .= "Not Compatible with\n"; |
1026 | $info[$groupindex] .= "Not Compatible with\n"; |
1027 | }
|
1027 | }
|
1028 | if (is_array($package['exclude'])) { |
1028 | if (is_array($package['exclude'])) { |
1029 | $package['exclude'] = implode(', ', $package['exclude']); |
1029 | $package['exclude'] = implode(', ', $package['exclude']); |
1030 | }
|
1030 | }
|
1031 | $info[$groupindex] .= " Package $package\n Versions " . |
1031 | $info[$groupindex] .= " Package $package\n Versions " . |
1032 | $package['exclude']; |
1032 | $package['exclude']; |
1033 | }
|
1033 | }
|
1034 | }
|
1034 | }
|
1035 | }
|
1035 | }
|
1036 | }
|
1036 | }
|
1037 | }
|
1037 | }
|
1038 | }
|
1038 | }
|
1039 | if ($obj->getPackageType() == 'bundle') { |
1039 | if ($obj->getPackageType() == 'bundle') { |
1040 | $info['Bundled Packages'] = ''; |
1040 | $info['Bundled Packages'] = ''; |
1041 | foreach ($obj->getBundledPackages() as $package) { |
1041 | foreach ($obj->getBundledPackages() as $package) { |
1042 | if (!empty($info['Bundled Packages'])) { |
1042 | if (!empty($info['Bundled Packages'])) { |
1043 | $info['Bundled Packages'] .= "\n"; |
1043 | $info['Bundled Packages'] .= "\n"; |
1044 | }
|
1044 | }
|
1045 | if (isset($package['uri'])) { |
1045 | if (isset($package['uri'])) { |
1046 | $info['Bundled Packages'] .= '__uri/' . $package['name']; |
1046 | $info['Bundled Packages'] .= '__uri/' . $package['name']; |
1047 | $info['Bundled Packages'] .= "\n (URI: $package[uri]"; |
1047 | $info['Bundled Packages'] .= "\n (URI: $package[uri]"; |
1048 | } else { |
1048 | } else { |
1049 | $info['Bundled Packages'] .= $package['channel'] . '/' . $package['name']; |
1049 | $info['Bundled Packages'] .= $package['channel'] . '/' . $package['name']; |
1050 | }
|
1050 | }
|
1051 | }
|
1051 | }
|
1052 | }
|
1052 | }
|
1053 | $info['package.xml version'] = '2.0'; |
1053 | $info['package.xml version'] = '2.0'; |
1054 | if ($installed) { |
1054 | if ($installed) { |
1055 | if ($obj->getLastModified()) { |
1055 | if ($obj->getLastModified()) { |
1056 | $info['Last Modified'] = date('Y-m-d H:i', $obj->getLastModified()); |
1056 | $info['Last Modified'] = date('Y-m-d H:i', $obj->getLastModified()); |
1057 | }
|
1057 | }
|
1058 | $v = $obj->getLastInstalledVersion(); |
1058 | $v = $obj->getLastInstalledVersion(); |
1059 | $info['Previous Installed Version'] = $v ? $v : '- None -'; |
1059 | $info['Previous Installed Version'] = $v ? $v : '- None -'; |
1060 | }
|
1060 | }
|
1061 | foreach ($info as $key => $value) { |
1061 | foreach ($info as $key => $value) { |
1062 | $data['data'][] = array($key, $value); |
1062 | $data['data'][] = array($key, $value); |
1063 | }
|
1063 | }
|
1064 | $data['raw'] = $obj->getArray(); // no validation needed |
1064 | $data['raw'] = $obj->getArray(); // no validation needed |
1065 | 1065 | ||
1066 | $this->ui->outputData($data, 'package-info'); |
1066 | $this->ui->outputData($data, 'package-info'); |
1067 | }
|
1067 | }
|
1068 | }
|
1068 | }
|
1069 | 1069 | ||
1070 | ?>
|
1070 | ?>
|
1071 | 1071 |