123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <?php
- /*
- * This file is part of the symfony package.
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * sfWidgetFormSchemaDecorator wraps a form schema widget inside a given HTML snippet.
- *
- * @package symfony
- * @subpackage widget
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- * @version SVN: $Id: sfWidgetFormSchemaDecorator.class.php 12409 2008-10-29 14:06:02Z fabien $
- */
- class sfWidgetFormSchemaDecorator extends sfWidgetFormSchema
- {
- protected
- $widget = null,
- $decorator = '';
- /**
- * Constructor.
- *
- * @param sfWidgetFormSchema $widget A sfWidgetFormSchema instance
- * @param string $decorator A decorator string
- *
- * @see sfWidgetFormSchema
- */
- public function __construct(sfWidgetFormSchema $widget, $decorator)
- {
- $this->widget = $widget;
- $this->decorator = $decorator;
- parent::__construct();
- }
- /**
- * Returns the decorated widget.
- *
- * @param sfWidget The decorated widget
- */
- public function getWidget()
- {
- return $this->widget;
- }
- /**
- * @param string $name The element name
- * @param string $value The value displayed in this widget
- * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
- * @param array $errors An array of errors for the field
- *
- * @see sfWidget
- */
- public function render($name, $values = array(), $attributes = array(), $errors = array())
- {
- return strtr($this->decorator, array('%content%' => $this->widget->render($name, $values, $attributes, $errors)));
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function addFormFormatter($name, sfWidgetFormSchemaFormatter $formatter)
- {
- return $this->widget->addFormFormatter($name, $formatter);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getFormFormatters()
- {
- return $this->widget->getFormFormatters();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setFormFormatterName($name)
- {
- $this->widget->setFormFormatterName($name);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getFormFormatterName()
- {
- return $this->widget->getFormFormatterName();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getFormFormatter()
- {
- return $this->widget->getFormFormatter();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setNameFormat($format)
- {
- $this->widget->setNameFormat($format);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getNameFormat()
- {
- return $this->widget->getNameFormat();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setLabels($labels)
- {
- $this->widget->setLabels($labels);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getLabels()
- {
- return $this->widget->getLabels();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setLabel($name, $value = null)
- {
- if (2 == func_num_args())
- {
- $this->widget->setLabel($name, $value);
- }
- else
- {
- $this->widget->setLabel($name);
- }
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getLabel($name = null)
- {
- return 1 == func_num_args() ? $this->widget->getLabel($name) : $this->widget->getLabel();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setHelps($helps)
- {
- $this->widget->setHelps($helps);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getHelps()
- {
- return $this->widget->getHelps();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setHelp($name, $help)
- {
- $this->widget->setHelp($name, $help);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getHelp($name)
- {
- return $this->widget->getHelp($name);
- }
- /**
- * Gets the stylesheet paths associated with the widget.
- *
- * @return array An array of stylesheet paths
- */
- public function getStylesheets()
- {
- return $this->widget->getStylesheets();
- }
- /**
- * Gets the JavaScript paths associated with the widget.
- *
- * @return array An array of JavaScript paths
- */
- public function getJavaScripts()
- {
- return $this->widget->getJavaScripts();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function needsMultipartForm()
- {
- return $this->widget->needsMultipartForm();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function renderField($name, $value = null, $attributes = array(), $errors = array())
- {
- return $this->widget->renderField($name, $value, $attributes, $errors);
- }
- /**
- * @see sfWidgetFormSchemaFormatter
- */
- public function generateLabel($name)
- {
- return $this->widget->getFormFormatter()->generateLabel($name);
- }
- /**
- * @see sfWidgetFormSchemaFormatter
- */
- public function generateLabelName($name)
- {
- return $this->widget->getFormFormatter()->generateLabelName($name);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function generateName($name)
- {
- return $this->widget->generateName($name);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getParent()
- {
- return $this->widget->getParent();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setParent(sfWidgetFormSchema $parent = null)
- {
- $this->widget->setParent($parent);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getFields()
- {
- return $this->widget->getFields();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function getPositions()
- {
- return $this->widget->getPositions();
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function setPositions($positions)
- {
- $this->widget->setPositions($positions);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function moveField($field, $action, $pivot = null)
- {
- return $this->widget->moveField($field, $action, $pivot);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function offsetExists($name)
- {
- return isset($this->widget[$name]);
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function offsetGet($name)
- {
- return $this->widget[$name];
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function offsetSet($name, $widget)
- {
- $this->widget[$name] = $widget;
- }
- /**
- * @see sfWidgetFormSchema
- */
- public function offsetUnset($name)
- {
- unset($this->widget[$name]);
- }
- public function __clone()
- {
- $this->widget = clone $this->widget;
- }
- }
|