public function testInlineDiffs() { // Test that covers all possibilities, must match 004.phpt from wikidiff2 $x = <<<END foo bar baz quux bang END; $y = <<<END foo test baz bang END; $diffExpected = <<<END <div class="mw-diff-inline-header"><!-- LINES 1,1 --></div> <div class="mw-diff-inline-changed">foo <del>bar</del><ins>test</ins></div> <div class="mw-diff-inline-context">baz</div> <div class="mw-diff-inline-deleted"><del>quux</del></div> <div class="mw-diff-inline-context">bang</div> END; $diff = new InlineDifferenceEngine(); $this->assertEquals($this->strip($diffExpected), $diff->generateTextDiffBody($this->strip($x), $this->strip($y))); }
/** * 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')); }
/** * Render the inline difference between two revisions * using InlineDiffEngine */ function showDiff() { $ctx = MobileContext::singleton(); $prevId = $this->prevRev ? $this->prevRev->getId() : 0; $unhide = (bool) $this->getRequest()->getVal('unhide'); $contentHandler = $this->rev->getContentHandler(); $de = $contentHandler->createDifferenceEngine($this->getContext(), $prevId, $this->revId); // HACK: if (get_class($de) == 'DifferenceEngine') { $de = new InlineDifferenceEngine($this->getContext(), $prevId, $this->revId, 0, false, $unhide); } else { $de->showDiffPage(); return; } $diff = $de->getDiffBody(); if (!$prevId) { $audience = $unhide ? Revision::FOR_THIS_USER : Revision::FOR_PUBLIC; $diff = '<ins>' . nl2br(htmlspecialchars($this->rev->getText($audience))) . '</ins>'; } $warnings = $de->getWarningMessageText(); if ($warnings) { $warnings = Html::openElement('div', array('class' => 'warning alert')) . $warnings . Html::closeElement('div'); } $this->getOutput()->addHtml($warnings . '<div id="mw-mf-minidiff">' . $diff . '</div>'); $prev = $this->rev->getPrevious(); $next = $this->rev->getNext(); if ($prev || $next) { $history = Html::openElement('ul', array('class' => 'hlist revision-history-links')); if ($prev) { $history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $prev->getId())->getLocalUrl()), $this->msg('previousdiff')) . Html::closeElement('li'); } if ($next) { $history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $next->getId())->getLocalUrl()), $this->msg('nextdiff')) . Html::closeElement('li'); } $history .= Html::closeElement('ul'); $this->getOutput()->addHtml($history); } }