We have no wfRunHooks() anymore
[BeagleSkin.git] / Beagle.php
blobe879fdd808f85f8a6d04dcf34fa408510b7e0ca3
1 <?php
2 /**
3 * This file is a rewrite of the Beagle Project MediaWiki skin:
4 * http://web.archive.org/web/20090106025017/http://beagle-project.org/
6 * Original credits:
7 * Beagle - modified from MonoBook
8 * by: Joe Shaw (joeshaw@novell.com)
9 * license: TBD, probably GPL
11 * Default artwork used:
12 * "Beagle puppy's head", extracted by Marcin Cieślak
13 * out of the photography by Wikimedia Commons user Juanelverdolaga
14 * https://commons.wikimedia.org/wiki/File:Beagle_puppy%27s_head.png
16 * Availabe under Creative Commons Attribution-Share Alike 4.0:
17 * https://creativecommons.org/licenses/by-sa/4.0/deed.en
20 /**
21 * Inherit main code from SkinTemplate, set the CSS and template filter.
22 * @ingroup Skins
24 class SkinBeagle extends SkinTemplate {
25 var $skinname = 'beagle', $stylename = 'beagle',
26 $template = 'BeagleTemplate', $useHeadElement = true;
28 public function initPage( OutputPage $out ) {
29 global $wgBeagleImage;
30 parent::initPage( $out );
31 $out->addInlineStyle( "#header h1 { background: transparent " .
32 "url(" . ( $wgBeagleImage ?:
33 $this->getSkinStylePath( '/bigielbanner.png' ) . ") " .
34 "no-repeat; }" ) );
36 $out->addModuleStyles( array(
37 'skins.beagle.css'
38 ) );
40 /**
41 * Add CSS via ResourceLoader
43 * @param $out OutputPage
45 function setupSkinUserCss( OutputPage $out ) {
46 parent::setupSkinUserCss( $out );
51 /**
52 * @todo document
53 * @addtogroup Skins
55 class BeagleTemplate extends BaseTemplate {
57 function sel( $sel ) {
58 if ( $sel ) {
59 if ( $sel[0] == '#' )
60 return ' id="' . substr( $sel, 1 ) . '"';
61 else
62 return ' class="' . $sel . '"';
63 } else
64 return "";
67 function div ( $sel = false, $role = false) {
68 print "<div" . $this->sel( $sel );
69 if ( $role ) print " role=\"$role\"";
70 print ">";
73 function div_ends ( $sel = false ) {
74 print "</div>\n";
77 function div_html( $dataitem, $sel ) {
78 if ( $this->data[ $dataitem ] ) {
79 $this->div( $sel );
80 $this->html( $dataitem );
81 $this->div_ends( $sel );
85 function div_span_html( $dataitem, $sel, $span = false ) {
86 if ( $this->data[ $dataitem ] ) {
87 $this->div( $sel );
88 if ( $span ) { print "<span" . $this->sel( $span ) . ">" ; }
89 $this->html( $dataitem );
90 if ( $span ) { print "</span>"; }
91 $this->div_ends( $sel );
95 function a_href_msg( $target_id, $msg ) {
96 print " <a href=\"$target_id\">";
97 $this->msg( $msg );
98 print "</a>";
101 function jumplinks() {
102 if ( $this->data['showjumplinks'] ) {
103 $this->div( '#jump-to-nav' );
104 $this->msg( 'jumpto' );
105 $this->a_href_msg( '#nav_top', 'jumptonavigation' );
106 print ",";
107 $this->a_href_msg( '#searchInput', 'jumptosearch' );
108 $this->div_ends( '#jump-to-nav' );
112 function data_html( $dataitem ) {
113 if ( $this->data[ $dataitem ] )
114 $this->html( $dataitem );
117 function data_rem( $dataitem ) {
118 if ( $this->data[ $dataitem ] ) {
119 print "<!-- Debug output:\n";
120 $this->text( $dataitem );
121 print "\n-->\n";
125 function ul_list( $source, $sel, $last_item = false ) {
126 if ( $source && is_array( $source ) ) {
127 print "<ul" . $this->sel( $sel ) . ">\n";
128 foreach( $source as $key => $action ) {
129 print "\t" . $this->makeListItem( $key, $action ) . "\n";
131 if ( $last_item ) {
132 print "\t" . $last_item . "\n";
134 print "</ul>\n";
137 function ul_html ( $source ) {
138 if ( $source && is_array( $source ) ) {
139 print "<ul class=\"nav-bottom\">\n";
140 foreach( $source as $key ) {
141 print "\t<li>";
142 print $this->html( $key );
143 print "</li>\n";
145 print "</ul>\n";
149 function ul_plain ( $source ) {
150 if ( $source && is_array( $source ) ) {
151 print "<ul class=\"nav-bottom\">\n";
152 foreach( $source as $value ) {
153 print "\t<li>";
154 print $value;
155 print "</li>\n";
157 print "</ul>\n";
161 function nav_top( $source ) {
162 print "<nav>\n";
163 $this->ul_list( $source, '#nav-top', '<li class="cheat"></li>' );
164 print "</nav>\n";
167 function nav_bottom( $source ) {
168 print "<nav>\n";
169 $this->ul_list( $source, 'nav-bottom' );
170 print "</nav>\n";
173 function recent_changes_link() {
174 $d = array();
175 $d[ 'id' ] = 'nn-recentchanges';
176 $d[ 'text' ] = $this->getMsg( 'recentchanges' );
177 $rc = $this->getMsg( 'recentchanges-url' )->inContentLanguage()->text();
178 $title = Title::newFromText( $rc );
179 if ( $title ) {
180 $d[ 'href' ] = $title->getLinkURL();
181 return $d;
182 } else {
183 return false;
187 function main_bar_source() {
188 $sidebar = $this->getSidebar();
189 if ( $sidebar )
190 if ( isset( $sidebar[ 'navigation' ] ) )
191 if ( isset( $sidebar[ 'navigation' ][ 'content' ] ) )
192 return $sidebar[ 'navigation' ][ 'content' ];
193 return false;
196 function special_pages_source() {
197 $source = $this->getToolbox();
198 $source [ 'recentchanges' ] = $this->recent_changes_link();
199 return $source;
202 function page_info() {
203 $this->div( '#article_info', 'contentinfo' );
204 $this->data_html( 'lastmod' );
205 $this->data_html( 'viewcount' );
206 $this->div_ends( '#article_info ');
209 function footer_icons() {
210 $source = array();
211 foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons )
212 foreach ( $footerIcons as $icon )
213 array_push ( $source, $this->getSkin()->makeFooterIcon( $icon ) );
214 return $source;
217 function search_form() { ?>
218 <div class="searchForm" role="search">
219 <form id="searchForm" class="searchForm" name="searchForm" action="<?php $this->text('searchaction') ?>">
220 <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" />
221 <?php print $this->makeSearchInput(); ?>
223 <?php print $this->makeSearchButton( 'go' ); ?>
225 <?php print $this->makeSearchButton( 'fulltext' ); ?>
227 </form>
228 </div>
229 <?php
232 function dotted_spacing() {
233 print "<hr class=\"clear dotted spacing\" />\n";
236 function execute() {
237 $skin = $this->getSkin();
238 $body = $this->data['bodycontent'];
240 $skin_path = $this->data['stylepath'].'/'.$this->data['stylename'];
242 // Output HTML Page
243 $this->html( 'headelement' );
245 ?><!-- START main page container -->
246 <div id="pagecontainer">
248 <!-- START subsection header and subnav -->
249 <div id="header">
250 <h1><?php $this->text( 'pagetitle' ) ?></h1>
251 </div>
252 <hr class="clear spacing" />
253 <?php
254 $this->nav_top( $this->main_bar_source() );
256 <div id="content" role="main">
257 <div id="content-body">
258 <div id="articleBody">
259 <a id="top"></a>
260 <?php $this->div_html( 'sitenotice', '#siteNotice' ); ?>
261 <div id="articleContent">
262 <?php
263 $this->div_html( 'subtitle', '#contentSub' );
264 $this->div_html( 'undelete', '#contentSub2' );
265 $this->div_html( 'newtalk', '#usermessage' );
266 $this->jumplinks();
267 $this->html( 'bodytext' );
268 $this->data_html( 'catlinks' );
270 </div><!-- aricleContent -->
271 </div><!-- articleBody -->
272 </div><!-- content-body -->
273 <hr class="clear" />
274 <?php
275 print $this->getIndicators();
276 $this->page_info();
278 </div><!-- content -->
279 <?php
280 $this->dotted_spacing();
281 $this->html( 'dataAfterContent' );
283 $this->nav_bottom( $this->getPersonalTools() );
284 $this->nav_bottom( $this->data[ 'content_actions' ] );
285 $this->nav_bottom( $this->data[ 'language_urls' ] );
286 $this->search_form();
287 $this->nav_bottom( $this->special_pages_source() );
288 Hooks::Run( 'SkinTemplateToolboxEnd', array( &$this ) );
289 # $this->ul_html( $this->getFooterLinks( )[ 'places' ] );
290 $this->ul_plain( $this->footer_icons() );
291 $this->div();
292 $this->dotted_spacing();
293 $this->div_ends();
294 $this->html( 'reporttime' );
295 $this->data_rem( 'debug' );
296 $this->printTrail(); ?>
297 </div>
298 </body>
299 </html>
300 <?php