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
 * package.xml parsing class, package.xml version 1.0
3
 * package.xml parsing class, package.xml version 1.0
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: v1.php,v 1.22 2006/03/27 05:25:48 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.0a1
13
 * @since      File available since Release 1.4.0a1
21
 */
14
 */
22
/**
15
/**
23
 * package.xml abstraction class
16
 * package.xml abstraction class
24
 */
17
 */
25
require_once 'PEAR/PackageFile/v1.php';
18
require_once 'PEAR/PackageFile/v1.php';
26
/**
19
/**
27
 * Parser for package.xml version 1.0
20
 * Parser for package.xml version 1.0
28
 * @category   pear
21
 * @category   pear
29
 * @package    PEAR
22
 * @package    PEAR
30
 * @author     Greg Beaver <cellog@php.net>
23
 * @author     Greg Beaver <cellog@php.net>
31
 * @copyright  1997-2006 The PHP Group
24
 * @copyright  1997-2009 The Authors
32
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
25
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
33
 * @version    Release: @PEAR-VER@
26
 * @version    Release: @PEAR-VER@
34
 * @link       http://pear.php.net/package/PEAR
27
 * @link       http://pear.php.net/package/PEAR
35
 * @since      Class available since Release 1.4.0a1
28
 * @since      Class available since Release 1.4.0a1
36
 */
29
 */
