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_PackageFile_v2, package.xml version 2.0, read/write version
3
 * PEAR_PackageFile_v2, package.xml version 2.0, read/write version
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     Greg Beaver <cellog@php.net>
9
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2006 The PHP Group
10
 * @copyright  1997-2009 The Authors
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
11
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
18
 * @version    CVS: $Id: rw.php,v 1.19 2006/10/30 04:12:02 cellog Exp $
-
 
19
 * @link       http://pear.php.net/package/PEAR
12
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a8
13
 * @since      File available since Release 1.4.0a8
21
 */
14
 */
22
/**
15
/**
23
 * For base class
16
 * For base class
24
 */
17
 */
25
require_once 'PEAR/PackageFile/v2.php';
18
require_once 'PEAR/PackageFile/v2.php';
26
/**
19
/**
27
 * @category   pear
20
 * @category   pear
28
 * @package    PEAR
21
 * @package    PEAR
29
 * @author     Greg Beaver <cellog@php.net>
22
 * @author     Greg Beaver <cellog@php.net>
30
 * @copyright  1997-2006 The PHP Group
23
 * @copyright  1997-2009 The Authors
31
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
24
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
32
 * @version    Release: 1.5.1
25
 * @version    Release: 1.10.1
33
 * @link       http://pear.php.net/package/PEAR
26
 * @link       http://pear.php.net/package/PEAR
34
 * @since      Class available since Release 1.4.0a8
27
 * @since      Class available since Release 1.4.0a8
35
 */
28
 */
36
class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
29
class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
37
{
30
{
38
    /**
31
    /**
39
     * @param string Extension name
32
     * @param string Extension name
40
     * @return bool success of operation
33
     * @return bool success of operation
41
     */
34
     */
42
    function setProvidesExtension($extension)
35
    function setProvidesExtension($extension)
43
    {
36
    {
44
        if (in_array($this->getPackageType(),
37
        if (in_array($this->getPackageType(),
45
              array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
38
              array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
46
            if (!isset($this->_packageInfo['providesextension'])) {
39
            if (!isset($this->_packageInfo['providesextension'])) {
47
                // ensure that the channel tag is set up in the right location
40
                // ensure that the channel tag is set up in the right location
48
                $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
41
                $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
49
                    array('usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
42
                    array('usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
50
                    'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
43
                    'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
51
                    'bundle', 'changelog'),
44
                    'bundle', 'changelog'),
52
                    $extension, 'providesextension');
45
                    $extension, 'providesextension');
53
            }
46
            }
54
            $this->_packageInfo['providesextension'] = $extension;
47
            $this->_packageInfo['providesextension'] = $extension;
55
            return true;
48
            return true;
56
        }
49
        }
57
        return false;
50
        return false;
58
    }
51
    }
59
 
52
 
60
    function setPackage($package)
53
    function setPackage($package)
61
    {
54
    {
62
        $this->_isValid = 0;
55
        $this->_isValid = 0;
63
        if (!isset($this->_packageInfo['attribs'])) {
56
        if (!isset($this->_packageInfo['attribs'])) {
64
            $this->_packageInfo = array_merge(array('attribs' => array(
57
            $this->_packageInfo = array_merge(array('attribs' => array(
65
                                 'version' => '2.0',
58
                                 'version' => '2.0',
66
                                 'xmlns' => 'http://pear.php.net/dtd/package-2.0',
59
                                 'xmlns' => 'http://pear.php.net/dtd/package-2.0',
67
                                 'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
60
                                 'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
68
                                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
61
                                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
69
                                 'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
62
                                 'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
70
    http://pear.php.net/dtd/tasks-1.0.xsd
63
    http://pear.php.net/dtd/tasks-1.0.xsd
71
    http://pear.php.net/dtd/package-2.0
64
    http://pear.php.net/dtd/package-2.0
72
    http://pear.php.net/dtd/package-2.0.xsd',
65
    http://pear.php.net/dtd/package-2.0.xsd',
73
                             )), $this->_packageInfo);
66
                             )), $this->_packageInfo);
74
        }
67
        }
75
        if (!isset($this->_packageInfo['name'])) {
68
        if (!isset($this->_packageInfo['name'])) {
76
            return $this->_packageInfo = array_merge(array('name' => $package),
69
            return $this->_packageInfo = array_merge(array('name' => $package),
77
                $this->_packageInfo);
70
                $this->_packageInfo);
78
        }
71
        }
79
        $this->_packageInfo['name'] = $package;
72
        $this->_packageInfo['name'] = $package;
80
    }
73
    }
81
 
74
 
82
    /**
75
    /**
83
     * set this as a package.xml version 2.1
76
     * set this as a package.xml version 2.1
84
     * @access private
77
     * @access private
85
     */
78
     */
86
    function _setPackageVersion2_1()
79
    function _setPackageVersion2_1()
87
    {
80
    {
88
        $info = array(
81
        $info = array(
89
                                 'version' => '2.1',
82
                                 'version' => '2.1',
90
                                 'xmlns' => 'http://pear.php.net/dtd/package-2.1',
83
                                 'xmlns' => 'http://pear.php.net/dtd/package-2.1',
91
                                 'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
84
                                 'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
92
                                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
85
                                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
93
                                 'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
86
                                 'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
94
    http://pear.php.net/dtd/tasks-1.0.xsd
87
    http://pear.php.net/dtd/tasks-1.0.xsd
95
    http://pear.php.net/dtd/package-2.1
88
    http://pear.php.net/dtd/package-2.1
96
    http://pear.php.net/dtd/package-2.1.xsd',
89
    http://pear.php.net/dtd/package-2.1.xsd',
97
                             );
90
                             );
98
        if (!isset($this->_packageInfo['attribs'])) {
91
        if (!isset($this->_packageInfo['attribs'])) {
99
            $this->_packageInfo = array_merge(array('attribs' => $info), $this->_packageInfo);
92
            $this->_packageInfo = array_merge(array('attribs' => $info), $this->_packageInfo);
100
        } else {
93
        } else {
101
            $this->_packageInfo['attribs'] = $info;
94
            $this->_packageInfo['attribs'] = $info;
102
        }
95
        }
103
    }
96
    }
104
 
97
 
105
    function setUri($uri)
98
    function setUri($uri)
106
    {
99
    {
107
        unset($this->_packageInfo['channel']);
100
        unset($this->_packageInfo['channel']);
108
        $this->_isValid = 0;
101
        $this->_isValid = 0;
109
        if (!isset($this->_packageInfo['uri'])) {
102
        if (!isset($this->_packageInfo['uri'])) {
110
            // ensure that the uri tag is set up in the right location
103
            // ensure that the uri tag is set up in the right location
111
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, 
104
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
112
                array('extends', 'summary', 'description', 'lead',
105
                array('extends', 'summary', 'description', 'lead',
113
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
106
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
114
                'stability', 'license', 'notes', 'contents', 'compatible',
107
                'stability', 'license', 'notes', 'contents', 'compatible',
115
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
108
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
116
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
109
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
117
                'extbinrelease', 'bundle', 'changelog'), $uri, 'uri');
110
                'extbinrelease', 'bundle', 'changelog'), $uri, 'uri');
118
        }
111
        }
119
        $this->_packageInfo['uri'] = $uri;
112
        $this->_packageInfo['uri'] = $uri;
120
    }
113
    }
121
 
114
 
122
    function setChannel($channel)
115
    function setChannel($channel)
123
    {
116
    {
124
        unset($this->_packageInfo['uri']);
117
        unset($this->_packageInfo['uri']);
125
        $this->_isValid = 0;
118
        $this->_isValid = 0;
126
        if (!isset($this->_packageInfo['channel'])) {
119
        if (!isset($this->_packageInfo['channel'])) {
127
            // ensure that the channel tag is set up in the right location
120
            // ensure that the channel tag is set up in the right location
128
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
121
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
129
                array('extends', 'summary', 'description', 'lead',
122
                array('extends', 'summary', 'description', 'lead',
130
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
123
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
131
                'stability', 'license', 'notes', 'contents', 'compatible',
124
                'stability', 'license', 'notes', 'contents', 'compatible',
132
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
125
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
133
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
126
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
134
                'extbinrelease', 'bundle', 'changelog'), $channel, 'channel');
127
                'extbinrelease', 'bundle', 'changelog'), $channel, 'channel');
135
        }
128
        }
136
        $this->_packageInfo['channel'] = $channel;
129
        $this->_packageInfo['channel'] = $channel;
137
    }
130
    }
138
 
131
 
139
    function setExtends($extends)
132
    function setExtends($extends)
140
    {
133
    {
141
        $this->_isValid = 0;
134
        $this->_isValid = 0;
142
        if (!isset($this->_packageInfo['extends'])) {
135
        if (!isset($this->_packageInfo['extends'])) {
143
            // ensure that the extends tag is set up in the right location
136
            // ensure that the extends tag is set up in the right location
144
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
137
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
145
                array('summary', 'description', 'lead',
138
                array('summary', 'description', 'lead',
146
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
139
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
147
                'stability', 'license', 'notes', 'contents', 'compatible',
140
                'stability', 'license', 'notes', 'contents', 'compatible',
148
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
141
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
149
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
142
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
150
                'extbinrelease', 'bundle', 'changelog'), $extends, 'extends');
143
                'extbinrelease', 'bundle', 'changelog'), $extends, 'extends');
151
        }
144
        }
152
        $this->_packageInfo['extends'] = $extends;
145
        $this->_packageInfo['extends'] = $extends;
153
    }
146
    }
154
 
147
 
155
    function setSummary($summary)
148
    function setSummary($summary)
156
    {
149
    {
157
        $this->_isValid = 0;
150
        $this->_isValid = 0;
158
        if (!isset($this->_packageInfo['summary'])) {
151
        if (!isset($this->_packageInfo['summary'])) {
159
            // ensure that the summary tag is set up in the right location
152
            // ensure that the summary tag is set up in the right location
160
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
153
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
161
                array('description', 'lead',
154
                array('description', 'lead',
162
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
155
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
163
                'stability', 'license', 'notes', 'contents', 'compatible',
156
                'stability', 'license', 'notes', 'contents', 'compatible',
164
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
157
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
165
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
158
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
166
                'extbinrelease', 'bundle', 'changelog'), $summary, 'summary');
159
                'extbinrelease', 'bundle', 'changelog'), $summary, 'summary');
167
        }
160
        }
168
        $this->_packageInfo['summary'] = $summary;
161
        $this->_packageInfo['summary'] = $summary;
169
    }
162
    }
170
 
163
 
171
    function setDescription($desc)
164
    function setDescription($desc)
172
    {
165
    {
173
        $this->_isValid = 0;
166
        $this->_isValid = 0;
174
        if (!isset($this->_packageInfo['description'])) {
167
        if (!isset($this->_packageInfo['description'])) {
175
            // ensure that the description tag is set up in the right location
168
            // ensure that the description tag is set up in the right location
176
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
169
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
177
                array('lead',
170
                array('lead',
178
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
171
                'developer', 'contributor', 'helper', 'date', 'time', 'version',
179
                'stability', 'license', 'notes', 'contents', 'compatible',
172
                'stability', 'license', 'notes', 'contents', 'compatible',
180
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
173
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
181
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
174
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
182
                'extbinrelease', 'bundle', 'changelog'), $desc, 'description');
175
                'extbinrelease', 'bundle', 'changelog'), $desc, 'description');
183
        }
176
        }
184
        $this->_packageInfo['description'] = $desc;
177
        $this->_packageInfo['description'] = $desc;
185
    }
178
    }
186
 
179
 
187
    /**
180
    /**
188
     * Adds a new maintainer - no checking of duplicates is performed, use
181
     * Adds a new maintainer - no checking of duplicates is performed, use
189
     * updatemaintainer for that purpose.
182
     * updatemaintainer for that purpose.
190
     */
183
     */
191
    function addMaintainer($role, $handle, $name, $email, $active = 'yes')
184
    function addMaintainer($role, $handle, $name, $email, $active = 'yes')
