Playing the ARIA game
[BeagleSkin.git] / Beagle.php
blobe0467e0498c16f3d6023504ac5468e8cc9bf2a0e
1 <?php
2 /*
3 * Copyright (c) 2015 Marcin Cieślak (saper.info)
4 *
5 * This file is part of Beagle Skin for Mediawiki.
6 *
7 * Beagle skin is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * Beagle is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Beagle. If not, see <http://www.gnu.org/licenses/>.
22 /**
23 * Inherit main code from SkinTemplate, set the CSS and template filter.
24 * @ingroup Skins
26 class SkinBeagle extends SkinTemplate {
27 var $skinname = 'beagle', $stylename = 'beagle',
28 $template = 'BeagleTemplate', $useHeadElement = true;
30 public function initPage( OutputPage $out ) {
31 parent::initPage( $out );
33 /**
34 * Add CSS via ResourceLoader
36 * @param $out OutputPage
38 function setupSkinUserCss( OutputPage $out ) {
39 parent::setupSkinUserCss( $out );
40 $out->addModuleStyles( array(
41 'skins.beagle.css'
42 ) );
47 /**
48 * @todo document
49 * @addtogroup Skins
51 class BeagleTemplate extends BaseTemplate {
53 function sel( $sel ) {
54 if ( $sel ) {
55 if ( $sel[0] == '#' )
56 return ' id="' . substr( $sel, 1 ) . '"';
57 else
58 return ' class="' . $sel . '"';
59 } else
60 return "";
63 function div ( $sel = false, $role = false) {
64 print "<div" . $this->sel( $sel );
65 if ( $role ) print " role=\"$role\"";
66 print ">";
69 function div_ends ( $sel = false ) {
70 print "</div>\n";
73 function div_html( $dataitem, $sel ) {
74 if ( $this->data[ $dataitem ] ) {
75 $this->div( $sel );
76 $this->html( $dataitem );
77 $this->div_ends( $sel );
81 function div_span_html( $dataitem, $sel, $span = false ) {
82 if ( $this->data[ $dataitem ] ) {
83 $this->div( $sel );
84 if ( $span ) { print "<span" . $this->sel( $span ) . ">" ; }
85 $this->html( $dataitem );
86 if ( $span ) { print "</span>"; }
87 $this->div_ends( $sel );
91 function a_href_msg( $target_id, $msg ) {
92 print " <a href=\"$target_id\">";
93 $this->msg( $msg );
94 print "</a>";
97 function jumplinks() {
98 if ( $this->data['showjumplinks'] ) {
99 $this->div( '#jump-to-nav' );
100 $this->msg( 'jumpto' );
101 $this->a_href_msg( '#nav_top', 'jumptonavigation' );
102 print ",";
103 $this->a_href_msg( '#searchInput', 'jumptosearch' );
104 $this->div_ends( '#jump-to-nav' );
108 function data_html( $dataitem ) {
109 if ( $this->data[ $dataitem ] )
110 $this->html( $dataitem );
113 function data_rem( $dataitem ) {
114 if ( $this->data[ $dataitem ] ) {
115 print "<!-- Debug output:\n";
116 $this->text( $dataitem );
117 print "\n-->\n";
121 function ul_list( $source, $sel, $last_item = false ) {
122 if ( $source && is_array( $source ) ) {
123 print "<ul" . $this->sel( $sel ) . ">\n";
124 foreach( $source as $key => $action ) {
125 print "\t" . $this->makeListItem( $key, $action ) . "\n";
127 if ( $last_item ) {
128 print "\t" . $last_item . "\n";
130 print "</ul>\n";
133 function ul_html ( $source ) {
134 if ( $source && is_array( $source ) ) {
135 print "<ul class=\"nav-bottom\">\n";
136 foreach( $source as $key ) {
137 print "\t<li>";
138 print $this->html( $key );
139 print "</li>\n";
141 print "</ul>\n";
145 function ul_plain ( $source ) {
146 if ( $source && is_array( $source ) ) {
147 print "<ul class=\"nav-bottom\">\n";
148 foreach( $source as $value ) {
149 print "\t<li>";
150 print $value;
151 print "</li>\n";
153 print "</ul>\n";
157 function nav_top( $source ) {
158 print "<nav>\n";
159 $this->ul_list( $source, '#nav-top', '<li class="cheat"></li>' );
160 print "</nav>\n";
163 function nav_bottom( $source ) {
164 print "<nav>\n";
165 $this->ul_list( $source, 'nav-bottom' );
166 print "</nav>\n";
169 function recent_changes_link() {
170 $d = array();
171 $d[ 'id' ] = 'nn-recentchanges';
172 $d[ 'text' ] = $this->getMsg( 'recentchanges' );
173 $rc = $this->getMsg( 'recentchanges-url' )->inContentLanguage()->text();
174 $title = Title::newFromText( $rc );
175 if ( $title ) {
176 $d[ 'href' ] = $title->getLinkURL();
177 return $d;
178 } else {
179 return false;
183 function main_bar_source() {
184 $sidebar = $this->getSidebar();
185 if ( $sidebar )
186 if ( isset( $sidebar[ 'navigation' ] ) )
187 if ( isset( $sidebar[ 'navigation' ][ 'content' ] ) )
188 return $sidebar[ 'navigation' ][ 'content' ];
189 return false;
192 function special_pages_source() {
193 $source = $this->getToolbox();
194 $source [ 'recentchanges' ] = $this->recent_changes_link();
195 return $source;
198 function page_info() {
199 $this->div( '#article_info', 'contentinfo' );
200 $this->data_html( 'lastmod' );
201 $this->data_html( 'viewcount' );
202 $this->div_ends( '#article_info ');
205 function footer_icons() {
206 $source = array();
207 foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons )
208 foreach ( $footerIcons as $icon )
209 array_push ( $source, $this->getSkin()->makeFooterIcon( $icon ) );
210 return $source;
213 function search_form() { ?>
214 <div class="searchForm" role="search">
215 <form id="searchForm" class="searchForm" name="searchForm" action="<?php $this->text('searchaction') ?>">
216 <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" />
217 <?php print $this->makeSearchInput(); ?>
219 <?php print $this->makeSearchButton( 'go' ); ?>
221 <?php print $this->makeSearchButton( 'fulltext' ); ?>
223 </form>
224 </div>
225 <?php
228 function dotted_spacing() {
229 print "<hr class=\"clear dotted spacing\" />\n";
232 function execute() {
233 $skin = $this->getSkin();
234 $body = $this->data['bodycontent'];
236 $skin_path = $this->data['stylepath'].'/'.$this->data['stylename'];
238 // Output HTML Page
239 $this->html( 'headelement' );
241 ?><!-- START main page container -->
242 <div id="pagecontainer">
244 <!-- START subsection header and subnav -->
245 <div id="header">
246 <h1><?php $this->text( 'pagetitle' ) ?></h1>
247 </div>
248 <hr class="clear spacing" />
249 <?php
250 $this->nav_top( $this->main_bar_source() );
252 <div id="content" role="main">
253 <div id="content-body">
254 <div id="articleBody">
255 <a id="top"></a>
256 <?php $this->div_html( 'sitenotice', '#siteNotice' ); ?>
257 <div id="articleContent">
258 <?php
259 $this->div_html( 'subtitle', '#contentSub' );
260 $this->div_html( 'undelete', '#contentSub2' );
261 $this->div_html( 'newtalk', '#usermessage' );
262 $this->jumplinks();
263 $this->html( 'bodytext' );
264 $this->data_html( 'catlinks' );
266 </div><!-- aricleContent -->
267 </div><!-- articleBody -->
268 </div><!-- content-body -->
269 <hr class="clear" />
270 <?php
271 print $this->getIndicators();
272 $this->page_info();
274 </div><!-- content -->
275 <?php
276 $this->dotted_spacing();
277 $this->html( 'dataAfterContent' );
279 $this->nav_bottom( $this->getPersonalTools() );
280 $this->nav_bottom( $this->data[ 'content_actions' ] );
281 $this->nav_bottom( $this->data[ 'language_urls' ] );
282 $this->search_form();
283 $this->nav_bottom( $this->special_pages_source() );
284 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
285 $this->ul_html( $this->getFooterLinks( )[ 'places' ] );
286 $this->ul_plain( $this->footer_icons() );
287 $this->div();
288 $this->dotted_spacing();
289 $this->div_ends();
290 $this->html( 'reporttime' );
291 $this->data_rem( 'debug' );
292 $this->printTrail(); ?>
293 </div>
294 </body>
295 </html>
296 <?php