3 * Copyright (c) 2015 Marcin Cieślak (saper.info)
5 * This file is part of Beagle Skin for Mediawiki.
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/>.
23 * Inherit main code from SkinTemplate, set the CSS and template filter.
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 );
34 * Add CSS via ResourceLoader
36 * @param $out OutputPage
38 function setupSkinUserCss( OutputPage
$out ) {
39 parent
::setupSkinUserCss( $out );
40 $out->addModuleStyles( array(
51 class BeagleTemplate
extends BaseTemplate
{
53 function sel( $sel ) {
56 return ' id="' . substr( $sel, 1 ) . '"';
58 return ' class="' . $sel . '"';
63 function div ( $sel = false, $role = false) {
64 print "<div" . $this->sel( $sel );
65 if ( $role ) print " role=\"$role\"";
69 function div_ends ( $sel = false ) {
73 function div_html( $dataitem, $sel ) {
74 if ( $this->data
[ $dataitem ] ) {
76 $this->html( $dataitem );
77 $this->div_ends( $sel );
81 function div_span_html( $dataitem, $sel, $span = false ) {
82 if ( $this->data
[ $dataitem ] ) {
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\">";
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' );
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 );
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";
128 print "\t" . $last_item . "\n";
133 function ul_html ( $source ) {
134 if ( $source && is_array( $source ) ) {
135 print "<ul class=\"nav-bottom\">\n";
136 foreach( $source as $key ) {
138 print $this->html( $key );
145 function ul_plain ( $source ) {
146 if ( $source && is_array( $source ) ) {
147 print "<ul class=\"nav-bottom\">\n";
148 foreach( $source as $value ) {
157 function nav_top( $source ) {
159 $this->ul_list( $source, '#nav-top', '<li class="cheat"></li>' );
163 function nav_bottom( $source ) {
165 $this->ul_list( $source, 'nav-bottom' );
169 function recent_changes_link() {
171 $d[ 'id' ] = 'nn-recentchanges';
172 $d[ 'text' ] = $this->getMsg( 'recentchanges' );
173 $rc = $this->getMsg( 'recentchanges-url' )->inContentLanguage()->text();
174 $title = Title
::newFromText( $rc );
176 $d[ 'href' ] = $title->getLinkURL();
183 function main_bar_source() {
184 $sidebar = $this->getSidebar();
186 if ( isset( $sidebar[ 'navigation' ] ) )
187 if ( isset( $sidebar[ 'navigation' ][ 'content' ] ) )
188 return $sidebar[ 'navigation' ][ 'content' ];
192 function special_pages_source() {
193 $source = $this->getToolbox();
194 $source [ 'recentchanges' ] = $this->recent_changes_link();
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() {
207 foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons )
208 foreach ( $footerIcons as $icon )
209 array_push ( $source, $this->getSkin()->makeFooterIcon( $icon ) );
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' ); ?
>
228 function dotted_spacing() {
229 print "<hr class=\"clear dotted spacing\" />\n";
233 $skin = $this->getSkin();
234 $body = $this->data
['bodycontent'];
236 $skin_path = $this->data
['stylepath'].'/'.$this->data
['stylename'];
239 $this->html( 'headelement' );
241 ?
><!-- START main page container
-->
242 <div id
="pagecontainer">
244 <!-- START subsection header
and subnav
-->
246 <h1
><?php
$this->text( 'pagetitle' ) ?
></h1
>
248 <hr
class="clear spacing" />
250 $this->nav_top( $this->main_bar_source() );
252 <div id
="content" role
="main">
253 <div id
="content-body">
254 <div id
="articleBody">
256 <?php
$this->div_html( 'sitenotice', '#siteNotice' ); ?
>
257 <div id
="articleContent">
259 $this->div_html( 'subtitle', '#contentSub' );
260 $this->div_html( 'undelete', '#contentSub2' );
261 $this->div_html( 'newtalk', '#usermessage' );
263 $this->html( 'bodytext' );
264 $this->data_html( 'catlinks' );
266 </div
><!-- aricleContent
-->
267 </div
><!-- articleBody
-->
268 </div
><!-- content
-body
-->
271 print $this->getIndicators();
274 </div
><!-- content
-->
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() );
288 $this->dotted_spacing();
290 $this->html( 'reporttime' );
291 $this->data_rem( 'debug' );
292 $this->printTrail(); ?
>