User:Karel.duran/monobook.js

<?php /** * dbSavageWeb, a MediaWiki skin * Version 1.01 * Made for MediaWiki 1.5 * By Alex Powell, alexp@savagebusinessnesssolutions.co.uk, 6/2/2006 * * Skin is a tokenizing skin - takes three pages from the wiki: *	MediaWiki:SiteHTML * MediaWiki:SiteCSS *	MediaWiki:MenuHTML * * It then replaces $$$$VarName$$$$ with a relevant variable * see code for list of variable names * @package MediaWiki * @subpackage Skins */

if(!defined('MEDIAWIKI')) die;

/** */ require_once('includes/SkinTemplate.php');

/** * @package MediaWiki * @subpackage Skins */ class SkindbSavageWeb extends SkinTemplate { function initPage( &$out ) { SkinTemplate::initPage( $out ); $this->skinname = 'dbSavageWeb'; $this->stylename = 'dbSavageWeb'; $this->template = 'dbSavageWebTemplate'; } }

/** * @package MediaWiki * @subpackage Skins */ class dbSavageWebTemplate extends QuickTemplate {

// Takes a page and an array of tag=>replacement. // modifies pg directly function ReplaceTags(&$pg, &$tagdata) {		$keys = array_keys($tagdata); $vals = array_values($tagdata); foreach($keys as &$k) {			$k = "\$\$\$\${$k}\$\$\$\$"; }		$pg = str_replace($keys,$vals,$pg); }

function t($s) {		return htmlspecialchars($this->data[$s]); }

/**	 * @access private */	function execute {

global $wgLanguageCode; global $wgArticlePath; global $wgSitename; global $wgUser; global $wgTitle; global $wgScriptPath; global $wgRequest; global $wgParser; wfSuppressWarnings;

$vars = array; // Set up all needed template variables first!

$homeLink = htmlspecialchars($this->data['nav_urls']		['mainpage']['href']); $isEnglish = false; if ($wgLanguageCode == "en") $isEnglish = true; $canEdit = false; if ($wgUser->isAllowed('edit')) $canEdit = true;

// Set up login text

$loginText = ""; foreach ($this->data['personal_urls'] as $key => $item) { $href = htmlspecialchars($item['href']); $text = htmlspecialchars($item['text']); $link = "$text"; if ($key == "anonlogin" || $key == "logout" ||		$key == "userpage" || $key == "preferences") $loginText .= $link; if ($key == "userpage" || $key == "preferences") $loginText .= " / "; }	if (!$loginText && !$userpage) { $text = htmlspecialchars(			$this->translator->translate("userlogin")); $path = str_replace('$1', "Special:Userlogin", $wgArticlePath); $loginText = "$text"; }

// Navigation links

foreach ($this->data['nav_urls'] as $key => $item) { $href = htmlspecialchars($item['href']); $text = htmlspecialchars($this->translator->translate($key)); if ($key == "upload" && $isEnglish) $text = "upload files"; $link = "$text"; if ($key == "help") $helpLink = $link; if ($key == "recentchanges") $recentLink = $link; if ($key == "upload") $uploadLink = $link; if ($key == "specialpages") $specialLink = $link; if ($key == "recentchangeslinked") $relatedLink = $link; if ($key == "whatlinkshere") $backLink = $link; $vars[$key] = $link; $s .= "{$link} "; //		echo $key. "\r\n"; }

// Content action links

foreach ($this->data['content_actions'] as $key => $item) { $href = htmlspecialchars($item['href']); $text = htmlspecialchars($item['text']); if ($key == "talk" && $isEnglish) $text = "discuss"; if ($key == "history" && $isEnglish) $text = "changes"; if ($key == "move" && $isEnglish) $text = "rename"; if ($key == "nstab-main") $text = $this->data['title']; $link = "$text"; if ($key == "talk") $talkLink = $link; if ($key == "edit") $editLink = $link; if ($key == "history") $historyLink = $link; if ($key == "protect") $protectLink = $link; if ($key == "delete") $deleteLink = $link; if ($key == "move") $moveLink = $link; if ($key == "watch") $watchLink = $link; if ($key == "unwatch") $watchLink = $link; if ($key == "restrict") $restrictLink = $link; if ($key == "unrestrict") $restrictLink = $link; if ($key == "nstab-main") $pageLink = $link; $vars[$key] = $link; $s .= "{$link} "; }

if (!$pageLink) $pageLink = $this->data['title'];

$text = htmlspecialchars(		$this->translator->translate("allpages")); $path = str_replace('$1', "Special:Allpages", $wgArticlePath); $allLink = "$text";

$searchLabel = htmlspecialchars($this->translator->translate("search"));

// Nothing for those without logon! if ( !$wgUser->isLoggedIn ) { $s = ""; }	$page = wfMsg("SiteHTML"); $t = $this->data["stylepath"]; $tn = $this->data["stylename"]; $apstylenoedit = ""; if (!$canEdit) { $apstylenoedit = '.editsection { display: none; visibility: hidden; } '; }	$bodyevents = ""; if($this->data['body_ondblclick']) { $bodyevents = " ondblclick='".$this->data['body_ondblclick']."'"; } if($this->data['body_onload']) { $bodyevents .= " onload=\"".$this->data['body_onload']."\""; } if($this->data['nsclass']) { $bodyevents .= " class=\"".$this->data['nsclass']."\""; } $vars["stylefolder"]			= htmlspecialchars("{$t}/{$tn}"); $vars["commondata"]				= htmlspecialchars("{$t}/common"); $vars["mimetype"]				= $this->t('mimetype'); $vars["lang"]					= $this->t('lang'); $vars["dir"]					= $this->t('dir'); $vars["charset"]				= $this->t('charset'); $vars["pagetitle"]				= $this->t('pagetitle'); $vars["jsmimetype"]				= $this->t('jsmimetype'); $vars["headlinks"]				= $this->data['headlinks']; $vars["usercss"]				= $this->data['usercss']; $vars["apheaderscripts"]		= apGetHeaderScripts(1); $vars["apbodyscripts"]			= apGetBodyScripts($this,1); $vars["TitlePrefixedText"]		= $wgTitle->getPrefixedText; $vars["bodyevents"]				= $bodyevents; $vars["apstylenoedit"]			= $apstylenoedit; $vars["pagename"]				= $pageLink; $vars["searchlabel"]			= $searchLabel; $vars["searchaction"]			= $this->data["searchaction"]; $vars["accesskey-search"]		= $this->data["accesskey-search"]; $vars["search"]					= $this->data["search"]; $vars["copyright"]				= $this->data["copyright"]; $vars["catlinks"]				= ' '. $this->data['catlinks']. ' ';	$vars["loginText"]				= $loginText; $vars["homelink"]				= $homeLink; // Complete options for admin. Same can be achieved individually. $vars["editoptions"]			= $s; // LAST ITEMS could contain $$$$ vars // These are the last to be added, so $$$$varname$$$$ will not be replaced twice in edit mode $o = $wgParser->parse(wfMsg("MenuHTML"),$wgTitle,ParserOptions::newFromUser($wgUser)); $vars["menubar"]				= $o->getText; // Do a replace in the menu, incase we want to use a var there too. $this->ReplaceTags($vars["menubar"],$vars); $vars["content"]				= preg_replace("/editsection.*\[(.*)\]/", "editsection\">$1", $this->data['bodytext']);	$this->ReplaceTags($page,$vars);

$action = $wgRequest->getText( 'action', 'view' ); // Final strip of any control codes lying around - don't do if page is being edited! if($action != "edit") $page = preg_replace("/\\$\\$\\$\\$.*\\$\\$\\$\\$/","",$page);

echo $page; wfRestoreWarnings; } } ?>