37
class PEAR_PackageFile_Parser_v1
30
class PEAR_PackageFile_Parser_v1
38
{
31
{
39
    var $_registry;
32
    var $_registry;
40
    var $_config;
33
    var $_config;
41
    var $_logger;
34
    var $_logger;
42
    /**
35
    /**
43
     * BC hack to allow PEAR_Common::infoFromString() to sort of
36
     * BC hack to allow PEAR_Common::infoFromString() to sort of
44
     * work with the version 2.0 format - there's no filelist though
37
     * work with the version 2.0 format - there's no filelist though
45
     * @param PEAR_PackageFile_v2
38
     * @param PEAR_PackageFile_v2
46
     */
39
     */
47
    function fromV2($packagefile)
40
    function fromV2($packagefile)
48
    {
41
    {
49
        $info = $packagefile->getArray(true);
42
        $info = $packagefile->getArray(true);
50
        $ret = new PEAR_PackageFile_v1;
43
        $ret = new PEAR_PackageFile_v1;
51
        $ret->fromArray($info['old']);
44
        $ret->fromArray($info['old']);
52
    }
45
    }
53
 
46
 
54
    function setConfig(&$c)
47
    function setConfig(&$c)
55
    {
48
    {
56
        $this->_config = &$c;
49
        $this->_config = &$c;
57
        $this->_registry = &$c->getRegistry();
50
        $this->_registry = &$c->getRegistry();
58
    }
51
    }
59
 
52
 
60
    function setLogger(&$l)
53
    function setLogger(&$l)
61
    {
54
    {
62
        $this->_logger = &$l;
55
        $this->_logger = &$l;
63
    }
56
    }
64
 
57
 
65
    /**
58
    /**
66
     * @param string contents of package.xml file, version 1.0
59
     * @param string contents of package.xml file, version 1.0
67
     * @return bool success of parsing
60
     * @return bool success of parsing
68
     */
61
     */
69
    function parse($data, $file, $archive = false)
62
    function &parse($data, $file, $archive = false)
70
    {
63
    {
71
        if (!extension_loaded('xml')) {
64
        if (!extension_loaded('xml')) {
72
            return PEAR::raiseError('Cannot create xml parser for parsing package.xml, no xml extension');
65
            return PEAR::raiseError('Cannot create xml parser for parsing package.xml, no xml extension');
73
        }
66
        }
74
        $xp = xml_parser_create();
67
        $xp = xml_parser_create();
75
        if (!$xp) {
68
        if (!$xp) {
76
            return PEAR::raiseError('Cannot create xml parser for parsing package.xml');
69
            $a = &PEAR::raiseError('Cannot create xml parser for parsing package.xml');
-
 
70
            return $a;
77
        }
71
        }
78
        xml_set_object($xp, $this);
72
        xml_set_object($xp, $this);
79
        xml_set_element_handler($xp, '_element_start_1_0', '_element_end_1_0');
73
        xml_set_element_handler($xp, '_element_start_1_0', '_element_end_1_0');
80
        xml_set_character_data_handler($xp, '_pkginfo_cdata_1_0');
74
        xml_set_character_data_handler($xp, '_pkginfo_cdata_1_0');
81
        xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
75
        xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
82
 
76
 
83
        $this->element_stack = array();
77
        $this->element_stack = array();
84
        $this->_packageInfo = array('provides' => array());
78
        $this->_packageInfo = array('provides' => array());
85
        $this->current_element = false;
79
        $this->current_element = false;
86
        unset($this->dir_install);
80
        unset($this->dir_install);
87
        $this->_packageInfo['filelist'] = array();
81
        $this->_packageInfo['filelist'] = array();
88
        $this->filelist =& $this->_packageInfo['filelist'];
82
        $this->filelist =& $this->_packageInfo['filelist'];
89
        $this->dir_names = array();
83
        $this->dir_names = array();
90
        $this->in_changelog = false;
84
        $this->in_changelog = false;
91
        $this->d_i = 0;
85
        $this->d_i = 0;
92
        $this->cdata = '';
86
        $this->cdata = '';
93
        $this->_isValid = true;
87
        $this->_isValid = true;
94
 
88
 
95
        if (!xml_parse($xp, $data, 1)) {
89
        if (!xml_parse($xp, $data, 1)) {
96
            $code = xml_get_error_code($xp);
90
            $code = xml_get_error_code($xp);
97
            $line = xml_get_current_line_number($xp);
91
            $line = xml_get_current_line_number($xp);
98
            xml_parser_free($xp);
92
            xml_parser_free($xp);
99
            return PEAR::raiseError(sprintf("XML error: %s at line %d",
93
            $a = PEAR::raiseError(sprintf("XML error: %s at line %d",
100
                           $str = xml_error_string($code), $line), 2);
94
                           $str = xml_error_string($code), $line), 2);
-
 
95
            return $a;
101
        }
96
        }
102
 
97
 
103
        xml_parser_free($xp);
98
        xml_parser_free($xp);
104
 
99
 
105
        $pf = new PEAR_PackageFile_v1;
100
        $pf = new PEAR_PackageFile_v1;
106
        $pf->setConfig($this->_config);
101
        $pf->setConfig($this->_config);
107
        if (isset($this->_logger)) {
102
        if (isset($this->_logger)) {
108
            $pf->setLogger($this->_logger);
103
            $pf->setLogger($this->_logger);
109
        }
104
        }
110
        $pf->setPackagefile($file, $archive);
105
        $pf->setPackagefile($file, $archive);
111
        $pf->fromArray($this->_packageInfo);
106
        $pf->fromArray($this->_packageInfo);
112
        return $pf;
107
        return $pf;
113
    }
108
    }
114
    // {{{ _unIndent()
109
    // {{{ _unIndent()
115
 
110
 
116
    /**
111
    /**
117
     * Unindent given string
112
     * Unindent given string
118
     *
113
     *
119
     * @param string $str The string that has to be unindented.
114
     * @param string $str The string that has to be unindented.
120
     * @return string
115
     * @return string
121
     * @access private
116
     * @access private
122
     */
117
     */
123
    function _unIndent($str)
118
    function _unIndent($str)
124
    {
119
    {
125
        // remove leading newlines
120
        // remove leading newlines
126
        $str = preg_replace('/^[\r\n]+/', '', $str);
121
        $str = preg_replace('/^[\r\n]+/', '', $str);
127
        // find whitespace at the beginning of the first line
122
        // find whitespace at the beginning of the first line
128
        $indent_len = strspn($str, " \t");
123
        $indent_len = strspn($str, " \t");
129
        $indent = substr($str, 0, $indent_len);
124
        $indent = substr($str, 0, $indent_len);
130
        $data = '';
125
        $data = '';
131
        // remove the same amount of whitespace from following lines
126
        // remove the same amount of whitespace from following lines
132
        foreach (explode("\n", $str) as $line) {
127
        foreach (explode("\n", $str) as $line) {
133
            if (substr($line, 0, $indent_len) == $indent) {
128
            if (substr($line, 0, $indent_len) == $indent) {
134
                $data .= substr($line, $indent_len) . "\n";
129
                $data .= substr($line, $indent_len) . "\n";
-
 
130
            } elseif (trim(substr($line, 0, $indent_len))) {
-
 
131
                $data .= ltrim($line);
135
            }
132
            }
136
        }
133
        }
137
        return $data;
134
        return $data;
138
    }
135
    }
139
 
136
 
140
    // Support for package DTD v1.0:
137
    // Support for package DTD v1.0:
141
    // {{{ _element_start_1_0()
138
    // {{{ _element_start_1_0()
142
 
139
 
143
    /**
140
    /**
144
     * XML parser callback for ending elements.  Used for version 1.0
141
     * XML parser callback for ending elements.  Used for version 1.0
145
     * packages.
142
     * packages.
146
     *
143
     *
147
     * @param resource  $xp    XML parser resource
144
     * @param resource  $xp    XML parser resource
148
     * @param string    $name  name of ending element
145
     * @param string    $name  name of ending element
149
     *
146
     *
150
     * @return void
147
     * @return void
151
     *
148
     *
152
     * @access private
149
     * @access private
153
     */
150
     */
154
    function _element_start_1_0($xp, $name, $attribs)
151
    function _element_start_1_0($xp, $name, $attribs)
155
    {
152
    {
156
        array_push($this->element_stack, $name);
153
        array_push($this->element_stack, $name);
157
        $this->current_element = $name;
154
        $this->current_element = $name;
158
        $spos = sizeof($this->element_stack) - 2;
155
        $spos = sizeof($this->element_stack) - 2;
159
        $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : '';
156
        $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : '';
160
        $this->current_attributes = $attribs;
157
        $this->current_attributes = $attribs;
161
        $this->cdata = '';
158
        $this->cdata = '';
162
        switch ($name) {
159
        switch ($name) {
163
            case 'dir':
160
            case 'dir':
164
                if ($this->in_changelog) {
161
                if ($this->in_changelog) {
165
                    break;
162
                    break;
166
                }
163
                }
167
                if (array_key_exists('name', $attribs) && $attribs['name'] != '/') {
164
                if (array_key_exists('name', $attribs) && $attribs['name'] != '/') {
168
                    $attribs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
165
                    $attribs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
169
                        $attribs['name']);
166
                        $attribs['name']);
170
                    if (strrpos($attribs['name'], '/') == strlen($attribs['name']) - 1) {
167
                    if (strrpos($attribs['name'], '/') === strlen($attribs['name']) - 1) {
171
                        $attribs['name'] = substr($attribs['name'], 0,
168
                        $attribs['name'] = substr($attribs['name'], 0,
172
                            strlen($attribs['name']) - 1);
169
                            strlen($attribs['name']) - 1);
173
                    }
170
                    }
174
                    if (strpos($attribs['name'], '/') === 0) {
171
                    if (strpos($attribs['name'], '/') === 0) {
175
                        $attribs['name'] = substr($attribs['name'], 1);
172
                        $attribs['name'] = substr($attribs['name'], 1);
176
                    }
173
                    }
177
                    $this->dir_names[] = $attribs['name'];
174
                    $this->dir_names[] = $attribs['name'];
178
                }
175
                }
179
                if (isset($attribs['baseinstalldir'])) {
176
                if (isset($attribs['baseinstalldir'])) {
180
                    $this->dir_install = $attribs['baseinstalldir'];
177
                    $this->dir_install = $attribs['baseinstalldir'];
181
                }
178
                }
182
                if (isset($attribs['role'])) {
179
                if (isset($attribs['role'])) {
183
                    $this->dir_role = $attribs['role'];
180
                    $this->dir_role = $attribs['role'];
184
                }
181
                }
185
                break;
182
                break;
186
            case 'file':
183
            case 'file':
187
                if ($this->in_changelog) {
184
                if ($this->in_changelog) {
188
                    break;
185
                    break;
189
                }
186
                }
190
                if (isset($attribs['name'])) {
187
                if (isset($attribs['name'])) {
191
                    $path = '';
188
                    $path = '';
192
                    if (count($this->dir_names)) {
189
                    if (count($this->dir_names)) {
193
                        foreach ($this->dir_names as $dir) {
190
                        foreach ($this->dir_names as $dir) {
194
                            $path .= $dir . '/';
191
                            $path .= $dir . '/';
195
                        }
192
                        }
196
                    }
193
                    }
197
                    $path .= preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
194
                    $path .= preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
198
                        $attribs['name']);
195
                        $attribs['name']);
199
                    unset($attribs['name']);
196
                    unset($attribs['name']);
200
                    $this->current_path = $path;
197
                    $this->current_path = $path;
201
                    $this->filelist[$path] = $attribs;
198
                    $this->filelist[$path] = $attribs;
202
                    // Set the baseinstalldir only if the file don't have this attrib
199
                    // Set the baseinstalldir only if the file don't have this attrib
203
                    if (!isset($this->filelist[$path]['baseinstalldir']) &&
200
                    if (!isset($this->filelist[$path]['baseinstalldir']) &&
204
                        isset($this->dir_install))
201
                        isset($this->dir_install))
205
                    {
202
                    {
206
                        $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
203
                        $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
207
                    }
204
                    }
208
                    // Set the Role
205
                    // Set the Role
209
                    if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
206
                    if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
210
                        $this->filelist[$path]['role'] = $this->dir_role;
207
                        $this->filelist[$path]['role'] = $this->dir_role;
211
                    }
208
                    }
212
                }
209
                }
