Ejemplo n.º 1
0
 public function renderAuthor(array $authors)
 {
     $output = [];
     $separator = ' & ';
     $format = AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::GIVEN_NAME_ABBR_ALL | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL;
     $formatter = new AuthorFormatter($format);
     foreach ($authors as $a) {
         $author = new Author(['givenName' => $a->given, 'familyName' => $a->family]);
         $output[] = $author->format($formatter);
     }
     return Html::encode(implode($separator, $output));
 }
Ejemplo n.º 2
0
 /**
  * Renders author component
  *
  * @return string
  */
 function render()
 {
     $authors = empty($this->reference->{'author'}) ? [] : $this->reference->{'author'};
     if (empty($authors)) {
         return 'S.a.';
     }
     $output = [];
     $separator = ' & ';
     $format = AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::GIVEN_NAME_ABBR_ALL | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL;
     $formatter = new AuthorFormatter($format);
     foreach ($authors as $a) {
         $author = new AuthorNormalizer(['givenName' => $a->given, 'familyName' => $a->family]);
         $output[] = $author->format($formatter);
     }
     return implode($separator, $output);
 }
 /**
  * @group authorformatter
  */
 public function testFormatStandardCase()
 {
     $authorString = 'Fuss-schnarrenberger, Carl-Friedrich-Peter Amar-Thomas Manfredo [= Fuss-Schnarchenberger, Karl-Friedrich]';
     $caseFormatMap = [10 => ['format' => AuthorFormatter::SEQ_FAMILY | AuthorFormatter::CAPITALIZATION_AS_IS, 'result' => 'Fuss-schnarrenberger'], 11 => ['format' => AuthorFormatter::SEQ_FAMILY | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger'], 12 => ['format' => AuthorFormatter::SEQ_FAMILY | AuthorFormatter::CAPITALIZATION_ALL_UPPERCASE, 'result' => 'FUSS-SCHNARRENBERGER'], 13 => ['format' => AuthorFormatter::SEQ_FAMILY | AuthorFormatter::CAPITALIZATION_SMALL_CAPS, 'result' => 'FUSS-SCHNARRENBERGER'], 14 => ['format' => AuthorFormatter::SEQ_FAMILY | AuthorFormatter::CAPITALIZATION_AS_IS | AuthorFormatter::ALTERNATIVE_NAMES_INSTEAD, 'result' => 'Fuss-Schnarchenberger'], 15 => ['format' => AuthorFormatter::SEQ_GIVEN_BLANK_FAMILY | AuthorFormatter::CAPITALIZATION_AS_IS, 'result' => 'Carl-Friedrich-Peter Amar-Thomas Manfredo Fuss-schnarrenberger'], 16 => ['format' => AuthorFormatter::SEQ_FAMILY_BLANK_GIVEN | AuthorFormatter::CAPITALIZATION_AS_IS, 'result' => 'Fuss-schnarrenberger Carl-Friedrich-Peter Amar-Thomas Manfredo'], 17 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::CAPITALIZATION_AS_IS, 'result' => 'Fuss-schnarrenberger, Carl-Friedrich-Peter Amar-Thomas Manfredo'], 18 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter Amar-Thomas Manfredo'], 19 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter Amar-Thomas'], 20 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_ALL | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, C.-F.-P. A.-T. M.'], 21 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_FROM_SECOND | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter A.-T. M.'], 22 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_FROM_SECOND | AuthorFormatter::GIVEN_NAME_FIRST | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter'], 23 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_FROM_SECOND | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter A.-T.'], 24 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_FROM_SECOND | AuthorFormatter::GIVEN_NAME_THIRD | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, Carl-Friedrich-Peter A.-T. M.'], 25 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_ALL | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::ALTERNATIVE_NAMES_SUPPRESS | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarrenberger, C.-F.-P. A.-T.'], 27 => ['format' => AuthorFormatter::SEQ_FAMILY_COMMA_GIVEN | AuthorFormatter::GIVEN_NAME_ABBR_ALL | AuthorFormatter::GIVEN_NAME_SECOND | AuthorFormatter::ALTERNATIVE_NAMES_INSTEAD | AuthorFormatter::CAPITALIZATION_NORMAL, 'result' => 'Fuss-Schnarchenberger, K.-F.']];
     foreach ($caseFormatMap as $caseIndex => $testCase) {
         $formatter = new AuthorFormatter($testCase['format']);
         $author = Author::initWithString($authorString, $formatter);
         $this->assertEquals($testCase['result'], $author->format(), "Case #{$caseIndex}");
     }
 }
Ejemplo n.º 4
0
 public function mapArticleJournal()
 {
     $reference = (object) [];
     $authorsStrings = explode("\n", $this->_model->authors);
     foreach ($authorsStrings as $authorString) {
         $author = Author::initWithString($authorString);
         if (!isset($reference->{'author'})) {
             $reference->{'author'} = [];
         }
         $reference->{'author'}[] = (object) ['family' => $author->familyName, 'given' => $author->givenName];
     }
     $reference->{'id'} = $this->_model->id;
     $reference->{'type'} = 'article-journal';
     $reference->{'title'} = $this->_model->title;
     $reference->{'container-title'} = $this->_model->secondaryTitle;
     $reference->{'publisher'} = $this->_model->publisher;
     $reference->{'publisher-place'} = $this->_model->place;
     // locater is not implemented in citeproc-php...
     $reference->{'locater'} = 'page';
     $reference->{'volume'} = $this->_model->volume;
     $reference->{'issue'} = $this->_model->number;
     $reference->{'page'} = $this->_model->pages;
     $reference->{'number_of_pages'} = $this->_model->pages;
     $reference->{'page-first'} = $this->_model->section;
     $reference->{'ISSN'} = $this->_model->isbn;
     $reference->{'issued'} = (object) ["date-parts" => [[$this->_model->year]], "literal" => $this->_model->year];
     return $reference;
 }
Ejemplo n.º 5
0
 /**
  * @group author
  */
 public function testCorporateName_2()
 {
     $authorString = 'Landesamt für Strahlenschäden an der Umwelt, [= Umweltamt für Strahlung,]';
     $author = Author::initWithString($authorString);
     $this->assertNull($author->familyName);
     $this->assertNull($author->givenName);
     $this->assertNull($author->altFamilyName);
     $this->assertNull($author->altGivenName);
     $this->assertEquals('Landesamt für Strahlenschäden an der Umwelt', $author->corporateName);
     $this->assertEquals('Umweltamt für Strahlung', $author->altCorporateName);
 }