Exemple #1
0
 /**
  * Return the allowed options for this container
  *
  * @return array
  */
 protected static function allowedOptions()
 {
     $additional = array('dir' => 1, 'lang' => 1, 'xml:lang' => 1);
     return array_merge(One_Form_Container_Abstract::allowedOptions(), $additional);
 }
Exemple #2
0
 /**
  * Determine what type of widget the DOMElement is and load it's conditions
  *
  * @param One_Form_Container_Abstract $container
  * @param DOMElement $element
  * @param string $widgetClass
  * @return One_Form_Widget_Abstract
  */
 protected static function determineWidget($container, $element, $widgetClass)
 {
     $id = $element->hasAttribute('id') ? $element->getAttribute('id') : $element->getAttribute('attribute');
     $name = $element->hasAttribute('name') ? $element->getAttribute('name') : $element->getAttribute('attribute');
     $label = $element->hasAttribute('label') ? $element->getAttribute('label') : $element->getAttribute('attribute');
     $attributes = array();
     $rawAttributes = $element->attributes;
     for ($i = 0; $i < $rawAttributes->length; $i++) {
         $attribute = $rawAttributes->item($i);
         $attributes[$attribute->localName] = $attribute->value;
     }
     if (false === isset($attributes['language'])) {
         $attributes['language'] = strtolower(One_Config::get('app.language'));
     }
     $widget = new $widgetClass($id, $name, $label, $attributes);
     if ($element->hasAttribute('optionsFrom') && method_exists($widget, 'setOptions')) {
         $parts = explode(':', $element->getAttribute('optionsFrom'));
         if (2 == count($parts)) {
             $session = One_Repository::getSession();
             $sessionCacheName = md5($id . '#' . $name . '#' . $element->getAttribute('optionsFrom'));
             if (false === $element->hasAttribute('cacheOptions') || $element->hasAttribute('cacheOptions') && false === $session->varExists($sessionCacheName, 'One_Form_Cache')) {
                 $optView = new One_View($parts[0], $parts[1]);
                 try {
                     $rawOptions = trim($optView->show());
                     $options = json_decode($rawOptions, 1);
                     if (false === is_array($options)) {
                         $options = array();
                     }
                     $widget->setOptions($options);
                     if ($element->hasAttribute('cacheOptions')) {
                         $session->set($sessionCacheName, $options, 'One_Form_Cache');
                     }
                 } catch (Exception $e) {
                     //					echo $e->getMessage();
                     //					exit;
                 }
             } else {
                 $options = $session->get($sessionCacheName, 'One_Form_Cache');
                 $widget->setOptions($options);
             }
         }
     }
     self::loadConstraints($element, $widget);
     $container->addWidget($widget);
     return $widget;
 }
Exemple #3
0
 /**
  * Return the allowed options for this container
  *
  * @return array
  */
 protected static function allowedOptions()
 {
     $additional = array('dir' => 1, 'lang' => 1, 'xml:lang' => 1, 'title' => 2, 'width' => 2, 'height' => 2, 'css' => 2);
     return array_merge(One_Form_Container_Abstract::allowedOptions(), $additional);
 }
Exemple #4
0
 /**
  * Return the allowed options for this container
  *
  * @return array
  */
 protected static function allowedOptions()
 {
     $additional = array('title' => 2, 'default' => 2);
     return array_merge(One_Form_Container_Abstract::allowedOptions(), $additional);
 }
Exemple #5
0
 /**
  * Return the allowed options for this container
  *
  * @return array
  */
 protected static function allowedOptions()
 {
     $additional = array('dir' => 1, 'lang' => 1, 'xml:lang' => 1, 'accept' => 1, 'accept-charset' => 1, 'enctype' => 1, 'target' => 1, 'widgetsInContainer' => 2, 'captcha' => 2, 'type' => 2);
     return array_merge(One_Form_Container_Abstract::allowedOptions(), $additional);
 }
Exemple #6
0
 /**
  * Class constructor
  *
  * @param string $id
  * @param array $config
  */
 public function __construct($id, array $config = array())
 {
     parent::__construct($id, $config);
 }