Security fix: do not use $IP on include (thanks brion)
[lhc/web/wiklou.git] / skins / WikimediaWiki.php
1 <?php
2 # Tentative to make a skin for wikimedia.org
3 # $Id$
4
5 if($wgUsePHPTal) {
6 require_once('includes/SkinPHPTal.php');
7
8 $wgExtraSkins['wikimediawiki'] = 'Wikimediawiki';
9
10 require_once('MonoBook.php');
11
12 class SkinWikimediawiki extends SkinMonoBook {
13 function initPage( &$out ) {
14 SkinPHPTal::initPage( $out );
15 $this->skinname = 'wikimediawiki';
16 $this->template = 'WikimediaWiki';
17 }
18
19 # build array of common navigation links
20 function buildNavUrls () {
21 global $wgTitle, $wgUser, $wgRequest;
22 global $wgSiteSupportPage;
23
24 $action = $wgRequest->getText( 'action' );
25 $oldid = $wgRequest->getVal( 'oldid' );
26 $diff = $wgRequest->getVal( 'diff' );
27 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
28 $nav_urls = array();
29 $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage')));
30 $nav_urls['randompage'] = (wfMsg('randompage') != '-') ? array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage'))) : false;
31 $nav_urls['recentchanges'] = (wfMsg('recentchanges') != '-') ? array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges'))) : false;
32 $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage ))));
33 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false;
34 $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false;
35 $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage ))));
36 $nav_urls['bugreports'] = (wfMsg('bugreports') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage'))) : false;
37 $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage));
38 $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
39 $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
40 $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
41
42
43 # Specific for mediawiki.org menu
44 $nav_urls['aboutmediawiki'] = (wfMsg('aboutmediawiki') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('aboutmediawiki-url'))) : false;
45 $nav_urls['projects'] = (wfMsg('projects') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('projects-url'))) : false;
46 $nav_urls['membership'] = (wfMsg('membership') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('membership-url'))) : false;
47 $nav_urls['pressroom'] = (wfMsg('pressroom') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('pressroom-url'))) : false;
48 $nav_urls['software'] = (wfMsg('software') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('software-url'))) : false;
49 $nav_urls['localchapters'] = (wfMsg('localchapters') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('localchapters-url'))) : false;
50 $nav_urls['contactus'] = (wfMsg('contactus') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('contactus-url'))) : false;
51
52 if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
53 $id = User::idFromName($wgTitle->getText());
54 $ip = User::isIP($wgTitle->getText());
55 } else {
56 $id = 0;
57 $ip = false;
58 }
59
60 if ( 0 != $wgUser->getID() ) { # show only to signed in users
61 if($id) {
62 # can only email non-anons
63 $nav_urls['emailuser'] = array(
64 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
65 );
66 # only non-anons have contrib list
67 $nav_urls['contributions'] = array(
68 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
69 );
70 }
71 }
72
73
74 return $nav_urls;
75 }
76 }
77
78 }
79 ?>