/** * @deprecated legacy entry point for cached JS requests */ public function checkData() { $articleId = $this->getVal('articleId'); $title = Title::newFromId($articleId); if (empty($articleId) || empty($title)) { $this->replace = false; $this->articleId = $articleId; return; } $messages = RelatedForumDiscussionController::getData($articleId); $timediff = time() - $messages['lastupdate']; $this->lastupdate = $messages['lastupdate']; $this->timediff = $timediff; unset($messages['lastupdate']); if ($timediff < 24 * 60 * 60) { $this->replace = true; $this->html = $this->app->renderView("RelatedForumDiscussion", "relatedForumDiscussion", array('messages' => $messages)); } else { $this->replace = false; $this->html = ''; } $this->response->setFormat(WikiaResponse::FORMAT_JSON); $this->response->setCacheValidity(6 * 60 * 60, WikiaResponse::CACHE_DISABLED); }
/** * Display Related Discussion (Forum posts) in bottom of article * @param OutputPage $out * @param string $text article HTML * @return bool: true because it is a hook */ public static function onOutputPageBeforeHTML(OutputPage $out, &$text) { $app = F::app(); $title = $out->getTitle(); if ($out->isArticle() && $title->exists() && $title->getNamespace() == NS_MAIN && !Wikia::isMainPage() && $out->getRequest()->getVal('diff') === null && $out->getRequest()->getVal('action') !== 'render' && !$app->checkSkin('wikiamobile', $out->getSkin())) { // VOLDEV-46: Omit zero-state, only render if there are related forum threads $messages = RelatedForumDiscussionController::getData($title->getArticleId()); unset($messages['lastupdate']); if (!empty($messages)) { $text .= $app->renderView('RelatedForumDiscussionController', 'index', array('messages' => $messages)); } } return true; }