예제 #1
0
 private function getSourceCitationText($sourceCitation)
 {
     $citation = '';
     $recordName = (string) $sourceCitation['record_name'];
     $citation .= $recordName;
     $title = (string) $sourceCitation['title'];
     $titleLower = mb_strtolower($title);
     if ($recordName && $title) {
         $citation = StructuredData::chomp($citation, ',') . ', in ';
     }
     $srcTitle = '';
     $altTitle = '';
     if (mb_strpos($titleLower, 'source:') === 0 || mb_strpos($titleLower, 'mysource:') === 0) {
         $fields = explode('|', $title);
         if (count($fields) > 1) {
             $altTitle = $fields[1];
         }
         $t = Title::newFromText($fields[0]);
         if ($t) {
             $srcTitle = StructuredData::getRedirectToTitle($t);
         }
     }
     if ($srcTitle) {
         if ($altTitle) {
             $citation .= "[[" . $srcTitle->getPrefixedText() . "|{$altTitle}]]";
         } else {
             if ($srcTitle->getNamespace() == NS_SOURCE) {
                 $source = new Source($srcTitle->getText());
             } else {
                 $source = new MySource($srcTitle->getText());
             }
             $source->loadPage();
             $citation .= $source->getCitationText(true);
         }
     } else {
         $citation .= $title;
     }
     $page = (string) $sourceCitation['page'];
     if ($page) {
         $citation = StructuredData::chomp($citation, ',') . ", {$page}";
     }
     $date = (string) $sourceCitation['date'];
     if ($date) {
         $citation = StructuredData::chomp($citation, ',') . ", {$date}";
     }
     $quality = (string) $sourceCitation['quality'];
     if (strlen($quality) > 0) {
         $qualName = array_search($quality, self::$QUALITY_OPTIONS);
         if (!$qualName && @self::$QUALITY_OPTIONS[$quality]) {
             $qualName = $quality;
         }
         // allow old alpha form
         if ($qualName) {
             $citation = StructuredData::chomp($citation, ',') . ", {$qualName} quality";
         }
     }
     return $citation;
 }
예제 #2
0
 private function writePage($fullTitle)
 {
     $this->title = Title::newFromText($fullTitle);
     $id = $this->titleMap[$fullTitle];
     $obj = null;
     $this->xml = null;
     $this->contents = null;
     $ns = $this->title->getNamespace();
     if ($this->title->exists()) {
         if ($ns == NS_PERSON) {
             $obj = new Person($this->title->getText());
         } else {
             if ($ns == NS_FAMILY) {
                 $obj = new Family($this->title->getText());
             } else {
                 if ($ns == NS_SOURCE) {
                     $obj = new Source($this->title->getText());
                 } else {
                     if ($ns == NS_MYSOURCE) {
                         $obj = new MySource($this->title->getText());
                     }
                 }
             }
         }
         if ($obj) {
             $obj->loadPage();
             $this->xml = $obj->getPageXml();
             if ($this->xml == null) {
                 echo "XML not found for title=" . $this->title->getPrefixedText() . " treeId={$this->treeId}\n";
             }
             $this->contents = $obj->getPageContents();
         }
     }
     $this->refdCitations = array();
     $this->refdNotes = array();
     $this->refdImages = array();
     if ($ns == NS_PERSON) {
         $uid = "WeRelate:" . $this->title->getNsText() . ":" . $this->title->getDBkey();
         $this->writePerson($id, $uid);
     } else {
         if ($ns == NS_FAMILY) {
             $this->writeFamily($id);
         } else {
             if ($ns == NS_SOURCE) {
                 $this->writeSource($id);
             } else {
                 if ($ns == NS_MYSOURCE) {
                     $this->writeMySource($id);
                 }
             }
         }
     }
 }