public function indexAction() { $docId = $this->getRequest()->getParam("docId"); if (isset($docId) === FALSE) { throw new Exception("docId must be set"); } $this->view->docId = $docId; $document = new Opus_Document($docId); $titles = $document->getTitleMain(); $authors = $document->getPersonAuthor(); $session = new Zend_Session_Namespace(); if (isset($session->language)) { $language = $session->language; } else { $language = 'en'; } foreach ($titles as $title) { if ($title->getLanguage() == $language) { $this->view->title = $title->getValue(); } } $authorsArray = array(); foreach ($authors as $author) { $authorsArray[] = $author->getName(); } $this->view->authors = implode(', ', $authorsArray); //get statistics from db for total count and for image tag (accessibility) $statistic = Opus_Statistic_LocalCounter::getInstance(); $totalAbstractPage = $statistic->readTotal($docId, 'frontdoor'); $totalFiles = $statistic->readTotal($docId, 'files'); $yearAbstractPage = $statistic->readYears($docId, 'frontdoor'); $yearFiles = $statistic->readYears($docId, 'files'); $this->view->totalAbstractPage = $totalAbstractPage; $this->view->totalFiles = $totalFiles; $years = array_merge(array_keys($yearAbstractPage), array_keys($yearFiles)); if (count($years) == 0) { $years = array(date('Y')); } foreach ($years as $year) { if (isset($yearFiles[$year]) === false) { $yearFiles[$year] = 0; } if (isset($yearAbstractPage[$year]) === false) { $yearAbstractPage[$year] = 0; } } ksort($yearFiles); ksort($yearAbstractPage); foreach (array_keys($yearAbstractPage) as $year) { $lines[] = $year . ': ' . $yearAbstractPage[$year] . ', ' . $yearFiles[$year]; } $this->view->altTextStat = implode('; ', $lines); }
public function testGetModel() { $form = new Admin_Form_Document_Title(); $doc = new Opus_Document(146); $titles = $doc->getTitleMain(); $title = $titles[0]; $form->getElement('Id')->setValue($title->getId()); $form->getElement('Type')->setValue('parent'); $form->getElement('Language')->setValue('rus'); $form->getElement('Value')->setValue('Test Title'); $model = $form->getModel(); $this->assertEquals($title->getId(), $model->getId()); $this->assertEquals('parent', $model->getType()); $this->assertEquals('rus', $model->getLanguage()); $this->assertEquals('Test Title', $model->getValue()); }
/** * Returns title in document language. */ public function getMainTitle() { $titles = $this->document->getTitleMain(); $language = $this->document->getLanguage(); if (count($titles) > 0) { foreach ($titles as $title) { if ($language === $title->getLanguage()) { return $title->getValue(); } } // if no title in document language ist found use first title return $titles[0]->getValue(); } else { return Zend_Registry::get('Zend_Translate')->translate('document_no_title') . '(id = ' . $this->getDocId() . ')'; } }
/** * * @param Opus_Document $document das Dokument auf das sich die Notifizierung bezieht * @param String $context Notifizierungskontext * @param String $url vollständiger Deeplink, der in der Mail angezeigt werden soll * @param boolean $notifySubmitter Wenn false, wird der Submitter nicht notifiziert * @param array $notifyAuthors Bitmaske, die für jeden Autor (über den Index referenziert) angibt, ob ihm/ihr eine * E-Mail gesendet werden kann (wenn false, dann wird keine Notifizierung versendet) */ public function prepareMail($document, $context, $url, $notifySubmitter = true, $notifyAuthors = array()) { if (!$this->validateContext($context)) { $this->logger->err("context {$context} is currently not supported or delivery of notification mails is not" . ' enabled for the current context'); return; } $this->logger->info("prepare {$context} notification email for document id " . $document->getId()); $authorAddresses = array(); $authors = array(); $title = ""; $personAuthors = $document->getPersonAuthor(); if (!empty($personAuthors)) { $index = 0; foreach ($personAuthors as $author) { $name = trim($author->getLastName() . ", " . $author->getFirstName()); // TODO Komma nur wenn FirstName present array_push($authors, $name); if ($context == self::PUBLICATION) { $email = trim($author->getEmail()); if (!empty($email) && (empty($notifyAuthors) || isset($notifyAuthors[$index]) && $notifyAuthors[$index])) { array_push($authorAddresses, array("name" => $name, "address" => $email)); } } $index++; } } // TODO Funktionalität existiert bereits (Documents Helper oder so) $titlesMain = $document->getTitleMain(); if (!empty($titlesMain)) { // ermittle (den ersten) TitleMain in Dokumentsprache $language = $document->getLanguage(); foreach ($titlesMain as $titleMain) { if ($titleMain->getLanguage() == $language) { $title = trim($titleMain->getValue()); break; } } } $this->scheduleNotification($this->getMailSubject($context, $document->getId(), $authors, $title), $this->getMailBody($context, $document->getId(), $authors, $title, $url), $this->getRecipients($context, $authorAddresses, $document, $notifySubmitter)); $this->logger->info("{$context} notification mail creation was completed successfully"); }
/** * Render body of notification mail. * * @param string $baseUrlServer * @param string $baseUrlFiles * @return string */ public function renderPublishMailBody($baseUrlServer, $baseUrlFiles) { $baseUrlServer = preg_replace('/[\\/]+$/', '', $baseUrlServer); $baseUrlFiles = preg_replace('/[\\/]+$/', '', $baseUrlFiles); $loggedUserModel = new Publish_Model_LoggedUser(); $person = $loggedUserModel->createPerson(); $submitterString = ''; if (!is_null($person) and $person->isValid()) { $submitterString = trim($person->getFirstName() . " " . $person->getLastName()); } $titleModels = $this->_document->getTitleMain(); $titleString = ''; if (count($titleModels) > 0) { $titleString = trim($titleModels[0]->getValue()); } $abstractModels = $this->_document->getTitleAbstract(); $abstractString = ''; if (count($abstractModels) > 0) { $abstractString = trim($abstractModels[0]->getValue()); } $template = new Matheon_Model_Template(); $template->template = APPLICATION_PATH . '/modules/matheon/models/confirmation-mail.template'; return $template->render(array('baseUrlServer' => $baseUrlServer, 'baseUrlFiles' => $baseUrlFiles, 'docId' => $this->getId(), 'submitterString' => $submitterString, 'titleString' => $titleString, 'abstractString' => $abstractString, 'files' => $this->_document->getFile())); }
/** * * @param Opus_Document $document * @return string */ private function getFrontdoorTitle($document) { $titlesMain = $document->getTitleMain(); if (count($titlesMain) == 0) { return ''; } $docLanguage = $document->getLanguage(); $docLanguage = is_array($docLanguage) ? $docLanguage : array($docLanguage); $firstNonEmptyTitle = ''; foreach ($titlesMain as $title) { $titleValue = trim($title->getValue()); if (strlen($titleValue) == 0) { continue; } if (in_array($title->getLanguage(), $docLanguage)) { return $titleValue; } if ($firstNonEmptyTitle == '') { $firstNonEmptyTitle = $titleValue; } } return $firstNonEmptyTitle; }
*/ /** * * Dieses Skript gibt alle IDs der Dokumente zurück, die mehr als einen Titel * und/oder Abstract in der Sprache des Dokuments besitzen. * * Diese Dokumente müssen aktuell manuell behandelt werden, da das Dokument * sonst nicht fehlerfrei indexiert werden kann (siehe OPUSVIER-2240). * */ $updateRequired = 0; $docfinder = new Opus_DocumentFinder(); foreach ($docfinder->ids() as $docId) { $doc = new Opus_Document($docId); $numOfTitles = 0; foreach ($doc->getTitleMain() as $title) { if ($title->getLanguage() === $doc->getLanguage()) { $numOfTitles++; } } $numOfAbstracts = 0; foreach ($doc->getTitleAbstract() as $abstract) { if ($abstract->getLanguage() === $doc->getLanguage()) { $numOfAbstracts++; } } if ($numOfTitles > 1 || $numOfAbstracts > 1) { $msg = "document #{$docId} ("; $opusThreeId = $doc->getIdentifierOpus3(); if (count($opusThreeId) > 0) { $msg .= 'opus3id #' . $opusThreeId[0]->getValue() . ' ';
/** * Regression test for OPUSVIER-2165 * * if database contains more than one title in the document's language, * the first title is used as page title */ public function testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates() { $d = new Opus_Document(146); $lang = $d->getLanguage(); $d->setLanguage('deu'); $titles = $d->getTitleMain(); $d->addTitleMain()->setValue('VBOK')->setLanguage('deu'); $d->store(); $this->dispatch('/frontdoor/index/index/docId/146'); // restore language // restore titles $d = new Opus_Document(146); $d->setLanguage($lang); $d->setTitleMain($titles); $d->store(); $this->assertNotContains('<title>OPUS 4 | COLN</title>', $this->getResponse()->getBody()); $this->assertNotContains('<title>OPUS 4 | VBOK</title>', $this->getResponse()->getBody()); $this->assertContains('<title>OPUS 4 | KOBV</title>', $this->getResponse()->getBody()); }