Subversion Repositories Applications.gtt

Rev

Rev 94 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
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
-
 
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
 */
23
 
16
 
24
/**
17
/**
25
 * base class
18
 * base class
26
 */
19
 */
27
require_once 'PEAR/Command/Common.php';
20
require_once 'PEAR/Command/Common.php';
28
 
21
 
29
/**
22
/**
30
 * PEAR commands for registry manipulation
23
 * PEAR commands for registry manipulation
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',
51
            'options' => array(
42
            'options' => array(
52
                'channel' => array(
43
                'channel' => array(
53
                    'shortopt' => 'c',
44
                    'shortopt' => 'c',
54
                    'doc' => 'list installed packages from this channel',
45
                    'doc' => 'list installed packages from this channel',
55
                    'arg' => 'CHAN',
46
                    'arg' => 'CHAN',
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.
66
',
61
',
67
            ),
62
            ),
68
        'list-files' => array(
63
        'list-files' => array(
69
            'summary' => 'List Files In Installed Package',
64
            'summary' => 'List Files In Installed Package',
70
            'function' => 'doFileList',
65
            'function' => 'doFileList',
71
            'shortcut' => 'fl',
66
            'shortcut' => 'fl',
72
            'options' => array(),
67
            'options' => array(),
73
            'doc' => '<package>
68
            'doc' => '<package>
74
List the files in an installed package.
69
List the files in an installed package.
75
'
70
'
76
            ),
71
            ),
77
        'shell-test' => array(
72
        'shell-test' => array(
78
            'summary' => 'Shell Script Test',
73
            'summary' => 'Shell Script Test',
79
            'function' => 'doShellTest',
74
            'function' => 'doShellTest',
80
            'shortcut' => 'st',
75
            'shortcut' => 'st',
81
            'options' => array(),
76
            'options' => array(),
82
            'doc' => '<package> [[relation] version]
77
            'doc' => '<package> [[relation] version]
83
Tests if a package is installed in the system. Will exit(1) if it is not.
78
Tests if a package is installed in the system. Will exit(1) if it is not.
84
   <relation>   The version comparison operator. One of:
79
   <relation>   The version comparison operator. One of:
85
                <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
80
                <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
86
   <version>    The version to compare with
81
   <version>    The version to compare with
87
'),
82
'),
88
        'info' => array(
83
        'info' => array(
89
            'summary'  => 'Display information about a package',
84
            'summary'  => 'Display information about a package',
90
            'function' => 'doInfo',
85
            'function' => 'doInfo',
91
            'shortcut' => 'in',
86
            'shortcut' => 'in',
92
            'options'  => array(),
87
            'options'  => array(),
93
            'doc'      => '<package>
88
            'doc'      => '<package>
94
Displays information about a package. The package argument may be a
89
Displays information about a package. The package argument may be a
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
        );
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);
111
    }
103
    }
112
 
-
 
113
    // }}}
-
 
114
 
-
 
115
    // {{{ doList()
-
 
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'];
121
        return strcmp($apackage, $bpackage);
109
        return strcmp($apackage, $bpackage);
122
    }
110
    }
123
 
111
 
124
    function doList($command, $options, $params)
112
    function doList($command, $options, $params)
125
    {
113
    {
-
 
114
        $reg = &$this->config->getRegistry();
-
 
115
        $channelinfo = isset($options['channelinfo']);
126
        if (isset($options['allchannels'])) {
116
        if (isset($options['allchannels']) && !$channelinfo) {
127
            return $this->doListAll($command, array(), $params);
117
            return $this->doListAll($command, array(), $params);
128
        }
118
        }
-
 
119
 
-
 
120
        if (isset($options['allchannels']) && $channelinfo) {
-
 
121
            // allchannels with $channelinfo
-
 
122
            unset($options['allchannels']);
129
        $reg = &$this->config->getRegistry();
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
 
-
 
141
            return true;
-
 
142
        }
-
 
143
 
130
        if (count($params) == 1) {
144
        if (count($params) === 1) {
131
            return $this->doFileList($command, $options, $params);
145
            return $this->doFileList($command, $options, $params);
132
        }
146
        }
-
 
147
 
133
        if (isset($options['channel'])) {
148
        if (isset($options['channel'])) {
134
            if ($reg->channelExists($options['channel'])) {
149
            if (!$reg->channelExists($options['channel'])) {
135
                $channel = $reg->channelName($options['channel']);
-
 
136
            } else {
-
 
137
                return $this->raiseError('Channel "' . $options['channel'] .'" does not exist');
150
                return $this->raiseError('Channel "' . $options['channel'] .'" does not exist');
138
            }
151
            }
-
 
152
 
-
 
153
            $channel = $reg->channelName($options['channel']);
139
        } else {
154
        } else {
140
            $channel = $this->config->get('default_channel');
155
            $channel = $this->config->get('default_channel');
141
        }
156
        }
-
 
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 ' .
147
                $channel . ':',
163
                $channel . ':',
148
            'border' => true,
164
            'border' => true,
149
            'headline' => array('Package', 'Version', 'State')
165
            'headline' => array('Package', 'Version', 'State'),
-
 
166
            'channel' => $channel,
150
            );
167
            );
-
 
168
        if ($channelinfo) {
-
 
169
            $data['headline'] = array('Channel', 'Package', 'Version', 'State');
-
 
170
        }
-
 
171
 
-
 
172
        if (count($installed) && !isset($data['data'])) {
-
 
173
            $data['data'] = array();
-
 
174
        }
-
 
175
 
151
        foreach ($installed as $package) {
176
        foreach ($installed as $package) {
152
            $pobj = $reg->getPackage(isset($package['package']) ?
177
            $pobj = $reg->getPackage(isset($package['package']) ?
153
                                        $package['package'] : $package['name'], $channel);
178
                                        $package['package'] : $package['name'], $channel);
-
 
179
            if ($channelinfo) {
-
 
180
                $packageinfo = array($pobj->getChannel(), $pobj->getPackage(), $pobj->getVersion(),
-
 
181
                                    $pobj->getState() ? $pobj->getState() : null);
-
 
182
            } else {
154
            $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(),
183
                $packageinfo = array($pobj->getPackage(), $pobj->getVersion(),
155
                                    $pobj->getState() ? $pobj->getState() : null);
184
                                    $pobj->getState() ? $pobj->getState() : null);
-
 
185
            }
-
 
186
            $data['data'][] = $packageinfo;
156
        }
187
        }
-
 
188
 
157
        if (count($installed)==0) {
189
        if (count($installed) === 0) {
-
 
190
            if (!$channelinfo) {
158
            $data = '(no packages installed from channel ' . $channel . ')';
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,
-
 
198
                    'data' => array(array('(no packages installed)')),
-
 
199
                );
-
 
200
            }
159
        }
201
        }
-
 
202
 
160
        $this->ui->outputData($data, $command);
203
        $this->ui->outputData($data, $command);
161
        return true;
204
        return true;
162
    }
205
    }
163
    
206
 
164
    function doListAll($command, $options, $params)
207
    function doListAll($command, $options, $params)
165
    {
208
    {
-
 
209
        // This duplicate code is deprecated over
-
 
210
        // list --channelinfo, which gives identical
-
 
211
        // output for list and list --allchannels.
166
        $reg = &$this->config->getRegistry();
212
        $reg = &$this->config->getRegistry();
167
        $installed = $reg->packageInfo(null, null, null);
213
        $installed = $reg->packageInfo(null, null, null);
168
        foreach ($installed as $channel => $packages) {
214
        foreach ($installed as $channel => $packages) {
169
            usort($packages, array($this, '_sortinfo'));
215
            usort($packages, array($this, '_sortinfo'));
170
            $i = $j = 0;
-
 
171
            $data = array(
216
            $data = array(
172
                'caption' => 'Installed packages, channel ' . $channel . ':',
217
                'caption'  => 'Installed packages, channel ' . $channel . ':',
173
                'border' => true,
218
                'border'   => true,
174
                'headline' => array('Package', 'Version', 'State')
219
                'headline' => array('Package', 'Version', 'State'),
-
 
220
                'channel'  => $channel
175
                );
221
            );
-
 
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);
179
                $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(),
226
                $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(),
180
                                        $pobj->getState() ? $pobj->getState() : null);
227
                                        $pobj->getState() ? $pobj->getState() : null);
181
            }
228
            }
-
 
229
 
-
 
230
            // Adds a blank line after each section
-
 
231
            $data['data'][] = array();
-
 
232
 
182
            if (count($packages)==0) {
233
            if (count($packages) === 0) {
183
                $data = array(
234
                $data = array(
184
                    'caption' => 'Installed packages, channel ' . $channel . ':',
235
                    'caption' => 'Installed packages, channel ' . $channel . ':',
185
                    'border' => true,
236
                    'border' => true,
186
                    'data' => array(array('(no packages installed)')),
237
                    'data' => array(array('(no packages installed)'), array()),
-
 
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
    {
196
        if (count($params) != 1) {
248
        if (count($params) !== 1) {
197
            return $this->raiseError('list-files expects 1 parameter');
249
            return $this->raiseError('list-files expects 1 parameter');
198
        }
250
        }
-
 
251
 
199
        $reg = &$this->config->getRegistry();
252
        $reg = &$this->config->getRegistry();
200
        $fp = false;
253
        $fp = false;
201
        if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0],
254
        if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], 'r'))) {
202
              'r'))) {
-
 
203
            if ($fp) {
255
            if ($fp) {
204
                fclose($fp);
256
                fclose($fp);
205
            }
257
            }
-
 
258
 
206
            if (!class_exists('PEAR_PackageFile')) {
259
            if (!class_exists('PEAR_PackageFile')) {
207
                require_once 'PEAR/PackageFile.php';
260
                require_once 'PEAR/PackageFile.php';
208
            }
261
            }
-
 
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);
212
            PEAR::staticPopErrorHandling();
266
            PEAR::staticPopErrorHandling();
213
            $headings = array('Package File', 'Install Path');
267
            $headings = array('Package File', 'Install Path');
214
            $installed = false;
268
            $installed = false;
215
        } else {
269
        } else {
216
            PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
270
            PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
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) {
244
            foreach ($list as $file => $att) {
303
            foreach ($list as $file => $att) {
245
                if ($installed) {
304
                if ($installed) {
246
                    if (empty($att['installed_as'])) {
305
                    if (empty($att['installed_as'])) {
247
                        continue;
306
                        continue;
248
                    }
307
                    }
249
                    $data['data'][] = array($att['role'], $att['installed_as']);
308
                    $data['data'][] = array($att['role'], $att['installed_as']);
250
                } else {
309
                } else {
251
                    if (isset($att['baseinstalldir']) && !in_array($att['role'],
310
                    if (isset($att['baseinstalldir']) && !in_array($att['role'],
252
                          array('test', 'data', 'doc'))) {
311
                          array('test', 'data', 'doc'))) {
253
                        $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR .
312
                        $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR .
254
                            $file;
313
                            $file;
255
                    } else {
314
                    } else {
256
                        $dest = $file;
315
                        $dest = $file;
257
                    }
316
                    }
258
                    switch ($att['role']) {
317
                    switch ($att['role']) {
259
                        case 'test':
318
                        case 'test':
260
                        case 'data':
319
                        case 'data':
261
                        case 'doc':
320
                        case 'doc':
262
                            $role = $att['role'];
321
                            $role = $att['role'];
263
                            if ($role == 'test') {
322
                            if ($role == 'test') {
264
                                $role .= 's';
323
                                $role .= 's';
265
                            }
324
                            }
266
                            $dest = $this->config->get($role . '_dir') . DIRECTORY_SEPARATOR .
325
                            $dest = $this->config->get($role . '_dir') . DIRECTORY_SEPARATOR .
267
                                $info->getPackage() . DIRECTORY_SEPARATOR . $dest;
326
                                $info->getPackage() . DIRECTORY_SEPARATOR . $dest;
268
                            break;
327
                            break;
269
                        case 'php':
328
                        case 'php':
270
                        default:
329
                        default:
271
                            $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR .
330
                            $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR .
272
                                $dest;
331
                                $dest;
273
                    }
332
                    }
274
                    $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
333
                    $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
275
                    $dest = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),
334
                    $dest = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),
276
                                                    array(DIRECTORY_SEPARATOR,
335
                                                    array(DIRECTORY_SEPARATOR,
277
                                                          DIRECTORY_SEPARATOR,
336
                                                          DIRECTORY_SEPARATOR,
278
                                                          DIRECTORY_SEPARATOR),
337
                                                          DIRECTORY_SEPARATOR),
279
                                                    $dest);
338
                                                    $dest);
280
                    $file = preg_replace('!/+!', '/', $file);
339
                    $file = preg_replace('!/+!', '/', $file);
281
                    $data['data'][] = array($file, $dest);
340
                    $data['data'][] = array($file, $dest);
282
                }
341
                }
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);
293
                if (!$role->isInstallable()) {
353
                if (!$role->isInstallable()) {
294
                    $dest = '(not installable)';
354
                    $dest = '(not installable)';
295
                } else {
355
                } else {
296
                    $dest = $role->processInstallation($info, $att, $file, '');
356
                    $dest = $role->processInstallation($info, $att, $file, '');
297
                    if (PEAR::isError($dest)) {
357
                    if (PEAR::isError($dest)) {
298
                        $dest = '(Unknown role "' . $att['role'] . ')';
358
                        $dest = '(Unknown role "' . $att['role'] . ')';
299
                    } else {
359
                    } else {
300
                        list(,, $dest) = $dest;
360
                        list(,, $dest) = $dest;
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
    }
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]');
317
        }
375
        }
-
 
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
323
        }
382
        }
-
 
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
            }
333
        }
393
        }
-
 
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
            }
350
        } else {
411
        } else {
351
            PEAR::staticPopErrorHandling();
412
            PEAR::staticPopErrorHandling();
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
    }
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);
370
            }
431
            }
-
 
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';
373
            }
435
            }
-
 
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)) {
379
                $uinfo = $obj->getUserInfo();
442
                $uinfo = $obj->getUserInfo();
380
                if (is_array($uinfo)) {
443
                if (is_array($uinfo)) {
381
                    foreach ($uinfo as $message) {
444
                    foreach ($uinfo as $message) {
382
                        if (is_array($message)) {
445
                        if (is_array($message)) {
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) {
431
                    case 'maintainers': {
502
                    case 'maintainers': {
432
                        $i = 0;
503
                        $i = 0;
433
                        $mstr = '';
504
                        $mstr = '';
434
                        foreach ($info[$key] as $m) {
505
                        foreach ($info[$key] as $m) {
435
                            if ($i++ > 0) {
506
                            if ($i++ > 0) {
436
                                $mstr .= "\n";
507
                                $mstr .= "\n";
437
                            }
508
                            }
438
                            $mstr .= $m['name'] . " <";
509
                            $mstr .= $m['name'] . " <";
439
                            if (isset($m['email'])) {
510
                            if (isset($m['email'])) {
440
                                $mstr .= $m['email'];
511
                                $mstr .= $m['email'];
441
                            } else {
512
                            } else {
442
                                $mstr .= $m['handle'] . '@php.net';
513
                                $mstr .= $m['handle'] . '@php.net';
443
                            }
514
                            }
444
                            $mstr .= "> ($m[role])";
515
                            $mstr .= "> ($m[role])";
445
                        }
516
                        }
446
                        $info[$key] = $mstr;
517
                        $info[$key] = $mstr;
447
                        break;
518
                        break;
448
                    }
519
                    }
449
                    case 'release_deps': {
520
                    case 'release_deps': {
450
                        $i = 0;
521
                        $i = 0;
451
                        $dstr = '';
522
                        $dstr = '';
452
                        foreach ($info[$key] as $d) {
523
                        foreach ($info[$key] as $d) {
453
                            if (isset($this->_deps_rel_trans[$d['rel']])) {
524
                            if (isset($this->_deps_rel_trans[$d['rel']])) {
454
                                $rel = $this->_deps_rel_trans[$d['rel']];
525
                                $rel = $this->_deps_rel_trans[$d['rel']];
455
                            } else {
526
                            } else {
456
                                $rel = $d['rel'];
527
                                $rel = $d['rel'];
457
                            }
528
                            }
458
                            if (isset($this->_deps_type_trans[$d['type']])) {
529
                            if (isset($this->_deps_type_trans[$d['type']])) {
459
                                $type = ucfirst($this->_deps_type_trans[$d['type']]);
530
                                $type = ucfirst($this->_deps_type_trans[$d['type']]);
460
                            } else {
531
                            } else {
461
                                $type = $d['type'];
532
                                $type = $d['type'];
462
                            }
533
                            }
463
                            if (isset($d['name'])) {
534
                            if (isset($d['name'])) {
464
                                $name = $d['name'] . ' ';
535
                                $name = $d['name'] . ' ';
465
                            } else {
536
                            } else {
466
                                $name = '';
537
                                $name = '';
467
                            }
538
                            }
468
                            if (isset($d['version'])) {
539
                            if (isset($d['version'])) {
469
                                $version = $d['version'] . ' ';
540
                                $version = $d['version'] . ' ';
470
                            } else {
541
                            } else {
471
                                $version = '';
542
                                $version = '';
472
                            }
543
                            }
473
                            if (isset($d['optional']) && $d['optional'] == 'yes') {
544
                            if (isset($d['optional']) && $d['optional'] == 'yes') {
474
                                $optional = ' (optional)';
545
                                $optional = ' (optional)';
475
                            } else {
546
                            } else {
476
                                $optional = '';
547
                                $optional = '';
477
                            }
548
                            }
478
                            $dstr .= "$type $name$rel $version$optional\n";
549
                            $dstr .= "$type $name$rel $version$optional\n";
479
                        }
550
                        }
480
                        $info[$key] = $dstr;
551
                        $info[$key] = $dstr;
481
                        break;
552
                        break;
482
                    }
553
                    }
483
                    case 'provides' : {
554
                    case 'provides' : {
484
                        $debug = $this->config->get('verbose');
555
                        $debug = $this->config->get('verbose');
485
                        if ($debug < 2) {
556
                        if ($debug < 2) {
486
                            $pstr = 'Classes: ';
557
                            $pstr = 'Classes: ';
487
                        } else {
558
                        } else {
488
                            $pstr = '';
559
                            $pstr = '';
489
                        }
560
                        }
490
                        $i = 0;
561
                        $i = 0;
491
                        foreach ($info[$key] as $p) {
562
                        foreach ($info[$key] as $p) {
492
                            if ($debug < 2 && $p['type'] != "class") {
563
                            if ($debug < 2 && $p['type'] != "class") {
493
                                continue;
564
                                continue;
494
                            }
565
                            }
495
                            // Only print classes when verbosity mode is < 2
566
                            // Only print classes when verbosity mode is < 2
496
                            if ($debug < 2) {
567
                            if ($debug < 2) {
497
                                if ($i++ > 0) {
568
                                if ($i++ > 0) {
498
                                    $pstr .= ", ";
569
                                    $pstr .= ", ";
499
                                }
570
                                }
500
                                $pstr .= $p['name'];
571
                                $pstr .= $p['name'];
501
                            } else {
572
                            } else {
502
                                if ($i++ > 0) {
573
                                if ($i++ > 0) {
503
                                    $pstr .= "\n";
574
                                    $pstr .= "\n";
504
                                }
575
                                }
505
                                $pstr .= ucfirst($p['type']) . " " . $p['name'];
576
                                $pstr .= ucfirst($p['type']) . " " . $p['name'];
506
                                if (isset($p['explicit']) && $p['explicit'] == 1) {
577
                                if (isset($p['explicit']) && $p['explicit'] == 1) {
507
                                    $pstr .= " (explicit)";
578
                                    $pstr .= " (explicit)";
508
                                }
579
                                }
509
                            }
580
                            }
510
                        }
581
                        }
511
                        $info[$key] = $pstr;
582
                        $info[$key] = $pstr;
512
                        break;
583
                        break;
513
                    }
584
                    }
514
                    case 'configure_options' : {
585
                    case 'configure_options' : {
515
                        foreach ($info[$key] as $i => $p) {
586
                        foreach ($info[$key] as $i => $p) {
516
                            $info[$key][$i] = array_map(null, array_keys($p), array_values($p));
587
                            $info[$key][$i] = array_map(null, array_keys($p), array_values($p));
517
                            $info[$key][$i] = array_map(create_function('$a',
588
                            $info[$key][$i] = array_map(create_function('$a',
518
                                'return join(" = ",$a);'), $info[$key][$i]);
589
                                'return join(" = ",$a);'), $info[$key][$i]);
519
                            $info[$key][$i] = implode(', ', $info[$key][$i]);
590
                            $info[$key][$i] = implode(', ', $info[$key][$i]);
520
                        }
591
                        }
521
                        $info[$key] = implode("\n", $info[$key]);
592
                        $info[$key] = implode("\n", $info[$key]);
522
                        break;
593
                        break;
523
                    }
594
                    }
524
                    default: {
595
                    default: {
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') {
535
                $info['Previous Installed Version'] = $info[$key] ? $info[$key] : '- None -';
607
                $info['Previous Installed Version'] = $info[$key] ? $info[$key] : '- None -';
536
                unset($info[$key]);
608
                unset($info[$key]);
537
            } else {
609
            } else {
538
                $info[$key] = trim($info[$key]);
610
                $info[$key] = trim($info[$key]);
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) {
549
            $key = ucwords(trim(str_replace('_', ' ', $key)));
622
            $key = ucwords(trim(str_replace('_', ' ', $key)));
550
            $data['data'][] = array($key, $value);
623
            $data['data'][] = array($key, $value);
551
        }
624
        }
552
        $data['raw'] = $info;
625
        $data['raw'] = $info;
553
 
626
 
554
        $this->ui->outputData($data, 'package-info');
627
        $this->ui->outputData($data, 'package-info');
555
    }
628
    }
556
 
-
 
557
    // }}}
-
 
558
 
629
 
559
    /**
630
    /**
560
     * @access private
631
     * @access private
561
     */
