Хранилища Subversion ant

Редакция

Редакция 69 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 69 Редакция 87
1
<?php
1
<?php
2
/**
2
/**
3
 * <tasks:postinstallscript> - read/write version
3
 * <tasks:postinstallscript> - 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
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
8
 * that is available through the world-wide-web at the following URI:
8
 * that is available through the world-wide-web at the following URI:
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
10
 * the PHP License and are unable to obtain it through the web, please
10
 * the PHP License and are unable to obtain it through the web, please
11
 * send a note to license@php.net so we can mail you a copy immediately.
11
 * send a note to license@php.net so we can mail you a copy immediately.
12
 *
12
 *
13
 * @category   pear
13
 * @category   pear
14
 * @package    PEAR
14
 * @package    PEAR
15
 * @author     Greg Beaver <cellog@php.net>
15
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2008 The PHP Group
16
 * @copyright  1997-2008 The PHP Group
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
18
 * @version    CVS: $Id: rw.php,v 1.12 2008/01/03 20:26:37 cellog Exp $
18
 * @version    CVS: $Id: rw.php,v 1.12 2008/01/03 20:26:37 cellog Exp $
19
 * @link       http://pear.php.net/package/PEAR
19
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a10
20
 * @since      File available since Release 1.4.0a10
21
 */
21
 */
22
/**
22
/**
23
 * Base class
23
 * Base class
24
 */
24
 */
25
require_once 'PEAR/Task/Postinstallscript.php';
25
require_once 'PEAR/Task/Postinstallscript.php';
26
/**
26
/**
27
 * Abstracts the postinstallscript file task xml.
27
 * Abstracts the postinstallscript file task xml.
28
 * @category   pear
28
 * @category   pear
29
 * @package    PEAR
29
 * @package    PEAR
30
 * @author     Greg Beaver <cellog@php.net>
30
 * @author     Greg Beaver <cellog@php.net>
31
 * @copyright  1997-2008 The PHP Group
31
 * @copyright  1997-2008 The PHP Group
32
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
32
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
33
 * @version    Release: 1.7.2
33
 * @version    Release: 1.7.2
34
 * @link       http://pear.php.net/package/PEAR
34
 * @link       http://pear.php.net/package/PEAR
35
 * @since      Class available since Release 1.4.0a10
35
 * @since      Class available since Release 1.4.0a10
36
 */
36
 */
37
class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
37
class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
38
{
38
{
39
    /**
39
    /**
40
     * parent package file object
40
     * parent package file object
41
     *
41
     *
42
     * @var PEAR_PackageFile_v2_rw
42
     * @var PEAR_PackageFile_v2_rw
43
     */
43
     */
44
    var $_pkg;
44
    var $_pkg;
45
    /**
45
    /**
46
     * Enter description here...
46
     * Enter description here...
47
     *
47
     *
48
     * @param PEAR_PackageFile_v2_rw $pkg
48
     * @param PEAR_PackageFile_v2_rw $pkg
49
     * @param PEAR_Config $config
49
     * @param PEAR_Config $config
50
     * @param PEAR_Frontend $logger
50
     * @param PEAR_Frontend $logger
51
     * @param array $fileXml
51
     * @param array $fileXml
52
     * @return PEAR_Task_Postinstallscript_rw
52
     * @return PEAR_Task_Postinstallscript_rw
53
     */
53
     */
54
    function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
54
    function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
55
    {
55
    {
56
        parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
56
        parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
57
        $this->_contents = $fileXml;
57
        $this->_contents = $fileXml;
58
        $this->_pkg = &$pkg;
58
        $this->_pkg = &$pkg;
59
        $this->_params = array();
59
        $this->_params = array();
60
    }
60
    }
61
61
62
    function validate()
62
    function validate()
63
    {
63
    {
64
        return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
64
        return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
65
    }
65
    }
66
66
67
    function getName()
67
    function getName()
68
    {
68
    {
69
        return 'postinstallscript';
69
        return 'postinstallscript';
70
    }
70
    }
71
71
72
    /**
72
    /**
73
     * add a simple <paramgroup> to the post-install script
73
     * add a simple <paramgroup> to the post-install script
74
     *
74
     *
75
     * Order is significant, so call this method in the same
75
     * Order is significant, so call this method in the same
76
     * sequence the users should see the paramgroups.  The $params
76
     * sequence the users should see the paramgroups.  The $params
77
     * parameter should either be the result of a call to {@link getParam()}
77
     * parameter should either be the result of a call to {@link getParam()}
78
     * or an array of calls to getParam().
78
     * or an array of calls to getParam().
79
     *
79
     *
80
     * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
80
     * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
81
     * a <conditiontype> tag
81
     * a <conditiontype> tag
82
     * @param string $id <paramgroup> id as seen by the script
82
     * @param string $id <paramgroup> id as seen by the script
83
     * @param array|false $params array of getParam() calls, or false for no params
83
     * @param array|false $params array of getParam() calls, or false for no params
84
     * @param string|false $instructions
84
     * @param string|false $instructions
85
     */
85
     */
86
    function addParamGroup($id, $params = false, $instructions = false)
86
    function addParamGroup($id, $params = false, $instructions = false)
87
    {
87
    {
88
        if ($params && isset($params[0]) && !isset($params[1])) {
88
        if ($params && isset($params[0]) && !isset($params[1])) {
89
            $params = $params[0];
89
            $params = $params[0];
90
        }
90
        }
91
        $stuff =
91
        $stuff =
92
            array(
92
            array(
93
                $this->_pkg->getTasksNs() . ':id' => $id,
93
                $this->_pkg->getTasksNs() . ':id' => $id,
94
            );
94
            );
95
        if ($instructions) {
95
        if ($instructions) {
96
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
96
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
97
        }
97
        }
98
        if ($params) {
98
        if ($params) {
99
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
99
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
100
        }
100
        }
101
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
101
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
102
    }
102
    }
103
103
104
    /**
104
    /**
105
     * add a complex <paramgroup> to the post-install script with conditions
105
     * add a complex <paramgroup> to the post-install script with conditions
106
     *
106
     *
107
     * This inserts a <paramgroup> with
107
     * This inserts a <paramgroup> with
108
     *
108
     *
109
     * Order is significant, so call this method in the same
109
     * Order is significant, so call this method in the same
110
     * sequence the users should see the paramgroups.  The $params
110
     * sequence the users should see the paramgroups.  The $params
111
     * parameter should either be the result of a call to {@link getParam()}
111
     * parameter should either be the result of a call to {@link getParam()}
112
     * or an array of calls to getParam().
112
     * or an array of calls to getParam().
113
     *
113
     *
114
     * Use {@link addParamGroup()} to add a simple <paramgroup>
114
     * Use {@link addParamGroup()} to add a simple <paramgroup>
115
     *
115
     *
116
     * @param string $id <paramgroup> id as seen by the script
116
     * @param string $id <paramgroup> id as seen by the script
117
     * @param string $oldgroup <paramgroup> id of the section referenced by
117
     * @param string $oldgroup <paramgroup> id of the section referenced by
118
     *                         <conditiontype>
118
     *                         <conditiontype>
119
     * @param string $param name of the <param> from the older section referenced
119
     * @param string $param name of the <param> from the older section referenced
120
     *                      by <contitiontype>
120
     *                      by <contitiontype>
121
     * @param string $value value to match of the parameter
121
     * @param string $value value to match of the parameter
122
     * @param string $conditiontype one of '=', '!=', 'preg_match'
122
     * @param string $conditiontype one of '=', '!=', 'preg_match'
123
     * @param array|false $params array of getParam() calls, or false for no params
123
     * @param array|false $params array of getParam() calls, or false for no params
124
     * @param string|false $instructions
124
     * @param string|false $instructions
125
     */
125
     */
126
    function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
126
    function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
127
                                   $params = false, $instructions = false)
127
                                   $params = false, $instructions = false)
