[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/system/pear/PEAR/Task/Postinstallscript/ -> rw.php (source)

   1  <?php
   2  /**
   3   * <tasks:postinstallscript> - read/write version
   4   *
   5   * PHP versions 4 and 5
   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
  14   * @package    PEAR
  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
  21   */
  22  /**
  23   * Base class
  24   */
  25  require_once 'PEAR/Task/Postinstallscript.php';
  26  /**
  27   * Abstracts the postinstallscript file task xml.
  28   * @category   pear
  29   * @package    PEAR
  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
  36   */
  37  class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript
  38  {
  39      /**
  40       * parent package file object
  41       *
  42       * @var PEAR_PackageFile_v2_rw
  43       */
  44      var $_pkg;
  45      /**
  46       * Enter description here...
  47       *
  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
  53       */
  54      function PEAR_Task_Postinstallscript_rw(&$pkg, &$config, &$logger, $fileXml)
  55      {
  56          parent::PEAR_Task_Common($config, $logger, PEAR_TASK_PACKAGE);
  57          $this->_contents = $fileXml;
  58          $this->_pkg = &$pkg;
  59          $this->_params = array();
  60      }
  61  
  62      function validate()
  63      {
  64          return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents);
  65      }
  66  
  67      function getName()
  68      {
  69          return 'postinstallscript';
  70      }
  71  
  72      /**
  73       * add a simple <paramgroup> to the post-install script
  74       *
  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().
  79       * 
  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
  85       */
  86      function addParamGroup($id, $params = false, $instructions = false)
  87      {
  88          if ($params && isset($params[0]) && !isset($params[1])) {
  89              $params = $params[0];
  90          }
  91          $stuff =
  92              array(
  93                  $this->_pkg->getTasksNs() . ':id' => $id,
  94              );
  95          if ($instructions) {
  96              $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
  97          }
  98          if ($params) {
  99              $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
 100          }
 101          $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
 102      }
 103  
 104      /**
 105       * add a complex <paramgroup> to the post-install script with conditions
 106       *
 107       * This inserts a <paramgroup> with
 108       *
 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().
 113       * 
 114       * Use {@link addParamGroup()} to add a simple <paramgroup>
 115       *
 116       * @param string $id <paramgroup> id as seen by the script
 117       * @param string $oldgroup <paramgroup> id of the section referenced by
 118       *                         <conditiontype>
 119       * @param string $param name of the <param> from the older section referenced
 120       *                      by <contitiontype>
 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
 125       */
 126      function addConditionTypeGroup($id, $oldgroup, $param, $value, $conditiontype = '=',
 127                                     $params = false, $instructions = false)
 128      {
 129          if ($params && isset($params[0]) && !isset($params[1])) {
 130              $params = $params[0];
 131          }
 132          $stuff =
 133              array(
 134                  $this->_pkg->getTasksNs() . ':id' => $id,
 135              );
 136          if ($instructions) {
 137              $stuff[$this->_pkg->getTasksNs() . ':instructions'] = $instructions;
 138          }
 139          $stuff[$this->_pkg->getTasksNs() . ':name'] = $oldgroup . '::' . $param;
 140          $stuff[$this->_pkg->getTasksNs() . ':conditiontype'] = $conditiontype;
 141          $stuff[$this->_pkg->getTasksNs() . ':value'] = $value;
 142          if ($params) {
 143              $stuff[$this->_pkg->getTasksNs() . ':param'] = $params;
 144          }
 145          $this->_params[$this->_pkg->getTasksNs() . ':paramgroup'][] = $stuff;
 146      }
 147  
 148      function getXml()
 149      {
 150          return $this->_params;
 151      }
 152  
 153      /**
 154       * Use to set up a param tag for use in creating a paramgroup
 155       * @static
 156       */
 157      function getParam($name, $prompt, $type = 'string', $default = null)
 158      {
 159          if ($default !== null) {
 160              return 
 161              array(
 162                  $this->_pkg->getTasksNs() . ':name' => $name,
 163                  $this->_pkg->getTasksNs() . ':prompt' => $prompt,
 164                  $this->_pkg->getTasksNs() . ':type' => $type,
 165                  $this->_pkg->getTasksNs() . ':default' => $default
 166              );
 167          }
 168          return
 169              array(
 170                  $this->_pkg->getTasksNs() . ':name' => $name,
 171                  $this->_pkg->getTasksNs() . ':prompt' => $prompt,
 172                  $this->_pkg->getTasksNs() . ':type' => $type,
 173              );
 174      }
 175  }
 176  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics