Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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