r5528 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r5527 | r5528 (on ViewVC) | r5529 >
Date:09:45, 26 September 2004
Author:jeluf
Status:new
Tags:
Comment:BUG#419 Added global variable that defines the elements of the navigation sidebar.
Made MonoBook use the global sidebar definition
Modified paths:

Diff [purge]

Index: trunk/phase3/skins/MonoBook.pt
===================================================================
--- trunk/phase3/skins/MonoBook.pt	(revision 5527)
+++ trunk/phase3/skins/MonoBook.pt	(revision 5528)
@@ -63,20 +63,9 @@
 	  <h5 i18n:translate="string:navigation">Navigation</h5>
 	  <div class="pBody">
 	    <ul>
-	      <li id="n-mainpage"><a href="${nav_urls/mainpage/href}"
-		i18n:translate="string:mainpage">Main Page</a></li>
-	      <li id="n-portal" tal:condition="nav_urls/portal/href"><a href="${nav_urls/portal/href}"
-		i18n:translate="string:portal">Community Portal</a></li>
-	      <li id="n-currentevents" tal:condition="nav_urls/currentevents/href"><a href="${nav_urls/currentevents/href}"
-		i18n:translate="string:currentevents">Current Events</a></li>
-	      <li id="n-recentchanges"><a href="${nav_urls/recentchanges/href}"
-		i18n:translate="string:recentchanges">Recent Changes</a></li>
-	      <li id="n-randompage"><a href="${nav_urls/randompage/href}"
-		i18n:translate="string:randompage">Random Page</a></li>
-	      <li id="n-help"><a href="${nav_urls/help/href}"
-		i18n:translate="string:help">Help</a></li>
-	      <li id="n-sitesupport" tal:condition="nav_urls/sitesupport/href"><a href="${nav_urls/sitesupport/href}"
-		i18n:translate="string:sitesupport">Donations</a></li>
+	      <li tal:repeat="navlink navigation_urls" tal:attributes="id navlink/id">
+	        <a tal:attributes="href navlink/href" tal:content="structure navlink/text">NavLink</a>
+	      </li>
 	    </ul>
 	  </div>
 	</div>
Index: trunk/phase3/LocalSettings.sample
===================================================================
--- trunk/phase3/LocalSettings.sample	(revision 5527)
+++ trunk/phase3/LocalSettings.sample	(revision 5528)
@@ -120,6 +120,15 @@
 #
 # $wgUseDatabaseMessages = false;
 
+## The links in the navigation sidebar can be configured.
+## To add a link to the sidebar, add a line like the following
+#
+# $wgNavigationLinks[] = array( 'text' => 'helpdesk', 'href' => 'helpdesk-url' );
+#
+## and create two MediaWiki:-pages with the corresponding names, e.g.
+## MediaWiki:helpdesk="User help desk"
+## MediaWiki:helpdesk-url="YourProject:Help_desk"
+
 ## Set $wgUseImageResize to true if you want to enable dynamic
 ## server side image resizing ("Thumbnails")
 #
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 5527)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 5528)
@@ -707,6 +707,23 @@
 	array(1280,1024),
 	array(10000,10000) );
 
+
+# Navigation links for the user sidebar.
+# 'text' is the name of the MediaWiki message that contains the label of this link
+# 'href' is the name of the MediaWiki message that contains the link target of this link.
+#        Link targets starting with http are considered remote links. Ones not starting with
+#        http are considered as names of local wiki pages.
+$wgNavigationLinks = array (
+	array( 'text'=>'mainpage',	'href'=>'mainpage' ),
+	array( 'text'=>'portal',	'href'=>'portal-url' ),
+	array( 'text'=>'currentevents', 'href'=>'currentevents-url' ),
+	array( 'text'=>'recentchanges', 'href'=>'recentchanges-url' ),
+	array( 'text'=>'randompage',	'href'=>'randompage-url' ),
+	array( 'text'=>'help', 		'href'=>'helppage' ),
+	array( 'text'=>'sitesupport',	'href'=>'sitesupport-url' ),
+);
+
+
 } else {
 	die();
 }
Index: trunk/phase3/includes/SkinPHPTal.php
===================================================================
--- trunk/phase3/includes/SkinPHPTal.php	(revision 5527)
+++ trunk/phase3/includes/SkinPHPTal.php	(revision 5528)
@@ -302,6 +302,7 @@
 		$out->mBodytext .= $printfooter ;
 		$tpl->setRef( 'bodytext', $out->mBodytext );
 
