Пример #1
0
 private function formatResult($doc, $hl, $pos, $condensed)
 {
     global $wgUser;
     $skin =& $wgUser->getSkin();
     $ns = @$doc['NamespaceStored'];
     $titleString = $doc['TitleStored'];
     $title = Title::newFromText($ns . ':' . $titleString);
     if ($this->pagetitle && $ns == $this->namespace && $title->getDBkey() == $this->pagetitle) {
         return '';
     }
     if (!$condensed) {
         $birth = $chr = $death = $burial = $marriage = $banns = '';
         $husbandBirth = $husbandDeath = $wifeBirth = $wifeDeath = '';
         if ($ns == 'Person') {
             $birth = $this->getEventInfo($hl, 'PersonBirth');
             $chr = $this->getEventInfo($hl, 'PersonChr');
             $death = $this->getEventInfo($hl, 'PersonDeath');
             $burial = $this->getEventInfo($hl, 'PersonBurial');
         } else {
             if ($ns == 'Family') {
                 $marriage = $this->getEventInfo($hl, 'Marriage');
                 $banns = $this->getEventInfo($hl, 'Banns');
                 $husbandBirth = $this->getEventInfo($doc, 'HusbandBirth');
                 if (!$husbandBirth) {
                     $husbandBirth = $this->getEventInfo($doc, 'HusbandChr');
                 }
                 $husbandDeath = $this->getEventInfo($doc, 'HusbandDeath');
                 if (!$husbandDeath) {
                     $husbandDeath = $this->getEventInfo($doc, 'HusbandBurial');
                 }
                 $wifeBirth = $this->getEventInfo($doc, 'WifeBirth');
                 if (!$wifeBirth) {
                     $wifeBirth = $this->getEventInfo($doc, 'WifeChr');
                 }
                 $wifeDeath = $this->getEventInfo($doc, 'WifeDeath');
                 if (!$wifeDeath) {
                     $wifeDeath = $this->getEventInfo($doc, 'WifeBurial');
                 }
             }
         }
         $imageURL = '';
         if (@$doc['PrimaryImage']) {
             $t = Title::makeTitle(NS_IMAGE, $doc['PrimaryImage']);
             if ($t && $t->exists()) {
                 $i = new Image($t);
                 $imageURL = $i->createThumb(SearchForm::THUMB_WIDTH, SearchForm::THUMB_HEIGHT);
                 $imagePageURL = $t->getLocalURL();
             }
         } else {
             if ($doc['NamespaceStored'] == 'Image') {
                 $t = Title::makeTitle(NS_IMAGE, $doc['TitleStored']);
                 if ($t && $t->exists()) {
                     $i = new Image($t);
                     $imageURL = $i->createThumb(SearchForm::THUMB_WIDTH, SearchForm::THUMB_HEIGHT);
                     $imagePageURL = $t->getLocalURL();
                 }
             }
         }
     }
     $displayTitle = '';
     if ($ns == 'Family') {
         if (@$hl['TitleStored']) {
             $displayTitle = SearchForm::removeId($hl['TitleStored'][0]);
         } else {
             $displayTitle = SearchForm::removeId($titleString);
         }
     } else {
         if ($ns == 'Person') {
             if (@$hl['FullnameStored'][0] && mb_strpos($hl['FullnameStored'][0], ' ') !== false) {
                 $displayTitle = $hl['FullnameStored'][0];
             } else {
                 if (@$hl['TitleStored']) {
                     $displayTitle = SearchForm::removeId($hl['TitleStored'][0]);
                 } else {
                     $displayTitle = SearchForm::removeId($titleString);
                 }
             }
         } else {
             if (@$hl['TitleStored']) {
                 $displayTitle = $hl['TitleStored'][0];
             } else {
                 $displayTitle = $titleString;
             }
         }
     }
     $titleText = $this->prepareValue(($ns ? $ns . ':' : '') . $displayTitle, 200);
     $result = '<tr><td class="searchresult" colspan=2>' . ($this->addSelectButtons() ? $this->getSelectButton($ns, $titleString) : '') . ($this->match ? $this->getMatchCheckbox($titleString, $pos + 1) : '') . '<span class="searchresulttitle">' . $skin->makeKnownLinkObj($title, $titleText, $this->addSelectButtons() ? 'target=' . urlencode($this->target) : '') . '</span></td>' . ($pos >= 0 ? '' : '<td>Recent edit, not yet indexed</td>') . '</tr>';
     // $pos is -1 for recent contribs
     if ($pos >= 0 && !$condensed) {
         $result .= '<tr><td ' . ($imageURL ? 'width="55%"' : 'colspan=2 width="70%"') . '><table width="100%">' . $this->formatValue('Birth', $birth) . (!$birth && $chr ? $this->formatValue('Chr/Bap', $chr) : '') . $this->formatValue('Death', $death) . (!$death && $burial ? $this->formatValue('Burial', $burial) : '') . $this->formatValue('Parents', SearchForm::removeId(@$hl['ParentFamilyTitle'][0])) . $this->formatValue('Spouse', SearchForm::removeSelf($titleString, SearchForm::removeId(@$hl['SpouseFamilyTitle'][0]))) . ($husbandBirth || $husbandDeath ? $this->formatValue('Husband', "{$husbandBirth} - {$husbandDeath}") : '') . ($wifeBirth || $wifeDeath ? $this->formatValue('Wife', "{$wifeBirth} - {$wifeDeath}") : '') . $this->formatValue('Marriage', $marriage) . (!$marriage && $banns ? $this->formatValue('Banns', $banns) : '') . $this->formatValue('Children', SearchForm::removeId(@$hl['ChildTitle'][0])) . $this->formatValue('Author', @$hl['AuthorStored'][0]) . $this->formatValue('Title', @$hl['SourceTitleStored'][0]) . $this->formatValue('Surnames', @$hl['SurnameStored'][0]) . $this->formatValue('Places', @$hl['PlaceStored'][0]) . (@$hl['SourceSubjectStored'][0] ? $this->formatValue('Subject', @$hl['SourceSubjectStored'][0] . (@$doc['SourceSubSubject'] ? ' - ' . @$doc['SourceSubSubject'] : '')) : '') . (@$doc['FromYear'] || @$doc['ToYear'] ? $this->formatValue('Year range', @$doc['FromYear'] . ' - ' . @$doc['ToYear']) : '') . $this->formatValue('Availability', @$hl['SourceAvailabilityStored'][0]) . $this->formatValue('Type', @$hl['PlaceType'][0]) . $this->formatValue('', @$hl['TextStored'][0], true) . '</table></td>' . ($imageURL ? "<td width=\"15%\"><a href=\"{$imagePageURL}\"><img alt=\"\" src=\"{$imageURL}\"/></a></td>" : '') . "<td width=\"24%\" align=\"right\"><table>" . ($this->ecp == 'e' ? '' : $this->formatValue('', $this->getStarsImage($doc['score']), false, false)) . $this->formatValue('Watching', $this->makeUserLinks(@$hl['UserStored'][0]), false, false) . $this->formatValue('Modified', @$doc['LastModDate'] ? date('j M Y', wfTimestamp(TS_UNIX, $doc['LastModDate'] . '000000')) : '') . "</table></td></tr>\n";
     }
     return $result;
 }