/** * Check whether given page exists and return extra info about page (href and title attribute for link) */ public static function checkInternalLink() { global $wgTitle, $wgEnableWallEngine; wfProfileIn(__METHOD__); $res = array('exists' => false); if (!empty($wgTitle)) { // existing local URL or interwiki link $exists = $wgTitle->exists() || $wgTitle->isSpecialPage() || $wgTitle->isExternal() || !empty($wgEnableWallEngine) && WallHelper::isWallNamespace($wgTitle->getNamespace()); $res = array('exists' => $exists, 'external' => $wgTitle->isExternal(), 'href' => $wgTitle->getLocalUrl(), 'title' => $exists ? $wgTitle->getPrefixedText() : wfMsg('red-link-title', $wgTitle->getPrefixedText())); } wfProfileOut(__METHOD__); return $res; }
/** * @brief Hooks into GetRailModuleList * * @return boolean true */ public static function onGetRailModuleList(&$modules) { $app = F::App(); wfProfileIn(__METHOD__); $namespace = $app->wg->Title->getNamespace(); $action = $app->wg->Request->getVal('action', null); if ($action !== 'history' && $namespace === NS_USER_WALL && !$app->wg->Title->isSubpage()) { // we want only chat, achivements and following pages $remove = array(1250, 1450, 1300, 1150); foreach ($remove as $rightRailEl) { if (!empty($modules[$rightRailEl])) { unset($modules[$rightRailEl]); } } } if ($action === 'history' && WallHelper::isWallNamespace($namespace)) { $modules = array(); $modules[1440] = array('WallRail', 'index', null); } wfProfileOut(__METHOD__); return true; }
public function onGetRailModuleSpecialPageList(&$railModuleList) { $app = F::App(); $namespace = $app->wg->Title->getNamespace(); $diff = $app->wg->Request->getVal('diff', false); $isDiff = !empty($diff) && $app->wg->Request->getVal('oldid', false); if ($isDiff && WallHelper::isWallNamespace($namespace)) { //SuppressRail $railModuleList = array(); } return true; }
public static function onChangesListItemGroupRegular(&$link, &$rcObj) { if (WallHelper::isWallNamespace(intval($rcObj->getAttribute('rc_namespace')))) { $wallMsg = WallMessage::newFromId($rcObj->getAttribute('rc_cur_id')); if (!empty($wallMsg)) { /* @var $wallMsg Wall */ $url = $wallMsg->getMessagePageUrl(); $link = '<a href="' . $url . '">' . $rcObj->timestamp . '</a>'; $rcObj->curlink = '<a href="' . $url . '">' . wfMessage('cur')->escaped() . '</a>'; } } return true; }
public function getRailModuleList() { wfProfileIn(__METHOD__); global $wgTitle, $wgUser, $wgEnableAchievementsExt, $wgContentNamespaces, $wgExtraNamespaces, $wgExtraNamespacesLocal, $wgEnableWikiAnswers, $wgEnableHuluVideoPanel, $wgEnableWallEngine, $wgRequest, $wgEnableForumExt; $namespace = $wgTitle->getNamespace(); $subjectNamespace = MWNamespace::getSubject($namespace); $railModuleList = array(); $latestActivityKey = $wgUser->isAnon() ? 1250 : 1300; $huluVideoPanelKey = $wgUser->isAnon() ? 1390 : 1280; // Forum Extension if ($wgEnableForumExt && ForumHelper::isForum()) { $railModuleList = array(1202 => array('Forum', 'forumRelatedThreads', null), 1201 => array('Forum', 'forumActivityModule', null), 1490 => array('Ad', 'Index', ['slotName' => 'TOP_RIGHT_BOXAD'])); // Include additional modules from other extensions (like chat) wfRunHooks('GetRailModuleList', array(&$railModuleList)); wfProfileOut(__METHOD__); return $railModuleList; } if ($namespace == NS_SPECIAL) { if (WikiaPageType::isSearch()) { if (empty($this->wg->EnableWikiaHomePageExt)) { $railModuleList = array($latestActivityKey => array('LatestActivity', 'Index', null)); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if (empty($wgEnableWikiAnswers)) { if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } } else { if ($wgTitle->isSpecial('Leaderboard')) { $railModuleList = array($latestActivityKey => array('LatestActivity', 'Index', null), 1290 => array('LatestEarnedBadges', 'Index', null)); } else { if ($wgTitle->isSpecial('WikiActivity')) { $railModuleList = array(1102 => array('HotSpots', 'Index', null), 1101 => array('CommunityCorner', 'Index', null)); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); } else { if ($wgTitle->isSpecial('Following') || $wgTitle->isSpecial('Contributions')) { // intentional nothing here } else { if ($wgTitle->isSpecial('ThemeDesignerPreview')) { $railModuleList = array($latestActivityKey => array('LatestActivity', 'Index', null)); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if (empty($wgEnableWikiAnswers)) { if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } else { // don't show any module for MW core special pages $railModuleList = array(); wfRunHooks('GetRailModuleSpecialPageList', array(&$railModuleList)); wfProfileOut(__METHOD__); return $railModuleList; } } } } } } // Content, category and forum namespaces. FB:1280 Added file,video,mw,template if ($wgTitle->isSubpage() && $wgTitle->getNamespace() == NS_USER || in_array($subjectNamespace, array(NS_CATEGORY, NS_CATEGORY_TALK, NS_FORUM, NS_PROJECT, NS_FILE, NS_MEDIAWIKI, NS_TEMPLATE, NS_HELP)) || in_array($subjectNamespace, $wgContentNamespaces) || array_key_exists($subjectNamespace, $wgExtraNamespaces)) { // add any content page related rail modules here $railModuleList[$latestActivityKey] = array('LatestActivity', 'Index', null); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if (empty($wgEnableWikiAnswers)) { if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } // User page namespaces if (in_array($wgTitle->getNamespace(), self::getUserPagesNamespaces())) { $page_owner = User::newFromName($wgTitle->getText()); if ($page_owner) { if (!$page_owner->getGlobalPreference('hidefollowedpages')) { $railModuleList[1101] = array('FollowedPages', 'Index', null); } if ($wgEnableAchievementsExt) { $railModuleList[1102] = array('Achievements', 'Index', null); } } } if (self::isBlogPost() || self::isBlogListing()) { $railModuleList[1250] = array('PopularBlogPosts', 'Index', null); } // No rail on main page or edit page for oasis skin // except &action=history of wall if (!empty($wgEnableWallEngine)) { $isEditPage = !WallHelper::isWallNamespace($namespace) && BodyController::isEditPage() || $wgRequest->getVal('diff'); } else { $isEditPage = BodyController::isEditPage(); } if ($isEditPage || WikiaPageType::isMainPage()) { $modules = array(); wfRunHooks('GetEditPageRailModuleList', array(&$modules)); wfProfileOut(__METHOD__); return $modules; } // No modules on Custom namespaces, unless they are in the ContentNamespaces list, those get the content rail if (is_array($wgExtraNamespacesLocal) && array_key_exists($subjectNamespace, $wgExtraNamespacesLocal) && !in_array($subjectNamespace, $wgContentNamespaces)) { wfProfileOut(__METHOD__); return array(); } // If the entire page is non readable due to permissions, don't display the rail either RT#75600 if (!$wgTitle->userCan('read')) { wfProfileOut(__METHOD__); return array(); } $railModuleList[1440] = array('Ad', 'Index', ['slotName' => 'TOP_RIGHT_BOXAD']); $railModuleList[1100] = array('Ad', 'Index', ['slotName' => 'LEFT_SKYSCRAPER_2']); unset($railModuleList[1450]); wfRunHooks('GetRailModuleList', array(&$railModuleList)); wfProfileOut(__METHOD__); return $railModuleList; }
/** * add comment to database */ public function addToDatabase() { $this->wf->ProfileIn(__METHOD__); //Just for transition time if (empty($this->wg->EnableWallEngine) || !WallHelper::isWallNamespace($this->namespace)) { return false; } if (!$this->wf->ReadOnly()) { $this->createTableCommentsIndex(); $db = $this->wf->GetDB(DB_MASTER); $timestamp = $db->timestamp(); if (empty($this->createdAt)) { $this->createdAt = $timestamp; } if (empty($this->lastTouched)) { $this->lastTouched = $timestamp; } $db->replace('comments_index', '', array('parent_page_id' => $this->parentPageId, 'comment_id' => $this->commentId, 'parent_comment_id' => $this->parentCommentId, 'last_child_comment_id' => $this->lastChildCommentId == 0 ? $this->commentId : $this->lastChildCommentId, 'archived' => $this->archived, 'deleted' => $this->deleted, 'removed' => $this->removed, 'locked' => $this->locked, 'protected' => $this->protected, 'sticky' => $this->sticky, 'first_rev_id' => $this->firstRevId, 'created_at' => $this->createdAt, 'last_rev_id' => $this->lastRevId, 'last_touched' => $this->lastTouched), __METHOD__); $db->commit(); } $this->wf->ProfileOut(__METHOD__); }
/** * Hook into MW transaction that creates new article comments and execute queries that create comments_index entries * @param $dbw database connetion * @param Title $title newly created article * @param Revision $revision revision containig the lastest version of article comment * @param $flags Integer bitfield, the same as in WikiPage::doEdit method */ public static function onArticleDoEdit($dbw, Title $title, Revision $revision, $flags) { global $wgEnableWallEngine; if (!empty($wgEnableWallEngine) && WallHelper::isWallNamespace($title->getNamespace())) { if ($flags & EDIT_NEW) { $titleText = $title->getText(); if (isset(self::$commentInfoData[$titleText])) { $data = array('namespace' => self::$commentInfoData[$titleText]->userPageTitle->getNamespace(), 'parentPageId' => self::$commentInfoData[$titleText]->userPageTitle->getArticleID(), 'commentId' => $title->getArticleID(), 'parentCommentId' => intval(self::$commentInfoData[$titleText]->parentId), 'firstRevId' => $revision->getId(), 'lastRevId' => $revision->getId()); $commentsIndex = new CommentsIndex($data, $dbw); $commentsIndex->addToDatabase(); $commentsIndex->updateParentLastCommentId($data['commentId']); } } else { $commentsIndex = CommentsIndex::newFromId($title->getArticleID(), 0, $dbw); if ($commentsIndex instanceof CommentsIndex) { $commentsIndex->updateLastRevId($revision->getId()); } } } return true; }
public function getRailModuleList() { wfProfileIn(__METHOD__); global $wgTitle, $wgUser, $wgEnableAchievementsExt, $wgContentNamespaces, $wgExtraNamespaces, $wgExtraNamespacesLocal, $wgEnableCorporatePageExt, $wgEnableWikiAnswers, $wgSalesTitles, $wgEnableHuluVideoPanel, $wgEnableGamingCalendarExt, $wgEnableWallEngine, $wgRequest; $namespace = $wgTitle->getNamespace(); $subjectNamespace = MWNamespace::getSubject($namespace); $railModuleList = array(); $latestPhotosKey = $wgUser->isAnon() ? 1300 : 1250; $latestActivityKey = $wgUser->isAnon() ? 1250 : 1300; $huluVideoPanelKey = $wgUser->isAnon() ? 1390 : 1280; // Forum Extension if (WikiaPageType::isForum()) { $railModuleList = array ( 1500 => array('Search', 'Index', null), 1002 => array('Forum', 'forumRelatedThreads', null), 1001 => array('Forum', 'forumActivityModule', null), 1000 => array('Forum', 'forumParticipationModule', null), 1490 => array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')), ); return $railModuleList; } if($namespace == NS_SPECIAL) { if (WikiaPageType::isSearch()) { if (empty($this->wg->EnableWikiaHomePageExt)) { $railModuleList = array( $latestActivityKey => array('LatestActivity', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } elseif ($wgEnableCorporatePageExt) { $railModuleList = array( 1490 => array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')) ); wfProfileOut(__METHOD__); return $railModuleList; } } else if ($wgTitle->isSpecial('Leaderboard')) { $railModuleList = array ( 1500 => array('Search', 'Index', null), $latestActivityKey => array('LatestActivity', 'Index', null), 1290 => array('LatestEarnedBadges', 'Index', null) ); } else if ($wgTitle->isSpecial('WikiActivity')) { $railModuleList = array ( 1500 => array('Search', 'Index', null), 1102 => array('HotSpots', 'Index', null), 1101 => array('CommunityCorner', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); } else if ($wgTitle->isSpecial('Following') || $wgTitle->isSpecial('Contributions') ) { // intentional nothing here } else if ($wgTitle->isSpecial('ThemeDesignerPreview') ) { $railModuleList = array ( 1500 => array('Search', 'Index', null), $latestActivityKey => array('LatestActivity', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } else if( $wgTitle->isSpecial('PageLayoutBuilderForm') ) { $railModuleList = array ( 1501 => array('Search', 'Index', null), 1500 => array('PageLayoutBuilderForm', 'Index', null) ); } else { // don't show any module for MW core special pages $railModuleList = array(); wfRunHooks( 'GetRailModuleSpecialPageList', array( &$railModuleList ) ); wfProfileOut(__METHOD__); return $railModuleList; } } else if ( !self::showUserPagesHeader() ) { // ProfilePagesV3 renders its own search box. // If this page is not a page with the UserPagesHeader on version 3, show search (majority case) $railModuleList = array ( 1500 => array('Search', 'Index', null), ); } // Content, category and forum namespaces. FB:1280 Added file,video,mw,template if( $wgTitle->isSubpage() && $wgTitle->getNamespace() == NS_USER || in_array($subjectNamespace, array (NS_CATEGORY, NS_CATEGORY_TALK, NS_FORUM, NS_PROJECT, NS_FILE, NS_VIDEO, NS_MEDIAWIKI, NS_TEMPLATE, NS_HELP)) || in_array($subjectNamespace, $wgContentNamespaces) || array_key_exists( $subjectNamespace, $wgExtraNamespaces ) ) { // add any content page related rail modules here $railModuleList[$latestActivityKey] = array('LatestActivity', 'Index', null); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } // User page namespaces if( in_array($wgTitle->getNamespace(), self::getUserPagesNamespaces() ) ) { $page_owner = User::newFromName($wgTitle->getText()); if($page_owner) { if( !$page_owner->getOption('hidefollowedpages') ) { $railModuleList[1101] = array('FollowedPages', 'Index', null); } if($wgEnableAchievementsExt && !(($wgUser->getId() == $page_owner->getId()) && $page_owner->getOption('hidepersonalachievements'))){ $railModuleList[1102] = array('Achievements', 'Index', null); } } } if (self::isBlogPost() || self::isBlogListing()) { $railModuleList[1500] = array('Search', 'Index', null); $railModuleList[1250] = array('PopularBlogPosts', 'Index', null); } // A/B testing leftovers, leave for now because we will do another one $useTestBoxad = false; // Special case rail modules for Corporate Skin if ($wgEnableCorporatePageExt) { $railModuleList = array ( 1500 => array('Search', 'Index', null), ); // No rail on main page or edit page for corporate skin if ( BodyController::isEditPage() || WikiaPageType::isMainPage() ) { $railModuleList = array(); } else if (self::isHubPage()) { if ($useTestBoxad) { $railModuleList[1490] = array('Ad', 'Index', array('slotname' => 'TEST_TOP_RIGHT_BOXAD')); } else { $railModuleList[1490] = array('Ad', 'Index', array('slotname' => 'CORP_TOP_RIGHT_BOXAD')); } $railModuleList[1480] = array('CorporateSite', 'HotSpots', null); // $railModuleList[1470] = array('CorporateSite', 'PopularHubPosts', null); // temp disabled - data not updating $railModuleList[1460] = array('CorporateSite', 'TopHubUsers', null); } else if ( is_array( $wgSalesTitles ) && in_array( $wgTitle->getText(), $wgSalesTitles ) ){ $railModuleList[1470] = array('CorporateSite', 'SalesSupport', null); } else { // content pages $railModuleList[1470] = array('CorporateSite', 'PopularStaffPosts', null); } wfProfileOut(__METHOD__); return $railModuleList; } // No rail on main page or edit page for oasis skin // except &action=history of wall if( !empty($wgEnableWallEngine) ) { $isEditPage = !WallHelper::isWallNamespace($namespace) && BodyController::isEditPage() || $wgRequest->getVal('diff'); } else { $isEditPage = BodyController::isEditPage(); } if ( $isEditPage || WikiaPageType::isMainPage() ) { $modules = array(); wfRunHooks( 'GetEditPageRailModuleList', array( &$modules ) ); wfProfileOut(__METHOD__); return $modules; } // No modules on Custom namespaces, unless they are in the ContentNamespaces list, those get the content rail if (is_array($wgExtraNamespacesLocal) && array_key_exists($subjectNamespace, $wgExtraNamespacesLocal) && !in_array($subjectNamespace, $wgContentNamespaces)) { wfProfileOut(__METHOD__); return array(); } // If the entire page is non readable due to permissions, don't display the rail either RT#75600 if (!$wgTitle->userCan( 'read' )) { wfProfileOut(__METHOD__); return array(); } if ($useTestBoxad) { $railModuleList[1440] = array('Ad', 'Index', array('slotname' => 'TEST_TOP_RIGHT_BOXAD')); } else { $railModuleList[1440] = array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')); } $railModuleList[1291] = array('Ad', 'Index', array('slotname' => 'MIDDLE_RIGHT_BOXAD')); $railModuleList[1100] = array('Ad', 'Index', array('slotname' => 'LEFT_SKYSCRAPER_2')); /** * Michał Roszka <*****@*****.**> * * SSW Gaming Calendar * * This is most likely going to be replaced with something similar to: * * $railModuleList[1260] = array( 'Ad', 'Index', array( 'slotname' => 'GAMING_CALENDAR_RAIL' ) ); */ if ( !empty( $wgEnableGamingCalendarExt ) ) { $railModuleList[1430] = array( 'GamingCalendarRail', 'Index', array( ) ); } else { $railModuleList[1430] = array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BUTTON')); } // WikiNav v2 - begin // TODO: remove once it's enabled sitewide global $wgOasisNavV2; if (!empty($wgOasisNavV2)) { // remove PagesOnWiki module unset($railModuleList[1450]); } // WikiNav v2 - end wfRunHooks( 'GetRailModuleList', array( &$railModuleList ) ); wfProfileOut(__METHOD__); return $railModuleList; }
/** * Hook * * @param WikiPage $wikiPage -- instance of Article class * @param User $user -- current user * @param string $reason -- deleting reason * @param integer $id -- article id * * @static * @access public * * @return boolean -- because it's a hook */ public static function articleDeleteComplete(WikiPage &$wikiPage, &$user, $reason, $id) { global $wgOut, $wgRC2UDPEnabled, $wgMaxCommentsToDelete, $wgCityId, $wgUser, $wgEnableMultiDeleteExt; wfProfileIn(__METHOD__); $title = $wikiPage->getTitle(); if (!MWNamespace::isTalk($title->getNamespace()) || !ArticleComment::isTitleComment($title)) { if (empty(self::$mArticlesToDelete)) { wfProfileOut(__METHOD__); return true; } } if (class_exists('WallHelper') && WallHelper::isWallNamespace($title->getNamespace())) { wfProfileOut(__METHOD__); return true; } //watch out for recursion if (self::$mDeletionInProgress) { wfProfileOut(__METHOD__); return true; } self::$mDeletionInProgress = true; //redirect to article/blog after deleting a comment (or whole article/blog) $parts = ArticleComment::explode($title->getText()); $parentTitle = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace())); $wgOut->redirect($parentTitle->getFullUrl()); //do not use $reason as it contains content of parent article/comment - not current ones that we delete in a loop $deleteReason = wfMsgForContent('article-comments-delete-reason'); //we have comment 1st level - checked in articleDelete() (or 2nd - so do nothing) if (is_array(self::$mArticlesToDelete)) { $mDelete = 'live'; if (isset($wgMaxCommentsToDelete) && count(self::$mArticlesToDelete) > $wgMaxCommentsToDelete) { if (!empty($wgEnableMultiDeleteExt)) { $mDelete = 'task'; } } if ($mDelete == 'live') { $irc_backup = $wgRC2UDPEnabled; //backup $wgRC2UDPEnabled = false; //turn off foreach (self::$mArticlesToDelete as $page_id => $oComment) { $oCommentTitle = $oComment->getTitle(); if ($oCommentTitle instanceof Title) { $oComment = new ArticleComment($oCommentTitle); $oComment->doDeleteComment($deleteReason); } } $wgRC2UDPEnabled = $irc_backup; //restore to whatever it was $listing = ArticleCommentList::newFromTitle($parentTitle); $listing->purge(); } else { $taskParams = array('mode' => 'you', 'wikis' => '', 'range' => 'one', 'reason' => 'delete page', 'lang' => '', 'cat' => '', 'selwikia' => $wgCityId, 'edittoken' => $wgUser->getEditToken(), 'user' => $wgUser->getName(), 'admin' => $wgUser->getName()); foreach (self::$mArticlesToDelete as $oComment) { $oCommentTitle = $oComment->getTitle(); if ($oCommentTitle instanceof Title) { /* @var $oCommentTitle Title */ $data = $taskParams; $data['page'] = $oCommentTitle->getFullText(); $task = new \Wikia\Tasks\Tasks\MultiTask(); $task->call('delete', $data); $submit_id = $task->queue(); Wikia::log(__METHOD__, 'deletecomment', "Added task ({$submit_id}) for {$data['page']} page"); } } } } wfProfileOut(__METHOD__); return true; }