/** * @param Title $title * @param Article $article * @return boolean */ public static function onArticleFromTitle(&$title, &$article) { wfProfileIn(__METHOD__); $app = F::app(); if ($title->isMainPage() && $app->checkSkin('oasis')) { $app->wg->SuppressPageHeader = true; $app->wg->SuppressWikiHeader = true; $app->wg->SuppressRail = true; $app->wg->SuppressFooter = true; if (!$app->wg->request->wasPosted()) { // don't change article object while saving data $article = new VideoHomePageArticle($title); } } wfProfileOut(__METHOD__); return true; }
/** * @param Title $title * @param Article $article * @return boolean */ public static function onArticleFromTitle(&$title, &$article) { wfProfileIn(__METHOD__); $app = F::app(); if ($title->isMainPage() && $app->checkSkin('oasis')) { $app->wg->SuppressPageHeader = true; $app->wg->SuppressWikiHeader = true; $app->wg->SuppressRail = true; $app->wg->SuppressFooter = true; $app->wg->SuppressArticleCategories = true; // If configured, also hide the ads. if (!empty($app->wg->MinimalMainPageHideAds)) { $app->wg->SuppressAds = true; $app->wg->ShowAds = false; } } wfProfileOut(__METHOD__); return true; }
/** * 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; }
/** * @param $out OutputPage * @param $text String * @return bool */ public function beforePageDisplayHTML(&$out, &$text) { global $wgContLang, $wgRequest, $wgMemc, $wgUser; wfProfileIn(__METHOD__); $userAgent = $_SERVER['HTTP_USER_AGENT']; $acceptHeader = isset($_SERVER["HTTP_ACCEPT"]) ? $_SERVER["HTTP_ACCEPT"] : ''; $uAmd5 = md5($userAgent); $key = wfMemcKey('mobile', 'ua', $uAmd5); $props = null; try { $props = $wgMemc->get($key); if (!$props) { $wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml'; $wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile); $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig); $wurflManager = $wurflManagerFactory->create(); $device = $wurflManager->getDeviceForHttpRequest($_SERVER); if ($device->isSpecific() === true) { $props = $device->getAllCapabilities(); $wgMemc->set($key, $props, 86400); } else { $wgMemc->set($key, 'generic', 86400); $props = 'generic'; } } } catch (Exception $e) { // echo $e->getMessage(); } // Note: The WebRequest Class calls are made in this block because // since PHP 5.1.x, all objects have their destructors called // before the output buffer callback function executes. // Thus, globalized objects will not be available as expected in the function. // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104] $xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : ''; self::$useFormat = $wgRequest->getText('useformat'); $mobileAction = $wgRequest->getText('mobileaction'); $action = $wgRequest->getText('action'); if (self::$useFormat !== 'mobile' && self::$useFormat !== 'mobile-wap' && !$xDevice) { wfProfileOut(__METHOD__); return true; } if ($action === 'edit' || $mobileAction === 'view_normal_site') { wfProfileOut(__METHOD__); return true; } self::$title = $out->getTitle(); if (self::$title->isMainPage()) { self::$isMainPage = true; } if (self::$title->getNamespace() == NS_FILE) { self::$isFilePage = true; } self::$htmlTitle = $out->getHTMLTitle(); self::$disableImages = $wgRequest->getText('disableImages', 0); self::$enableImages = $wgRequest->getText('enableImages', 0); self::$displayNoticeId = $wgRequest->getText('noticeid', ''); if (self::$disableImages == 1) { $wgRequest->response()->setcookie('disableImages', 1); $location = str_replace('?disableImages=1', '', str_replace('&disableImages=1', '', $wgRequest->getFullRequestURL())); $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location)); $location = $this->getRelativeURL($location); $wgRequest->response()->header('Location: ' . $location . '&mfi=0'); } elseif (self::$disableImages == 0) { $disableImages = $wgRequest->getCookie('disableImages'); if ($disableImages) { self::$disableImages = $disableImages; } } if (self::$enableImages == 1) { $disableImages = $wgRequest->getCookie('disableImages'); if ($disableImages) { $wgRequest->response()->setcookie('disableImages', ''); } $location = str_replace('?enableImages=1', '', str_replace('&enableImages=1', '', $wgRequest->getFullRequestURL())); $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location)); $location = $this->getRelativeURL($location); $wgRequest->response()->header('Location: ' . $location . '&mfi=1'); } self::$format = $wgRequest->getText('format'); self::$callback = $wgRequest->getText('callback'); self::$requestedSegment = $wgRequest->getText('seg', 0); self::$search = $wgRequest->getText('search'); self::$searchField = $wgRequest->getText('search', ''); $device = new DeviceDetection(); if ($xDevice) { $formatName = $xDevice; } else { $formatName = $device->formatName($userAgent, $acceptHeader); } self::$device = $device->format($formatName); if (self::$device['view_format'] === 'wml') { $this->contentFormat = 'WML'; } elseif (self::$device['view_format'] === 'html') { $this->contentFormat = 'XHTML'; } if (self::$useFormat === 'mobile-wap') { $this->contentFormat = 'WML'; } if ($mobileAction == 'leave_feedback') { echo $this->renderLeaveFeedbackXHTML(); wfProfileOut(__METHOD__); exit; } if ($mobileAction == 'leave_feedback_post') { $this->getMsg(); $subject = $wgRequest->getText('subject', ''); $message = $wgRequest->getText('message', ''); $token = $wgRequest->getText('edittoken', ''); $title = Title::newFromText(self::$messages['mobile-frontend-feedback-page']); if ($title->userCan('edit') && !$wgUser->isBlockedFrom($title) && $wgUser->matchEditToken($token)) { $article = new Article($title, 0); $rawtext = $article->getRawText(); $rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> "; $article->doEdit($rawtext, ''); } $location = str_replace('&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '¬iceid=1&useformat=mobile'); $location = $this->getRelativeURL($location); $wgRequest->response()->header('Location: ' . $location); wfProfileOut(__METHOD__); exit; } if ($mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML') { echo $this->renderDisableMobileSiteXHTML(); wfProfileOut(__METHOD__); exit; } if ($mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML') { echo $this->renderOptInMobileSiteXHTML(); wfProfileOut(__METHOD__); exit; } if ($mobileAction == 'opt_out_mobile_site' && $this->contentFormat == 'XHTML') { echo $this->renderOptOutMobileSiteXHTML(); wfProfileOut(__METHOD__); exit; } if ($mobileAction == 'opt_in_cookie') { wfIncrStats('mobile.opt_in_cookie_set'); $this->setOptInOutCookie('1'); $this->disableCaching(); $location = wfExpandUrl(Title::newMainPage()->getFullURL(), PROTO_CURRENT); $wgRequest->response()->header('Location: ' . $location); } if ($mobileAction == 'opt_out_cookie') { $this->setOptInOutCookie(''); } $this->getMsg(); $this->disableCaching(); $this->sendXDeviceVaryHeader(); $this->sendApplicationVersionVaryHeader(); $this->checkUserStatus(); $this->checkUserLoggedIn(); if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) { self::$wsLoginToken = $wgRequest->getSessionData('wsLoginToken'); $q = array('action' => 'submitlogin', 'type' => 'login'); $returnToVal = $wgRequest->getVal('returnto'); if ($returnToVal) { $q['returnto'] = $returnToVal; } self::$wsLoginFormAction = self::$title->getLocalURL($q); } $this->setDefaultLogo(); ob_start(array($this, 'DOMParse')); wfProfileOut(__METHOD__); return true; }
/** * 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; }