/** * setProps -- change props for comment article * */ public function setProps($props, $update = false) { wfProfileIn(__METHOD__); if ($update && class_exists('BlogArticle')) { BlogArticle::setProps($this->mTitle->getArticleID(), $props); } $this->mProps = $props; wfProfileOut(__METHOD__); }
protected function afterSave($status) { switch ($status->value) { case EditPage::AS_SUCCESS_UPDATE: case EditPage::AS_SUCCESS_NEW_ARTICLE: $article = $this->getEditedArticle(); $articleId = $article->getID(); $aPageProps = array(); $aPageProps['commenting'] = 0; if ($this->getField(self::FIELD_IS_COMMENTING_ENABLED) != "") { $aPageProps['commenting'] = 1; } if (count($aPageProps)) { BlogArticle::setProps($articleId, $aPageProps); } $this->invalidateCacheConnected($article); $this->createListingPage(); // BugID:25123 purge the main blog listing pages cache global $wgMemc; $user = $article->getTitle()->getBaseText(); $ns = $article->getTitle()->getNSText(); foreach (range(0, 5) as $page) { $wgMemc->delete(wfMemcKey('blog', 'listing', $ns, $user, $page)); } $this->out->redirect($article->getTitle()->getFullUrl()); break; default: Wikia::log(__METHOD__, "editpage", $status->value); if ($status->value == EditPage::AS_READ_ONLY_PAGE_LOGGED) { $sMsg = wfMsg('create-blog-cant-edit'); } else { $sMsg = wfMsg('create-blog-spam'); } Wikia::log(__METHOD__, "save error", $sMsg, true); break; } }
/** * Enables commenting for a blog post that has been moved from another namespace * @param Title $oOldTitle An object for the old article's name * @param Title $oNewTitle An object for the new article's name * @param User $oUser * @param integer $iOldId * @param integer $iNewId * @return bool */ public static function onTitleMoveComplete(Title $oOldTitle, Title $oNewTitle, User $oUser, $iOldId, $iNewId) { global $wgArticleCommentsNamespaces; wfProfileIn(__METHOD__); // Enables comments if an article has been moved to // a Blog namespace from a non-blog one // and if the new namespace has comments enabled. if (ArticleComment::isBlog($oNewTitle) && in_array($oNewTitle->getNamespace(), $wgArticleCommentsNamespaces) && $oOldTitle->getNamespace() !== $oNewTitle->getNamespace()) { BlogArticle::setProps($oNewTitle->getArticleID(), ['commenting' => '1']); } wfProfileOut(__METHOD__); return true; }
/** * Hook * * @param Title $oTitle -- instance of Title class * @param User $User -- current user * @param string $reason -- undeleting reason * * @static * @access public * * @return true -- because it's hook */ public static function undeleteComplete($oTitle, $oUser, $reason) { wfProfileIn(__METHOD__); if ($oTitle instanceof Title) { if (in_array($oTitle->getNamespace(), array(NS_BLOG_ARTICLE, NS_BLOG_ARTICLE_TALK))) { $aProps = $oTitle->aProps; $pageId = $oTitle->getArticleId(); if (!empty($aProps)) { BlogArticle::setProps($pageId, $aProps); } } } wfProfileOut(__METHOD__); return true; }
protected function save() { global $wgOut, $wgUser, $wgContLang, $wgRequest; // CategorySelect compatibility (add categories to article body) if ($this->mCategorySelectEnabled) { CategorySelectImportFormData($this->mEditPage, $wgRequest); } $sPostBody = $this->mEditPage->textbox1; /** * add category for blogs (if defined in message and not existed already) * @author eloy */ $catName = wfMsgForContent("create-blog-post-category"); if ($catName && $catName !== "-" && !$this->mPostArticle->exists()) { $sCategoryNSName = $wgContLang->getFormattedNsText(NS_CATEGORY); $sPostBody .= "\n[[" . $sCategoryNSName . ":" . $catName . "]]"; } $aPageProps = array(); $aPageProps['voting'] = 0; $aPageProps['commenting'] = 0; if (!empty($this->mFormData['isVotingEnabled'])) { $aPageProps['voting'] = 1; } if (!empty($this->mFormData['isCommentingEnabled'])) { $aPageProps['commenting'] = 1; } $editPage = new EditBlogPage($this->mPostArticle); $editPage->initialiseForm(); $editPage->textbox1 = $sPostBody; $editPage->watchthis = $this->mFormData['isWatched']; $editPage->summary = isset($this->mFormData['postEditSummary']) ? $this->mFormData['postEditSummary'] : wfMsgForContent('create-blog-updated'); $result = false; $bot = $wgUser->isAllowed('bot') && $wgRequest->getBool('bot', true); $status = $editPage->internalAttemptSave($result, $bot); switch ($status->value) { case EditPage::AS_SUCCESS_UPDATE: case EditPage::AS_SUCCESS_NEW_ARTICLE: if (count($aPageProps)) { BlogArticle::setProps($this->mPostArticle->getId(), $aPageProps); } self::invalidateCacheConnected($this->mPostArticle); $this->createListingPage(); $wgOut->redirect($this->mPostArticle->getTitle()->getFullUrl()); break; // fix an issue with double edit page when captcha is triggered (BugId:6679) // fix an issue with double edit page when captcha is triggered (BugId:6679) case EditPage::AS_HOOK_ERROR: Wikia::log(__METHOD__, 'editpage', 'hook prevented the save'); break; default: Wikia::log(__METHOD__, "editpage", $status->value); if ($status->value == EditPage::AS_READ_ONLY_PAGE_LOGGED) { $sMsg = wfMsg('create-blog-cant-edit'); } else { $sMsg = wfMsg('create-blog-spam'); } $this->mFormErrors[] = $sMsg . '(' . $status->value . ')'; $this->renderForm(); break; } }