Exemple #1
0
/**
 * Called to display the Special:Merge page
 *
 * @param unknown_type $par
 * @param unknown_type $specialPage
 */
function wfSpecialMerge($par = NULL, $specialPage)
{
    global $wgOut, $wgScriptPath, $wgCommandLineMode, $wrSidebarHtml, $wgMemc, $wgUser;
    //		$sideText = '';
    $mergeForm = new MergeForm();
    // read query parameters into variables
    $mergeForm->readQueryParms($par);
    if (!$wgUser->isLoggedIn()) {
        if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
            User::SetupSession();
        }
        $mergeTargetTitle = $mergeForm->getMergeTargetTitle();
        $requestData = array();
        if ($mergeTargetTitle) {
            $requestData['returnto'] = $mergeTargetTitle->getPrefixedUrl();
        }
        $request = new FauxRequest($requestData);
        require_once 'includes/SpecialUserlogin.php';
        $form = new LoginForm($request);
        $form->mainLoginForm("You need to sign in to merge pages<br/><br/>", '');
        return;
    }
    if ($wgUser->isBlocked()) {
        $wgOut->blockedPage();
        return;
    }
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    $isGedcom = $mergeForm->isGedcom();
    $wgOut->setPageTitle($isGedcom ? 'Update pages' : 'Merge pages');
    if ($mergeForm->getFormAction() == 'Cancel') {
        $output = '<H2>Merge Cancelled</H2><p>You can use the <b>back</b> button on your browser to navigate back to where you were, or select an item from the menu.</p>';
    } else {
        if ($mergeForm->getFormAction() == 'NotMatch') {
            $output = $mergeForm->getNotMatchResults();
        } else {
            if ($mergeForm->getFormAction() != 'Merge' || !$mergeForm->preMerge()) {
                $output = '<H2>Unable to merge</H2>' . $mergeForm->getWarnings() . '<p>Press the <b>back</b> button on your browser to go back to the Compare page.</p>';
            } else {
                if ($mergeForm->isSecondPhase()) {
                    // disallow merging the same page twice in a row (result of double-click)
                    if ($mergeForm->isGedcom()) {
                        $cacheKey = 'mergekey:ged:' . $mergeForm->gedcomId . $mergeForm->gedcomKey;
                    } else {
                        $cacheKey = 'mergekey:' . $wgUser->getID() . $mergeForm->editToken;
                    }
                    if (!$wgMemc->get($cacheKey)) {
                        $wgMemc->set($cacheKey, 't', 5);
                        $output = $mergeForm->doMerge();
                    }
                } else {
                    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/merge.10.js\"></script>");
                    //		$mergeText = $isGedcom ? 'update' : 'merge';
                    //		$mergeButton = $isGedcom ? 'Update' : 'Merge';
                    //		$sideText = '<h3>Instructions</h3><p>' .
                    //						($mergeForm->getMergesCount() > 1 ? "For each set of pages to $mergeText, check" : 'Check') .
                    //						" the boxes next to the pieces of information you want included in the {$mergeText}d page.</p>" .
                    //						($isGedcom ? '<p><b>Updating pages is optional.</b>  It is not necessary or desirable to update these pages unless you have more accurate information or reliable sources to add.</b></p>'
                    //								: '<p>The <i>target</i> is the page that the other page(s) will be merged into.</p>').
                    //						'<p>The box colors are for your information only:</p>'.
                    //						'<p><font color="green">Green</font> boxes mean the information is specific and matches exactly.</p>'.
                    //						'<p><font color="yellow">Yellow</font> boxes mean the information is non-specific (missing some pieces) or is a partial match.</p>'.
                    //						'<p><font color="red">Red</font> boxes mean the information differs.</p>'.
                    //						"<p>Once you have chosen which pieces of information to include, click on the \"$mergeButton\" button at the bottom of the screen to $mergeText the pages.</p>".
                    //						'<p>(<a href="/wiki/Help:Merging_pages">more help</a>)</p>';
                    $output = $mergeForm->getMergeResults();
                }
            }
        }
    }
    //   $skin = $wgUser->getSkin();
    $wrSidebarHtml = wfMsgWikiHtml('MergeHelp');
    $wgOut->addHTML($output);
}