Passed
Push — master ( e8f075...8ec226 )
by Tom
10:19
created

Pivot.skin.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Skin file for Pivot 
5
 *
6
 * @file
7
 * @ingroup Skins
8
 */
9
 
10
11
class SkinPivot extends SkinTemplate {
12
	public $skinname = 'pivot', $stylename = 'pivot', $template = 'pivotTemplate', $useHeadElement = true;
13
	
14
	public function setupSkinUserCss(OutputPage $out) {
15
		parent::setupSkinUserCss($out);
16
    	global $wgLocalStylePath;
17
		global $wgPivotFeatures;
18
		$wgPivotFeaturesDefaults = array(
19
			'showActionsForAnon' => true,
20
			'fixedNavBar' => false,
21
			'usePivotTabs' => false,
22
			'showHelpUnderTools' => true,
23
			'showRecentChangesUnderTools' => true,
24
			'wikiName' => &$GLOBALS['wgSitename'],
25
			'wikiNameDesktop' => &$GLOBALS['wgSitename'],
26
			'navbarIcon' => false,
27
			'preloadFontAwesome' => false,
28
			'showFooterIcons' => false,
29
			'addThisPUBID' => '',
30
			'useAddThisShare' => '',
31
			'useAddThisFollow' => ''
32
		);
33
		foreach ($wgPivotFeaturesDefaults as $fgOption => $fgOptionValue) {
34
			if ( !isset($wgPivotFeatures[$fgOption]) ) {
35
				$wgPivotFeatures[$fgOption] = $fgOptionValue;
36
			}
37
		}
38
		
39
		if ( $wgPivotFeatures['preloadFontAwesome'] ) {
40
			$out->addHeadItem('font', '<link rel="preload" href="'.$wgLocalStylePath.'/pivot/assets/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" type="font/woff2" crossorigin="anonymous" />');
41
		}
42
		
43
		$out->addModuleStyles('skins.pivot.styles');
44
45
	}
46
	
47
	public function initPage(OutputPage $out) {
48
		global $wgLocalStylePath;
49
		parent::initPage($out);
50
51
		$viewport_meta = 'width=device-width, user-scalable=yes, initial-scale=1.0';
52
		$out->addMeta('viewport', $viewport_meta);
53
		$out->addModules('skins.pivot.js');
54
	}
55
56
}
57
58
59
class pivotTemplate extends BaseTemplate {
60
	public function execute() {
61
		global $wgUser;
62
		global $wgPivotFeatures;
63
		Wikimedia\suppressWarnings();
64
		$this->html('headelement');
65
		switch ($wgPivotFeatures['usePivotTabs']) {
66
			case true:
67
			    ob_start();
68
				$this->html('bodytext');
69
				$out = ob_get_contents();
70
				ob_end_clean();
71
				$markers = array("&lt;a", "&lt;/a", "&gt;");
72
				$tags = array("<a", "</a", ">");
73
				$body = str_replace($markers, $tags, $out);
74
				break;	
75
			default:
76
				$body = '';
77
				break;
78
		}
79
		switch ($wgPivotFeatures['showFooterIcons']) {
80
			case true:
81
				$poweredbyType = "icononly";
82
				$poweredbyMakeType = 'withImage';
83
				break;
84
			default:
85
				$poweredbyType = "nocopyright";
86
				$poweredbyMakeType = 'withoutImage';
87
				break;	
88
		}
89
90
?>
91
<!-- START PIVOTTEMPLATE -->
92
		<div class="off-canvas-wrap docs-wrap" data-offcanvas="">
93
			<div class="inner-wrap">
94
				<?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "<div class='fixed'>"; ?>
95
				<nav class="tab-bar hide-for-print">
96
					<section id="left-nav-aside" class="left-small show-for-small">
97
						<a href="#" class="left-off-canvas-toggle"><span id="menu-user"><i class="fa fa-navicon fa-lg"></i></span></a>
98
					</section>
99
					
100
					<section id="middle-nav" class="middle tab-bar-section">
101
						<div class="title"><a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>">
102
					<span class="show-for-medium-up"><?php echo $wgPivotFeatures['wikiNameDesktop']; ?></span>
103
						<span class="show-for-small-only">
104
						<?php if ($wgPivotFeatures['navbarIcon'] != false) { ?>
105
							<img alt="<?php echo $this->text('sitename'); ?>" src="<?php echo $this->text('logopath'); ?>" style="max-width: 64px;height:auto; max-height:36px; display: inline-block; vertical-align:middle;">
106
								<?php } ?>
107
						<?php echo $wgPivotFeatures['wikiName']; ?></span></a></div>
108
					</section>
109
					
110
					<section id="right-nav-aside" class="right-small">
111
					<a href="#" class="right-off-canvas-toggle"><span id="menu-user"><i class="fa <?php if ($wgUser->isLoggedIn()): ?>fa-user<?php else: ?>fa-navicon<?php endif; ?> fa-lg"></i></span></a>
112
					</section>
113
				</nav>
114
				<?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "</div>"; ?>
115
				    <aside class="left-off-canvas-menu">
116
      					<ul class="off-canvas-list">
117
						
118
								<li class="has-form">
119
									<form action="<?php $this->text( 'wgScript' ); ?>" id="searchform-sidebar" class="mw-search">
120
										<div class="row collapse">
121
											<div class="small-12 columns">
122
												<input type="search" name="search" placeholder="<?php echo wfMessage( 'search' )->text() ?>" title="Search [alt-shift-f]" accesskey="f" id="searchInput" autocomplete="off">
123
											</div>
124
										</div>
125
									</form>
126
								</li>
127
								
128
							<?php $this->renderSidebar() ?>
129
						</ul>
130
					</aside>
131
					
132
					<aside class="right-off-canvas-menu">
133
					  <ul class="off-canvas-list">
134
					<?php if ($wgUser->isLoggedIn()): ?>
135
						<li id="personal-tools"><label><?php echo wfMessage( 'pivot-personal-tools' )->text() ?></label></li>
136
						<?php foreach ($this->getPersonalTools() as $key => $item) { echo $this->makeListItem($key, $item); } ?>
137
							<?php else: ?>
138
								<?php foreach ($this->getPersonalTools() as $key => $item) { echo $this->makeListItem($key, $item); } ?>
139
							<?php endif; ?>
140
					  </ul>
141
					</aside>
142
143
					<section id="main-section" class="main-section" <?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "style='margin-top:2.8125em'"; ?>>
144
					
145
						<div id="page-content">
146
							
147
							<div id="mw-js-message" style="display:none;"></div>
148
149
							<div class="row">
150
								
151
								<div id="sidebar" class="large-2 medium-3 columns hide-for-small hide-for-print">
152
										<ul class="side-nav">
153
											<li class="name logo">
154
											<a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>">
155
												<img alt="<?php echo $this->text('sitename'); ?>" src="<?php echo $this->text('logopath') ?>" style="max-width: 100%;height: auto;display: inline-block; vertical-align: middle;"></a>		
156
											</li>
157
											<li class="has-form">
158
												<form action="<?php $this->text( 'wgScript' ); ?>" id="searchform-offCanvas" class="mw-search">
159
													<div class="row collapse">
160
														<div class="small-12 columns">
161
															<input type="search" name="search" placeholder="<?php echo wfMessage( 'search' )->text() ?>" title="Search [alt-shift-f]" accesskey="f" class="mw-searchInput" autocomplete="off">
162
														</div>
163
													</div>
164
												</form>
165
											</li>
166
								
167
											<?php $this->renderSidebar() ?>
168
										</ul>
169
								</div>
170
								
171
								<div id="p-cactions" class="large-10 medium-9 columns">
172
								
173
									<div class="row">
174
										<div class="large-12 columns">
175
												<!-- Output page indicators -->
176
												<?php echo $this->getIndicators(); ?>
177
												<!-- If user is logged in output echo location -->
178
												<?php if ($wgUser->isLoggedIn()): ?>
179
												<div id="echo-notifications">
180
												<div id="echo-notifications-alerts"></div>
181
												<div id="echo-notifications-messages"></div>
182
												<div id="echo-notifications-notice"></div>
183
												</div>
184
												<?php endif; ?>
185
												<!--[if lt IE 9]>
186
												<div id="siteNotice" class="sitenotice"><?php echo $this->text('sitename') . ' '. wfMessage( 'pivot-browsermsg' )->text(); ?></div>
187
												<![endif]-->
188
189
												<?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice" class="sitenotice"><?php $this->html( 'sitenotice' ); ?></div><?php } ?>
190
												<?php if ( $this->data['newtalk'] ) { ?><div id="usermessage" class="newtalk"><?php $this->html( 'newtalk' ); ?></div><?php } ?>
191
										</div>
192
									</div>
193
								
194
									<?php if ($wgUser->isLoggedIn() || $wgPivotFeatures['showActionsForAnon']): ?>
195
										<a href="#" data-options="align:left" data-dropdown="drop1" class="button secondary small radius pull-right hide-for-print" id="drop"><i class="fa fa-navicon fa-lg"><span id="page-actions" class="show-for-medium-up">&nbsp;<?php echo wfMessage( 'actions' )->text() ?></span></i></a>
196
										<ul id="drop1" class="tiny content f-dropdown" data-dropdown-content>
197
											<?php foreach($this->data['content_actions'] as $key => $tab) { echo preg_replace(array('/\sprimary="1"/', '/\scontext="[a-z]+"/', '/\srel="archives"/'),'',$this->makeListItem($key, $tab)); } ?>
198
											<?php Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ));  ?>
