Credit the original Beagle Project
[BeagleSkin.git] / Beagle.php
blob330fd0a94ff0eddbbc2221c6e0a7add44fb18770
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/>.
21 /**
22 * This file is a rewrite of the Beagle Project MediaWiki skin:
23 * http://web.archive.org/web/20090106025017/http://beagle-project.org/
25 * Original credits:
26 * Beagle - modified from MonoBook
27 * by: Joe Shaw (joeshaw@novell.com)
28 * license: TBD, probably GPL
30 * Default artwork used:
31 * "Beagle puppy's head", extracted by Marcin Cieślak
32 * out of the photography by Wikimedia Commons user Juanelverdolaga
33 * https://commons.wikimedia.org/wiki/File:Beagle_puppy%27s_head.png
35 * Availabe under Creative Commons Attribution-Share Alike 4.0:
36 * https://creativecommons.org/licenses/by-sa/4.0/deed.en
39 /**
40 * Inherit main code from SkinTemplate, set the CSS and template filter.
41 * @ingroup Skins
43 class SkinBeagle extends SkinTemplate {
44 var $skinname = 'beagle', $stylename = 'beagle',
45 $template = 'BeagleTemplate', $useHeadElement = true;
47 public function initPage( OutputPage $out ) {
48 global $wgBeagleImage;
49 parent::initPage( $out );
50 $out->addInlineStyle( "#header h1 { background: transparent " .
51 "url(" . ( $wgBeagleImage ?:
52 $this->getSkinStylePath( '/bigielbanner.png' ) . ") " .
53 "no-repeat; }" ) );
55 $out->addModuleStyles( array(
56 'skins.beagle.css'
57 ) );
59 /**
60 * Add CSS via ResourceLoader
62 * @param $out OutputPage
64 function setupSkinUserCss( OutputPage $out ) {
65 parent::setupSkinUserCss( $out );
70 /**
71 * @todo document
72 * @addtogroup Skins
74 class BeagleTemplate extends BaseTemplate {
76 function sel( $sel ) {
77 if ( $sel ) {
78 if ( $sel[0] == '#' )
79 return ' id="' . substr( $sel, 1 ) . '"';
80 else
81 return ' class="' . $sel . '"';
82 } else
83 return "";
86 function div ( $sel = false, $role = false) {
87 print "<div" . $this->sel( $sel );
88 if ( $role ) print " role=\"$role\"";
89 print ">";
92 function div_ends ( $sel = false ) {
93 print "</div>\n";
96 function div_html( $dataitem, $sel ) {
97 if ( $this->data[ $dataitem ] ) {
98 $this->div( $sel );
99 $this->html( $dataitem );
100 $this->div_ends( $sel );
104 function div_span_html( $dataitem, $sel, $span = false ) {
105 if ( $this->data[ $dataitem ] ) {
106 $this->div( $sel );
107 if ( $span ) { print "<span" . $this->sel( $span ) . ">" ; }
108 $this->html( $dataitem );
109 if ( $span ) { print "</span>"; }
110 $this->div_ends( $sel );
114 function a_href_msg( $target_id, $msg ) {
115 print " <a href=\"$target_id\">";
116 $this->msg( $msg );
117 print "</a>";
120 function jumplinks() {
121 if ( $this->data['showjumplinks'] ) {
122 $this->div( '#jump-to-nav' );
123 $this->msg( 'jumpto' );
124 $this->a_href_msg( '#nav_top', 'jumptonavigation' );
125 print ",";
126 $this->a_href_msg( '#searchInput', 'jumptosearch' );
127 $this->div_ends( '#jump-to-nav' );
131 function data_html( $dataitem ) {
132 if ( $this->data[ $dataitem ] )
133 $this->html( $dataitem );
136 function data_rem( $dataitem ) {
137 if ( $this->data[ $dataitem ] ) {
138 print "<!-- Debug output:\n";
139 $this->text( $dataitem );
140 print "\n-->\n";
144 function ul_list( $source, $sel, $last_item = false ) {
145 if ( $source && is_array( $source ) ) {
146 print "<ul" . $this->sel( $sel ) . ">\n";
147 foreach( $source as $key => $action ) {
148 print "\t" . $this->makeListItem( $key, $action ) . "\n";
150 if ( $last_item ) {
151 print "\t" . $last_item . "\n";
153 print "</ul>\n";
156 function ul_html ( $source ) {
157 if ( $source && is_array( $source ) ) {
158 print "<ul class=\"nav-bottom\">\n";
159 foreach( $source as $key ) {
160 print "\t<li>";
161 print $this->html( $key );
162 print "</li>\n";
164 print "</ul>\n";
168 function ul_plain ( $source ) {
169 if ( $source && is_array( $source ) ) {
170 print "<ul class=\"nav-bottom\">\n";
171 foreach( $source as $value ) {
172 print "\t<li>";
173 print $value;
174 print "</li>\n";
176 print "</ul>\n";
180 function nav_top( $source ) {
181 print "<nav>\n";
182 $this->ul_list( $source, '#nav-top', '<li class="cheat"></li>' );
183 print "</nav>\n";
186 function nav_bottom( $source ) {
187 print "<nav>\n";
188 $this->ul_list( $source, 'nav-bottom' );
189 print "</nav>\n";
192 function recent_changes_link() {
193 $d = array();
194 $d[ 'id' ] = 'nn-recentchanges';
195 $d[ 'text' ] = $this->getMsg( 'recentchanges' );
196 $rc = $this->getMsg( 'recentchanges-url' )->inContentLanguage()->text();
197 $title = Title::newFromText( $rc );
198 if ( $title ) {
199 $d[ 'href' ] = $title->getLinkURL();
200 return $d;
201 } else {
202 return false;
206 function main_bar_source() {
207 $sidebar = $this->getSidebar();
208 if ( $sidebar )
209 if ( isset( $sidebar[ 'navigation' ] ) )
210 if ( isset( $sidebar[ 'navigation' ][ 'content' ] ) )
211 return $sidebar[ 'navigation' ][ 'content' ];
212 return false;
215 function special_pages_source() {
216 $source = $this->getToolbox();
217 $source [ 'recentchanges' ] = $this->recent_changes_link();
218 return $source;
221 function page_info() {
222 $this->div( '#article_info', 'contentinfo' );
223 $this->data_html( 'lastmod' );
224 $this->data_html( 'viewcount' );
225 $this->div_ends( '#article_info ');
228 function footer_icons() {
229 $source = array();
230 foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons )
231 foreach ( $footerIcons as $icon )
232 array_push ( $source, $this->getSkin()->makeFooterIcon( $icon ) );
233 return $source;
236 function search_form() { ?>
237 <div class="searchForm" role="search">
238 <form id="searchForm" class="searchForm" name="searchForm" action="<?php $this->text('searchaction') ?>">
239 <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" />
240 <?php print $this->makeSearchInput(); ?>
242 <?php print $this->makeSearchButton( 'go' ); ?>
244 <?php print $this->makeSearchButton( 'fulltext' ); ?>
246 </form>
247 </div>
248 <?php
251 function dotted_spacing() {
252 print "<hr class=\"clear dotted spacing\" />\n";
255 function execute() {
256 $skin = $this->getSkin();
257 $body = $this->data['bodycontent'];
259 $skin_path = $this->data['stylepath'].'/'.$this->data['stylename'];
261 // Output HTML Page
262 $this->html( 'headelement' );
264 ?><!-- START main page container -->
265 <div id="pagecontainer">
267 <!-- START subsection header and subnav -->
268 <div id="header">
269 <h1><?php $this->text( 'pagetitle' ) ?></h1>
270 </div>
271 <hr class="clear spacing" />
272 <?php
273 $this->nav_top( $this->main_bar_source() );
275 <div id="content" role="main">
276 <div id="content-body">
277 <div id="articleBody">
278 <a id="top"></a>
279 <?php $this->div_html( 'sitenotice', '#siteNotice' ); ?>
280 <div id="articleContent">
281 <?php
282 $this->div_html( 'subtitle', '#contentSub' );
283 $this->div_html( 'undelete', '#contentSub2' );
284 $this->div_html( 'newtalk', '#usermessage' );
285 $this->jumplinks();
286 $this->html( 'bodytext' );
287 $this->data_html( 'catlinks' );
289 </div><!-- aricleContent -->
290 </div><!-- articleBody -->
291 </div><!-- content-body -->
292 <hr class="clear" />
293 <?php
294 print $this->getIndicators();
295 $this->page_info();
297 </div><!-- content -->
298 <?php
299 $this->dotted_spacing();
300 $this->html( 'dataAfterContent' );
302 $this->nav_bottom( $this->getPersonalTools() );
303 $this->nav_bottom( $this->data[ 'content_actions' ] );
304 $this->nav_bottom( $this->data[ 'language_urls' ] );
305 $this->search_form();
306 $this->nav_bottom( $this->special_pages_source() );
307 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
308 # $this->ul_html( $this->getFooterLinks( )[ 'places' ] );
309 $this->ul_plain( $this->footer_icons() );
310 $this->div();
311 $this->dotted_spacing();
312 $this->div_ends();
313 $this->html( 'reporttime' );
314 $this->data_rem( 'debug' );
315 $this->printTrail(); ?>
316 </div>
317 </body>
318 </html>
319 <?php