Passed
Pull Request — master (#116)
by
unknown
01:13
created

Pivot.skin.php (6 issues)

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 function getDefaultModules() {
13
		global $wgPivotFeatures;
14
		$wgPivotFeaturesDefaults = array(
15
			'showActionsForAnon' => true,
16
			'fixedNavBar' => false,
17
			'usePivotTabs' => false,
18
			'showHelpUnderTools' => true,
19
			'showRecentChangesUnderTools' => true,
20
			'wikiName' => &$GLOBALS['wgSitename'],
21
			'wikiNameDesktop' => &$GLOBALS['wgSitename'],
22
			'navbarIcon' => false,
23
			'preloadFontAwesome' => false,
24
			'showFooterIcons' => false,
25
			'addThisPUBID' => '',
26
			'useAddThisShare' => '',
27
			'useAddThisFollow' => ''
28
		);
29
		foreach ($wgPivotFeaturesDefaults as $fgOption => $fgOptionValue) {
30
			if ( !isset($wgPivotFeatures[$fgOption]) ) {
31
				$wgPivotFeatures[$fgOption] = $fgOptionValue;
32
			}
33
		}
34
		
35
		if ( $wgPivotFeatures['preloadFontAwesome'] ) {
36
			$this->getOutput()->addHeadItem('font', '<link rel="preload" href="'.$wgLocalStylePath.'/pivot/assets/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" type="font/woff2" crossorigin="anonymous" />');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $wgLocalStylePath seems to be never defined.
Loading history...
37
		}
38
		return parent::getDefaultModules();
39
	}
40
}
41
42
43
class PivotTemplate extends BaseTemplate {
44
	public function execute() {
45
		global $wgUser;
46
		global $wgPivotFeatures;
47
		Wikimedia\suppressWarnings();
0 ignored issues
show
The function suppressWarnings was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
		/** @scrutinizer ignore-call */ 
48
  Wikimedia\suppressWarnings();
Loading history...
48
		switch ($wgPivotFeatures['usePivotTabs']) {
49
			case true:
50
			    ob_start();
51
				$this->html('bodytext');
52
				$out = ob_get_contents();
53
				ob_end_clean();
54
				$markers = array("&lt;a", "&lt;/a", "&gt;");
55
				$tags = array("<a", "</a", ">");
56
				$body = str_replace($markers, $tags, $out);
57
				break;	
58
			default:
59
				$body = '';
60
				break;
61
		}
62
		switch ($wgPivotFeatures['showFooterIcons']) {
63
			case true:
64
				$poweredbyType = "icononly";
65
				$poweredbyMakeType = 'withImage';
66
				break;
67
			default:
68
				$poweredbyType = "nocopyright";
69
				$poweredbyMakeType = 'withoutImage';
70
				break;	
71
		}
72
73
?>
74
<!-- START PIVOTTEMPLATE -->
75
		<div class="off-canvas-wrap docs-wrap" data-offcanvas="">
76
			<div class="inner-wrap">
77
				<?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "<div class='fixed'>"; ?>
78
				<nav class="tab-bar hide-for-print">
79
					<section id="left-nav-aside" class="left-small show-for-small">
80
						<a href="#" class="left-off-canvas-toggle"><span id="menu-user"><i class="fa fa-navicon fa-lg"></i></span></a>
81
					</section>
82
					
83
					<section id="middle-nav" class="middle tab-bar-section">
84
						<div class="title"><a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>">
85
					<span class="show-for-medium-up"><?php echo $wgPivotFeatures['wikiNameDesktop']; ?></span>
86
						<span class="show-for-small-only">
87
						<?php if ($wgPivotFeatures['navbarIcon'] != false) { ?>
88
							<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;">
89
								<?php } ?>
90
						<?php echo $wgPivotFeatures['wikiName']; ?></span></a></div>
91
					</section>
92
					
93
					<section id="right-nav-aside" class="right-small">
94
					<a href="#" class="right-off-canvas-toggle"><span id="menu-user"><i class="fa <?php if ($wgUser->isRegistered()): ?>fa-user<?php else: ?>fa-navicon<?php endif; ?> fa-lg"></i></span></a>
95
					</section>
96
				</nav>
97
				<?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "</div>"; ?>
98
				    <aside class="left-off-canvas-menu">
99
      					<ul class="off-canvas-list">
100
						
101
								<li class="has-form">
102
									<form action="<?php $this->text( 'wgScript' ); ?>" id="searchform-sidebar" class="mw-search">
103
										<div class="row collapse">
104
											<div class="small-12 columns">
105
												<input type="search" name="search" placeholder="<?php echo wfMessage( 'search' )->text() ?>" title="Search [alt-shift-f]" accesskey="f" id="searchInput" autocomplete="off">
106
											</div>
107
										</div>
108
									</form>
109
								</li>
110
								
111
							<?php $this->renderSidebar() ?>
112
						</ul>
113
					</aside>
114
					
115
					<aside class="right-off-canvas-menu">
116
					  <ul class="off-canvas-list">
117
					<?php if ($wgUser->isRegistered()): ?>
118
						<li id="personal-tools"><label><?php echo wfMessage( 'pivot-personal-tools' )->text() ?></label></li>
119
						<?php foreach ($this->getPersonalTools() as $key => $item) { echo $this->makeListItem($key, $item); } ?>
120
							<?php else: ?>
121
								<?php foreach ($this->getPersonalTools() as $key => $item) { echo $this->makeListItem($key, $item); } ?>
122
							<?php endif; ?>
123
					  </ul>
124
					</aside>
125
126
					<section id="main-section" class="main-section" <?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "style='margin-top:2.8125em'"; ?>>
127
					
128
						<div id="page-content">
129
							
130
							<div id="mw-js-message" style="display:none;"></div>
131
132
							<div class="row">
133
								
134
								<div id="sidebar" class="large-2 medium-3 columns hide-for-small hide-for-print">
135
										<ul class="side-nav">
136
											<li class="name logo">
137
											<a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>">
138
												<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>		
139
											</li>
140
											<li class="has-form">
141
												<form action="<?php $this->text( 'wgScript' ); ?>" id="searchform-offCanvas" class="mw-search">
142
													<div class="row collapse">
143
														<div class="small-12 columns">
144
															<input type="search" name="search" placeholder="<?php echo wfMessage( 'search' )->text() ?>" title="Search [alt-shift-f]" accesskey="f" class="mw-searchInput" autocomplete="off">
145
														</div>
146
													</div>
147
												</form>
148
											</li>
149
								
150
											<?php $this->renderSidebar() ?>
151
										</ul>
152
								</div>
153
								
154
								<div id="p-cactions" class="large-10 medium-9 columns">
155
								
156
									<div class="row">
157
										<div class="large-12 columns">
158
												<!-- Output page indicators -->
159
												<?php echo $this->getIndicators(); ?>
160
												<!-- If user is logged in output echo location -->
161
												<?php if ($wgUser->isRegistered()): ?>
162
												<div id="echo-notifications">
163
												<div id="echo-notifications-alerts"></div>
164
												<div id="echo-notifications-messages"></div>
165
												<div id="echo-notifications-notice"></div>
166
												</div>
167
												<?php endif; ?>
168
												<!--[if lt IE 9]>
169
												<div id="siteNotice" class="sitenotice"><?php echo $this->text('sitename') . ' '. wfMessage( 'pivot-browsermsg' )->text(); ?></div>
170
												<![endif]-->
171
172
												<?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice" class="sitenotice"><?php $this->html( 'sitenotice' ); ?></div><?php } ?>
173
												<?php if ( $this->data['newtalk'] ) { ?><div id="usermessage" class="newtalk"><?php $this->html( 'newtalk' ); ?></div><?php } ?>
174
										</div>
175
									</div>
176
								
177
									<?php if ($wgUser->isRegistered() || $wgPivotFeatures['showActionsForAnon']): ?>
178
										<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>
179
										<ul id="drop1" class="tiny content f-dropdown" data-dropdown-content>
180
											<?php foreach($this->data['content_actions'] as $key => $tab) { echo preg_replace(array('/\sprimary="1"/', '/\scontext="[a-z]+"/', '/\srel="archives"/'),'',$this->makeListItem($key, $tab)); } ?>
181
											<?php Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ));  ?>
