当前位置: 首页>>代码示例>>PHP>>正文


PHP DifferenceEngine类代码示例

本文整理汇总了PHP中DifferenceEngine的典型用法代码示例。如果您正苦于以下问题:PHP DifferenceEngine类的具体用法?PHP DifferenceEngine怎么用?PHP DifferenceEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DifferenceEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeBunchPatrolTableContent

 public function writeBunchPatrolTableContent(&$dbr, $target, $readOnly)
 {
     global $wgOut, $wgUser;
     $wgOut->addHTML("<table width='100%' align='center' class='bunchtable'><tr>");
     if (!$readOnly) {
         $wgOut->addHTML("<td><b>Patrol?</b></td>");
     }
     $wgOut->addHTML("<td align='center'><b>Diff</b></td></tr>");
     $opts = array('rc_user_text' => $target, 'rc_patrolled=0');
     $opts[] = ' (rc_namespace = 2 OR rc_namespace = 3) ';
     $res = $dbr->select('recentchanges', array('rc_id', 'rc_title', 'rc_namespace', 'rc_this_oldid', 'rc_cur_id', 'rc_last_oldid'), $opts, "wfSpecialBunchpatrol", array('LIMIT' => 15));
     $count = 0;
     while (($row = $dbr->fetchObject($res)) != null) {
         $t = Title::makeTitle($row->rc_namespace, $row->rc_title);
         $diff = $row->rc_this_oldid;
         $rcid = $row->rc_id;
         $oldid = $row->rc_last_oldid;
         $de = new DifferenceEngine($t, $oldid, $diff, $rcid);
         $wgOut->addHTML("<tr>");
         if (!$readOnly) {
             $wgOut->addHTML("<td valign='middle' style='padding-right:24px; border-right: 1px solid #eee;'><input type='checkbox' name='rc_{$rcid}'></td>");
         }
         $wgOut->addHTML("<td style='border-top: 1px solid #eee;'>");
         $wgOut->addHTML($wgUser->getSkin()->makeLinkObj($t));
         $de->showDiffPage(true);
         $wgOut->addHTML("</td></tr>");
         $count++;
     }
     $dbr->freeResult($res);
     $wgOut->addHTML("</table><br/><br/>");
     return $count;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:32,代码来源:Bunchpatrol.body.php

示例2: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $rev1 = $this->revisionOrTitleOrId($params['fromrev'], $params['fromtitle'], $params['fromid']);
     $rev2 = $this->revisionOrTitleOrId($params['torev'], $params['totitle'], $params['toid']);
     $de = new DifferenceEngine($this->getContext(), $rev1, $rev2, null, true, false);
     $vals = array();
     if (isset($params['fromtitle'])) {
         $vals['fromtitle'] = $params['fromtitle'];
     }
     if (isset($params['fromid'])) {
         $vals['fromid'] = $params['fromid'];
     }
     $vals['fromrevid'] = $rev1;
     if (isset($params['totitle'])) {
         $vals['totitle'] = $params['totitle'];
     }
     if (isset($params['toid'])) {
         $vals['toid'] = $params['toid'];
     }
     $vals['torevid'] = $rev2;
     $difftext = $de->getDiffBody();
     if ($difftext === false) {
         $this->dieUsage('The diff cannot be retrieved. ' . 'Maybe one or both revisions do not exist or you do not have permission to view them.', 'baddiff');
     } else {
         ApiResult::setContent($vals, $difftext);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $vals);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:ApiComparePages.php

示例3: testGetDiff

 public function testGetDiff()
 {
     $engine = new DifferenceEngine();
     $textA = 'foo';
     $textB = 'foobar';
     $diff = $engine->generateDiffBody($textA, $textB);
     $this->assertContains('<span class="diffchange diffchange-inline">foo</span>', $diff);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:DiffEngineTest.php

示例4: showDiff

 public static function showDiff($data)
 {
     $rev1 = self::revOrTitle($data['Revision1'], $data['Page1']);
     $rev2 = self::revOrTitle($data['Revision2'], $data['Page2']);
     if ($rev1 && $rev2) {
         $de = new DifferenceEngine(null, $rev1, $rev2, null, $data["Action"] == 'purge', false);
         $de->showDiffPage(true);
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:9,代码来源:SpecialComparePages.php

示例5: showDiff

 public static function showDiff($data, HTMLForm $form)
 {
     $rev1 = self::revOrTitle($data['Revision1'], $data['Page1']);
     $rev2 = self::revOrTitle($data['Revision2'], $data['Page2']);
     if ($rev1 && $rev2) {
         $de = new DifferenceEngine($form->getContext(), $rev1, $rev2, null, $data['Action'] == 'purge', $data['Unhide'] == '1');
         $de->showDiffPage(true);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:SpecialComparePages.php

示例6: formatDiffRow

 public static function formatDiffRow($title, $oldid, $newid, $timestamp, $comment, $actiontext = '')
 {
     global $wgFeedDiffCutoff, $wgContLang, $wgUser;
     wfProfileIn(__FUNCTION__);
     $skin = $wgUser->getSkin();
     # log enties
     $completeText = '<p>' . implode(' ', array_filter(array($actiontext, $skin->formatComment($comment)))) . "</p>\n";
     //NOTE: Check permissions for anonymous users, not current user.
     //      No "privileged" version should end up in the cache.
     //      Most feed readers will not log in anway.
     $anon = new User();
     $accErrors = $title->getUserPermissionsErrors('read', $anon, true);
     if ($title->getNamespace() >= 0 && !$accErrors) {
         if ($oldid) {
             wfProfileIn(__FUNCTION__ . "-dodiff");
             #$diffText = $de->getDiff( wfMsg( 'revisionasof',
             #	$wgContLang->timeanddate( $timestamp ) ),
             #	wfMsg( 'currentrev' ) );
             // Don't bother generating the diff if we won't be able to show it
             if ($wgFeedDiffCutoff > 0) {
                 $de = new DifferenceEngine($title, $oldid, $newid);
                 $diffText = $de->getDiff(wfMsg('previousrevision'), wfMsg('revisionasof', $wgContLang->timeanddate($timestamp)));
             }
             if (strlen($diffText) > $wgFeedDiffCutoff || $wgFeedDiffCutoff <= 0) {
                 // Omit large diffs
                 $diffLink = $title->escapeFullUrl('diff=' . $newid . '&oldid=' . $oldid);
                 $diffText = '<a href="' . $diffLink . '">' . htmlspecialchars(wfMsgForContent('showdiff')) . '</a>';
             } elseif ($diffText === false) {
                 // Error in diff engine, probably a missing revision
                 $diffText = "<p>Can't load revision {$newid}</p>";
             } else {
                 // Diff output fine, clean up any illegal UTF-8
                 $diffText = UtfNormal::cleanUp($diffText);
                 $diffText = self::applyDiffStyle($diffText);
             }
             wfProfileOut(__FUNCTION__ . "-dodiff");
         } else {
             $rev = Revision::newFromId($newid);
             if (is_null($rev)) {
                 $newtext = '';
             } else {
                 $newtext = $rev->getText();
             }
             $diffText = '<p><b>' . wfMsg('newpage') . '</b></p>' . '<div>' . nl2br(htmlspecialchars($newtext)) . '</div>';
         }
         $completeText .= $diffText;
     }
     wfProfileOut(__FUNCTION__);
     return $completeText;
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:50,代码来源:FeedUtils.php

示例7: execute

    function execute($par)
    {
        $request = $this->getRequest();
        $output = $this->getOutput();
        $this->setHeaders();
        $this->checkPermissions();
        $inputValue = htmlspecialchars($request->getText('page', $par));
        $pagenamePlaceholder = $this->msg('pp-pagename-placeholder')->escaped();
        $prepareButtonValue = $this->msg('pp-prepare-button-label')->escaped();
        $saveButtonValue = $this->msg('pp-save-button-label')->escaped();
        $cancelButtonValue = $this->msg('pp-cancel-button-label')->escaped();
        $summaryValue = $this->msg('pp-save-summary')->inContentLanguage()->escaped();
        $output->addModules('ext.translate.special.pagepreparation');
        $output->addModuleStyles('jquery.uls.grid');
        $out = '';
        $diff = new DifferenceEngine($this->getContext());
        $diffHeader = $diff->addHeader(" ", $this->msg('pp-diff-old-header')->escaped(), $this->msg('pp-diff-new-header')->escaped());
        $out = <<<HTML
<div class="grid">
\t<form class="mw-tpp-sp-form row" name="mw-tpp-sp-input-form" action="">
\t\t<input id="pp-summary" type="hidden" value="{$summaryValue}" />
\t\t<input name="page" id="page" class="mw-searchInput mw-ui-input"
\t\t\tplaceholder="{$pagenamePlaceholder}" value="{$inputValue}"/>
\t\t<button id="action-prepare" class="mw-ui-button mw-ui-primary" type="button">
\t\t\t{$prepareButtonValue}</button>
\t\t<button id="action-save" class="mw-ui-button mw-ui-constructive hide" type="button">
\t\t\t{$saveButtonValue}</button>
\t\t<button id="action-cancel" class="mw-ui-button mw-ui-quiet hide" type="button">
\t\t\t{$cancelButtonValue}</button>
\t</form>
\t<div class="messageDiv hide"></div>
\t<div class="divDiff hide">
\t\t{$diffHeader}
\t</div>
</div>
HTML;
        $output->addHTML($out);
    }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:38,代码来源:SpecialPagePreparation.php

示例8: formatApi

 /**
  * Diff would format against two revisions
  */
 public function formatApi(FormatterRow $newRow, FormatterRow $oldRow, IContextSource $ctx)
 {
     $oldRes = $this->revisionViewFormatter->formatApi($oldRow, $ctx);
     $newRes = $this->revisionViewFormatter->formatApi($newRow, $ctx);
     $oldContent = $oldRow->revision->getContent('wikitext');
     $newContent = $newRow->revision->getContent('wikitext');
     $differenceEngine = new \DifferenceEngine();
     $differenceEngine->setContent(new \TextContent($oldContent), new \TextContent($newContent));
     if ($oldRow->revision->isFirstRevision()) {
         $prevLink = null;
     } else {
         $prevLink = $this->urlGenerator->diffLink($oldRow->revision, $ctx->getTitle(), UUID::create($oldRes['workflowId']))->getLocalURL();
     }
     // this is probably a network request which typically goes in the query
     // half, but we don't have to worry about batching because we only show
     // one diff at a time so just do it.
     $nextRevision = $newRow->revision->getCollection()->getNextRevision($newRow->revision);
     if ($nextRevision === null) {
         $nextLink = null;
     } else {
         $nextLink = $this->urlGenerator->diffLink($nextRevision, $ctx->getTitle(), UUID::create($newRes['workflowId']))->getLocalURL();
     }
     return array('new' => $newRes, 'old' => $oldRes, 'diff_content' => $differenceEngine->getDiffBody(), 'links' => array('previous' => $prevLink, 'next' => $nextLink));
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:27,代码来源:RevisionDiffViewFormatter.php

示例9: showFooter

 /**
  * Render the footer including userinfos (Name, Role, Editcount)
  */
 function showFooter()
 {
     $output = $this->getOutput();
     $output->addHtml(Html::openElement('div', array('id' => 'mw-mf-userinfo', 'class' => 'position-fixed')) . Html::openElement('div', array('class' => 'post-content')));
     $userId = $this->rev->getUser();
     if ($userId) {
         $user = User::newFromId($userId);
         $edits = $user->getEditCount();
         $attrs = array('class' => MobileUI::iconClass('user', 'before', 'mw-mf-user icon-16px'), 'data-revision-id' => $this->revId, 'data-user-name' => $user->getName(), 'data-user-gender' => $user->getOption('gender'));
         $output->addHtml(Html::openElement('div', $attrs) . Linker::link($user->getUserPage(), htmlspecialchars($user->getName()), array('class' => 'mw-mf-user-link')) . '</div>' . '<div class="mw-mf-roles meta">' . $this->listGroups($user) . '</div>' . '<div class="mw-mf-edit-count meta">' . $this->msg('mobile-frontend-diffview-editcount', $this->getLanguage()->formatNum($edits))->parse() . '</div>');
     } else {
         $ipAddr = $this->rev->getUserText();
         $userPage = SpecialPage::getTitleFor('Contributions', $ipAddr);
         $output->addHtml(Html::element('div', array('class' => MobileUI::iconClass('anonymous', 'before', 'mw-mf-user icon-16px mw-mf-anon')), $this->msg('mobile-frontend-diffview-anonymous')) . '<div>' . Linker::link($userPage, htmlspecialchars($ipAddr)) . '</div>');
     }
     if ($this->mDiffEngine instanceof InlineDifferenceEngine) {
         $output->addHtml($this->mDiffEngine->getPatrolledLink());
     }
     $output->addHtml(Html::closeElement('div') . Html::closeElement('div'));
 }
开发者ID:felixonmars,项目名称:mediawiki-extensions-MobileFrontend,代码行数:23,代码来源:SpecialMobileDiff.php

示例10: getData

 public function getData()
 {
     $db = wfGetDB(DB_MASTER);
     $conds = array('rt_page' => $this->handle->getTitle()->getArticleID(), 'rt_type' => RevTag::getType('tp:transver'));
     $options = array('ORDER BY' => 'rt_revision DESC');
     $translationRevision = $db->selectField('revtag', 'rt_value', $conds, __METHOD__, $options);
     if ($translationRevision === false) {
         throw new TranslationHelperException("No definition revision recorded");
     }
     $definitionTitle = Title::makeTitleSafe($this->handle->getTitle()->getNamespace(), $this->handle->getKey() . '/' . $this->group->getSourceLanguage());
     if (!$definitionTitle || !$definitionTitle->exists()) {
         throw new TranslationHelperException("Definition page doesn't exist");
     }
     // Using newFromId instead of newFromTitle, because the page might have been renamed
     $oldrev = Revision::newFromId($translationRevision);
     if (!$oldrev) {
         throw new TranslationHelperException("Old definition version doesn't exist anymore");
     }
     $oldContent = $oldrev->getContent();
     $newContent = $this->getDefinitionContent();
     if (!$oldContent) {
         throw new TranslationHelperException("Old definition version doesn't exist anymore");
     }
     if (!$oldContent instanceof WikitextContent || !$newContent instanceof WikitextContent) {
         throw new TranslationHelperException('Can only work on Wikitext content');
     }
     if ($oldContent->equals($newContent)) {
         throw new TranslationHelperException('No changes');
     }
     $diff = new DifferenceEngine($this->context);
     if (method_exists('DifferenceEngine', 'setTextLanguage')) {
         $diff->setTextLanguage($this->group->getSourceLanguage());
     }
     $diff->setContent($oldContent, $newContent);
     $diff->setReducedLineNumbers();
     $diff->showDiffStyle();
     $html = $diff->getDiff($this->context->msg('tpt-diff-old')->escaped(), $this->context->msg('tpt-diff-new')->escaped());
     return array('value_old' => $oldContent->getNativeData(), 'value_new' => $newContent->getNativeData(), 'revisionid_old' => $oldrev->getId(), 'revisionid_new' => $definitionTitle->getLatestRevId(), 'language' => $this->group->getSourceLanguage(), 'html' => $html);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:39,代码来源:UpdatedDefinitionAid.php

示例11: addToEditView

 /**
  * Adds stable version tags to page when editing
  */
 public function addToEditView(EditPage $editPage)
 {
     global $wgParser;
     $reqUser = $this->getUser();
     $this->load();
     # Must be reviewable. UI may be limited to unobtrusive patrolling system.
     if (!$this->article->isReviewable()) {
         return true;
     }
     $items = array();
     # Show stabilization log
     $log = $this->stabilityLogNotice();
     if ($log) {
         $items[] = $log;
     }
     # Check the newest stable version
     $frev = $this->article->getStableRev();
     if ($frev) {
         $quality = $frev->getQuality();
         # Find out revision id of base version
         $latestId = $this->article->getLatest();
         $revId = $editPage->oldid ? $editPage->oldid : $latestId;
         # Let users know if their edit will have to be reviewed.
         # Note: if the log excerpt was shown then this is redundant.
         if (!$log && $this->editWillRequireReview($editPage)) {
             $items[] = wfMsgExt('revreview-editnotice', 'parseinline');
         }
         # Add a notice if there are pending edits...
         if ($this->article->revsArePending()) {
             $revsSince = $this->article->getPendingRevCount();
             $items[] = FlaggedRevsXML::pendingEditNotice($this->article, $frev, $revsSince);
         }
         # Show diff to stable, to make things less confusing.
         # This can be disabled via user preferences and other conditions...
         if ($frev->getRevId() < $latestId && $reqUser->getBoolOption('flaggedrevseditdiffs') && $revId == $latestId && $editPage->section != 'new' && $editPage->formtype != 'diff') {
             # Left diff side...
             $leftNote = $quality ? 'revreview-hist-quality' : 'revreview-hist-basic';
             $lClass = FlaggedRevsXML::getQualityColor((int) $quality);
             $leftNote = "<span class='{$lClass}'>[" . wfMsgHtml($leftNote) . "]</span>";
             # Right diff side...
             $rClass = FlaggedRevsXML::getQualityColor(false);
             $rightNote = "<span class='{$rClass}'>[" . wfMsgHtml('revreview-hist-pending') . "]</span>";
             # Get the stable version source
             $text = $frev->getRevText();
             # Are we editing a section?
             $section = $editPage->section == "" ? false : intval($editPage->section);
             if ($section !== false) {
                 $text = $wgParser->getSection($text, $section);
             }
             if ($text !== false && strcmp($text, $editPage->textbox1) !== 0) {
                 $diffEngine = new DifferenceEngine($this->article->getTitle());
                 $diffBody = $diffEngine->generateDiffBody($text, $editPage->textbox1);
                 $diffHtml = wfMsgExt('review-edit-diff', 'parseinline') . ' ' . FlaggedRevsXML::diffToggle() . "<div id='mw-fr-stablediff'>" . self::getFormattedDiff($diffBody, '', $leftNote, $rightNote) . "</div>\n";
                 $items[] = $diffHtml;
                 $diffEngine->showDiffStyle();
                 // add CSS
             }
         }
         # Output items
         if (count($items)) {
             $html = "<table class='flaggedrevs_editnotice plainlinks'>";
             foreach ($items as $item) {
                 $html .= '<tr><td>' . $item . '</td></tr>';
             }
             $html .= '</table>';
             $this->out->addHTML($html);
         }
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:73,代码来源:FlaggablePageView.php

示例12: makeADifference

 function makeADifference($text, $title, $section)
 {
     global $wgOut;
     /* make an article object */
     $rtitle = Title::newFromText($title);
     $rarticle = new Article($rtitle, $rtitle->getArticleID());
     $epage = new EditPage($rarticle);
     $epage->section = $section;
     /* customized getDiff from EditPage */
     $oldtext = $epage->mArticle->fetchContent();
     $edittime = $epage->mArticle->getTimestamp();
     $newtext = $epage->mArticle->replaceSection($section, $text, '', $edittime);
     $newtext = $epage->mArticle->preSaveTransform($newtext);
     $oldtitle = wfMsgExt('currentrev', array('parseinline'));
     $newtitle = wfMsgExt('yourtext', array('parseinline'));
     if ($oldtext !== false || $newtext != '') {
         $de = new DifferenceEngine($epage->mTitle);
         $de->setText($oldtext, $newtext);
         $difftext = $de->getDiff($oldtitle, $newtitle);
     } else {
         $difftext = '';
     }
     $diffdiv = '<div id="wikiDiff">' . $difftext . '</div>';
     $wgOut->addHTML($diffdiv);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:25,代码来源:MediaWikiWyg.php

示例13: showEditForm


//.........这里部分代码省略.........
            } else {
                // Hide the toolbar and edit area, user can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>';
            }
        }
        $tabindex = 2;
        $checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
        $checkboxhtml = implode($checkboxes, "\n");
        $buttons = $this->getEditButtons($tabindex);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $this->showFormBeforeText();
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
END
);
        if ($this->isConflict || $this->diff) {
            # MeanEditor: should be redundant, but let's be sure
            $this->noVisualEditor = true;
        }
        # MeanEditor: also apply htmlspecialchars? See $encodedtext
        $html_text = $this->safeUnicodeOutput($this->textbox1);
        if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) {
            $this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n");
        } else {
            $wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n");
            $this->showTextbox1($classes);
        }
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterWarn}
{$metadata}
{$editsummary}
{$summarypreview}
{$checkboxhtml}
{$safemodehtml}
END
);
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        $this->showEditTools();
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
END
);
        if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
            $wgOut->wrapWikiMsg('==$1==', "yourdiff");
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->wrapWikiMsg('==$1==', "yourtext");
            $this->showTextbox2();
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, false);
        }
        wfProfileOut($fname);
    }
开发者ID:erpel,项目名称:meaneditor,代码行数:101,代码来源:MeanEditorEditPage.body.php

示例14: rollback

 /**
  * User interface for rollback operations
  */
 public function rollback()
 {
     global $wgUser, $wgOut, $wgRequest;
     $details = null;
     $result = $this->doRollback($wgRequest->getVal('from'), $wgRequest->getText('summary'), $wgRequest->getVal('token'), $wgRequest->getBool('bot'), $details);
     if (in_array(array('actionthrottledtext'), $result)) {
         $wgOut->rateLimited();
         return;
     }
     if (isset($result[0][0]) && ($result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback')) {
         $wgOut->setPageTitle(wfMsg('rollbackfailed'));
         $errArray = $result[0];
         $errMsg = array_shift($errArray);
         $wgOut->addWikiMsgArray($errMsg, $errArray);
         if (isset($details['current'])) {
             $current = $details['current'];
             if ($current->getComment() != '') {
                 $wgOut->addWikiMsgArray('editcomment', array($wgUser->getSkin()->formatComment($current->getComment())), array('replaceafter'));
             }
         }
         return;
     }
     # Display permissions errors before read-only message -- there's no
     # point in misleading the user into thinking the inability to rollback
     # is only temporary.
     if (!empty($result) && $result !== array(array('readonlytext'))) {
         # array_diff is completely broken for arrays of arrays, sigh.
         # Remove any 'readonlytext' error manually.
         $out = array();
         foreach ($result as $error) {
             if ($error != array('readonlytext')) {
                 $out[] = $error;
             }
         }
         $wgOut->showPermissionsErrorPage($out);
         return;
     }
     if ($result == array(array('readonlytext'))) {
         $wgOut->readOnlyPage();
         return;
     }
     $current = $details['current'];
     $target = $details['target'];
     $newId = $details['newid'];
     $wgOut->setPageTitle(wfMsg('actioncomplete'));
     $wgOut->setRobotPolicy('noindex,nofollow');
     if ($current->getUserText() === '') {
         $old = wfMsg('rev-deleted-user');
     } else {
         $old = $wgUser->getSkin()->userLink($current->getUser(), $current->getUserText()) . $wgUser->getSkin()->userToolLinks($current->getUser(), $current->getUserText());
     }
     $new = $wgUser->getSkin()->userLink($target->getUser(), $target->getUserText()) . $wgUser->getSkin()->userToolLinks($target->getUser(), $target->getUserText());
     $wgOut->addHTML(wfMsgExt('rollback-success', array('parse', 'replaceafter'), $old, $new));
     $wgOut->returnToMain(false, $this->mTitle);
     if (!$wgRequest->getBool('hidediff', false) && !$wgUser->getBoolOption('norollbackdiff', false)) {
         $de = new DifferenceEngine($this->mTitle, $current->getId(), $newId, false, true);
         $de->showDiff('', '');
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:62,代码来源:Article.php

示例15: extractRowInfo


//.........这里部分代码省略.........
             $vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
         } else {
             $vals['sha1'] = '';
         }
     }
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
             $vals['commenthidden'] = '';
         } else {
             $comment = $revision->getComment();
             if ($this->fld_comment) {
                 $vals['comment'] = $comment;
             }
             if ($this->fld_parsedcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($comment, $title);
             }
         }
     }
     if ($this->fld_tags) {
         if ($row->ts_tags) {
             $tags = explode(',', $row->ts_tags);
             $this->getResult()->setIndexedTagName($tags, 'tag');
             $vals['tags'] = $tags;
         } else {
             $vals['tags'] = array();
         }
     }
     if (!is_null($this->token)) {
         $tokenFunctions = $this->getTokenFunctions();
         foreach ($this->token as $t) {
             $val = call_user_func($tokenFunctions[$t], $title->getArticleID(), $title, $revision);
             if ($val === false) {
                 $this->setWarning("Action '{$t}' is not allowed for the current user");
             } else {
                 $vals[$t . 'token'] = $val;
             }
         }
     }
     $text = null;
     global $wgParser;
     if ($this->fld_content || !is_null($this->difftotext)) {
         $text = $revision->getText();
         // Expand templates after getting section content because
         // template-added sections don't count and Parser::preprocess()
         // will have less input
         if ($this->section !== false) {
             $text = $wgParser->getSection($text, $this->section, false);
             if ($text === false) {
                 $this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
             }
         }
     }
     if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
         if ($this->generateXML) {
             $wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), OT_PREPROCESS);
             $dom = $wgParser->preprocessToDom($text);
             if (is_callable(array($dom, 'saveXML'))) {
                 $xml = $dom->saveXML();
             } else {
                 $xml = $dom->__toString();
             }
             $vals['parsetree'] = $xml;
         }
         if ($this->expandTemplates && !$this->parseContent) {
             $text = $wgParser->preprocess($text, $title, ParserOptions::newFromContext($this->getContext()));
         }
         if ($this->parseContent) {
             $text = $wgParser->parse($text, $title, ParserOptions::newFromContext($this->getContext()))->getText();
         }
         ApiResult::setContent($vals, $text);
     } elseif ($this->fld_content) {
         $vals['texthidden'] = '';
     }
     if (!is_null($this->diffto) || !is_null($this->difftotext)) {
         global $wgAPIMaxUncachedDiffs;
         static $n = 0;
         // Number of uncached diffs we've had
         if ($n < $wgAPIMaxUncachedDiffs) {
             $vals['diff'] = array();
             $context = new DerivativeContext($this->getContext());
             $context->setTitle($title);
             if (!is_null($this->difftotext)) {
                 $engine = new DifferenceEngine($context);
                 $engine->setText($text, $this->difftotext);
             } else {
                 $engine = new DifferenceEngine($context, $revision->getID(), $this->diffto);
                 $vals['diff']['from'] = $engine->getOldid();
                 $vals['diff']['to'] = $engine->getNewid();
             }
             $difftext = $engine->getDiffBody();
             ApiResult::setContent($vals['diff'], $difftext);
             if (!$engine->wasCacheHit()) {
                 $n++;
             }
         } else {
             $vals['diff']['notcached'] = '';
         }
     }
     return $vals;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ApiQueryRevisions.php


注:本文中的DifferenceEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。