Development

/branches/1.2/lib/widget/sfWidgetFormSchemaDecorator.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/widget/sfWidgetFormSchemaDecorator.class.php

Revision 20301, 6.4 kB (checked in by fabien, 5 years ago)

[1.2, 1.3] added exception phpdocs to all widget classes and change function signature (closes #6840 - patch from gimler)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfWidgetFormSchemaDecorator wraps a form schema widget inside a given HTML snippet.
13  *
14  * @package    symfony
15  * @subpackage widget
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfWidgetFormSchemaDecorator extends sfWidgetFormSchema
20 {
21   protected
22     $widget    = null,
23     $decorator = '';
24
25   /**
26    * Constructor.
27    *
28    * @param sfWidgetFormSchema $widget     A sfWidgetFormSchema instance
29    * @param string             $decorator  A decorator string
30    *
31    * @see sfWidgetFormSchema
32    */
33   public function __construct(sfWidgetFormSchema $widget, $decorator)
34   {
35     $this->widget    = $widget;
36     $this->decorator = $decorator;
37
38     parent::__construct();
39   }
40
41   /**
42    * Returns the decorated widget.
43    *
44    * @param sfWidget The decorated widget
45    */
46   public function getWidget()
47   {
48     return $this->widget;
49   }
50
51   /**
52    * @param  string $name        The element name
53    * @param  string $values      The value displayed in this widget
54    * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
55    * @param  array  $errors      An array of errors for the field
56    *
57    * @see sfWidget
58    */
59   public function render($name, $values = array(), $attributes = array(), $errors = array())
60   {
61     return strtr($this->decorator, array('%content%' => $this->widget->render($name, $values, $attributes, $errors)));
62   }
63
64   /**
65    * @see sfWidgetFormSchema
66    */
67   public function addFormFormatter($name, sfWidgetFormSchemaFormatter $formatter)
68   {
69     return $this->widget->addFormFormatter($name, $formatter);
70   }
71
72   /**
73    * @see sfWidgetFormSchema
74    */
75   public function getFormFormatters()
76   {
77     return $this->widget->getFormFormatters();
78   }
79
80   /**
81    * @see sfWidgetFormSchema
82    */
83   public function setFormFormatterName($name)
84   {
85     $this->widget->setFormFormatterName($name);
86   }
87
88   /**
89    * @see sfWidgetFormSchema
90    */
91   public function getFormFormatterName()
92   {
93     return $this->widget->getFormFormatterName();
94   }
95
96   /**
97    * @see sfWidgetFormSchema
98    */
99   public function getFormFormatter()
100   {
101     return $this->widget->getFormFormatter();
102   }
103
104   /**
105    * @see sfWidgetFormSchema
106    */
107   public function setNameFormat($format)
108   {
109     $this->widget->setNameFormat($format);
110   }
111
112   /**
113    * @see sfWidgetFormSchema
114    */
115   public function getNameFormat()
116   {
117     return $this->widget->getNameFormat();
118   }
119
120   /**
121    * @see sfWidgetFormSchema
122    */
123   public function setLabels(array $labels)
124   {
125     $this->widget->setLabels($labels);
126   }
127
128   /**
129    * @see sfWidgetFormSchema
130    */
131   public function getLabels()
132   {
133     return $this->widget->getLabels();
134   }
135
136   /**
137    * @see sfWidgetFormSchema
138    */
139   public function setLabel($name, $value = null)
140   {
141     if (2 == func_num_args())
142     {
143       $this->widget->setLabel($name, $value);
144     }
145     else
146     {
147       $this->widget->setLabel($name);
148     }
149   }
150
151   /**
152    * @see sfWidgetFormSchema
153    */
154   public function getLabel($name = null)
155   {
156     return 1 == func_num_args() ? $this->widget->getLabel($name) : $this->widget->getLabel();
157   }
158
159   /**
160    * @see sfWidgetFormSchema
161    */
162   public function setHelps(array $helps)
163   {
164     $this->widget->setHelps($helps);
165   }
166
167   /**
168    * @see sfWidgetFormSchema
169    */
170   public function getHelps()
171   {
172     return $this->widget->getHelps();
173   }
174
175   /**
176    * @see sfWidgetFormSchema
177    */
178   public function setHelp($name, $help)
179   {
180     $this->widget->setHelp($name, $help);
181   }
182
183   /**
184    * @see sfWidgetFormSchema
185    */
186   public function getHelp($name)
187   {
188     return $this->widget->getHelp($name);
189   }
190
191   /**
192    * Gets the stylesheet paths associated with the widget.
193    *
194    * @return array An array of stylesheet paths
195    */
196   public function getStylesheets()
197   {
198     return $this->widget->getStylesheets();
199   }
200
201   /**
202    * Gets the JavaScript paths associated with the widget.
203    *
204    * @return array An array of JavaScript paths
205    */
206   public function getJavaScripts()
207   {
208     return $this->widget->getJavaScripts();
209   }
210
211   /**
212    * @see sfWidgetFormSchema
213    */
214   public function needsMultipartForm()
215   {
216     return $this->widget->needsMultipartForm();
217   }
218
219   /**
220    * @see sfWidgetFormSchema
221    */
222   public function renderField($name, $value = null, $attributes = array(), $errors = array())
223   {
224     return $this->widget->renderField($name, $value, $attributes, $errors);
225   }
226
227   /**
228    * @see sfWidgetFormSchemaFormatter
229    */
230   public function generateLabel($name)
231   {
232     return $this->widget->getFormFormatter()->generateLabel($name);
233   }
234
235   /**
236    * @see sfWidgetFormSchemaFormatter
237    */
238   public function generateLabelName($name)
239   {
240     return $this->widget->getFormFormatter()->generateLabelName($name);
241   }
242
243   /**
244    * @see sfWidgetFormSchema
245    */
246   public function generateName($name)
247   {
248     return $this->widget->generateName($name);
249   }
250
251   /**
252    * @see sfWidgetFormSchema
253    */
254   public function getParent()
255   {
256     return $this->widget->getParent();
257   }
258
259   /**
260    * @see sfWidgetFormSchema
261    */
262   public function setParent(sfWidgetFormSchema $parent = null)
263   {
264     $this->widget->setParent($parent);
265   }
266
267   /**
268    * @see sfWidgetFormSchema
269    */
270   public function getFields()
271   {
272     return $this->widget->getFields();
273   }
274
275   /**
276    * @see sfWidgetFormSchema
277    */
278   public function getPositions()
279   {
280     return $this->widget->getPositions();
281   }
282
283   /**
284    * @see sfWidgetFormSchema
285    */
286   public function setPositions(array $positions)
287   {
288     $this->widget->setPositions($positions);
289   }
290
291   /**
292    * @see sfWidgetFormSchema
293    */
294   public function moveField($field, $action, $pivot = null)
295   {
296     return $this->widget->moveField($field, $action, $pivot);
297   }
298
299   /**
300    * @see sfWidgetFormSchema
301    */
302   public function offsetExists($name)
303   {
304     return isset($this->widget[$name]);
305   }
306
307   /**
308    * @see sfWidgetFormSchema
309    */
310   public function offsetGet($name)
311   {
312     return $this->widget[$name];
313   }
314
315   /**
316    * @see sfWidgetFormSchema
317    */
318   public function offsetSet($name, $widget)
319   {
320     $this->widget[$name] = $widget;
321   }
322
323   /**
324    * @see sfWidgetFormSchema
325    */
326   public function offsetUnset($name)
327   {
328     unset($this->widget[$name]);
329   }
330
331   public function __clone()
332   {
333     $this->widget = clone $this->widget;
334   }
335 }
336
Note: See TracBrowser for help on using the browser.