/trunk/bibliotheque/pear/PEAR/Task/Unixeol.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Unixeol.php,v 1.8 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
/** |
* Base class |
28,30 → 21,31 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_Task_Unixeol extends PEAR_Task_Common |
{ |
var $type = 'simple'; |
var $phase = PEAR_TASK_PACKAGE; |
var $_replacements; |
public $type = 'simple'; |
public $phase = PEAR_TASK_PACKAGE; |
public $_replacements; |
/** |
* Validate the raw xml at parsing-time. |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
* @static |
* |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
*/ |
function validateXml($pkg, $xml, &$config, $fileXml) |
public static function validateXml($pkg, $xml, $config, $fileXml) |
{ |
if ($xml != '') { |
return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); |
} |
return true; |
} |
59,8 → 53,9 |
* Initialize a task instance with the parameters |
* @param array raw, parsed xml |
* @param unused |
* @param unused |
*/ |
function init($xml, $attribs) |
public function init($xml, $attribs, $lastVersion = null) |
{ |
} |
68,16 → 63,17 |
* Replace all line endings with line endings customized for the current OS |
* |
* See validateXml() source for the complete list of allowed fields |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError), otherwise return the new contents |
* (use $this->throwError), otherwise return the new contents |
*/ |
function startSession($pkg, $contents, $dest) |
public function startSession($pkg, $contents, $dest) |
{ |
$this->logger->log(3, "replacing all line endings with \\n in $dest"); |
return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Windowseol/rw.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: rw.php,v 1.4 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
*/ |
/** |
* Base class |
25,38 → 18,39 |
require_once 'PEAR/Task/Windowseol.php'; |
/** |
* Abstracts the windowseol task xml. |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a10 |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a10 |
*/ |
class PEAR_Task_Windowseol_rw extends PEAR_Task_Windowseol |
{ |
function PEAR_Task_Windowseol_rw(&$pkg, &$config, &$logger, $fileXml) |
function __construct(&$pkg, &$config, &$logger, $fileXml) |
{ |
parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE); |
parent::__construct($config, $logger, PEAR_TASK_PACKAGE); |
$this->_contents = $fileXml; |
$this->_pkg = &$pkg; |
$this->_params = array(); |
} |
function validate() |
public function validate() |
{ |
return true; |
} |
function getName() |
public function getName() |
{ |
return 'windowseol'; |
} |
function getXml() |
public function getXml() |
{ |
return ''; |
} |
} |
?> |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Replace/rw.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: rw.php,v 1.3 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
*/ |
/** |
* Base class |
28,40 → 21,39 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a10 |
*/ |
class PEAR_Task_Replace_rw extends PEAR_Task_Replace |
{ |
function PEAR_Task_Replace_rw(&$pkg, &$config, &$logger, $fileXml) |
public function __construct(&$pkg, &$config, &$logger, $fileXml) |
{ |
parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE); |
parent::__construct($config, $logger, PEAR_TASK_PACKAGE); |
$this->_contents = $fileXml; |
$this->_pkg = &$pkg; |
$this->_params = array(); |
} |
function validate() |
public function validate() |
{ |
return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents); |
} |
function setInfo($from, $to, $type) |
public function setInfo($from, $to, $type) |
{ |
$this->_params = array('attribs' => array('from' => $from, 'to' => $to, 'type' => $type)); |
} |
function getName() |
public function getName() |
{ |
return 'replace'; |
} |
function getXml() |
public function getXml() |
{ |
return $this->_params; |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Common.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Common.php,v 1.16 2006/11/12 05:02:41 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
/**#@+ |
* Error codes for task validation routines |
48,14 → 41,15 |
* This will first replace any instance of @data-dir@ in the test.php file |
* with the path to the current data directory. Then, it will include the |
* test.php file and run the script it contains to configure the package post-installation. |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
* @abstract |
*/ |
class PEAR_Task_Common |
68,34 → 62,35 |
* changes directly to disk |
* |
* Child task classes must override this property. |
* |
* @access protected |
*/ |
var $type = 'simple'; |
protected $type = 'simple'; |
/** |
* Determines which install phase this task is executed under |
*/ |
var $phase = PEAR_TASK_INSTALL; |
public $phase = PEAR_TASK_INSTALL; |
/** |
* @access protected |
*/ |
var $config; |
protected $config; |
/** |
* @access protected |
*/ |
var $registry; |
protected $registry; |
/** |
* @access protected |
*/ |
var $logger; |
public $logger; |
/** |
* @access protected |
*/ |
var $installphase; |
protected $installphase; |
/** |
* @param PEAR_Config |
* @param PEAR_Common |
*/ |
function PEAR_Task_Common(&$config, &$logger, $phase) |
function __construct(&$config, &$logger, $phase) |
{ |
$this->config = &$config; |
$this->registry = &$config->getRegistry(); |
108,86 → 103,90 |
/** |
* Validate the basic contents of a task tag. |
* |
* @param PEAR_PackageFile_v2 |
* @param array |
* @param PEAR_Config |
* @param array the entire parsed <file> tag |
* |
* @return true|array On error, return an array in format: |
* array(PEAR_TASK_ERROR_???[, param1][, param2][, ...]) |
* array(PEAR_TASK_ERROR_???[, param1][, param2][, ...]) |
* |
* For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in |
* For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and an array |
* of legal values in |
* @static |
* For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in |
* For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and |
* an array of legal values in |
* |
* @abstract |
*/ |
function validateXml($pkg, $xml, &$config, $fileXml) |
public static function validateXml($pkg, $xml, $config, $fileXml) |
{ |
} |
/** |
* Initialize a task instance with the parameters |
* @param array raw, parsed xml |
* @param array attributes from the <file> tag containing this task |
* @param string|null last installed version of this package |
* |
* @param array raw, parsed xml |
* @param array attributes from the <file> tag containing this task |
* @param string|null last installed version of this package |
* @abstract |
*/ |
function init($xml, $fileAttributes, $lastVersion) |
public function init($xml, $fileAttributes, $lastVersion) |
{ |
} |
/** |
* Begin a task processing session. All multiple tasks will be processed after each file |
* has been successfully installed, all simple tasks should perform their task here and |
* return any errors using the custom throwError() method to allow forward compatibility |
* Begin a task processing session. All multiple tasks will be processed |
* after each file has been successfully installed, all simple tasks should |
* perform their task here and return any errors using the custom |
* throwError() method to allow forward compatibility |
* |
* This method MUST NOT write out any changes to disk |
* @param PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError), otherwise return the new contents |
* |
* @param PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError), otherwise return the new contents |
* @abstract |
*/ |
function startSession($pkg, $contents, $dest) |
public function startSession($pkg, $contents, $dest) |
{ |
} |
/** |
* This method is used to process each of the tasks for a particular multiple class |
* type. Simple tasks need not implement this method. |
* @param array an array of tasks |
* @access protected |
* @static |
* @abstract |
* This method is used to process each of the tasks for a particular |
* multiple class type. Simple tasks need not implement this method. |
* |
* @param array an array of tasks |
* @access protected |
*/ |
function run($tasks) |
public static function run($tasks) |
{ |
} |
/** |
* @static |
* @final |
*/ |
function hasPostinstallTasks() |
public static function hasPostinstallTasks() |
{ |
return isset($GLOBALS['_PEAR_TASK_POSTINSTANCES']); |
} |
/** |
* @static |
* @final |
*/ |
function runPostinstallTasks() |
{ |
foreach ($GLOBALS['_PEAR_TASK_POSTINSTANCES'] as $class => $tasks) { |
$err = call_user_func(array($class, 'run'), |
$GLOBALS['_PEAR_TASK_POSTINSTANCES'][$class]); |
if ($err) { |
return PEAR_Task_Common::throwError($err); |
} |
} |
unset($GLOBALS['_PEAR_TASK_POSTINSTANCES']); |
/** |
* @final |
*/ |
public static function runPostinstallTasks() |
{ |
foreach ($GLOBALS['_PEAR_TASK_POSTINSTANCES'] as $class => $tasks) { |
$err = call_user_func( |
array($class, 'run'), |
$GLOBALS['_PEAR_TASK_POSTINSTANCES'][$class] |
); |
if ($err) { |
return PEAR_Task_Common::throwError($err); |
} |
} |
unset($GLOBALS['_PEAR_TASK_POSTINSTANCES']); |
} |
/** |
194,15 → 193,15 |
* Determines whether a role is a script |
* @return bool |
*/ |
function isScript() |
public function isScript() |
{ |
return $this->type == 'script'; |
return $this->type == 'script'; |
} |
function throwError($msg, $code = -1) |
public function throwError($msg, $code = -1) |
{ |
include_once 'PEAR.php'; |
return PEAR::raiseError($msg, $code); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Windowseol.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Windowseol.php,v 1.7 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
/** |
* Base class |
25,33 → 18,35 |
require_once 'PEAR/Task/Common.php'; |
/** |
* Implements the windows line endsings file task. |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_Task_Windowseol extends PEAR_Task_Common |
{ |
var $type = 'simple'; |
var $phase = PEAR_TASK_PACKAGE; |
var $_replacements; |
public $type = 'simple'; |
public $phase = PEAR_TASK_PACKAGE; |
public $_replacements; |
/** |
* Validate the raw xml at parsing-time. |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
* @static |
* |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
*/ |
function validateXml($pkg, $xml, &$config, $fileXml) |
public static function validateXml($pkg, $xml, $config, $fileXml) |
{ |
if ($xml != '') { |
return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); |
} |
return true; |
} |
59,8 → 54,9 |
* Initialize a task instance with the parameters |
* @param array raw, parsed xml |
* @param unused |
* @param unused |
*/ |
function init($xml, $attribs) |
public function init($xml, $attribs, $lastVersion = null) |
{ |
} |
68,16 → 64,17 |
* Replace all line endings with windows line endings |
* |
* See validateXml() source for the complete list of allowed fields |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError), otherwise return the new contents |
* (use $this->throwError), otherwise return the new contents |
*/ |
function startSession($pkg, $contents, $dest) |
public function startSession($pkg, $contents, $dest) |
{ |
$this->logger->log(3, "replacing all line endings with \\r\\n in $dest"); |
return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Postinstallscript/rw.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: rw.php,v 1.11 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
*/ |
/** |
* Base class |
28,9 → 21,9 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a10 |
*/ |
41,30 → 34,31 |
* |
* @var PEAR_PackageFile_v2_rw |
*/ |
var $_pkg; |
public $_pkg; |
/** |
* Enter description here... |
* |
* @param PEAR_PackageFile_v2_rw $pkg |
* @param PEAR_Config $config |
* @param PEAR_Frontend $logger |
* @param array $fileXml |
* @param PEAR_PackageFile_v2_rw $pkg Package |
* @param PEAR_Config $config Config |
* @param PEAR_Frontend $logger Logger |
* @param array $fileXml XML |
* |
* @return PEAR_Task_Postinstallscript_rw |
*/ |
function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml) |
function __construct(&$pkg, &$config, &$logger, $fileXml) |
{ |
parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE); |
parent::__construct($config, $logger, PEAR_TASK_PACKAGE); |
$this->_contents = $fileXml; |
$this->_pkg = &$pkg; |
$this->_params = array(); |
} |
function validate() |
public function validate() |
{ |
return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents); |
} |
function getName() |
public function getName() |
{ |
return 'postinstallscript'; |
} |
76,14 → 70,15 |
* sequence the users should see the paramgroups. The $params |
* parameter should either be the result of a call to {@link getParam()} |
* or an array of calls to getParam(). |
* |
* |
* Use {@link addConditionTypeGroup()} to add a <paramgroup> containing |
* a <conditiontype> tag |
* @param string $id <paramgroup> id as seen by the script |
* @param array|false $params array of getParam() calls, or false for no params |
* |
* @param string $id <paramgroup> id as seen by the script |
* @param array|false $params array of getParam() calls, or false for no params |
* @param string|false $instructions |
*/ |
function addParamGroup($id, $params = false, $instructions = false) |
public function addParamGroup($id, $params = false, $instructions = false) |
{ |
if ($params && isset($params[0]) && !isset($params[1])) { |
$params = $params[0]; |
90,19 → 85,19 |
} |
$stuff = |
array( |
$this->_pkg->getTasksNs() . ':id' => $id, |
$this->_pkg->getTasksNs().':id' => $id, |
); |
if ($instructions) { |
$stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions; |
$stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions; |
} |
if ($params) { |
$stuff[$this->_pkg->getTasksNs() . ':param'] = $params; |
$stuff[$this->_pkg->getTasksNs().':param'] = $params; |
} |
$this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff; |
$this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff; |
} |
/** |
* add a complex <paramgroup> to the post-install script with conditions |
* Add a complex <paramgroup> to the post-install script with conditions |
* |
* This inserts a <paramgroup> with |
* |
110,42 → 105,46 |
* sequence the users should see the paramgroups. The $params |
* parameter should either be the result of a call to {@link getParam()} |
* or an array of calls to getParam(). |
* |
* |
* Use {@link addParamGroup()} to add a simple <paramgroup> |
* |
* @param string $id <paramgroup> id as seen by the script |
* @param string $oldgroup <paramgroup> id of the section referenced by |
* <conditiontype> |
* @param string $param name of the <param> from the older section referenced |
* by <contitiontype> |
* @param string $value value to match of the parameter |
* @param string $conditiontype one of '=', '!=', 'preg_match' |
* @param array|false $params array of getParam() calls, or false for no params |
* @param string $id <paramgroup> id as seen by the script |
* @param string $oldgroup <paramgroup> id of the section referenced by |
* <conditiontype> |
* @param string $param name of the <param> from the older section referenced |
* by <contitiontype> |
* @param string $value value to match of the parameter |
* @param string $conditiontype one of '=', '!=', 'preg_match' |
* @param array|false $params array of getParam() calls, or false for no params |
* @param string|false $instructions |
*/ |
function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=', |
$params = false, $instructions = false) |
{ |
public function addConditionTypeGroup($id, |
$oldgroup, |
$param, |
$value, |
$conditiontype = '=', |
$params = false, |
$instructions = false |
) { |
if ($params && isset($params[0]) && !isset($params[1])) { |
$params = $params[0]; |
} |
$stuff = |
array( |
$this->_pkg->getTasksNs() . ':id' => $id, |
); |
$stuff = array( |
$this->_pkg->getTasksNs().':id' => $id, |
); |
if ($instructions) { |
$stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions; |
$stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions; |
} |
$stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param; |
$stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype; |
$stuff[$this->_pkg->getTasksNs() . ':value'] = $value; |
$stuff[$this->_pkg->getTasksNs().':name'] = $oldgroup.'::'.$param; |
$stuff[$this->_pkg->getTasksNs().':conditiontype'] = $conditiontype; |
$stuff[$this->_pkg->getTasksNs().':value'] = $value; |
if ($params) { |
$stuff[$this->_pkg->getTasksNs() . ':param'] = $params; |
$stuff[$this->_pkg->getTasksNs().':param'] = $params; |
} |
$this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff; |
$this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff; |
} |
function getXml() |
public function getXml() |
{ |
return $this->_params; |
} |
152,25 → 151,32 |
/** |
* Use to set up a param tag for use in creating a paramgroup |
* @static |
* |
* @param mixed $name Name of parameter |
* @param mixed $prompt Prompt |
* @param string $type Type, defaults to 'string' |
* @param mixed $default Default value |
* |
* @return array |
*/ |
function getParam($name, $prompt, $type = 'string', $default = null) |
{ |
public static function getParam( |
$name, $prompt, $type = 'string', $default = null |
) { |
if ($default !== null) { |
return |
return |
array( |
$this->_pkg->getTasksNs() . ':name' => $name, |
$this->_pkg->getTasksNs() . ':prompt' => $prompt, |
$this->_pkg->getTasksNs() . ':type' => $type, |
$this->_pkg->getTasksNs() . ':default' => $default |
$this->_pkg->getTasksNs().':name' => $name, |
$this->_pkg->getTasksNs().':prompt' => $prompt, |
$this->_pkg->getTasksNs().':type' => $type, |
$this->_pkg->getTasksNs().':default' => $default, |
); |
} |
return |
array( |
$this->_pkg->getTasksNs() . ':name' => $name, |
$this->_pkg->getTasksNs() . ':prompt' => $prompt, |
$this->_pkg->getTasksNs() . ':type' => $type, |
$this->_pkg->getTasksNs().':name' => $name, |
$this->_pkg->getTasksNs().':prompt' => $prompt, |
$this->_pkg->getTasksNs().':type' => $type, |
); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Replace.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Replace.php,v 1.15 2006/03/02 18:14:13 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
/** |
* Base class |
28,26 → 21,26 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_Task_Replace extends PEAR_Task_Common |
{ |
var $type = 'simple'; |
var $phase = PEAR_TASK_PACKAGEANDINSTALL; |
var $_replacements; |
public $type = 'simple'; |
public $phase = PEAR_TASK_PACKAGEANDINSTALL; |
public $_replacements; |
/** |
* Validate the raw xml at parsing-time. |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
* @static |
* |
* @param PEAR_PackageFile_v2 |
* @param array raw, parsed xml |
* @param PEAR_Config |
*/ |
function validateXml($pkg, $xml, &$config, $fileXml) |
public static function validateXml($pkg, $xml, $config, $fileXml) |
{ |
if (!isset($xml['attribs'])) { |
return array(PEAR_TASK_ERROR_NOATTRIBS); |
64,7 → 57,7 |
if ($xml['attribs']['type'] == 'pear-config') { |
if (!in_array($xml['attribs']['to'], $config->getKeys())) { |
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], |
$config->getKeys()); |
$config->getKeys(), ); |
} |
} elseif ($xml['attribs']['type'] == 'php-const') { |
if (defined($xml['attribs']['to'])) { |
71,14 → 64,16 |
return true; |
} else { |
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], |
array('valid PHP constant')); |
array('valid PHP constant'), ); |
} |
} elseif ($xml['attribs']['type'] == 'package-info') { |
if (in_array($xml['attribs']['to'], |
if (in_array( |
$xml['attribs']['to'], |
array('name', 'summary', 'channel', 'notes', 'extends', 'description', |
'release_notes', 'license', 'release-license', 'license-uri', |
'version', 'api-version', 'state', 'api-state', 'release_date', |
'date', 'time'))) { |
'date', 'time', ) |
)) { |
return true; |
} else { |
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], |
85,12 → 80,13 |
array('name', 'summary', 'channel', 'notes', 'extends', 'description', |
'release_notes', 'license', 'release-license', 'license-uri', |
'version', 'api-version', 'state', 'api-state', 'release_date', |
'date', 'time')); |
'date', 'time', ), ); |
} |
} else { |
return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'type', $xml['attribs']['type'], |
array('pear-config', 'package-info', 'php-const')); |
array('pear-config', 'package-info', 'php-const'), ); |
} |
return true; |
} |
98,8 → 94,9 |
* Initialize a task instance with the parameters |
* @param array raw, parsed xml |
* @param unused |
* @param unused |
*/ |
function init($xml, $attribs) |
public function init($xml, $attribs, $lastVersion = null) |
{ |
$this->_replacements = isset($xml['attribs']) ? array($xml) : $xml; |
} |
108,13 → 105,14 |
* Do a package.xml 1.0 replacement, with additional package-info fields available |
* |
* See validateXml() source for the complete list of allowed fields |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file contents |
* @param string the eventual final file location (informational only) |
* @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError), otherwise return the new contents |
* (use $this->throwError), otherwise return the new contents |
*/ |
function startSession($pkg, $contents, $dest) |
public function startSession($pkg, $contents, $dest) |
{ |
$subst_from = $subst_to = array(); |
foreach ($this->_replacements as $a) { |
130,6 → 128,7 |
$to = $chan->getServer(); |
} else { |
$this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]"); |
return false; |
} |
} else { |
146,6 → 145,7 |
} |
if (is_null($to)) { |
$this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]"); |
return false; |
} |
} elseif ($a['type'] == 'php-const') { |
156,6 → 156,7 |
$to = constant($a['to']); |
} else { |
$this->logger->log(0, "$dest: invalid php-const replacement: $a[to]"); |
return false; |
} |
} else { |
163,6 → 164,7 |
$to = $t; |
} else { |
$this->logger->log(0, "$dest: invalid package-info replacement: $a[to]"); |
return false; |
} |
} |
171,12 → 173,14 |
$subst_to[] = $to; |
} |
} |
$this->logger->log(3, "doing " . sizeof($subst_from) . |
" substitution(s) for $dest"); |
$this->logger->log( |
3, "doing ".sizeof($subst_from). |
" substitution(s) for $dest" |
); |
if (sizeof($subst_from)) { |
$contents = str_replace($subst_from, $subst_to, $contents); |
} |
return $contents; |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Unixeol/rw.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: rw.php,v 1.4 2006/01/06 04:47:37 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a10 |
*/ |
/** |
* Base class |
28,35 → 21,35 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a10 |
*/ |
class PEAR_Task_Unixeol_rw extends PEAR_Task_Unixeol |
{ |
function PEAR_Task_Unixeol_rw(&$pkg, &$config, &$logger, $fileXml) |
function __construct(&$pkg, &$config, &$logger, $fileXml) |
{ |
parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE); |
parent::__construct($config, $logger, PEAR_TASK_PACKAGE); |
$this->_contents = $fileXml; |
$this->_pkg = &$pkg; |
$this->_params = array(); |
} |
function validate() |
public function validate() |
{ |
return true; |
} |
function getName() |
public function getName() |
{ |
return 'unixeol'; |
} |
function getXml() |
public function getXml() |
{ |
return ''; |
} |
} |
?> |
?> |
/trunk/bibliotheque/pear/PEAR/Task/Postinstallscript.php |
---|
4,20 → 4,13 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Postinstallscript.php,v 1.18 2006/02/08 01:21:47 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
/** |
* Base class |
28,28 → 21,29 |
* |
* Note that post-install scripts are handled separately from installation, by the |
* "pear run-scripts" command |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_Task_Postinstallscript extends PEAR_Task_Common |
{ |
var $type = 'script'; |
var $_class; |
var $_params; |
var $_obj; |
public $type = 'script'; |
public $_class; |
public $_params; |
public $_obj; |
/** |
* |
* @var PEAR_PackageFile_v2 |
*/ |
var $_pkg; |
var $_contents; |
var $phase = PEAR_TASK_INSTALL; |
public $_pkg; |
public $_contents; |
public $phase = PEAR_TASK_INSTALL; |
/** |
* Validate the raw xml at parsing-time. |
56,28 → 50,29 |
* |
* This also attempts to validate the script to make sure it meets the criteria |
* for a post-install script |
* @param PEAR_PackageFile_v2 |
* @param array The XML contents of the <postinstallscript> tag |
* @param PEAR_Config |
* @param array the entire parsed <file> tag |
* @static |
* |
* @param PEAR_PackageFile_v2 |
* @param array The XML contents of the <postinstallscript> tag |
* @param PEAR_Config |
* @param array the entire parsed <file> tag |
*/ |
function validateXml($pkg, $xml, &$config, $fileXml) |
public static function validateXml($pkg, $xml, $config, $fileXml) |
{ |
if ($fileXml['role'] != 'php') { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" must be role="php"'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" must be role="php"', ); |
} |
PEAR::pushErrorHandling(PEAR_ERROR_RETURN); |
$file = $pkg->getFileContents($fileXml['name']); |
if (PEAR::isError($file)) { |
PEAR::popErrorHandling(); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" is not valid: ' . |
$file->getMessage()); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" is not valid: '. |
$file->getMessage(), ); |
} elseif ($file === null) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" could not be retrieved for processing!'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" could not be retrieved for processing!', ); |
} else { |
$analysis = $pkg->analyzeSourceCode($file, true); |
if (!$analysis) { |
84,29 → 79,37 |
PEAR::popErrorHandling(); |
$warnings = ''; |
foreach ($pkg->getValidationWarnings() as $warn) { |
$warnings .= $warn['message'] . "\n"; |
$warnings .= $warn['message']."\n"; |
} |
return array(PEAR_TASK_ERROR_INVALID, 'Analysis of post-install script "' . |
$fileXml['name'] . '" failed: ' . $warnings); |
return array(PEAR_TASK_ERROR_INVALID, 'Analysis of post-install script "'. |
$fileXml['name'].'" failed: '.$warnings, ); |
} |
if (count($analysis['declared_classes']) != 1) { |
PEAR::popErrorHandling(); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" must declare exactly 1 class'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" must declare exactly 1 class', ); |
} |
$class = $analysis['declared_classes'][0]; |
if ($class != str_replace(array('/', '.php'), array('_', ''), |
$fileXml['name']) . '_postinstall') { |
if ($class != str_replace( |
array('/', '.php'), array('_', ''), |
$fileXml['name'] |
).'_postinstall') { |
PEAR::popErrorHandling(); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" class "' . $class . '" must be named "' . |
str_replace(array('/', '.php'), array('_', ''), |
$fileXml['name']) . '_postinstall"'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" class "'.$class.'" must be named "'. |
str_replace( |
array('/', '.php'), array('_', ''), |
$fileXml['name'] |
).'_postinstall"', ); |
} |
if (!isset($analysis['declared_methods'][$class])) { |
PEAR::popErrorHandling(); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" must declare methods init() and run()'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" must declare methods init() and run()', ); |
} |
$methods = array('init' => 0, 'run' => 1); |
foreach ($analysis['declared_methods'][$class] as $method) { |
116,129 → 119,137 |
} |
if (count($methods)) { |
PEAR::popErrorHandling(); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" must declare methods init() and run()'); |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" must declare methods init() and run()', ); |
} |
} |
PEAR::popErrorHandling(); |
$definedparams = array(); |
$tasksNamespace = $pkg->getTasksNs() . ':'; |
if (!isset($xml[$tasksNamespace . 'paramgroup']) && isset($xml['paramgroup'])) { |
$tasksNamespace = $pkg->getTasksNs().':'; |
if (!isset($xml[$tasksNamespace.'paramgroup']) && isset($xml['paramgroup'])) { |
// in order to support the older betas, which did not expect internal tags |
// to also use the namespace |
$tasksNamespace = ''; |
} |
if (isset($xml[$tasksNamespace . 'paramgroup'])) { |
$params = $xml[$tasksNamespace . 'paramgroup']; |
if (isset($xml[$tasksNamespace.'paramgroup'])) { |
$params = $xml[$tasksNamespace.'paramgroup']; |
if (!is_array($params) || !isset($params[0])) { |
$params = array($params); |
} |
foreach ($params as $param) { |
if (!isset($param[$tasksNamespace . 'id'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" <paramgroup> must have ' . |
'an ' . $tasksNamespace . 'id> tag'); |
if (!isset($param[$tasksNamespace.'id'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" <paramgroup> must have '. |
'an '.$tasksNamespace.'id> tag', ); |
} |
if (isset($param[$tasksNamespace . 'name'])) { |
if (!in_array($param[$tasksNamespace . 'name'], $definedparams)) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" ' . $tasksNamespace . |
'paramgroup> id "' . $param[$tasksNamespace . 'id'] . |
'" parameter "' . $param[$tasksNamespace . 'name'] . |
'" has not been previously defined'); |
if (isset($param[$tasksNamespace.'name'])) { |
if (!in_array($param[$tasksNamespace.'name'], $definedparams)) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" '.$tasksNamespace. |
'paramgroup> id "'.$param[$tasksNamespace.'id']. |
'" parameter "'.$param[$tasksNamespace.'name']. |
'" has not been previously defined', ); |
} |
if (!isset($param[$tasksNamespace . 'conditiontype'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" ' . $tasksNamespace . |
'paramgroup> id "' . $param[$tasksNamespace . 'id'] . |
'" must have a ' . $tasksNamespace . |
'conditiontype> tag containing either "=", ' . |
'"!=", or "preg_match"'); |
if (!isset($param[$tasksNamespace.'conditiontype'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" '.$tasksNamespace. |
'paramgroup> id "'.$param[$tasksNamespace.'id']. |
'" must have a '.$tasksNamespace. |
'conditiontype> tag containing either "=", '. |
'"!=", or "preg_match"', ); |
} |
if (!in_array($param[$tasksNamespace . 'conditiontype'], |
array('=', '!=', 'preg_match'))) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" ' . $tasksNamespace . |
'paramgroup> id "' . $param[$tasksNamespace . 'id'] . |
'" must have a ' . $tasksNamespace . |
'conditiontype> tag containing either "=", ' . |
'"!=", or "preg_match"'); |
if (!in_array( |
$param[$tasksNamespace.'conditiontype'], |
array('=', '!=', 'preg_match') |
)) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" '.$tasksNamespace. |
'paramgroup> id "'.$param[$tasksNamespace.'id']. |
'" must have a '.$tasksNamespace. |
'conditiontype> tag containing either "=", '. |
'"!=", or "preg_match"', ); |
} |
if (!isset($param[$tasksNamespace . 'value'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" ' . $tasksNamespace . |
'paramgroup> id "' . $param[$tasksNamespace . 'id'] . |
'" must have a ' . $tasksNamespace . |
'value> tag containing expected parameter value'); |
if (!isset($param[$tasksNamespace.'value'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" '.$tasksNamespace. |
'paramgroup> id "'.$param[$tasksNamespace.'id']. |
'" must have a '.$tasksNamespace. |
'value> tag containing expected parameter value', ); |
} |
} |
if (isset($param[$tasksNamespace . 'instructions'])) { |
if (!is_string($param[$tasksNamespace . 'instructions'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" ' . $tasksNamespace . |
'paramgroup> id "' . $param[$tasksNamespace . 'id'] . |
'" ' . $tasksNamespace . 'instructions> must be simple text'); |
if (isset($param[$tasksNamespace.'instructions'])) { |
if (!is_string($param[$tasksNamespace.'instructions'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" '.$tasksNamespace. |
'paramgroup> id "'.$param[$tasksNamespace.'id']. |
'" '.$tasksNamespace.'instructions> must be simple text', ); |
} |
} |
if (!isset($param[$tasksNamespace . 'param'])) { |
if (!isset($param[$tasksNamespace.'param'])) { |
continue; // <param> is no longer required |
} |
$subparams = $param[$tasksNamespace . 'param']; |
$subparams = $param[$tasksNamespace.'param']; |
if (!is_array($subparams) || !isset($subparams[0])) { |
$subparams = array($subparams); |
} |
foreach ($subparams as $subparam) { |
if (!isset($subparam[$tasksNamespace . 'name'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" parameter for ' . |
$tasksNamespace . 'paramgroup> id "' . |
$param[$tasksNamespace . 'id'] . '" must have ' . |
'a ' . $tasksNamespace . 'name> tag'); |
if (!isset($subparam[$tasksNamespace.'name'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" parameter for '. |
$tasksNamespace.'paramgroup> id "'. |
$param[$tasksNamespace.'id'].'" must have '. |
'a '.$tasksNamespace.'name> tag', ); |
} |
if (!preg_match('/[a-zA-Z0-9]+/', |
$subparam[$tasksNamespace . 'name'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" parameter "' . |
$subparam[$tasksNamespace . 'name'] . |
'" for ' . $tasksNamespace . 'paramgroup> id "' . |
$param[$tasksNamespace . 'id'] . |
'" is not a valid name. Must contain only alphanumeric characters'); |
if (!preg_match( |
'/[a-zA-Z0-9]+/', |
$subparam[$tasksNamespace.'name'] |
)) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" parameter "'. |
$subparam[$tasksNamespace.'name']. |
'" for '.$tasksNamespace.'paramgroup> id "'. |
$param[$tasksNamespace.'id']. |
'" is not a valid name. Must contain only alphanumeric characters', ); |
} |
if (!isset($subparam[$tasksNamespace . 'prompt'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" parameter "' . |
$subparam[$tasksNamespace . 'name'] . |
'" for ' . $tasksNamespace . 'paramgroup> id "' . |
$param[$tasksNamespace . 'id'] . |
'" must have a ' . $tasksNamespace . 'prompt> tag'); |
if (!isset($subparam[$tasksNamespace.'prompt'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" parameter "'. |
$subparam[$tasksNamespace.'name']. |
'" for '.$tasksNamespace.'paramgroup> id "'. |
$param[$tasksNamespace.'id']. |
'" must have a '.$tasksNamespace.'prompt> tag', ); |
} |
if (!isset($subparam[$tasksNamespace . 'type'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "' . |
$fileXml['name'] . '" parameter "' . |
$subparam[$tasksNamespace . 'name'] . |
'" for ' . $tasksNamespace . 'paramgroup> id "' . |
$param[$tasksNamespace . 'id'] . |
'" must have a ' . $tasksNamespace . 'type> tag'); |
if (!isset($subparam[$tasksNamespace.'type'])) { |
return array(PEAR_TASK_ERROR_INVALID, 'Post-install script "'. |
$fileXml['name'].'" parameter "'. |
$subparam[$tasksNamespace.'name']. |
'" for '.$tasksNamespace.'paramgroup> id "'. |
$param[$tasksNamespace.'id']. |
'" must have a '.$tasksNamespace.'type> tag', ); |
} |
$definedparams[] = $param[$tasksNamespace . 'id'] . '::' . |
$subparam[$tasksNamespace . 'name']; |
$definedparams[] = $param[$tasksNamespace.'id'].'::'. |
$subparam[$tasksNamespace.'name']; |
} |
} |
} |
return true; |
} |
/** |
* Initialize a task instance with the parameters |
* @param array raw, parsed xml |
* @param array attributes from the <file> tag containing this task |
* @param string|null last installed version of this package, if any (useful for upgrades) |
* @param array $xml raw, parsed xml |
* @param array $fileattribs attributes from the <file> tag containing |
* this task |
* @param string|null $lastversion last installed version of this package, |
* if any (useful for upgrades) |
*/ |
function init($xml, $fileattribs, $lastversion) |
public function init($xml, $fileattribs, $lastversion) |
{ |
$this->_class = str_replace('/', '_', $fileattribs['name']); |
$this->_filename = $fileattribs['name']; |
$this->_class = str_replace ('.php', '', $this->_class) . '_postinstall'; |
$this->_class = str_replace('.php', '', $this->_class).'_postinstall'; |
$this->_params = $xml; |
$this->_lastversion = $lastversion; |
} |
248,7 → 259,7 |
* |
* @access private |
*/ |
function _stripNamespace($params = null) |
public function _stripNamespace($params = null) |
{ |
if ($params === null) { |
$params = array(); |
259,7 → 270,7 |
if (is_array($param)) { |
$param = $this->_stripNamespace($param); |
} |
$params[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param; |
$params[str_replace($this->_pkg->getTasksNs().':', '', $i)] = $param; |
} |
$this->_params = $params; |
} else { |
268,21 → 279,24 |
if (is_array($param)) { |
$param = $this->_stripNamespace($param); |
} |
$newparams[str_replace($this->_pkg->getTasksNs() . ':', '', $i)] = $param; |
$newparams[str_replace($this->_pkg->getTasksNs().':', '', $i)] = $param; |
} |
return $newparams; |
} |
} |
/** |
* Unlike other tasks, the installed file name is passed in instead of the file contents, |
* because this task is handled post-installation |
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string file name |
* Unlike other tasks, the installed file name is passed in instead of the |
* file contents, because this task is handled post-installation |
* |
* @param mixed $pkg PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
* @param string $contents file name |
* |
* @return bool|PEAR_Error false to skip this file, PEAR_Error to fail |
* (use $this->throwError) |
* (use $this->throwError) |
*/ |
function startSession($pkg, $contents) |
public function startSession($pkg, $contents) |
{ |
if ($this->installphase != PEAR_TASK_INSTALL) { |
return false; |
290,17 → 304,21 |
// remove the tasks: namespace if present |
$this->_pkg = $pkg; |
$this->_stripNamespace(); |
$this->logger->log(0, 'Including external post-installation script "' . |
$contents . '" - any errors are in this script'); |
$this->logger->log( |
0, 'Including external post-installation script "'. |
$contents.'" - any errors are in this script' |
); |
include_once $contents; |
if (class_exists($this->_class)) { |
$this->logger->log(0, 'Inclusion succeeded'); |
} else { |
return $this->throwError('init of post-install script class "' . $this->_class |
. '" failed'); |
return $this->throwError( |
'init of post-install script class "'.$this->_class |
.'" failed' |
); |
} |
$this->_obj = new $this->_class; |
$this->logger->log(1, 'running post-install script "' . $this->_class . '->init()"'); |
$this->_obj = new $this->_class(); |
$this->logger->log(1, 'running post-install script "'.$this->_class.'->init()"'); |
PEAR::pushErrorHandling(PEAR_ERROR_RETURN); |
$res = $this->_obj->init($this->config, $pkg, $this->_lastversion); |
PEAR::popErrorHandling(); |
307,23 → 325,25 |
if ($res) { |
$this->logger->log(0, 'init succeeded'); |
} else { |
return $this->throwError('init of post-install script "' . $this->_class . |
'->init()" failed'); |
return $this->throwError( |
'init of post-install script "'.$this->_class. |
'->init()" failed' |
); |
} |
$this->_contents = $contents; |
return true; |
} |
/** |
* No longer used |
* @see PEAR_PackageFile_v2::runPostinstallScripts() |
* @param array an array of tasks |
* @param string install or upgrade |
* |
* @see PEAR_PackageFile_v2::runPostinstallScripts() |
* @param array an array of tasks |
* @param string install or upgrade |
* @access protected |
* @static |
*/ |
function run() |
public static function run() |
{ |
} |
} |
?> |