+		# Language links
 		$language_urls = array();
 		foreach( $wgOut->getLanguageLinks() as $l ) {
 			$nt = Title::newFromText( $l );
@@ -314,6 +315,8 @@
 		} else {
 			$tpl->set('language_urls', false);
 		}
+
+		# Personal toolbar
 		$tpl->set('personal_urls', $this->buildPersonalUrls());
 		$content_actions = $this->buildContentActionUrls();
 		$tpl->setRef('content_actions', $content_actions);
@@ -324,6 +327,7 @@
 		} else {
 			$tpl->set('body_ondblclick', false);
 		}
+		$tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
 		$tpl->set( 'nav_urls', $this->buildNavUrls() );
 
 		// execute template
@@ -559,6 +563,22 @@
 	}
 
 	/**
+	 * build array of global navigation links
+	 */ 
+	function buildNavigationUrls () {
+		global $wgNavigationLinks;
+		$result = array();
+		foreach ( $wgNavigationLinks as $link ) {
+			$result[] = array(
+				'text' => wfMsg( $link['text'] ),
+				'href' => $this->makeInternalOrExternalUrl( wfMsg( $link['href'] ) ),
+				'id' => 'n-'.$link['text']
+			);
+		}
+		return $result;
+	}
+
+	/**
 	 * build array of common navigation links
 	 */
 	function buildNavUrls () {
Index: trunk/phase3/includes/Skin.php
===================================================================
--- trunk/phase3/includes/Skin.php	(revision 5527)
+++ trunk/phase3/includes/Skin.php	(revision 5528)
@@ -1765,6 +1765,17 @@
 		$this->checkTitle($title, $name);
 		return $title->getLocalURL( $urlaction );
 	}
+
+	# If url string starts with http, consider as external URL, else
+	# internal
+	/*static*/ function makeInternalOrExternalUrl( $name ) {
+		if ( strncmp( $name, 'http', 4 ) == 0 ) {
+			return $name;
+		} else {
+			return $this->makeUrl( $name );
+		}
+	}
+
 	# this can be passed the NS number as defined in Language.php
 	/*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
 		$title = Title::makeTitleSafe( $namespace, $name );
Index: trunk/phase3/languages/Language.php
===================================================================
--- trunk/phase3/languages/Language.php	(revision 5527)
+++ trunk/phase3/languages/Language.php	(revision 5528)
@@ -315,7 +315,8 @@
 "wikititlesuffix" => "{{SITENAME}}",
 "bugreports"	=> "Bug reports",
 "bugreportspage" => "{{ns:4}}:Bug_reports",
-'sitesupport'   => 'Donations', # Set a URL in $wgSiteSupportPage in LocalSettings.php
+'sitesupport'   => 'Donations', 
+'sitesupport-url' => '{{ns:4}}:Site support',
 'faq'			=> 'FAQ',
 "faqpage"		=> "{{ns:4}}:FAQ",
 "edithelp"		=> "Editing help",
@@ -335,6 +336,7 @@
 'anontalk'		=> 'Talk for this IP',
 'navigation' => 'Navigation',
 'currentevents' => 'Current events',
+'currentevents-url' => 'Current events',
 'disclaimers' => 'Disclaimers',
 "disclaimerpage"		=> "{{ns:4}}:General_disclaimer",
 "errorpagetitle" => "Error",
@@ -817,6 +819,7 @@
 #
 'changes' => 'changes',
 'recentchanges' => 'Recent changes',
+'recentchanges-url' => 'Special:Recentchanges',
 'recentchangestext' => 'Track the most recent changes to the wiki on this page.',
 'rcloaderr'		=> 'Loading recent changes',
 'rcnote'		=> "Below are the last <strong>$1</strong> changes in last <strong>$2</strong> days.",
@@ -992,6 +995,7 @@
 'nlinks'		=> '$1 links',
 'allpages'		=> 'All pages',
 'randompage'	=> 'Random page',
+'randompage-url'=> 'Special:Randompage',
 'shortpages'	=> 'Short pages',
 'longpages'		=> 'Long pages',
 'deadendpages'  => 'Dead-end pages',
@@ -1550,6 +1554,8 @@
 'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)',
 
 'newimages' => 'New images gallery',
+'mormo' => 'mormo.org',
+'mormo-url' => 'http://mormo.org',
 
 
 );
Views
Toolbox