Exemplo n.º 1
0
 /**
  * Allocates member variables of currentElement and its children.
  * Parses for child nodes and there atrributes.
  * @param DomElement $field
  * @return false: no child nodes or no attributes have been found.
  */
 private function _parseSubFields(DomElement $field, $currentElement)
 {
     if ($field->hasChildNodes()) {
         foreach ($field->getElementsByTagname('subfield') as $subField) {
             //subfields have also type FormElement
             $currentSubField = new Publish_Model_FormElement($this->form);
             if ($subField->hasAttributes()) {
                 $subElementName = $subField->getAttribute('name');
                 $subRequired = $subField->getAttribute('required');
                 $subFormElement = $subField->getAttribute('formelement');
                 $subDatatype = $subField->getAttribute('datatype');
                 $currentSubField->setElementName($currentElement->getElementName() . $subElementName);
                 if ($subRequired === 'yes') {
                     $currentSubField->setRequired(true);
                 } else {
                     $currentSubField->setRequired(false);
                 }
                 $currentSubField->setFormElement($subFormElement);
                 $currentSubField->setDatatype($subDatatype);
                 $currentSubField->isSubField = true;
             } else {
                 //No Attributes found!
                 return false;
             }
             if ($subField->hasChildNodes()) {
                 $this->_parseDefaultEntry($currentElement, $subField, $currentSubField);
             }
             $currentElement->addSubFormElement($currentSubField->transform());
         }
         $options = array();
         foreach ($field->getElementsByTagname('option') as $option) {
             if ($option->hasAttributes()) {
                 $value = $option->getAttribute('value');
                 $options[$value] = $value;
             }
         }
         $currentElement->setListOptions($options);
     } else {
         return false;
     }
 }