0 ignored issues
show
The type Hooks 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...
182
										</ul>
183
184
									<?php endif;
185
									$namespace = str_replace('_', ' ', $this->getSkin()->getTitle()->getNsText());
186
									$displaytitle = $this->data['title'];
187
									if (!empty($namespace)) {
188
										$pagetitle = $this->getSkin()->getTitle();
189
										$newtitle = str_replace($namespace.':', '', $pagetitle);
190
										$displaytitle = str_replace($pagetitle, $newtitle, $displaytitle);
191
									?><h4 class="namespace label"><?php print $namespace; ?></h4><?php } ?>
192
									<div id="content">
193
									<h1 class="title"><?php print $displaytitle; ?></h1>
194
											<?php if ($wgPivotFeatures['useAddThisShare'] !== '') { ?>
195
											<!-- Go to www.addthis.com/dashboard to customize your tools -->
196
											<div class="<?php echo $wgPivotFeatures['useAddThisShare']; ?> hide-for-print"></div>
197
											<!-- Go to www.addthis.com/dashboard to customize your tools -->
198
											<?php } ?>
199
									<?php if ( $this->data['isarticle'] ) { ?><h3 id="tagline"><?php $this->msg( 'tagline' ) ?></h3><?php } ?>
200
									<?php if ( $this->html('subtitle') ) { ?><h5 id="sitesub" class="subtitle"><?php $this->html('subtitle') ?></h5><?php } ?>