192
    {
185
    {
193
        if (!in_array($role, array('lead', 'developer', 'contributor', 'helper'))) {
186
        if (!in_array($role, array('lead', 'developer', 'contributor', 'helper'))) {
194
            return false;
187
            return false;
195
        }
188
        }
196
        if (isset($this->_packageInfo[$role])) {
189
        if (isset($this->_packageInfo[$role])) {
197
            if (!isset($this->_packageInfo[$role][0])) {
190
            if (!isset($this->_packageInfo[$role][0])) {
198
                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);
191
                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);
199
            }
192
            }
200
            $this->_packageInfo[$role][] =
193
            $this->_packageInfo[$role][] =
201
                array(
194
                array(
202
                    'name' => $name,
195
                    'name' => $name,
203
                    'user' => $handle,
196
                    'user' => $handle,
204
                    'email' => $email,
197
                    'email' => $email,
205
                    'active' => $active,
198
                    'active' => $active,
206
                );
199
                );
207
        } else {
200
        } else {
208
            $testarr = array('lead',
201
            $testarr = array('lead',
209
                    'developer', 'contributor', 'helper', 'date', 'time', 'version',
202
                    'developer', 'contributor', 'helper', 'date', 'time', 'version',
210
                    'stability', 'license', 'notes', 'contents', 'compatible',
203
                    'stability', 'license', 'notes', 'contents', 'compatible',
211
                    'dependencies', 'providesextension', 'usesrole', 'usestask',
204
                    'dependencies', 'providesextension', 'usesrole', 'usestask',
212
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
205
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
213
                    'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog');
206
                    'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog');
214
            foreach (array('lead', 'developer', 'contributor', 'helper') as $testrole) {
207
            foreach (array('lead', 'developer', 'contributor', 'helper') as $testrole) {
215
                array_shift($testarr);
208
                array_shift($testarr);
216
                if ($role == $testrole) {
209
                if ($role == $testrole) {
217
                    break;
210
                    break;
218
                }
211
                }
219
            }
212
            }
220
            if (!isset($this->_packageInfo[$role])) {
213
            if (!isset($this->_packageInfo[$role])) {
221
                // ensure that the extends tag is set up in the right location
214
                // ensure that the extends tag is set up in the right location
222
                $this->_packageInfo = $this->_insertBefore($this->_packageInfo, $testarr,
215
                $this->_packageInfo = $this->_insertBefore($this->_packageInfo, $testarr,
223
                    array(), $role);
216
                    array(), $role);
224
            }
217
            }
225
            $this->_packageInfo[$role] =
218
            $this->_packageInfo[$role] =
226
                array(
219
                array(
227
                    'name' => $name,
220
                    'name' => $name,
228
                    'user' => $handle,
221
                    'user' => $handle,
229
                    'email' => $email,
222
                    'email' => $email,
230
                    'active' => $active,
223
                    'active' => $active,
231
                );
224
                );
232
        }
225
        }
233
        $this->_isValid = 0;
226
        $this->_isValid = 0;
234
    }
227
    }
235
 
228
 
236
    function updateMaintainer($newrole, $handle, $name, $email, $active = 'yes')
229
    function updateMaintainer($newrole, $handle, $name, $email, $active = 'yes')
237
    {
230
    {
238
        $found = false;
231
        $found = false;
239
        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
232
        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
240
            if (!isset($this->_packageInfo[$role])) {
233
            if (!isset($this->_packageInfo[$role])) {
241
                continue;
234
                continue;
242
            }
235
            }
243
            $info = $this->_packageInfo[$role];
236
            $info = $this->_packageInfo[$role];
244
            if (!isset($info[0])) {
237
            if (!isset($info[0])) {
245
                if ($info['user'] == $handle) {
238
                if ($info['user'] == $handle) {
246
                    $found = true;
239
                    $found = true;
247
                    break;
240
                    break;
248
                }
241
                }
249
            }
242
            }
250
            foreach ($info as $i => $maintainer) {
243
            foreach ($info as $i => $maintainer) {
251
                if ($maintainer['user'] == $handle) {
244
                if (is_array($maintainer) && $maintainer['user'] == $handle) {
252
                    $found = $i;
245
                    $found = $i;
253
                    break 2;
246
                    break 2;
254
                }
247
                }
255
            }
248
            }
256
        }
249
        }
257
        if ($found === false) {
250
        if ($found === false) {
258
            return $this->addMaintainer($newrole, $handle, $name, $email, $active);
251
            return $this->addMaintainer($newrole, $handle, $name, $email, $active);
259
        }
252
        }
260
        if ($found !== false) {
253
        if ($found !== false) {
261
            if ($found === true) {
254
            if ($found === true) {
262
                unset($this->_packageInfo[$role]);
255
                unset($this->_packageInfo[$role]);
263
            } else {
256
            } else {
264
                unset($this->_packageInfo[$role][$found]);
257
                unset($this->_packageInfo[$role][$found]);
265
                $this->_packageInfo[$role] = array_values($this->_packageInfo[$role]);
258
                $this->_packageInfo[$role] = array_values($this->_packageInfo[$role]);
266
            }
259
            }
267
        }
260
        }
268
        $this->addMaintainer($newrole, $handle, $name, $email, $active);
261
        $this->addMaintainer($newrole, $handle, $name, $email, $active);
269
        $this->_isValid = 0;
262
        $this->_isValid = 0;
270
    }
263
    }
271
 
264
 
272
    function deleteMaintainer($handle)
265
    function deleteMaintainer($handle)
273
    {
266
    {
274
        $found = false;
267
        $found = false;
275
        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
268
        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
276
            if (!isset($this->_packageInfo[$role])) {
269
            if (!isset($this->_packageInfo[$role])) {
277
                continue;
270
                continue;
278
            }
271
            }
279
            if (!isset($this->_packageInfo[$role][0])) {
272
            if (!isset($this->_packageInfo[$role][0])) {
280
                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);
273
                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);
281
            }
274
            }
282
            foreach ($this->_packageInfo[$role] as $i => $maintainer) {
275
            foreach ($this->_packageInfo[$role] as $i => $maintainer) {
283
                if ($maintainer['user'] == $handle) {
276
                if ($maintainer['user'] == $handle) {
284
                    $found = $i;
277
                    $found = $i;
285
                    break;
278
                    break;
286
                }
279
                }
287
            }
280
            }
288
            if ($found !== false) {
281
            if ($found !== false) {
289
                unset($this->_packageInfo[$role][$found]);
282
                unset($this->_packageInfo[$role][$found]);
290
                if (!count($this->_packageInfo[$role]) && $role == 'lead') {
283
                if (!count($this->_packageInfo[$role]) && $role == 'lead') {
291
                    $this->_isValid = 0;
284
                    $this->_isValid = 0;
292
                }
285
                }
293
                if (!count($this->_packageInfo[$role])) {
286
                if (!count($this->_packageInfo[$role])) {
294
                    unset($this->_packageInfo[$role]);
287
                    unset($this->_packageInfo[$role]);
295
                    return true;
288
                    return true;
296
                }
289
                }
297
                $this->_packageInfo[$role] =
290
                $this->_packageInfo[$role] =
298
                    array_values($this->_packageInfo[$role]);
291
                    array_values($this->_packageInfo[$role]);
299
                if (count($this->_packageInfo[$role]) == 1) {
292
                if (count($this->_packageInfo[$role]) == 1) {
300
                    $this->_packageInfo[$role] = $this->_packageInfo[$role][0];
293
                    $this->_packageInfo[$role] = $this->_packageInfo[$role][0];
301
                }
294
                }
302
                return true;
295
                return true;
303
            }
296
            }
304
            if (count($this->_packageInfo[$role]) == 1) {
297
            if (count($this->_packageInfo[$role]) == 1) {
305
                $this->_packageInfo[$role] = $this->_packageInfo[$role][0];
298
                $this->_packageInfo[$role] = $this->_packageInfo[$role][0];
306
            }
299
            }
307
        }
300
        }
308
        return false;
301
        return false;
309
    }
302
    }
310
 
303
 
311
    function setReleaseVersion($version)
304
    function setReleaseVersion($version)
312
    {
305
    {
313
        if (isset($this->_packageInfo['version']) &&
306
        if (isset($this->_packageInfo['version']) &&
314
              isset($this->_packageInfo['version']['release'])) {
307
              isset($this->_packageInfo['version']['release'])) {
315
            unset($this->_packageInfo['version']['release']);
308
            unset($this->_packageInfo['version']['release']);
316
        }
309
        }
317
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
310
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
318
            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
311
            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
319
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
312
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
320
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
313
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
321
                'extbinrelease', 'bundle', 'changelog'),
314
                'extbinrelease', 'bundle', 'changelog'),
322
            'release' => array('api')));
315
            'release' => array('api')));
323
        $this->_isValid = 0;
316
        $this->_isValid = 0;
324
    }
317
    }
325
 
318
 
326
    function setAPIVersion($version)
319
    function setAPIVersion($version)
327
    {
320
    {
328
        if (isset($this->_packageInfo['version']) &&
321
        if (isset($this->_packageInfo['version']) &&
329
              isset($this->_packageInfo['version']['api'])) {
322
              isset($this->_packageInfo['version']['api'])) {
330
            unset($this->_packageInfo['version']['api']);
323
            unset($this->_packageInfo['version']['api']);
331
        }
324
        }
332
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
325
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
333
            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
326
            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
334
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
327
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
335
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
328
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
336
                'extbinrelease', 'bundle', 'changelog'),
329
                'extbinrelease', 'bundle', 'changelog'),
337
            'api' => array()));
330
            'api' => array()));
338
        $this->_isValid = 0;
331
        $this->_isValid = 0;
339
    }
332
    }
340
 
333
 
341
    /**
334
    /**
342
     * snapshot|devel|alpha|beta|stable
335
     * snapshot|devel|alpha|beta|stable
343
     */
336
     */
344
    function setReleaseStability($state)
337
    function setReleaseStability($state)
345
    {
338
    {
346
        if (isset($this->_packageInfo['stability']) &&
339
        if (isset($this->_packageInfo['stability']) &&
347
              isset($this->_packageInfo['stability']['release'])) {
340
              isset($this->_packageInfo['stability']['release'])) {
348
            unset($this->_packageInfo['stability']['release']);
341
            unset($this->_packageInfo['stability']['release']);
349
        }
342
        }
350
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
343
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
351
            'stability' => array('license', 'notes', 'contents', 'compatible',
344
            'stability' => array('license', 'notes', 'contents', 'compatible',
352
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
345
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
353
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
346
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
354
                'extbinrelease', 'bundle', 'changelog'),
347
                'extbinrelease', 'bundle', 'changelog'),
355
            'release' => array('api')));
348
            'release' => array('api')));
356
        $this->_isValid = 0;
349
        $this->_isValid = 0;
357
    }
350
    }
358
 
351
 
359
    /**
352
    /**
360
     * @param devel|alpha|beta|stable
353
     * @param devel|alpha|beta|stable
361
     */
354
     */
362
    function setAPIStability($state)
355
    function setAPIStability($state)
363
    {
356
    {
364
        if (isset($this->_packageInfo['stability']) &&
357
        if (isset($this->_packageInfo['stability']) &&
365
              isset($this->_packageInfo['stability']['api'])) {
358
              isset($this->_packageInfo['stability']['api'])) {
366
            unset($this->_packageInfo['stability']['api']);
359
            unset($this->_packageInfo['stability']['api']);
367
        }
360
        }
368
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
361
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
369
            'stability' => array('license', 'notes', 'contents', 'compatible',
362
            'stability' => array('license', 'notes', 'contents', 'compatible',
370
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
363
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
371
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
364
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
372
                'extbinrelease', 'bundle', 'changelog'),
365
                'extbinrelease', 'bundle', 'changelog'),
373
            'api' => array()));
366
            'api' => array()));
374
        $this->_isValid = 0;
367
        $this->_isValid = 0;
375
    }
368
    }
376
 
369
 
377
    function setLicense($license, $uri = false, $filesource = false)
370
    function setLicense($license, $uri = false, $filesource = false)
378
    {
371
    {
379
        if (!isset($this->_packageInfo['license'])) {
372
        if (!isset($this->_packageInfo['license'])) {
380
            // ensure that the license tag is set up in the right location
373
            // ensure that the license tag is set up in the right location
381
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
374
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
382
                array('notes', 'contents', 'compatible',
375
                array('notes', 'contents', 'compatible',
383
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
376
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
384
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
377
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
385
                'extbinrelease', 'bundle', 'changelog'), 0, 'license');
378
                'extbinrelease', 'bundle', 'changelog'), 0, 'license');
386
        }
379
        }
387
        if ($uri || $filesource) {
380
        if ($uri || $filesource) {
388
            $attribs = array();
381
            $attribs = array();
389
            if ($uri) {
382
            if ($uri) {
390
                $attribs['uri'] = $uri;
383
                $attribs['uri'] = $uri;
391
            }
384
            }
392
            $uri = true; // for test below
385
            $uri = true; // for test below
393
            if ($filesource) {
386
            if ($filesource) {
394
                $attribs['filesource'] = $filesource;
387
                $attribs['filesource'] = $filesource;
395
            }
388
            }
396
        }
389
        }
397
        $license = $uri ? array('attribs' => $attribs, '_content' => $license) : $license;
390
        $license = $uri ? array('attribs' => $attribs, '_content' => $license) : $license;
398
        $this->_packageInfo['license'] = $license;
391
        $this->_packageInfo['license'] = $license;
399
        $this->_isValid = 0;
392
        $this->_isValid = 0;
400
    }
393
    }
401
 
394
 
402
    function setNotes($notes)
395
    function setNotes($notes)
403
    {
396
    {
404
        $this->_isValid = 0;
397
        $this->_isValid = 0;
405
        if (!isset($this->_packageInfo['notes'])) {
398
        if (!isset($this->_packageInfo['notes'])) {
406
            // ensure that the notes tag is set up in the right location
399
            // ensure that the notes tag is set up in the right location
407
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
400
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
408
                array('contents', 'compatible',
401
                array('contents', 'compatible',
409
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
402
                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
410
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
403
                'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
411
                'extbinrelease', 'bundle', 'changelog'), $notes, 'notes');
404
                'extbinrelease', 'bundle', 'changelog'), $notes, 'notes');
412
        }
405
        }