632
     */
562
    function _doInfo2($command, $options, $params, &$obj, $installed)
633
    function _doInfo2($command, $options, $params, &$obj, $installed)
563
    {
634
    {
564
        $reg = &$this->config->getRegistry();
635
        $reg = &$this->config->getRegistry();
565
        $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' .
636
        $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' .
566
            $obj->getVersion();
637
            $obj->getVersion();
567
        $data = array(
638
        $data = array(
568
            'caption' => $caption,
639
            'caption' => $caption,
569
            'border' => true);
640
            'border' => true);
570
        switch ($obj->getPackageType()) {
641
        switch ($obj->getPackageType()) {
571
            case 'php' :
642
            case 'php' :
572
                $release = 'PEAR-style PHP-based Package';
643
                $release = 'PEAR-style PHP-based Package';
573
            break;
644
            break;
574
            case 'extsrc' :
645
            case 'extsrc' :
575
                $release = 'PECL-style PHP extension (source code)';
646
                $release = 'PECL-style PHP extension (source code)';
576
            break;
647
            break;
577
            case 'zendextsrc' :
648
            case 'zendextsrc' :
578
                $release = 'PECL-style Zend extension (source code)';
649
                $release = 'PECL-style Zend extension (source code)';
579
            break;
650
            break;
580
            case 'extbin' :
651
            case 'extbin' :
581
                $release = 'PECL-style PHP extension (binary)';
652
                $release = 'PECL-style PHP extension (binary)';
582
            break;
653
            break;
583
            case 'zendextbin' :
654
            case 'zendextbin' :
584
                $release = 'PECL-style Zend extension (binary)';
655
                $release = 'PECL-style Zend extension (binary)';
585
            break;
656
            break;
586
            case 'bundle' :
657
            case 'bundle' :
587
                $release = 'Package bundle (collection of packages)';
658
                $release = 'Package bundle (collection of packages)';
588
            break;
659
            break;
589
        }
660
        }
590
        $extends = $obj->getExtends();
661
        $extends = $obj->getExtends();
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()),
601
            'Description' => preg_replace('/  +/', ' ', $obj->getDescription()),
673
            'Description' => preg_replace('/  +/', ' ', $obj->getDescription()),
602
            );