201
									<div id="contentSub" class="clear_both"></div>
202
									<div id="bodyContent" class="mw-bodytext">
203
									<?php 
204
									switch ($wgPivotFeatures['usePivotTabs']) {
205
										case true:
206
											echo $body;
207
											break;
208
										default:
209
										$this->html('bodytext');
210
											break;
211
											}
212
									?>
213
									<div class="clear_both"></div>
214
									</div>
215
									</div>
216
									<div id="categories" class="row">
217
										<div class="small-12 columns">
218
											<div class="group"><?php $this->html('catlinks'); ?></div>
219
											<?php $this->html('dataAfterContent'); ?>
220
										</div>
221
									</div>	
222
													
223
									<footer class="row">
224
225
										<div id="footer">
226
											<div id="div-footer-left" class="small-12 medium-8 large-9 columns">
227
											<ul id="footer-left">
228
												<?php foreach ($this->getFooterLinks("flat") as $key) { ?>
229
													<li id="footer-<?php echo $key ?>"><?php $this->html($key) ?></li>
230
												<?php } ?>									
231
											</ul>
232
											</div>	
233
											<div id="footer-right-icons" class="small-12 medium-4 large-3 columns hide-for-print">
234
											<ul id="footer-right">
235
												<li class="social-follow hide-for-print">
236
													<?php if ($wgPivotFeatures['useAddThisFollow'] !== '') { ?>
237
														<div class="social-links">
238
															<!-- Go to www.addthis.com/dashboard to customize your tools -->
239
															<div class="<?php echo $wgPivotFeatures['useAddThisFollow']; ?> hide-for-print"></div>
240
														</div>
241
													<?php } ?>
242
												</li>
243
												<?php foreach ($this->getFooterIcons($poweredbyType) as $blockName => $footerIcons) { ?>
244
													<li class="<?php echo $blockName ?>"><?php foreach ($footerIcons as $icon) { ?>
245
														<?php echo $this->getSkin()->makeFooterIcon($icon, $poweredbyMakeType); ?>
246
														<?php } ?>
247
													</li>
248
												<?php } ?>
249
											</ul>
250
											</div>		
251
										</div>			
252
									</footer>
253
								
254
								</div>
255
						</div>
256
					</div>
257
						
258
				</section>
259
				
260
			</div>
261
		</div>
262
		<div>
263
			<a class="exit-off-canvas"></a>	
264
		</div>
265
266
			<?php if ($this->data['isarticle'] && $wgPivotFeatures['addThisPUBID'] !== '') { ?>
267
				<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<?php echo $wgPivotFeatures['addThisPUBID']; ?>" async="async"></script>
268
			<?php } ?>	
269
270
<?php
271
		Wikimedia\restoreWarnings();
0 ignored issues
show
The function restoreWarnings was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

271
		/** @scrutinizer ignore-call */ 
272
  Wikimedia\restoreWarnings();
Loading history...
272
		
273
	}
274
	
275
	function renderSidebar() { 
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
276
		$sidebar = $this->getSidebar();
277
		foreach ($sidebar as $boxName => $box) { 
278
			echo '<li><label class="sidebar" id="'.Sanitizer::escapeIdForAttribute( $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...
279
					if ( is_array( $box['content'] ) ) {
280
							foreach ($box['content'] as $key => $item) { echo $this->makeListItem($key, $item); }
281
								} 
282
							}
283
		return;	}	
284
}
285
?>
286