Exemplo n.º 1
0
 public function __construct(XmlElement $node, $control_name = '', $options = null)
 {
     $this->control_name = $control_name;
     $attributes = $node->getAttributes();
     // unset cf-namespace attribute
     if (isset($attributes['cf-namespace'])) {
         unset($attributes['cf-namespace']);
     }
     if (array_key_exists("name", $attributes)) {
         $this->name = $attributes["name"];
     }
     if (isset($attributes["value"])) {
         $this->value = $attributes["value"];
     }
     if (!isset($attributes["id"])) {
         $attributes["id"] = $attributes["name"] . "_id";
     }
     unset($attributes["value"]);
     if (!is_null($options)) {
         $this->options = $options;
     }
     $this->attributes = $attributes;
     $this->label = new FormFieldLabel($this);
     if (!empty($this->unset_attributes)) {
         $this->unsetAttributes($this->unset_attributes);
     }
     $this->initialize();
 }
Exemplo n.º 2
0
 private function parseNode(XmlElement $node)
 {
     $className = ucfirst($node->getName());
     if (!ClassCache::exists($className)) {
         $instance = new HtmlComponent($node->getName(), $node->getText(), $node->getAttributes());
     } else {
         if (!ClassUtil::isSubclassOf($className, "Component")) {
             throw new ComponentNotExistsException($className);
         }
         $instance = new $className();
         foreach ($node->getAttributes() as $attrName => $attrValue) {
             $setterName = "set" . ucfirst($attrName);
             $setter = new ReflectionMethod($instance, $setterName);
             $setter->invoke($instance, (string) $attrValue);
         }
     }
     foreach ($node->getChildren() as $child) {
         $instance->addChild($this->parseNode($child));
     }
     return $instance;
 }
Exemplo n.º 3
0
 /**
  * FormFieldLabel constructor.
  *
  * @param XmlElement $field
  *
  * @since 1.0.0
  */
 public function __construct($field)
 {
     $fieldAttributes = $field->getAttributes();
     $attributes = $this->getAttributes();
     $this->unsetAttributes(array('name'));
     if (isset($fieldAttributes["label"])) {
         $this->setValue($fieldAttributes["label"]);
     }
     $attributes["for"] = $fieldAttributes["id"];
     $attributes['id'] = str_replace("_id", "_lbl", $fieldAttributes['id']);
     if (empty($attributes['class'])) {
         $attributes["class"] = self::$label_class;
     } else {
         $attributes["class"] = $fieldAttributes['class'] . " " . self::$label_class;
     }
     $this->setAttributes($attributes);
 }