213
                break;
210
                break;
214
            case 'replace':
211
            case 'replace':
215
                if (!$this->in_changelog) {
212
                if (!$this->in_changelog) {
216
                    $this->filelist[$this->current_path]['replacements'][] = $attribs;
213
                    $this->filelist[$this->current_path]['replacements'][] = $attribs;
217
                }
214
                }
218
                break;
215
                break;
219
            case 'maintainers':
216
            case 'maintainers':
220
                $this->_packageInfo['maintainers'] = array();
217
                $this->_packageInfo['maintainers'] = array();
221
                $this->m_i = 0; // maintainers array index
218
                $this->m_i = 0; // maintainers array index
222
                break;
219
                break;
223
            case 'maintainer':
220
            case 'maintainer':
224
                // compatibility check
221
                // compatibility check
225
                if (!isset($this->_packageInfo['maintainers'])) {
222
                if (!isset($this->_packageInfo['maintainers'])) {
226
                    $this->_packageInfo['maintainers'] = array();
223
                    $this->_packageInfo['maintainers'] = array();
227
                    $this->m_i = 0;
224
                    $this->m_i = 0;
228
                }
225
                }
229
                $this->_packageInfo['maintainers'][$this->m_i] = array();
226
                $this->_packageInfo['maintainers'][$this->m_i] = array();
