GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#4)
by mw
05:59
created

MainContent::buildMwIndicators()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5.3915

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 22
ccs 5
cts 14
cp 0.357
rs 9.2
cc 3
eloc 14
nc 3
nop 0
crap 5.3915
1
<?php
2
/**
3
 * File holding the MainContent class
4
 *
5
 * This file is part of the MediaWiki skin Chameleon.
6
 *
7
 * @copyright 2013 - 2014, Stephan Gambke
8
 * @license   GNU General Public License, version 3 (or any later version)
9
 *
10
 * The Chameleon skin is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by the Free
12
 * Software Foundation, either version 3 of the License, or (at your option) any
13
 * later version.
14
 *
15
 * The Chameleon skin is distributed in the hope that it will be useful, but
16
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18
 * details.
19
 *
20
 * You should have received a copy of the GNU General Public License along
21
 * with this program. If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 * @file
24
 * @ingroup   Skins
25
 */
26
27
namespace Skins\Chameleon\Components;
28
29
use Skins\Chameleon\IdRegistry;
30
31
/**
32
 * The NavbarHorizontal class.
33
 *
34
 * A horizontal navbar containing the sidebar items.
35
 * Does not include standard items (toolbox, search, language links). They need to be added to the page elsewhere
36
 *
37
 * The navbar is a list of lists wrapped in a nav element: <nav role="navigation" id="p-navbar" >
38
 *
39
 * @author Stephan Gambke
40
 * @since 1.0
41
 * @ingroup Skins
42
 */