413
        $this->_packageInfo['notes'] = $notes;
406
        $this->_packageInfo['notes'] = $notes;
414
    }
407
    }
415
 
408
 
416
    /**
409
    /**
417
     * This is only used at install-time, after all serialization
410
     * This is only used at install-time, after all serialization
418
     * is over.
411
     * is over.
419
     * @param string file name
412
     * @param string file name
420
     * @param string installed path
413
     * @param string installed path
421
     */
414
     */
422
    function setInstalledAs($file, $path)
415
    function setInstalledAs($file, $path)
423
    {
416
    {
424
        if ($path) {
417
        if ($path) {
425
            return $this->_packageInfo['filelist'][$file]['installed_as'] = $path;
418
            return $this->_packageInfo['filelist'][$file]['installed_as'] = $path;
426
        }
419
        }
427
        unset($this->_packageInfo['filelist'][$file]['installed_as']);
420
        unset($this->_packageInfo['filelist'][$file]['installed_as']);
428
    }
421
    }
429
 
422
 
430
    /**
423
    /**
431
     * This is only used at install-time, after all serialization
424
     * This is only used at install-time, after all serialization
432
     * is over.
425
     * is over.
433
     */
426
     */
434
    function installedFile($file, $atts)
427
    function installedFile($file, $atts)
435
    {
428
    {
436
        if (isset($this->_packageInfo['filelist'][$file])) {
429
        if (isset($this->_packageInfo['filelist'][$file])) {
437
            $this->_packageInfo['filelist'][$file] =
430
            $this->_packageInfo['filelist'][$file] =
438
                array_merge($this->_packageInfo['filelist'][$file], $atts['attribs']);
431
                array_merge($this->_packageInfo['filelist'][$file], $atts['attribs']);
439
        } else {
432
        } else {
440
            $this->_packageInfo['filelist'][$file] = $atts['attribs'];
433
            $this->_packageInfo['filelist'][$file] = $atts['attribs'];
441
        }
434
        }
442
    }
435
    }
443
 
436
 
444
    /**
437
    /**
445
     * Reset the listing of package contents
438
     * Reset the listing of package contents
446
     * @param string base installation dir for the whole package, if any
439
     * @param string base installation dir for the whole package, if any
447
     */
440
     */
448
    function clearContents($baseinstall = false)
441
    function clearContents($baseinstall = false)
449
    {
442
    {
450
        $this->_filesValid = false;
443
        $this->_filesValid = false;
451
        $this->_isValid = 0;
444
        $this->_isValid = 0;
452
        if (!isset($this->_packageInfo['contents'])) {
445
        if (!isset($this->_packageInfo['contents'])) {
453
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
446
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
454
                array('compatible',
447
                array('compatible',
455
                    'dependencies', 'providesextension', 'usesrole', 'usestask',
448
                    'dependencies', 'providesextension', 'usesrole', 'usestask',
456
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
449
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
457
                    'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
450
                    'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
458
                    'bundle', 'changelog'), array(), 'contents');
451
                    'bundle', 'changelog'), array(), 'contents');
459
        }
452
        }
460
        if ($this->getPackageType() != 'bundle') {
453
        if ($this->getPackageType() != 'bundle') {
461
            $this->_packageInfo['contents'] = 
454
            $this->_packageInfo['contents'] =
462
                array('dir' => array('attribs' => array('name' => '/')));
455
                array('dir' => array('attribs' => array('name' => '/')));
463
            if ($baseinstall) {
456
            if ($baseinstall) {
464
                $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'] = $baseinstall;
457
                $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'] = $baseinstall;
465
            }
458
            }
-
 
459
        } else {
-
 
460
            $this->_packageInfo['contents'] = array('bundledpackage' => array());
466
        }
461
        }
467
    }
462
    }
468
 
463
 
469
    /**
464
    /**
470
     * @param string relative path of the bundled package.
465
     * @param string relative path of the bundled package.
471
     */
466
     */
472
    function addBundledPackage($path)
467
    function addBundledPackage($path)
473
    {
468
    {
474
        if ($this->getPackageType() != 'bundle') {
469
        if ($this->getPackageType() != 'bundle') {
475
            return false;
470
            return false;
476
        }
471
        }
477
        $this->_filesValid = false;
472
        $this->_filesValid = false;
478
        $this->_isValid = 0;
473
        $this->_isValid = 0;
479
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $path, array(
474
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $path, array(
480
                'contents' => array('compatible', 'dependencies', 'providesextension',
475
                'contents' => array('compatible', 'dependencies', 'providesextension',
481
                'usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
476
                'usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
482
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
477
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
483
                'bundle', 'changelog'),
478
                'bundle', 'changelog'),
484
                'bundledpackage' => array()));
479
                'bundledpackage' => array()));
485
    }
480
    }
486
 
481
 
487
    /**
482
    /**
488
     * @param string file name
483
     * @param string file name
489
     * @param PEAR_Task_Common a read/write task
484
     * @param PEAR_Task_Common a read/write task
490
     */
485
     */
491
    function addTaskToFile($filename, $task)
486
    function addTaskToFile($filename, $task)
492
    {
487
    {
493
        if (!method_exists($task, 'getXml')) {
488
        if (!method_exists($task, 'getXml')) {
494
            return false;
489
            return false;
495
        }
490
        }
496
        if (!method_exists($task, 'getName')) {
491
        if (!method_exists($task, 'getName')) {
497
            return false;
492
            return false;
498
        }
493
        }
499
        if (!method_exists($task, 'validate')) {
494
        if (!method_exists($task, 'validate')) {
500
            return false;
495
            return false;
501
        }
496
        }
502
        if (!$task->validate()) {
497
        if (!$task->validate()) {
503
            return false;
498
            return false;
504
        }
499
        }
505
        if (!isset($this->_packageInfo['contents']['dir']['file'])) {
500
        if (!isset($this->_packageInfo['contents']['dir']['file'])) {
506
            return false;
501
            return false;
507
        }
502
        }
508
        $this->getTasksNs(); // discover the tasks namespace if not done already
503
        $this->getTasksNs(); // discover the tasks namespace if not done already
509
        $files = $this->_packageInfo['contents']['dir']['file'];
504
        $files = $this->_packageInfo['contents']['dir']['file'];
510
        if (!isset($files[0])) {
505
        if (!isset($files[0])) {
511
            $files = array($files);
506
            $files = array($files);
512
            $ind = false;
507
            $ind = false;
513
        } else {
508
        } else {
514
            $ind = true;
509
            $ind = true;
515
        }
510
        }
516
        foreach ($files as $i => $file) {
511
        foreach ($files as $i => $file) {
517
            if (isset($file['attribs'])) {
512
            if (isset($file['attribs'])) {
518
                if ($file['attribs']['name'] == $filename) {
513
                if ($file['attribs']['name'] == $filename) {
519
                    if ($ind) {
514
                    if ($ind) {
520
                        $t = isset($this->_packageInfo['contents']['dir']['file'][$i]
515
                        $t = isset($this->_packageInfo['contents']['dir']['file'][$i]
521
                              ['attribs'][$this->_tasksNs .
516
                              ['attribs'][$this->_tasksNs .
522
                              ':' . $task->getName()]) ?
517
                              ':' . $task->getName()]) ?
523
                              $this->_packageInfo['contents']['dir']['file'][$i]
518
                              $this->_packageInfo['contents']['dir']['file'][$i]
524
                              ['attribs'][$this->_tasksNs .
519
                              ['attribs'][$this->_tasksNs .
525
                              ':' . $task->getName()] : false;
520
                              ':' . $task->getName()] : false;
526
                        if ($t && !isset($t[0])) {
521
                        if ($t && !isset($t[0])) {
527
                            $this->_packageInfo['contents']['dir']['file'][$i]
522
                            $this->_packageInfo['contents']['dir']['file'][$i]
528
                                [$this->_tasksNs . ':' . $task->getName()] = array($t);
523
                                [$this->_tasksNs . ':' . $task->getName()] = array($t);
529
                        }
524
                        }
530
                        $this->_packageInfo['contents']['dir']['file'][$i][$this->_tasksNs .
525
                        $this->_packageInfo['contents']['dir']['file'][$i][$this->_tasksNs .
531
                            ':' . $task->getName()][] = $task->getXml();
526
                            ':' . $task->getName()][] = $task->getXml();
532
                    } else {
527
                    } else {
533
                        $t = isset($this->_packageInfo['contents']['dir']['file']
528
                        $t = isset($this->_packageInfo['contents']['dir']['file']
534
                              ['attribs'][$this->_tasksNs .
529
                              ['attribs'][$this->_tasksNs .
535
                              ':' . $task->getName()]) ? $this->_packageInfo['contents']['dir']['file']
530
                              ':' . $task->getName()]) ? $this->_packageInfo['contents']['dir']['file']
536
                              ['attribs'][$this->_tasksNs .
531
                              ['attribs'][$this->_tasksNs .
537
                              ':' . $task->getName()] : false;
532
                              ':' . $task->getName()] : false;
538
                        if ($t && !isset($t[0])) {
533
                        if ($t && !isset($t[0])) {
539
                            $this->_packageInfo['contents']['dir']['file']
534
                            $this->_packageInfo['contents']['dir']['file']
540
                                [$this->_tasksNs . ':' . $task->getName()] = array($t);
535
                                [$this->_tasksNs . ':' . $task->getName()] = array($t);
541
                        }
536
                        }
542
                        $this->_packageInfo['contents']['dir']['file'][$this->_tasksNs .
537
                        $this->_packageInfo['contents']['dir']['file'][$this->_tasksNs .
543
                            ':' . $task->getName()][] = $task->getXml();
538
                            ':' . $task->getName()][] = $task->getXml();
544
                    }
539
                    }
545
                    return true;
540
                    return true;
546
                }
541
                }
547
            }
542
            }
548
        }
543
        }
549
        return false;
544
        return false;
550
    }
545
    }
551
 
546
 
552
    /**
547
    /**
553
     * @param string path to the file
548
     * @param string path to the file
554
     * @param string filename
549
     * @param string filename
555
     * @param array extra attributes
550
     * @param array extra attributes
556
     */
551
     */
557
    function addFile($dir, $file, $attrs)
552
    function addFile($dir, $file, $attrs)
558
    {
553
    {
559
        if ($this->getPackageType() == 'bundle') {
554
        if ($this->getPackageType() == 'bundle') {
560
            return false;
555
            return false;
561
        }
556
        }
562
        $this->_filesValid = false;
557
        $this->_filesValid = false;
563
        $this->_isValid = 0;
558
        $this->_isValid = 0;
564
        $dir = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'), $dir);
559
        $dir = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'), $dir);
565
        if ($dir == '/' || $dir == '') {
560
        if ($dir == '/' || $dir == '') {
566
            $dir = '';
561
            $dir = '';
567
        } else {
562
        } else {
568
            $dir .= '/';
563
            $dir .= '/';
569
        }
564
        }
570
        $attrs['name'] = $dir . $file;
565
        $attrs['name'] = $dir . $file;
571
        if (!isset($this->_packageInfo['contents'])) {
566
        if (!isset($this->_packageInfo['contents'])) {
572
            // ensure that the contents tag is set up
567
            // ensure that the contents tag is set up
573
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
568
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
574
                array('compatible', 'dependencies', 'providesextension', 'usesrole', 'usestask',
569
                array('compatible', 'dependencies', 'providesextension', 'usesrole', 'usestask',
575
                'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
570
                'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
576
                'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
571
                'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
577
                'bundle', 'changelog'), array(), 'contents');
572
                'bundle', 'changelog'), array(), 'contents');
578
        }
573
        }
579
        if (isset($this->_packageInfo['contents']['dir']['file'])) {
574
        if (isset($this->_packageInfo['contents']['dir']['file'])) {
580
            if (!isset($this->_packageInfo['contents']['dir']['file'][0])) {
575
            if (!isset($this->_packageInfo['contents']['dir']['file'][0])) {
581
                $this->_packageInfo['contents']['dir']['file'] =
576
                $this->_packageInfo['contents']['dir']['file'] =
582
                    array($this->_packageInfo['contents']['dir']['file']);
577
                    array($this->_packageInfo['contents']['dir']['file']);
583
            }
578
            }
584
            $this->_packageInfo['contents']['dir']['file'][]['attribs'] = $attrs;
579
            $this->_packageInfo['contents']['dir']['file'][]['attribs'] = $attrs;
585
        } else {
580
        } else {
586
            $this->_packageInfo['contents']['dir']['file']['attribs'] = $attrs;
581
            $this->_packageInfo['contents']['dir']['file']['attribs'] = $attrs;
587
        }
582
        }
588
    }
583
    }
589
 
584
 
