public function testTranslationOfOpusSubjectFields() { $model = new Opus_Subject(); $fieldNames = $model->describe(); foreach ($fieldNames as $name) { $key = $this->helper->getKeyForField('Opus_Subject', $name); $this->assertTrue($this->translate->isTranslated($key), 'Translation key \'' . $key . '\' is missing.'); } }
/** * method to prepare a subject object for storing * @param <Opus_Document> $this->document * @param <Array> $formValues * @param <String> $dataKey current Element of formValues * @param <Array> $externalFields * @return <Array> $formValues */ private function storeSubjectObject($dataKey, $dataValue) { $type = $this->getSubjectType($dataKey); $this->_log->debug("subject is a " . $type); $counter = $this->getCounter($dataKey); $this->_log->debug("counter: " . $counter); $subject = new Opus_Subject(); if ($type === 'Swd') { $subject->setLanguage('deu'); } else { $index = 'Subject' . $type . 'Language' . '_' . $counter; $entry = $this->_documentData[$index]['value']; if ($entry !== "") { $subject->setLanguage($entry); } } $subject->setValue($dataValue); $subject->setType(strtolower($type)); try { $this->_document->addSubject($subject); } catch (Opus_Model_Exception $e) { $this->_log->err("could not add subject of type {$dataKey} with value {$dataValue} to document " . $this->_docId . " : " . $e->getMessage()); throw new Publish_Model_Exception(); } }
/** * Überträgt die Werte im Formular in ein Opus_Subject Objekt. * @param \Opus_Subject $subject */ public function updateModel($subject) { $subject->setLanguage($this->getElementValue(self::ELEMENT_LANGUAGE)); $subject->setValue($this->getElementValue(self::ELEMENT_VALUE)); $subject->setExternalKey($this->getElementValue(self::ELEMENT_EXTERNAL_KEY)); $subject->setType($this->_subjectType); }
private function addSampleDocWithMultipleSubjects($numOfSubjects = 0) { $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setLanguage('eng'); $title = new Opus_Title(); $title->setValue('facetlimittestwithsubjects-opusvier2610'); $title->setLanguage('eng'); $doc->addTitleMain($title); for ($index = 0; $index < $numOfSubjects; $index++) { $subject = new Opus_Subject(); if ($index < 10) { $subject->setValue('subject' . '0' . $index); } else { $subject->setValue('subject' . $index); } $subject->setType('uncontrolled'); $subject->setLanguage('eng'); $doc->addSubject($subject); } $doc->store(); return $doc; }
/** * * @param DOMNode $node * @param Opus_Document $doc */ private function handleKeywords($node, $doc) { foreach ($node->childNodes as $childNode) { if ($childNode instanceof DOMElement) { $s = new Opus_Subject(); $s->setLanguage(trim($childNode->getAttribute('language'))); $s->setType($childNode->getAttribute('type')); $s->setValue(trim($childNode->textContent)); $doc->addSubject($s); } } }