public function testUpdateOnLicenceChange()
 {
     $document = $this->createTestDocument();
     $document->store();
     $documentCacheTable = new Opus_Db_DocumentXmlCache();
     $docXmlCache = $documentCacheTable->find($document->getId(), '1')->current()->xml_data;
     $domDoc = new DomDocument();
     $domDoc->loadXML($docXmlCache);
     $licences = $domDoc->getElementsByTagName('Licence');
     $this->assertTrue($licences->length == 0, 'Expected no Licence element in dom.');
     $licence = new Opus_Licence();
     $licence->setNameLong('TestLicence');
     $licence->setLinkLicence('http://example.org/licence');
     $licenceId = $licence->store();
     $document->setServerState('published');
     $document->setLicence($licence);
     $docId = $document->store();
     $licence = new Opus_Licence($licenceId);
     $licence->setNameLong('TestLicenceAltered');
     $licence->store();
     $docXmlCacheResult = $documentCacheTable->find($document->getId(), '1');
     $this->assertTrue($docXmlCacheResult->count() == 0, 'Expected empty document xml cache');
     $this->executeScript('cron-update-document-cache.php');
     $docXmlCacheAfter = $documentCacheTable->find($docId, '1')->current()->xml_data;
     $domDocAfter = new DomDocument();
     $domDocAfter->loadXML($docXmlCacheAfter);
     $licencesAfter = $domDocAfter->getElementsByTagName('Licence');
     $this->assertTrue($licencesAfter->length == 1, 'Expected one Licence element in dom.');
     $licences = $document->getLicence();
     $licences[0]->delete();
 }
Ejemplo n.º 2
0
 public function testSetGetModelsNull()
 {
     $form = new Application_Form_Model_Table();
     $form->setModels(Opus_Licence::getAll());
     $this->assertNotNull($form->getModels());
     $form->setModels(null);
     $this->assertNull($form->getModels());
 }
Ejemplo n.º 3
0
 public function testPopulateFromModel()
 {
     $form = new Admin_Form_Document_Licences();
     $document = new Opus_Document(146);
     $form->populateFromModel($document);
     $licences = Opus_Licence::getAll();
     foreach ($licences as $licence) {
         $element = $form->getElement('licence' . $licence->getId());
         // Nur Lizenz mit ID = 4 ist gesetzt fuer Dokument 146
         if ($licence->getId() == 4) {
             $this->assertEquals(4, $element->getValue(), 'Lizenz ' . $licence->getId() . ' nicht gesetzt.');
         } else {
             $this->assertEquals(0, $element->getValue(), 'Lizenz ' . $licence->getId() . ' gesetzt.');
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Erzeugt Checkbox Formularelemente für alle Lizenzen.
  */
 public function init()
 {
     parent::init();
     $licences = Opus_Licence::getAll();
     foreach ($licences as $licence) {
         $element = new Form_Element_Checkbox(self::ELEMENT_NAME_PREFIX . $licence->getId());
         $element->setDisableTranslator(true);
         // Lizenzen werden nicht übersetzt
         $element->setLabel($licence->getNameLong());
         $cssClass = $licence->getActive() ? self::ACTIVE_CSS_CLASS : self::INACTIVE_CSS_CLASS;
         $labelDecorator = $element->getDecorator('Label');
         $labelDecorator->setOption('class', $cssClass);
         $element->setCheckedValue($licence->getId());
         $this->addElement($element);
     }
     $this->setLegend('admin_document_section_licences');
 }
$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";
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 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->setContributingCorporation('Pixar Animation Studio');
$swd = $doc->addSubject()->setType('swd');
$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)) {
Ejemplo n.º 9
0
 public function testRenderQuestionEscaped()
 {
     $licence = new Opus_Licence();
     $licence->setNameLong('<h1>Name mit Tags</h1>');
     $this->form->setModel($licence);
     $this->assertNotContains('<h1>Name mit Tags</h1>', $this->form->renderQuestion());
     $this->assertContains('&lt;h1&gt;Name mit Tags&lt;/h1&gt;', $this->form->renderQuestion());
 }
Ejemplo n.º 10
0
 /**
  * return the available licences from registry, database or chache
  * @return <Array> languages
  */
 private function getLicences()
 {
     $licences = array();
     if (empty($this->licences)) {
         foreach ($dbLicences = Opus_Licence::getAll() as $lic) {
             if ($lic->getActive() == '1') {
                 $name = $lic->getDisplayName();
                 $id = $lic->getId();
                 $licences[$id] = $name;
             }
         }
         $this->licences = $licences;
         return $licences;
     } else {
         return $this->licences;
     }
 }
Ejemplo n.º 11
0
 /**
  * Tests that the sort order of the licences in the publish form matches
  * the sort order provided from the database.
  */
 public function testSortOrderOfSelectOptionForLicence()
 {
     $licences = Opus_Licence::getAll();
     $activeLicences = array();
     foreach ($licences as $licence) {
         if ($licence->getActive() == '1') {
             $activeLicences[] = $licence->getDisplayName();
         }
     }
     $val = new Publish_Model_Validation('Licence', $this->session);
     $values = $val->selectOptions();
     $this->assertEquals(count($values), count($activeLicences));
     $pos = 0;
     foreach ($values as $name) {
         $this->assertEquals($name, $activeLicences[$pos]);
         $pos++;
     }
 }
Ejemplo n.º 12
0
 public function testNumberLicencesAfterMigration()
 {
     $this->assertEquals(10, count(Opus_Licence::getAll()));
 }
 public function createNewModel()
 {
     $licence = new Opus_Licence();
     $licence->setNameLong('Test Licence (LicenceControllerTest::testDeleteAction)');
     $licence->setLinkLicence('testlink');
     $licence->setLanguage('rus');
     return $licence->store();
 }
Ejemplo n.º 14
0
 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']);
 }