Wikia code/includes/SkinTemplate.php

--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\SkinTemplate.php	2011-07-18 22:31:28.234375000 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\SkinTemplate.php	2011-08-17 15:28:46.594726600 +0100
@@ -135,6 +135,7 @@
 		global $wgPageShowWatchingUsers;
 		global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
 		global $wgArticlePath, $wgScriptPath, $wgServer;
+		global $wgCityId;
 
 		wfProfileIn( __METHOD__ );
 
@@ -169,6 +170,12 @@
 		$this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
 		$this->username = $wgUser->getName();
 
+		/* Wikia change begin - @author: Marooned */
+		/* Pass parameters to skin, see: Login friction project */
+		$tpl->set( 'thisurl', $this->thisurl );
+		$tpl->set( 'thisquery', $this->thisquery );
+		/* Wikia change end */
+
 		if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
 			$this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
 		} else {
@@ -222,7 +229,13 @@
 
 		wfProfileIn( __METHOD__ . '-stuff2' );
 		$tpl->set( 'title', $out->getPageTitle() );
+		wfProfileIn( "parsePageTitle" );
 		$tpl->set( 'pagetitle', $out->getHTMLTitle() );
+
+		# quick hack for rt#15730; if you ever feel temptation to add 'elseif' ***CREATE A PROPER HOOK***
+		if (NS_CATEGORY == $this->mTitle->getNamespace()) $tpl->set( 'pagetitle', preg_replace("/^{$this->mTitle->getNsText()}:/", '', $out->getHTMLTitle()));
+
+		wfProfileOut( "parsePageTitle" );
 		$tpl->set( 'displaytitle', $out->mPageLinkTitle );
 		$tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
 		$tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
@@ -254,6 +267,9 @@
 			''
 		);
 