43
class MainContent extends Component {
44
45
	/**
46
	 * Builds the HTML code for this component
47
	 *
48
	 * @return String the HTML code
49
	 */
50 8
	public function getHtml() {
51
52 8
		$skintemplate = $this->getSkinTemplate();
53 8
		$idRegistry = IdRegistry::getRegistry();
54
55
		// START content
56
		$ret =
57 8
			$this->indent() . '<!-- start the content area -->' .
58 8
			$this->indent() . $idRegistry->openElement( 'div',
59 8
				array( 'id' => 'content', 'class' => 'mw-body ' . $this->getClassString() )
60 8
			) .
61
62 8
			$idRegistry->element( 'a', array( 'id' => 'top' ) ) .
63 8
			$idRegistry->element( 'div', array( 'id' => 'mw-indicators' ), $this->buildMwIndicators() ) .
64
65 8
			$this->indent() . '<div ' . \Html::expandAttributes( array(
66 8
					'id'    => $idRegistry->getId( 'mw-js-message' ),
67
					'style' => 'display:none;'
68 8
				)
69 8
			) . $skintemplate->get( 'userlangattributes' ) . '></div>';
70
71 8
		$ret .= $this->buildContentHeader();
72 8
		$ret .= $this->buildContentBody();
73 8
		$ret .= $this->buildCategoryLinks();
74
75 8
		$ret .= $this->indent( -1 ) . '</div>' . "\n";
76
		// END content
77
78 8
		return $ret;
79
	}
80
81
	/**
82
	 * @return string
83
	 */
84 8
	protected function buildContentHeader() {
85
86 8
		$skintemplate = $this->getSkinTemplate();
87 8
		$idRegistry = IdRegistry::getRegistry();
88
89 8
		$ret = $this->indent( 1 ) . '<div class ="contentHeader">' .
90
91 8
			$this->indent( 1 ) . '<!-- title of the page -->' .
92 8
			$this->indent() . $idRegistry->element( 'h1', array( 'id' => 'firstHeading', 'class' => 'firstHeading' ), $skintemplate->get( 'title' ) ) .
93
94 8
			$this->indent() . '<!-- tagline; usually goes something like "From WikiName" primary purpose of this seems to be for printing to identify the source of the content -->' .
95 8
			$this->indent() . $idRegistry->element( 'div', array( 'id'=> 'siteSub' ), $skintemplate->getMsg( 'tagline' )->escaped() );
96
97 8 View Code Duplication
		if ( $skintemplate->get( 'subtitle' ) ) {
98
99
			// TODO: should not use class 'small', better use class 'contentSub' and do styling in a less file
100
			$ret .=
101 8
				$this->indent() . '<!-- subtitle line; used for various things like the subpage hierarchy -->' .
102 8
				$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub', 'class' => 'small' ), $skintemplate->get( 'subtitle' ) );
103
104 8
		}
105
106 8 View Code Duplication
		if ( $skintemplate->get( 'undelete' ) ) {
107
			// TODO: should not use class 'small', better use class 'contentSub2' and do styling in a less file
108
			$ret .=
109 8
				$this->indent() . '<!-- undelete message -->' .
110 8
				$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub2', 'class' => 'small' ), $skintemplate->get( 'undelete' ) );
111 8
		}
112
113
		// TODO: Do we need this? Seems to be an accessibility thing. It's used in vector to jump to the nav wich is at the bottom of the document, but our nav is usually at the top
114 8
		$ret .= $idRegistry->element( 'div', array( 'id' => 'jump-to-nav', 'class' => 'mw-jump' ),
115 8
			$skintemplate->getMsg( 'jumpto' )->escaped() . '<a href="#mw-navigation">' . $skintemplate->getMsg( 'jumptonavigation' )->escaped() . '</a>' .
116 8
			$skintemplate->getMsg( 'comma-separator' )->escaped() . '<a href="#p-search">' . $skintemplate->getMsg( 'jumptosearch' )->escaped() . '</a>'
117 8
		);
118
119 8
		$ret .= $this->indent( -1 ) . '</div>';
120 8
		return $ret;
121
	}
122
123
	/**
124
	 * @return string
125
	 */
126 8
	protected function buildContentBody() {
127 8
		return IdRegistry::getRegistry()->element( 'div', array( 'id' => 'bodyContent' ),
128 8
			$this->indent() . '<!-- body text -->' . "\n" .
129 8
			$this->indent() . $this->getSkinTemplate()->get( 'bodytext' ) .
130 8
			$this->buildDataAfterContent()
131 8
		);
132
	}
133
134
	/**
135
	 * @return string
136
	 */
137 8
	protected function buildCategoryLinks() {
138
		// TODO: Category links should be a separate component, but
139
		// * dataAfterContent should come after the the category links.
140
		// * only one extension is known to use it dataAfterContent and it is geared specifically towards MonoBook
141
		// => provide an attribut hideCatLinks for the XML and -if present- hide category links and assume somebody knows what they are doing
142
		return
143 8
			$this->indent() . '<!-- category links -->' .
144 8
			$this->indent() . $this->getSkinTemplate()->get( 'catlinks' );
145
	}
146
147
	/**
148
	 * @return string
149
	 */
150 8
	protected function buildDataAfterContent() {
151
152 8
		$skinTemplate = $this->getSkinTemplate();
153
154 8
		if ( $skinTemplate->get( 'dataAfterContent' ) ) {
155
			return
156 8
				$this->indent() . '<!-- data blocks which should go somewhere after the body text, but not before the catlinks block-->' .
157 8
				$this->indent() . $skinTemplate->get( 'dataAfterContent' );
158
		}
159
160
		return '';
161
	}
162
163
	/**
164
	 * @return string
165
	 */
166 8
	private function buildMwIndicators() {
167
168 8
		$html = '';
169 8
		$indicators = $this->getSkinTemplate()->get( 'indicators' );
170
171 8
		if ( !is_array( $indicators ) ) {
172 8
			return $html;
173
		}
174
175
		foreach ( $indicators as $id => $content ) {
176
			$html .= \Html::rawElement(
177
				'div',
178
				array(
179
					'id' => \Sanitizer::escapeId( "mw-indicator-$id" ),
180
					'class' => 'mw-indicator',
181
				),
182
				$content
183
			) . "\n";
184
		}
185
186
		return $html;
187
	}
188
189
}
190