Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12854 from Wikia/release-505-MAIN-10316
Browse files Browse the repository at this point in the history
Revert "Merge pull request #12611 from Wikia/IRIS-3983"
  • Loading branch information
slayful authored Apr 27, 2017
2 parents bdc8e60 + 69c271d commit fef293c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 865 deletions.
27 changes: 6 additions & 21 deletions extensions/wikia/Discussions/Discussions.setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
$wgAutoloadClasses['DiscussionsVarTogglerException'] = $dir . 'DiscussionsVarToggler.class.php';
$wgAutoloadClasses['ThreadCreator'] = $dir . 'api/ThreadCreator.class.php';
$wgAutoloadClasses['DiscussionsActivator'] = $dir . 'api/DiscussionsActivator.class.php';
$wgAutoloadClasses['LegacyRedirect'] = $dir . 'api/LegacyRedirect.class.php';
$wgAutoloadClasses['StaffWelcomePoster'] = $dir . 'maintenance/StaffWelcomePoster.class.php';

// register special page
Expand All @@ -30,25 +29,7 @@
// is enabled and Forums are disabled.
if ( !empty( $wgEnableDiscussions ) && empty( $wgEnableForumExt ) ) {
$wgAutoloadClasses['SpecialForumRedirectController'] = $dir . 'controllers/SpecialForumRedirectController.class.php';
$wgHooks['ArticleViewHeader'][] = 'SpecialForumRedirectController::onArticleViewHeader';
$wgHooks['BeforePageHistory'][] = 'SpecialForumRedirectController::onBeforePageHistory';
$wgSpecialPages['Forum'] = 'SpecialForumRedirectController';

// Make sure we recognize the Forum namespaces so we can redirect them if requested
$wgExtensionNamespacesFiles['Discussions'] = $dir . '../Forum/Forum.namespaces.php';
wfLoadExtensionNamespaces( 'Forum',
[
NS_WIKIA_FORUM_BOARD,
NS_WIKIA_FORUM_BOARD_THREAD,
NS_WIKIA_FORUM_TOPIC_BOARD
]
);

$app->registerNamespaceController(
NS_WIKIA_FORUM_BOARD,
'SpecialForumRedirectController',
'redirectBoardToCategory'
);
}

// message files
Expand All @@ -67,13 +48,17 @@
$wgHooks['WikiaSkinTopScripts'][] = 'addDiscussionJsVariable';

/**
* MW1.19 - ResourceLoaderStartUpModule class adds more variables
* @param array $vars JS variables to be added at the bottom of the page
* @param $scripts
*
* @param OutputPage $out
* @return bool return true - it's a hook
*/
function addDiscussionJsVariable(Array &$vars, &$scripts) {
wfProfileIn(__METHOD__);

$vars['wgDiscussionsApiUrl'] = F::app()->wg->DiscussionsApiUrl;

wfProfileOut(__METHOD__);
return true;
}

80 changes: 0 additions & 80 deletions extensions/wikia/Discussions/api/LegacyRedirect.class.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,147 +4,11 @@ class SpecialForumRedirectController extends WikiaSpecialPageController {

const DISCUSSIONS_LINK = '/d/f';

private $legacyRedirect;

public function __construct() {
parent::__construct( 'Forum', '', false );

$this->legacyRedirect = new LegacyRedirect( F::App()->wg->CityId );
}

public function index() {
$this->redirectForumToDiscussions();
}

/**
* Redirect requests for Special:Forum to discussions, e.g. from:
*
* http://garth.wikia.com/wiki/Special:Forum
*
* to:
*
* http://garth.wikia.com/d/f?sort=latest
*/
public function redirectForumToDiscussions() {
$discussionUrl = $this->getDiscussionUrl();
$this->response->redirect( $discussionUrl );
}

/**
* Redirect requests for the board page to discussions, e.g, from:
*
* http://garth.wikia.com/wiki/Board:Some_Board_Name
*
* to:
*
* http://garth.wikia.com/d/f?catId=2016136434548737693
*
* This is handled by registering a namespace controller (deprecated currently, but how wall
* works) e.g. this line in Discussions.setup.php:
*
* $app->registerNamespaceController(
* NS_WIKIA_FORUM_BOARD,
* 'SpecialForumRedirectController',
* 'redirectBoardToCategory',
* );
*
*/
public function redirectBoardToCategory() {
// No template for this, we're only interested in setting the redirect.
$this->skipRendering();

$boardId = $this->getBoardId();
$categoryUrl = $this->legacyRedirect->getBoardRedirect( $boardId );

$this->response->redirect( $categoryUrl );
}

/**
* Redirect requests for a thread to discussions, e.g. from:
*
* http://garth.garth.wikia-dev.us/wiki/Thread:2892
*
* to:
*
* http://garth.wikia.com/d/p/2914856863801542335
*
* @param Title $thread
*/
public static function redirectThreadToPost( Title $thread ) {
$threadId = $thread->getArticleID();

$legacyRedirect = new LegacyRedirect( F::App()->wg->CityId );
$postUrl = $legacyRedirect->getThreadRedirect( $threadId );

F::app()->wg->Out->redirect( $postUrl );
}

private function getDiscussionUrl() {
return self::DISCUSSIONS_LINK;
}

private function getBoardId() {
return $this->wg->Title->getArticleID();
}

/**
* @param Article $article
*
* @return bool
*/
public static function onBeforePageHistory( &$article ) {
self::redirectPage( $article );
return true;
}

/**
* @param Article $article
* @param bool $outputDone
* @param bool $useParserCache
*
* @return bool
*/
public static function onArticleViewHeader( &$article, &$outputDone, &$useParserCache ) {
self::redirectPage( $article );
return true;
}

private static function redirectPage( &$article ) {
$mainTitle = self::getMainTitle( $article );
if ( empty( $mainTitle ) ) {
return;
}

// Redirect to discussions
self::redirectThreadToPost( $mainTitle );
}

/**
* Some of this logic has been borrowed from WallHooksHelper::onArticleViewHeader
*
* @param Article $article
* @return null|Title
*/
private static function getMainTitle( Article $article ) {
$title = $article->getTitle();

if ( $title->getNamespace() != NS_USER_WALL_MESSAGE || $title->getText() <= 0 ) {
return null;
}

$mainTitle = Title::newFromId( $title->getText() );

if ( empty( $mainTitle ) ) {
return null;
}

$dbKey = $mainTitle->getDBkey();

$helper = new WallHelper();
if ( !$helper->isDbkeyFromWall( $dbKey ) ) {
return null;
}

return $mainTitle;
$this->response->redirect( self::DISCUSSIONS_LINK );
}
}
}
4 changes: 2 additions & 2 deletions extensions/wikia/Forum/Forum.setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
include ( $dir . '/Forum.namespace.setup.php' );

// add this namespace to list of wall namespaces
$app->registerNamespaceController( NS_WIKIA_FORUM_BOARD, 'ForumController', 'board', true );
$app->registerNamespaceController( NS_WIKIA_FORUM_TOPIC_BOARD, 'ForumController', 'board', true );
$app->registerNamespaceControler( NS_WIKIA_FORUM_BOARD, 'ForumController', 'board', true );
$app->registerNamespaceControler( NS_WIKIA_FORUM_TOPIC_BOARD, 'ForumController', 'board', true );

JSMessages::registerPackage( 'Forum', [
'back',
Expand Down
Loading

0 comments on commit fef293c

Please sign in to comment.