230
                $this->current_maintainer =& $this->_packageInfo['maintainers'][$this->m_i];
227
                $this->current_maintainer =& $this->_packageInfo['maintainers'][$this->m_i];
231
                break;
228
                break;
232
            case 'changelog':
229
            case 'changelog':
233
                $this->_packageInfo['changelog'] = array();
230
                $this->_packageInfo['changelog'] = array();
234
                $this->c_i = 0; // changelog array index
231
                $this->c_i = 0; // changelog array index
235
                $this->in_changelog = true;
232
                $this->in_changelog = true;
236
                break;
233
                break;
237
            case 'release':
234
            case 'release':
238
                if ($this->in_changelog) {
235
                if ($this->in_changelog) {
239
                    $this->_packageInfo['changelog'][$this->c_i] = array();
236
                    $this->_packageInfo['changelog'][$this->c_i] = array();
240
                    $this->current_release = &$this->_packageInfo['changelog'][$this->c_i];
237
                    $this->current_release = &$this->_packageInfo['changelog'][$this->c_i];
241
                } else {
238
                } else {
242
                    $this->current_release = &$this->_packageInfo;
239
                    $this->current_release = &$this->_packageInfo;
243
                }
240
                }
244
                break;
241
                break;
245
            case 'deps':
242
            case 'deps':
246
                if (!$this->in_changelog) {
243
                if (!$this->in_changelog) {
247
                    $this->_packageInfo['release_deps'] = array();
244
                    $this->_packageInfo['release_deps'] = array();
248
                }
245
                }
249
                break;
246
                break;
250
            case 'dep':
247
            case 'dep':
251
                // dependencies array index
248
                // dependencies array index
252
                if (!$this->in_changelog) {
249
                if (!$this->in_changelog) {
253
                    $this->d_i++;
250
                    $this->d_i++;
254
                    isset($attribs['type']) ? ($attribs['type'] = strtolower($attribs['type'])) : false;
251
                    isset($attribs['type']) ? ($attribs['type'] = strtolower($attribs['type'])) : false;
255
                    $this->_packageInfo['release_deps'][$this->d_i] = $attribs;
252
                    $this->_packageInfo['release_deps'][$this->d_i] = $attribs;
256
                }
253
                }