590
    /**
585
    /**
591
     * @param string Dependent package name
586
     * @param string Dependent package name
592
     * @param string Dependent package's channel name
587
     * @param string Dependent package's channel name
593
     * @param string minimum version of specified package that this release is guaranteed to be
588
     * @param string minimum version of specified package that this release is guaranteed to be
594
     *               compatible with
589
     *               compatible with
595
     * @param string maximum version of specified package that this release is guaranteed to be
590
     * @param string maximum version of specified package that this release is guaranteed to be
596
     *               compatible with
591
     *               compatible with
597
     * @param string versions of specified package that this release is not compatible with
592
     * @param string versions of specified package that this release is not compatible with
598
     */
593
     */
599
    function addCompatiblePackage($name, $channel, $min, $max, $exclude = false)
594
    function addCompatiblePackage($name, $channel, $min, $max, $exclude = false)
600
    {
595
    {
601
        $this->_isValid = 0;
596
        $this->_isValid = 0;
602
        $set = array(
597
        $set = array(
603
            'name' => $name,
598
            'name' => $name,
604
            'channel' => $channel,
599
            'channel' => $channel,
605
            'min' => $min,
600
            'min' => $min,
606
            'max' => $max,
601
            'max' => $max,
607
        );
602
        );
608
        if ($exclude) {
603
        if ($exclude) {
609
            $set['exclude'] = $exclude;
604
            $set['exclude'] = $exclude;
610
        }
605
        }
611
        $this->_isValid = 0;
606
        $this->_isValid = 0;
612
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
607
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
613
                'compatible' => array('dependencies', 'providesextension', 'usesrole', 'usestask',
608
                'compatible' => array('dependencies', 'providesextension', 'usesrole', 'usestask',
614
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
609
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
615
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
610
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
616
            ));
611
            ));
617
    }
612
    }
618
 
613
 
619
    /**
614
    /**
620
     * Removes the <usesrole> tag entirely
615
     * Removes the <usesrole> tag entirely
621
     */
616
     */
622
    function resetUsesrole()
617
    function resetUsesrole()
623
    {
618
    {
624
        if (isset($this->_packageInfo['usesrole'])) {
619
        if (isset($this->_packageInfo['usesrole'])) {
625
            unset($this->_packageInfo['usesrole']);
620
            unset($this->_packageInfo['usesrole']);
626
        }
621
        }
627
    }
622
    }
628
 
623
 
629
    /**
624
    /**
630
     * @param string
625
     * @param string
631
     * @param string package name or uri
626
     * @param string package name or uri
632
     * @param string channel name if non-uri
627
     * @param string channel name if non-uri
633
     */
628
     */
634
    function addUsesrole($role, $packageOrUri, $channel = false) {
629
    function addUsesrole($role, $packageOrUri, $channel = false) {
635
        $set = array('role' => $role);
630
        $set = array('role' => $role);
636
        if ($channel) {
631
        if ($channel) {
637
            $set['package'] = $packageOrUri;
632
            $set['package'] = $packageOrUri;
638
            $set['channel'] = $channel;
633
            $set['channel'] = $channel;
639
        } else {
634
        } else {
640
            $set['uri'] = $packageOrUri;
635
            $set['uri'] = $packageOrUri;
641
        }
636
        }
642
        $this->_isValid = 0;
637
        $this->_isValid = 0;
643
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
638
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
644
                'usesrole' => array('usestask', 'srcpackage', 'srcuri',
639
                'usesrole' => array('usestask', 'srcpackage', 'srcuri',
645
                    'phprelease', 'extsrcrelease', 'extbinrelease',
640
                    'phprelease', 'extsrcrelease', 'extbinrelease',
646
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
641
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
647
            ));
642
            ));
648
    }
643
    }
649
 
644
 
650
    /**
645
    /**
651
     * Removes the <usestask> tag entirely
646
     * Removes the <usestask> tag entirely
652
     */
647
     */
653
    function resetUsestask()
648
    function resetUsestask()
654
    {
649
    {
655
        if (isset($this->_packageInfo['usestask'])) {
650
        if (isset($this->_packageInfo['usestask'])) {
656
            unset($this->_packageInfo['usestask']);
651
            unset($this->_packageInfo['usestask']);
657
        }
652
        }
658
    }
653
    }
659
 
654
 
660
 
655
 
661
    /**
656
    /**
662
     * @param string
657
     * @param string
663
     * @param string package name or uri
658
     * @param string package name or uri
664
     * @param string channel name if non-uri
659
     * @param string channel name if non-uri
665
     */
660
     */
666
    function addUsestask($task, $packageOrUri, $channel = false) {
661
    function addUsestask($task, $packageOrUri, $channel = false) {
667
        $set = array('task' => $task);
662
        $set = array('task' => $task);
668
        if ($channel) {
663
        if ($channel) {
669
            $set['package'] = $packageOrUri;
664
            $set['package'] = $packageOrUri;
670
            $set['channel'] = $channel;
665
            $set['channel'] = $channel;
671
        } else {
666
        } else {
672
            $set['uri'] = $packageOrUri;
667
            $set['uri'] = $packageOrUri;
673
        }
668
        }
674
        $this->_isValid = 0;
669
        $this->_isValid = 0;
675
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
670
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
676
                'usestask' => array('srcpackage', 'srcuri',
671
                'usestask' => array('srcpackage', 'srcuri',
677
                    'phprelease', 'extsrcrelease', 'extbinrelease',
672
                    'phprelease', 'extsrcrelease', 'extbinrelease',
678
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
673
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
679
            ));
674
            ));
680
    }
675
    }
681
 
676
 
682
    /**
677
    /**
683
     * Remove all compatible tags
678
     * Remove all compatible tags
684
     */
679
     */
685
    function clearCompatible()
680
    function clearCompatible()
686
    {
681
    {
687
        unset($this->_packageInfo['compatible']);
682
        unset($this->_packageInfo['compatible']);
688
    }
683
    }
689
 
684
 
690
    /**
685
    /**
691
     * Reset dependencies prior to adding new ones
686
     * Reset dependencies prior to adding new ones
692
     */
687
     */
693
    function clearDeps()
688
    function clearDeps()
694
    {
689
    {
695
        if (!isset($this->_packageInfo['dependencies'])) {
690
        if (!isset($this->_packageInfo['dependencies'])) {
696
            $this->_packageInfo = $this->_mergeTag($this->_packageInfo, array(),
691
            $this->_packageInfo = $this->_mergeTag($this->_packageInfo, array(),
697
                array(
692
                array(
698
                    'dependencies' => array('providesextension', 'usesrole', 'usestask',
693
                    'dependencies' => array('providesextension', 'usesrole', 'usestask',
699
                        'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
694
                        'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
700
                        'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')));
695
                        'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')));
701
        }
696
        }
702
        $this->_packageInfo['dependencies'] = array();
697
        $this->_packageInfo['dependencies'] = array();
703
    }
698
    }
704
 
699
 
705
    /**
700
    /**
706
     * @param string minimum PHP version allowed
701
     * @param string minimum PHP version allowed
707
     * @param string maximum PHP version allowed
702
     * @param string maximum PHP version allowed
708
     * @param array $exclude incompatible PHP versions
703
     * @param array $exclude incompatible PHP versions
709
     */
704
     */
710
    function setPhpDep($min, $max = false, $exclude = false)
705
    function setPhpDep($min, $max = false, $exclude = false)
711
    {
706
    {
712
        $this->_isValid = 0;
707
        $this->_isValid = 0;
713
        $dep =
708
        $dep =
714
            array(
709
            array(
715
                'min' => $min,
710
                'min' => $min,
716
            );
711
            );
717
        if ($max) {
712
        if ($max) {
718
            $dep['max'] = $max;
713
            $dep['max'] = $max;
719
        }
714
        }
720
        if ($exclude) {
715
        if ($exclude) {
721
            if (count($exclude) == 1) {
716
            if (count($exclude) == 1) {
722
                $exclude = $exclude[0];
717
                $exclude = $exclude[0];
723
            }
718
            }
724
            $dep['exclude'] = $exclude;
719
            $dep['exclude'] = $exclude;
725
        }
720
        }
726
        if (isset($this->_packageInfo['dependencies']['required']['php'])) {
721
        if (isset($this->_packageInfo['dependencies']['required']['php'])) {
727
            $this->_stack->push(__FUNCTION__, 'warning', array('dep' =>
722
            $this->_stack->push(__FUNCTION__, 'warning', array('dep' =>
728
            $this->_packageInfo['dependencies']['required']['php']),
723
            $this->_packageInfo['dependencies']['required']['php']),
729
                'warning: PHP dependency already exists, overwriting');
724
                'warning: PHP dependency already exists, overwriting');
730
            unset($this->_packageInfo['dependencies']['required']['php']);
725
            unset($this->_packageInfo['dependencies']['required']['php']);
731
        }
726
        }
732
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
727
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
733
            array(
728
            array(
734
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
729
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
735
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
730
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
736
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
731
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
737
                'required' => array('optional', 'group'),
732
                'required' => array('optional', 'group'),
738
                'php' => array('pearinstaller', 'package', 'subpackage', 'extension', 'os', 'arch')
733
                'php' => array('pearinstaller', 'package', 'subpackage', 'extension', 'os', 'arch')
739
            ));
734
            ));
740
        return true;
735
        return true;
741
    }
736
    }
742
 
737
 
743
    /**
738
    /**
744
     * @param string minimum allowed PEAR installer version
739
     * @param string minimum allowed PEAR installer version
745
     * @param string maximum allowed PEAR installer version
740
     * @param string maximum allowed PEAR installer version
746
     * @param string recommended PEAR installer version
741
     * @param string recommended PEAR installer version
747
     * @param array incompatible version of the PEAR installer
742
     * @param array incompatible version of the PEAR installer
748
     */
743
     */
749
    function setPearinstallerDep($min, $max = false, $recommended = false, $exclude = false)
744
    function setPearinstallerDep($min, $max = false, $recommended = false, $exclude = false)
750
    {
745
    {
751
        $this->_isValid = 0;
746
        $this->_isValid = 0;
752
        $dep =
747
        $dep =
753
            array(
748
            array(
754
                'min' => $min,
749
                'min' => $min,
755
            );
750
            );
756
        if ($max) {
751
        if ($max) {
757
            $dep['max'] = $max;
752
            $dep['max'] = $max;
758
        }
753
        }
759
        if ($recommended) {
754
        if ($recommended) {
760
            $dep['recommended'] = $recommended;
755
            $dep['recommended'] = $recommended;
761
        }
756
        }
762
        if ($exclude) {
757
        if ($exclude) {
763
            if (count($exclude) == 1) {
758
            if (count($exclude) == 1) {
764
                $exclude = $exclude[0];
759
                $exclude = $exclude[0];
765
            }
760
            }
766
            $dep['exclude'] = $exclude;
761
            $dep['exclude'] = $exclude;
767
        }
762
        }
768
        if (isset($this->_packageInfo['dependencies']['required']['pearinstaller'])) {
763
        if (isset($this->_packageInfo['dependencies']['required']['pearinstaller'])) {
769
            $this->_stack->push(__FUNCTION__, 'warning', array('dep' =>
764
            $this->_stack->push(__FUNCTION__, 'warning', array('dep' =>
770
            $this->_packageInfo['dependencies']['required']['pearinstaller']),
765
            $this->_packageInfo['dependencies']['required']['pearinstaller']),
771
                'warning: PEAR Installer dependency already exists, overwriting');
766
                'warning: PEAR Installer dependency already exists, overwriting');
772
            unset($this->_packageInfo['dependencies']['required']['pearinstaller']);
767
            unset($this->_packageInfo['dependencies']['required']['pearinstaller']);
773
        }
768
        }
774
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
769
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
775
            array(
770
            array(
776
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
771
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
777
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
772
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
778
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
773
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
779
                'required' => array('optional', 'group'),
774
                'required' => array('optional', 'group'),
780
                'pearinstaller' => array('package', 'subpackage', 'extension', 'os', 'arch')
775
                'pearinstaller' => array('package', 'subpackage', 'extension', 'os', 'arch')
781
            ));
776
            ));
782
    }
777
    }
783
 
778
 
784
    /**
779
    /**
785
     * Mark a package as conflicting with this package
780
     * Mark a package as conflicting with this package
786
     * @param string package name
781
     * @param string package name
787
     * @param string package channel
782
     * @param string package channel
788
     * @param string extension this package provides, if any
783
     * @param string extension this package provides, if any
789
     * @param string|false minimum version required
784
     * @param string|false minimum version required
790
     * @param string|false maximum version allowed
785
     * @param string|false maximum version allowed
791
     * @param array|false versions to exclude from installation
786
     * @param array|false versions to exclude from installation
792
     */
787
     */
793
    function addConflictingPackageDepWithChannel($name, $channel,
788
    function addConflictingPackageDepWithChannel($name, $channel,
794
                $providesextension = false, $min = false, $max = false, $exclude = false)
789
                $providesextension = false, $min = false, $max = false, $exclude = false)
