コード例 #1
0
ファイル: MySource.php プロジェクト: k-hasan-19/wiki
 public function getCitationText($makeLink = false)
 {
     $result = '';
     if (isset($this->xml->author)) {
         $result .= trim((string) $this->xml->author);
     }
     if ($result) {
         $result = StructuredData::chomp($result, '.') . '. ';
     }
     $result .= '<i>' . $this->getMySourceTitle() . '</i>';
     if ($makeLink) {
         $result = preg_replace("/\\[\\[(.+?\\|(.+?)|([^\\|]+?))\\]\\]/", "\$2\$3", $result);
         $result = "[[MySource:{$this->titleString}|{$result}]]";
     }
     if (isset($this->xml->publication_info)) {
         $result = StructuredData::chomp($result, '.') . '. (' . trim((string) $this->xml->publication_info) . ')';
     }
     return StructuredData::chomp($result, '.');
 }
コード例 #2
0
ファイル: ESINHandler.php プロジェクト: k-hasan-19/wiki
 protected function formatSourceCitation($sourceCitation, $xml, $parser)
 {
     global $wgCite;
     $citation = $this->getSourceCitationText($sourceCitation);
     //      $notes = StructuredData::formatAsLinks((string)$sourceCitation['notes']);
     //      $images = StructuredData::formatAsLinks((string)$sourceCitation['images']);
     //      $refs = '';
     //      if ($notes || $images) {
     //         $refs = ' <sup>' . $images . ($notes && $images ? ', ' : '') . $notes . '</sup>';
     //      }
     $text = (string) $sourceCitation['text'];
     $text .= (string) $sourceCitation;
     // get from both until we standardize on the latter
     //      if ($text) {
     //         $text = " <span class=\"wr-infotable-text\">$text</span>";
     //      }
     $text = trim(str_replace("\n", "<br>", $text));
     // hack - parser call in cite translates \n to '', so add spaces
     if ($text) {
         $text = "\n<div class=\"wr-citation-text\">\n{$text}\n</div>\n";
     }
     // <code> tag must be at begin of line for parser to handle it properly
     $notes = '';
     $cites = $this->getCites((string) $sourceCitation['notes']);
     foreach ($cites as $cite) {
         foreach ($xml->note as $note) {
             if ($cite == (string) $note['id']) {
                 // get note text from both until we standardize on the latter
                 $noteText = (string) $note['text'];
                 $noteText .= (string) $note;
                 $noteText = trim(str_replace("\n", "<br>", $noteText));
                 $notes .= "\n<div class=\"wr-citation-sourcenote\">\n{$noteText}\n</div>\n";
                 // <code> tag must be at begin of line for parser to handle it properly
             }
         }
     }
     $images = '';
     $cites = $this->getCites((string) $sourceCitation['images']);
     foreach ($cites as $cite) {
         foreach ($xml->image as $image) {
             if ($cite == (string) $image['id']) {
                 $images .= $this->formatImage($image, true);
             }
         }
     }
     if ($images) {
         $images = '<div class="wr-citation-images">' . $images . '</div>';
     }
     return StructuredData::chomp($citation, '.') . '. ' . $text . ' ' . $notes . $images;
     //      return <<<END
     //<tr id="$id">
     //   <td class="wr-infotable-id $firstChildClass"><span class="wr-infotable-id">$id.</span></td>
     //   <td class="wr-infotable-citation $firstChildClass"><span class="wr-infotable-citation">$citation.</span>$refs$text</td>
     //</tr>
     //END;
 }
コード例 #3
0
ファイル: Source.php プロジェクト: k-hasan-19/wiki
 public function getCitationText($makeLink = false, $altTitle = null)
 {
     $result = '';
     $type = '';
     if (isset($this->xml->source_type)) {
         $type = (string) $this->xml->source_type;
     }
     if (isset($this->xml->author)) {
         $authors = array();
         foreach ($this->xml->author as $author) {
             $authorString = (string) $author;
             if (count($authors) > 0) {
                 $pos = mb_strpos($authorString, ',');
                 if ($pos !== false) {
                     $authorString = trim(mb_substr($authorString, $pos + 1)) . ' ' . trim(mb_substr($authorString, 0, $pos));
                 }
             }
             $authors[] = trim($authorString);
         }
         if (count($authors) == 1) {
             $result .= $authors[0];
         } else {
             if (count($authors) == 2) {
                 $result .= StructuredData::chomp($authors[0], ',') . ', and ' . $authors[1];
             } else {
                 if (count($authors) > 2) {
                     for ($i = 0; $i < count($authors); $i++) {
                         if ($i == count($authors) - 1) {
                             $result = StructuredData::chomp($result, ';') . '; and ';
                         } else {
                             if ($i > 0) {
                                 $result = StructuredData::chomp($result, ';') . '; ';
                             }
                         }
                         $result .= $authors[$i];
                     }
                 }
             }
         }
     } else {
         if ($type == 'Government / Church records' || $type == 'Newspaper') {
             foreach ($this->xml->place as $place) {
                 $p = (string) $place;
                 $pos = mb_strpos($p, '|');
                 if ($pos !== false) {
                     $p = mb_substr($p, $pos + 1);
                 }
                 $result .= $p;
                 break;
             }
         }
     }
     if (isset($this->xml->source_title)) {
         $sourceTitle = StructuredData::chomp((string) $this->xml->source_title, '.');
     } else {
         $sourceTitle = StructuredData::chomp($this->titleString, '.');
     }
     if ($result) {
         $result = StructuredData::chomp($result, '.') . '. ';
     }
     $result .= "<i>{$sourceTitle}</i>";
     if (isset($this->xml->subtitle)) {
         $result .= ': <i>' . StructuredData::chomp((string) $this->xml->subtitle, '.') . '</i>';
     }
     if ($makeLink) {
         $result = preg_replace("/\\[\\[(.+?\\|(.+?)|([^\\|]+?))\\]\\]/", "\$2\$3", $result);
         $result = "[[Source:{$this->titleString}|{$result}]]";
     }
     if ($type == 'Article' && isset($this->xml->series_name)) {
         $result = StructuredData::chomp($result, '.') . '. ' . (string) $this->xml->series_name;
     }
     //      if (isset($this->xml->references)) {
     //         $result = StructuredData::chomp($result,'.').'. References '.(string)$this->xml->references;
     //      }
     //      if (isset($this->xml->volumes)) {
     //         $result = StructuredData::chomp($result,'.').'. '.(string)$this->xml->volumes.' Volumes';
     //      }
     if (isset($this->xml->place_issued) || isset($this->xml->publisher) || isset($this->xml->date_issued)) {
         $pubInfo = '';
         if (isset($this->xml->place_issued)) {
             $pubInfo .= (string) $this->xml->place_issued;
         }
         if (isset($this->xml->publisher)) {
             if ($pubInfo) {
                 $pubInfo = StructuredData::chomp($pubInfo, ':') . ': ';
             }
             $pubInfo .= (string) $this->xml->publisher;
         }
         if (isset($this->xml->date_issued)) {
             if ($pubInfo) {
                 $pubInfo = StructuredData::chomp($pubInfo, ',') . ', ';
             }
             $pubInfo .= (string) $this->xml->date_issued;
         }
         $result = StructuredData::chomp($result, '.') . ". ({$pubInfo})";
     }
     //      if (isset($this->xml->pages)) {
     //         $result = StructuredData::chomp($result,',').', '.(string)$this->xml->pages;
     //      }
     return StructuredData::chomp($result, '.');
 }