We're still getting this site set up. Feel free to help out if you feel you can. Thank you for your patience.
Header
From Tp Wiki
m (Reverted edit of No. 1 Chelsea Fan, changed back to last version by Seba Nile) |
|||
Line 1: | Line 1: | ||
- | + | <?php | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | if(!defined('MEDIAWIKI')) { | |
- | // | + | header("HTTP/1.1 404 Not Found"); |
- | + | die('<H1>404 Not found</H1>'); | |
+ | } | ||
+ | |||
+ | /** | ||
+ | * A hook that adds a theories tab to Lostpedia | ||
+ | * | ||
+ | * @package MediaWiki | ||
+ | * @subpackage Extensions | ||
+ | * | ||
+ | * @author Jabberwock @ Lostpedia | ||
+ | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later | ||
+ | */ | ||
+ | $wgExtensionFunctions[] = 'wfTheoryTab'; | ||
+ | $wgExtensionCredits['other'][] = array( | ||
+ | 'name' => 'Theory Tab', | ||
+ | 'description' => 'Adds a theories tab to articles', | ||
+ | 'author' => '[http://lostpedia.com/wiki/User:jabrwocky7 Jabberwock]' | ||
+ | ); | ||
+ | |||
+ | # Enable subpages in the main namespace | ||
+ | $wgNamespacesWithSubpages[NS_MAIN] = true; | ||
+ | |||
+ | //install extension hooks | ||
+ | $wgHooks['SkinTemplateTabs'][] = 'TheoryTabHook'; | ||
+ | |||
+ | |||
+ | // Intialize | ||
+ | function wfTheoryTab() { | ||
+ | global $wgMessageCache, $wgParser, $wgUser, $wgVersion; | ||
+ | |||
+ | // add a tab on the article page | ||
+ | function TheoryTabHook(&$skin , &$content_actions ) { | ||
+ | global $wgTitle, $tMain, $tTheory, $tHREF, $tTheoryTabName, $tParentTabName, $tAction; | ||
+ | |||
+ | $tMain = $wgTitle->getLocalUrl(''); | ||
+ | $tTheory = "/Theories"; | ||
+ | $tHREF = $tMain.$tTheory; | ||
+ | $tTheoryTabName = 'Theories'; | ||
+ | $tParentTabName = 'Main Article'; | ||
+ | $tAction = '?action=edit'; | ||
+ | |||
+ | //create the theory tab for regular articles in NS_MAIN namespace | ||
+ | if ( $wgTitle->getNamespace() == NS_MAIN | ||
+ | && $wgTitle->isTalkPage() !== 1 | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Main_Page") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Portal:") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Category:") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Template:") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),$tTheoryTabName) == FALSE ) { | ||
+ | |||
+ | $content_actions['TheoryTab'] = array( | ||
+ | 'text' => $tTheoryTabName, | ||
+ | 'href' => $tHREF | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | //If already on the theory page, make a tab for the parent article. | ||
+ | if ( strstr($wgTitle->getLocalUrl(''),$tTheoryTabName) == TRUE | ||
+ | && $wgTitle->isTalkPage() !== 1 | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Main_Page") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Portal:") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Category:") == FALSE | ||
+ | && strstr($wgTitle->getLocalUrl(''),"Template:") == FALSE ) { | ||
+ | |||
+ | $tMain = substr_replace ($tMain, '', -(strlen($tTheory))); | ||
+ | $content_actions['TheoryTab'] = array( | ||
+ | 'text' => $tParentTabName, | ||
+ | 'href' => $tMain | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | }//endfunction wfTheoryTabHook | ||
+ | |||
+ | |||
+ | }//endfunction wfTheoryTab | ||
+ | |||
+ | |||
+ | ?> |
Revision as of 14:33, 19 December 2006
<?php
if(!defined('MEDIAWIKI')) {
header("HTTP/1.1 404 Not Found");die('
404 Not found
');}
/**
* A hook that adds a theories tab to Lostpedia * * @package MediaWiki * @subpackage Extensions * * @author Jabberwock @ Lostpedia * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */
$wgExtensionFunctions[] = 'wfTheoryTab'; $wgExtensionCredits['other'][] = array(
'name' => 'Theory Tab', 'description' => 'Adds a theories tab to articles', 'author' => 'Jabberwock'
);
- Enable subpages in the main namespace
$wgNamespacesWithSubpages[NS_MAIN] = true;
//install extension hooks $wgHooks['SkinTemplateTabs'][] = 'TheoryTabHook';
// Intialize
function wfTheoryTab() {
global $wgMessageCache, $wgParser, $wgUser, $wgVersion;
// add a tab on the article page function TheoryTabHook(&$skin , &$content_actions ) {
global $wgTitle, $tMain, $tTheory, $tHREF, $tTheoryTabName, $tParentTabName, $tAction;
$tMain = $wgTitle->getLocalUrl(); $tTheory = "/Theories"; $tHREF = $tMain.$tTheory; $tTheoryTabName = 'Theories'; $tParentTabName = 'Main Article'; $tAction = '?action=edit';
//create the theory tab for regular articles in NS_MAIN namespace if ( $wgTitle->getNamespace() == NS_MAIN
&& $wgTitle->isTalkPage() !== 1 && strstr($wgTitle->getLocalUrl(),"Main_Page") == FALSE && strstr($wgTitle->getLocalUrl(),"Portal:") == FALSE && strstr($wgTitle->getLocalUrl(),"Category:") == FALSE && strstr($wgTitle->getLocalUrl(),"Template:") == FALSE && strstr($wgTitle->getLocalUrl(),$tTheoryTabName) == FALSE ) { $content_actions['TheoryTab'] = array( 'text' => $tTheoryTabName, 'href' => $tHREF ); }
//If already on the theory page, make a tab for the parent article.
if ( strstr($wgTitle->getLocalUrl(),$tTheoryTabName) == TRUE
&& $wgTitle->isTalkPage() !== 1 && strstr($wgTitle->getLocalUrl(),"Main_Page") == FALSE && strstr($wgTitle->getLocalUrl(),"Portal:") == FALSE && strstr($wgTitle->getLocalUrl(),"Category:") == FALSE && strstr($wgTitle->getLocalUrl(),"Template:") == FALSE ) { $tMain = substr_replace ($tMain, , -(strlen($tTheory))); $content_actions['TheoryTab'] = array( 'text' => $tParentTabName, 'href' => $tMain ); }
}//endfunction wfTheoryTabHook
}//endfunction wfTheoryTab
?>