795
    {
790
    {
796
        $this->_isValid = 0;
791
        $this->_isValid = 0;
797
        $dep = $this->_constructDep($name, $channel, false, $min, $max, false,
792
        $dep = $this->_constructDep($name, $channel, false, $min, $max, false,
798
            $exclude, $providesextension, false, true);
793
            $exclude, $providesextension, false, true);
799
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
794
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
800
            array(
795
            array(
801
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
796
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
802
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
797
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
803
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
798
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
804
                'required' => array('optional', 'group'),
799
                'required' => array('optional', 'group'),
805
                'package' => array('subpackage', 'extension', 'os', 'arch')
800
                'package' => array('subpackage', 'extension', 'os', 'arch')
806
            ));
801
            ));
807
    }
802
    }
808
 
803
 
809
    /**
804
    /**
810
     * Mark a package as conflicting with this package
805
     * Mark a package as conflicting with this package
811
     * @param string package name
806
     * @param string package name
812
     * @param string package channel
807
     * @param string package channel
813
     * @param string extension this package provides, if any
808
     * @param string extension this package provides, if any
814
     */
809
     */
815
    function addConflictingPackageDepWithUri($name, $uri, $providesextension = false)
810
    function addConflictingPackageDepWithUri($name, $uri, $providesextension = false)
816
    {
811
    {
817
        $this->_isValid = 0;
812
        $this->_isValid = 0;
818
        $dep =
813
        $dep =
819
            array(
814
            array(
820
                'name' => $name,
815
                'name' => $name,
821
                'uri' => $uri,
816
                'uri' => $uri,
822
                'conflicts' => '',
817
                'conflicts' => '',
823
            );
818
            );
824
        if ($providesextension) {
819
        if ($providesextension) {
825
            $dep['providesextension'] = $providesextension;
820
            $dep['providesextension'] = $providesextension;
826
        }
821
        }
827
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
822
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
828
            array(
823
            array(
829
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
824
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
830
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
825
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
831
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
826
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
832
                'required' => array('optional', 'group'),
827
                'required' => array('optional', 'group'),
833
                'package' => array('subpackage', 'extension', 'os', 'arch')
828
                'package' => array('subpackage', 'extension', 'os', 'arch')
834
            ));
829
            ));
835
    }
830
    }
836
 
831
 
837
    function addDependencyGroup($name, $hint)
832
    function addDependencyGroup($name, $hint)
838
    {
833
    {
839
        $this->_isValid = 0;
834
        $this->_isValid = 0;
840
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo,
835
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo,
841
            array('attribs' => array('name' => $name, 'hint' => $hint)),
836
            array('attribs' => array('name' => $name, 'hint' => $hint)),
842
            array(
837
            array(
843
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
838
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
844
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
839
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
845
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
840
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
846
                'group' => array(),
841
                'group' => array(),
847
            ));
842
            ));
848
    }
843
    }
849
 
844
 
850
    /**
845
    /**
851
     * @param string package name
846
     * @param string package name
852
     * @param string|false channel name, false if this is a uri
847
     * @param string|false channel name, false if this is a uri
853
     * @param string|false uri name, false if this is a channel
848
     * @param string|false uri name, false if this is a channel
854
     * @param string|false minimum version required
849
     * @param string|false minimum version required
855
     * @param string|false maximum version allowed
850
     * @param string|false maximum version allowed
856
     * @param string|false recommended installation version
851
     * @param string|false recommended installation version
857
     * @param array|false versions to exclude from installation
852
     * @param array|false versions to exclude from installation
858
     * @param string extension this package provides, if any
853
     * @param string extension this package provides, if any
859
     * @param bool if true, tells the installer to ignore the default optional dependency group
854
     * @param bool if true, tells the installer to ignore the default optional dependency group
860
     *             when installing this package
855
     *             when installing this package
861
     * @param bool if true, tells the installer to negate this dependency (conflicts)
856
     * @param bool if true, tells the installer to negate this dependency (conflicts)
862
     * @return array
857
     * @return array
863
     * @access private
858
     * @access private
864
     */
859
     */
865
    function _constructDep($name, $channel, $uri, $min, $max, $recommended, $exclude,
860
    function _constructDep($name, $channel, $uri, $min, $max, $recommended, $exclude,
866
                           $providesextension = false, $nodefault = false,
861
                           $providesextension = false, $nodefault = false,
867
                           $conflicts = false)
862
                           $conflicts = false)
868
    {
863
    {
869
        $dep =
864
        $dep =
870
            array(
865
            array(
871
                'name' => $name,
866
                'name' => $name,
872
            );
867
            );
873
        if ($channel) {
868
        if ($channel) {
874
            $dep['channel'] = $channel;
869
            $dep['channel'] = $channel;
875
        } elseif ($uri) {
870
        } elseif ($uri) {
876
            $dep['uri'] = $uri;
871
            $dep['uri'] = $uri;
877
        }
872
        }
878
        if ($min) {
873
        if ($min) {
879
            $dep['min'] = $min;
874
            $dep['min'] = $min;
880
        }
875
        }
881
        if ($max) {
876
        if ($max) {
882
            $dep['max'] = $max;
877
            $dep['max'] = $max;
883
        }
878
        }
884
        if ($recommended) {
879
        if ($recommended) {
885
            $dep['recommended'] = $recommended;
880
            $dep['recommended'] = $recommended;
886
        }
881
        }
887
        if ($exclude) {
882
        if ($exclude) {
888
            if (is_array($exclude) && count($exclude) == 1) {
883
            if (is_array($exclude) && count($exclude) == 1) {
889
                $exclude = $exclude[0];
884
                $exclude = $exclude[0];
890
            }
885
            }
891
            $dep['exclude'] = $exclude;
886
            $dep['exclude'] = $exclude;
892
        }
887
        }
893
        if ($conflicts) {
888
        if ($conflicts) {
894
            $dep['conflicts'] = '';
889
            $dep['conflicts'] = '';
895
        }
890
        }
896
        if ($nodefault) {
891
        if ($nodefault) {
897
            $dep['nodefault'] = '';
892
            $dep['nodefault'] = '';
898
        }
893
        }
899
        if ($providesextension) {
894
        if ($providesextension) {
900
            $dep['providesextension'] = $providesextension;
895
            $dep['providesextension'] = $providesextension;
901
        }
896
        }
902
        return $dep;
897
        return $dep;
903
    }
898
    }
904
 
899
 
905
    /**
900
    /**
906
     * @param package|subpackage
901
     * @param package|subpackage
907
     * @param string group name
902
     * @param string group name
908
     * @param string package name
903
     * @param string package name
909
     * @param string package channel
904
     * @param string package channel
910
     * @param string minimum version
905
     * @param string minimum version
911
     * @param string maximum version
906
     * @param string maximum version
912
     * @param string recommended version
907
     * @param string recommended version
913
     * @param array|false optional excluded versions
908
     * @param array|false optional excluded versions
914
     * @param string extension this package provides, if any
909
     * @param string extension this package provides, if any
915
     * @param bool if true, tells the installer to ignore the default optional dependency group
910
     * @param bool if true, tells the installer to ignore the default optional dependency group
916
     *             when installing this package
911
     *             when installing this package
917
     * @return bool false if the dependency group has not been initialized with
912
     * @return bool false if the dependency group has not been initialized with
918
     *              {@link addDependencyGroup()}, or a subpackage is added with
913
     *              {@link addDependencyGroup()}, or a subpackage is added with
919
     *              a providesextension
914
     *              a providesextension
920
     */
915
     */
921
    function addGroupPackageDepWithChannel($type, $groupname, $name, $channel, $min = false,
916
    function addGroupPackageDepWithChannel($type, $groupname, $name, $channel, $min = false,
922
                                      $max = false, $recommended = false, $exclude = false,
917
                                      $max = false, $recommended = false, $exclude = false,
923
                                      $providesextension = false, $nodefault = false)
918
                                      $providesextension = false, $nodefault = false)
924
    {
919
    {
925
        if ($type == 'subpackage' && $providesextension) {
920
        if ($type == 'subpackage' && $providesextension) {
926
            return false; // subpackages must be php packages
921
            return false; // subpackages must be php packages
927
        }
922
        }
928
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
923
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
929
            $providesextension, $nodefault);
924
            $providesextension, $nodefault);
930
        return $this->_addGroupDependency($type, $dep, $groupname);
925
        return $this->_addGroupDependency($type, $dep, $groupname);
931
    }
926
    }
932
 
927
 
933
    /**
928
    /**
934
     * @param package|subpackage
929
     * @param package|subpackage
935
     * @param string group name
930
     * @param string group name
936
     * @param string package name
931
     * @param string package name
937
     * @param string package uri
932
     * @param string package uri
938
     * @param string extension this package provides, if any
933
     * @param string extension this package provides, if any
939
     * @param bool if true, tells the installer to ignore the default optional dependency group
934
     * @param bool if true, tells the installer to ignore the default optional dependency group
940
     *             when installing this package
935
     *             when installing this package
941
     * @return bool false if the dependency group has not been initialized with
936
     * @return bool false if the dependency group has not been initialized with
942
     *              {@link addDependencyGroup()}
937
     *              {@link addDependencyGroup()}
943
     */
938
     */
944
    function addGroupPackageDepWithURI($type, $groupname, $name, $uri, $providesextension = false,
939
    function addGroupPackageDepWithURI($type, $groupname, $name, $uri, $providesextension = false,
945
                                       $nodefault = false)
940
                                       $nodefault = false)
946
    {
941
    {
947
        if ($type == 'subpackage' && $providesextension) {
942
        if ($type == 'subpackage' && $providesextension) {
948
            return false; // subpackages must be php packages
943
            return false; // subpackages must be php packages
949
        }
944
        }
950
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false,
945
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false,
951
            $providesextension, $nodefault);
946
            $providesextension, $nodefault);
952
        return $this->_addGroupDependency($type, $dep, $groupname);
947
        return $this->_addGroupDependency($type, $dep, $groupname);
953
    }
948
    }
954
 
949
 
955
    /**
950
    /**
956
     * @param string group name (must be pre-existing)
951
     * @param string group name (must be pre-existing)
957
     * @param string extension name
952
     * @param string extension name
958
     * @param string minimum version allowed
953
     * @param string minimum version allowed
959
     * @param string maximum version allowed
954
     * @param string maximum version allowed
960
     * @param string recommended version
955
     * @param string recommended version
961
     * @param array incompatible versions
956
     * @param array incompatible versions
962
     */
957
     */
963
    function addGroupExtensionDep($groupname, $name, $min = false, $max = false,
958
    function addGroupExtensionDep($groupname, $name, $min = false, $max = false,
964
                                         $recommended = false, $exclude = false)
959
                                         $recommended = false, $exclude = false)
965
    {
960
    {
966
        $this->_isValid = 0;
961
        $this->_isValid = 0;
967
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
962
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
968
        return $this->_addGroupDependency('extension', $dep, $groupname);
963
        return $this->_addGroupDependency('extension', $dep, $groupname);
969
    }
964
    }
970
 
965
 
971
    /**
966
    /**
972
     * @param package|subpackage|extension
967
     * @param package|subpackage|extension
973
     * @param array dependency contents
968
     * @param array dependency contents
974
     * @param string name of the dependency group to add this to
969
     * @param string name of the dependency group to add this to
975
     * @return boolean
970
     * @return boolean
976
     * @access private
971
     * @access private
977
     */
972
     */
978
    function _addGroupDependency($type, $dep, $groupname)
973
    function _addGroupDependency($type, $dep, $groupname)
979
    {
974
    {
980
        $arr = array('subpackage', 'extension');
975
        $arr = array('subpackage', 'extension');
981
        if ($type != 'package') {
976
        if ($type != 'package') {
982
            array_shift($arr);
977
            array_shift($arr);
983
        }
978
        }
984
        if ($type == 'extension') {
979
        if ($type == 'extension') {
985
            array_shift($arr);
980
            array_shift($arr);
986
        }
981
        }
987
        if (!isset($this->_packageInfo['dependencies']['group'])) {
982
        if (!isset($this->_packageInfo['dependencies']['group'])) {
988
            return false;
983
            return false;
989
        } else {
984
        } else {
990
            if (!isset($this->_packageInfo['dependencies']['group'][0])) {
985
            if (!isset($this->_packageInfo['dependencies']['group'][0])) {
991
                if ($this->_packageInfo['dependencies']['group']['attribs']['name'] == $groupname) {
986
                if ($this->_packageInfo['dependencies']['group']['attribs']['name'] == $groupname) {
992
                    $this->_packageInfo['dependencies']['group'] = $this->_mergeTag(
987
                    $this->_packageInfo['dependencies']['group'] = $this->_mergeTag(
993
                        $this->_packageInfo['dependencies']['group'], $dep,
988
                        $this->_packageInfo['dependencies']['group'], $dep,
994
                        array(
989
                        array(
995
                            $type => $arr
990
                            $type => $arr
996
                        ));
991
                        ));
997
                    $this->_isValid = 0;
992
                    $this->_isValid = 0;
998
                    return true;
993
                    return true;
999
                } else {
994
                } else {
1000
                    return false;
995
                    return false;
1001
                }
996
                }
1002
            } else {
997
            } else {
1003
                foreach ($this->_packageInfo['dependencies']['group'] as $i => $group) {
998
                foreach ($this->_packageInfo['dependencies']['group'] as $i => $group) {
1004
                    if ($group['attribs']['name'] == $groupname) {
999
                    if ($group['attribs']['name'] == $groupname) {
1005
                    $this->_packageInfo['dependencies']['group'][$i] = $this->_mergeTag(
1000
                    $this->_packageInfo['dependencies']['group'][$i] = $this->_mergeTag(
1006
                        $this->_packageInfo['dependencies']['group'][$i], $dep,
1001
                        $this->_packageInfo['dependencies']['group'][$i], $dep,
1007
                        array(
1002
                        array(
1008
                            $type => $arr
1003
                            $type => $arr
1009
                        ));
1004
                        ));
1010
                        $this->_isValid = 0;
1005
                        $this->_isValid = 0;
1011
                        return true;
1006
                        return true;
1012
                    }
1007
                    }
1013
                }
1008
                }
1014
                return false;
1009
                return false;
1015
            }
1010
            }
1016
        }
1011
        }
1017
    }
1012
    }