257
                break;
254
                break;
258
            case 'configureoptions':
255
            case 'configureoptions':
259
                if (!$this->in_changelog) {
256
                if (!$this->in_changelog) {
260
                    $this->_packageInfo['configure_options'] = array();
257
                    $this->_packageInfo['configure_options'] = array();
261
                }
258
                }
262
                break;
259
                break;
263
            case 'configureoption':
260
            case 'configureoption':
264
                if (!$this->in_changelog) {
261
                if (!$this->in_changelog) {
265
                    $this->_packageInfo['configure_options'][] = $attribs;
262
                    $this->_packageInfo['configure_options'][] = $attribs;
266
                }
263
                }
267
                break;
264
                break;
268
            case 'provides':
265
            case 'provides':
269
                if (empty($attribs['type']) || empty($attribs['name'])) {
266
                if (empty($attribs['type']) || empty($attribs['name'])) {
270
                    break;
267
                    break;
271
                }
268
                }
272
                $attribs['explicit'] = true;
269
                $attribs['explicit'] = true;
273
                $this->_packageInfo['provides']["$attribs[type];$attribs[name]"] = $attribs;
270
                $this->_packageInfo['provides']["$attribs[type];$attribs[name]"] = $attribs;
274
                break;
271
                break;
275
            case 'package' :
272
            case 'package' :
276
                if (isset($attribs['version'])) {
273
                if (isset($attribs['version'])) {
277
                    $this->_packageInfo['xsdversion'] = trim($attribs['version']);
274
                    $this->_packageInfo['xsdversion'] = trim($attribs['version']);
278
                } else {
275
                } else {
279
                    $this->_packageInfo['xsdversion'] = '1.0';
276
                    $this->_packageInfo['xsdversion'] = '1.0';
280
                }
277
                }
281
                if (isset($attribs['packagerversion'])) {
278
                if (isset($attribs['packagerversion'])) {
282
                    $this->_packageInfo['packagerversion'] = $attribs['packagerversion'];
279
                    $this->_packageInfo['packagerversion'] = $attribs['packagerversion'];
283
                }
280
                }
284
                break;
281
                break;
285
        }
282
        }
286
    }
283
    }
287
 
284
 
288
    // }}}
285
    // }}}
289
    // {{{ _element_end_1_0()
286
    // {{{ _element_end_1_0()
290
 
287
 
291
    /**
288
    /**
292
     * XML parser callback for ending elements.  Used for version 1.0
289
     * XML parser callback for ending elements.  Used for version 1.0
293
     * packages.
290
     * packages.
294
     *
291
     *
295
     * @param resource  $xp    XML parser resource
292
     * @param resource  $xp    XML parser resource
296
     * @param string    $name  name of ending element
293
     * @param string    $name  name of ending element
297
     *
294
     *
298
     * @return void
295
     * @return void
299
     *
296
     *
300
     * @access private
297
     * @access private
301
     */
298
     */
302
    function _element_end_1_0($xp, $name)
299
    function _element_end_1_0($xp, $name)
