本文整理汇总了PHP中Opus_Document::getLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Opus_Document::getLanguage方法的具体用法?PHP Opus_Document::getLanguage怎么用?PHP Opus_Document::getLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opus_Document
的用法示例。
在下文中一共展示了Opus_Document::getLanguage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMainTitle
/**
* 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() . ')';
}
}
示例2: prepareMail
/**
*
* @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");
}
示例3: getFrontdoorTitle
/**
*
* @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;
}
示例4: foreach
/**
*
* 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() . ' ';
}
示例5: foreach
* @copyright Copyright (c) 2008-2012, OPUS 4 development team
* @license http://www.gnu.org/licenses/gpl.html General Public License
* @version $Id: find_docs_without_titles_in_doclanguage.php 11775 2013-06-25 14:28:41Z tklein $
*/
/**
* Dieses Skript gibt alle IDs der Dokumente zurück, die keinen Titel
* in der Sprache des Dokuments besitzen.
*
* Diese Dokumente werden in der Trefferansicht als "Unbekanntes Dokument" angezeigt.
*
*/
$updateRequired = 0;
$docfinder = new Opus_DocumentFinder();
foreach ($docfinder->ids() as $docId) {
$doc = new Opus_Document($docId);
foreach ($doc->getTitleMain() as $title) {
$titleLanguage = $title->getLanguage();
$docLanguage = $doc->getLanguage();
}
$lang = strpbrk($docLanguage, $titleLanguage);
if ($lang === false) {
echo "Dokument {$doc} muss überprueft werden.\n";
$updateRequired++;
}
}
if ($updateRequired == 0) {
echo "Alle Dokumente wurden überprüft -- alles ok!\n";
} else {
echo "Alle Dokumente wurden überprüft -- Anzahl der Dokumente, die keinen Titel in der Sprache des Dokuments besitzen: {$updateRequired} !\n";
}
exit;
示例6: populateFromModel
/**
* Befuellt das Formular anhand der Metadaten eines Dokuments.
* @param Opus_Document $document
*/
public function populateFromModel($document)
{
$datesHelper = $this->getDatesHelper();
$this->getElement(self::ELEMENT_LANGUAGE)->setValue($document->getLanguage());
$this->getElement(self::ELEMENT_TYPE)->setValue($document->getType());
$date = $datesHelper->getDateString($document->getCompletedDate());
$this->getElement(self::ELEMENT_COMPLETED_DATE)->setValue($date);
$this->getElement(self::ELEMENT_COMPLETED_YEAR)->setValue($document->getCompletedYear());
$date = $datesHelper->getDateString($document->getPublishedDate());
$this->getElement(self::ELEMENT_PUBLISHED_DATE)->setValue($date);
$this->getElement(self::ELEMENT_PUBLISHED_YEAR)->setValue($document->getPublishedYear());
$date = $datesHelper->getDateString($document->getEmbargoDate());
$this->getElement(self::ELEMENT_EMBARGO_DATE)->setValue($date);
}
示例7: testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates
/**
* 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());
}