1018
 
1013
 
1019
    /**
1014
    /**
1020
     * @param optional|required
1015
     * @param optional|required
1021
     * @param string package name
1016
     * @param string package name
1022
     * @param string package channel
1017
     * @param string package channel
1023
     * @param string minimum version
1018
     * @param string minimum version
1024
     * @param string maximum version
1019
     * @param string maximum version
1025
     * @param string recommended version
1020
     * @param string recommended version
1026
     * @param string extension this package provides, if any
1021
     * @param string extension this package provides, if any
1027
     * @param bool if true, tells the installer to ignore the default optional dependency group
1022
     * @param bool if true, tells the installer to ignore the default optional dependency group
1028
     *             when installing this package
1023
     *             when installing this package
1029
     * @param array|false optional excluded versions
1024
     * @param array|false optional excluded versions
1030
     */
1025
     */
1031
    function addPackageDepWithChannel($type, $name, $channel, $min = false, $max = false,
1026
    function addPackageDepWithChannel($type, $name, $channel, $min = false, $max = false,
1032
                                      $recommended = false, $exclude = false,
1027
                                      $recommended = false, $exclude = false,
1033
                                      $providesextension = false, $nodefault = false)
1028
                                      $providesextension = false, $nodefault = false)
1034
    {
1029
    {
1035
        if (!in_array($type, array('optional', 'required'), true)) {
1030
        if (!in_array($type, array('optional', 'required'), true)) {
1036
            $type = 'required';
1031
            $type = 'required';
1037
        }
1032
        }
1038
        $this->_isValid = 0;
1033
        $this->_isValid = 0;
1039
        $arr = array('optional', 'group');
1034
        $arr = array('optional', 'group');
1040
        if ($type != 'required') {
1035
        if ($type != 'required') {
1041
            array_shift($arr);
1036
            array_shift($arr);
1042
        }
1037
        }
1043
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
1038
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
1044
            $providesextension, $nodefault);
1039
            $providesextension, $nodefault);
1045
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1040
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1046
            array(
1041
            array(
1047
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1042
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1048
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1043
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1049
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1044
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1050
                $type => $arr,
1045
                $type => $arr,
1051
                'package' => array('subpackage', 'extension', 'os', 'arch')
1046
                'package' => array('subpackage', 'extension', 'os', 'arch')
1052
            ));
1047
            ));
1053
    }
1048
    }
1054
 
1049
 
1055
    /**
1050
    /**
1056
     * @param optional|required
1051
     * @param optional|required
1057
     * @param string name of the package
1052
     * @param string name of the package
1058
     * @param string uri of the package
1053
     * @param string uri of the package
1059
     * @param string extension this package provides, if any
1054
     * @param string extension this package provides, if any
1060
     * @param bool if true, tells the installer to ignore the default optional dependency group
1055
     * @param bool if true, tells the installer to ignore the default optional dependency group
1061
     *             when installing this package
1056
     *             when installing this package
1062
     */
1057
     */
1063
    function addPackageDepWithUri($type, $name, $uri, $providesextension = false,
1058
    function addPackageDepWithUri($type, $name, $uri, $providesextension = false,
1064
                                  $nodefault = false)
1059
                                  $nodefault = false)
1065
    {
1060
    {
1066
        $this->_isValid = 0;
1061
        $this->_isValid = 0;
1067
        $arr = array('optional', 'group');
1062
        $arr = array('optional', 'group');
1068
        if ($type != 'required') {
1063
        if ($type != 'required') {
1069
            array_shift($arr);
1064
            array_shift($arr);
1070
        }
1065
        }
1071
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false,
1066
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false,
1072
            $providesextension, $nodefault);
1067
            $providesextension, $nodefault);
1073
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1068
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1074
            array(
1069
            array(
1075
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1070
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1076
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1071
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1077
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1072
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1078
                $type => $arr,
1073
                $type => $arr,
1079
                'package' => array('subpackage', 'extension', 'os', 'arch')
1074
                'package' => array('subpackage', 'extension', 'os', 'arch')
1080
            ));
1075
            ));
1081
    }
1076
    }
1082
 
1077
 
1083
    /**
1078
    /**
1084
     * @param optional|required optional, required
1079
     * @param optional|required optional, required
1085
     * @param string package name
1080
     * @param string package name
1086
     * @param string package channel
1081
     * @param string package channel
1087
     * @param string minimum version
1082
     * @param string minimum version
1088
     * @param string maximum version
1083
     * @param string maximum version
1089
     * @param string recommended version
1084
     * @param string recommended version
1090
     * @param array incompatible versions
1085
     * @param array incompatible versions
1091
     * @param bool if true, tells the installer to ignore the default optional dependency group
1086
     * @param bool if true, tells the installer to ignore the default optional dependency group
1092
     *             when installing this package
1087
     *             when installing this package
1093
     */
1088
     */
1094
    function addSubpackageDepWithChannel($type, $name, $channel, $min = false, $max = false,
1089
    function addSubpackageDepWithChannel($type, $name, $channel, $min = false, $max = false,
1095
                                         $recommended = false, $exclude = false,
1090
                                         $recommended = false, $exclude = false,
1096
                                         $nodefault = false)
1091
                                         $nodefault = false)
1097
    {
1092
    {
1098
        $this->_isValid = 0;
1093
        $this->_isValid = 0;
1099
        $arr = array('optional', 'group');
1094
        $arr = array('optional', 'group');
1100
        if ($type != 'required') {
1095
        if ($type != 'required') {
1101
            array_shift($arr);
1096
            array_shift($arr);
1102
        }
1097
        }
1103
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
1098
        $dep = $this->_constructDep($name, $channel, false, $min, $max, $recommended, $exclude,
1104
            $nodefault);
1099
            $nodefault);
1105
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1100
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1106
            array(
1101
            array(
1107
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1102
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1108
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1103
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1109
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1104
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1110
                $type => $arr,
1105
                $type => $arr,
1111
                'subpackage' => array('extension', 'os', 'arch')
1106
                'subpackage' => array('extension', 'os', 'arch')
1112
            ));
1107
            ));
1113
    }
1108
    }
1114
 
1109
 
1115
    /**
1110
    /**
1116
     * @param optional|required optional, required
1111
     * @param optional|required optional, required
1117
     * @param string package name
1112
     * @param string package name
1118
     * @param string package uri for download
1113
     * @param string package uri for download
1119
     * @param bool if true, tells the installer to ignore the default optional dependency group
1114
     * @param bool if true, tells the installer to ignore the default optional dependency group
1120
     *             when installing this package
1115
     *             when installing this package
1121
     */
1116
     */
1122
    function addSubpackageDepWithUri($type, $name, $uri, $nodefault = false)
1117
    function addSubpackageDepWithUri($type, $name, $uri, $nodefault = false)
1123
    {
1118
    {
1124
        $this->_isValid = 0;
1119
        $this->_isValid = 0;
1125
        $arr = array('optional', 'group');
1120
        $arr = array('optional', 'group');
1126
        if ($type != 'required') {
1121
        if ($type != 'required') {
1127
            array_shift($arr);
1122
            array_shift($arr);
1128
        }
1123
        }
1129
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false, $nodefault);
1124
        $dep = $this->_constructDep($name, false, $uri, false, false, false, false, $nodefault);
1130
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1125
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1131
            array(
1126
            array(
1132
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1127
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1133
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1128
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1134
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1129
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1135
                $type => $arr,
1130
                $type => $arr,
1136
                'subpackage' => array('extension', 'os', 'arch')
1131
                'subpackage' => array('extension', 'os', 'arch')
1137
            ));
1132
            ));
1138
    }
1133
    }
1139
 
1134
 
1140
    /**
1135
    /**
1141
     * @param optional|required optional, required
1136
     * @param optional|required optional, required
1142
     * @param string extension name
1137
     * @param string extension name
1143
     * @param string minimum version
1138
     * @param string minimum version
1144
     * @param string maximum version
1139
     * @param string maximum version
1145
     * @param string recommended version
1140
     * @param string recommended version
1146
     * @param array incompatible versions
1141
     * @param array incompatible versions
1147
     */
1142
     */
1148
    function addExtensionDep($type, $name, $min = false, $max = false, $recommended = false,
1143
    function addExtensionDep($type, $name, $min = false, $max = false, $recommended = false,
1149
                             $exclude = false)
1144
                             $exclude = false)
1150
    {
1145
    {
1151
        $this->_isValid = 0;
1146
        $this->_isValid = 0;
1152
        $arr = array('optional', 'group');
1147
        $arr = array('optional', 'group');
1153
        if ($type != 'required') {
1148
        if ($type != 'required') {
1154
            array_shift($arr);
1149
            array_shift($arr);
1155
        }
1150
        }
1156
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
1151
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
1157
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1152
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1158
            array(
1153
            array(
1159
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1154
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1160
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1155
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1161
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1156
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1162
                $type => $arr,
1157
                $type => $arr,
1163
                'extension' => array('os', 'arch')
1158
                'extension' => array('os', 'arch')
1164
            ));
1159
            ));
1165
    }
1160
    }
1166
 
1161
 
1167
    /**
1162
    /**
1168
     * @param string Operating system name
1163
     * @param string Operating system name
1169
     * @param boolean true if this package cannot be installed on this OS
1164
     * @param boolean true if this package cannot be installed on this OS
1170
     */
1165
     */
1171
    function addOsDep($name, $conflicts = false)
1166
    function addOsDep($name, $conflicts = false)
1172
    {
1167
    {
1173
        $this->_isValid = 0;
1168
        $this->_isValid = 0;
1174
        $dep = array('name' => $name);
1169
        $dep = array('name' => $name);
1175
        if ($conflicts) {
1170
        if ($conflicts) {
1176
            $dep['conflicts'] = '';
1171
            $dep['conflicts'] = '';
1177
        }
1172
        }
1178
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1173
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1179
            array(
1174
            array(
1180
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1175
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1181
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1176
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1182
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1177
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1183
                'required' => array('optional', 'group'),
1178
                'required' => array('optional', 'group'),
1184
                'os' => array('arch')
1179
                'os' => array('arch')
1185
            ));
1180
            ));
1186
    }
1181
    }
1187
 
1182
 
1188
    /**
1183
    /**
1189
     * @param string Architecture matching pattern
1184
     * @param string Architecture matching pattern
1190
     * @param boolean true if this package cannot be installed on this architecture
1185
     * @param boolean true if this package cannot be installed on this architecture
1191
     */
1186
     */
1192
    function addArchDep($pattern, $conflicts = false)
1187
    function addArchDep($pattern, $conflicts = false)
1193
    {
1188
    {
1194
        $this->_isValid = 0;
1189
        $this->_isValid = 0;
1195
        $dep = array('pattern' => $pattern);
1190
        $dep = array('pattern' => $pattern);
1196
        if ($conflicts) {
1191
        if ($conflicts) {
1197
            $dep['conflicts'] = '';
1192
            $dep['conflicts'] = '';
1198
        }
1193
        }
1199
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1194
        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
1200
            array(
1195
            array(
1201
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1196
                'dependencies' => array('providesextension', 'usesrole', 'usestask',
1202
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1197
                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
1203
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1198
                    'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
1204
                'required' => array('optional', 'group'),
1199
                'required' => array('optional', 'group'),
1205
                'arch' => array()
1200
                'arch' => array()
1206
            ));
1201
            ));
1207
    }
1202
    }
1208
 
1203
 
1209
    /**
1204
    /**
1210
     * Set the kind of package, and erase all release tags
1205
     * Set the kind of package, and erase all release tags
1211
     *
1206
     *
1212
     * - a php package is a PEAR-style package
1207
     * - a php package is a PEAR-style package
1213
     * - an extbin package is a PECL-style extension binary
1208
     * - an extbin package is a PECL-style extension binary
1214
     * - an extsrc package is a PECL-style source for a binary
1209
     * - an extsrc package is a PECL-style source for a binary
1215
     * - an zendextbin package is a PECL-style zend extension binary
1210
     * - an zendextbin package is a PECL-style zend extension binary
1216
     * - an zendextsrc package is a PECL-style source for a zend extension binary
1211
     * - an zendextsrc package is a PECL-style source for a zend extension binary
1217
     * - a bundle package is a collection of other pre-packaged packages
1212
     * - a bundle package is a collection of other pre-packaged packages
1218
     * @param php|extbin|extsrc|zendextsrc|zendextbin|bundle
1213
     * @param php|extbin|extsrc|zendextsrc|zendextbin|bundle
1219
     * @return bool success
1214
     * @return bool success
1220
     */
