aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2019-01-21 16:41:00 -0500
committerBrian Evans <grknight@gentoo.org>2019-01-26 10:47:45 -0500
commit62fee4d3cef35badfa006adef966dea84669eb4e (patch)
treede884f19288c727c60e0903712e76e0cfe027545
parentAdd README file. (diff)
downloadskin-tyrian-62fee4d3cef35badfa006adef966dea84669eb4e.tar.gz
skin-tyrian-62fee4d3cef35badfa006adef966dea84669eb4e.tar.bz2
skin-tyrian-62fee4d3cef35badfa006adef966dea84669eb4e.zip
Optimize code a bitHEADv1.30.1.2master
Signed-off-by: Brian Evans <grknight@gentoo.org>
-rw-r--r--TyrianTemplate.php138
1 files changed, 66 insertions, 72 deletions
diff --git a/TyrianTemplate.php b/TyrianTemplate.php
index 0598f76..2f12ff4 100644
--- a/TyrianTemplate.php
+++ b/TyrianTemplate.php
@@ -7,7 +7,7 @@
* Copyright (C) 2016-2019 Gentoo wiki project <wiki@gentoo.org>
*/
class TyrianTemplate extends BaseTemplate {
- function execute() {
+ public function execute() {
wfSuppressWarnings();
$this->html( 'headelement' );
@@ -20,41 +20,42 @@ class TyrianTemplate extends BaseTemplate {
<div class="col-md-12">
<div id="content" class="mw-body" role="main">
<a id="top"></a>
- <?php if ( $this->data['sitenotice'] ) { ?>
- <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
- <?php } ?>
+ <?php if ( $this->data['sitenotice'] ) {
+ echo '<div id="siteNotice">'; $this->html( 'sitenotice' ); echo '</div>';
+ } ?>
<h1 id="firstHeading" class="first-header" lang="<?php $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); $this->text( 'pageLanguage' ); ?>">
- <span dir="auto"><?php $this->html( 'title' ) ?></span>
+ <span dir="auto"><?php $this->html( 'title' ); ?></span>
</h1>
<div id="bodyContent" class="mw-body-content">
<div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
- <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>>
+ <div id="contentSub"<?php $this->html( 'userlangattributes' ); ?>>
<?php $this->html( 'subtitle' ) ?>
</div>
- <?php if ( $this->data['undelete'] ) { ?>
- <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
- <?php } ?>
- <?php if ( $this->data['newtalk'] ) { ?>
- <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
- <?php } ?>
+ <?php if ( $this->data['undelete'] ) {
+ echo '<div id="contentSub2">'; $this->html( 'undelete' ); echo '</div>';
+ }
+ if ( $this->data['newtalk'] ) {
+ echo '<div class="usermessage">'; $this->html( 'newtalk' ); echo '</div>';
+ } ?>
<div id="jump-to-nav" class="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>
+ <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'] ) { ?>
- <?php $this->html( 'catlinks' ); ?>
- <?php } ?>
- <!-- end content -->
-
- <?php if ( $this->data['dataAfterContent'] ) {
- $this->html( 'dataAfterContent' );
- } ?>
+ <?php $this->html( 'bodytext' );
+ if ( $this->data['catlinks'] ) {
+ $this->html( 'catlinks' );
+ }
+ //<!-- end content -->
+
+ if ( $this->data['dataAfterContent'] ) {
+ $this->html( 'dataAfterContent' );
+ }
+ ?>
</div>
</div>
</div>
@@ -77,10 +78,10 @@ class TyrianTemplate extends BaseTemplate {
/*************************************************************************************************/
- function header() {
+ private function header() {
?>
<div class="mw-jump sr-only">
- <?php $this->msg( 'jumpto' ) ?>
+ <?php $this->msg( 'jumpto' ); ?>
<a href="#top">content</a>
</div>
<header>
@@ -151,7 +152,7 @@ class TyrianTemplate extends BaseTemplate {
<?php
}
- function footer() {
+ private function footer() {
$validFooterIcons = $this->getFooterIcons( "icononly" );
$validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
?>
@@ -159,15 +160,15 @@ class TyrianTemplate extends BaseTemplate {
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-offset-2 col-md-7">
- <?php if ( count( $validFooterLinks ) > 0 ) { ?>
+ <?php if ( count( $validFooterLinks ) > 0 ): ?>
<div class="spacer"></div>
<ul id="f-list">
- <?php foreach ( $validFooterLinks as $aLink ) { ?>
- <?php if ($aLink === 'copyright') continue; ?>
- <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
- <?php } ?>
+ <?php foreach ( $validFooterLinks as $aLink ) {
+ if ($aLink === 'copyright') continue;
+ echo "<li id=\"{$aLink}>\">"; $this->html( $aLink ); echo '</li>';
+ } ?>
</ul>
- <?php } ?>
+ <?php endif; ?>
</div>
<div class="col-xs-12 col-md-3">
<!-- No questions or comments, the Wiki has enough information on how to contact us. -->
@@ -200,37 +201,31 @@ class TyrianTemplate extends BaseTemplate {
/**
* @param array $sidebar
*/
- protected function renderPortals( $sidebar ) {
+ protected function renderPortals( array $sidebar ) {
// These are already rendered elsewhere
$sidebar['SEARCH'] = false;
$sidebar['TOOLBOX'] = false;
$sidebar['LANGUAGES'] = false;
- foreach ( $sidebar as $boxName => $content ) {
- if ( $content === false ) {
- continue;
- }
-
- $this->customBox( $boxName, $content );
- }
+ array_walk($sidebar, [$this, 'customBox'] );
}
- function searchBox() {
+ private function searchBox() {
?>
<form action="<?php $this->text( 'wgScript' ) ?>" id="searchform" class="navbar-form navbar-right" role="search">
<input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
<div class="input-group">
- <?php echo $this->makeSearchInput( array( "id" => "searchInput", "class" => "form-control", "placeholder" => $this->getMsg( 'search' )->escaped() ) ); ?>
+ <?php echo $this->makeSearchInput( [ "id" => "searchInput", "class" => "form-control", "placeholder" => $this->getMsg( 'search' )->escaped() ] ); ?>
<div class="input-group-btn"><?php
echo $this->makeSearchButton(
"go",
- array( "id" => "searchGoButton", "class" => "searchButton btn btn-default" )
+ [ "id" => "searchGoButton", "class" => "searchButton btn btn-default" ]
);
echo $this->makeSearchButton(
"fulltext",
- array( "id" => "mw-searchButton", "class" => "searchButton btn btn-default" )
+ [ "id" => "mw-searchButton", "class" => "searchButton btn btn-default" ]
);
?></div>
</div>
@@ -238,33 +233,30 @@ class TyrianTemplate extends BaseTemplate {
<?php
}
- function cactions() {
- $context_actions = array();
- $primary_actions = array();
- $secondary_actions = array();
+ private function cactions() {
+ $context_actions = [];
+ $primary_actions = [];
+ $secondary_actions = [];
+
+ $assign_active = function(array &$actionTab) {
+ if ( strpos( $actionTab['class'], 'selected' ) !== false ) {
+ $actionTab['class'] .= ' active';
+ }
+ };
foreach ( $this->data['content_actions'] as $key => $tab ) {
// TODO: handling form_edit separately here is a hack, no idea how it works in Vector.
if ( isset($tab['primary']) && $tab['primary'] == '1' || $key == 'form_edit' || $key == 'formedit' ) {
if ( isset($tab['context']) ) {
$context_actions[$key] = $tab;
-
- if ( strpos( $tab['class'], 'selected' ) !== false ) {
- $context_actions[$key]['class'] .= ' active';
- }
+ $assign_active($context_actions[$key]);
} else {
$primary_actions[$key] = $tab;
-
- if ( strpos( $tab['class'], 'selected' ) !== false ) {
- $primary_actions[$key]['class'] .= ' active';
- }
+ $assign_active($primary_actions[$key]);
}
} else {
$secondary_actions[$key] = $tab;
-
- if ( strpos( $tab['class'], 'selected' ) !== false ) {
- $secondary_actions[$key]['class'] .= ' active';
- }
+ $assign_active($secondary_actions[$key]);
}
}
?>
@@ -313,7 +305,7 @@ class TyrianTemplate extends BaseTemplate {
}
/*************************************************************************************************/
- function toolbox() {
+ private function toolbox() {
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-cog"></i> <?php $this->msg( 'toolbox' ) ?> <span class="caret"></span></a>
@@ -323,8 +315,8 @@ class TyrianTemplate extends BaseTemplate {
echo $this->makeListItem( $key, $tbitem );
}
- wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
- wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
+ wfRunHooks( 'MonoBookTemplateToolboxEnd', [&$this] );
+ wfRunHooks( 'SkinTemplateToolboxEnd', [ &$this, true ] );
?>
</ul>
</li>
@@ -332,13 +324,13 @@ class TyrianTemplate extends BaseTemplate {
}
/*************************************************************************************************/
- function personaltools() {
+ private function personaltools() {
$personal_tools = $this->getPersonalTools();
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
- <span class="glyphicon glyphicon-user" aria-label="<?php $this->msg( 'personaltools' ) ?>"></span>
+ <span class="fa fa-user" aria-label="<?php $this->msg( 'personaltools' ) ?>"></span>
<?php
if (isset($personal_tools['userpage'])) {
echo $personal_tools['userpage']['links'][0]['text'];
@@ -379,17 +371,16 @@ class TyrianTemplate extends BaseTemplate {
}
/*************************************************************************************************/
- function languageBox() {
- if ( $this->data['language_urls'] !== false ) {
+ private function languageBox() {
+ if ( $this->data['language_urls'] !== false ):
?>
<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
+ <?php foreach ( $this->data['language_urls'] as $key => $langlink ) {
+ echo $this->makeListItem( $key, $langlink );
}
?>
</ul>
@@ -398,7 +389,7 @@ class TyrianTemplate extends BaseTemplate {
</div>
</div>
<?php
- }
+ endif;
}
/*************************************************************************************************/
@@ -406,7 +397,10 @@ class TyrianTemplate extends BaseTemplate {
* @param string $bar
* @param array|string $cont
*/
- function customBox( $bar, $cont ) {
+ private function customBox( $cont, $bar ) {
+ if ($cont === false) {
+ return;
+ }
$msgObj = wfMessage( $bar );
if ( $bar !== 'navigation' ) { ?>