674
            );
603
        $info['Maintainers'] = '';
675
        $info['Maintainers'] = '';
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) {
629
            if (isset($uri['uri'])) {
707
            if (isset($uri['uri'])) {
630
                $info['License'] .= ' (' . $uri['uri'] . ')';
708
                $info['License'] .= ' (' . $uri['uri'] . ')';
631
            } else {
709
            } else {
632
                $extra = $obj->getInstalledLocation($info['filesource']);
710
                $extra = $obj->getInstalledLocation($info['filesource']);
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'] = '';
749
                        } else {
847
                        } else {
750
                            $info['Not Compatible with'] .= "\n";
848
                            $info['Not Compatible with'] .= "\n";
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 ' .
797
                            $reg->parsedPackageNameToString($package, true);
902
                            $reg->parsedPackageNameToString($package, true);
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 {
812
                        $info['Not Compatible with'] .= "\n";
919
                        $info['Not Compatible with'] .= "\n";
813
                    }
920
                    }
814
                    $info['Not Compatible with'] .= "$os[name] Operating System";
921
                    $info['Not Compatible with'] .= "$os[name] Operating System";
815
                } else {
922
                } else {
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 {
830
                        $info['Not Compatible with'] .= "\n";
939
                        $info['Not Compatible with'] .= "\n";
831
                    }
940
                    }
832
                    $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'";
941
                    $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'";
833
                } else {
942
                } else {
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'] = '';
851
                            } else {
962
                            } else {
852
                                $info['Not Compatible with'] .= "\n";
963
                                $info['Not Compatible with'] .= "\n";
853
                            }
964
                            }
854
                        } else {
965
                        } else {
855
                            $infoindex = 'Optional Dependencies';
966
                            $infoindex = 'Optional Dependencies';
856
                            if (!isset($info['Optional Dependencies'])) {
967
                            if (!isset($info['Optional Dependencies'])) {
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'])) {
954
                                $info[$groupindex] .= " \n  Version " .
1081
                                $info[$groupindex] .= " \n  Version " .
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'];
974
                            }
1104
                            }
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
-
 
-
 
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
}
1144
}
1010
 
-
 
1011
?>
-