/** * Prepare the content for the 'last edited' message, e.g. 'Last edited on 30 August * 2013, at 23:31'. This message is different for the main page since main page * content is typically transcuded rather than edited directly. * @param Title $title The Title object of the page being viewed * @return array */ protected function getHistoryLink(Title $title) { $user = $this->getUser(); $isMainPage = $title->isMainPage(); // add last modified timestamp $revId = $this->getRevisionId(); $timestamp = Revision::getTimestampFromId($this->getTitle(), $revId); // Main pages tend to include transclusions (see bug 51924) if ($isMainPage) { $lastModified = $this->msg('mobile-frontend-history')->plain(); } else { $lastModified = $this->msg('mobile-frontend-last-modified-date', $this->getLanguage()->userDate($timestamp, $user), $this->getLanguage()->userTime($timestamp, $user))->parse(); } $unixTimestamp = wfTimestamp(TS_UNIX, $timestamp); $historyUrl = $this->mobileContext->getMobileUrl($title->getFullURL('action=history')); $link = array('data-timestamp' => $isMainPage ? '' : $unixTimestamp, 'href' => $historyUrl, 'text' => $lastModified, 'data-user-name' => '', 'data-user-gender' => 'unknown'); $rev = Revision::newFromId($this->getRevisionId()); if ($rev) { $userId = $rev->getUser(); if ($userId) { $revUser = User::newFromId($userId); $revUser->load(User::READ_NORMAL); $link = array_merge($link, array('data-user-name' => $revUser->getName(), 'data-user-gender' => $revUser->getOption('gender'))); } } $link['href'] = SpecialPage::getTitleFor('History', $title)->getLocalURL(); return $link; }
/** * Prepare the content for the 'last edited' message, e.g. 'Last edited on 30 August * 2013, at 23:31'. This message is different for the main page since main page * content is typically transcuded rather than edited directly. * @param Title $title The Title object of the page being viewed * @return array */ protected function getHistoryLink(Title $title) { $user = $this->getUser(); $isMainPage = $title->isMainPage(); $mp = new MobilePage($this->getTitle(), false); $timestamp = $mp->getLatestTimestamp(); // Main pages tend to include transclusions (see bug 51924) if ($isMainPage) { $lastModified = $this->msg('mobile-frontend-history')->plain(); } else { $lastModified = $this->msg('mobile-frontend-last-modified-date', $this->getLanguage()->userDate($timestamp, $user), $this->getLanguage()->userTime($timestamp, $user))->parse(); } $historyUrl = $this->mobileContext->getMobileUrl($title->getFullURL('action=history')); $edit = $mp->getLatestEdit(); $link = array('data-timestamp' => $isMainPage ? '' : $edit['timestamp'], 'href' => $historyUrl, 'text' => $lastModified, 'data-user-name' => $edit['name'], 'data-user-gender' => $edit['gender']); $link['href'] = SpecialPage::getTitleFor('History', $title)->getLocalURL(); return $link; }
/** * Appends a mobile view link to the desktop footer * @param Skin $sk * @param QuickTemplate $tpl * @param MobileContext $ctx * @param Title $title * @param WebRequest $req */ public static function desktopFooter($sk, $tpl, $ctx, $title, $req) { $footerlinks = $tpl->data['footerlinks']; $args = $req->getQueryValues(); // avoid title being set twice unset($args['title'], $args['useformat']); $args['mobileaction'] = 'toggle_view_mobile'; $mobileViewUrl = $title->getFullURL($args); $mobileViewUrl = $ctx->getMobileUrl($mobileViewUrl); $link = Html::element('a', array('href' => $mobileViewUrl, 'class' => 'noprint stopMobileRedirectToggle'), wfMessage('mobile-frontend-view')->text()); $tpl->set('mobileview', $link); $footerlinks['places'][] = 'mobileview'; $tpl->set('footerlinks', $footerlinks); }