+    global $wgValidateUserName;
+    $tpl->set( 'liveValidation', $wgValidateUserName );
+
 		$tpl->set( 'catlinks', $this->getCategories() );
 		if( $out->isSyndicated() ) {
 			$feeds = array();
@@ -328,19 +344,30 @@
 		$newtalks = $wgUser->getNewMessageLinks();
 		$ntl = '';
 
-		if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
+		/* Wikia change begin - @author: tor */
+		global $wgSitename;
+		if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === $wgSitename ) {
+		/* Wikia change end */
 			$usertitle = $this->mUser->getUserPage();
 			$usertalktitle = $usertitle->getTalkPage();
 
 			if( !$usertalktitle->equals( $this->mTitle ) ) {
-				$newmessageslink = $this->link(
+				/* Wikia change begin - @author: Macbre */
+				$ntl = wfMsg( Wikia::isOasis() ? 'oasis-notification-youhavenewmessages' : 'youhavenewmessages',
+				/* Wikia change end */
+					$this->makeKnownLinkObj(
 					$usertalktitle,
 					wfMsgHtml( 'newmessageslink' ),
-					array(),
-					array( 'redirect' => 'no' ),
-					array( 'known', 'noclasses' )
+						'redirect=no'
+					),
+					$this->makeKnownLinkObj(
+						$usertalktitle,
+						wfMsgHtml( 'newmessagesdifflink' ),
+						'diff=cur'
+					)
 				);
 
+				/* Wikia change begin - @author: tor
 				$newmessagesdifflink = $this->link(
 					$usertalktitle,
 					wfMsgHtml( 'newmessagesdifflink' ),
@@ -354,6 +381,7 @@
 					$newmessageslink,
 					$newmessagesdifflink
 				);
+				  Wikia change end */
 				# Disable Cache
 				$out->setSquidMaxage( 0 );
 			}
@@ -369,6 +397,14 @@
 			$ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
 			$out->setSquidMaxage( 0 );
 		}
+
+		/* Wikia change begin - @author: Macbre */
+		/* Save content of notification about new messages and user's talk page(s) */
+		$tpl->set( 'usernewmessages', $ntl );
+		/* Wikia change end */
+
+		wfRunHooks( 'SkinTemplatePageBeforeUserMsg', array( &$ntl ) );
+
 		wfProfileOut( __METHOD__ . '-stuff2' );
 
 		wfProfileIn( __METHOD__ . '-stuff3' );
@@ -429,7 +465,13 @@
 			$tpl->set( 'credits', false );
 			$tpl->set( 'numberofwatchingusers', false );
 		} else {
+			//#2579, fix by Bartek 20081106 - load copyright for edit pages
+			if( 'edit' == $action ) {
+				$tpl->set('copyright', $this->getCopyright());
+			} else {
 			$tpl->set( 'copyright', false );
+			}
+
 			$tpl->set( 'viewcount', false );
 			$tpl->set( 'lastmod', false );
 			$tpl->set( 'credits', false );
@@ -443,6 +485,9 @@
 		$tpl->set( 'disclaimer', $this->disclaimerLink() );
 		$tpl->set( 'privacy', $this->privacyLink() );
 		$tpl->set( 'about', $this->aboutLink() );
+		$tpl->set( 'hostedbyico', $this->getHostedBy() );
+		$tpl->set( 'diggs', $this->diggsLink() );
+		$tpl->set( 'delicious', $this->deliciousLink() );
 
 		if ( $wgDebugComments ) {
 			$tpl->setRef( 'debug', $out->mDebugtext );
@@ -450,7 +495,9 @@
 			$tpl->set( 'debug', '' );
 		}
 
-		$tpl->set( 'reporttime', wfReportTime() );
+		if ( !Wikia::isOasis() ){
+			$tpl->set( 'reporttime', wfReportTime() );  // Wikia change -- moved this further down in page rendering for Oasis.
+		}
 		$tpl->set( 'sitenotice', wfGetSiteNotice() );
 		$tpl->set( 'bottomscripts', $this->bottomScripts() );
 
@@ -490,6 +537,15 @@
 		$content_actions = $this->buildContentActionUrls();
 		$tpl->setRef( 'content_actions', $content_actions );
 
+		// XXX: attach this from javascript, same with section editing
+		if($this->iseditable &&	$wgUser->getOption("editondblclick"))
+		{
+			$encEditUrl = Xml::escapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
+			$tpl->set( 'body_ondblclick', 'document.location = "' . $encEditUrl . '";' );
+		} else {
+			$tpl->set( 'body_ondblclick', false );
+		}
+		$tpl->set( 'body_onload', false );
 		$tpl->set( 'sidebar', $this->buildSidebar() );
 		$tpl->set( 'nav_urls', $this->buildNavUrls() );
 
@@ -546,11 +602,12 @@
 
 		/* set up the default links for the personal toolbar */
 		$personal_urls = array();
-		$page = $wgRequest->getVal( 'returnto', $this->thisurl );
-		$query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
-		$returnto = "returnto=$page";
+		/* Wikia change begin - @author: Marooned */
+		/* Simplified version of MW code - no need to check wgRequest again */
+		$returnto = "returnto={$this->thisurl}";
 		if( $this->thisquery != '' )
-			$returnto .= "&returntoquery=$query";
+			$returnto .= "&returntoquery={$this->thisquery}";
+		/* Wikia change end */
 		if( $this->loggedin ) {
 			$personal_urls['userpage'] = array(
 				'text' => $this->username,
@@ -608,6 +665,7 @@
 				'active' => false
 			);
 		} else {
+			global $wgUseAjax;
 			global $wgUser;
 			$loginlink = $wgUser->isAllowed( 'createaccount' )
 				? 'nav-login-createaccount'
@@ -629,12 +687,14 @@
 					'active' => ( $pageurl == $href )
 				);
 				$personal_urls['anonlogin'] = array(
+					'id' => 'login',
 					'text' => wfMsg( $loginlink ),
 					'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
 					'active' => $title->isSpecial( 'Userlogin' )
 				);
 			} else {
 				$personal_urls['login'] = array(
+					'id' => 'login',
 					'text' => wfMsg( $loginlink ),
 					'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
 					'active' => $title->isSpecial( 'Userlogin' )
@@ -742,7 +802,7 @@
 				$istalkclass = $istalk?' istalk':'';
 				$content_actions['edit'] = array(
 					'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass,
-					'text' => $this->mTitle->exists()
+					'text' => $this->mTitle->isKnown()
 						? wfMsg( 'edit' )
 						: wfMsg( 'create' ),
 					'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
@@ -842,8 +902,8 @@
 			}
 
 			wfProfileOut( __METHOD__ . '-live' );
-
-			if( $this->loggedin ) {
+			global $wgEnableWikiaFollowedPages;
+			if( $this->loggedin || $wgEnableWikiaFollowedPages) {
 				if( !$this->mTitle->userIsWatching()) {
 					$content_actions['watch'] = array(
 						'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
@@ -1055,6 +1115,11 @@
 		wfProfileIn( __METHOD__ );
 		$out = false;
 		wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
+		# make a little CDATA block
+		if ( !empty($out) ) {
+			$out = '/*<![CDATA[*/' . $out . '/*]]>*/';
+		}
+
 		wfProfileOut( __METHOD__ );
 		return $out;
 	}
@@ -1115,6 +1180,10 @@
 		echo htmlspecialchars( $this->data[$str] );
 	}
 
+	function textret( $str ) {
+		return htmlspecialchars( $this->data[$str] );
+	}
+
 	/**
 	 * @private
 	 */
@@ -1135,6 +1204,9 @@
 	function msg( $str ) {
 		echo htmlspecialchars( $this->translator->translate( $str ) );
 	}
+	function msgret( $str ) {
+		return htmlspecialchars( $this->translator->translate( $str ) );
+	}
 
 	/**
 	 * @private