[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Horde_UI_VarRenderer:: class provides base functionality for 4 * other Horde UI elements. 5 * 6 * $Horde: framework/UI/UI/VarRenderer.php,v 1.12.10.10 2006/06/20 09:08:45 jan Exp $ 7 * 8 * Copyright 2003-2006 Jason M. Felice <jfelice@cronosys.com> 9 * 10 * See the enclosed file COPYING for license information (LGPL). If you 11 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 12 * 13 * @since Horde_UI 0.0.1 14 * @package Horde_UI 15 */ 16 class Horde_UI_VarRenderer { 17 18 /** 19 * Parameters which change this renderer's behavior. 20 * 21 * @var array 22 */ 23 var $_params; 24 25 /** 26 * Charset to use for output. 27 * 28 * @var string 29 */ 30 var $_charset; 31 32 /** 33 * Constructs a new renderer. 34 * 35 * @param array $params The name of the variable which will track this UI 36 * widget's state. 37 */ 38 function Horde_UI_VarRenderer($params = array()) 39 { 40 $this->_params = $params; 41 $this->_charset = NLS::getCharset(); 42 } 43 44 /** 45 * Constructs a new Horde_UI_VarRenderer:: instance. 46 * 47 * @param mixed $driver This is the renderer subclass we will instantiate. 48 * If an array is passed, the first element is the 49 * library path and the second element is the driver 50 * name. 51 * @param array $params Parameters specific to the subclass. 52 * 53 * @return Horde_UI_VarRenderer A Horde_UI_VarRenderer:: subclass 54 * instance. 55 */ 56 function &factory($driver, $params = array()) 57 { 58 if (is_array($driver)) { 59 $app = $driver[0]; 60 $driver = $driver[1]; 61 } 62 63 $driver = basename($driver); 64 65 if (!empty($app)) { 66 require_once $GLOBALS['registry']->get('fileroot', $app) . '/lib/UI/VarRenderer/' . $driver . '.php'; 67 } elseif (@file_exists(dirname(__FILE__) . '/VarRenderer/' . $driver . '.php')) { 68 require_once dirname(__FILE__) . '/VarRenderer/' . $driver . '.php'; 69 } else { 70 @include_once 'Horde/UI/VarRenderer/' . $driver . '.php'; 71 } 72 73 $class = 'Horde_UI_VarRenderer_' . $driver; 74 if (class_exists($class)) { 75 $vr = &new $class($params); 76 } else { 77 $vr = PEAR::raiseError('Class definition of ' . $class . ' not found.'); 78 } 79 80 return $vr; 81 } 82 83 /** 84 * Returns a Horde_UI_VarRenderer:: instance, constructing one with the 85 * specified parameters if necessary. 86 * 87 * @param string $driver This is the renderer subclass we will 88 * instantiate. 89 * @param array $params Parameters specific to the subclass. 90 * 91 * @return Horde_UI_VarRenderer A Horde_UI_VarRenderer:: subclass 92 * instance. 93 */ 94 function &singleton($driver, $params = array()) 95 { 96 static $cache; 97 98 if (is_null($driver)) { 99 $class = 'Horde_UI_VarRenderer'; 100 } 101 $key = serialize(array ($driver, $params)); 102 if (!isset($cache[$key])) { 103 $cache[$key] = &Horde_UI_VarRenderer::factory($driver, $params); 104 } 105 return $cache[$key]; 106 } 107 108 /** 109 * Renders a variable. 110 * 111 * @param Horde_Form &$form Reference to a Horde_Form instance, 112 * or null if none is available. 113 * @param Horde_Form_Variable &$var Reference to a Horde_Form_Variable. 114 * @param Variables &$vars A Variables instance. 115 * @param boolean $isInput Whether this is an input field. 116 */ 117 function render(&$form, &$var, &$vars, $isInput = false) 118 { 119 if ($isInput) { 120 $state = 'Input'; 121 } else { 122 $state = 'Display'; 123 } 124 $method = "_renderVar$state}_" . $var->type->getTypeName(); 125 if (!@method_exists($this, $method)) { 126 $method = "_renderVar$state}Default"; 127 } 128 return $this->$method($form, $var, $vars); 129 } 130 131 /** 132 * Finishes rendering after all fields are output. 133 */ 134 function renderEnd() 135 { 136 return ''; 137 } 138 139 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |