Ejemplo n.º 1
0
 /**
  * Initialize model with the following fields:
  * - KeyName
  * - Value
  *
  * @return void
  */
 protected function _init()
 {
     $key = new Opus_Model_Field('KeyName');
     $key->setMandatory(true)->setValidator(new Zend_Validate_NotEmpty())->setSelection(true)->setDefault(Opus_EnrichmentKey::getAll());
     $value = new Opus_Model_Field('Value');
     $value->setMandatory(true)->setValidator(new Zend_Validate_NotEmpty());
     $this->addField($key);
     $this->addField($value);
 }
Ejemplo n.º 2
0
 /**
  * Shows list of all enrichmentkeys.
  */
 public function indexAction()
 {
     $this->view->title = $this->view->translate('admin_enrichmentkey_index');
     $enrichmentkeys = Opus_EnrichmentKey::getAll();
     if (!empty($enrichmentkeys)) {
         $this->view->protectedKeys = array_merge(Opus_EnrichmentKey::getAllReferenced(), $this->protectedEnrichmentkeys);
         $this->view->enrichmentkeys = array();
         foreach ($enrichmentkeys as $enrichmentkey) {
             $this->view->enrichmentkeys[$enrichmentkey->getName()] = $enrichmentkey->getDisplayName();
         }
     } else {
         return $this->renderScript('enrichmentkey/none.phtml');
     }
 }
Ejemplo n.º 3
0
 public function init()
 {
     parent::init();
     $options = Opus_EnrichmentKey::getAll();
     $values = array();
     $translator = $this->getTranslator();
     $this->setDisableTranslator(true);
     // keys are translated below if possible
     foreach ($options as $index => $option) {
         $keyName = $option->getName();
         $values[] = $keyName;
         $translationKey = 'Enrichment' . $keyName;
         if (!is_null($translator) && $translator->isTranslated($translationKey)) {
             $this->addMultiOption($keyName, $translator->translate($translationKey));
         } else {
             $this->addMultiOption($keyName, $keyName);
         }
     }
     $validator = new Zend_Validate_InArray($values);
     $validator->setMessage('validation_error_unknown_enrichmentkey');
     $this->addValidator($validator);
 }
$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();
        $newEnrichmentKey->setName($missingEnrichmentKeyName);
        $newEnrichmentKey->store();
    }
}
// Some Enrichment-Fields from Opus3-Migration
$doc->addEnrichment()->setKeyName('SourceSwb')->setValue('http://www.test.de');
$doc->addEnrichment()->setKeyName('SourceTitle')->setValue('Dieses Dokument ist auch erschienen als ...');
 public function testNewActionCancel()
 {
     $this->createsModels = true;
     $modelCount = count($this->getModels());
     $post = array('Name' => 'MyTestEnrichment', 'Cancel' => 'Abbrechen');
     $this->getRequest()->setPost($post)->setMethod('POST');
     $this->dispatch($this->getControllerPath() . '/new');
     $this->assertRedirectTo('/admin/enrichmentkey', 'Should be a redirect to index action.');
     $this->assertEquals($modelCount, count(Opus_EnrichmentKey::getAll()), 'There should be no new enrichment.');
 }
Ejemplo n.º 6
0
 public function testOptions()
 {
     $element = $this->getElement();
     $allOptions = Opus_EnrichmentKey::getAll();
     $this->assertEquals(count($allOptions), count($element->getMultiOptions()));
 }