1215
     */
1221
    function setPackageType($type)
1216
    function setPackageType($type)
1222
    {
1217
    {
1223
        $this->_isValid = 0;
1218
        $this->_isValid = 0;
1224
        if (!in_array($type, array('php', 'extbin', 'extsrc', 'zendextsrc',
1219
        if (!in_array($type, array('php', 'extbin', 'extsrc', 'zendextsrc',
1225
                                   'zendextbin', 'bundle'))) {
1220
                                   'zendextbin', 'bundle'))) {
1226
            return false;
1221
            return false;
1227
        }
1222
        }
-
 
1223
 
1228
        if (in_array($type, array('zendextsrc', 'zendextbin'))) {
1224
        if (in_array($type, array('zendextsrc', 'zendextbin'))) {
1229
            $this->_setPackageVersion2_1();
1225
            $this->_setPackageVersion2_1();
1230
        }
1226
        }
-
 
1227
 
1231
        if ($type != 'bundle') {
1228
        if ($type != 'bundle') {
1232
            $type .= 'release';
1229
            $type .= 'release';
1233
        }
1230
        }
-
 
1231
 
1234
        foreach (array('phprelease', 'extbinrelease', 'extsrcrelease',
1232
        foreach (array('phprelease', 'extbinrelease', 'extsrcrelease',
1235
                       'zendextsrcrelease', 'zendextbinrelease', 'bundle') as $test) {
1233
                       'zendextsrcrelease', 'zendextbinrelease', 'bundle') as $test) {
1236
            unset($this->_packageInfo[$test]);
1234
            unset($this->_packageInfo[$test]);
1237
        }
1235
        }
-
 
1236
 
1238
        if (!isset($this->_packageInfo[$type])) {
1237
        if (!isset($this->_packageInfo[$type])) {
1239
            // ensure that the release tag is set up
1238
            // ensure that the release tag is set up
1240
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('changelog'),
1239
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('changelog'),
1241
                array(), $type);
1240
                array(), $type);
1242
        }
1241
        }
-
 
1242
 
1243
        $this->_packageInfo[$type] = array();
1243
        $this->_packageInfo[$type] = array();
1244
        return true;
1244
        return true;
1245
    }
1245
    }
1246
 
1246
 
1247
    /**
1247
    /**
1248
     * @return bool true if package type is set up
1248
     * @return bool true if package type is set up
1249
     */
1249
     */
1250
    function addRelease()
1250
    function addRelease()
1251
    {
1251
    {
1252
        if ($type = $this->getPackageType()) {
1252
        if ($type = $this->getPackageType()) {
1253
            if ($type != 'bundle') {
1253
            if ($type != 'bundle') {
1254
                $type .= 'release';
1254
                $type .= 'release';
1255
            }
1255
            }
1256
            $this->_packageInfo = $this->_mergeTag($this->_packageInfo, array(),
1256
            $this->_packageInfo = $this->_mergeTag($this->_packageInfo, array(),
1257
                array($type => array('changelog')));
1257
                array($type => array('changelog')));
1258
            return true;
1258
            return true;
1259
        }
1259
        }
1260
        return false;
1260
        return false;
1261
    }
1261
    }
1262
 
1262
 
1263
    /**
1263
    /**
1264
     * Get the current release tag in order to add to it
1264
     * Get the current release tag in order to add to it
1265
     * @param bool returns only releases that have installcondition if true
1265
     * @param bool returns only releases that have installcondition if true
1266
     * @return array|null
1266
     * @return array|null
1267
     */
1267
     */
1268
    function &_getCurrentRelease($strict = true)
1268
    function &_getCurrentRelease($strict = true)
1269
    {
1269
    {
1270
        if ($p = $this->getPackageType()) {
1270
        if ($p = $this->getPackageType()) {
1271
            if ($strict) {
1271
            if ($strict) {
1272
                if ($p == 'extsrc' || $p == 'zendextsrc') {
1272
                if ($p == 'extsrc' || $p == 'zendextsrc') {
1273
                    $a = null;
1273
                    $a = null;
1274
                    return $a;
1274
                    return $a;
1275
                }
1275
                }
1276
            }
1276
            }
1277
            if ($p != 'bundle') {
1277
            if ($p != 'bundle') {
1278
                $p .= 'release';
1278
                $p .= 'release';
1279
            }
1279
            }
1280
            if (isset($this->_packageInfo[$p][0])) {
1280
            if (isset($this->_packageInfo[$p][0])) {
1281
                return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1];
1281
                return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1];
1282
            } else {
1282
            } else {
1283
                return $this->_packageInfo[$p];
1283
                return $this->_packageInfo[$p];
1284
            }
1284
            }
1285
        } else {
1285
        } else {
1286
            $a = null;
1286
            $a = null;
1287
            return $a;
1287
            return $a;
1288
        }
1288
        }
1289
    }
1289
    }
1290
 
1290
 
1291
    /**
1291
    /**
1292
     * Add a file to the current release that should be installed under a different name
1292
     * Add a file to the current release that should be installed under a different name
1293
     * @param string <contents> path to file
1293
     * @param string <contents> path to file
1294
     * @param string name the file should be installed as
1294
     * @param string name the file should be installed as
1295
     */
1295
     */
1296
    function addInstallAs($path, $as)
1296
    function addInstallAs($path, $as)
1297
    {
1297
    {
1298
        $r = &$this->_getCurrentRelease();
1298
        $r = &$this->_getCurrentRelease();
1299
        if ($r === null) {
1299
        if ($r === null) {
1300
            return false;
1300
            return false;
1301
        }
1301
        }
1302
        $this->_isValid = 0;
1302
        $this->_isValid = 0;
1303
        $r = $this->_mergeTag($r, array('attribs' => array('name' => $path, 'as' => $as)),
1303
        $r = $this->_mergeTag($r, array('attribs' => array('name' => $path, 'as' => $as)),
1304
            array(
1304
            array(
1305
                'filelist' => array(),
1305
                'filelist' => array(),
1306
                'install' => array('ignore')
1306
                'install' => array('ignore')
1307
            ));
1307
            ));
1308
    }
1308
    }
1309
 
1309
 
1310
    /**
1310
    /**
1311
     * Add a file to the current release that should be ignored
1311
     * Add a file to the current release that should be ignored
1312
     * @param string <contents> path to file
1312
     * @param string <contents> path to file
1313
     * @return bool success of operation
1313
     * @return bool success of operation
1314
     */
1314
     */
1315
    function addIgnore($path)
1315
    function addIgnore($path)
1316
    {
1316
    {
1317
        $r = &$this->_getCurrentRelease();
1317
        $r = &$this->_getCurrentRelease();
1318
        if ($r === null) {
1318
        if ($r === null) {
1319
            return false;
1319
            return false;
1320
        }
1320
        }
1321
        $this->_isValid = 0;
1321
        $this->_isValid = 0;
1322
        $r = $this->_mergeTag($r, array('attribs' => array('name' => $path)),
1322
        $r = $this->_mergeTag($r, array('attribs' => array('name' => $path)),
1323
            array(
1323
            array(
1324
                'filelist' => array(),
1324
                'filelist' => array(),
1325
                'ignore' => array()
1325
                'ignore' => array()
1326
            ));
1326
            ));
1327
    }
1327
    }
1328
 
1328
 
1329
    /**
1329
    /**
1330
     * Add an extension binary package for this extension source code release
1330
     * Add an extension binary package for this extension source code release
1331
     *
1331
     *
1332
     * Note that the package must be from the same channel as the extension source package
1332
     * Note that the package must be from the same channel as the extension source package
1333
     * @param string
1333
     * @param string
1334
     */
1334
     */
1335
    function addBinarypackage($package)
1335
    function addBinarypackage($package)
1336
    {
1336
    {
1337
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1337
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1338
            return false;
1338
            return false;
1339
        }
1339
        }
1340
        $r = &$this->_getCurrentRelease(false);
1340
        $r = &$this->_getCurrentRelease(false);
1341
        if ($r === null) {
1341
        if ($r === null) {
1342
            return false;
1342
            return false;
1343
        }
1343
        }
1344
        $this->_isValid = 0;
1344
        $this->_isValid = 0;
1345
        $r = $this->_mergeTag($r, $package,
1345
        $r = $this->_mergeTag($r, $package,
1346
            array(
1346
            array(
1347
                'binarypackage' => array('filelist'),
1347
                'binarypackage' => array('filelist'),
1348
            ));
1348
            ));
1349
    }
1349
    }
1350
 
1350
 
1351
    /**
1351
    /**
1352
     * Add a configureoption to an extension source package
1352
     * Add a configureoption to an extension source package
1353
     * @param string
1353
     * @param string
1354
     * @param string
1354
     * @param string
1355
     * @param string
1355
     * @param string
1356
     */
1356
     */
1357
    function addConfigureOption($name, $prompt, $default = null)
1357
    function addConfigureOption($name, $prompt, $default = null)
1358
    {
1358
    {
1359
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1359
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1360
            return false;
1360
            return false;
1361
        }
1361
        }
-
 
1362
 
1362
        $r = &$this->_getCurrentRelease(false);
1363
        $r = &$this->_getCurrentRelease(false);
1363
        if ($r === null) {
1364
        if ($r === null) {
1364
            return false;
1365
            return false;
1365
        }
1366
        }
-
 
1367
 
1366
        $opt = array('attribs' => array('name' => $name, 'prompt' => $prompt));
1368
        $opt = array('attribs' => array('name' => $name, 'prompt' => $prompt));
1367
        if ($default !== null) {
1369
        if ($default !== null) {
1368
            $opt['default'] = $default;
1370
            $opt['attribs']['default'] = $default;
1369
        }
1371
        }
-
 
1372
 
1370
        $this->_isValid = 0;
1373
        $this->_isValid = 0;
1371
        $r = $this->_mergeTag($r, $opt,
1374
        $r = $this->_mergeTag($r, $opt,
1372
            array(
1375
            array(
1373
                'configureoption' => array('binarypackage', 'filelist'),
1376
                'configureoption' => array('binarypackage', 'filelist'),
1374
            ));
1377
            ));
1375
    }
1378
    }
1376
 
1379
 
1377
    /**
1380
    /**
1378
     * Set an installation condition based on php version for the current release set
1381
     * Set an installation condition based on php version for the current release set
1379
     * @param string minimum version
1382
     * @param string minimum version
1380
     * @param string maximum version
1383
     * @param string maximum version
1381
     * @param false|array incompatible versions of PHP
1384
     * @param false|array incompatible versions of PHP
1382
     */
1385
     */
1383
    function setPhpInstallCondition($min, $max, $exclude = false)
1386
    function setPhpInstallCondition($min, $max, $exclude = false)
1384
    {
1387
    {
1385
        $r = &$this->_getCurrentRelease();
1388
        $r = &$this->_getCurrentRelease();
1386
        if ($r === null) {
1389
        if ($r === null) {
1387
            return false;
1390
            return false;
1388
        }
1391
        }
1389
        $this->_isValid = 0;
1392
        $this->_isValid = 0;
1390
        if (isset($r['installconditions']['php'])) {
1393
        if (isset($r['installconditions']['php'])) {
1391
            unset($r['installconditions']['php']);
1394
            unset($r['installconditions']['php']);
1392
        }
1395
        }
1393
        $dep = array('min' => $min, 'max' => $max);
1396
        $dep = array('min' => $min, 'max' => $max);
1394
        if ($exclude) {
1397
        if ($exclude) {
1395
            if (is_array($exclude) && count($exclude) == 1) {
1398
            if (is_array($exclude) && count($exclude) == 1) {
1396
                $exclude = $exclude[0];
1399
                $exclude = $exclude[0];
1397
            }
1400
            }
1398
            $dep['exclude'] = $exclude;
1401
            $dep['exclude'] = $exclude;
1399
        }
1402
        }
1400
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1403
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1401
            $r = $this->_mergeTag($r, $dep,
1404
            $r = $this->_mergeTag($r, $dep,
1402
                array(
1405
                array(
1403
                    'installconditions' => array('configureoption', 'binarypackage',
1406
                    'installconditions' => array('configureoption', 'binarypackage',
1404
                        'filelist'),
1407
                        'filelist'),
1405
                    'php' => array('extension', 'os', 'arch')
1408
                    'php' => array('extension', 'os', 'arch')
1406
                ));
1409
                ));
1407
        } else {
1410
        } else {
1408
            $r = $this->_mergeTag($r, $dep,
1411
            $r = $this->_mergeTag($r, $dep,
1409
                array(
1412
                array(
1410
                    'installconditions' => array('filelist'),
1413
                    'installconditions' => array('filelist'),
1411
                    'php' => array('extension', 'os', 'arch')
1414
                    'php' => array('extension', 'os', 'arch')
1412
                ));
1415
                ));
1413
        }
1416
        }
