public function executeIndex() { wfProfileIn(__METHOD__); if (class_exists('ArticleCommentInit') && ArticleCommentInit::ArticleCommentCheck()) { $isMobile = $this->app->checkSkin('wikiamobile'); // for non-JS version !!! (used also for Monobook and WikiaMobile) if ($this->wg->Request->wasPosted()) { $sComment = $this->wg->Request->getVal('wpArticleComment', false); $iArticleId = $this->wg->Request->getVal('wpArticleId', false); $sSubmit = $this->wg->Request->getVal('wpArticleSubmit', false); if ($sSubmit && $sComment && $iArticleId) { $oTitle = Title::newFromID($iArticleId); if ($oTitle instanceof Title) { $response = ArticleComment::doPost($this->wg->Request->getVal('wpArticleComment'), $this->wg->User, $oTitle); if (!$isMobile) { $this->wg->Out->redirect($oTitle->getLocalURL()); } else { $result = array(); $canComment = ArticleCommentInit::userCanComment($result, $oTitle); //this check should be done for all the skins and before calling ArticleComment::doPost but that requires a good bit of refactoring //and some design review as the OAsis/Monobook template doesn't handle error feedback from this code if ($canComment == true) { if (empty($response[2]['error'])) { //wgOut redirect doesn't work when running fully under the //Nirvana stack (WikiaMobile skin), also send back to the first page of comments $this->response->redirect($oTitle->getLocalURL(array('page' => 1)) . '#article-comments'); } else { $this->response->setVal('error', $response[2]['msg']); } } else { $this->response->setVal('error', $result['msg']); } } } } } $this->page = $this->wg->request->getVal('page', 1); $this->isLoadingOnDemand = ArticleComment::isLoadingOnDemand(); $this->isMiniEditorEnabled = ArticleComment::isMiniEditorEnabled(); if ($this->isLoadingOnDemand) { $this->response->setJsVar('wgArticleCommentsLoadOnDemand', true); } else { $this->getCommentsData($this->wg->Title, $this->page); if ($isMobile) { $this->forward(__CLASS__, 'WikiaMobileIndex', false); } else { if ($this->app->checkSkin('oasis')) { $this->response->addAsset('articlecomments' . ($this->isMiniEditorEnabled ? '_mini_editor' : '') . '_scss'); } } } } wfProfileOut(__METHOD__); }
/** * axReply -- static hook/entry for ajax request post -- reply a comment * * @static * @access public * * @return String -- html -> textarea */ public static function axReply() { global $wgRequest, $wgStylePath; $articleId = $wgRequest->getVal('article', false); $commentId = $wgRequest->getVal('id', false); $result = array('id' => $commentId); $title = Title::newFromID($articleId); if (!$title) { $result['error'] = 1; return $result; } $canComment = ArticleCommentInit::userCanComment($result, $title); if ($canComment == true) { $articleId = $wgRequest->getVal('article', false); $vars = array('commentId' => $commentId, 'isMiniEditorEnabled' => ArticleComment::isMiniEditorEnabled(), 'stylePath' => $wgStylePath); $result['html'] = F::app()->getView('ArticleComments', 'Reply', $vars)->render(); } return $result; }