/** * Renders a banner telling the user the page is unavailable * * @param string $msg Message to display */ protected function renderUnavailableBanner($msg) { $out = $this->getOutput(); $out->setPageTitle($this->msg('mobile-frontend-requires-title')); $out->setProperty('unstyledContent', true); $out->addHTML(MobileUI::warningBox($msg)); }
/** * Prepare warnings for mobile output * @param BaseTemplate $tpl */ protected function prepareWarnings(BaseTemplate $tpl) { $out = $this->getOutput(); if ($out->getRequest()->getText('oldid')) { $tpl->set('_old_revision_warning', MobileUI::warningBox($this->getOldRevisionHtml())); } }
/** * Render the contributions of user to page * @param ResultWrapper $res */ protected function showContributions(ResultWrapper $res) { $numRows = $res->numRows(); $rev = null; $out = $this->getOutput(); $revs = array(); $prevRevs = array(); foreach ($res as $row) { $rev = new Revision($row); $revs[] = $rev; if ($res->key() <= self::LIMIT + 1 && $rev->getParentId()) { $prevRevs[] = $rev->getParentId(); } } $this->prevLengths = Revision::getParentLengths(wfGetDB(DB_SLAVE), $prevRevs); if ($numRows > 0) { $count = 0; foreach ($revs as $rev) { if ($count++ < self::LIMIT) { $this->showContributionsRow($rev); } } $out->addHtml('</ul>'); // Captured 1 more than we should have done so if the number of // results is greater than the limit there are more to show. if ($numRows > self::LIMIT) { $out->addHtml($this->getMoreButton($rev->getTimestamp())); } } else { // For users who exist but have not made any edits $out->addHtml(MobileUI::warningBox($this->msg('mobile-frontend-history-no-results'))); } }
/** * Render the history list * @see showRow() * @see doQuery() * @param ResultWrapper $res The result of doQuery */ protected function showHistory(ResultWrapper $res) { $numRows = $res->numRows(); $rev1 = $rev2 = null; $out = $this->getOutput(); if ($numRows > 0) { foreach ($res as $row) { $rev1 = new Revision($row); if ($rev2) { $this->showRow($rev2, $rev1); } $rev2 = $rev1; } if ($rev1 && $numRows < self::LIMIT + 1) { $this->showRow($rev1, null); } $out->addHtml('</ul>'); // Captured 1 more than we should have done so if the number of // results is greater than the limit there are more to show. if ($numRows > self::LIMIT) { $out->addHtml($this->getMoreButton($rev1->getTimestamp())); } } else { // Edge case. // I suspect this is here because revisions may exist but may have been hidden. $out->addHtml(MobileUI::warningBox($this->msg('mobile-frontend-history-no-results'))); } }
/** * 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 $this->diffClass($this->getContext(), $prevId, $this->revId, 0, false, $unhide); } else { $de->showDiffPage(); return; } $this->mDiffEngine = $de; $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 = MobileUI::warningBox($warnings); } $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); } }