1414
    }
1417
    }
1415
 
1418
 
1416
    /**
1419
    /**
1417
     * @param optional|required optional, required
1420
     * @param optional|required optional, required
1418
     * @param string extension name
1421
     * @param string extension name
1419
     * @param string minimum version
1422
     * @param string minimum version
1420
     * @param string maximum version
1423
     * @param string maximum version
1421
     * @param string recommended version
1424
     * @param string recommended version
1422
     * @param array incompatible versions
1425
     * @param array incompatible versions
1423
     */
1426
     */
1424
    function addExtensionInstallCondition($name, $min = false, $max = false, $recommended = false,
1427
    function addExtensionInstallCondition($name, $min = false, $max = false, $recommended = false,
1425
                                          $exclude = false)
1428
                                          $exclude = false)
1426
    {
1429
    {
1427
        $r = &$this->_getCurrentRelease();
1430
        $r = &$this->_getCurrentRelease();
1428
        if ($r === null) {
1431
        if ($r === null) {
1429
            return false;
1432
            return false;
1430
        }
1433
        }
1431
        $this->_isValid = 0;
1434
        $this->_isValid = 0;
1432
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
1435
        $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
1433
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1436
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1434
            $r = $this->_mergeTag($r, $dep,
1437
            $r = $this->_mergeTag($r, $dep,
1435
                array(
1438
                array(
1436
                    'installconditions' => array('configureoption', 'binarypackage',
1439
                    'installconditions' => array('configureoption', 'binarypackage',
1437
                        'filelist'),
1440
                        'filelist'),
1438
                    'extension' => array('os', 'arch')
1441
                    'extension' => array('os', 'arch')
1439
                ));
1442
                ));
1440
        } else {
1443
        } else {
1441
            $r = $this->_mergeTag($r, $dep,
1444
            $r = $this->_mergeTag($r, $dep,
1442
                array(
1445
                array(
1443
                    'installconditions' => array('filelist'),
1446
                    'installconditions' => array('filelist'),
1444
                    'extension' => array('os', 'arch')
1447
                    'extension' => array('os', 'arch')
1445
                ));
1448
                ));
1446
        }
1449
        }
1447
    }
1450
    }
1448
 
1451
 
1449
    /**
1452
    /**
1450
     * Set an installation condition based on operating system for the current release set
1453
     * Set an installation condition based on operating system for the current release set
1451
     * @param string OS name
1454
     * @param string OS name
1452
     * @param bool whether this OS is incompatible with the current release
1455
     * @param bool whether this OS is incompatible with the current release
1453
     */
1456
     */
1454
    function setOsInstallCondition($name, $conflicts = false)
1457
    function setOsInstallCondition($name, $conflicts = false)
1455
    {
1458
    {
1456
        $r = &$this->_getCurrentRelease();
1459
        $r = &$this->_getCurrentRelease();
1457
        if ($r === null) {
1460
        if ($r === null) {
1458
            return false;
1461
            return false;
1459
        }
1462
        }
1460
        $this->_isValid = 0;
1463
        $this->_isValid = 0;
1461
        if (isset($r['installconditions']['os'])) {
1464
        if (isset($r['installconditions']['os'])) {
1462
            unset($r['installconditions']['os']);
1465
            unset($r['installconditions']['os']);
1463
        }
1466
        }
1464
        $dep = array('name' => $name);
1467
        $dep = array('name' => $name);
1465
        if ($conflicts) {
1468
        if ($conflicts) {
1466
            $dep['conflicts'] = '';
1469
            $dep['conflicts'] = '';
1467
        }
1470
        }
1468
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1471
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1469
            $r = $this->_mergeTag($r, $dep,
1472
            $r = $this->_mergeTag($r, $dep,
1470
                array(
1473
                array(
1471
                    'installconditions' => array('configureoption', 'binarypackage',
1474
                    'installconditions' => array('configureoption', 'binarypackage',
1472
                        'filelist'),
1475
                        'filelist'),
1473
                    'os' => array('arch')
1476
                    'os' => array('arch')
1474
                ));
1477
                ));
1475
        } else {
1478
        } else {
1476
            $r = $this->_mergeTag($r, $dep,
1479
            $r = $this->_mergeTag($r, $dep,
1477
                array(
1480
                array(
1478
                    'installconditions' => array('filelist'),
1481
                    'installconditions' => array('filelist'),
1479
                    'os' => array('arch')
1482
                    'os' => array('arch')
1480
                ));
1483
                ));
1481
        }
1484
        }
1482
    }
1485
    }
1483
 
1486
 
1484
    /**
1487
    /**
1485
     * Set an installation condition based on architecture for the current release set
1488
     * Set an installation condition based on architecture for the current release set
1486
     * @param string architecture pattern
1489
     * @param string architecture pattern
1487
     * @param bool whether this arch is incompatible with the current release
1490
     * @param bool whether this arch is incompatible with the current release
1488
     */
1491
     */
1489
    function setArchInstallCondition($pattern, $conflicts = false)
1492
    function setArchInstallCondition($pattern, $conflicts = false)
1490
    {
1493
    {
1491
        $r = &$this->_getCurrentRelease();
1494
        $r = &$this->_getCurrentRelease();
1492
        if ($r === null) {
1495
        if ($r === null) {
1493
            return false;
1496
            return false;
1494
        }
1497
        }
1495
        $this->_isValid = 0;
1498
        $this->_isValid = 0;
1496
        if (isset($r['installconditions']['arch'])) {
1499
        if (isset($r['installconditions']['arch'])) {
1497
            unset($r['installconditions']['arch']);
1500
            unset($r['installconditions']['arch']);
1498
        }
1501
        }
1499
        $dep = array('pattern' => $pattern);
1502
        $dep = array('pattern' => $pattern);
1500
        if ($conflicts) {
1503
        if ($conflicts) {
1501
            $dep['conflicts'] = '';
1504
            $dep['conflicts'] = '';
1502
        }
1505
        }
1503
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1506
        if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
1504
            $r = $this->_mergeTag($r, $dep,
1507
            $r = $this->_mergeTag($r, $dep,
1505
                array(
1508
                array(
1506
                    'installconditions' => array('configureoption', 'binarypackage',
1509
                    'installconditions' => array('configureoption', 'binarypackage',
1507
                        'filelist'),
1510
                        'filelist'),
1508
                    'arch' => array()
1511
                    'arch' => array()
1509
                ));
1512
                ));
1510
        } else {
1513
        } else {
1511
            $r = $this->_mergeTag($r, $dep,
1514
            $r = $this->_mergeTag($r, $dep,
1512
                array(
1515
                array(
1513
                    'installconditions' => array('filelist'),
1516
                    'installconditions' => array('filelist'),
1514
                    'arch' => array()
1517
                    'arch' => array()
1515
                ));
1518
                ));
1516
        }
1519
        }
1517
    }
1520
    }
1518
 
1521
 
1519
    /**
1522
    /**
1520
     * For extension binary releases, this is used to specify either the
1523
     * For extension binary releases, this is used to specify either the
1521
     * static URI to a source package, or the package name and channel of the extsrc/zendextsrc
1524
     * static URI to a source package, or the package name and channel of the extsrc/zendextsrc
1522
     * package it is based on.
1525
     * package it is based on.
1523
     * @param string Package name, or full URI to source package (extsrc/zendextsrc type)
1526
     * @param string Package name, or full URI to source package (extsrc/zendextsrc type)
1524
     */
1527
     */
1525
    function setSourcePackage($packageOrUri)
1528
    function setSourcePackage($packageOrUri)
1526
    {
1529
    {
1527
        $this->_isValid = 0;
1530
        $this->_isValid = 0;
1528
        if (isset($this->_packageInfo['channel'])) {
1531
        if (isset($this->_packageInfo['channel'])) {
1529
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
1532
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
1530
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
1533
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
1531
                'bundle', 'changelog'),
1534
                'bundle', 'changelog'),
1532
                $packageOrUri, 'srcpackage');
1535
                $packageOrUri, 'srcpackage');
1533
        } else {
1536
        } else {
1534
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
1537
            $this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
1535
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
1538
                'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
1536
                'bundle', 'changelog'), $packageOrUri, 'srcuri');
1539
                'bundle', 'changelog'), $packageOrUri, 'srcuri');
1537
        }
1540
        }
1538
    }
1541
    }
1539
 
1542
 
1540
    /**
1543
    /**
1541
     * Generate a valid change log entry from the current package.xml
1544
     * Generate a valid change log entry from the current package.xml
1542
     * @param string|false
1545
     * @param string|false
1543
     */
1546
     */
1544
    function generateChangeLogEntry($notes = false)
1547
    function generateChangeLogEntry($notes = false)
1545
    {
1548
    {
1546
        return array(
1549
        return array(
1547
            'version' => 
1550
            'version' =>
1548
                array(
1551
                array(
1549
                    'release' => $this->getVersion('release'),
1552
                    'release' => $this->getVersion('release'),
1550
                    'api' => $this->getVersion('api'),
1553
                    'api' => $this->getVersion('api'),
1551
                    ),
1554
                    ),
1552
            'stability' =>
1555
            'stability' =>
1553
                $this->getStability(),
1556
                $this->getStability(),
1554
            'date' => $this->getDate(),
1557
            'date' => $this->getDate(),
1555
            'license' => $this->getLicense(true),
1558
            'license' => $this->getLicense(true),
1556
            'notes' => $notes ? $notes : $this->getNotes()
1559
            'notes' => $notes ? $notes : $this->getNotes()
1557
            );
1560
            );
1558
    }
1561
    }
1559
 
1562
 
1560
    /**
1563
    /**
1561
     * @param string release version to set change log notes for
1564
     * @param string release version to set change log notes for
1562
     * @param array output of {@link generateChangeLogEntry()}
1565
     * @param array output of {@link generateChangeLogEntry()}
1563
     */
1566
     */
1564
    function setChangelogEntry($releaseversion, $contents)
1567
    function setChangelogEntry($releaseversion, $contents)
1565
    {
1568
    {
1566
        if (!isset($this->_packageInfo['changelog'])) {
1569
        if (!isset($this->_packageInfo['changelog'])) {
1567
            $this->_packageInfo['changelog']['release'] = $contents;
1570
            $this->_packageInfo['changelog']['release'] = $contents;
1568
            return;
1571
            return;
1569
        }
1572
        }
1570
        if (!isset($this->_packageInfo['changelog']['release'][0])) {
1573
        if (!isset($this->_packageInfo['changelog']['release'][0])) {
1571
            if ($this->_packageInfo['changelog']['release']['version']['release'] == $releaseversion) {
1574
            if ($this->_packageInfo['changelog']['release']['version']['release'] == $releaseversion) {
1572
                $this->_packageInfo['changelog']['release'] = array(
1575
                $this->_packageInfo['changelog']['release'] = array(
1573
                    $this->_packageInfo['changelog']['release']);
1576
                    $this->_packageInfo['changelog']['release']);
1574
            } else {
1577
            } else {
1575
                $this->_packageInfo['changelog']['release'] = array(
1578
                $this->_packageInfo['changelog']['release'] = array(
1576
                    $this->_packageInfo['changelog']['release']);
1579
                    $this->_packageInfo['changelog']['release']);
1577
                return $this->_packageInfo['changelog']['release'][] = $contents;
1580
                return $this->_packageInfo['changelog']['release'][] = $contents;
1578
            }
1581
            }
1579
        }
1582
        }
1580
        foreach($this->_packageInfo['changelog']['release'] as $index => $changelog) {
1583
        foreach($this->_packageInfo['changelog']['release'] as $index => $changelog) {
1581
            if (isset($changelog['version']) &&
1584
            if (isset($changelog['version']) &&
1582
                  strnatcasecmp($changelog['version']['release'], $releaseversion) == 0) {
1585
                  strnatcasecmp($changelog['version']['release'], $releaseversion) == 0) {
1583
                $curlog = $index;
1586
                $curlog = $index;
1584
            }
1587
            }
1585
        }
1588
        }
1586
        if (isset($curlog)) {
1589
        if (isset($curlog)) {
1587
            $this->_packageInfo['changelog']['release'][$curlog] = $contents;
1590
            $this->_packageInfo['changelog']['release'][$curlog] = $contents;
1588
        } else {
1591
        } else {
1589
            $this->_packageInfo['changelog']['release'][] = $contents;
1592
            $this->_packageInfo['changelog']['release'][] = $contents;
1590
        }
1593
        }
1591
    }
1594
    }
1592
 
1595
 
1593
    /**
1596
    /**
1594
     * Remove the changelog entirely
1597
     * Remove the changelog entirely
1595
     */
1598
     */
1596
    function clearChangeLog()
1599
    function clearChangeLog()
1597
    {
1600
    {
1598
        unset($this->_packageInfo['changelog']);
1601
        unset($this->_packageInfo['changelog']);
1599
    }
1602
    }
1600
}
-
 
1601
?>
-
 
1602
1603
}
-
 
1604
1603
1605