Subversion Repositories Applications.gtt

Rev

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

Rev 94 Rev 187
Line 2... Line 2...
2
/**
2
/**
3
 * <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
-
 
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.11 2006/01/06 04:47:37 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.0a10
13
 * @since     File available since Release 1.4.0a10
21
 */
14
 */
22
/**
15
/**
23
 * Base class
16
 * Base class
24
 */
17
 */
25
require_once 'PEAR/Task/Postinstallscript.php';
18
require_once 'PEAR/Task/Postinstallscript.php';
26
/**
19
/**
27
 * Abstracts the postinstallscript file task xml.
20
 * Abstracts the postinstallscript file task xml.
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: 1.5.1
26
 * @version    Release: 1.10.1
34
 * @link       http://pear.php.net/package/PEAR
27
 * @link       http://pear.php.net/package/PEAR
35
 * @since      Class available since Release 1.4.0a10
28
 * @since      Class available since Release 1.4.0a10
36
 */
29
 */
37
class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
30
class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
38
{
31
{
39
    /**
32
    /**
40
     * parent package file object
33
     * parent package file object
41
     *
34
     *
42
     * @var PEAR_PackageFile_v2_rw
35
     * @var PEAR_PackageFile_v2_rw
43
     */
36
     */
44
    var $_pkg;
37
    public $_pkg;
45
    /**
38
    /**
46
     * Enter description here...
39
     * Enter description here...
47
     *
40
     *
48
     * @param PEAR_PackageFile_v2_rw $pkg
41
     * @param PEAR_PackageFile_v2_rw $pkg     Package
49
     * @param PEAR_Config $config
42
     * @param PEAR_Config            $config  Config
50
     * @param PEAR_Frontend $logger
43
     * @param PEAR_Frontend          $logger  Logger
51
     * @param array $fileXml
44
     * @param array                  $fileXml XML
-
 
45
     *
52
     * @return PEAR_Task_Postinstallscript_rw
46
     * @return PEAR_Task_Postinstallscript_rw
53
     */
47
     */
54
    function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
48
    function __construct(&$pkg, &$config, &$logger, $fileXml)
55
    {
49
    {
56
        parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
50
        parent::__construct($config, $logger, PEAR_TASK_PACKAGE);
57
        $this->_contents = $fileXml;
51
        $this->_contents = $fileXml;
58
        $this->_pkg = &$pkg;
52
        $this->_pkg = &$pkg;
59
        $this->_params = array();
53
        $this->_params = array();
60
    }
54
    }
Line 61... Line 55...
61
 
55
 
62
    function validate()
56
    public function validate()
63
    {
57
    {
64
        return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
58
        return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
Line 65... Line 59...
65
    }
59
    }
66
 
60
 
67
    function getName()
61
    public function getName()
68
    {
62
    {
Line 69... Line 63...
69
        return 'postinstallscript';
63
        return 'postinstallscript';
Line 74... Line 68...
74
     *
68
     *
75
     * Order is significant, so call this method in the same
69
     * Order is significant, so call this method in the same
76
     * sequence the users should see the paramgroups.  The $params
70
     * sequence the users should see the paramgroups.  The $params
77
     * parameter should either be the result of a call to {@link getParam()}
71
     * parameter should either be the result of a call to {@link getParam()}
78
     * or an array of calls to getParam().
72
     * or an array of calls to getParam().
79
     * 
73
     *
80
     * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
74
     * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
81
     * a <conditiontype> tag
75
     * a <conditiontype> tag
-
 
76
     *
82
     * @param string $id <paramgroup> id as seen by the script
77
     * @param string       $id           <paramgroup> id as seen by the script
83
     * @param array|false $params array of getParam() calls, or false for no params
78
     * @param array|false  $params       array of getParam() calls, or false for no params
84
     * @param string|false $instructions
79
     * @param string|false $instructions
85
     */
80
     */
86
    function addParamGroup($id, $params = false, $instructions = false)
81
    public function addParamGroup($id, $params = false, $instructions = false)
87
    {
82
    {
88
        if ($params && isset($params[0]) && !isset($params[1])) {
83
        if ($params && isset($params[0]) && !isset($params[1])) {
89
            $params = $params[0];
84
            $params = $params[0];
90
        }
85
        }
91
        $stuff =
86
        $stuff =
92
            array(
87
            array(
93
                $this->_pkg->getTasksNs() . ':id' => $id,
88
                $this->_pkg->getTasksNs().':id' => $id,
94
            );
89
            );
95
        if ($instructions) {
90
        if ($instructions) {
96
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
91
            $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions;
97
        }
92
        }
98
        if ($params) {
93
        if ($params) {
99
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
94
            $stuff[$this->_pkg->getTasksNs().':param'] = $params;
100
        }
95
        }
101
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
96
        $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff;
102
    }
97
    }
Line 103... Line 98...
103
 
98
 
104
    /**
99
    /**
105
     * add a complex <paramgroup> to the post-install script with conditions
100
     * Add a complex <paramgroup> to the post-install script with conditions
106
     *
101
     *
107
     * This inserts a <paramgroup> with
102
     * This inserts a <paramgroup> with
108
     *
103
     *
109
     * Order is significant, so call this method in the same
104
     * Order is significant, so call this method in the same
110
     * sequence the users should see the paramgroups.  The $params
105
     * sequence the users should see the paramgroups.  The $params
111
     * parameter should either be the result of a call to {@link getParam()}
106
     * parameter should either be the result of a call to {@link getParam()}
112
     * or an array of calls to getParam().
107
     * or an array of calls to getParam().
113
     * 
108
     *
114
     * Use {@link addParamGroup()} to add a simple <paramgroup>
109
     * Use {@link addParamGroup()} to add a simple <paramgroup>
115
     *
110
     *
116
     * @param string $id <paramgroup> id as seen by the script
111
     * @param string       $id            <paramgroup> id as seen by the script
117
     * @param string $oldgroup <paramgroup> id of the section referenced by
112
     * @param string       $oldgroup      <paramgroup> id of the section referenced by
118
     *                         <conditiontype>
113
     *                                    <conditiontype>
119
     * @param string $param name of the <param> from the older section referenced
114
     * @param string       $param         name of the <param> from the older section referenced
120
     *                      by <contitiontype>
115
     *                                    by <contitiontype>
121
     * @param string $value value to match of the parameter
116
     * @param string       $value         value to match of the parameter
122
     * @param string $conditiontype one of '=', '!=', 'preg_match'
117
     * @param string       $conditiontype one of '=', '!=', 'preg_match'
123
     * @param array|false $params array of getParam() calls, or false for no params
118
     * @param array|false  $params        array of getParam() calls, or false for no params
124
     * @param string|false $instructions
119
     * @param string|false $instructions
125
     */
120
     */
-
 
121
    public function addConditionTypeGroup($id,
-
 
122
        $oldgroup,
-
 
123
        $param,
-
 
124
        $value,
-
 
125
        $conditiontype = '=',
126
    function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
126
        $params = false,
127
                                   $params = false, $instructions = false)
127
        $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
        }
-
 
132
        $stuff =
131
        }
133
            array(
132
        $stuff = array(
134
                $this->_pkg->getTasksNs() . ':id' => $id,
133
            $this->_pkg->getTasksNs().':id' => $id,
135
            );
134
        );
136
        if ($instructions) {
135
        if ($instructions) {
137
            $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
136
            $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions;
138
        }
137
        }
139
        $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
138
        $stuff[$this->_pkg->getTasksNs().':name'] = $oldgroup.'::'.$param;
140
        $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
139
        $stuff[$this->_pkg->getTasksNs().':conditiontype'] = $conditiontype;
141
        $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
140
        $stuff[$this->_pkg->getTasksNs().':value'] = $value;
142
        if ($params) {
141
        if ($params) {
143
            $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
142
            $stuff[$this->_pkg->getTasksNs().':param'] = $params;
144
        }
143
        }
145
        $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
144
        $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff;
Line 146... Line 145...
146
    }
145
    }
