Пример #1
0
    public function getMergeResults()
    {
        global $wgUser;
        list($maxPages, $width) = $this->getPagesWidth();
        $output = '';
        if (count($this->redirects) > 0) {
            $skin =& $wgUser->getSkin();
            $output .= '<b>The following pages have already been merged</b><ul>';
            foreach ($this->redirects as $redir) {
                if (GedcomUtil::isGedcomTitle($redir->getText())) {
                    $titleLink = htmlspecialchars($redir->getPrefixedText());
                } else {
                    $titleLink = $skin->makeKnownLinkObj($redir, htmlspecialchars($redir->getPrefixedText()), 'redirect=no');
                }
                $output .= "<li>{$titleLink}</li>\n";
            }
            $output .= '</ul>';
        }
        $first = true;
        $editToken = htmlspecialchars($wgUser->editToken());
        if ($this->isGedcom()) {
            $gedcomField = "<input type=\"hidden\" name=\"gedcomdata\" value=\"" . htmlspecialchars($this->gedcomDataString) . "\">";
            $gedcomExtra = '?gedcomtab=' . htmlspecialchars($this->gedcomTab) . '&gedcomkey=' . htmlspecialchars($this->gedcomKey);
        } else {
            $gedcomField = '';
            $gedcomExtra = '';
        }
        $output .= <<<END
<form id="merge" name="merge" action="/wiki/Special:Merge{$gedcomExtra}" method="post">
<input type="hidden" name="merging" value="true">
<input type="hidden" name="ns" value="{$this->namespace}">
<input type="hidden" name="wpEditToken" value="{$editToken}">
{$gedcomField}
<table border="0" cellspacing="0" cellpadding="4">
END;
        $this->mergeNumber = 0;
        $hiddenFields = '';
        $semiProtected = false;
        foreach ($this->data as &$datai) {
            $pageCount = count($datai);
            if ($pageCount > 1) {
                $this->rowNumber = 0;
                $output .= $this->insertSeparatorRow($datai, $width, $hiddenFields);
                $ns = $this->namespace == 'Person' || !$first ? NS_PERSON : NS_FAMILY;
                $output .= $this->getTitleRow($datai, $width, $ns);
                $output .= $this->getTargetsRow($datai, $width, $ns);
                if ($ns == NS_PERSON) {
                    $output .= $this->getRows($datai, $width, 'names', 'labelName', 'matchName', 'compareNames');
                    $output .= $this->getRow($datai, $width, 'gender', 'formatGender');
                }
                $output .= $this->getRows($datai, $width, 'events', 'labelEvent', 'matchEvent', 'compareEvents');
                $output .= $this->getRows($datai, $width, 'sources', 'labelSource', 'matchSource', 'compareIds');
                $output .= $this->getRows($datai, $width, 'images', 'labelImage', 'matchImage', 'compareIds');
                $output .= $this->getRows($datai, $width, 'notes', 'labelNote', 'matchNote', 'compareIds');
                $output .= $this->getRow($datai, $width, 'contents', 'formatContents');
                $hiddenFields .= "<input type=\"hidden\" name=\"merges_{$this->mergeNumber}\" value=\"{$pageCount}\"><input type=\"hidden\" name=\"rows_{$this->mergeNumber}\" value=\"{$this->rowNumber}\">";
                $this->mergeNumber++;
                if (!$datai[0]['updatable']) {
                    $semiProtected = true;
                }
            }
            $first = false;
        }
        $cols = $maxPages * 3 + 1;
        $nonmergedPages = $this->getNonmergedPages();
        if ($nonmergedPages) {
            $nonmergedPages = '<p>In addition to people listed above, the following will also be included in the target family' . ($this->isGedcom() ? '<br/>(GEDCOM people listed will be added when the GEDCOM imported)' : '') . $nonmergedPages . "</p>\n";
        }
        $semiProtectedMsg = $semiProtected ? '<br>' . CompareForm::getSemiProtectedMessage($this->isTrusted) : '';
        if ($this->isGedcom()) {
            $cancelFunction = 'doCancelGedcom()';
            $mergeFunction = 'doMergeGedcom()';
            $mergeLabel = 'Update';
            $mergeSummary = '';
            $mergeTitle = 'Update the existing page(s) with the checked information from your GEDCOM';
        } else {
            $cancelFunction = 'doCancel()';
            $mergeFunction = 'doMerge()';
            $mergeLabel = 'Merge';
            $mergeSummary = 'Merge Summary: &nbsp; <input type="text" size="25" name="userComment"> &nbsp; &nbsp;';
            $mergeTitle = 'Combine the pages, keeping only the checked information';
        }
        $output .= <<<END
<tr><td align=right colspan="{$cols}"><input type="hidden" name="formAction">
{$mergeSummary}
<input id="mergeButton" type="button" title="{$mergeTitle}" value="{$mergeLabel}" onClick="{$mergeFunction}"/></td></tr>
</table>
{$hiddenFields}
<input type="hidden" name="merges" value="{$this->mergeNumber}">
</form>
{$semiProtectedMsg}
{$nonmergedPages}
END;
        return $output;
    }