3 * <tasks:postinstallscript> - read/write version
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.
15 * @author Greg Beaver <cellog@php.net>
16 * @copyright 1997-2006 The PHP Group
17 * @license http://www.php.net/license/3_0.txt PHP License 3.0
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
20 * @since File available since Release 1.4.0a10
25 require_once 'PEAR/Task/Postinstallscript.php';
27 * Abstracts the postinstallscript file task xml.
30 * @author Greg Beaver <cellog@php.net>
31 * @copyright 1997-2006 The PHP Group
32 * @license http://www.php.net/license/3_0.txt PHP License 3.0
33 * @version Release: 1.4.11
34 * @link http://pear.php.net/package/PEAR
35 * @since Class available since Release 1.4.0a10
37 class PEAR_Task_Postinstallscript_rw
extends PEAR_Task_Postinstallscript
40 * parent package file object
42 * @var PEAR_PackageFile_v2_rw
46 * Enter description here...
48 * @param PEAR_PackageFile_v2_rw $pkg
49 * @param PEAR_Config $config
50 * @param PEAR_Frontend $logger
51 * @param array $fileXml
52 * @return PEAR_Task_Postinstallscript_rw
54 function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
56 parent
::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE
);
57 $this->_contents
= $fileXml;
59 $this->_params
= array();
64 return $this->validateXml($this->_pkg
, $this->_params
, $this->config
, $this->_contents
);
69 return 'postinstallscript';
73 * add a simple <paramgroup> to the post-install script
75 * Order is significant, so call this method in the same
76 * sequence the users should see the paramgroups. The $params
77 * parameter should either be the result of a call to {@link getParam()}
78 * or an array of calls to getParam().
80 * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
81 * a <conditiontype> tag
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
84 * @param string|false $instructions
86 function addParamGroup($id, $params = false, $instructions = false)
88 if ($params && isset($params[0]) && !isset($params[1])) {
93 $this->_pkg
->getTasksNs() . ':id' => $id,
96 $stuff[$this->_pkg
->getTasksNs() . ':instructions'] = $instructions;
99 $stuff[$this->_pkg
->getTasksNs() . ':param'] = $params;
101 $this->_params
[$this->_pkg
->getTasksNs() . ':paramgroup'][] = $stuff;
105 * add a complex <paramgroup> to the post-install script with conditions
107 * This inserts a <paramgroup> with
109 * Order is significant, so call this method in the same
110 * sequence the users should see the paramgroups. The $params
111 * parameter should either be the result of a call to {@link getParam()}
112 * or an array of calls to getParam().
114 * Use {@link addParamGroup()} to add a simple <paramgroup>
116 * @param string $id <paramgroup> id as seen by the script
117 * @param string $oldgroup <paramgroup> id of the section referenced by
119 * @param string $param name of the <param> from the older section referenced
121 * @param string $value value to match of the parameter
122 * @param string $conditiontype one of '=', '!=', 'preg_match'
123 * @param array|false $params array of getParam() calls, or false for no params
124 * @param string|false $instructions
126 function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
127 $params = false, $instructions = false)
129 if ($params && isset($params[0]) && !isset($params[1])) {
130 $params = $params[0];
134 $this->_pkg
->getTasksNs() . ':id' => $id,
137 $stuff[$this->_pkg
->getTasksNs() . ':instructions'] = $instructions;
139 $stuff[$this->_pkg
->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
140 $stuff[$this->_pkg
->getTasksNs() . ':conditiontype'] = $conditiontype;
141 $stuff[$this->_pkg
->getTasksNs() . ':value'] = $value;
143 $stuff[$this->_pkg
->getTasksNs() . ':param'] = $params;
145 $this->_params
[$this->_pkg
->getTasksNs() . ':paramgroup'][] = $stuff;
150 return $this->_params
;
154 * Use to set up a param tag for use in creating a paramgroup
157 function getParam($name, $prompt, $type = 'string', $default = null)
159 if ($default !== null) {
162 $this->_pkg
->getTasksNs() . ':name' => $name,
163 $this->_pkg
->getTasksNs() . ':prompt' => $prompt,
164 $this->_pkg
->getTasksNs() . ':type' => $type,
165 $this->_pkg
->getTasksNs() . ':default' => $default
170 $this->_pkg
->getTasksNs() . ':name' => $name,
171 $this->_pkg
->getTasksNs() . ':prompt' => $prompt,
172 $this->_pkg
->getTasksNs() . ':type' => $type,