199
										</ul>
200
201
									<?php endif;
202
									$namespace = str_replace('_', ' ', $this->getSkin()->getTitle()->getNsText());
203
									$displaytitle = $this->data['title'];
204
									if (!empty($namespace)) {
205
										$pagetitle = $this->getSkin()->getTitle();
206
										$newtitle = str_replace($namespace.':', '', $pagetitle);
207
										$displaytitle = str_replace($pagetitle, $newtitle, $displaytitle);
208
									?><h4 class="namespace label"><?php print $namespace; ?></h4><?php } ?>
209
									<div id="content">
210
									<h1 class="title"><?php print $displaytitle; ?></h1>
211
											<?php if ($wgPivotFeatures['useAddThisShare'] !== '') { ?>
212
											<!-- Go to www.addthis.com/dashboard to customize your tools -->
213
											<div class="<?php echo $wgPivotFeatures['useAddThisShare']; ?> hide-for-print"></div>
214
											<!-- Go to www.addthis.com/dashboard to customize your tools -->
215
											<?php } ?>
216
									<?php if ( $this->data['isarticle'] ) { ?><h3 id="tagline"><?php $this->msg( 'tagline' ) ?></h3><?php } ?>
217
									<?php if ( $this->html('subtitle') ) { ?><h5 id="sitesub" class="subtitle"><?php $this->html('subtitle') ?></h5><?php } ?>
