public function testUnrequiredFirstNames()
 {
     $session = new Zend_Session_Namespace('Publish');
     $session->documentType = 'all';
     $form = new Publish_Form_PublishingSecond($this->_logger);
     $name = 'PersonAuthor';
     $required = true;
     $formElement = 'text';
     $datatype = 'Person';
     $multiplicity = 1;
     $element = new Publish_Model_FormElement($form, $name, $required, $formElement, $datatype, $multiplicity);
     $element->initGroup();
     $subformElements = $element->getSubFormElements();
     foreach ($subformElements as $sub) {
         /* @var $sub Zend_Form_Element */
         if ($sub->getName() == 'PersonAuthorFirstName') {
             $this->assertFalse($sub->isRequired());
         }
     }
 }
示例#2
0
 /**
  * Allocates member variables of currentElement or can be used for subfields.
  * Parses for default values and the possibility of edit and make it public.
  * @param DOMElement $field
  * @param Publish_Model_FormElement $subfield
  * @return false if there are no child nodes
  */
 private function _parseDefaultEntry($currentElement, DOMElement $field, Publish_Model_FormElement $subfield = null)
 {
     if ($field->hasChildNodes()) {
         foreach ($field->getElementsByTagname('default') as $default) {
             if ($default->hasAttributes()) {
                 $defaultArray = array();
                 $forValue = $default->getAttribute('for');
                 if (isset($forValue)) {
                     $defaultArray['for'] = $forValue;
                 }
                 $value = $default->getAttribute('value');
                 if (isset($value)) {
                     $defaultArray['value'] = $value;
                 }
                 $edit = $default->getAttribute('edit');
                 if (isset($edit)) {
                     $defaultArray['edit'] = $edit;
                 }
                 $public = $default->getAttribute('public');
                 if (isset($public)) {
                     $defaultArray['public'] = $public;
                 }
                 if (!isset($subfield)) {
                     $currentElement->setDefaultValue($defaultArray);
                     $this->log->debug(__METHOD__ . " : " . $value);
                 } else {
                     $subfield->setDefaultValue($defaultArray);
                 }
             } else {
                 return false;
             }
         }
     }
 }
示例#3
0
 private function implicitFields($workflow)
 {
     switch ($workflow) {
         case 'Person':
             //creates two subfields for first and last name
             $first = new Publish_Model_FormElement($this->form, $this->elementName . self::FIRST, false, 'text', 'Person');
             $first->isSubField = true;
             $first->setDefaultValue($this->default, self::FIRST);
             $elementFirst = $first->transform();
             $last = new Publish_Model_FormElement($this->form, $this->elementName . self::LAST, $this->required, 'text', 'Person');
             $last->isSubField = false;
             $last->setDefaultValue($this->default, self::LAST);
             $elementLast = $last->transform();
             return array($elementFirst, $elementLast);
             break;
         case 'Series':
             //creates a additional field for a number
             $number = new Publish_Model_FormElement($this->form, $this->elementName . self::NR, $this->required, 'text', 'SeriesNumber');
             $number->isSubField = false;
             $number->setDefaultValue($this->default, self::NR);
             $elementNumber = $number->transform();
             $select = new Publish_Model_FormElement($this->form, $this->elementName, $this->required, 'select', 'Series');
             $select->isSubField = true;
             $select->setDefaultValue($this->default);
             $element = $select->transform();
             return array($elementNumber, $element);
             break;
         case 'Subject':
         case 'Title':
             //creates two subfields: a value text field (subject, title) and language selection
             if ($this->isTitleElement()) {
                 if ($this->isTextareaElement()) {
                     $value = new Publish_Model_FormElement($this->form, $this->elementName, $this->required, 'textarea', 'Title');
                 } else {
                     $value = new Publish_Model_FormElement($this->form, $this->elementName, $this->required, 'text', 'Title');
                 }
             } else {
                 $value = new Publish_Model_FormElement($this->form, $this->elementName, $this->required, 'text', 'Subject');
             }
             $value->isSubField = false;
             $value->setDefaultValue($this->default, self::VALUE);
             $elementValue = $value->transform();
             // die Sprache ist nicht verpflichtend: da als Default-Option immer die Dokumentsprache angenommen wird
             $lang = new Publish_Model_FormElement($this->form, $this->elementName . self::LANG, false, 'select', 'Language');
             $lang->isSubField = true;
             $lang->setDefaultValue($this->default, self::LANG);
             $elementLang = $lang->transform();
             return array($elementValue, $elementLang);
             break;
     }
 }