3 * Copyright (c) 2011-2012 Francesco Siddi (fsiddi.com), Luca Bonavita (mindrones.com)
4 * Copyright (c) 2015 Marcin Cieślak (saper.info)
6 * This file is part of Naiad Skin for Mediawiki:
7 * http://wiki.blender.org/index.php/Meta:Skins/Naiad/Mediawiki
9 * Naiad is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * Naiad is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Naiad. If not, see <http://www.gnu.org/licenses/>.
25 * Inherit main code from SkinTemplate, set the CSS and template filter.
28 class SkinNaiad
extends SkinTemplate
{
30 var $skinname = 'naiad', $stylename = 'naiad',
31 $template = 'NaiadTemplate', $useHeadElement = true;
33 public function initPage( OutputPage
$out ) {
34 parent
::initPage( $out );
35 $out->addModules( 'skins.naiad.js' );
36 $out->addModuleStyles( 'skins.naiad.css' );
39 * Add CSS via ResourceLoader
41 * @param $out OutputPage
43 function setupSkinUserCss( OutputPage
$out ) {
44 parent
::setupSkinUserCss( $out );
53 class NaiadTemplate
extends BaseTemplate
{
55 * Template filter callback for MonoBook skin.
56 * Takes an associative array of data set from a SkinTemplate-based
57 * class, and a wrapper for MediaWiki's localization database, and
58 * outputs a formatted page.
63 $skin = $this->getSkin();
64 $body = $this->data
['bodycontent'];
66 $skin_path = $this->data
['stylepath'].'/'.$this->data
['stylename'];
68 if ( method_exists( 'DeToc', 'RemoveToc' ) ) {
69 $new_body = DeToc
::RemoveToc($body, $extracted_toc);
71 wfDebugLog( 'naiad', 'DeToc extension not installed: leaving table of contents in-place' );
75 // Set blenderized defaults
76 global $wgLogo, $wgResourceBasePath;
77 if ( $wgLogo === "$wgResourceBasePath/resources/assets/wiki.png" ) {
78 wfDebugLog( 'naiad', "Default MediaWiki logo detected in $wgLogo, using Blender logo." );
79 $this->data
['logopath'] = $skin_path . '/images/blender_logo.png';
82 global $wgUser, $wgParser, $wgTitle;
83 if ( is_object( $wgParser ) ) $psr =& $wgParser; else $psr = new Parser
;
84 $parser_opt = ParserOptions
::newFromUser( $wgUser );
85 foreach ( array( 'NavTreeTopPages', 'NavTree', 'Series',
86 'Languages', 'NavigationArrows', 'SidebarBanner',
87 'SearchSeries', 'SearchLanguages' ) as $opt ) {
88 $value = wfMessage( $opt )->plain();
89 wfDebugLog( 'naiad', "$opt before hook: [" . var_export($value, true) . "]");
90 wfRunHooks( 'Naiad' . $opt, array( &$value ) );
91 wfDebugLog( 'naiad', "$opt after hook: [" . var_export($value, true) . "]");
92 $this->data
[$opt] = $psr->parse( $value, $wgTitle, $parser_opt, true, true )->getText();
95 // Suppress warnings to prevent notices about missing indexes in $this->data
99 $this->html( 'headelement' );
101 $sidebarkey = $this->data
['sidebar-key'] = wfMessage( 'naiad-sidebar-key' )->plain();
102 if ( !isset( $this->data
['sidebar'][$sidebarkey] ) ) {
103 wfDebugLog( 'naiad', "Define '$sidebarkey' section in [[MediaWiki:Sidebar]] to override Blender header navigation URLs." );
105 $ids = explode( '|', wfMessage('naiad-navigation')->plain() );
106 foreach( $ids as $id ) {
107 $headerdesc = explode( '|', wfMessage('naiad-navigation-' . $id )->plain(), 2 );
108 $headerdesc['id'] = $id;
109 $headerdesc['href'] = $headerdesc[0];
110 $headerdesc['text'] = $headerdesc[1];
111 array_push( $cont, $headerdesc );
113 $this->data
['sidebar'][$sidebarkey] = $cont;
117 <!-- START main page container
-->
118 <div id
="pagecontainer">
120 <!-- START subsection header
and subnav
-->
121 <div id
="headerWrapper">
122 <div
class="subnav boxheader">
123 <div id
="left_controls">
124 <a id
="logo" href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href']) ?>" title
="Go to Main Page">
125 <img src
="<?php echo( $this->data['logopath'] ); ?>" />
127 <ul
class="external_nav">
129 $cont=$this->data
['sidebar'][$this->data
['sidebar-key']];
130 foreach($cont as $key => $val) {
131 $items = explode( '|', $val['text'], 2 );
132 ?
> <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
133 if ( $val['active'] ) { ?
> class="active" <?php
}?
>>
134 <a href
="<?php echo htmlspecialchars($val['href']) ?>"<?php
135 if ( $items[1] ) { echo ' title="' . htmlspecialchars( trim($items[1]) ) . '"'; };
136 ?
>><?php
echo htmlspecialchars(trim($items[0])) ?
></a
>
141 <h1
class="title_link">
142 <?php
$this->data
['displaytitle']!=""?
$this->html('title'):$this->text('title') ?
>
146 $pitems=$this->data
['personal_urls'];
147 $us = array_shift($pitems);
148 $lo = array_pop($pitems);
149 array_unshift($pitems,$us);
150 if($lo) { array_push($pitems,$lo); }
151 $lo['text']=preg_replace('/\s*\/.+$/','',$lo['text']);
153 <span
class="right_controls">
155 <?php
if(sizeof($pitems)>1) { # if logged-in ?>
156 <!-- (<a href
="<?php echo htmlspecialchars($lo['href']) ?>"><?php
echo htmlspecialchars($lo['text']) ?
></a
>)-->
157 <div id
="extras_one" class="dd_item">
158 <div
class="button grey"><p
><?php
echo htmlspecialchars($us['text']) ?
></p
></div
>
159 <div
class="dd_menu extras_one">
160 <?php
array_shift($pitems); ?
>
162 <li
><a
class="userid" href
="<?php echo htmlspecialchars($us['href']) ?>"><?php
echo htmlspecialchars($us['text']) ?
></a
></li
>
164 foreach($pitems as $key => $item) { ?
>
165 <li id
="pt-<?php echo Sanitizer::escapeId($key) ?>"<?php
166 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
167 echo htmlspecialchars($item['href']) ?>"<?php
168 if(!empty($item['class'])) { ?
> class="<?php
169 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
170 echo htmlspecialchars($item['text']) ?
></a
></li
>
178 <a
class="userid" href
="<?php echo htmlspecialchars($us['href']) ?>"><?php
echo htmlspecialchars($us['text']) ?
></a
>
184 <div id
="p-cactions" class="subnav sublevel2">
185 <div id
="contentSub"><?php
$this->html('subtitle') ?
></div
>
187 <div id
="dd_selectors">
188 <?php
print $this->data
['Series'];?
>
189 <?php
print $this->data
['Languages'];?
>
190 <?php
print $this->data
['NavigationArrows'];?
>
193 <ul id
="content_actions">
194 <?php
$i=0; foreach($this->data
['content_actions'] as $key => $tab) {?
>
195 <?php
if(preg_match("/nstab/i", $key) ||
$key == "talk" ||
$key == "edit" ||
$key == "history" ||
$key == "watch" ||
$key == "viewsource" ||
$key == "current"){?
>
196 <li id
="ca-<?php echo Sanitizer::escapeId($key) ?>"<?php
197 if($tab['class']) { ?
> class="<?php echo htmlspecialchars($tab['class']) ?>"<?php
}?
>>
198 <a href
="<?php echo htmlspecialchars($tab['href']) ?>"><?php
echo htmlspecialchars($tab['text']) ?
></a
>
204 <div id
="extras_two" class="dd_item">
205 <div
class="button grey"><p
>Page
</p
></div
>
206 <div
class="dd_menu extras_two">
209 <?php
$i=0; foreach($this->data
['content_actions'] as $key => $tab) {?
>
210 <?php
if(!(preg_match("/nstab/i", $key) ||
$key == "talk" ||
$key == "edit" ||
$key == "history" ||
$key == "watch" ||
$key == "viewsource" ||
$key == "current")){?
>
211 <li id
="ca-<?php echo Sanitizer::escapeId($key) ?>"<?php
212 if($tab['class']) { ?
> class="<?php echo htmlspecialchars($tab['class']) ?>"<?php
}?
>>
213 <a href
="<?php echo htmlspecialchars($tab['href']) ?>"><?php
echo htmlspecialchars($tab['text']) ?
></a
>
218 <?php
if($this->data
['notspecialpage']) { ?
>
219 <li id
="t-whatlinkshere">
220 <a href
="<?php echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])?>"><?php
$this->msg('whatlinkshere') ?
></a
>
222 <?php
if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
223 <li id
="t-recentchangeslinked">
224 <a href
="<?php echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])?>"><?php
$this->msg('recentchangeslinked') ?
></a
>
228 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
229 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
230 ?>"><?php
$this->msg('permalink') ?
></a
></li
><?php
231 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
232 <li id
="t-ispermalink"><?php
$this->msg('permalink') ?
></li
><?php
241 <!-- END subsection header
and subnav
-->
243 <div id
="globalWrapper">
244 <div id
="col-content">
246 <a name
="top" id
="top"></a
>
247 <div id
="bodyContent">
248 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
250 <?php
if($this->data
['undelete']) { ?
><div id
="contentSub2"><?php
$this->html('undelete') ?
></div
><?php
} ?
>
252 <?php
if($this->data
['showjumplinks']) { ?
><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
><?php
} ?
>
254 <!-- START content
-->
255 <?php
echo $new_body ?
>
256 <?php
if($this->data
['catlinks']) { ?
><div id
="catlinks"><?php
$this->html('catlinks') ?
></div
><?php
} ?
>
259 <div
class="visualClear"></div
>
264 <!-- START column left
-->
265 <div id
="column-one">
267 <?php
print $this->data
['NavTreeTopPages'];?
>
269 <div id
="scrollbar2">
271 <div
class="viewport">
272 <div
class="overview">
273 <!-- START navtree
-->
274 <?php
print $this->data
['NavTree']; ?
>
281 <!-- END column left
-->
283 <!-- START column right
-->
284 <div id
="column-two">
285 <div id
="scrollbar_right" class="nano">
288 <div
class="overview">
289 <!-- USER MESSAGES
-->
290 <?php
if($this->data
['newtalk'] ) { ?
><div
class="usermessage shade"><?php
$this->html('newtalk') ?
></div
><?php
} ?
>
292 <?php
if($this->data
['sitenotice']) { ?
><div id
="site_notice" class="sidebar_panel"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
294 <?php
print $this->data
['SidebarBanner'];?
>
296 <div id
="review_status_container"></div
>
297 <!-- FLAGGED REVS
-->
298 <div id
="flagged_revs_container" class="sidebar_panel">
299 <!-- dataAfterContent
-->
300 <?php
$this->html( 'dataAfterContent' ); ?
>
301 <!-- /dataAfterContent
-->
305 $extracted_toc=preg_replace('!<ul>!','<ul id="toc-ul">',$extracted_toc,1);
308 <div
class="port" id
="toc">
309 <?php
echo $extracted_toc; ?
>
317 <!-- END column right
-->
320 <div
class="visualClear"></div
>
321 <div id
="footer" class="boxbg">
324 <form action
="<?php $this->text('searchaction') ?>" id
="searchform">
325 <div id
="p-search-div">
326 <input onfocus
="if (this.value == 'quick search...') {this.value=''}; this.style.color='#000'" onblur
="if (this.value == '') {this.value = 'quick search...'; this.style.color='#999';}" value
="quick search..." id
="searchInput" name
="search" type
="text" autocomplete
="on" <?php
327 if( isset( $this->data
['search'] ) ) {
328 ?
> value
="<?php $this->text('search') ?>"<?php
330 <input type
="hidden" value
="en" id
="searchLang" name
="searchLang">
331 <input type
="hidden" value
="" id
="searchSer" name
="searchSer">
332 <button type
="submit" title
="Quick search" name
="fulltext" id
="searchGoButton"><img src
="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/images/magnifier.png" /></button
>
337 <?php
print $this->data
['SearchSeries'];?
>
338 <?php
print $this->data
['SearchLanguages'];?
>
340 <div id
="wiki_dd" class="dd_item">
341 <div
class="button grey">
344 <div
class="dd_menu wiki">
347 <?php
$cont=$this->data
['sidebar']['maintenance'];
348 foreach($cont as $key => $val) { ?
>
349 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
350 if ( $val['active'] ) { ?
> class="active" <?php
}?
>>
351 <a href
="<?php echo htmlspecialchars($val['href']) ?>">
352 <?php
echo htmlspecialchars($val['text']) ?
></a
>
358 <?php
if(isset($this->data
['nav_urls']['trackbacklink'])) { ?
>
360 <a href
="<?php echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])?>"><?php
$this->msg('trackbacklink') ?
></a
>
363 if($this->data
['feeds']) { ?
>
364 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
365 ?
><span id
="feed-<?php echo Sanitizer::escapeId($key) ?>"><a href
="<?php
366 echo htmlspecialchars($feed['href']) ?>"><?php
echo htmlspecialchars($feed['text'])?
></a
> 
;</span
>
370 foreach( array('contributions', 'blockip', 'emailuser') as $special ) {
372 if($this->data
['nav_urls'][$special]) {
373 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
374 ?>"><?php
$this->msg($special) ?
></a
></li
><?php
381 <?php
$specialpages = 'specialpages';
382 if($this->data
['nav_urls'][$specialpages]) {
383 ?
><li id
="t-<?php echo $specialpages ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$specialpages]['href'])
384 ?>"><?php
$this->msg($specialpages) ?
></a
></li
><?php
387 <?php
$cont=$this->data
['sidebar']['monitoring'];
388 foreach($cont as $key => $val) { ?
>
389 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
390 if ( $val['active'] ) { ?
> class="active" <?php
}?
>>
391 <a href
="<?php echo htmlspecialchars($val['href']) ?>">
392 <?php
echo htmlspecialchars($val['text']) ?
></a
>
398 <?php
$upload = 'upload';
399 if($this->data
['nav_urls'][$upload]) {
400 ?
><li id
="t-<?php echo $upload ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$upload]['href'])
401 ?>"><?php
$this->msg($upload) ?
></a
></li
><?php
411 if($this->data
['poweredbyico']) { ?
>
412 <a title
="Powered by mediawiki.org" class="poweredbyico" href
="http://www.mediawiki.org/">
413 <img src
="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/images/poweredby_mediawiki.png" alt
="power" />
416 if($this->data
['copyrightico']) { ?
>
417 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
420 // Generate additional footer links
424 $footerlinks = array(
425 //'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
426 //'privacy', 'about', 'disclaimer', 'tagline',
429 foreach( $footerlinks as $aLink ) {
430 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
431 ?
> <li id
="<?php echo $aLink?>"><?php
$this->html($aLink) ?
></li
>
438 <?php
$this->html('reporttime') ?
>
439 <?php
if ( $this->data
['debug'] ): ?
>
441 <?php
$this->text( 'debug' ); ?
>