303
    {
300
    {
304
        $data = trim($this->cdata);
301
        $data = trim($this->cdata);
305
        switch ($name) {
302
        switch ($name) {
306
            case 'name':
303
            case 'name':
307
                switch ($this->prev_element) {
304
                switch ($this->prev_element) {
308
                    case 'package':
305
                    case 'package':
309
                        $this->_packageInfo['package'] = $data;
306
                        $this->_packageInfo['package'] = $data;
310
                        break;
307
                        break;
311
                    case 'maintainer':
308
                    case 'maintainer':
312
                        $this->current_maintainer['name'] = $data;
309
                        $this->current_maintainer['name'] = $data;
313
                        break;
310
                        break;
314
                }
311
                }
315
                break;
312
                break;
316
            case 'extends' :
313
            case 'extends' :
317
                $this->_packageInfo['extends'] = $data;
314
                $this->_packageInfo['extends'] = $data;
318
                break;
315
                break;
319
            case 'summary':
316
            case 'summary':
320
                $this->_packageInfo['summary'] = $data;
317
                $this->_packageInfo['summary'] = $data;
321
                break;
318
                break;
322
            case 'description':
319
            case 'description':
323
                $data = $this->_unIndent($this->cdata);
320
                $data = $this->_unIndent($this->cdata);
324
                $this->_packageInfo['description'] = $data;
321
                $this->_packageInfo['description'] = $data;
325
                break;
322
                break;
326
            case 'user':
323
            case 'user':
327
                $this->current_maintainer['handle'] = $data;
324
                $this->current_maintainer['handle'] = $data;
328
                break;
325
                break;
329
            case 'email':
326
            case 'email':
330
                $this->current_maintainer['email'] = $data;
327
                $this->current_maintainer['email'] = $data;
331
                break;
328
                break;
332
            case 'role':
329
            case 'role':
333
                $this->current_maintainer['role'] = $data;
330
                $this->current_maintainer['role'] = $data;
334
                break;
331
                break;
335
            case 'version':
332
            case 'version':
336
                //$data = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $data);
-
 
337
                if ($this->in_changelog) {
333
                if ($this->in_changelog) {
338
                    $this->current_release['version'] = $data;
334
                    $this->current_release['version'] = $data;
339
                } else {
335
                } else {
340
                    $this->_packageInfo['version'] = $data;
336
                    $this->_packageInfo['version'] = $data;
341
                }
337
                }
342
                break;
338
                break;
343
            case 'date':
339
            case 'date':
344
                if ($this->in_changelog) {
340
                if ($this->in_changelog) {
345
                    $this->current_release['release_date'] = $data;
341
                    $this->current_release['release_date'] = $data;
346
                } else {
342
                } else {
347
                    $this->_packageInfo['release_date'] = $data;
343
                    $this->_packageInfo['release_date'] = $data;
348
                }
344
                }
349
                break;
345
                break;
350
            case 'notes':
346
            case 'notes':
351
                // try to "de-indent" release notes in case someone
347
                // try to "de-indent" release notes in case someone
352
                // has been over-indenting their xml ;-)
348
                // has been over-indenting their xml ;-)
-
 
349
                // Trim only on the right side
353
                $data = $this->_unIndent($this->cdata);
350
                $data = rtrim($this->_unIndent($this->cdata));
354
                if ($this->in_changelog) {
351
                if ($this->in_changelog) {
355
                    $this->current_release['release_notes'] = $data;
352
                    $this->current_release['release_notes'] = $data;
356
                } else {
353
                } else {
357
                    $this->_packageInfo['release_notes'] = $data;
354
                    $this->_packageInfo['release_notes'] = $data;
358
                }
355
                }
359
                break;
356
                break;
360
            case 'warnings':
357
            case 'warnings':
361
                if ($this->in_changelog) {
358
                if ($this->in_changelog) {
362
                    $this->current_release['release_warnings'] = $data;
359
                    $this->current_release['release_warnings'] = $data;
363
                } else {
360
                } else {
364
                    $this->_packageInfo['release_warnings'] = $data;
361
                    $this->_packageInfo['release_warnings'] = $data;
365
                }
362
                }
366
                break;
363
                break;
367
            case 'state':
364
            case 'state':
368
                if ($this->in_changelog) {
365
                if ($this->in_changelog) {
369
                    $this->current_release['release_state'] = $data;
366
                    $this->current_release['release_state'] = $data;
370
                } else {
367
                } else {
371
                    $this->_packageInfo['release_state'] = $data;
368
                    $this->_packageInfo['release_state'] = $data;
372
                }
369
                }
373
                break;
370
                break;
374
            case 'license':
371
            case 'license':
375
                if ($this->in_changelog) {
372
                if ($this->in_changelog) {
376
                    $this->current_release['release_license'] = $data;
373
                    $this->current_release['release_license'] = $data;
377
                } else {
374
                } else {
378
                    $this->_packageInfo['release_license'] = $data;
375
                    $this->_packageInfo['release_license'] = $data;
379
                }
376
                }
380
                break;
377
                break;
381
            case 'dep':
378
            case 'dep':
382
                if ($data && !$this->in_changelog) {
379
                if ($data && !$this->in_changelog) {
383
                    $this->_packageInfo['release_deps'][$this->d_i]['name'] = $data;
380
                    $this->_packageInfo['release_deps'][$this->d_i]['name'] = $data;
384
                }
381
                }
385
                break;
382
                break;
386
            case 'dir':
383
            case 'dir':
387
                if ($this->in_changelog) {
384
                if ($this->in_changelog) {
388
                    break;
385
                    break;
389
                }
386
                }
390
                array_pop($this->dir_names);
387
                array_pop($this->dir_names);
391
                break;
388
                break;
392
            case 'file':
389
            case 'file':
393
                if ($this->in_changelog) {
390
                if ($this->in_changelog) {
394
                    break;
391
                    break;
395
                }
392
                }
396
                if ($data) {
393
                if ($data) {
397
                    $path = '';
394
                    $path = '';
398
                    if (count($this->dir_names)) {
395
                    if (count($this->dir_names)) {
399
                        foreach ($this->dir_names as $dir) {
396
                        foreach ($this->dir_names as $dir) {
400
                            $path .= $dir . '/';
397
                            $path .= $dir . '/';
401
                        }
398
                        }
402
                    }
399
                    }
403
                    $path .= $data;
400
                    $path .= $data;
404
                    $this->filelist[$path] = $this->current_attributes;
401
                    $this->filelist[$path] = $this->current_attributes;
405
                    // Set the baseinstalldir only if the file don't have this attrib
402
                    // Set the baseinstalldir only if the file don't have this attrib
406
                    if (!isset($this->filelist[$path]['baseinstalldir']) &&
403
                    if (!isset($this->filelist[$path]['baseinstalldir']) &&
407
                        isset($this->dir_install))
404
                        isset($this->dir_install))
408
                    {
405
                    {
409
                        $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
406
                        $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
410
                    }
407
                    }
411
                    // Set the Role
408
                    // Set the Role
412
                    if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
409
                    if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
413
                        $this->filelist[$path]['role'] = $this->dir_role;
410
                        $this->filelist[$path]['role'] = $this->dir_role;
414
                    }
411
                    }
415
                }
412
                }
416
                break;
413
                break;
417
            case 'maintainer':
414
            case 'maintainer':
418
                if (empty($this->_packageInfo['maintainers'][$this->m_i]['role'])) {
415
                if (empty($this->_packageInfo['maintainers'][$this->m_i]['role'])) {
419
                    $this->_packageInfo['maintainers'][$this->m_i]['role'] = 'lead';
416
                    $this->_packageInfo['maintainers'][$this->m_i]['role'] = 'lead';
420
                }
417
                }
421
                $this->m_i++;
418
                $this->m_i++;
422
                break;
419
                break;
423
            case 'release':
420
            case 'release':
424
                if ($this->in_changelog) {
421
                if ($this->in_changelog) {
425
                    $this->c_i++;
422
                    $this->c_i++;
426
                }
423
                }
427
                break;
424
                break;
428
            case 'changelog':
425
            case 'changelog':
429
                $this->in_changelog = false;
426
                $this->in_changelog = false;
430
                break;
427
                break;
431
        }
428
        }
