User:Dantman/GE Extended/Custom Extensions/GENetwork/GENetwork.php

<?php

/** * The ConNetwork Extension's task's are: * - Auto-Protection of /Tech/Admin subpages of Worlds. * - Per Anime Styling in both Common and Skin specific types. * - Title modification to strip out the World's name when in a article located inside of a world. * * @author Daniel Friesen (http://www.wikia.com/wiki/User:Dantman) (dan_the_man@telus.net) * @license http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later */ $egConPrefixes = array( 'Con' );

$wgGroupPermissions['*'   ]['viewconnetwork'] = true; $wgGroupPermissions['sysop']['editconnetwork'] = true; $wgGroupPermissions['sysop']['editconprotected'] = true; function efConIsProtected( $title ) { if( $title->mNamespace == 0 ) { $name = $title->mTextform; $dbr =& wfGetDB( DB_SLAVE ); $ConRes = $dbr->select( 'etConNetworkWorlds',			array( 'wid', 'world' ) ); while( $row = $dbr->fetchObject( $ConRes ) ) { if( preg_match( '/^'.preg_quote( $row->world, '/' ).'\/Tech\/Admin(\/|$)/i', $name ) ) return true; }	}	return false; }

$wgHooks['ExpandSkinCSS'][] = 'efConAddStyles'; function efConAddStyles( &$css, $skinname ) { global $wgScript, $wgTitle, $wgSquidMaxage; if( $wgTitle->mNamespace == 0 ) { $name = $wgTitle->mTextform; $dbr =& wfGetDB( DB_SLAVE ); $ConRes = $dbr->select( 'etConNetworkWorlds',			array( 'wid', 'world' ) ); while( $row = $dbr->fetchObject( $ConRes ) ) { if( preg_match( '/^'.preg_quote( $row->world, '/' ).'(\/|$)/i', $name ) ) { $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; $css .= "@import \"".Skin::makeNSUrl( "{$row->world}/Tech/Admin/common.css", $query, NS_MAIN )."\";\n"; $css .= "@import \"".Skin::makeNSUrl( "{$row->world}/Tech/Admin/{$skinname}.css", $query, NS_MAIN )."\";\n"; return true; }		}	}	return true; }

$wgHooks['ViewTitle'][] = 'efConTitleMod'; function efConTitleMod( &$articleTitle, &$displayTitle ) { if( $articleTitle->mNamespace == 0 ) { $name = $articleTitle->mTextform; $dbr =& wfGetDB( DB_SLAVE ); $ConRes = $dbr->select( 'etConNetworkWorlds',			array( 'wid', 'world' ) ); while( $row = $dbr->fetchObject( $ConRes ) ) { if( preg_match( '/^'.preg_quote( $row->world, '/' ).'(\/|$)/i', $name ) ) { $displayTitle = preg_replace( '/^'.preg_quote( $row->world, '/' ).'\//i', '', $name ); return true; }		}	}	return true; }

?>