-
Notifications
You must be signed in to change notification settings - Fork 2
/
BrlCad.skin.php
577 lines (493 loc) · 18.7 KB
/
BrlCad.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<?php
/**
* Skin file for skin BrlCad Skin
*
* @file
* @ingroup Skins
*/
/**
* Skin Template class for BrlCad Skin skin
* @ingroup Skins
*/
class SkinBrlCad extends SkinTemplate {
var $skinname = 'brlcad', $stylename = 'brlcad',
$template = 'BrlCadTemplate', $useHeadElement = true;
/**
* @param $out OutputPage object
*/
function setupSkinUserCss( OutputPage $out ){
parent::setupSkinUserCss( $out );
$out->addModuleStyles( "skins.brlcad" );
}
}
/**
* @todo document
* @ingroup Skins
*/
class BrlCadTemplate extends BaseTemplate {
/**
* Template filter callback for BrlCad skin.
* Takes an associative array of data set from a SkinTemplate-based
* class, and a wrapper for MediaWiki's localization database, and
* outputs a formatted page.
*
* @access private
*/
function execute() {
// Suppress warnings to prevent notices about missing indexes in $this->data
wfSuppressWarnings();
$this->html( 'headelement' );
?>
<!-- MARK UP STARTS FROM HERE -->
<!-- BRL-CAD main website navigation -->
<div class="brlcad-site-nav">
<div class="container">
<!-- the circular logo that also works as menu toggle -->
<div class="id_logo" id='logo'>
<span class="circle" href="#">
<img src= <?php echo $this->getSkin()->getSkinStylePath( 'images/logo_70.png'); ?> width="40px" height="40px"/>
</span>
</div>
<!-- header code starts here -->
<header class="head">
<nav class="navbar">
<ul class="navigation id_main-nav" id="main-nav">
<li><a href="">
<img class = "icon" src=<?php echo $this->getSkin()->getSkinStylePath( 'images/icons/gallery.png'); ?> />
Gallery</a></li>
<li><a href="">
<img class = "icon" src=<?php echo $this->getSkin()->getSkinStylePath( 'images/icons/wiki.png'); ?> />
Blog</a></li>
<li><a href="">
<img class = "icon" src=<?php echo $this->getSkin()->getSkinStylePath( 'images/icons/contribute.png'); ?> >
Community</a></li>
<li><a href="">
<img class = "icon" src= <?php echo $this->getSkin()->getSkinStylePath( 'images/icons/documentation.png'); ?> />
Documentation</a></li>
<li><a href="">
<img class = "icon" src= <?php echo $this->getSkin()->getSkinStylePath( 'images/icons/download-2.png'); ?> />
Download</a></li>
<li class="selected">
<a href="#about">
<img class = "icon" src=<?php echo $this->getSkin()->getSkinStylePath( 'images/icons/home.png'); ?> />
About
</a>
</li>
</ul>
</nav>
</header>
</div>
<style>
@font-face {
font-family: "untitled-font-2";
src:url("<?php echo $this->getSkin()->getSkinStylePath('stylesheets/fonts/untitled-font-2.eot');?>");
src:url("<?php echo $this->getSkin()->getSkinStylePath('stylesheets/fonts/untitled-font-2.eot?#iefix');?>") format("embedded-opentype"),
url("<?php echo $this->getSkin()->getSkinStylePath('stylesheets/fonts/untitled-font-2.ttf');?>") format("truetype"),
url("<?php echo $this->getSkin()->getSkinStylePath('stylesheets/fonts/untitled-font-2.svg#untitled-font-2');?>") format("svg"),
url("<?php echo $this->getSkin()->getSkinStylePath('stylesheets/fonts/untitled-font-2.woff');?>") format("woff");
font-weight: normal;
font-style: normal;
}
</style>
<!-- MOBILE ONLY NAVIGATIONS -->
<!-- set of full screen mobile navigation panels that appear only on smaller screens -->
<!-- Toolbox navigation -->
<div class="mobile-nav mobile-nav-toolbox">
<div class="m-nav-container">
<!-- quit button on the right hand side -->
<div class="nav-quit"><a class="nav-quit-X" href="#">X</a></div>
<!-- personal tools -->
<div class="m-nav-ptools">
<!-- personal tools box called protlet, for mobile m-portlet -->
<div class="m-portlet" id="m-p-personal" role="navigation">
<!-- portlet heading -->
<h3 id="m-personal-tools"><?php $this->msg( 'personaltools' ) ?></h3>
<!-- portlet body -->
<div class="m-pBody">
<ul<?php $this->html( 'userlangattributes' ) ?> class="m-nav-ul">
<?php foreach ( $this->getPersonalTools() as $key => $item ) {
echo $this->makeListItem( $key, $item );
} ?>
</ul>
</div>
</div>
</div>
<!-- personal tools end here -->
<!-- tools -->
<div class=" m-nav-tools">
<div class="m-portlet" id="m-p-tb" role="navigation">
<h3><?php $this->msg( 'toolbox' ) ?></h3>
<div class="m-pBody">
<ul class="m-nav-ul">
<?php foreach ( $this->getToolbox() as $key => $tbitem ) {
echo $this->makeListItem( $key, $tbitem );
}
wfRunHooks( 'BrlCadTemplateToolboxEnd', array( &$this ) );
wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
?>
</ul>
</div>
</div>
</div>
<!-- tools end here -->
</div>
<!-- first nav container ends here -->
</div>
<!-- Tool box navigation ends here -->
<!-- Views mobile navigation -->
<div class="mobile-nav mobile-nav-views">
<div class="m-nav-container m-nav-views">
<div class="nav-quit"><a class="nav-quit-X" href="#">X</a></div>
<div id="m-p-cactions" class="m-portlet" role="navigation">
<h3><?php $this->msg( 'views' ) ?></h3>
<div class="m-pBody">
<ul class="m-nav-ul"><?php
foreach ( $this->data['content_actions'] as $key => $tab ) {
echo '
' . $this->makeListItem( $key, $tab );
} ?>
</ul>
</div>
</div>
</div>
</div>
<!-- ********* ---->
<!-- the content starts from here -->
<div class="content-wrapper">
<!-- left control bar acts as the wrapper for wiki article's views -->
<div class = "left-control-bar"> <?php $this->cactions(); ?> </div>
<!-- Column content contains the wiki article container used to differentiate
from column-one which is container for sidebar -->
<div class="column-content">
<!-- Notifications from mediawiki shows here -->
<?php if ( $this->data['sitenotice'] ) { ?>
<div id="siteNotice">
<?php $this->html( 'sitenotice' ) ?>
</div>
<?php } ?>
<!-- The wiki article starts from here -->
<div class="content mw-body-primary" role="main">
<a id="top"></a>
<!-- page top bar is a container for on-page navigation, page is the place
where all the content of wiki is stored. It appears currently (feb14,2014)
only on smaller screens -->
<div class="page-top-bar">
<div class="page-nav">
<!-- d is home icon, C is toolbar icon (wrench) and e is quil signifying editing -->
<a class="page-nav-item" id="pn-home" href =
<?php echo $this->data['nav_urls']['mainpage']['href']; ?>
> d </a>
<a class="page-nav-item" id="pn-tools" href ="#"> C </a>
<a class="page-nav-item" id="pn-views" href="#"> e </a>
<a class="page-nav-item" id="pn-brl-cad" href="http://brlcad.org">
<img src=
<?php echo $this->getSkin()->getSkinStylePath( 'images/logo_70.png'); ?>
width="30px" height="30px"
/>
</a>
</div>
<div class ="page-search"> <?php $this->searchbox(); ?> </div>
</div>
<!-- Heading of the wiki article -->
<h1 class="first-heading" lang="<?php
$this->data['pageLanguage'] =
$this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
$this->text( 'pageLanguage' );
?>">
<span dir="auto"><?php $this->html( 'title' ) ?></span>
<!-- Minutes show the number of minutes it would take to read the article
It's value is populated from javascript
TODO: remove minutes div out of <h1>-->
<div id="minutes"></div>
</h1>
<!-- Paragraphs and body of the wiki article -->
<div class=" the-text mw-body">
<div id="content-sub"<?php $this->html( 'userlangattributes' ) ?>>
<?php $this->html( 'subtitle' ) ?></div>
<?php if ( $this->data['undelete'] ) { ?>
<div class="content-sub-2">
<?php $this->html( 'undelete' ) ?>
</div>
<?php } ?>
<?php if ( $this->data['newtalk'] ) { ?>
<div class="user-message">
<?php $this->html( 'newtalk' ) ?>
</div>
<?php } ?>
<div class="jump-to-nav mw-jump">
<?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>
<!-- start content -->
<?php $this->html( 'bodytext' ) ?>
<?php if ( $this->data['catlinks'] ) { $this->html( 'catlinks' ); } ?>
<!-- end content -->
<a id="mw-page-bottom"></a>
<?php if ( $this->data['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?>
<div class="visualClear"></div>
</div> <!-- the-text ends here -->
</div><!-- content ends here -->
</div><!-- column content ends here -->
<!-- Column one is the container for the sidebar -->
<div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
<!-- Main navigation, Search and tools -->
<?php $this->renderPortals( $this->data['sidebar'] ); ?>
<!-- Personal Tools -->
<div class="portlet" id="p-personal" role="navigation">
<h3 id="personal-tools"><?php $this->msg( 'personaltools' ) ?></h3>
<div class="pBody">
<ul class="sidebar-ul"<?php $this->html( 'userlangattributes' ) ?>>
<?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
<?php echo $this->makeListItem( $key, $item ); ?>
<?php } ?>
</ul>
</div>
</div>
</div><!-- end of the sidebar -->
<div class="visualClear"></div>
<?php
$validFooterIcons = $this->getFooterIcons( "icononly" );
$validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
<!-- Footer markup starts here -->
<div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
<?php
$footerEnd = '</div>';
} else {
$footerEnd = '';
}
foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
<div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
<?php foreach ( $footerIcons as $icon ) { ?>
<?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
<?php } ?>
</div>
<?php }
if ( count( $validFooterLinks ) > 0 ) { ?>
<ul id="f-list">
<?php foreach ( $validFooterLinks as $aLink ) { ?>
<li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
<?php } ?>
</ul>
<?php } echo $footerEnd; ?>
</div> <!-- footer ends -->
<!-- SCRIPTS DUNGEON -->
<!-- loading jquery,scrollbar plugin and their dependencies -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- the mousewheel plugin - optional to provide mousewheel support -->
<script type="text/javascript" src="<?php echo $this->getSkin()->getSkinStylePath( 'scripts/jquery.transit.min.js'); ?>"></script>
<!-- script for the toggle navigation menu -->
<script type="text/javascript">
var isMenuOpen = false;
$("#logo").click(function(){
var headHeight = $(".head").height();
if(isMenuOpen)
{
$(".head").animate({
"top":"-"+(headHeight*2)
}, 1000 );
isMenuOpen=false;
}
else
{
$(".head").animate({
"top":"0px"
}, 1000);
isMenuOpen=true;
}
});
</script>
<!-- Script for mobile navigation menus -->
<script type="text/javascript">
$('.mobile-nav a').click(function(){
console.log("done");
$(".mobile-nav").transition({
top:"-1000px"
},700 );
$('body').css({"overflow":"auto"});
});
$('#pn-tools').click(function(){
$(".mobile-nav-toolbox").transition({
"top":"0",
delay:500
},1000);
$('body').css({"overflow":"hidden"});
});
$('#pn-views').click(function(){
$(".mobile-nav-views").transition({
"top":"0",
delay:500
},1000);
$('body').css({"overflow":"hidden"});
});
</script>
<!-- script to initiate scroll on same anchor, credits:css-tricks.com -->
<script type="text/javascript">
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
<!-- script to count the number of minutes it would take to read a wiki page -->
<script type="text/javascript">
var text = $("#mw-content-text").text();
var wordCount = text.replace( /[^\w ]/g, "" ).split( /\s+/ ).length;
var minutesToRead = Math.round(wordCount/300);
$("#minutes").text(minutesToRead + " min read");
</script>
<?php
$this->printTrail();
echo Html::closeElement( 'body' );
echo Html::closeElement( 'html' );
wfRestoreWarnings();
} // end of execute() method
/*************************************************************************************************/
/********** FUNCTIONS DUNGEON exact as from monobook theme **********/
/**
* @param $sidebar array
*/
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 == 'SEARCH' ) {
$this->searchBox();
} elseif ( $boxName == 'TOOLBOX' ) {
$this->toolbox();
} elseif ( $boxName == 'LANGUAGES' ) {
$this->languageBox();
} else {
$this->customBox( $boxName, $content );
}
}
}
function searchBox() {
global $wgUseTwoButtonsSearchForm;
?>
<div id="p-search" class="portlet" role="search">
<h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
<div id="searchBody" class="pBody">
<form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
<input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
<?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
<?php echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
if ( $wgUseTwoButtonsSearchForm ) { ?> 
<?php echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
} else { ?>
<div><a href="<?php $this->text( 'searchaction' ) ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
} ?>
</form>
</div>
</div>
<?php
}
/**
* Prints the cactions bar.
* Shared between MonoBook and Modern
*/
function cactions() {
?>
<div id="p-cactions" class="portlet" role="navigation">
<h3><?php $this->msg( 'views' ) ?></h3>
<div class="pBody">
<ul><?php
foreach ( $this->data['content_actions'] as $key => $tab ) {
echo '
' . $this->makeListItem( $key, $tab );
} ?>
</ul>
</div>
</div>
<?php
}
/*************************************************************************************************/
function toolbox() {
?>
<div class="portlet" id="p-tb" role="navigation">
<h3><?php $this->msg( 'toolbox' ) ?></h3>
<div class="pBody">
<ul>
<?php
foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
<?php echo $this->makeListItem( $key, $tbitem ); ?>
<?php
}
wfRunHooks( 'BrlCadTemplateToolboxEnd', array( &$this ) );
wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
?>
</ul>
</div>
</div>
<?php
}
/*************************************************************************************************/
function languageBox() {
if ( $this->data['language_urls'] ) {
?>
<div id="p-lang" class="portlet" role="navigation">
<h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
<div class="pBody">
<ul>
<?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
<?php echo $this->makeListItem( $key, $langlink ); ?>
<?php } ?>
</ul>
</div>
</div>
<?php
}
}
/*************************************************************************************************/
/**
* @param $bar string
* @param $cont array|string
*/
function customBox( $bar, $cont ) {
$portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ), 'role' => 'navigation' );
$tooltip = Linker::titleAttrib( "p-$bar" );
if ( $tooltip !== false ) {
$portletAttribs['title'] = $tooltip;
}
echo ' ' . Html::openElement( 'div', $portletAttribs );
$msgObj = wfMessage( $bar );
?>
<h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
<div class='pBody'>
<?php if ( is_array( $cont ) ) { ?>
<ul>
<?php foreach ( $cont as $key => $val ) { ?>
<?php echo $this->makeListItem( $key, $val ); ?>
<?php } ?>
</ul>
<?php } else {
# allow raw HTML block to be defined by extensions
print $cont;
}
?>
</div>
</div>
<?php
}
} // end of class