[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/Block/ -> UI.php (source)

   1  <?php
   2  /**
   3   * Class for setting up Horde Blocks using the Horde_Form:: classes.
   4   *
   5   * Copyright 2004-2006 Marko Djukic <marko@oblo.com>
   6   *
   7   * See the enclosed file COPYING for license information (LGPL). If you did
   8   * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
   9   *
  10   * $Horde: framework/Block/Block/UI.php,v 1.8.10.5 2006/01/02 17:46:35 jan Exp $
  11   *
  12   * @author  Marko Djukic <marko@oblo.com>
  13   * @since   Horde 3.0
  14   * @package Horde_Block
  15   */
  16  class Horde_Block_UI {
  17  
  18      var $_blocks = array();
  19      var $_form = null;
  20      var $_vars = null;
  21  
  22      function Horde_Block_UI()
  23      {
  24          require_once  'Horde/Block.php';
  25          require_once  'Horde/Block/Collection.php';
  26          $this->_blocks = &Horde_Block_Collection::singleton();
  27      }
  28  
  29      function setForm(&$form)
  30      {
  31          $this->_form = &$form;
  32      }
  33  
  34      function setVars(&$vars)
  35      {
  36          $this->_vars = &$vars;
  37      }
  38  
  39      function setupEditForm($field = 'block')
  40      {
  41          if (is_null($this->_vars)) {
  42              /* No existing vars set, get them now. */
  43              require_once 'Horde/Variables.php';
  44              $this->_vars = &Variables::getDefaultVariables();
  45          }
  46  
  47          if (!is_a($this->_form, 'Horde_Form')) {
  48              /* No existing valid form object set so set up a new one. */
  49              require_once 'Horde/Form.php';
  50              $this->_form = &Horde_Form::singleton('', $this->_vars, _("Edit Block"));
  51          }
  52  
  53          /* Get the current value of the block selection. */
  54          $value = $this->_vars->get($field);
  55  
  56          /* Field to select apps. */
  57          $apps = $this->_blocks->getBlocksList();
  58          $v = &$this->_form->addVariable(_("Application"), $field . '[app]', 'enum', true, false, null, array($apps));
  59          $v->setOption('trackchange', true);
  60  
  61          if (empty($value['app'])) {
  62              return;
  63          }
  64  
  65          /* If a block has been selected, output any options input. */
  66          list($app, $block) = explode(':', $value['app']);
  67  
  68          /* Get the options for the requested block. */
  69          $options = $this->_blocks->getParams($app, $block);
  70  
  71          /* Go through the options for this block and set up any required
  72           * extra input. */
  73          foreach ($options as $option) {
  74              $name = $this->_blocks->getParamName($app, $block, $option);
  75              $type = $this->_blocks->getOptionType($app, $block, $option);
  76              $required = $this->_blocks->getOptionRequired($app, $block, $option);
  77              $values = $this->_blocks->getOptionValues($app, $block, $option);
  78              /* TODO: the setting 'string' should be changed in all blocks
  79               * to 'text' so that it conforms with Horde_Form syntax. */
  80              if ($type == 'string') {
  81                  $type = 'text';
  82              }
  83              $params = array();
  84              if ($type == 'enum' || $type == 'mlenum') {
  85                  $params = array($values, true);
  86              }
  87              $this->_form->addVariable($name, $field . '[options][' . $option . ']', $type, $required, false, null, $params);
  88          }
  89      }
  90  
  91  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7