forked from South-Paw/Bootstrap-MediaWiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap-MW.skin.php
266 lines (244 loc) · 8.13 KB
/
Bootstrap-MW.skin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
/**
* Skin file for Bootstrap MW skin.
*
* @file
* @ingroup Skins
*/
class SkinBootstrapMW extends SkinTemplate {
var $skinname = 'bootstrapmw', $stylename = 'bootstrapmw', $template = 'BootstrapMW', $useHeadElement = true;
function setupSkinUserCss(OutputPage $out){
parent::setupSkinUserCss($out);
$out->addHeadItem('ie-meta', '<meta http-equiv="X-UA-Compatible" content="IE=edge" />');
$out->addHeadItem('viewport-meta', '<meta name="viewport" content="width=device-width, initial-scale=1" />');
$out->addModuleStyles('skins.bootstrapmw');
}
}
/**
* BaseTemplate class for Bootstrap MW skin
* @ingroup Skins
*/
class BootstrapMW extends BaseTemplate {
public function execute() {
// Suppress warnings to prevent notices about missing indexes in $this->data
wfSuppressWarnings();
$this->html('headelement'); ?>
<header class="header">
<div class="container">
<nav class="navbar navbar-default hidden-print" role="navigation">
<div class="navbar-header"><?php
// Create index link for wiki header
echo '
<a href="'. $this->data['nav_urls']['mainpage']['href'] .'" class="navbar-brand">
'. $this->data['sitename'] .'
</a>'; ?>
</div>
<div class="navbar-form navbar-right form-inline"><?php
// Create a search form for wiki header
$this->searchBox(); ?>
</div>
</nav>
</div>
</header>
<main class="wiki">
<nav class="navbar-wiki">
<div class="container"><?php
// Print content actions nav items
$this->contentActions(); ?>
</div>
</nav>
<div class="container">
<div class="row">
<section class="col-md-10 col-sm-12 page">
<?php if($this->data['sitenotice']) { ?><div id="alert alert-info"><?php $this->html('sitenotice'); ?></div><?php }; ?>
<div class="page-header">
<h1><?php $this->html('title'); ?> <small class="visible-print"><?php $this->msg('tagline'); ?></small></h1>
</div>
<div class="page">
<div class="subtitle"><?php $this->html('subtitle'); ?></div>
<?php if($this->data['undelete']) { ?><div class="undelete"><?php $this->html('undelete'); ?></div><?php } ?>
<?php if($this->data['newtalk'] ) { ?><div class="newtalk"><?php $this->html('newtalk'); ?></div><?php } ?>
<?php if($this->data['showjumplinks']) {
// Todo: showing these for mobiles to easily navigate ?>
<div class="jumplinks">
<?php $this->msg('jumpto'); ?><a href="#column-one"><?php $this->msg('jumptonavigation'); ?></a>
<?php $this->msg('comma-separator'); ?><a href="#searchInput"><?php $this->msg('jumptosearch'); ?></a>
</div>
<?php };
// Now print the acutal page content
$this->html('bodytext');
// Print the catagory links for this content
if($this->data['catlinks']) { $this->html('catlinks'); }
// Print any remaining data after the content
if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); }?>
<div class="clearfix"></div>
</div>
</section>
<aside class="col-md-2 hidden-sm hidden-xs sidebar hidden-print"><?php
// Print the personal tools
$this->personalTools();
// Print all the other navigation blocks
$this->renderPortals($this->data['sidebar']); ?>
</aside>
</div>
</div>
<footer class="footer">
<div class="container"><?php
$validFooterIcons = $this->getFooterIcons('icononly');
$validFooterLinks = $this->getFooterLinks('flat'); // Additional footer links
if ( count( $validFooterLinks ) > 0 ) { ?>
<div class="row">
<div class="col-md-12">
<ul class="list"><?php
foreach( $validFooterLinks as $aLink ) { ?>
<li class="footer-<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
<?php } ?>
<li><a href="https://github.com/South-Paw/Bootstrap-MW">Bootstrap MW Skin</a> v1.0</li>
</ul>
</div>
</div>
<?php }; ?>
<div class="row"><?php
foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
<div class="col-md-6 icons footer-<?php echo htmlspecialchars($blockName); ?>"><?php
foreach ( $footerIcons as $icon ) {
echo $this->getSkin()->makeFooterIcon( $icon );
}; ?>
</div>
<?php }; ?>
</div>
</div>
</footer>
</main>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="skins/Bootstrap-MW/js/bootstrap.min.js"></script>
<?php $this->printTrail(); ?>
</body>
</html><?php
wfRestoreWarnings();
}
/*************************************************************************************************/
/**
* Prints all navigation portals
*/
protected function renderPortals($sidebar) {
if (!isset($sidebar['SEARCH'])) $sidebar['SEARCH'] = true;
if (!isset($sidebar['TOOLBOX'])) $sidebar['TOOLBOX'] = true;
if (!isset($sidebar['LANGUAGES'])) $sidebar['LANGUAGES'] = true;
foreach($sidebar as $boxName => $content) {
if ($content === false)
continue;
if ($boxName == 'TOOLBOX') {
$this->toolBox();
} elseif ($boxName == 'LANGUAGES') {
$this->languageBox();
} else {
$this->customBox($boxName, $content);
};
};
}
/**
* For renderPortals()
* Print tool box portal
*/
function toolBox() { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php $this->msg('toolbox'); ?></h3>
</div>
<div class="panel-body">
<ul class="nav nav-pills nav-stacked"><?php
foreach ( $this->getToolbox() as $key => $tbitem ) {
echo $this->makeListItem($key, $tbitem);
};
wfRunHooks('MonoBookTemplateToolboxEnd', array(&$this));
wfRunHooks('SkinTemplateToolboxEnd', array(&$this, true )); ?>
</ul>
</div>
</div><?php
}
/**
* For renderPortals()
* Print language box portal
*/
function languageBox() {
if($this->data['language_urls']) { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php $this->msg('otherlanguages'); ?></h3>
</div>
<div class="panel-body">
<ul class="nav nav-pills nav-stacked"><?php
foreach($this->data['language_urls'] as $key => $langlink) {
echo $this->makeListItem($key, $langlink);
}; ?>
</ul>
</div>
</div><?php
};
}
/**
* For renderPortals()
* Print any custom box portal
*/
function customBox($bar, $cont) { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h3>
</div>
<div class="panel-body"><?php
if ( is_array( $cont ) ) { ?>
<ul class="nav nav-pills nav-stacked"><?php
foreach($cont as $key => $val) {
echo $this->makeListItem($key, $val);
}; ?>
</ul><?php
} else {
print $cont;
}; ?>
</div>
</div><?php
}
/*************************************************************************************************/
/**
* Prints the search box
*/
function searchBox() {
global $wgUseTwoButtonsSearchForm; ?>
<form action="<?php $this->text('wgScript'); ?>" class="searchform">
<div class="form-group"><?php
echo $this->makeSearchInput(array('id' => 'searchInput', 'class' => 'form-control')); ?>
</div>
<div class="form-group"><?php
echo $this->makeSearchButton('go', array( 'class' => 'btn btn-primary' )); ?>
</div>
</form><?php
}
/**
* Prints the content actions nav items
*/
function contentActions() { ?>
<ul class="nav nav-tabs"><?php
foreach($this->data['content_actions'] as $key => $tab) {
echo $this->makeListItem( $key, $tab );
}; ?>
</ul><?php
}
/**
* Prints the personal tools.
*/
function personalTools() { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php $this->msg('personaltools'); ?></h3>
</div>
<div class="panel-body">
<ul class="nav nav-pills nav-stacked"><?php
foreach($this->getPersonalTools() as $key => $item) {
echo $this->makeListItem($key, $item);
}; ?>
</ul>
</div>
</div><?php
}
} ?>