public function testPopulateFromModel() { $form = new Admin_Form_Licence(); $licence = new Opus_Licence(); $licence->setActive(true); $licence->setCommentInternal('Test Internal Comment'); $licence->setDescMarkup('<h1>Test Markup</h1>'); $licence->setDescText('Test Description'); $licence->setLanguage('rus'); $licence->setLinkLicence('http://www.example.org/licence'); $licence->setLinkLogo('http://www.example.org/logo'); $licence->setMimeType('text/plain'); $licence->setNameLong('Test Licence'); $licence->setSortOrder(3); $licence->setPodAllowed(false); $form->populateFromModel($licence); $this->assertTrue($form->getElement('Active')->getValue()); $this->assertEquals('Test Internal Comment', $form->getElement('CommentInternal')->getValue()); $this->assertEquals('<h1>Test Markup</h1>', $form->getElement('DescMarkup')->getValue()); $this->assertEquals('Test Description', $form->getElement('DescText')->getValue()); $this->assertEquals('rus', $form->getElement('Language')->getValue()); $this->assertEquals('http://www.example.org/licence', $form->getElement('LinkLicence')->getValue()); $this->assertEquals('http://www.example.org/logo', $form->getElement('LinkLogo')->getValue()); $this->assertEquals('text/plain', $form->getElement('MimeType')->getValue()); $this->assertEquals('Test Licence', $form->getElement('NameLong')->getValue()); $this->assertEquals(3, $form->getElement('SortOrder')->getValue()); $this->assertEquals(0, $form->getElement('PodAllowed')->getValue()); }
$doc->setThesisPublisher($dnbInstitute); // // Subjects // $doc->addSubject()->setType('swd')->setValue(randString($counter++)); foreach (array('uncontrolled', 'msc', 'ddc') as $type) { $doc->addSubject()->setType($type)->setLanguage(randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++)); $doc->addSubject()->setType($type)->setLanguage("eng" . randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++)); $doc->addSubject()->setType($type)->setLanguage("deu")->setValue(randString($counter++))->setExternalKey(randString($counter++)); $doc->addSubject()->setType($type)->setLanguage("eng")->setValue(randString($counter++))->setExternalKey(randString($counter++)); } // // Notes // $doc->addNote()->setVisibility('public')->setMessage(randString($counter++)); $doc->addNote()->setVisibility('private')->setMessage(randString($counter++)); // // Licenses // $lic = new Opus_Licence(); $lic->setActive(1); $lic->setLanguage('deu' . randString($counter++)); $lic->setLinkLicence(randString($counter++)); $lic->setNameLong(randString($counter++)); $lic->store(); $doc->setLicence($lic); // // Storing... // $doc->store(); print "Document stored. ID: " . $doc->getId() . "\n";
/** * transfers any OPUS3-conform classification System into an array * * @param DOMDocument $data XML-Document to be imported * @return array List of documents that have been imported */ protected function transferOpus3Licence($data) { //$classification = array(); $doclist = $data->getElementsByTagName('row'); $licenses = array(); foreach ($doclist as $document) { $lic = new Opus_Licence(); $shortname = ""; foreach ($document->getElementsByTagName('field') as $field) { if ($field->nodeValue === '') { continue; } if ($field->getAttribute('name') === 'active') { $lic->setActive($field->nodeValue); } if ($field->getAttribute('name') === 'comment') { $lic->setCommentInternal($field->nodeValue); } if ($field->getAttribute('name') === 'desc_html') { $lic->setDescMarkup($field->nodeValue); } if ($field->getAttribute('name') === 'desc_text') { $lic->setDescText(html_entity_decode($field->nodeValue, ENT_COMPAT, 'UTF-8')); } if ($field->getAttribute('name') === 'language') { $lic->setLanguage($this->mapLanguage($field->nodeValue)); } if ($field->getAttribute('name') === 'link') { $lic->setLinkLicence($field->nodeValue); } if ($field->getAttribute('name') === 'logo') { $lic->setLinkLogo($field->nodeValue); } if ($field->getAttribute('name') === 'link_tosign') { $lic->setLinkSign($field->nodeValue); } if ($field->getAttribute('name') === 'mime_type') { $lic->setMimeType($field->nodeValue); } if ($field->getAttribute('name') === 'longname') { $lic->setNameLong(html_entity_decode($field->nodeValue, ENT_COMPAT, 'UTF-8')); } if ($field->getAttribute('name') === 'pod_allowed') { $lic->setPodAllowed($field->nodeValue); } //if ($field->getAttribute('name') === 'sort') $lic->setSortOrder($field->nodeValue); if ($field->getAttribute('name') === 'shortname') { $shortname = $field->nodeValue; } } $this->checkMandatoryFields($lic, $shortname); $this->maxSortOrder++; $lic->setSortOrder($this->maxSortOrder); $licenses[$shortname] = $lic; } return $licenses; }
$swd->setValue('Test'); $freeSubjectDeu = $doc->addSubject()->setType('uncontrolled'); $freeSubjectDeu->setLanguage('deu')->setValue('Maustest'); $freeSubjectEng = $doc->addSubject()->setType('uncontrolled'); $freeSubjectEng->setLanguage('eng')->setValue('mouse test'); $note = $doc->addNote(); $note->setVisibility('public')->setMessage('ein Dokument, dass noch eine Bemerkung braucht, weil im Abstract nicht alles gesagt wurde...'); $noteTwo = $doc->addNote(); $noteTwo->setVisibility('private')->setMessage('und noch eine Bemerkung zum Bearbeitungsstand.'); $licences = Opus_Licence::getAll(); if (count($licences) >= 1) { $lic = $licences[0]; } else { $lic = new Opus_Licence(); $lic->setActive(1); $lic->setLanguage('deu'); $lic->setLinkLicence('http://www.test.de'); $lic->setNameLong('Ein langer LizenzName'); $lic->store(); } $doc->setLicence($lic); // check for enrichment keys before creating enrichments $enrichmentKeys = Opus_EnrichmentKey::getAll(); $enrichmentKeyNames = array(); foreach ($enrichmentKeys as $enrichmentKey) { $enrichmentKeyNames[] = $enrichmentKey->getName(); } $missingEnrichmentKeyNames = array_diff(array('SourceSwb', 'SourceTitle', 'ClassRvk', 'ContributorsName', 'Event', 'City', 'Country'), $enrichmentKeyNames); if (!empty($missingEnrichmentKeyNames)) { foreach ($missingEnrichmentKeyNames as $missingEnrichmentKeyName) { $newEnrichmentKey = new Opus_EnrichmentKey();
public function createNewModel() { $licence = new Opus_Licence(); $licence->setNameLong('Test Licence (LicenceControllerTest::testDeleteAction)'); $licence->setLinkLicence('testlink'); $licence->setLanguage('rus'); return $licence->store(); }
public function testHandleConfirmationPostYes() { $licence = new Opus_Licence(); $licence->setNameLong(__METHOD__); $licence->setLanguage('deu'); $licence->setLinkLicence('www.example.org/licence'); $licenceId = $licence->store(); $result = $this->controller->handleConfirmationPost(array('Id' => $licenceId, 'ConfirmYes' => 'Ja')); $this->assertNotNull($result); $this->assertInternalType('array', $result); $this->assertEquals(1, count($result)); $this->assertArrayHasKey('message', $result); $this->assertEquals(Application_Controller_ActionCRUD::DELETE_SUCCESS, $result['message']); }