147
 
146
 
148
    function getXml()
147
    public function getXml()
149
    {
148
    {
Line 150... Line 149...
150
        return $this->_params;
149
        return $this->_params;
151
    }
150
    }
-
 
151
 
-
 
152
    /**
-
 
153
     * Use to set up a param tag for use in creating a paramgroup
-
 
154
     *
-
 
155
     * @param mixed  $name    Name of parameter
-
 
156
     * @param mixed  $prompt  Prompt
152
 
157
     * @param string $type    Type, defaults to 'string'
153
    /**
158
     * @param mixed  $default Default value
-
 
159
     *
154
     * Use to set up a param tag for use in creating a paramgroup
160
     * @return array
155
     * @static
161
     */
156
     */
162
    public static function getParam(
157
    function getParam($name, $prompt, $type = 'string', $default = null)
163
        $name, $prompt, $type = 'string', $default = null
158
    {
164
    ) {
159
        if ($default !== null) {
165
        if ($default !== null) {
160
            return 
166
            return
161
            array(
167
            array(
162
                $this->_pkg->getTasksNs() . ':name' => $name,
168
                $this->_pkg->getTasksNs().':name' => $name,
163
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
169
                $this->_pkg->getTasksNs().':prompt' => $prompt,
164
                $this->_pkg->getTasksNs() . ':type' => $type,
170
                $this->_pkg->getTasksNs().':type' => $type,
-
 
171
                $this->_pkg->getTasksNs().':default' => $default,
165
                $this->_pkg->getTasksNs() . ':default' => $default
172
            );
166
            );
173
        }
167
        }
174
 
168
        return
175
        return
169
            array(
176
            array(
170
                $this->_pkg->getTasksNs() . ':name' => $name,
177
                $this->_pkg->getTasksNs().':name' => $name,
171
                $this->_pkg->getTasksNs() . ':prompt' => $prompt,
178
                $this->_pkg->getTasksNs().':prompt' => $prompt,
172
                $this->_pkg->getTasksNs() . ':type' => $type,
179
                $this->_pkg->getTasksNs().':type' => $type,
173
            );
-
 
174
    }
180
            );