128
    {
128
    {
129
        if ($params && isset($params[0]) && !isset($params[1])) {
129
        if ($params && isset($params[0]) && !isset($params[1])) {
130
            $params = $params[0];
130
            $params = $params[0];
131
        }
131
        }
132
        $stuff =
132
        $stuff =
133
            array(
133
            array(
134
                $this->_pkg->getTasksNs() . ':id' => $id,
134
                $this->_pkg->getTasksNs() . ':id' => $id,
135
            );
135
            );
136
        if ($instructions) {
136
        if ($instructions) {
137
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
137
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
138
        }
138
        }
139
        $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
139
        $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
140
        $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
140
        $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
141
        $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
141
        $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
142
        if ($params) {
142
        if ($params) {
143
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
143
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
144
        }
144
        }
145
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
145
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
146
    }
146
    }
147
147
148
    function getXml()
148
    function getXml()
149
    {
149
    {
150
        return $this->_params;
150
        return $this->_params;
151
    }
151
    }
152
152
153
    /**
153
    /**
154
     * Use to set up a param tag for use in creating a paramgroup
154
     * Use to set up a param tag for use in creating a paramgroup
155
     * @static
155
     * @static
156
     */
156
     */
157
    function getParam($name, $prompt, $type = 'string', $default = null)
157
    function getParam($name, $prompt, $type = 'string', $default = null)
158
    {
158
    {
159
        if ($default !== null) {
159
        if ($default !== null) {
160
            return
160
            return
161
            array(
161
            array(
162
                $this->_pkg->getTasksNs() . ':name' => $name,
162
                $this->_pkg->getTasksNs() . ':name' => $name,
163
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
163
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
164
                $this->_pkg->getTasksNs() . ':type' => $type,
164
                $this->_pkg->getTasksNs() . ':type' => $type,
165
                $this->_pkg->getTasksNs() . ':default' => $default
165
                $this->_pkg->getTasksNs() . ':default' => $default
166
            );
166
            );
167
        }
167
        }
168
        return
168
        return
169
            array(
169
            array(
170
                $this->_pkg->getTasksNs() . ':name' => $name,
170
                $this->_pkg->getTasksNs() . ':name' => $name,
171
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
171
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
172
                $this->_pkg->getTasksNs() . ':type' => $type,
172
                $this->_pkg->getTasksNs() . ':type' => $type,
173
            );
173
            );
174
    }
174
    }
175
}
175
}
176
?>
176
?>