3 * <tasks:postinstallscript> - read/write version
9 * @author Greg Beaver <cellog@php.net>
10 * @copyright 1997-2009 The Authors
11 * @license http://opensource.org/licenses/bsd-license.php New BSD License
12 * @version CVS: $Id: rw.php 313023 2011-07-06 19:17:11Z dufuz $
13 * @link http://pear.php.net/package/PEAR
14 * @since File available since Release 1.4.0a10
19 require_once 'PEAR/Task/Postinstallscript.php';
21 * Abstracts the postinstallscript file task xml.
24 * @author Greg Beaver <cellog@php.net>
25 * @copyright 1997-2009 The Authors
26 * @license http://opensource.org/licenses/bsd-license.php New BSD License
27 * @version Release: 1.9.4
28 * @link http://pear.php.net/package/PEAR
29 * @since Class available since Release 1.4.0a10
31 class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
34 * parent package file object
36 * @var PEAR_PackageFile_v2_rw
40 * Enter description here...
42 * @param PEAR_PackageFile_v2_rw $pkg
43 * @param PEAR_Config $config
44 * @param PEAR_Frontend $logger
45 * @param array $fileXml
46 * @return PEAR_Task_Postinstallscript_rw
48 function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
50 parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
51 $this->_contents = $fileXml;
53 $this->_params = array();
58 return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
63 return 'postinstallscript';
67 * add a simple <paramgroup> to the post-install script
69 * Order is significant, so call this method in the same
70 * sequence the users should see the paramgroups. The $params
71 * parameter should either be the result of a call to {@link getParam()}
72 * or an array of calls to getParam().
74 * Use {@link addConditionTypeGroup()} to add a <paramgroup> containing
75 * a <conditiontype> tag
76 * @param string $id <paramgroup> id as seen by the script
77 * @param array|false $params array of getParam() calls, or false for no params
78 * @param string|false $instructions
80 function addParamGroup($id, $params = false, $instructions = false)
82 if ($params && isset($params[0]) && !isset($params[1])) {
87 $this->_pkg->getTasksNs() . ':id' => $id,
90 $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
93 $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
95 $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
99 * add a complex <paramgroup> to the post-install script with conditions
101 * This inserts a <paramgroup> with
103 * Order is significant, so call this method in the same
104 * sequence the users should see the paramgroups. The $params
105 * parameter should either be the result of a call to {@link getParam()}
106 * or an array of calls to getParam().
108 * Use {@link addParamGroup()} to add a simple <paramgroup>
110 * @param string $id <paramgroup> id as seen by the script
111 * @param string $oldgroup <paramgroup> id of the section referenced by
113 * @param string $param name of the <param> from the older section referenced
115 * @param string $value value to match of the parameter
116 * @param string $conditiontype one of '=', '!=', 'preg_match'
117 * @param array|false $params array of getParam() calls, or false for no params
118 * @param string|false $instructions
120 function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
121 $params = false, $instructions = false)
123 if ($params && isset($params[0]) && !isset($params[1])) {
124 $params = $params[0];
127 $this->_pkg->getTasksNs() . ':id' => $id,
130 $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
132 $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
133 $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
134 $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
136 $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
138 $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
143 return $this->_params;
147 * Use to set up a param tag for use in creating a paramgroup
150 function getParam($name, $prompt, $type = 'string', $default = null)
152 if ($default !== null) {
155 $this->_pkg->getTasksNs() . ':name' => $name,
156 $this->_pkg->getTasksNs() . ':prompt' => $prompt,
157 $this->_pkg->getTasksNs() . ':type' => $type,
158 $this->_pkg->getTasksNs() . ':default' => $default
163 $this->_pkg->getTasksNs() . ':name' => $name,
164 $this->_pkg->getTasksNs() . ':prompt' => $prompt,
165 $this->_pkg->getTasksNs() . ':type' => $type,