218
									<div id="contentSub" class="clear_both"></div>
219
									<div id="bodyContent" class="mw-bodytext">
220
									<?php 
221
									switch ($wgPivotFeatures['usePivotTabs']) {
222
										case true:
223
											echo $body;
224
											break;
225
										default:
226
										$this->html('bodytext');
227
											break;
228
											}
229
									?>
230
									<div class="clear_both"></div>
231
									</div>
232
									</div>
233
									<div id="categories" class="row">
234
										<div class="small-12 columns">
235
											<div class="group"><?php $this->html('catlinks'); ?></div>
236
											<?php $this->html('dataAfterContent'); ?>
237
										</div>
238
									</div>	
239
													
240
									<footer class="row">
241
242
										<div id="footer">
243
											<div id="div-footer-left" class="small-12 medium-8 large-9 columns">
244
											<ul id="footer-left">
245
												<?php foreach ($this->getFooterLinks("flat") as $key) { ?>
246
													<li id="footer-<?php echo $key ?>"><?php $this->html($key) ?></li>
247
												<?php } ?>									
248
											</ul>
249
											</div>	
250
											<div id="footer-right-icons" class="small-12 medium-4 large-3 columns hide-for-print">
251
											<ul id="footer-right">
252
												<li class="social-follow hide-for-print">
253
													<?php if ($wgPivotFeatures['useAddThisFollow'] !== '') { ?>
254
														<div class="social-links">
255
															<!-- Go to www.addthis.com/dashboard to customize your tools -->
256
															<div class="<?php echo $wgPivotFeatures['useAddThisFollow']; ?> hide-for-print"></div>
257
														</div>
258
													<?php } ?>
259
												</li>
260
												<?php foreach ($this->getFooterIcons($poweredbyType) as $blockName => $footerIcons) { ?>
261
													<li class="<?php echo $blockName ?>"><?php foreach ($footerIcons as $icon) { ?>
262
														<?php echo $this->getSkin()->makeFooterIcon($icon, $poweredbyMakeType); ?>
263
														<?php } ?>
264
													</li>
265
												<?php } ?>
266
											</ul>
267
											</div>		
268
										</div>			
269
									</footer>
270
								
271
								</div>
272
						</div>
273
					</div>
274
						
275
				</section>
276
				
277
			</div>
278
		</div>
279
		<div>
280
			<a class="exit-off-canvas"></a>	
281
		</div>
282
		
283
		
284
		<?php $this->printTrail(); ?>
285
286
			<?php if ($this->data['isarticle'] && $wgPivotFeatures['addThisPUBID'] !== '') { ?>
287
				<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<?php echo $wgPivotFeatures['addThisPUBID']; ?>" async="async"></script>
288
			<?php } ?>	
289
		</body>
290
		</html>
291
292
<?php
293
		Wikimedia\restoreWarnings();
294
		
295
	}
296
	
297
	function renderSidebar() { 
298
		$sidebar = $this->getSidebar();
299
		foreach ($sidebar as $boxName => $box) { 
300
			echo '<li><label class="sidebar" id="'.Sanitizer::escapeId( $box['id'] ).'"';echo Linker::tooltip( $box['id'] ).'>'.htmlspecialchars( $box['header'] ).'</label></li>';
0 ignored issues
show
The type Linker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
301
					if ( is_array( $box['content'] ) ) {
302
							foreach ($box['content'] as $key => $item) { echo $this->makeListItem($key, $item); }
303
								} 
304
							}
305
		return;	}	
306
}
307
?>
308