432
        array_pop($this->element_stack);
429
        array_pop($this->element_stack);
433
        $spos = sizeof($this->element_stack) - 1;
430
        $spos = sizeof($this->element_stack) - 1;
434
        $this->current_element = ($spos > 0) ? $this->element_stack[$spos] : '';
431
        $this->current_element = ($spos > 0) ? $this->element_stack[$spos] : '';
435
        $this->cdata = '';
432
        $this->cdata = '';
436
    }
433
    }
437
 
434
 
438
    // }}}
435
    // }}}
439
    // {{{ _pkginfo_cdata_1_0()
436
    // {{{ _pkginfo_cdata_1_0()
440
 
437
 
441
    /**
438
    /**
442
     * XML parser callback for character data.  Used for version 1.0
439
     * XML parser callback for character data.  Used for version 1.0
443
     * packages.
440
     * packages.
444
     *
441
     *
445
     * @param resource  $xp    XML parser resource
442
     * @param resource  $xp    XML parser resource
446
     * @param string    $name  character data
443
     * @param string    $name  character data
447
     *
444
     *
448
     * @return void
445
     * @return void
449
     *
446
     *
450
     * @access private
447
     * @access private
451
     */
448
     */
452
    function _pkginfo_cdata_1_0($xp, $data)
449
    function _pkginfo_cdata_1_0($xp, $data)
453
    {
450
    {
454
        if (isset($this->cdata)) {
451
        if (isset($this->cdata)) {
455
            $this->cdata .= $data;
452
            $this->cdata .= $data;
456
        }
453
        }
457
    }
454
    }
458
 
455
 
459
    // }}}
456
    // }}}
460
}
457
}
461
?>
458
?>