コード例 #1
0
 /**
  * @expectedException Publish_Model_FormIncorrectEnrichmentKeyException
  */
 public function testIncorrectEnrichmentKey()
 {
     $session = new Zend_Session_Namespace('Publish');
     $session->documentType = 'all';
     /* @var $dom DomDocument */
     $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('all');
     $this->assertInstanceOf('DOMDocument', $dom);
     foreach ($dom->getElementsByTagname('documenttype') as $rootNode) {
         $domElement = $dom->createElement('field');
         $domAttribute = $dom->createAttribute('name');
         $domAttribute->value = 'IncorrectEnrichmentKey';
         $domAttribute2 = $dom->createAttribute('datatype');
         $domAttribute2->value = 'Enrichment';
         // Don't forget to append it to the element
         $domElement->appendChild($domAttribute);
         $domElement->appendChild($domAttribute2);
         // Append it to the document itself
         $rootNode->appendChild($domElement);
         $dom->saveXML();
     }
     $model = new Publish_Model_DocumenttypeParser($dom, new Publish_Form_PublishingSecond($this->_logger));
     $model->parse();
 }
コード例 #2
0
ファイル: PublishingSecond.php プロジェクト: alexukua/opus4
 /**
  * Build document publishing form whose fields depend on the choosen document type.
  * 
  * @return void
  */
 public function init()
 {
     parent::init();
     $this->setDisableTranslator(true);
     $this->doctype = $this->session->documentType;
     if (!isset($this->doctype) or empty($this->doctype)) {
         throw new Publish_Model_FormSessionTimeoutException();
     }
     $dom = null;
     try {
         // Fetch the current XML DOM structure of the documenttype.
         $dom = $this->documentTypesHelper->getDocument($this->doctype);
     } catch (Application_Exception $e) {
         $this->log->err("Unable to load document type '" . $this->doctype . "'");
         throw $e;
     }
     $this->additionalFields = $this->session->additionalFields;
     $parser = new Publish_Model_DocumenttypeParser($dom, $this, $this->additionalFields, $this->postData);
     $parser->parse();
     $parserElements = $parser->getFormElements();
     $this->log->debug("DocumenttypeParser (doctype '" . $this->doctype . "') found: " . count($parserElements) . " elements.");
     $this->addElements($parserElements);
     $this->addElements($this->getExternalElements());
     $this->addSubmitButton('button_label_send', 'send');
     $this->addSubmitButton('button_label_back', 'back');
     if (!is_null($this->postData)) {
         $this->populate($this->postData);
     }
     $this->setViewValues();
 }