Index: branches/SkinSystemRewrite/skins/Simple.php |
— | — | @@ -7,20 +7,35 @@ |
8 | 8 | * @ingroup Skins |
9 | 9 | */ |
10 | 10 | |
11 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 11 | +if( !defined( 'MEDIAWIKI' ) ) { |
12 | 12 | die( -1 ); |
| 13 | +} |
13 | 14 | |
14 | 15 | /** */ |
15 | | -require_once( dirname(__FILE__) . '/MonoBook.php' ); |
| 16 | +require_once( dirname( __FILE__ ) . '/MonoBook.php' ); |
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Inherit main code from SkinTemplate, set the CSS and template filter. |
19 | 20 | * @ingroup Skins |
20 | 21 | */ |
21 | | -class SkinSimple extends SkinTemplate { |
22 | | - var $skinname = 'simple', $stylename = 'simple', |
23 | | - $template = 'MonoBookTemplate', $useHeadElement = true; |
| 22 | +class SkinSimple extends SkinMonoBook { |
| 23 | + /** |
| 24 | + * We don't want common/wikiprintable.css. |
| 25 | + */ |
| 26 | + public function commonPrintStylesheet() { |
| 27 | + return false; |
| 28 | + } |
24 | 29 | |
| 30 | + /** @return string path to the skin stylesheet */ |
| 31 | + public function getStylesheet() { |
| 32 | + return 'simple/main.css'; |
| 33 | + } |
| 34 | + |
| 35 | + /** @return string skin name */ |
| 36 | + public function getSkinName() { |
| 37 | + return 'simple'; |
| 38 | + } |
| 39 | + |
25 | 40 | function setupSkinUserCss( OutputPage $out ){ |
26 | 41 | $out->addStyle( 'simple/main.css', 'screen' ); |
27 | 42 | $out->addStyle( 'simple/rtl.css', '', '', 'rtl' ); |
Index: branches/SkinSystemRewrite/skins/MySkin.php |
— | — | @@ -7,14 +7,31 @@ |
8 | 8 | * @ingroup Skins |
9 | 9 | */ |
10 | 10 | |
11 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 11 | +if( !defined( 'MEDIAWIKI' ) ) { |
12 | 12 | die( -1 ); |
| 13 | +} |
13 | 14 | |
14 | 15 | /** |
15 | | - * Inherit main code from SkinTemplate, set the CSS and template filter. |
| 16 | + * Inherit main code from SkinMonoBook. |
16 | 17 | * @ingroup Skins |
17 | 18 | */ |
18 | | -class SkinMySkin extends SkinTemplate { |
19 | | - var $skinname = 'myskin', $stylename = 'myskin', |
20 | | - $template = 'MonoBookTemplate', $useHeadElement = true; |
| 19 | +class SkinMySkin extends SkinMonoBook { |
| 20 | + |
| 21 | + /** |
| 22 | + * We don't want common/wikiprintable.css. |
| 23 | + */ |
| 24 | + public function commonPrintStylesheet() { |
| 25 | + return false; |
| 26 | + } |
| 27 | + |
| 28 | + /** @return string skin name */ |
| 29 | + public function getSkinName() { |
| 30 | + return 'myskin'; |
| 31 | + } |
| 32 | + |
| 33 | + function setupSkinUserCss( OutputPage $out ) { |
| 34 | + $out->addStyle( 'common/shared.css' ); |
| 35 | + $out->addStyle( 'common/commonPrint.css', 'print' ); |
| 36 | + $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' ); |
| 37 | + } |
21 | 38 | } |
Index: branches/SkinSystemRewrite/skins/Chick.php |
— | — | @@ -7,22 +7,41 @@ |
8 | 8 | * @ingroup Skins |
9 | 9 | */ |
10 | 10 | |
11 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 11 | +if( !defined( 'MEDIAWIKI' ) ) { |
12 | 12 | die( -1 ); |
| 13 | +} |
13 | 14 | |
14 | 15 | /** */ |
15 | | -require_once( dirname(__FILE__) . '/MonoBook.php' ); |
| 16 | +require_once( dirname( __FILE__ ) . '/MonoBook.php' ); |
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Inherit main code from SkinTemplate, set the CSS and template filter. |
19 | 20 | * @ingroup Skins |
20 | 21 | */ |
21 | | -class SkinChick extends SkinTemplate { |
22 | | - var $skinname = 'chick', $stylename = 'chick', |
23 | | - $template = 'MonoBookTemplate', $useHeadElement = true; |
| 22 | +class SkinChick extends SkinMonoBook { |
24 | 23 | |
25 | | - function setupSkinUserCss( OutputPage $out ){ |
26 | | - parent::setupSkinUserCss( $out ); |
| 24 | + /** |
| 25 | + * We don't want common/wikiprintable.css. |
| 26 | + */ |
| 27 | + public function commonPrintStylesheet() { |
| 28 | + return false; |
| 29 | + } |
| 30 | + |
| 31 | + /** @return string path to the skin stylesheet */ |
| 32 | + public function getStylesheet() { |
| 33 | + return 'chick/main.css'; |
| 34 | + } |
| 35 | + |
| 36 | + /** @return string skin name */ |
| 37 | + public function getSkinName() { |
| 38 | + return 'chick'; |
| 39 | + } |
| 40 | + |
| 41 | + function setupSkinUserCss( OutputPage $out ) { |
| 42 | + $out->addStyle( 'common/shared.css' ); |
| 43 | + $out->addStyle( 'common/commonPrint.css', 'print' ); |
| 44 | + $out->addStyle( $this->getStylesheet() ); |
| 45 | + $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' ); |
27 | 46 | // Append to the default screen common & print styles... |
28 | 47 | $out->addStyle( 'chick/main.css', 'screen,handheld' ); |
29 | 48 | $out->addStyle( 'chick/IE60Fixes.css', 'screen,handheld', 'IE 6' ); |
Index: branches/SkinSystemRewrite/skins/MonoBook.php |
— | — | @@ -10,26 +10,41 @@ |
11 | 11 | * @ingroup Skins |
12 | 12 | */ |
13 | 13 | |
14 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 14 | +if( !defined( 'MEDIAWIKI' ) ) { |
15 | 15 | die( -1 ); |
| 16 | +} |
16 | 17 | |
17 | 18 | /** |
18 | | - * Inherit main code from SkinTemplate, set the CSS and template filter. |
| 19 | + * Inherit main code from Skin, set the CSS and template filter. |
19 | 20 | * @todo document |
20 | 21 | * @ingroup Skins |
21 | 22 | */ |
22 | | -class SkinMonoBook extends SkinTemplate { |
23 | | - /** Using monobook. */ |
24 | | - var $skinname = 'monobook', $stylename = 'monobook', |
25 | | - $template = 'MonoBookTemplate', $useHeadElement = true; |
| 23 | +class SkinMonoBook extends Skin { |
26 | 24 | |
| 25 | + /** @return string path to the skin stylesheet */ |
| 26 | + public function getStylesheet() { |
| 27 | + return 'monobook/main.css'; |
| 28 | + } |
| 29 | + |
| 30 | + /** @return string skin name */ |
| 31 | + public function getSkinName() { |
| 32 | + return 'monobook'; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Add skin specific stylesheets |
| 37 | + * Overridden so that oldshared.css won't get added. |
| 38 | + * @param $out OutputPage |
| 39 | + */ |
27 | 40 | function setupSkinUserCss( OutputPage $out ) { |
28 | 41 | global $wgHandheldStyle; |
29 | 42 | |
30 | | - parent::setupSkinUserCss( $out ); |
| 43 | + $out->addStyle( 'common/shared.css' ); |
| 44 | + $out->addStyle( 'common/commonPrint.css', 'print' ); |
| 45 | + $out->addStyle( $this->getStylesheet() ); |
| 46 | + $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' ); |
31 | 47 | |
32 | 48 | // Append to the default screen common & print styles... |
33 | | - $out->addStyle( 'monobook/main.css', 'screen' ); |
34 | 49 | if( $wgHandheldStyle ) { |
35 | 50 | // Currently in testing... try 'chick/main.css' |
36 | 51 | $out->addStyle( $wgHandheldStyle, 'handheld' ); |
— | — | @@ -39,304 +54,271 @@ |
40 | 55 | $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' ); |
41 | 56 | $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' ); |
42 | 57 | } |
43 | | -} |
44 | 58 | |
45 | | -/** |
46 | | - * @todo document |
47 | | - * @ingroup Skins |
48 | | - */ |
49 | | -class MonoBookTemplate extends QuickTemplate { |
50 | | - var $skin; |
51 | 59 | /** |
52 | | - * Template filter callback for MonoBook skin. |
53 | | - * Takes an associative array of data set from a SkinTemplate-based |
54 | | - * class, and a wrapper for MediaWiki's localization database, and |
55 | | - * outputs a formatted page. |
56 | | - * |
57 | | - * @access private |
| 60 | + * Renders things that are displayed before the actual page content. |
| 61 | + * For example, newtalk notifications, site notice etc. |
| 62 | + * @return HTML |
58 | 63 | */ |
59 | | - function execute() { |
60 | | - global $wgRequest; |
| 64 | + function doBeforeContent() { |
| 65 | + global $wgContLang, $wgUser; |
| 66 | + wfProfileIn( __METHOD__ ); |
61 | 67 | |
62 | | - $this->skin = $skin = $this->data['skin']; |
63 | | - $action = $wgRequest->getText( 'action' ); |
| 68 | + $s = ''; |
64 | 69 | |
65 | | - // Suppress warnings to prevent notices about missing indexes in $this->data |
66 | | - wfSuppressWarnings(); |
| 70 | + $attribs = $this->getAttributes(); |
| 71 | + $s .= '<div id="globalWrapper"> |
| 72 | + <div id="column-content"> |
| 73 | + <div id="content"' . $attribs[1] . '> |
| 74 | + <a id="top"></a>' . "\n"; |
67 | 75 | |
68 | | - $this->html( 'headelement' ); |
69 | | -?><div id="globalWrapper"> |
70 | | -<div id="column-content"><div id="content" <?php $this->html("specialpageattributes") ?>> |
71 | | - <a id="top"></a> |
72 | | - <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?> |
| 76 | + // Site notice ([[MediaWiki:Sitenotice]]) |
| 77 | + $notice = wfGetSiteNotice(); |
| 78 | + if( $notice ) { |
| 79 | + $s .= "\n<div id=\"siteNotice\">$notice</div>\n"; |
| 80 | + } |
73 | 81 | |
74 | | - <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1> |
75 | | - <div id="bodyContent"> |
76 | | - <h3 id="siteSub"><?php $this->msg('tagline') ?></h3> |
77 | | - <div id="contentSub" <?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div> |
78 | | -<?php if($this->data['undelete']) { ?> |
79 | | - <div id="contentSub2"><?php $this->html('undelete') ?></div> |
80 | | -<?php } ?><?php if($this->data['newtalk'] ) { ?> |
81 | | - <div class="usermessage"><?php $this->html('newtalk') ?></div> |
82 | | -<?php } ?><?php if($this->data['showjumplinks']) { ?> |
83 | | - <div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div> |
84 | | -<?php } ?> |
85 | | - <!-- start content --> |
86 | | -<?php $this->html('bodytext') ?> |
87 | | - <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?> |
88 | | - <!-- end content --> |
89 | | - <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?> |
90 | | - <div class="visualClear"></div> |
91 | | - </div> |
92 | | -</div></div> |
93 | | -<div id="column-one" <?php $this->html('userlangattributes') ?>> |
94 | | - <div id="p-cactions" class="portlet"> |
95 | | - <h5><?php $this->msg('views') ?></h5> |
96 | | - <div class="pBody"> |
97 | | - <ul><?php |
98 | | - foreach($this->data['content_actions'] as $key => $tab) { |
99 | | - echo ' |
100 | | - <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"'; |
101 | | - if( $tab['class'] ) { |
102 | | - echo ' class="'.htmlspecialchars($tab['class']).'"'; |
103 | | - } |
104 | | - echo '><a href="'.htmlspecialchars($tab['href']).'"'; |
105 | | - # We don't want to give the watch tab an accesskey if the |
106 | | - # page is being edited, because that conflicts with the |
107 | | - # accesskey on the watch checkbox. We also don't want to |
108 | | - # give the edit tab an accesskey, because that's fairly su- |
109 | | - # perfluous and conflicts with an accesskey (Ctrl-E) often |
110 | | - # used for editing in Safari. |
111 | | - if( in_array( $action, array( 'edit', 'submit' ) ) |
112 | | - && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) { |
113 | | - echo $skin->tooltip( "ca-$key" ); |
114 | | - } else { |
115 | | - echo $skin->tooltipAndAccesskey( "ca-$key" ); |
116 | | - } |
117 | | - echo '>'.htmlspecialchars($tab['text']).'</a></li>'; |
118 | | - } ?> |
| 82 | + $s .= $this->pageTitle() . "\n"; |
| 83 | + $s .= '<div id="bodyContent">' . "\n"; |
| 84 | + $s .= $this->pageSubtitle() . "\n"; |
119 | 85 | |
120 | | - </ul> |
121 | | - </div> |
122 | | - </div> |
123 | | - <div class="portlet" id="p-personal"> |
124 | | - <h5><?php $this->msg('personaltools') ?></h5> |
125 | | - <div class="pBody"> |
126 | | - <ul <?php $this->html('userlangattributes') ?>> |
127 | | -<?php foreach($this->data['personal_urls'] as $key => $item) { ?> |
128 | | - <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php |
129 | | - if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php |
130 | | - echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php |
131 | | - if(!empty($item['class'])) { ?> class="<?php |
132 | | - echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php |
133 | | - echo htmlspecialchars($item['text']) ?></a></li> |
134 | | -<?php } ?> |
135 | | - </ul> |
136 | | - </div> |
137 | | - </div> |
138 | | - <div class="portlet" id="p-logo"> |
139 | | - <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php |
140 | | - ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php |
141 | | - echo $skin->tooltipAndAccesskey('p-logo') ?>></a> |
142 | | - </div> |
143 | | - <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script> |
144 | | -<?php |
145 | | - $sidebar = $this->data['sidebar']; |
146 | | - if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true; |
147 | | - if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true; |
148 | | - if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true; |
149 | | - foreach ($sidebar as $boxName => $cont) { |
150 | | - if ( $boxName == 'SEARCH' ) { |
151 | | - $this->searchBox(); |
152 | | - } elseif ( $boxName == 'TOOLBOX' ) { |
153 | | - $this->toolbox(); |
154 | | - } elseif ( $boxName == 'LANGUAGES' ) { |
155 | | - $this->languageBox(); |
156 | | - } else { |
157 | | - $this->customBox( $boxName, $cont ); |
158 | | - } |
| 86 | + // Undelete link, if available |
| 87 | + $undelete = $this->getUndeleteLink(); |
| 88 | + if ( !empty( $undelete ) ) { |
| 89 | + $s .= '<span class="subpages">' . $undelete . '</span>'; |
159 | 90 | } |
160 | | -?> |
161 | | -</div><!-- end of the left (by default at least) column --> |
162 | | -<div class="visualClear"></div> |
163 | | -<div id="footer" <?php $this->html('userlangattributes') ?>> |
164 | | -<?php |
165 | | -if($this->data['poweredbyico']) { ?> |
166 | | - <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div> |
167 | | -<?php } |
168 | | -if($this->data['copyrightico']) { ?> |
169 | | - <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div> |
170 | | -<?php } |
171 | 91 | |
172 | | - // Generate additional footer links |
173 | | - $footerlinks = array( |
174 | | - 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright', |
175 | | - 'privacy', 'about', 'disclaimer', 'tagline', |
176 | | - ); |
177 | | - $validFooterLinks = array(); |
178 | | - foreach( $footerlinks as $aLink ) { |
179 | | - if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
180 | | - $validFooterLinks[] = $aLink; |
181 | | - } |
| 92 | + // New talk page messages, if any |
| 93 | + $newtalks = $this->getNewtalks(); |
| 94 | + if ( !empty( $newtalks ) ) { |
| 95 | + $s .= '<div class="usermessage">' . $newtalks . '</div>'; |
182 | 96 | } |
183 | | - if ( count( $validFooterLinks ) > 0 ) { |
184 | | -?> <ul id="f-list"> |
185 | | -<?php |
186 | | - foreach( $validFooterLinks as $aLink ) { |
187 | | - if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
188 | | -?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li> |
189 | | -<?php } |
190 | | - } |
191 | | -?> |
192 | | - </ul> |
193 | | -<?php } |
194 | | -?> |
195 | | -</div> |
196 | | -</div> |
197 | | -<?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?> |
198 | | -<?php $this->html('reporttime') ?> |
199 | | -<?php if ( $this->data['debug'] ): ?> |
200 | | -<!-- Debug output: |
201 | | -<?php $this->text( 'debug' ); ?> |
202 | 97 | |
203 | | -<?php endif; ?> |
204 | | -</body></html> |
205 | | -<?php |
206 | | - wfRestoreWarnings(); |
207 | | - } // end of execute() method |
| 98 | + // Jump to navigation links, if user has enabled them in their prefs. |
| 99 | + if ( $wgUser->getOption( 'showjumplinks' ) ) { |
| 100 | + $s .= "\n" . '<div id="jump-to-nav">' . wfMsg( 'jumpto' ) . |
| 101 | + ' <a href="#column-one">' . wfMsg( 'jumptonavigation' ) . |
| 102 | + '</a>, <a href="#searchInput">' . wfMsg( 'jumptosearch' ) . |
| 103 | + '</a></div>' . "\n"; |
| 104 | + } |
208 | 105 | |
209 | | - /*************************************************************************************************/ |
210 | | - function searchBox() { |
211 | | - global $wgUseTwoButtonsSearchForm; |
212 | | -?> |
213 | | - <div id="p-search" class="portlet"> |
214 | | - <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5> |
215 | | - <div id="searchBody" class="pBody"> |
216 | | - <form action="<?php $this->text('wgScript') ?>" id="searchform"> |
217 | | - <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/> |
218 | | - <?php |
219 | | - echo Html::input( 'search', |
220 | | - isset( $this->data['search'] ) ? $this->data['search'] : '', 'search', |
221 | | - array( |
222 | | - 'id' => 'searchInput', |
223 | | - 'title' => $this->skin->titleAttrib( 'search' ), |
224 | | - 'accesskey' => $this->skin->accesskey( 'search' ) |
225 | | - ) ); ?> |
226 | | - |
227 | | - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?> |
228 | | - <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?> |
229 | | - |
230 | | - <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?> |
231 | | - |
232 | | - </form> |
233 | | - </div> |
234 | | - </div> |
235 | | -<?php |
| 106 | + wfProfileOut( __METHOD__ ); |
| 107 | + return $s; |
236 | 108 | } |
237 | 109 | |
238 | | - /*************************************************************************************************/ |
239 | | - function toolbox() { |
240 | | -?> |
241 | | - <div class="portlet" id="p-tb"> |
242 | | - <h5><?php $this->msg('toolbox') ?></h5> |
243 | | - <div class="pBody"> |
244 | | - <ul> |
245 | | -<?php |
246 | | - if($this->data['notspecialpage']) { ?> |
247 | | - <li id="t-whatlinkshere"><a href="<?php |
248 | | - echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href']) |
249 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li> |
250 | | -<?php |
251 | | - if( $this->data['nav_urls']['recentchangeslinked'] ) { ?> |
252 | | - <li id="t-recentchangeslinked"><a href="<?php |
253 | | - echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href']) |
254 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li> |
255 | | -<?php } |
| 110 | + /** |
| 111 | + * Gets the page subtitle and site tagline. |
| 112 | + * @return HTML |
| 113 | + */ |
| 114 | + function pageSubtitle() { |
| 115 | + global $wgOut; |
| 116 | + |
| 117 | + $s = ''; |
| 118 | + $attribs = $this->getAttributes(); |
| 119 | + $sub = $wgOut->getSubtitle(); |
| 120 | + $s .= '<div id="contentSub"' . $attribs[0] . '>' . $sub . '</div>'; |
| 121 | + if ( $sub == '' ) { |
| 122 | + global $wgExtraSubtitle; |
| 123 | + $sub = '<h3 id="siteSub">' . wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle . '</h3>'; |
256 | 124 | } |
257 | | - if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?> |
258 | | - <li id="t-trackbacklink"><a href="<?php |
259 | | - echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href']) |
260 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li> |
261 | | -<?php } |
262 | | - if($this->data['feeds']) { ?> |
263 | | - <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) { |
264 | | - ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php |
265 | | - echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a> |
266 | | - <?php } ?></li><?php |
| 125 | + $subpages = $this->subPageSubtitle(); |
| 126 | + if ( !empty( $subpages ) ) { |
| 127 | + $sub .= '<span class="subpages">' . $subpages . '</span>' . $wgOut->getSubtitle(); |
| 128 | + } else { |
| 129 | + $sub .= $wgOut->getSubtitle(); |
267 | 130 | } |
| 131 | + return $s; |
| 132 | + } |
268 | 133 | |
269 | | - foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) { |
| 134 | + /** |
| 135 | + * Overridden pageTitle function to give the h1 element a new ID and class. |
| 136 | + * @return HTML |
| 137 | + */ |
| 138 | + function pageTitle() { |
| 139 | + global $wgOut; |
| 140 | + $s = '<h1 id="firstHeading" class="firstHeading">' |
| 141 | + . $wgOut->getPageTitle() . |
| 142 | + '</h1>'; |
| 143 | + return $s; |
| 144 | + } |
270 | 145 | |
271 | | - if($this->data['nav_urls'][$special]) { |
272 | | - ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href']) |
273 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li> |
274 | | -<?php } |
275 | | - } |
| 146 | + /** |
| 147 | + * No-op, since the default has two div tags, which would mess up things. |
| 148 | + * @return nothing |
| 149 | + */ |
| 150 | + function doAfterContent() {} |
276 | 151 | |
277 | | - if(!empty($this->data['nav_urls']['print']['href'])) { ?> |
278 | | - <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href']) |
279 | | - ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php |
280 | | - } |
| 152 | + /** |
| 153 | + * Builds personal tools (links to own user/talk pages, contribs, etc.) |
| 154 | + * @return HTML |
| 155 | + */ |
| 156 | + function getPersonalTools() { |
| 157 | + $attribs = $this->getAttributes(); |
| 158 | + $s = '<div class="portlet" id="p-personal"> |
| 159 | + <h5>' . wfMsg( 'personaltools' ) . '</h5> |
| 160 | + <div class="pBody"> |
| 161 | + <ul' . $attribs[0] . '>' |
| 162 | + . $this->renderPersonalTools() . |
| 163 | + '</ul> |
| 164 | + </div> |
| 165 | + </div>'; |
| 166 | + return $s; |
| 167 | + } |
281 | 168 | |
282 | | - if(!empty($this->data['nav_urls']['permalink']['href'])) { ?> |
283 | | - <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href']) |
284 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php |
285 | | - } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?> |
286 | | - <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php |
287 | | - } |
288 | | - |
289 | | - wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) ); |
290 | | - wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); |
291 | | -?> |
292 | | - </ul> |
| 169 | + /** |
| 170 | + * Gets content action tabs (edit, move, history, watch...). |
| 171 | + * @return HTML |
| 172 | + */ |
| 173 | + function getContentActions() { |
| 174 | + $s = '<div id="p-cactions" class="portlet"> |
| 175 | + <h5>' . wfMsg( 'views' ) . '</h5> |
| 176 | + <div class="pBody"> |
| 177 | + <ul>' . $this->renderContentActions() . '</ul> |
293 | 178 | </div> |
294 | | - </div> |
295 | | -<?php |
| 179 | + </div>'; |
| 180 | + return $s; |
296 | 181 | } |
297 | 182 | |
298 | | - /*************************************************************************************************/ |
299 | | - function languageBox() { |
300 | | - if( $this->data['language_urls'] ) { |
301 | | -?> |
302 | | - <div id="p-lang" class="portlet"> |
303 | | - <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5> |
| 183 | + /** |
| 184 | + * Gets the interlanguage links box. |
| 185 | + * @return HTML |
| 186 | + */ |
| 187 | + function getInterlanguageLinksBox() { |
| 188 | + $s = ''; |
| 189 | + $language_urls = $this->fetchInterlanguageLinks(); |
| 190 | + // Display the interlanguage links if we have any |
| 191 | + if( count( $language_urls ) ) { |
| 192 | + $attribs = $this->getAttributes(); |
| 193 | + $s .= '<div id="p-lang" class="portlet"> |
| 194 | + <h5' . $attribs[0] . '>' . wfMsg( 'otherlanguages' ) . '</h5> |
304 | 195 | <div class="pBody"> |
305 | | - <ul> |
306 | | -<?php foreach($this->data['language_urls'] as $langlink) { ?> |
307 | | - <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php |
308 | | - ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li> |
309 | | -<?php } ?> |
310 | | - </ul> |
| 196 | + <ul>'; |
| 197 | + foreach( $language_urls as $langlink ) { |
| 198 | + $s .= '<li class="' . htmlspecialchars( $langlink['class'] ) . '"> |
| 199 | + <a href="' . htmlspecialchars( $langlink['href'] ) . '">' |
| 200 | + . $langlink['text'] . |
| 201 | + '</a> |
| 202 | + </li>'; |
| 203 | + } |
| 204 | + $s .= '</ul> |
311 | 205 | </div> |
312 | | - </div> |
313 | | -<?php |
| 206 | + </div>'; |
314 | 207 | } |
| 208 | + return $s; |
315 | 209 | } |
316 | 210 | |
317 | | - /*************************************************************************************************/ |
318 | | - function customBox( $bar, $cont ) { |
319 | | -?> |
320 | | - <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>> |
321 | | - <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5> |
322 | | - <div class='pBody'> |
323 | | -<?php if ( is_array( $cont ) ) { ?> |
324 | | - <ul> |
325 | | -<?php foreach($cont as $key => $val) { ?> |
326 | | - <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php |
327 | | - if ( $val['active'] ) { ?> class="active" <?php } |
328 | | - ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li> |
329 | | -<?php } ?> |
330 | | - </ul> |
331 | | -<?php } else { |
332 | | - # allow raw HTML block to be defined by extensions |
333 | | - print $cont; |
| 211 | + /** |
| 212 | + * Gets the logo portlet. |
| 213 | + * @return HTML |
| 214 | + */ |
| 215 | + function getLogoPortlet() { |
| 216 | + global $wgLogo; |
| 217 | + $navUrls = $this->buildNavUrls(); |
| 218 | + $s = '<div class="portlet" id="p-logo"> |
| 219 | + <a style="background-image: url(' . $wgLogo . ');" href="' . |
| 220 | + htmlspecialchars( $navUrls['mainpage']['href'] ) . '"' . |
| 221 | + $this->tooltipAndAccesskey( 'p-logo' ) . '></a> |
| 222 | + </div>'; |
| 223 | + return $s; |
| 224 | + } |
| 225 | + |
| 226 | + /** |
| 227 | + * Main search form. searchBox() does the UI stuff. |
| 228 | + * @return HTML |
| 229 | + */ |
| 230 | + function searchForm() { |
| 231 | + global $wgScript, $wgRequest, $wgUseTwoButtonsSearchForm; |
| 232 | + |
| 233 | + $searchTitle = SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey(); |
| 234 | + $searchQuery = trim( $wgRequest->getVal( 'search' ) ); |
| 235 | + |
| 236 | + $s = '<form action="' . $wgScript . '" id="searchform"> |
| 237 | + <input type="hidden" name="title" value="' . $searchTitle . '" />'; |
| 238 | + $s .= Html::input( |
| 239 | + 'search', |
| 240 | + isset( $searchQuery ) ? $searchQuery : '', 'search', |
| 241 | + array( |
| 242 | + 'id' => 'searchInput', |
| 243 | + 'title' => $this->titleAttrib( 'search' ), |
| 244 | + 'accesskey' => $this->accesskey( 'search' ) |
| 245 | + ) |
| 246 | + ) . "\n"; |
| 247 | + |
| 248 | + $s .= '<input type="submit" name="go" class="searchButton" id="searchGoButton" value="' . wfMsg( 'searcharticle' ) . '"' . $this->tooltipAndAccesskey( 'search-go' ) . ' />'; |
| 249 | + if ( $wgUseTwoButtonsSearchForm ) { |
| 250 | + $s .= ' |
| 251 | + <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="' . wfMsg( 'searchbutton' ) . '"' . $this->tooltipAndAccesskey( 'search-fulltext' ) . ' />'; |
| 252 | + } else { |
| 253 | + $s .= '<div><a href="' . $this->escapeSearchLink() . '" rel="search">' |
| 254 | + . wfMsg( 'powersearch-legend' ) . '</a></div>'; |
334 | 255 | } |
335 | | -?> |
336 | | - </div> |
337 | | - </div> |
338 | | -<?php |
| 256 | + |
| 257 | + $s .= '</form>'; |
| 258 | + return $s; |
339 | 259 | } |
340 | | -} // end of class |
341 | 260 | |
| 261 | + function outputPage( OutputPage $out ) { |
| 262 | + global $wgDebugComments; |
| 263 | + wfProfileIn( __METHOD__ ); |
342 | 264 | |
| 265 | + $this->setMembers(); |
| 266 | + $this->initPage( $out ); |
| 267 | + |
| 268 | + // See self::afterContentHook() for documentation |
| 269 | + $afterContent = $this->afterContentHook(); |
| 270 | + |
| 271 | + $out->out( $out->headElement( $this ) ); |
| 272 | + |
| 273 | + if ( $wgDebugComments ) { |
| 274 | + $out->out( |
| 275 | + "<!-- Wiki debugging output:\n" . |
| 276 | + $out->mDebugtext . "-->\n" |
| 277 | + ); |
| 278 | + } |
| 279 | + |
| 280 | + $out->out( $this->beforeContent() ); |
| 281 | + |
| 282 | + $out->out( '<!-- start content -->' . "\n" ); |
| 283 | + $out->out( $out->mBodytext . "\n" ); |
| 284 | + $out->out( $this->getCategories() . "\n" ); |
| 285 | + $out->out( '<!-- end content -->' . "\n" ); |
| 286 | + |
| 287 | + $out->out( $this->afterContent() ); |
| 288 | + |
| 289 | + $out->out( $afterContent ); |
| 290 | + |
| 291 | + $attribs = $this->getAttributes(); |
| 292 | + $out->out( '<div class="visualClear"></div> |
| 293 | + </div><!-- #bodyContent --> |
| 294 | + </div><!-- #content --> |
| 295 | + </div><!-- #column-content --> |
| 296 | + <div id="column-one"' . $attribs[0] . '>' . "\n" ); |
| 297 | + |
| 298 | + $out->out( $this->getContentActions() . "\n" ); |
| 299 | + |
| 300 | + $out->out( $this->getPersonalTools() . "\n" ); |
| 301 | + |
| 302 | + $out->out( $this->getLogoPortlet() . "\n" ); |
| 303 | + |
| 304 | + global $wgJsMimeType; |
| 305 | + $out->out( '<script type="' . $wgJsMimeType . '"> if ( window.isMSIE55 ) fixalpha(); </script>' . "\n" ); |
| 306 | + |
| 307 | + $out->out( $this->doSidebar() . "\n" ); |
| 308 | + |
| 309 | + $out->out( |
| 310 | + "\t\t" . '</div><!-- end of the left (by default at least) column (column-one) -->' . "\n" . |
| 311 | + '<div class="visualClear"></div>' . "\n" |
| 312 | + ); |
| 313 | + |
| 314 | + $out->out( $this->footer() . "\n" ); |
| 315 | + $out->out( '</div><!-- #globalWrapper -->' . "\n" ); |
| 316 | + |
| 317 | + $out->out( $this->bottomScripts() . "\n" ); |
| 318 | + |
| 319 | + $out->out( wfReportTime() . "\n" ); |
| 320 | + |
| 321 | + $out->out( "\n</body></html>" ); |
| 322 | + wfProfileOut( __METHOD__ ); |
| 323 | + } |
| 324 | + |
| 325 | +} // end of class |
\ No newline at end of file |
Index: branches/SkinSystemRewrite/skins/Modern.php |
— | — | @@ -1,338 +1,273 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Modern skin, derived from monobook template. |
| 4 | + * Modern skin, derived from Monobook template. |
5 | 5 | * |
6 | 6 | * @todo document |
7 | 7 | * @file |
8 | 8 | * @ingroup Skins |
9 | 9 | */ |
10 | 10 | |
11 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 11 | +if( !defined( 'MEDIAWIKI' ) ) { |
12 | 12 | die( -1 ); |
| 13 | +} |
13 | 14 | |
14 | 15 | /** |
15 | | - * Inherit main code from SkinTemplate, set the CSS and template filter. |
| 16 | + * Inherit main code from Skin, set the CSS and template filter. |
16 | 17 | * @todo document |
17 | 18 | * @ingroup Skins |
18 | 19 | */ |
19 | | -class SkinModern extends SkinTemplate { |
20 | | - var $skinname = 'modern', $stylename = 'modern', |
21 | | - $template = 'ModernTemplate', $useHeadElement = true; |
| 20 | +class SkinModern extends Skin { |
22 | 21 | |
23 | | - /* |
| 22 | + /** |
| 23 | + * We don't want common/wikiprintable.css, we have our own print stylesheet. |
| 24 | + */ |
| 25 | + public function commonPrintStylesheet() { |
| 26 | + return false; |
| 27 | + } |
| 28 | + |
| 29 | + /** @return string skin name */ |
| 30 | + public function getSkinName() { |
| 31 | + return 'modern'; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
24 | 35 | * We don't like the default getPoweredBy, the icon clashes with the |
25 | 36 | * skin L&F. |
26 | 37 | */ |
27 | 38 | function getPoweredBy() { |
28 | | - global $wgVersion; |
29 | | - return "<div class='mw_poweredby'>Powered by MediaWiki $wgVersion</div>"; |
| 39 | + global $wgVersion; |
| 40 | + return "<div class=\"mw_poweredby\">Powered by MediaWiki $wgVersion</div>"; |
30 | 41 | } |
31 | 42 | |
32 | | - function setupSkinUserCss( OutputPage $out ){ |
33 | | - global $wgStyleVersion, $wgJsMimeType, $wgStylePath; |
34 | | - |
35 | | - // Do not call parent::setupSkinUserCss(), we have our own print style |
| 43 | + /** |
| 44 | + * Add skin specific stylesheets |
| 45 | + * Overridden because we have our own print style. |
| 46 | + * @param $out OutputPage |
| 47 | + */ |
| 48 | + function setupSkinUserCss( OutputPage $out ) { |
36 | 49 | $out->addStyle( 'common/shared.css', 'screen' ); |
37 | 50 | $out->addStyle( 'modern/main.css', 'screen' ); |
38 | 51 | $out->addStyle( 'modern/print.css', 'print' ); |
39 | 52 | $out->addStyle( 'modern/rtl.css', 'screen', '', 'rtl' ); |
40 | 53 | } |
41 | | -} |
42 | 54 | |
43 | | -/** |
44 | | - * @todo document |
45 | | - * @ingroup Skins |
46 | | - */ |
47 | | -class ModernTemplate extends QuickTemplate { |
48 | | - var $skin; |
| 55 | + function pageTitle() { |
| 56 | + global $wgOut; |
| 57 | + $s = '<!-- heading -->' . "\n"; |
| 58 | + $s .= '<div id="mw_header"><h1 id="firstHeading">' |
| 59 | + . $wgOut->getPageTitle() . |
| 60 | + '</h1></div>' . "\n"; |
| 61 | + return $s; |
| 62 | + } |
| 63 | + |
49 | 64 | /** |
50 | | - * Template filter callback for Modern skin. |
51 | | - * Takes an associative array of data set from a SkinTemplate-based |
52 | | - * class, and a wrapper for MediaWiki's localization database, and |
53 | | - * outputs a formatted page. |
54 | | - * |
55 | | - * @access private |
| 65 | + * Gets the page subtitle and site tagline. |
| 66 | + * @todo FIXME/CHECKME: maybe not necessary? |
| 67 | + * @return HTML |
56 | 68 | */ |
57 | | - function execute() { |
58 | | - global $wgRequest, $wgOut; |
59 | | - $this->skin = $skin = $this->data['skin']; |
60 | | - $action = $wgRequest->getText( 'action' ); |
| 69 | + function pageSubtitle() { |
| 70 | + global $wgOut; |
61 | 71 | |
62 | | - // Suppress warnings to prevent notices about missing indexes in $this->data |
63 | | - wfSuppressWarnings(); |
| 72 | + $s = ''; |
| 73 | + $attribs = $this->getAttributes(); |
| 74 | + $sub = $wgOut->getSubtitle(); |
| 75 | + $s .= '<div id="contentSub"' . $attribs[0] . '>' . $sub . '</div>'; |
| 76 | + if ( $sub == '' ) { |
| 77 | + global $wgExtraSubtitle; |
| 78 | + $sub = '<h3 id="siteSub">' . wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle . '</h3>'; |
| 79 | + } |
| 80 | + $subpages = $this->subPageSubtitle(); |
| 81 | + $sub .= !empty( $subpages ) ? '<span class="subpages">' . $subpages . '</span>' : $wgOut->getSubtitle(); |
| 82 | + return $s; |
| 83 | + } |
64 | 84 | |
65 | | - $this->html( 'headelement' ); |
66 | | -?> |
| 85 | + /** |
| 86 | + * Renders things that are displayed before the actual page content. |
| 87 | + * For example, newtalk notifications, site notice etc. |
| 88 | + * @return HTML |
| 89 | + */ |
| 90 | + function doBeforeContent() { |
| 91 | + global $wgContLang, $wgUser; |
| 92 | + wfProfileIn( __METHOD__ ); |
67 | 93 | |
68 | | - <!-- heading --> |
69 | | - <div id="mw_header"><h1 id="firstHeading"><?php $this->html('title') ?></h1></div> |
| 94 | + $s = ''; |
70 | 95 | |
71 | | - <div id="mw_main"> |
| 96 | + $s .= $this->pageTitle() . "\n"; |
| 97 | + $s .= '<div id="mw_main"> |
72 | 98 | <div id="mw_contentwrapper"> |
73 | | - <!-- navigation portlet --> |
74 | | - <div id="p-cactions" class="portlet"> |
75 | | - <h5><?php $this->msg('views') ?></h5> |
76 | | - <div class="pBody"> |
77 | | - <ul> |
78 | | - <?php foreach($this->data['content_actions'] as $key => $tab) { |
79 | | - echo ' |
80 | | - <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"'; |
81 | | - if( $tab['class'] ) { |
82 | | - echo ' class="'.htmlspecialchars($tab['class']).'"'; |
83 | | - } |
84 | | - echo'><a href="'.htmlspecialchars($tab['href']).'"'; |
85 | | - # We don't want to give the watch tab an accesskey if the |
86 | | - # page is being edited, because that conflicts with the |
87 | | - # accesskey on the watch checkbox. We also don't want to |
88 | | - # give the edit tab an accesskey, because that's fairly su- |
89 | | - # perfluous and conflicts with an accesskey (Ctrl-E) often |
90 | | - # used for editing in Safari. |
91 | | - if( in_array( $action, array( 'edit', 'submit' ) ) |
92 | | - && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) { |
93 | | - echo $skin->tooltip( "ca-$key" ); |
94 | | - } else { |
95 | | - echo $skin->tooltipAndAccesskey( "ca-$key" ); |
96 | | - } |
97 | | - echo '>'.htmlspecialchars($tab['text']).'</a></li>'; |
98 | | - } ?> |
99 | | - </ul> |
100 | | - </div> |
101 | | - </div> |
| 99 | + <!-- navigation portlet -->'; |
| 100 | + $s .= $this->getContentActions(); |
102 | 101 | |
103 | | - <!-- content --> |
| 102 | + $attribs = $this->getAttributes(); |
| 103 | + $s .= '<!-- content --> |
104 | 104 | <div id="mw_content"> |
105 | 105 | <!-- contentholder does nothing by default, but it allows users to style the text inside |
106 | | - the content area without affecting the meaning of 'em' in #mw_content, which is used |
| 106 | + the content area without affecting the meaning of "em" in #mw_content, which is used |
107 | 107 | for the margins --> |
108 | | - <div id="mw_contentholder" <?php $this->html("specialpageattributes") ?>> |
109 | | - <div class='mw-topboxes'> |
110 | | - <div id="mw-js-message" style="display:none;" <?php $this->html('userlangattributes')?>></div> |
111 | | - <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div> |
112 | | - <?php if($this->data['newtalk'] ) { |
113 | | - ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div> |
114 | | - <?php } ?> |
115 | | - <?php if($this->data['sitenotice']) { |
116 | | - ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div> |
117 | | - <?php } ?> |
118 | | - </div> |
| 108 | + <div id="mw_contentholder"' . $attribs[1] . '> |
| 109 | + <div class="mw-topboxes"> |
| 110 | + <div id="mw-js-message" style="display:none;"' . $attribs[0] . '></div>'; |
| 111 | + // New talk page messages, if any |
| 112 | + $newtalks = $this->getNewtalks(); |
| 113 | + if ( !empty( $newtalks ) ) { |
| 114 | + $s .= '<div class="usermessage mw-topbox">' . $newtalks . '</div>'; |
| 115 | + } |
119 | 116 | |
120 | | - <div id="contentSub" <?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div> |
| 117 | + // Site notice ([[MediaWiki:Sitenotice]]) |
| 118 | + $notice = wfGetSiteNotice(); |
| 119 | + if( $notice ) { |
| 120 | + $s .= "\n<div class=\"mw-topbox\" id=\"siteNotice\">$notice</div>\n"; |
| 121 | + } |
| 122 | + $s .= '</div>'; |
| 123 | + $s .= $this->pageSubtitle(); |
121 | 124 | |
122 | | - <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?> |
123 | | - <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#mw_portlets"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?> |
| 125 | + // Undelete link, if available |
| 126 | + $undelete = $this->getUndeleteLink(); |
| 127 | + if ( !empty( $undelete ) ) { |
| 128 | + $s .= '<span class="subpages">' . $undelete . '</span>'; |
| 129 | + } |
124 | 130 | |
125 | | - <?php $this->html('bodytext') ?> |
126 | | - <div class='mw_clear'></div> |
127 | | - <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?> |
128 | | - <?php $this->html ('dataAfterContent') ?> |
129 | | - </div><!-- mw_contentholder --> |
130 | | - </div><!-- mw_content --> |
131 | | - </div><!-- mw_contentwrapper --> |
132 | | - |
133 | | - <div id="mw_portlets" <?php $this->html("userlangattributes") ?>> |
134 | | - |
135 | | - <!-- portlets --> |
136 | | - <?php |
137 | | - $sidebar = $this->data['sidebar']; |
138 | | - if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true; |
139 | | - if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true; |
140 | | - if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true; |
141 | | - |
142 | | - foreach ($sidebar as $boxName => $cont) { |
143 | | - if ( $boxName == 'SEARCH' ) { |
144 | | - $this->searchBox(); |
145 | | - } elseif ( $boxName == 'TOOLBOX' ) { |
146 | | - $this->toolbox(); |
147 | | - } elseif ( $boxName == 'LANGUAGES' ) { |
148 | | - $this->languageBox(); |
149 | | - } else { |
150 | | - $this->customBox( $boxName, $cont ); |
151 | | - } |
| 131 | + // Jump to navigation links, if user has enabled them in their prefs. |
| 132 | + if ( $wgUser->getOption( 'showjumplinks' ) ) { |
| 133 | + $s .= "\n" . '<div id="jump-to-nav">' . wfMsg( 'jumpto' ) . |
| 134 | + ' <a href="#mw_portlets">' . wfMsg( 'jumptonavigation' ) . |
| 135 | + '</a>, <a href="#searchInput">' . wfMsg( 'jumptosearch' ) . |
| 136 | + '</a></div>' . "\n"; |
152 | 137 | } |
153 | | - ?> |
154 | 138 | |
155 | | - </div><!-- mw_portlets --> |
| 139 | + wfProfileOut( __METHOD__ ); |
| 140 | + return $s; |
| 141 | + } |
156 | 142 | |
| 143 | + /** |
| 144 | + * No-op, since the default has two div tags, which would mess up things. |
| 145 | + * @return nothing |
| 146 | + */ |
| 147 | + function doAfterContent() {} |
157 | 148 | |
158 | | - </div><!-- main --> |
| 149 | + /** |
| 150 | + * Gets content action tabs (edit, move, history, watch...). |
| 151 | + * @return HTML |
| 152 | + */ |
| 153 | + function getContentActions() { |
| 154 | + $s = '<div id="p-cactions" class="portlet"> |
| 155 | + <h5>' . wfMsg( 'views' ) . '</h5> |
| 156 | + <div class="pBody"> |
| 157 | + <ul>' . $this->renderContentActions() . '</ul> |
| 158 | + </div> |
| 159 | + </div>'; |
| 160 | + return $s; |
| 161 | + } |
159 | 162 | |
160 | | - <div class="mw_clear"></div> |
161 | | - |
162 | | - <!-- personal portlet --> |
163 | | - <div class="portlet" id="p-personal"> |
164 | | - <h5><?php $this->msg('personaltools') ?></h5> |
| 163 | + /** |
| 164 | + * Builds personal tools (links to own user/talk pages, contribs, etc.) |
| 165 | + * @return HTML |
| 166 | + */ |
| 167 | + function getPersonalTools() { |
| 168 | + $attribs = $this->getAttributes(); |
| 169 | + $s = '<div class="portlet" id="p-personal"> |
| 170 | + <h5>' . wfMsg( 'personaltools' ) . '</h5> |
165 | 171 | <div class="pBody"> |
166 | | - <ul> |
167 | | -<?php foreach($this->data['personal_urls'] as $key => $item) { ?> |
168 | | - <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php |
169 | | - if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php |
170 | | - echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php |
171 | | - if(!empty($item['class'])) { ?> class="<?php |
172 | | - echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php |
173 | | - echo htmlspecialchars($item['text']) ?></a></li> |
174 | | -<?php } ?> |
175 | | - </ul> |
| 172 | + <ul' . $attribs[0] . '>' |
| 173 | + . $this->renderPersonalTools() . |
| 174 | + '</ul> |
176 | 175 | </div> |
177 | | - </div> |
| 176 | + </div>'; |
| 177 | + return $s; |
| 178 | + } |
178 | 179 | |
| 180 | + /** |
| 181 | + * Main search form. searchBox() does the UI stuff. |
| 182 | + * @return HTML |
| 183 | + */ |
| 184 | + function searchForm() { |
| 185 | + global $wgScript, $wgRequest, $wgUseTwoButtonsSearchForm; |
179 | 186 | |
180 | | - <!-- footer --> |
181 | | - <div id="footer" <?php $this->html('userlangattributes') ?>> |
182 | | - <ul id="f-list"> |
183 | | -<?php |
184 | | - $footerlinks = array( |
185 | | - 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright', |
186 | | - 'privacy', 'about', 'disclaimer', 'tagline', |
187 | | - ); |
188 | | - foreach( $footerlinks as $aLink ) { |
189 | | - if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
190 | | -?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li> |
191 | | -<?php } |
| 187 | + $searchTitle = SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey(); |
| 188 | + $searchQuery = trim( $wgRequest->getVal( 'search' ) ); |
| 189 | + |
| 190 | + $s = '<form action="' . $wgScript . '" id="searchform"> |
| 191 | + <input type="hidden" name="title" value="' . $searchTitle . '" />'; |
| 192 | + $s .= Html::input( |
| 193 | + 'search', |
| 194 | + isset( $searchQuery ) ? $searchQuery : '', 'search', |
| 195 | + array( |
| 196 | + 'id' => 'searchInput', |
| 197 | + 'title' => $this->titleAttrib( 'search' ), |
| 198 | + 'accesskey' => $this->accesskey( 'search' ) |
| 199 | + ) |
| 200 | + ) . "\n"; |
| 201 | + |
| 202 | + $s .= '<input type="submit" name="go" class="searchButton" id="searchGoButton" value="' . wfMsg( 'searcharticle' ) . '"' . $this->tooltipAndAccesskey( 'search-go' ) . ' />'; |
| 203 | + if ( $wgUseTwoButtonsSearchForm ) { |
| 204 | + $s .= ' |
| 205 | + <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="' . wfMsg( 'searchbutton' ) . '"' . $this->tooltipAndAccesskey( 'search-fulltext' ) . ' />'; |
| 206 | + } else { |
| 207 | + $s .= '<div><a href="' . $this->escapeSearchLink() . '" rel="search">' |
| 208 | + . wfMsg( 'powersearch-legend' ) . '</a></div>'; |
192 | 209 | } |
193 | | -?> |
194 | | - </ul> |
195 | | - <?php echo $this->html("poweredbyico"); ?> |
196 | | - </div> |
197 | 210 | |
198 | | - <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?> |
199 | | -<?php $this->html('reporttime') ?> |
200 | | -<?php if ( $this->data['debug'] ): ?> |
201 | | -<!-- Debug output: |
202 | | -<?php $this->text( 'debug' ); ?> |
203 | | -<?php endif; ?> |
204 | | -</body></html> |
205 | | -<?php |
206 | | - wfRestoreWarnings(); |
207 | | - } // end of execute() method |
| 211 | + $s .= '</form>'; |
| 212 | + return $s; |
| 213 | + } |
208 | 214 | |
209 | | - /*************************************************************************************************/ |
210 | | - function searchBox() { |
211 | | - global $wgUseTwoButtonsSearchForm; |
212 | | -?> |
213 | | - <!-- search --> |
214 | | - <div id="p-search" class="portlet"> |
215 | | - <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5> |
216 | | - <div id="searchBody" class="pBody"> |
217 | | - <form action="<?php $this->text('wgScript') ?>" id="searchform"> |
218 | | - <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/> |
219 | | - <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search'); |
220 | | - if( isset( $this->data['search'] ) ) { |
221 | | - ?> value="<?php $this->text('search') ?>"<?php } ?> /> |
222 | | - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?> |
223 | | - <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?> |
| 215 | + function outputPage( OutputPage $out ) { |
| 216 | + global $wgDebugComments; |
| 217 | + wfProfileIn( __METHOD__ ); |
224 | 218 | |
225 | | - <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?> |
| 219 | + $this->setMembers(); |
| 220 | + $this->initPage( $out ); |
226 | 221 | |
227 | | - </form> |
228 | | - </div> |
229 | | - </div> |
230 | | -<?php |
231 | | - } |
| 222 | + // See self::afterContentHook() for documentation |
| 223 | + $afterContent = $this->afterContentHook(); |
232 | 224 | |
233 | | - /*************************************************************************************************/ |
234 | | - function toolbox() { |
235 | | -?> |
236 | | - <!-- toolbox --> |
237 | | - <div class="portlet" id="p-tb"> |
238 | | - <h5><?php $this->msg('toolbox') ?></h5> |
239 | | - <div class="pBody"> |
240 | | - <ul> |
241 | | -<?php |
242 | | - if($this->data['notspecialpage']) { ?> |
243 | | - <li id="t-whatlinkshere"><a href="<?php |
244 | | - echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href']) |
245 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li> |
246 | | -<?php |
247 | | - if( $this->data['nav_urls']['recentchangeslinked'] ) { ?> |
248 | | - <li id="t-recentchangeslinked"><a href="<?php |
249 | | - echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href']) |
250 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li> |
251 | | -<?php } |
| 225 | + $out->out( $out->headElement( $this ) ); |
| 226 | + |
| 227 | + if ( $wgDebugComments ) { |
| 228 | + $out->out( |
| 229 | + "<!-- Wiki debugging output:\n" . |
| 230 | + $out->mDebugtext . "-->\n" |
| 231 | + ); |
252 | 232 | } |
253 | | - if(isset($this->data['nav_urls']['trackbacklink'])) { ?> |
254 | | - <li id="t-trackbacklink"><a href="<?php |
255 | | - echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href']) |
256 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li> |
257 | | -<?php } |
258 | | - if($this->data['feeds']) { ?> |
259 | | - <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) { |
260 | | - ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php |
261 | | - echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a> |
262 | | - <?php } ?></li><?php |
263 | | - } |
264 | 233 | |
265 | | - foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) { |
| 234 | + $out->out( $this->beforeContent() ); |
266 | 235 | |
267 | | - if($this->data['nav_urls'][$special]) { |
268 | | - ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href']) |
269 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li> |
270 | | -<?php } |
271 | | - } |
| 236 | + $out->out( '<!-- start content -->' . "\n" ); |
| 237 | + $out->out( $out->mBodytext . "\n" ); |
| 238 | + $out->out( '<div class="mw_clear"></div>' . "\n" ); |
| 239 | + $out->out( $this->getCategories() . "\n" ); |
| 240 | + $out->out( '<!-- end content -->' . "\n" ); |
272 | 241 | |
273 | | - if(!empty($this->data['nav_urls']['print']['href'])) { ?> |
274 | | - <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href']) |
275 | | - ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php |
276 | | - } |
| 242 | + $out->out( $this->afterContent() ); |
277 | 243 | |
278 | | - if(!empty($this->data['nav_urls']['permalink']['href'])) { ?> |
279 | | - <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href']) |
280 | | - ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php |
281 | | - } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?> |
282 | | - <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php |
283 | | - } |
| 244 | + $out->out( $afterContent ); |
284 | 245 | |
285 | | - wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); |
286 | | -?> |
287 | | - </ul> |
288 | | - </div> |
289 | | - </div> |
290 | | -<?php |
291 | | - } |
| 246 | + $out->out( '</div><!-- mw_contentholder --> |
| 247 | + </div><!-- mw_content --> |
| 248 | + </div><!-- mw_contentwrapper -->' |
| 249 | + ); |
292 | 250 | |
293 | | - /*************************************************************************************************/ |
294 | | - function languageBox() { |
295 | | - if( $this->data['language_urls'] ) { |
296 | | -?> |
297 | | - <div id="p-lang" class="portlet"> |
298 | | - <h5><?php $this->msg('otherlanguages') ?></h5> |
299 | | - <div class="pBody"> |
300 | | - <ul> |
301 | | -<?php foreach($this->data['language_urls'] as $langlink) { ?> |
302 | | - <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php |
303 | | - ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li> |
304 | | -<?php } ?> |
305 | | - </ul> |
306 | | - </div> |
307 | | - </div> |
308 | | -<?php |
309 | | - } |
310 | | - } |
| 251 | + $attribs = $this->getAttributes(); |
| 252 | + $out->out( '<div id="mw_portlets"' . $attribs[0] . '>' . "\n" ); |
| 253 | + $out->out( "\n" . '<!-- portlets -->' . "\n" ); |
| 254 | + $out->out( $this->doSidebar() . "\n" ); |
| 255 | + $out->out( '</div><!-- mw_portlets -->' . "\n" ); |
| 256 | + $out->out( "\n\n" . '</div><!-- main -->' . "\n" ); |
311 | 257 | |
312 | | - /*************************************************************************************************/ |
313 | | - function customBox( $bar, $cont ) { |
314 | | -?> |
315 | | - <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>> |
316 | | - <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5> |
317 | | - <div class='pBody'> |
318 | | -<?php if ( is_array( $cont ) ) { ?> |
319 | | - <ul> |
320 | | -<?php foreach($cont as $key => $val) { ?> |
321 | | - <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php |
322 | | - if ( $val['active'] ) { ?> class="active" <?php } |
323 | | - ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li> |
324 | | -<?php } ?> |
325 | | - </ul> |
326 | | -<?php } else { |
327 | | - # allow raw HTML block to be defined by extensions |
328 | | - print $cont; |
329 | | - } |
330 | | -?> |
331 | | - </div> |
332 | | - </div> |
333 | | -<?php |
334 | | - } |
| 258 | + $out->out( '<div class="mw_clear"></div>' . "\n" ); |
335 | 259 | |
336 | | -} // end of class |
| 260 | + $out->out( '<!-- personal portlet -->' . "\n" ); |
| 261 | + $out->out( $this->getPersonalTools() . "\n" ); |
337 | 262 | |
| 263 | + $out->out( '<!-- footer -->' . "\n" ); |
| 264 | + $out->out( $this->footer() . "\n" ); |
338 | 265 | |
| 266 | + $out->out( $this->bottomScripts() . "\n" ); |
| 267 | + |
| 268 | + $out->out( wfReportTime() . "\n" ); |
| 269 | + |
| 270 | + $out->out( "\n</body></html>" ); |
| 271 | + wfProfileOut( __METHOD__ ); |
| 272 | + } |
| 273 | + |
| 274 | +} // end of class |
Index: branches/SkinSystemRewrite/includes/SkinTemplate.php |
— | — | @@ -308,108 +308,23 @@ |
309 | 309 | // Users can have their language set differently than the |
310 | 310 | // content of the wiki. For these users, tell the web browser |
311 | 311 | // that interface elements are in a different language. |
312 | | - $tpl->set( 'userlangattributes', ''); |
313 | | - $tpl->set( 'specialpageattributes', ''); |
| 312 | + $attribs = $this->getAttributes(); |
| 313 | + $tpl->set( 'userlangattributes', $attribs[0] ); |
| 314 | + $tpl->set( 'specialpageattributes', $attribs[1] ); |
314 | 315 | |
315 | | - $lang = $wgLang->getCode(); |
316 | | - $dir = $wgLang->getDir(); |
317 | | - if ( $lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir() ) { |
318 | | - $attrs = "lang='$lang' xml:lang='$lang' dir='$dir'"; |
| 316 | + $newtalks = $this->getNewtalks(); |
319 | 317 | |
320 | | - $tpl->set( 'userlangattributes', $attrs ); |
321 | | - |
322 | | - // The content of SpecialPages should be presented in the |
323 | | - // user's language. Content of regular pages should not be touched. |
324 | | - if($this->mTitle->isSpecialPage()) { |
325 | | - $tpl->set( 'specialpageattributes', $attrs ); |
326 | | - } |
327 | | - } |
328 | | - |
329 | | - $newtalks = $wgUser->getNewMessageLinks(); |
330 | | - |
331 | | - if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) { |
332 | | - $usertitle = $this->mUser->getUserPage(); |
333 | | - $usertalktitle = $usertitle->getTalkPage(); |
334 | | - |
335 | | - if( !$usertalktitle->equals( $this->mTitle ) ) { |
336 | | - $newmessageslink = $this->link( |
337 | | - $usertalktitle, |
338 | | - wfMsgHtml( 'newmessageslink' ), |
339 | | - array(), |
340 | | - array( 'redirect' => 'no' ), |
341 | | - array( 'known', 'noclasses' ) |
342 | | - ); |
343 | | - |
344 | | - $newmessagesdifflink = $this->link( |
345 | | - $usertalktitle, |
346 | | - wfMsgHtml( 'newmessagesdifflink' ), |
347 | | - array(), |
348 | | - array( 'diff' => 'cur' ), |
349 | | - array( 'known', 'noclasses' ) |
350 | | - ); |
351 | | - |
352 | | - $ntl = wfMsg( |
353 | | - 'youhavenewmessages', |
354 | | - $newmessageslink, |
355 | | - $newmessagesdifflink |
356 | | - ); |
357 | | - # Disable Cache |
358 | | - $out->setSquidMaxage( 0 ); |
359 | | - } |
360 | | - } else if( count( $newtalks ) ) { |
361 | | - // _>" " for BC <= 1.16 |
362 | | - $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) ); |
363 | | - $msgs = array(); |
364 | | - foreach( $newtalks as $newtalk ) { |
365 | | - $msgs[] = Xml::element('a', |
366 | | - array( 'href' => $newtalk['link'] ), $newtalk['wiki'] ); |
367 | | - } |
368 | | - $parts = implode( $sep, $msgs ); |
369 | | - $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts ); |
370 | | - $out->setSquidMaxage( 0 ); |
371 | | - } else { |
372 | | - $ntl = ''; |
373 | | - } |
374 | 318 | wfProfileOut( __METHOD__ . '-stuff2' ); |
375 | 319 | |
376 | 320 | wfProfileIn( __METHOD__ . '-stuff3' ); |
377 | | - $tpl->setRef( 'newtalk', $ntl ); |
| 321 | + $tpl->setRef( 'newtalk', $newtalks ); |
378 | 322 | $tpl->setRef( 'skin', $this ); |
379 | 323 | $tpl->set( 'logo', $this->logoText() ); |
380 | 324 | if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and |
381 | | - $wgArticle and 0 != $wgArticle->getID() ){ |
382 | | - if ( !$wgDisableCounters ) { |
383 | | - $viewcount = $wgLang->formatNum( $wgArticle->getCount() ); |
384 | | - if ( $viewcount ) { |
385 | | - $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) ); |
386 | | - } else { |
387 | | - $tpl->set( 'viewcount', false ); |
388 | | - } |
389 | | - } else { |
390 | | - $tpl->set( 'viewcount', false ); |
391 | | - } |
| 325 | + $wgArticle and 0 != $wgArticle->getID() ) { |
| 326 | + $tpl->set( 'viewcount', $this->getViewCount() ); |
392 | 327 | |
393 | | - if( $wgPageShowWatchingUsers ) { |
394 | | - $dbr = wfGetDB( DB_SLAVE ); |
395 | | - $watchlist = $dbr->tableName( 'watchlist' ); |
396 | | - $res = $dbr->select( 'watchlist', |
397 | | - array( 'COUNT(*) AS n' ), |
398 | | - array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ), |
399 | | - __METHOD__ |
400 | | - ); |
401 | | - $x = $dbr->fetchObject( $res ); |
402 | | - $numberofwatchingusers = $x->n; |
403 | | - if( $numberofwatchingusers > 0 ) { |
404 | | - $tpl->set( 'numberofwatchingusers', |
405 | | - wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ), |
406 | | - $wgLang->formatNum( $numberofwatchingusers ) ) |
407 | | - ); |
408 | | - } else { |
409 | | - $tpl->set( 'numberofwatchingusers', false ); |
410 | | - } |
411 | | - } else { |
412 | | - $tpl->set( 'numberofwatchingusers', false ); |
413 | | - } |
| 328 | + $tpl->set( 'numberofwatchingusers', $this->getNumberOfWatchingUsers() ); |
414 | 329 | |
415 | 330 | $tpl->set( 'copyright', $this->getCopyright() ); |
416 | 331 | |
— | — | @@ -460,26 +375,9 @@ |
461 | 376 | $tpl->setRef( 'bodytext', $out->mBodytext ); |
462 | 377 | |
463 | 378 | # Language links |
464 | | - $language_urls = array(); |
465 | | - |
466 | | - if ( !$wgHideInterlanguageLinks ) { |
467 | | - foreach( $out->getLanguageLinks() as $l ) { |
468 | | - $tmp = explode( ':', $l, 2 ); |
469 | | - $class = 'interwiki-' . $tmp[0]; |
470 | | - unset( $tmp ); |
471 | | - $nt = Title::newFromText( $l ); |
472 | | - if ( $nt ) { |
473 | | - $language_urls[] = array( |
474 | | - 'href' => $nt->getFullURL(), |
475 | | - 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ? |
476 | | - $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ), |
477 | | - 'class' => $class |
478 | | - ); |
479 | | - } |
480 | | - } |
481 | | - } |
482 | | - if( count( $language_urls ) ) { |
483 | | - $tpl->setRef( 'language_urls', $language_urls ); |
| 379 | + $langLinks = $this->fetchInterlanguageLinks(); |
| 380 | + if ( $langLinks ) { |
| 381 | + $tpl->setRef( 'language_urls', $langLinks ); |
484 | 382 | } else { |
485 | 383 | $tpl->set( 'language_urls', false ); |
486 | 384 | } |
— | — | @@ -533,163 +431,6 @@ |
534 | 432 | echo $str; |
535 | 433 | } |
536 | 434 | |
537 | | - /** |
538 | | - * build array of urls for personal toolbar |
539 | | - * @return array |
540 | | - * @private |
541 | | - */ |
542 | | - function buildPersonalUrls() { |
543 | | - global $wgOut, $wgRequest; |
544 | | - |
545 | | - $title = $wgOut->getTitle(); |
546 | | - $pageurl = $title->getLocalURL(); |
547 | | - wfProfileIn( __METHOD__ ); |
548 | | - |
549 | | - /* set up the default links for the personal toolbar */ |
550 | | - $personal_urls = array(); |
551 | | - $page = $wgRequest->getVal( 'returnto', $this->thisurl ); |
552 | | - $query = $wgRequest->getVal( 'returntoquery', $this->thisquery ); |
553 | | - $returnto = "returnto=$page"; |
554 | | - if( $this->thisquery != '' ) |
555 | | - $returnto .= "&returntoquery=$query"; |
556 | | - if( $this->loggedin ) { |
557 | | - $personal_urls['userpage'] = array( |
558 | | - 'text' => $this->username, |
559 | | - 'href' => &$this->userpageUrlDetails['href'], |
560 | | - 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
561 | | - 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ) |
562 | | - ); |
563 | | - $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
564 | | - $personal_urls['mytalk'] = array( |
565 | | - 'text' => wfMsg( 'mytalk' ), |
566 | | - 'href' => &$usertalkUrlDetails['href'], |
567 | | - 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
568 | | - 'active' => ( $usertalkUrlDetails['href'] == $pageurl ) |
569 | | - ); |
570 | | - $href = self::makeSpecialUrl( 'Preferences' ); |
571 | | - $personal_urls['preferences'] = array( |
572 | | - 'text' => wfMsg( 'mypreferences' ), |
573 | | - 'href' => $href, |
574 | | - 'active' => ( $href == $pageurl ) |
575 | | - ); |
576 | | - $href = self::makeSpecialUrl( 'Watchlist' ); |
577 | | - $personal_urls['watchlist'] = array( |
578 | | - 'text' => wfMsg( 'mywatchlist' ), |
579 | | - 'href' => $href, |
580 | | - 'active' => ( $href == $pageurl ) |
581 | | - ); |
582 | | - |
583 | | - # We need to do an explicit check for Special:Contributions, as we |
584 | | - # have to match both the title, and the target (which could come |
585 | | - # from request values or be specified in "sub page" form. The plot |
586 | | - # thickens, because $wgTitle is altered for special pages, so doesn't |
587 | | - # contain the original alias-with-subpage. |
588 | | - $origTitle = Title::newFromText( $wgRequest->getText( 'title' ) ); |
589 | | - if( $origTitle instanceof Title && $origTitle->getNamespace() == NS_SPECIAL ) { |
590 | | - list( $spName, $spPar ) = |
591 | | - SpecialPage::resolveAliasWithSubpage( $origTitle->getText() ); |
592 | | - $active = $spName == 'Contributions' |
593 | | - && ( ( $spPar && $spPar == $this->username ) |
594 | | - || $wgRequest->getText( 'target' ) == $this->username ); |
595 | | - } else { |
596 | | - $active = false; |
597 | | - } |
598 | | - |
599 | | - $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username ); |
600 | | - $personal_urls['mycontris'] = array( |
601 | | - 'text' => wfMsg( 'mycontris' ), |
602 | | - 'href' => $href, |
603 | | - 'active' => $active |
604 | | - ); |
605 | | - $personal_urls['logout'] = array( |
606 | | - 'text' => wfMsg( 'userlogout' ), |
607 | | - 'href' => self::makeSpecialUrl( 'Userlogout', |
608 | | - $title->isSpecial( 'Preferences' ) ? '' : $returnto |
609 | | - ), |
610 | | - 'active' => false |
611 | | - ); |
612 | | - } else { |
613 | | - global $wgUser; |
614 | | - $loginlink = $wgUser->isAllowed( 'createaccount' ) |
615 | | - ? 'nav-login-createaccount' |
616 | | - : 'login'; |
617 | | - if( $this->showIPinHeader() ) { |
618 | | - $href = &$this->userpageUrlDetails['href']; |
619 | | - $personal_urls['anonuserpage'] = array( |
620 | | - 'text' => $this->username, |
621 | | - 'href' => $href, |
622 | | - 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
623 | | - 'active' => ( $pageurl == $href ) |
624 | | - ); |
625 | | - $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
626 | | - $href = &$usertalkUrlDetails['href']; |
627 | | - $personal_urls['anontalk'] = array( |
628 | | - 'text' => wfMsg( 'anontalk' ), |
629 | | - 'href' => $href, |
630 | | - 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
631 | | - 'active' => ( $pageurl == $href ) |
632 | | - ); |
633 | | - $personal_urls['anonlogin'] = array( |
634 | | - 'text' => wfMsg( $loginlink ), |
635 | | - 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
636 | | - 'active' => $title->isSpecial( 'Userlogin' ) |
637 | | - ); |
638 | | - } else { |
639 | | - $personal_urls['login'] = array( |
640 | | - 'text' => wfMsg( $loginlink ), |
641 | | - 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
642 | | - 'active' => $title->isSpecial( 'Userlogin' ) |
643 | | - ); |
644 | | - } |
645 | | - } |
646 | | - |
647 | | - wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) ); |
648 | | - wfProfileOut( __METHOD__ ); |
649 | | - return $personal_urls; |
650 | | - } |
651 | | - |
652 | | - function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) { |
653 | | - $classes = array(); |
654 | | - if( $selected ) { |
655 | | - $classes[] = 'selected'; |
656 | | - } |
657 | | - if( $checkEdit && !$title->isKnown() ) { |
658 | | - $classes[] = 'new'; |
659 | | - $query = 'action=edit&redlink=1'; |
660 | | - } |
661 | | - |
662 | | - $text = wfMsg( $message ); |
663 | | - if ( wfEmptyMsg( $message, $text ) ) { |
664 | | - global $wgContLang; |
665 | | - $text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) ); |
666 | | - } |
667 | | - |
668 | | - $result = array(); |
669 | | - if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this, |
670 | | - $title, $message, $selected, $checkEdit, |
671 | | - &$classes, &$query, &$text, &$result ) ) ) { |
672 | | - return $result; |
673 | | - } |
674 | | - |
675 | | - return array( |
676 | | - 'class' => implode( ' ', $classes ), |
677 | | - 'text' => $text, |
678 | | - 'href' => $title->getLocalUrl( $query ) ); |
679 | | - } |
680 | | - |
681 | | - function makeTalkUrlDetails( $name, $urlaction = '' ) { |
682 | | - $title = Title::newFromText( $name ); |
683 | | - if( !is_object( $title ) ) { |
684 | | - throw new MWException( __METHOD__ . " given invalid pagename $name" ); |
685 | | - } |
686 | | - $title = $title->getTalkPage(); |
687 | | - self::checkTitle( $title, $name ); |
688 | | - return array( |
689 | | - 'href' => $title->getLocalURL( $urlaction ), |
690 | | - 'exists' => $title->getArticleID() != 0 ? true : false |
691 | | - ); |
692 | | - } |
693 | | - |
694 | 435 | function makeArticleUrlDetails( $name, $urlaction = '' ) { |
695 | 436 | $title = Title::newFromText( $name ); |
696 | 437 | $title= $title->getSubjectPage(); |
— | — | @@ -701,323 +442,6 @@ |
702 | 443 | } |
703 | 444 | |
704 | 445 | /** |
705 | | - * an array of edit links by default used for the tabs |
706 | | - * @return array |
707 | | - * @private |
708 | | - */ |
709 | | - function buildContentActionUrls() { |
710 | | - global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle; |
711 | | - |
712 | | - wfProfileIn( __METHOD__ ); |
713 | | - |
714 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
715 | | - $section = $wgRequest->getVal( 'section' ); |
716 | | - $content_actions = array(); |
717 | | - |
718 | | - $prevent_active_tabs = false; |
719 | | - wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$prevent_active_tabs ) ); |
720 | | - |
721 | | - if( $this->iscontent ) { |
722 | | - $subjpage = $this->mTitle->getSubjectPage(); |
723 | | - $talkpage = $this->mTitle->getTalkPage(); |
724 | | - |
725 | | - $nskey = $this->mTitle->getNamespaceKey(); |
726 | | - $content_actions[$nskey] = $this->tabAction( |
727 | | - $subjpage, |
728 | | - $nskey, |
729 | | - !$this->mTitle->isTalkPage() && !$prevent_active_tabs, |
730 | | - '', true |
731 | | - ); |
732 | | - |
733 | | - $content_actions['talk'] = $this->tabAction( |
734 | | - $talkpage, |
735 | | - 'talk', |
736 | | - $this->mTitle->isTalkPage() && !$prevent_active_tabs, |
737 | | - '', |
738 | | - true |
739 | | - ); |
740 | | - |
741 | | - wfProfileIn( __METHOD__ . '-edit' ); |
742 | | - if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) { |
743 | | - $istalk = $this->mTitle->isTalkPage(); |
744 | | - $istalkclass = $istalk?' istalk':''; |
745 | | - $content_actions['edit'] = array( |
746 | | - 'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass, |
747 | | - 'text' => $this->mTitle->exists() |
748 | | - ? wfMsg( 'edit' ) |
749 | | - : wfMsg( 'create' ), |
750 | | - 'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() ) |
751 | | - ); |
752 | | - |
753 | | - // adds new section link if page is a current revision of a talk page or |
754 | | - if ( ( $wgArticle && $wgArticle->isCurrent() && $istalk ) || $wgOut->showNewSectionLink() ) { |
755 | | - if ( !$wgOut->forceHideNewSectionLink() ) { |
756 | | - $content_actions['addsection'] = array( |
757 | | - 'class' => $section == 'new' ? 'selected' : false, |
758 | | - 'text' => wfMsg( 'addsection' ), |
759 | | - 'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' ) |
760 | | - ); |
761 | | - } |
762 | | - } |
763 | | - } elseif ( $this->mTitle->isKnown() ) { |
764 | | - $content_actions['viewsource'] = array( |
765 | | - 'class' => ($action == 'edit') ? 'selected' : false, |
766 | | - 'text' => wfMsg( 'viewsource' ), |
767 | | - 'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() ) |
768 | | - ); |
769 | | - } |
770 | | - wfProfileOut( __METHOD__ . '-edit' ); |
771 | | - |
772 | | - wfProfileIn( __METHOD__ . '-live' ); |
773 | | - if ( $this->mTitle->exists() ) { |
774 | | - |
775 | | - $content_actions['history'] = array( |
776 | | - 'class' => ($action == 'history') ? 'selected' : false, |
777 | | - 'text' => wfMsg( 'history_short' ), |
778 | | - 'href' => $this->mTitle->getLocalUrl( 'action=history' ), |
779 | | - 'rel' => 'archives', |
780 | | - ); |
781 | | - |
782 | | - if( $wgUser->isAllowed( 'delete' ) ) { |
783 | | - $content_actions['delete'] = array( |
784 | | - 'class' => ($action == 'delete') ? 'selected' : false, |
785 | | - 'text' => wfMsg( 'delete' ), |
786 | | - 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) |
787 | | - ); |
788 | | - } |
789 | | - if ( $this->mTitle->quickUserCan( 'move' ) ) { |
790 | | - $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage ); |
791 | | - $content_actions['move'] = array( |
792 | | - 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, |
793 | | - 'text' => wfMsg( 'move' ), |
794 | | - 'href' => $moveTitle->getLocalUrl() |
795 | | - ); |
796 | | - } |
797 | | - |
798 | | - if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
799 | | - if( !$this->mTitle->isProtected() ){ |
800 | | - $content_actions['protect'] = array( |
801 | | - 'class' => ($action == 'protect') ? 'selected' : false, |
802 | | - 'text' => wfMsg( 'protect' ), |
803 | | - 'href' => $this->mTitle->getLocalUrl( 'action=protect' ) |
804 | | - ); |
805 | | - |
806 | | - } else { |
807 | | - $content_actions['unprotect'] = array( |
808 | | - 'class' => ($action == 'unprotect') ? 'selected' : false, |
809 | | - 'text' => wfMsg( 'unprotect' ), |
810 | | - 'href' => $this->mTitle->getLocalUrl( 'action=unprotect' ) |
811 | | - ); |
812 | | - } |
813 | | - } |
814 | | - } else { |
815 | | - //article doesn't exist or is deleted |
816 | | - if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'deletedtext' ) ) { |
817 | | - if( $n = $this->mTitle->isDeleted() ) { |
818 | | - $undelTitle = SpecialPage::getTitleFor( 'Undelete' ); |
819 | | - $content_actions['undelete'] = array( |
820 | | - 'class' => false, |
821 | | - 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum( $n ) ), |
822 | | - 'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) ) |
823 | | - #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" ) |
824 | | - ); |
825 | | - } |
826 | | - } |
827 | | - |
828 | | - if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
829 | | - if( !$this->mTitle->getRestrictions( 'create' ) ) { |
830 | | - $content_actions['protect'] = array( |
831 | | - 'class' => ($action == 'protect') ? 'selected' : false, |
832 | | - 'text' => wfMsg( 'protect' ), |
833 | | - 'href' => $this->mTitle->getLocalUrl( 'action=protect' ) |
834 | | - ); |
835 | | - |
836 | | - } else { |
837 | | - $content_actions['unprotect'] = array( |
838 | | - 'class' => ($action == 'unprotect') ? 'selected' : false, |
839 | | - 'text' => wfMsg( 'unprotect' ), |
840 | | - 'href' => $this->mTitle->getLocalUrl( 'action=unprotect' ) |
841 | | - ); |
842 | | - } |
843 | | - } |
844 | | - } |
845 | | - |
846 | | - wfProfileOut( __METHOD__ . '-live' ); |
847 | | - |
848 | | - if( $this->loggedin ) { |
849 | | - if( !$this->mTitle->userIsWatching()) { |
850 | | - $content_actions['watch'] = array( |
851 | | - 'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false, |
852 | | - 'text' => wfMsg( 'watch' ), |
853 | | - 'href' => $this->mTitle->getLocalUrl( 'action=watch' ) |
854 | | - ); |
855 | | - } else { |
856 | | - $content_actions['unwatch'] = array( |
857 | | - 'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false, |
858 | | - 'text' => wfMsg( 'unwatch' ), |
859 | | - 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' ) |
860 | | - ); |
861 | | - } |
862 | | - } |
863 | | - |
864 | | - |
865 | | - wfRunHooks( 'SkinTemplateTabs', array( $this, &$content_actions ) ); |
866 | | - } else { |
867 | | - /* show special page tab */ |
868 | | - |
869 | | - $content_actions[$this->mTitle->getNamespaceKey()] = array( |
870 | | - 'class' => 'selected', |
871 | | - 'text' => wfMsg('nstab-special'), |
872 | | - 'href' => $wgRequest->getRequestURL(), // @bug 2457, 2510 |
873 | | - ); |
874 | | - |
875 | | - wfRunHooks( 'SkinTemplateBuildContentActionUrlsAfterSpecialPage', array( &$this, &$content_actions ) ); |
876 | | - } |
877 | | - |
878 | | - /* show links to different language variants */ |
879 | | - global $wgDisableLangConversion; |
880 | | - $variants = $wgContLang->getVariants(); |
881 | | - if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
882 | | - $preferred = $wgContLang->getPreferredVariant(); |
883 | | - $vcount=0; |
884 | | - foreach( $variants as $code ) { |
885 | | - $varname = $wgContLang->getVariantname( $code ); |
886 | | - if( $varname == 'disable' ) |
887 | | - continue; |
888 | | - $selected = ( $code == $preferred )? 'selected' : false; |
889 | | - $content_actions['varlang-' . $vcount] = array( |
890 | | - 'class' => $selected, |
891 | | - 'text' => $varname, |
892 | | - 'href' => $this->mTitle->getLocalURL( '', $code ) |
893 | | - ); |
894 | | - $vcount ++; |
895 | | - } |
896 | | - } |
897 | | - |
898 | | - wfRunHooks( 'SkinTemplateContentActions', array( &$content_actions ) ); |
899 | | - |
900 | | - wfProfileOut( __METHOD__ ); |
901 | | - return $content_actions; |
902 | | - } |
903 | | - |
904 | | - /** |
905 | | - * build array of common navigation links |
906 | | - * @return array |
907 | | - * @private |
908 | | - */ |
909 | | - function buildNavUrls() { |
910 | | - global $wgUseTrackbacks, $wgOut, $wgUser, $wgRequest; |
911 | | - global $wgEnableUploads, $wgUploadNavigationUrl; |
912 | | - |
913 | | - wfProfileIn( __METHOD__ ); |
914 | | - |
915 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
916 | | - |
917 | | - $nav_urls = array(); |
918 | | - $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() ); |
919 | | - if( $wgUploadNavigationUrl ) { |
920 | | - $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl ); |
921 | | - } elseif( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) { |
922 | | - $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) ); |
923 | | - } else { |
924 | | - $nav_urls['upload'] = false; |
925 | | - } |
926 | | - $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) ); |
927 | | - |
928 | | - // default permalink to being off, will override it as required below. |
929 | | - $nav_urls['permalink'] = false; |
930 | | - |
931 | | - // A print stylesheet is attached to all pages, but nobody ever |
932 | | - // figures that out. :) Add a link... |
933 | | - if( $this->iscontent && ( $action == 'view' || $action == 'purge' ) ) { |
934 | | - if ( !$wgOut->isPrintable() ) { |
935 | | - $nav_urls['print'] = array( |
936 | | - 'text' => wfMsg( 'printableversion' ), |
937 | | - 'href' => $wgRequest->appendQuery( 'printable=yes' ) |
938 | | - ); |
939 | | - } |
940 | | - |
941 | | - // Also add a "permalink" while we're at it |
942 | | - if ( $this->mRevisionId ) { |
943 | | - $nav_urls['permalink'] = array( |
944 | | - 'text' => wfMsg( 'permalink' ), |
945 | | - 'href' => $wgOut->getTitle()->getLocalURL( "oldid=$this->mRevisionId" ) |
946 | | - ); |
947 | | - } |
948 | | - |
949 | | - // Copy in case this undocumented, shady hook tries to mess with internals |
950 | | - $revid = $this->mRevisionId; |
951 | | - wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) ); |
952 | | - } |
953 | | - |
954 | | - if( $this->mTitle->getNamespace() != NS_SPECIAL ) { |
955 | | - $wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage ); |
956 | | - $nav_urls['whatlinkshere'] = array( |
957 | | - 'href' => $wlhTitle->getLocalUrl() |
958 | | - ); |
959 | | - if( $this->mTitle->getArticleId() ) { |
960 | | - $rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage ); |
961 | | - $nav_urls['recentchangeslinked'] = array( |
962 | | - 'href' => $rclTitle->getLocalUrl() |
963 | | - ); |
964 | | - } else { |
965 | | - $nav_urls['recentchangeslinked'] = false; |
966 | | - } |
967 | | - if( $wgUseTrackbacks ) |
968 | | - $nav_urls['trackbacklink'] = array( |
969 | | - 'href' => $wgOut->getTitle()->trackbackURL() |
970 | | - ); |
971 | | - } |
972 | | - |
973 | | - if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) { |
974 | | - $id = User::idFromName( $this->mTitle->getText() ); |
975 | | - $ip = User::isIP( $this->mTitle->getText() ); |
976 | | - } else { |
977 | | - $id = 0; |
978 | | - $ip = false; |
979 | | - } |
980 | | - |
981 | | - if( $id || $ip ) { # both anons and non-anons have contribs list |
982 | | - $nav_urls['contributions'] = array( |
983 | | - 'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() ) |
984 | | - ); |
985 | | - |
986 | | - if( $id ) { |
987 | | - $logPage = SpecialPage::getTitleFor( 'Log' ); |
988 | | - $nav_urls['log'] = array( |
989 | | - 'href' => $logPage->getLocalUrl( |
990 | | - array( |
991 | | - 'user' => $this->mTitle->getText() |
992 | | - ) |
993 | | - ) |
994 | | - ); |
995 | | - } else { |
996 | | - $nav_urls['log'] = false; |
997 | | - } |
998 | | - |
999 | | - if ( $wgUser->isAllowed( 'block' ) ) { |
1000 | | - $nav_urls['blockip'] = array( |
1001 | | - 'href' => self::makeSpecialUrlSubpage( 'Blockip', $this->mTitle->getText() ) |
1002 | | - ); |
1003 | | - } else { |
1004 | | - $nav_urls['blockip'] = false; |
1005 | | - } |
1006 | | - } else { |
1007 | | - $nav_urls['contributions'] = false; |
1008 | | - $nav_urls['log'] = false; |
1009 | | - $nav_urls['blockip'] = false; |
1010 | | - } |
1011 | | - $nav_urls['emailuser'] = false; |
1012 | | - if( $this->showEmailUser( $id ) ) { |
1013 | | - $nav_urls['emailuser'] = array( |
1014 | | - 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $this->mTitle->getText() ) |
1015 | | - ); |
1016 | | - } |
1017 | | - wfProfileOut( __METHOD__ ); |
1018 | | - return $nav_urls; |
1019 | | - } |
1020 | | - |
1021 | | - /** |
1022 | 446 | * Generate strings used for xml 'id' names |
1023 | 447 | * @return string |
1024 | 448 | * @private |
Index: branches/SkinSystemRewrite/includes/Skin.php |
— | — | @@ -2091,6 +2091,7 @@ |
2092 | 2092 | wfProfileOut( __METHOD__ ); |
2093 | 2093 | return $bar; |
2094 | 2094 | } |
| 2095 | + |
2095 | 2096 | /** |
2096 | 2097 | * Add content from a sidebar system message |
2097 | 2098 | * Currently only used for MediaWiki:Sidebar (but may be used by Extensions) |
— | — | @@ -2162,4 +2163,1025 @@ |
2163 | 2164 | public function commonPrintStylesheet() { |
2164 | 2165 | return true; |
2165 | 2166 | } |
| 2167 | + |
| 2168 | + /** |
| 2169 | + * Gets new talk page messages for the current user. |
| 2170 | + * @return MediaWiki message or if no new talk page messages, nothing |
| 2171 | + */ |
| 2172 | + function getNewtalks() { |
| 2173 | + global $wgUser, $wgOut; |
| 2174 | + $newtalks = $wgUser->getNewMessageLinks(); |
| 2175 | + |
| 2176 | + if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) { |
| 2177 | + $userTitle = $this->mUser->getUserPage(); |
| 2178 | + $userTalkTitle = $userTitle->getTalkPage(); |
| 2179 | + |
| 2180 | + if( !$userTalkTitle->equals( $this->mTitle ) ) { |
| 2181 | + $newMessagesLink = $this->link( |
| 2182 | + $userTalkTitle, |
| 2183 | + wfMsgHtml( 'newmessageslink' ), |
| 2184 | + array(), |
| 2185 | + array( 'redirect' => 'no' ), |
| 2186 | + array( 'known', 'noclasses' ) |
| 2187 | + ); |
| 2188 | + |
| 2189 | + $newMessagesDiffLink = $this->link( |
| 2190 | + $userTalkTitle, |
| 2191 | + wfMsgHtml( 'newmessagesdifflink' ), |
| 2192 | + array(), |
| 2193 | + array( 'diff' => 'cur' ), |
| 2194 | + array( 'known', 'noclasses' ) |
| 2195 | + ); |
| 2196 | + |
| 2197 | + $ntl = wfMsg( |
| 2198 | + 'youhavenewmessages', |
| 2199 | + $newMessagesLink, |
| 2200 | + $newMessagesDiffLink |
| 2201 | + ); |
| 2202 | + # Disable Squid cache |
| 2203 | + $wgOut->setSquidMaxage( 0 ); |
| 2204 | + } |
| 2205 | + } elseif( count( $newtalks ) ) { |
| 2206 | + // _>" " for BC <= 1.16 |
| 2207 | + $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) ); |
| 2208 | + $msgs = array(); |
| 2209 | + foreach( $newtalks as $newtalk ) { |
| 2210 | + $msgs[] = Xml::element( |
| 2211 | + 'a', |
| 2212 | + array( 'href' => $newtalk['link'] ), $newtalk['wiki'] |
| 2213 | + ); |
| 2214 | + } |
| 2215 | + $parts = implode( $sep, $msgs ); |
| 2216 | + $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts ); |
| 2217 | + $wgOut->setSquidMaxage( 0 ); |
| 2218 | + } else { |
| 2219 | + $ntl = ''; |
| 2220 | + } |
| 2221 | + return $ntl; |
| 2222 | + } |
| 2223 | + |
| 2224 | + /** |
| 2225 | + * Build array of common navigation links |
| 2226 | + * @return array |
| 2227 | + */ |
| 2228 | + function buildNavUrls() { |
| 2229 | + global $wgUseTrackbacks, $wgOut, $wgUser, $wgRequest; |
| 2230 | + global $wgEnableUploads, $wgUploadNavigationUrl; |
| 2231 | + |
| 2232 | + wfProfileIn( __METHOD__ ); |
| 2233 | + |
| 2234 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 2235 | + $title = $this->mTitle->getText(); |
| 2236 | + |
| 2237 | + $nav_urls = array(); |
| 2238 | + $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() ); |
| 2239 | + if( $wgUploadNavigationUrl ) { |
| 2240 | + $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl ); |
| 2241 | + } elseif( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) { |
| 2242 | + $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) ); |
| 2243 | + } else { |
| 2244 | + $nav_urls['upload'] = false; |
| 2245 | + } |
| 2246 | + $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) ); |
| 2247 | + |
| 2248 | + // default permalink to being off, will override it as required below. |
| 2249 | + $nav_urls['permalink'] = false; |
| 2250 | + |
| 2251 | + // A print stylesheet is attached to all pages, but nobody ever |
| 2252 | + // figures that out. :) Add a link... |
| 2253 | + if( $this->mTitle->getNamespace() != NS_SPECIAL && ( $action == 'view' || $action == 'purge' ) ) { |
| 2254 | + if ( !$wgOut->isPrintable() ) { |
| 2255 | + $nav_urls['print'] = array( |
| 2256 | + 'text' => wfMsg( 'printableversion' ), |
| 2257 | + 'href' => $wgRequest->appendQuery( 'printable=yes' ) |
| 2258 | + ); |
| 2259 | + } |
| 2260 | + |
| 2261 | + // Also add a "permalink" while we're at it |
| 2262 | + if ( $this->mRevisionId ) { |
| 2263 | + $nav_urls['permalink'] = array( |
| 2264 | + 'text' => wfMsg( 'permalink' ), |
| 2265 | + 'href' => $wgOut->getTitle()->getLocalURL( "oldid=$this->mRevisionId" ) |
| 2266 | + ); |
| 2267 | + } |
| 2268 | + |
| 2269 | + // Copy in case this undocumented, shady hook tries to mess with internals |
| 2270 | + $revid = $this->mRevisionId; |
| 2271 | + wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( $this, &$nav_urls, &$revid, &$revid ) ); |
| 2272 | + } |
| 2273 | + |
| 2274 | + if( $this->mTitle->getNamespace() != NS_SPECIAL ) { |
| 2275 | + $wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ); |
| 2276 | + $nav_urls['whatlinkshere'] = array( |
| 2277 | + 'href' => $wlhTitle->getLocalURL() |
| 2278 | + ); |
| 2279 | + if( $this->mTitle->getArticleId() ) { |
| 2280 | + $rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ); |
| 2281 | + $nav_urls['recentchangeslinked'] = array( |
| 2282 | + 'href' => $rclTitle->getLocalURL() |
| 2283 | + ); |
| 2284 | + } else { |
| 2285 | + $nav_urls['recentchangeslinked'] = false; |
| 2286 | + } |
| 2287 | + if( $wgUseTrackbacks ) { |
| 2288 | + $nav_urls['trackbacklink'] = array( |
| 2289 | + 'href' => $wgOut->getTitle()->trackbackURL() |
| 2290 | + ); |
| 2291 | + } |
| 2292 | + } |
| 2293 | + |
| 2294 | + if( |
| 2295 | + $this->mTitle->getNamespace() == NS_USER || |
| 2296 | + $this->mTitle->getNamespace() == NS_USER_TALK |
| 2297 | + ) |
| 2298 | + { |
| 2299 | + $id = User::idFromName( $title ); |
| 2300 | + $ip = User::isIP( $title ); |
| 2301 | + } else { |
| 2302 | + $id = 0; |
| 2303 | + $ip = false; |
| 2304 | + } |
| 2305 | + |
| 2306 | + if( $id || $ip ) { # both anons and non-anons have contribs list |
| 2307 | + $nav_urls['contributions'] = array( |
| 2308 | + 'href' => self::makeSpecialUrlSubpage( 'Contributions', $title ) |
| 2309 | + ); |
| 2310 | + |
| 2311 | + if( $id ) { |
| 2312 | + $logPage = SpecialPage::getTitleFor( 'Log' ); |
| 2313 | + $nav_urls['log'] = array( |
| 2314 | + 'href' => $logPage->getLocalURL( |
| 2315 | + array( |
| 2316 | + 'user' => $title |
| 2317 | + ) |
| 2318 | + ) |
| 2319 | + ); |
| 2320 | + } else { |
| 2321 | + $nav_urls['log'] = false; |
| 2322 | + } |
| 2323 | + |
| 2324 | + if ( $wgUser->isAllowed( 'block' ) ) { |
| 2325 | + $nav_urls['blockip'] = array( |
| 2326 | + 'href' => self::makeSpecialUrlSubpage( 'Blockip', $title ) |
| 2327 | + ); |
| 2328 | + } else { |
| 2329 | + $nav_urls['blockip'] = false; |
| 2330 | + } |
| 2331 | + } else { |
| 2332 | + $nav_urls['contributions'] = false; |
| 2333 | + $nav_urls['log'] = false; |
| 2334 | + $nav_urls['blockip'] = false; |
| 2335 | + } |
| 2336 | + $nav_urls['emailuser'] = false; |
| 2337 | + if( $this->showEmailUser( $id ) ) { |
| 2338 | + $nav_urls['emailuser'] = array( |
| 2339 | + 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $title ) |
| 2340 | + ); |
| 2341 | + } |
| 2342 | + wfProfileOut( __METHOD__ ); |
| 2343 | + return $nav_urls; |
| 2344 | + } |
| 2345 | + |
| 2346 | + /** |
| 2347 | + * An array of edit links by default used for the tabs |
| 2348 | + * @return array |
| 2349 | + */ |
| 2350 | + function buildContentActionUrls() { |
| 2351 | + global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle; |
| 2352 | + |
| 2353 | + wfProfileIn( __METHOD__ ); |
| 2354 | + |
| 2355 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 2356 | + $section = $wgRequest->getVal( 'section' ); |
| 2357 | + $content_actions = array(); |
| 2358 | + |
| 2359 | + $prevent_active_tabs = false; |
| 2360 | + wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( $this, &$prevent_active_tabs ) ); |
| 2361 | + |
| 2362 | + if( $this->mTitle->getNamespace() != NS_SPECIAL ) { |
| 2363 | + $subjpage = $this->mTitle->getSubjectPage(); |
| 2364 | + $talkpage = $this->mTitle->getTalkPage(); |
| 2365 | + |
| 2366 | + $nskey = $this->mTitle->getNamespaceKey(); |
| 2367 | + $content_actions[$nskey] = $this->tabAction( |
| 2368 | + $subjpage, |
| 2369 | + $nskey, |
| 2370 | + !$this->mTitle->isTalkPage() && !$prevent_active_tabs, |
| 2371 | + '', true |
| 2372 | + ); |
| 2373 | + |
| 2374 | + $content_actions['talk'] = $this->tabAction( |
| 2375 | + $talkpage, |
| 2376 | + 'talk', |
| 2377 | + $this->mTitle->isTalkPage() && !$prevent_active_tabs, |
| 2378 | + '', |
| 2379 | + true |
| 2380 | + ); |
| 2381 | + |
| 2382 | + wfProfileIn( __METHOD__ . '-edit' ); |
| 2383 | + if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) { |
| 2384 | + $isTalk = $this->mTitle->isTalkPage(); |
| 2385 | + $isTalkClass = $isTalk ? ' istalk' : ''; |
| 2386 | + $content_actions['edit'] = array( |
| 2387 | + 'class' => ( ( ( $action == 'edit' || $action == 'submit' ) && $section != 'new' ) ? 'selected' : '' ) . $isTalkClass, |
| 2388 | + 'text' => $this->mTitle->exists() |
| 2389 | + ? wfMsg( 'edit' ) |
| 2390 | + : wfMsg( 'create' ), |
| 2391 | + 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ) |
| 2392 | + ); |
| 2393 | + |
| 2394 | + // adds new section link if page is a current revision of a talk page or |
| 2395 | + if ( ( $wgArticle && $wgArticle->isCurrent() && $isTalk ) || $wgOut->showNewSectionLink() ) { |
| 2396 | + if ( !$wgOut->forceHideNewSectionLink() ) { |
| 2397 | + $content_actions['addsection'] = array( |
| 2398 | + 'class' => $section == 'new' ? 'selected' : false, |
| 2399 | + 'text' => wfMsg( 'addsection' ), |
| 2400 | + 'href' => $this->mTitle->getLocalURL( 'action=edit§ion=new' ) |
| 2401 | + ); |
| 2402 | + } |
| 2403 | + } |
| 2404 | + } elseif ( $this->mTitle->isKnown() ) { |
| 2405 | + $content_actions['viewsource'] = array( |
| 2406 | + 'class' => ( $action == 'edit' ) ? 'selected' : false, |
| 2407 | + 'text' => wfMsg( 'viewsource' ), |
| 2408 | + 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ) |
| 2409 | + ); |
| 2410 | + } |
| 2411 | + wfProfileOut( __METHOD__ . '-edit' ); |
| 2412 | + |
| 2413 | + wfProfileIn( __METHOD__ . '-live' ); |
| 2414 | + if ( $this->mTitle->exists() ) { |
| 2415 | + |
| 2416 | + $content_actions['history'] = array( |
| 2417 | + 'class' => ( $action == 'history' ) ? 'selected' : false, |
| 2418 | + 'text' => wfMsg( 'history_short' ), |
| 2419 | + 'href' => $this->mTitle->getLocalURL( 'action=history' ), |
| 2420 | + 'rel' => 'archives', |
| 2421 | + ); |
| 2422 | + |
| 2423 | + if( $wgUser->isAllowed( 'delete' ) ) { |
| 2424 | + $content_actions['delete'] = array( |
| 2425 | + 'class' => ( $action == 'delete' ) ? 'selected' : false, |
| 2426 | + 'text' => wfMsg( 'delete' ), |
| 2427 | + 'href' => $this->mTitle->getLocalURL( 'action=delete' ) |
| 2428 | + ); |
| 2429 | + } |
| 2430 | + if ( $this->mTitle->quickUserCan( 'move' ) ) { |
| 2431 | + $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->mTitle->getPrefixedDBkey() ); |
| 2432 | + $content_actions['move'] = array( |
| 2433 | + 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, |
| 2434 | + 'text' => wfMsg( 'move' ), |
| 2435 | + 'href' => $moveTitle->getLocalURL() |
| 2436 | + ); |
| 2437 | + } |
| 2438 | + |
| 2439 | + if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| 2440 | + if( !$this->mTitle->isProtected() ) { |
| 2441 | + $content_actions['protect'] = array( |
| 2442 | + 'class' => ( $action == 'protect' ) ? 'selected' : false, |
| 2443 | + 'text' => wfMsg( 'protect' ), |
| 2444 | + 'href' => $this->mTitle->getLocalURL( 'action=protect' ) |
| 2445 | + ); |
| 2446 | + |
| 2447 | + } else { |
| 2448 | + $content_actions['unprotect'] = array( |
| 2449 | + 'class' => ( $action == 'unprotect' ) ? 'selected' : false, |
| 2450 | + 'text' => wfMsg( 'unprotect' ), |
| 2451 | + 'href' => $this->mTitle->getLocalURL( 'action=unprotect' ) |
| 2452 | + ); |
| 2453 | + } |
| 2454 | + } |
| 2455 | + } else { |
| 2456 | + // article doesn't exist or is deleted |
| 2457 | + if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'deletedtext' ) ) { |
| 2458 | + $n = $this->mTitle->isDeleted(); |
| 2459 | + if( $n ) { |
| 2460 | + $undelTitle = SpecialPage::getTitleFor( 'Undelete' ); |
| 2461 | + $content_actions['undelete'] = array( |
| 2462 | + 'class' => false, |
| 2463 | + 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum( $n ) ), |
| 2464 | + 'href' => $undelTitle->getLocalURL( 'target=' . urlencode( $this->thispage ) ) |
| 2465 | + #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" ) |
| 2466 | + ); |
| 2467 | + } |
| 2468 | + } |
| 2469 | + |
| 2470 | + if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| 2471 | + if( !$this->mTitle->getRestrictions( 'create' ) ) { |
| 2472 | + $content_actions['protect'] = array( |
| 2473 | + 'class' => ( $action == 'protect' ) ? 'selected' : false, |
| 2474 | + 'text' => wfMsg( 'protect' ), |
| 2475 | + 'href' => $this->mTitle->getLocalURL( 'action=protect' ) |
| 2476 | + ); |
| 2477 | + |
| 2478 | + } else { |
| 2479 | + $content_actions['unprotect'] = array( |
| 2480 | + 'class' => ( $action == 'unprotect' ) ? 'selected' : false, |
| 2481 | + 'text' => wfMsg( 'unprotect' ), |
| 2482 | + 'href' => $this->mTitle->getLocalURL( 'action=unprotect' ) |
| 2483 | + ); |
| 2484 | + } |
| 2485 | + } |
| 2486 | + } |
| 2487 | + |
| 2488 | + wfProfileOut( __METHOD__ . '-live' ); |
| 2489 | + |
| 2490 | + if( $wgUser->isLoggedIn() ) { |
| 2491 | + if( !$this->mTitle->userIsWatching() ) { |
| 2492 | + $content_actions['watch'] = array( |
| 2493 | + 'class' => ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false, |
| 2494 | + 'text' => wfMsg( 'watch' ), |
| 2495 | + 'href' => $this->mTitle->getLocalURL( 'action=watch' ) |
| 2496 | + ); |
| 2497 | + } else { |
| 2498 | + $content_actions['unwatch'] = array( |
| 2499 | + 'class' => ( $action == 'unwatch' || $action == 'watch' ) ? 'selected' : false, |
| 2500 | + 'text' => wfMsg( 'unwatch' ), |
| 2501 | + 'href' => $this->mTitle->getLocalURL( 'action=unwatch' ) |
| 2502 | + ); |
| 2503 | + } |
| 2504 | + } |
| 2505 | + |
| 2506 | + |
| 2507 | + wfRunHooks( 'SkinTemplateTabs', array( $this, &$content_actions ) ); |
| 2508 | + } else { |
| 2509 | + /* show special page tab */ |
| 2510 | + |
| 2511 | + $content_actions[$this->mTitle->getNamespaceKey()] = array( |
| 2512 | + 'class' => 'selected', |
| 2513 | + 'text' => wfMsg( 'nstab-special' ), |
| 2514 | + 'href' => $wgRequest->getRequestURL(), // @bug 2457, 2510 |
| 2515 | + ); |
| 2516 | + |
| 2517 | + wfRunHooks( 'SkinTemplateBuildContentActionUrlsAfterSpecialPage', array( $this, &$content_actions ) ); |
| 2518 | + } |
| 2519 | + |
| 2520 | + /* show links to different language variants */ |
| 2521 | + global $wgDisableLangConversion; |
| 2522 | + $variants = $wgContLang->getVariants(); |
| 2523 | + if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
| 2524 | + $preferred = $wgContLang->getPreferredVariant(); |
| 2525 | + $vcount = 0; |
| 2526 | + foreach( $variants as $code ) { |
| 2527 | + $varname = $wgContLang->getVariantname( $code ); |
| 2528 | + if( $varname == 'disable' ) { |
| 2529 | + continue; |
| 2530 | + } |
| 2531 | + $selected = ( $code == $preferred ) ? 'selected' : false; |
| 2532 | + $content_actions['varlang-' . $vcount] = array( |
| 2533 | + 'class' => $selected, |
| 2534 | + 'text' => $varname, |
| 2535 | + 'href' => $this->mTitle->getLocalURL( '', $code ) |
| 2536 | + ); |
| 2537 | + $vcount++; |
| 2538 | + } |
| 2539 | + } |
| 2540 | + |
| 2541 | + wfRunHooks( 'SkinTemplateContentActions', array( &$content_actions ) ); |
| 2542 | + |
| 2543 | + wfProfileOut( __METHOD__ ); |
| 2544 | + return $content_actions; |
| 2545 | + } |
| 2546 | + |
| 2547 | + /** |
| 2548 | + * Renders the content action tabs (edit, history, move, watch etc.) |
| 2549 | + * @return HTML |
| 2550 | + */ |
| 2551 | + function renderContentActions() { |
| 2552 | + $s = ''; |
| 2553 | + foreach( $this->buildContentActionUrls() as $key => $tab ) { |
| 2554 | + $s .= '<li id="' . Sanitizer::escapeId( "ca-$key" ) . '"'; |
| 2555 | + if( $tab['class'] ) { |
| 2556 | + $s .= ' class="' . htmlspecialchars( $tab['class'] ) . '"'; |
| 2557 | + } |
| 2558 | + $s .= '><a href="' . htmlspecialchars( $tab['href'] ) . '"'; |
| 2559 | + # We don't want to give the watch tab an accesskey if the |
| 2560 | + # page is being edited, because that conflicts with the |
| 2561 | + # accesskey on the watch checkbox. We also don't want to |
| 2562 | + # give the edit tab an accesskey, because that's fairly su- |
| 2563 | + # perfluous and conflicts with an accesskey (Ctrl-E) often |
| 2564 | + # used for editing in Safari. |
| 2565 | + global $wgRequest; |
| 2566 | + $action = $wgRequest->getText( 'action' ); |
| 2567 | + if( |
| 2568 | + in_array( $action, array( 'edit', 'submit' ) ) && |
| 2569 | + in_array( $key, array( 'edit', 'watch', 'unwatch' ) ) ) |
| 2570 | + { |
| 2571 | + $s .= $this->tooltip( "ca-$key" ); |
| 2572 | + } else { |
| 2573 | + $s .= $this->tooltipAndAccesskey( "ca-$key" ); |
| 2574 | + } |
| 2575 | + $s .= '>' . htmlspecialchars( $tab['text'] ) . '</a></li>' . "\n"; |
| 2576 | + } |
| 2577 | + return $s; |
| 2578 | + } |
| 2579 | + |
| 2580 | + /** |
| 2581 | + * Build array of URLs for personal toolbar |
| 2582 | + * @return array |
| 2583 | + */ |
| 2584 | + function buildPersonalUrls() { |
| 2585 | + global $wgOut, $wgRequest, $wgUser; |
| 2586 | + |
| 2587 | + $title = $wgOut->getTitle(); |
| 2588 | + $pageurl = $title->getLocalURL(); |
| 2589 | + wfProfileIn( __METHOD__ ); |
| 2590 | + |
| 2591 | + if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) { |
| 2592 | + $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage ); |
| 2593 | + } else { |
| 2594 | + # This won't be used in the standard skins, but we define it to preserve the interface |
| 2595 | + # To save time, we check for existence |
| 2596 | + $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage ); |
| 2597 | + } |
| 2598 | + /* set up the default links for the personal toolbar */ |
| 2599 | + $personal_urls = array(); |
| 2600 | + $page = $wgRequest->getVal( 'returnto', $this->mTitle->getPrefixedURL() ); |
| 2601 | + $query = array(); |
| 2602 | + if ( !$wgRequest->wasPosted() ) { |
| 2603 | + $query = $wgRequest->getValues(); |
| 2604 | + unset( $query['title'] ); |
| 2605 | + unset( $query['returnto'] ); |
| 2606 | + unset( $query['returntoquery'] ); |
| 2607 | + } |
| 2608 | + $query = $wgRequest->getVal( 'returntoquery', wfUrlencode( wfArrayToCGI( $query ) ) ); |
| 2609 | + $returnto = "returnto=$page"; |
| 2610 | + if( $query != '' ) { |
| 2611 | + $returnto .= "&returntoquery=$query"; |
| 2612 | + } |
| 2613 | + if( $wgUser->isLoggedIn() ) { |
| 2614 | + $personal_urls['userpage'] = array( |
| 2615 | + 'text' => $wgUser->getName(), |
| 2616 | + 'href' => &$this->userpageUrlDetails['href'], |
| 2617 | + 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
| 2618 | + 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ) |
| 2619 | + ); |
| 2620 | + $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
| 2621 | + $personal_urls['mytalk'] = array( |
| 2622 | + 'text' => wfMsg( 'mytalk' ), |
| 2623 | + 'href' => &$usertalkUrlDetails['href'], |
| 2624 | + 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
| 2625 | + 'active' => ( $usertalkUrlDetails['href'] == $pageurl ) |
| 2626 | + ); |
| 2627 | + $href = self::makeSpecialUrl( 'Preferences' ); |
| 2628 | + $personal_urls['preferences'] = array( |
| 2629 | + 'text' => wfMsg( 'mypreferences' ), |
| 2630 | + 'href' => $href, |
| 2631 | + 'active' => ( $href == $pageurl ) |
| 2632 | + ); |
| 2633 | + $href = self::makeSpecialUrl( 'Watchlist' ); |
| 2634 | + $personal_urls['watchlist'] = array( |
| 2635 | + 'text' => wfMsg( 'mywatchlist' ), |
| 2636 | + 'href' => $href, |
| 2637 | + 'active' => ( $href == $pageurl ) |
| 2638 | + ); |
| 2639 | + |
| 2640 | + # We need to do an explicit check for Special:Contributions, as we |
| 2641 | + # have to match both the title, and the target (which could come |
| 2642 | + # from request values or be specified in "sub page" form. The plot |
| 2643 | + # thickens, because $wgTitle is altered for special pages, so doesn't |
| 2644 | + # contain the original alias-with-subpage. |
| 2645 | + $origTitle = Title::newFromText( $wgRequest->getText( 'title' ) ); |
| 2646 | + if( $origTitle instanceof Title && $origTitle->getNamespace() == NS_SPECIAL ) { |
| 2647 | + list( $spName, $spPar ) = |
| 2648 | + SpecialPage::resolveAliasWithSubpage( $origTitle->getText() ); |
| 2649 | + $active = $spName == 'Contributions' |
| 2650 | + && ( ( $spPar && $spPar == $wgUser->getName() ) |
| 2651 | + || $wgRequest->getText( 'target' ) == $wgUser->getName() ); |
| 2652 | + } else { |
| 2653 | + $active = false; |
| 2654 | + } |
| 2655 | + |
| 2656 | + $href = self::makeSpecialUrlSubpage( 'Contributions', $wgUser->getName() ); |
| 2657 | + $personal_urls['mycontris'] = array( |
| 2658 | + 'text' => wfMsg( 'mycontris' ), |
| 2659 | + 'href' => $href, |
| 2660 | + 'active' => $active |
| 2661 | + ); |
| 2662 | + $personal_urls['logout'] = array( |
| 2663 | + 'text' => wfMsg( 'userlogout' ), |
| 2664 | + 'href' => self::makeSpecialUrl( 'Userlogout', |
| 2665 | + $title->isSpecial( 'Preferences' ) ? '' : $returnto |
| 2666 | + ), |
| 2667 | + 'active' => false |
| 2668 | + ); |
| 2669 | + } else { |
| 2670 | + global $wgUser; |
| 2671 | + $loginlink = $wgUser->isAllowed( 'createaccount' ) |
| 2672 | + ? 'nav-login-createaccount' |
| 2673 | + : 'login'; |
| 2674 | + if( $this->showIPinHeader() ) { |
| 2675 | + $href = &$this->userpageUrlDetails['href']; |
| 2676 | + $personal_urls['anonuserpage'] = array( |
| 2677 | + 'text' => $wgUser->getName(), |
| 2678 | + 'href' => $href, |
| 2679 | + 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
| 2680 | + 'active' => ( $pageurl == $href ) |
| 2681 | + ); |
| 2682 | + $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
| 2683 | + $href = &$usertalkUrlDetails['href']; |
| 2684 | + $personal_urls['anontalk'] = array( |
| 2685 | + 'text' => wfMsg( 'anontalk' ), |
| 2686 | + 'href' => $href, |
| 2687 | + 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
| 2688 | + 'active' => ( $pageurl == $href ) |
| 2689 | + ); |
| 2690 | + $personal_urls['anonlogin'] = array( |
| 2691 | + 'text' => wfMsg( $loginlink ), |
| 2692 | + 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
| 2693 | + 'active' => $title->isSpecial( 'Userlogin' ) |
| 2694 | + ); |
| 2695 | + } else { |
| 2696 | + $personal_urls['login'] = array( |
| 2697 | + 'text' => wfMsg( $loginlink ), |
| 2698 | + 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
| 2699 | + 'active' => $title->isSpecial( 'Userlogin' ) |
| 2700 | + ); |
| 2701 | + } |
| 2702 | + } |
| 2703 | + |
| 2704 | + wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) ); |
| 2705 | + wfProfileOut( __METHOD__ ); |
| 2706 | + return $personal_urls; |
| 2707 | + } |
| 2708 | + |
| 2709 | + /** |
| 2710 | + * Renders the items in the personal toolbar (links to user page, |
| 2711 | + * talk page, contributions list, watchlist etc.) |
| 2712 | + * @return HTML |
| 2713 | + */ |
| 2714 | + function renderPersonalTools() { |
| 2715 | + $s = ''; |
| 2716 | + foreach( $this->buildPersonalUrls() as $key => $item ) { |
| 2717 | + $s .= '<li id="' . Sanitizer::escapeId( "pt-$key" ) . '"'; |
| 2718 | + if ( $item['active'] ) { |
| 2719 | + $s .= 'class="active"'; |
| 2720 | + } |
| 2721 | + $s .= '><a href="' . htmlspecialchars( $item['href'] ) . '"' . |
| 2722 | + $this->tooltipAndAccesskey( 'pt-' . $key ); |
| 2723 | + if( !empty( $item['class'] ) ) { |
| 2724 | + $s .= ' class="' . htmlspecialchars( $item['class'] ) . '"'; |
| 2725 | + } |
| 2726 | + $s .= '>' . htmlspecialchars( $item['text'] ) . '</a></li>'; |
| 2727 | + } |
| 2728 | + return $s; |
| 2729 | + } |
| 2730 | + |
| 2731 | + function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) { |
| 2732 | + $classes = array(); |
| 2733 | + if( $selected ) { |
| 2734 | + $classes[] = 'selected'; |
| 2735 | + } |
| 2736 | + if( $checkEdit && !$title->isKnown() ) { |
| 2737 | + $classes[] = 'new'; |
| 2738 | + $query = 'action=edit&redlink=1'; |
| 2739 | + } |
| 2740 | + |
| 2741 | + $text = wfMsg( $message ); |
| 2742 | + if ( wfEmptyMsg( $message, $text ) ) { |
| 2743 | + global $wgContLang; |
| 2744 | + $text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) ); |
| 2745 | + } |
| 2746 | + |
| 2747 | + $result = array(); |
| 2748 | + if( !wfRunHooks( 'SkinTemplateTabAction', array( $this, $title, |
| 2749 | + $message, $selected, $checkEdit, &$classes, &$query, &$text, |
| 2750 | + &$result ) ) |
| 2751 | + ) |
| 2752 | + { |
| 2753 | + return $result; |
| 2754 | + } |
| 2755 | + |
| 2756 | + return array( |
| 2757 | + 'class' => implode( ' ', $classes ), |
| 2758 | + 'text' => $text, |
| 2759 | + 'href' => $title->getLocalURL( $query ) |
| 2760 | + ); |
| 2761 | + } |
| 2762 | + |
| 2763 | + function makeTalkUrlDetails( $name, $urlaction = '' ) { |
| 2764 | + $title = Title::newFromText( $name ); |
| 2765 | + if( !is_object( $title ) ) { |
| 2766 | + throw new MWException( __METHOD__ . " given invalid pagename $name" ); |
| 2767 | + } |
| 2768 | + $title = $title->getTalkPage(); |
| 2769 | + self::checkTitle( $title, $name ); |
| 2770 | + return array( |
| 2771 | + 'href' => $title->getLocalURL( $urlaction ), |
| 2772 | + 'exists' => $title->getArticleID() != 0 ? true : false |
| 2773 | + ); |
| 2774 | + } |
| 2775 | + |
| 2776 | + /** |
| 2777 | + * Users can have their language set differently than the |
| 2778 | + * content of the wiki. For these users, tell the web browser |
| 2779 | + * that interface elements are in a different language. |
| 2780 | + * @return array |
| 2781 | + */ |
| 2782 | + function getAttributes() { |
| 2783 | + global $wgLang, $wgContLang; |
| 2784 | + |
| 2785 | + $attrs = ''; |
| 2786 | + $specialPageAttributes = ''; |
| 2787 | + $lang = $wgLang->getCode(); |
| 2788 | + $dir = $wgLang->getDir(); |
| 2789 | + |
| 2790 | + if ( $lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir() ) { |
| 2791 | + $attrs = " lang='$lang' xml:lang='$lang' dir='$dir'"; |
| 2792 | + |
| 2793 | + // The content of SpecialPages should be presented in the |
| 2794 | + // user's language. Content of regular pages should not be touched. |
| 2795 | + if( $this->mTitle->isSpecialPage() ) { |
| 2796 | + $specialPageAttributes = $attrs; |
| 2797 | + } |
| 2798 | + } |
| 2799 | + |
| 2800 | + return array( $attrs, $specialPageAttributes ); |
| 2801 | + } |
| 2802 | + |
| 2803 | + /** |
| 2804 | + * Builds the array of interlanguage links for getInterlanguageLinksBox(). |
| 2805 | + * @return array |
| 2806 | + */ |
| 2807 | + function fetchInterlanguageLinks() { |
| 2808 | + global $wgHideInterlanguageLinks, $wgOut, $wgContLang; |
| 2809 | + |
| 2810 | + # Language links |
| 2811 | + $language_urls = array(); |
| 2812 | + |
| 2813 | + if ( !$wgHideInterlanguageLinks ) { |
| 2814 | + foreach( $wgOut->getLanguageLinks() as $l ) { |
| 2815 | + $tmp = explode( ':', $l, 2 ); |
| 2816 | + $class = 'interwiki-' . $tmp[0]; |
| 2817 | + unset( $tmp ); |
| 2818 | + $nt = Title::newFromText( $l ); |
| 2819 | + if ( $nt ) { |
| 2820 | + $langName = $wgContLang->getLanguageName( $nt->getInterwiki() ); |
| 2821 | + $language_urls[] = array( |
| 2822 | + 'href' => $nt->getFullURL(), |
| 2823 | + 'text' => ( $langName != '' ? $langName : $l ), |
| 2824 | + 'class' => $class |
| 2825 | + ); |
| 2826 | + } |
| 2827 | + } |
| 2828 | + } |
| 2829 | + return $language_urls; |
| 2830 | + } |
| 2831 | + |
| 2832 | + /** |
| 2833 | + * Renders links (permalink, What links here, etc.) for the toolbox. |
| 2834 | + * @return HTML |
| 2835 | + */ |
| 2836 | + function renderToolboxLinks() { |
| 2837 | + global $wgOut; |
| 2838 | + |
| 2839 | + $navUrls = $this->buildNavUrls(); |
| 2840 | + $s = ''; |
| 2841 | + |
| 2842 | + if( $this->mTitle->getNamespace() != NS_SPECIAL ) { |
| 2843 | + $s .= '<li id="t-whatlinkshere"> |
| 2844 | + <a href="' . |
| 2845 | + htmlspecialchars( $navUrls['whatlinkshere']['href'] ) . |
| 2846 | + '"' . $this->tooltipAndAccesskey( 't-whatlinkshere' ) . '>' |
| 2847 | + . wfMsg( 'whatlinkshere' ) . |
| 2848 | + '</a> |
| 2849 | + </li>'; |
| 2850 | + if( $navUrls['recentchangeslinked'] ) { |
| 2851 | + $s .= '<li id="t-recentchangeslinked"> |
| 2852 | + <a href="' . |
| 2853 | + htmlspecialchars( $navUrls['recentchangeslinked']['href'] ) . |
| 2854 | + '"' . $this->tooltipAndAccesskey( 't-recentchangeslinked' ) . '>' |
| 2855 | + . wfMsg( 'recentchangeslinked-toolbox' ) . |
| 2856 | + '</a> |
| 2857 | + </li>'; |
| 2858 | + } |
| 2859 | + } |
| 2860 | + |
| 2861 | + if( isset( $navUrls['trackbacklink'] ) && $navUrls['trackbacklink'] ) { |
| 2862 | + $s .= '<li id="t-trackbacklink"><a href="' . |
| 2863 | + htmlspecialchars( $navUrls['trackbacklink']['href'] ) . |
| 2864 | + '"' . $this->tooltipAndAccesskey( 't-trackbacklink' ) . '>' |
| 2865 | + . wfMsg( 'trackbacklink' ) . |
| 2866 | + '</a> |
| 2867 | + </li>'; |
| 2868 | + } |
| 2869 | + |
| 2870 | + if( $wgOut->isSyndicated() ) { |
| 2871 | + $feeds = array(); |
| 2872 | + foreach( $wgOut->getSyndicationLinks() as $format => $link ) { |
| 2873 | + $feeds[$format] = array( |
| 2874 | + 'text' => wfMsg( "feed-$format" ), |
| 2875 | + 'href' => $link |
| 2876 | + ); |
| 2877 | + } |
| 2878 | + if( $feeds ) { |
| 2879 | + $s .= '<li id="feedlinks">'; |
| 2880 | + foreach( $feeds as $key => $feed ) { |
| 2881 | + $s .= '<a id="' . Sanitizer::escapeId( "feed-$key" ) . |
| 2882 | + '" href="' . htmlspecialchars( $feed['href'] ) . |
| 2883 | + '" rel="alternate" type="application/' . $key . '+xml"' . |
| 2884 | + ' class="feedlink"' . $this->tooltipAndAccesskey( 'feed-' . $key ) . '>' . |
| 2885 | + htmlspecialchars( $feed['text'] ) . '</a> '; |
| 2886 | + } |
| 2887 | + $s .= '</li>'; |
| 2888 | + } |
| 2889 | + } |
| 2890 | + |
| 2891 | + $specials = array( |
| 2892 | + 'contributions', 'log', 'blockip', |
| 2893 | + 'emailuser', 'upload', 'specialpages' |
| 2894 | + ); |
| 2895 | + foreach( $specials as $special ) { |
| 2896 | + if( $navUrls[$special] ) { |
| 2897 | + $s .= '<li id="t-' . $special . '"> |
| 2898 | + <a href="' . htmlspecialchars( $navUrls[$special]['href'] ) . |
| 2899 | + '"' . $this->tooltipAndAccesskey( 't-' . $special ) . '>' |
| 2900 | + . wfMsg( $special ) . '</a> |
| 2901 | + </li>'; |
| 2902 | + } |
| 2903 | + } |
| 2904 | + |
| 2905 | + if( !empty( $navUrls['print']['href'] ) ) { |
| 2906 | + $s .= '<li id="t-print"><a href="' . |
| 2907 | + htmlspecialchars( $navUrls['print']['href'] ) . '" rel="alternate"' . |
| 2908 | + $this->tooltipAndAccesskey( 't-print' ) . '>' |
| 2909 | + . wfMsg( 'printableversion' ) . '</a> |
| 2910 | + </li>'; |
| 2911 | + } |
| 2912 | + |
| 2913 | + if( !empty( $navUrls['permalink']['href'] ) ) { |
| 2914 | + $s .= '<li id="t-permalink"><a href="' . |
| 2915 | + htmlspecialchars( $navUrls['permalink']['href'] ) . '"' . |
| 2916 | + $this->tooltipAndAccesskey( 't-permalink' ) . '>' |
| 2917 | + . wfMsg( 'permalink' ) . '</a></li>'; |
| 2918 | + } elseif ( $navUrls['permalink']['href'] === '' ) { |
| 2919 | + $s .= '<li id="t-ispermalink"' . $this->tooltip( 't-ispermalink' ) . '>' |
| 2920 | + . wfMsg( 'permalink' ) . |
| 2921 | + '</li>'; |
| 2922 | + } |
| 2923 | + |
| 2924 | + wfRunHooks( 'MonoBookTemplateToolboxEnd', array( $this, &$s ) ); |
| 2925 | + wfRunHooks( 'SkinTemplateToolboxEnd', array( $this, &$s ) ); // For backwards compatibility only. |
| 2926 | + |
| 2927 | + return $s; |
| 2928 | + } |
| 2929 | + |
| 2930 | + /** |
| 2931 | + * This function renders the toolbox. |
| 2932 | + * @return HTML |
| 2933 | + */ |
| 2934 | + function toolbox() { |
| 2935 | + $s = '<div class="portlet" id="p-tb"> |
| 2936 | + <h5>' . wfMsg( 'toolbox' ) . '</h5> |
| 2937 | + <div class="pBody"> |
| 2938 | + <ul>' . $this->renderToolboxLinks() . |
| 2939 | + '</ul> |
| 2940 | + </div> |
| 2941 | + </div>'; |
| 2942 | + return $s; |
| 2943 | + } |
| 2944 | + |
| 2945 | + /** |
| 2946 | + * Prints a custom box (a box that is not the search box, toolbox or |
| 2947 | + * interlanguage links box) for the sidebar. |
| 2948 | + * @return HTML |
| 2949 | + */ |
| 2950 | + function customBox( $bar, $cont ) { |
| 2951 | + $out = wfMsg( $bar ); |
| 2952 | + if ( wfEmptyMsg( $bar, $out ) ) { |
| 2953 | + $header = htmlspecialchars( $bar ); |
| 2954 | + } else { |
| 2955 | + $header = htmlspecialchars( $out ); |
| 2956 | + } |
| 2957 | + $s = '<div class="generated-sidebar portlet" id="' . |
| 2958 | + Sanitizer::escapeId( "p-$bar" ) . '"' . |
| 2959 | + $this->tooltip( 'p-' . $bar ) . '> |
| 2960 | + <h5>' . $header . '</h5> |
| 2961 | + <div class="pBody">'; |
| 2962 | + if ( is_array( $cont ) ) { |
| 2963 | + $s .= '<ul>'; |
| 2964 | + foreach( $cont as $key => $val ) { |
| 2965 | + $s .= '<li id="' . Sanitizer::escapeId( $val['id'] ) . '"'; |
| 2966 | + if ( $val['active'] ) { |
| 2967 | + $s .= ' class="active"'; |
| 2968 | + } |
| 2969 | + $s .= '><a href="' . htmlspecialchars( $val['href'] ) . '"' . |
| 2970 | + $this->tooltipAndAccesskey( $val['id'] ) . '>' . |
| 2971 | + htmlspecialchars( $val['text'] ) . |
| 2972 | + '</a> |
| 2973 | + </li>'; |
| 2974 | + } |
| 2975 | + $s .= '</ul>'; |
| 2976 | + } else { |
| 2977 | + # allow raw HTML block to be defined by extensions |
| 2978 | + $s .= $cont; |
| 2979 | + } |
| 2980 | + $s .= '</div> |
| 2981 | + </div>'; |
| 2982 | + return $s; |
| 2983 | + } |
| 2984 | + |
| 2985 | + /** |
| 2986 | + * Gets the search box UI (most of it anyway). |
| 2987 | + * Actual form is constructed by searchForm(). |
| 2988 | + * @return HTML |
| 2989 | + */ |
| 2990 | + function searchBox() { |
| 2991 | + $s = '<div id="p-search" class="portlet"> |
| 2992 | + <h5><label for="searchInput">' . wfMsg( 'search' ) . '</label></h5> |
| 2993 | + <div id="searchBody" class="pBody">' |
| 2994 | + . $this->searchForm() . |
| 2995 | + '</div> |
| 2996 | + </div>'; |
| 2997 | + return $s; |
| 2998 | + } |
| 2999 | + |
| 3000 | + /** |
| 3001 | + * Builds the sidebar, along with all the related boxes (search box, |
| 3002 | + * interlanguage links box and toolbox). |
| 3003 | + * @return HTML |
| 3004 | + */ |
| 3005 | + function doSidebar() { |
| 3006 | + $s = ''; |
| 3007 | + $sidebar = $this->buildSidebar(); |
| 3008 | + if ( !isset( $sidebar['SEARCH'] ) ) { |
| 3009 | + $sidebar['SEARCH'] = true; |
| 3010 | + } |
| 3011 | + if ( !isset( $sidebar['TOOLBOX'] ) ) { |
| 3012 | + $sidebar['TOOLBOX'] = true; |
| 3013 | + } |
| 3014 | + if ( !isset( $sidebar['LANGUAGES'] ) ) { |
| 3015 | + $sidebar['LANGUAGES'] = true; |
| 3016 | + } |
| 3017 | + foreach ( $sidebar as $boxName => $cont ) { |
| 3018 | + if ( $boxName == 'SEARCH' ) { |
| 3019 | + $s .= $this->searchBox(); |
| 3020 | + } elseif ( $boxName == 'TOOLBOX' ) { |
| 3021 | + $s .= $this->toolbox(); |
| 3022 | + } elseif ( $boxName == 'LANGUAGES' ) { |
| 3023 | + $s .= $this->getInterlanguageLinksBox(); |
| 3024 | + } else { |
| 3025 | + $s .= $this->customBox( $boxName, $cont ); |
| 3026 | + } |
| 3027 | + } |
| 3028 | + wfRunHooks( 'SkinAfterSidebar', array( $this, &$s ) ); |
| 3029 | + return $s; |
| 3030 | + } |
| 3031 | + |
| 3032 | + /** |
| 3033 | + * Renders the footer - powered by and copyright icons and other stuff. |
| 3034 | + * @return HTML |
| 3035 | + */ |
| 3036 | + function footer() { |
| 3037 | + $attribs = $this->getAttributes(); |
| 3038 | + $s = "\n" . '<div id="footer"' . $attribs[0] . '>'; |
| 3039 | + |
| 3040 | + if( $this->getPoweredBy() ) { |
| 3041 | + $s .= "\n" . '<div id="f-poweredbyico">' |
| 3042 | + . $this->getPoweredBy() . |
| 3043 | + '</div>' . "\n"; |
| 3044 | + } |
| 3045 | + |
| 3046 | + if( $this->getCopyrightIcon() ) { |
| 3047 | + $s .= '<div id="f-copyrightico">' |
| 3048 | + . $this->getCopyrightIcon() . |
| 3049 | + '</div>' . "\n"; |
| 3050 | + } |
| 3051 | + |
| 3052 | + // Generate additional footer links |
| 3053 | + $s .= '<ul id="f-list">'; |
| 3054 | + // Special pages cannot have authors, watchers etc. so don't even try! |
| 3055 | + global $wgRequest; |
| 3056 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 3057 | + if ( $this->mTitle->getNamespace() != NS_SPECIAL && $action !== 'edit' ) { |
| 3058 | + $s .= '<li id="lastmod">' . $this->lastModified() . '</li> |
| 3059 | + <li id="viewcount">' . $this->getViewCount() . '</li> |
| 3060 | + <li id="numberofwatchingusers">' . $this->getNumberOfWatchingUsers() . '</li> |
| 3061 | + <li id="credits">' . $this->getCredits() . '</li> |
| 3062 | + <li id="copyrights">' . $this->getCopyright() . '</li>' . "\n"; |
| 3063 | + } |
| 3064 | + $s .= '<li id="privacy">' . $this->privacyLink() . '</li> |
| 3065 | + <li id="about">' . $this->aboutLink() . '</li> |
| 3066 | + <li id="disclaimer">' . $this->disclaimerLink() . '</li> |
| 3067 | + </ul>' . "\n"; |
| 3068 | + $s .= '</div>' . "\n"; |
| 3069 | + return $s; |
| 3070 | + } |
| 3071 | + |
| 3072 | + function getCredits() { |
| 3073 | + global $wgArticle, $wgOut, $wgMaxCredits, $wgRequest, $wgShowCreditsIfMax; |
| 3074 | + |
| 3075 | + $s = ''; |
| 3076 | + $oldid = $wgRequest->getVal( 'oldid' ); |
| 3077 | + $diff = $wgRequest->getVal( 'diff' ); |
| 3078 | + |
| 3079 | + if ( |
| 3080 | + $wgOut->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) && |
| 3081 | + $wgArticle && 0 != $wgArticle->getID() |
| 3082 | + ) |
| 3083 | + { |
| 3084 | + if( $wgMaxCredits != 0 ) { |
| 3085 | + $s = ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax ); |
| 3086 | + } |
| 3087 | + } |
| 3088 | + |
| 3089 | + return $s; |
| 3090 | + } |
| 3091 | + |
| 3092 | + /** |
| 3093 | + * If counters are enabled ($wgDisableCounters is NOT true), gets the |
| 3094 | + * number of how many times this page has been viewed. Obviously works only |
| 3095 | + * for existing content pages. |
| 3096 | + * @return string |
| 3097 | + */ |
| 3098 | + function getViewCount() { |
| 3099 | + global $wgArticle, $wgOut, $wgRequest; |
| 3100 | + |
| 3101 | + $s = ''; |
| 3102 | + $oldid = $wgRequest->getVal( 'oldid' ); |
| 3103 | + $diff = $wgRequest->getVal( 'diff' ); |
| 3104 | + |
| 3105 | + if ( |
| 3106 | + $wgOut->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) && |
| 3107 | + $wgArticle && 0 != $wgArticle->getID() |
| 3108 | + ) |
| 3109 | + { |
| 3110 | + global $wgDisableCounters, $wgLang; |
| 3111 | + if ( !$wgDisableCounters ) { |
| 3112 | + $viewcount = $wgLang->formatNum( $wgArticle->getCount() ); |
| 3113 | + if ( $viewcount ) { |
| 3114 | + $s .= wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ); |
| 3115 | + } |
| 3116 | + } |
| 3117 | + } |
| 3118 | + return $s; |
| 3119 | + } |
| 3120 | + |
| 3121 | + function getNumberOfWatchingUsers() { |
| 3122 | + global $wgOut, $wgArticle, $wgRequest; |
| 3123 | + $s = ''; |
| 3124 | + |
| 3125 | + $oldid = $wgRequest->getVal( 'oldid' ); |
| 3126 | + $diff = $wgRequest->getVal( 'diff' ); |
| 3127 | + |
| 3128 | + if ( |
| 3129 | + $wgOut->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) && |
| 3130 | + $wgArticle && 0 != $wgArticle->getID() |
| 3131 | + ) |
| 3132 | + { |
| 3133 | + global $wgPageShowWatchingUsers, $wgLang; |
| 3134 | + if( $wgPageShowWatchingUsers ) { |
| 3135 | + $dbr = wfGetDB( DB_SLAVE ); |
| 3136 | + $res = $dbr->select( |
| 3137 | + 'watchlist', |
| 3138 | + array( 'COUNT(*) AS n' ), |
| 3139 | + array( |
| 3140 | + 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), |
| 3141 | + 'wl_namespace' => $this->mTitle->getNamespace() |
| 3142 | + ), |
| 3143 | + __METHOD__ |
| 3144 | + ); |
| 3145 | + $x = $dbr->fetchObject( $res ); |
| 3146 | + $numberofwatchingusers = $x->n; |
| 3147 | + if( $numberofwatchingusers > 0 ) { |
| 3148 | + $s .= wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ), |
| 3149 | + $wgLang->formatNum( $numberofwatchingusers ) ); |
| 3150 | + } |
| 3151 | + } |
| 3152 | + } |
| 3153 | + return $s; |
| 3154 | + } |
| 3155 | + |
| 3156 | + /** |
| 3157 | + * Gets the interlanguage links box. |
| 3158 | + * @return HTML |
| 3159 | + */ |
| 3160 | + function getInterlanguageLinksBox() { |
| 3161 | + return ''; |
| 3162 | + } |
| 3163 | + |
| 3164 | + /** |
| 3165 | + * Gets content action tabs (edit, move, history, watch...). |
| 3166 | + * @return HTML |
| 3167 | + */ |
| 3168 | + function getContentActions() { |
| 3169 | + return ''; |
| 3170 | + } |
| 3171 | + |
| 3172 | + /** |
| 3173 | + * Builds personal tools (links to own user/talk pages, contribs, etc.) |
| 3174 | + * @return HTML |
| 3175 | + */ |
| 3176 | + function getPersonalTools() { |
| 3177 | + return ''; |
| 3178 | + } |
| 3179 | + |
| 3180 | + /** |
| 3181 | + * Gets the logo portlet. |
| 3182 | + * @return HTML |
| 3183 | + */ |
| 3184 | + function getLogoPortlet() { |
| 3185 | + return ''; |
| 3186 | + } |
| 3187 | + |
2166 | 3188 | } |