Hutchy68 /
pivot
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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; |
||
|
0 ignored issues
–
show
|
|||
| 13 | |||
| 14 | public function setupSkinUserCss(OutputPage $out) { |
||
|
0 ignored issues
–
show
setupSkinUserCss uses the super-global variable $GLOBALS which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
setupSkinUserCss uses the super-global variable $_SERVER which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
|
|||
| 15 | parent::setupSkinUserCss($out); |
||
| 16 | global $wgPivotFeatures; |
||
| 17 | $wgPivotFeaturesDefaults = array( |
||
| 18 | 'showActionsForAnon' => true, |
||
| 19 | 'fixedNavBar' => false, |
||
| 20 | 'usePivotTabs' => false, |
||
| 21 | 'showHelpUnderTools' => true, |
||
| 22 | 'showRecentChangesUnderTools' => true, |
||
| 23 | 'wikiName' => &$GLOBALS['wgSitename'], |
||
| 24 | 'wikiNameDesktop' => &$GLOBALS['wgSitename'], |
||
| 25 | 'navbarIcon' => false, |
||
| 26 | 'IeEdgeCode' => 1, |
||
| 27 | 'showFooterIcons' => false, |
||
| 28 | 'addThisPUBID' => '', |
||
| 29 | 'useAddThisShare' => '', |
||
| 30 | 'useAddThisFollow' => '' |
||
| 31 | ); |
||
| 32 | foreach ($wgPivotFeaturesDefaults as $fgOption => $fgOptionValue) { |
||
| 33 | if ( !isset($wgPivotFeatures[$fgOption]) ) { |
||
| 34 | $wgPivotFeatures[$fgOption] = $fgOptionValue; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | switch ($wgPivotFeatures['IeEdgeCode']) { |
||
| 38 | case 1: |
||
| 39 | $out->addHeadItem('ie-meta', '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'); |
||
| 40 | break; |
||
| 41 | case 2: |
||
| 42 | if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) |
||
| 43 | header('X-UA-Compatible: IE=edge'); |
||
| 44 | break; |
||
| 45 | } |
||
| 46 | $out->addModuleStyles('skins.pivot.styles'); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function initPage(OutputPage $out) { |
||
| 50 | global $wgLocalStylePath; |
||
| 51 | parent::initPage($out); |
||
| 52 | |||
| 53 | $viewport_meta = 'width=device-width, user-scalable=yes, initial-scale=1.0'; |
||
| 54 | $out->addMeta('viewport', $viewport_meta); |
||
| 55 | $out->addModuleScripts('skins.pivot.js'); |
||
| 56 | } |
||
| 57 | |||
| 58 | } |
||
| 59 | |||
| 60 | |||
| 61 | class pivotTemplate extends BaseTemplate { |
||
| 62 | public function execute() { |
||
| 63 | global $wgUser; |
||
| 64 | global $wgPivotFeatures; |
||
| 65 | wfSuppressWarnings(); |
||
| 66 | $this->html('headelement'); |
||
| 67 | switch ($wgPivotFeatures['usePivotTabs']) { |
||
| 68 | case true: |
||
| 69 | ob_start(); |
||
| 70 | $this->html('bodytext'); |
||
| 71 | $out = ob_get_contents(); |
||
| 72 | ob_end_clean(); |
||
| 73 | $markers = array("<a", "</a", ">"); |
||
| 74 | $tags = array("<a", "</a", ">"); |
||
| 75 | $body = str_replace($markers, $tags, $out); |
||
| 76 | break; |
||
| 77 | default: |
||
| 78 | $body = ''; |
||
| 79 | break; |
||
| 80 | } |
||
| 81 | switch ($wgPivotFeatures['showFooterIcons']) { |
||
| 82 | case true: |
||
| 83 | $poweredbyType = "icononly"; |
||
| 84 | $poweredbyMakeType = 'withImage'; |
||
| 85 | break; |
||
| 86 | default: |
||
| 87 | $poweredbyType = "nocopyright"; |
||
| 88 | $poweredbyMakeType = 'withoutImage'; |
||
| 89 | break; |
||
| 90 | } |
||
| 91 | |||
| 92 | ?> |
||
| 93 | <!-- START PIVOTTEMPLATE --> |
||
| 94 | <div class="off-canvas-wrap docs-wrap" data-offcanvas=""> |
||
| 95 | <div class="inner-wrap"> |
||
| 96 | <?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "<div class='fixed'>"; ?> |
||
| 97 | <nav class="tab-bar hide-for-print"> |
||
| 98 | <section id="left-nav-aside" class="left-small show-for-small"> |
||
| 99 | <a class="left-off-canvas-toggle"><span id="menu-user"><i class="fa fa-navicon fa-lg"></i></span></a> |
||
| 100 | </section> |
||
| 101 | |||
| 102 | <section id="middle-nav" class="middle tab-bar-section"> |
||
| 103 | <h1 class="title"><a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>"> |
||
| 104 | <span class="show-for-medium-up"><?php echo $wgPivotFeatures['wikiNameDesktop']; ?></span> |
||
| 105 | <span class="show-for-small-only"> |
||
| 106 | <?php if ($wgPivotFeatures['navbarIcon'] != false) { ?> |
||
| 107 | <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;"> |
||
| 108 | <?php } ?> |
||
| 109 | <?php echo $wgPivotFeatures['wikiName']; ?></span></a></h1> |
||
| 110 | </section> |
||
| 111 | |||
| 112 | <section id="right-nav-aside" class="right-small"> |
||
| 113 | <a 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> |
||
| 114 | </section> |
||
| 115 | </nav> |
||
| 116 | <?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "</div>"; ?> |
||
| 117 | <aside class="left-off-canvas-menu"> |
||
| 118 | <ul class="off-canvas-list"> |
||
| 119 | |||
| 120 | <li class="has-form"> |
||
| 121 | <form action="/w/index.php" id="searchform-offcanvas" class="mw-search"> |
||
| 122 | <div class="row collapse"> |
||
| 123 | <div class="small-12 columns"> |
||
| 124 | <input type="search" name="search" placeholder="Search" title="Search [alt-shift-f]" accesskey="f" id="searchInput-offcanvas" autocomplete="off"> |
||
| 125 | </div> |
||
| 126 | </div> |
||
| 127 | </form> |
||
| 128 | </li> |
||
| 129 | |||
| 130 | <?php $this->renderSidebar() ?> |
||
| 131 | </ul> |
||
| 132 | </aside> |
||
| 133 | |||
| 134 | <aside class="right-off-canvas-menu"> |
||
| 135 | <ul class="off-canvas-list"> |
||
| 136 | <?php if ($wgUser->isLoggedIn()): ?> |
||
| 137 | <li id="personal-tools"><label>Personal</label></li> |
||
| 138 | <?php foreach ($this->getPersonalTools() as $key => $item) { echo $this->makeListItem($key, $item); } ?> |
||
| 139 | <?php else: ?> |
||
| 140 | <?php if (isset($this->data['personal_urls']['anonlogin'])): ?> |
||
| 141 | <li><a href="<?php echo $this->data['personal_urls']['anonlogin']['href']; ?>"><?php echo wfMessage( 'login' )->text() ?></a></li> |
||
| 142 | <?php elseif (isset($this->data['personal_urls']['login'])): ?> |
||
| 143 | <li><a href="<?php echo htmlspecialchars($this->data['personal_urls']['login']['href']); ?>"><?php echo wfMessage( 'login' )->text() ?></a></li> |
||
| 144 | <?php else: ?> |
||
| 145 | <li><?php echo Linker::link(Title::newFromText('Special:UserLogin'), wfMessage( 'login' )->text()); ?></li> |
||
| 146 | <?php endif; ?> |
||
| 147 | <?php endif; ?> |
||
| 148 | </ul> |
||
| 149 | </aside> |
||
| 150 | |||
| 151 | <section id="main-section" class="main-section" <?php if ($wgPivotFeatures['fixedNavBar'] != false) echo "style='margin-top:2.8125em'"; ?>> |
||
| 152 | |||
| 153 | <div id="page-content"> |
||
| 154 | |||
| 155 | <div id="mw-js-message" style="display:none;"></div> |
||
| 156 | |||
| 157 | <div class="row"> |
||
| 158 | |||
| 159 | <div id="sidebar" class="large-2 medium-3 columns hide-for-small hide-for-print"> |
||
| 160 | <ul class="side-nav"> |
||
| 161 | <li class="name logo"> |
||
| 162 | <a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>"> |
||
| 163 | <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> |
||
| 164 | </li> |
||
| 165 | <li class="has-form"> |
||
| 166 | <form action="/w/index.php" id="searchform" class="mw-search"> |
||
| 167 | <div class="row collapse"> |
||
| 168 | <div class="small-12 columns"> |
||
| 169 | <input type="search" name="search" placeholder="Search" title="Search [alt-shift-f]" accesskey="f" id="searchInput" autocomplete="off"> |
||
| 170 | </div> |
||
| 171 | </div> |
||
| 172 | </form> |
||
| 173 | </li> |
||
| 174 | |||
| 175 | <?php $this->renderSidebar() ?> |
||
| 176 | </ul> |
||
| 177 | </div> |
||
| 178 | |||
| 179 | <div id="p-cactions" class="large-10 medium-9 columns"> |
||
| 180 | |||
| 181 | <div class="row"> |
||
| 182 | <div class="large-12 columns"> |
||
| 183 | <!-- Output page indicators --> |
||
| 184 | <?php echo $this->getIndicators(); ?> |
||
| 185 | <!-- If user is logged in output echo location --> |
||
| 186 | <?php if ($wgUser->isLoggedIn()): ?> |
||
| 187 | <div id="echo-notifications"> |
||
| 188 | <div id="echo-notifications-alerts"></div> |
||
| 189 | <div id="echo-notifications-messages"></div> |
||
| 190 | </div> |
||
| 191 | <?php endif; ?> |
||
| 192 | <!--[if lt IE 9]> |
||
| 193 | <div id="siteNotice" class="sitenotice panel radius"><?php echo $this->text('sitename') . ' '. wfMessage( 'pivot-browsermsg' )->text(); ?></div> |
||
| 194 | <![endif]--> |
||
| 195 | |||
| 196 | <?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice" class="sitenotice panel radius"><?php $this->html( 'sitenotice' ); ?></div><?php } ?> |
||
| 197 | <?php if ( $this->data['newtalk'] ) { ?><div id="usermessage" class="newtalk panel radius"><?php $this->html( 'newtalk' ); ?></div><?php } ?> |
||
| 198 | </div> |
||
| 199 | </div> |
||
| 200 | |||
| 201 | <?php if ($wgUser->isLoggedIn() || $wgPivotFeatures['showActionsForAnon']): ?> |
||
| 202 | <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"> <?php echo wfMessage( 'actions' )->text() ?></span></i></a> |
||
| 203 | <ul id="drop1" class="tiny content f-dropdown" data-dropdown-content> |
||
| 204 | <?php foreach($this->data['content_actions'] as $key => $tab) { echo preg_replace(array('/\sprimary="1"/', '/\scontext="[a-z]+"/', '/\srel="archives"/'),'',$this->makeListItem($key, $tab)); } ?> |
||
| 205 | <?php wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true )); ?> |
||
| 206 | </ul> |
||
| 207 | |||
| 208 | <?php endif; |
||
| 209 | $namespace = str_replace('_', ' ', $this->getSkin()->getTitle()->getNsText()); |
||
| 210 | $displaytitle = $this->data['title']; |
||
| 211 | if (!empty($namespace)) { |
||
| 212 | $pagetitle = $this->getSkin()->getTitle(); |
||
| 213 | $newtitle = str_replace($namespace.':', '', $pagetitle); |
||
| 214 | $displaytitle = str_replace($pagetitle, $newtitle, $displaytitle); |
||
| 215 | ?><h4 class="namespace label"><?php print $namespace; ?></h4><?php } ?> |
||
| 216 | <div id="content"> |
||
| 217 | <h2 class="title"><?php print $displaytitle; ?></h2> |
||
| 218 | <?php if ($wgPivotFeatures['useAddThisShare'] !== '') { ?> |
||
| 219 | <!-- Go to www.addthis.com/dashboard to customize your tools --> |
||
| 220 | <div class="<?php echo $wgPivotFeatures['useAddThisShare']; ?> hide-for-print"></div> |
||
| 221 | <!-- Go to www.addthis.com/dashboard to customize your tools --> |
||
| 222 | <?php } ?> |
||
| 223 | <?php if ( $this->data['isarticle'] ) { ?><h3 id="tagline"><?php $this->msg( 'tagline' ) ?></h3><?php } ?> |
||
| 224 | <h5 id="sitesub" class="subtitle"><?php $this->html('subtitle') ?></h5> |
||
| 225 | <div id="contentSub" class="clear_both"></div> |
||
| 226 | <div id="bodyContent" class="mw-bodytext"> |
||
| 227 | <?php |
||
| 228 | switch ($wgPivotFeatures['usePivotTabs']) { |
||
| 229 | case true: |
||
| 230 | echo $body; |
||
| 231 | break; |
||
| 232 | default: |
||
| 233 | $this->html('bodytext'); |
||
| 234 | break; |
||
| 235 | } |
||
| 236 | ?> |
||
| 237 | <div class="clear_both"></div> |
||
| 238 | </div> |
||
| 239 | </div> |
||
| 240 | <div id="categories" class="row"> |
||
| 241 | <div class="small-12 columns"> |
||
| 242 | <div class="group"><?php $this->html('catlinks'); ?></div> |
||
| 243 | <?php $this->html('dataAfterContent'); ?> |
||
| 244 | </div> |
||
| 245 | </div> |
||
| 246 | |||
| 247 | <footer class="row"> |
||
| 248 | |||
| 249 | <div id="footer"> |
||
| 250 | <div id="footer-left" class="small-12 medium-8 large-9 columns"> |
||
| 251 | <ul id="footer-left"> |
||
| 252 | <?php foreach ($this->getFooterLinks("flat") as $key) { ?> |
||
| 253 | <li id="footer-<?php echo $key ?>"><?php $this->html($key) ?></li> |
||
| 254 | <?php } ?> |
||
| 255 | </ul> |
||
| 256 | </div> |
||
| 257 | <div id="footer-right-icons" class="small-12 medium-4 large-3 columns hide-for-print"> |
||
| 258 | <ul id="footer-right"> |
||
| 259 | <li class="social-follow hide-for-print"> |
||
| 260 | <?php if ($wgPivotFeatures['useAddThisFollow'] !== '') { ?> |
||
| 261 | <div class="social-links"> |
||
| 262 | <!-- Go to www.addthis.com/dashboard to customize your tools --> |
||
| 263 | <div class="<?php echo $wgPivotFeatures['useAddThisFollow']; ?> hide-for-print"></div> |
||
| 264 | </div> |
||
| 265 | <?php } ?> |
||
| 266 | </li> |
||
| 267 | <?php foreach ($this->getFooterIcons($poweredbyType) as $blockName => $footerIcons) { ?> |
||
| 268 | <li class="<?php echo $blockName ?>"><?php foreach ($footerIcons as $icon) { ?> |
||
| 269 | <?php echo $this->getSkin()->makeFooterIcon($icon, $poweredbyMakeType); ?> |
||
| 270 | <?php } ?> |
||
| 271 | </li> |
||
| 272 | <?php } ?> |
||
| 273 | </ul> |
||
| 274 | </div> |
||
| 275 | </div> |
||
| 276 | </footer> |
||
| 277 | |||
| 278 | </div> |
||
| 279 | </div> |
||
| 280 | </div> |
||
| 281 | |||
| 282 | </section> |
||
| 283 | |||
| 284 | </div> |
||
| 285 | </div> |
||
| 286 | <a class="exit-off-canvas"></a> |
||
| 287 | </div> |
||
| 288 | |||
| 289 | |||
| 290 | <?php $this->printTrail(); ?> |
||
| 291 | |||
| 292 | <?php if ($this->data['isarticle'] && $wgPivotFeatures['addThisPUBID'] !== '') { ?> |
||
| 293 | <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<?php echo $wgPivotFeatures['addThisPUBID']; ?>" async="async">></script> |
||
| 294 | <?php } ?> |
||
| 295 | </body> |
||
| 296 | </html> |
||
| 297 | |||
| 298 | <?php |
||
| 299 | wfRestoreWarnings(); |
||
| 300 | |||
| 301 | } |
||
| 302 | |||
| 303 | function renderSidebar() { |
||
| 304 | $sidebar = $this->getSidebar(); |
||
| 305 | $toolbox = $this->getToolbox(); |
||
| 306 | foreach ($sidebar as $boxName => $box) { if ( ($box['header'] != wfMessage( 'toolbox' )->text()) ) { |
||
| 307 | echo '<li id='.Sanitizer::escapeId( $box['id'] ); Linker::tooltip( $box['id'] ).'>'; |
||
| 308 | echo '<li><label>'.htmlspecialchars( $box['header'] ).'</label></li>'; |
||
| 309 | if ( is_array( $box['content'] ) ) { |
||
| 310 | foreach ($box['content'] as $key => $item) { echo $this->makeListItem($key, $item); } |
||
| 311 | } } |
||
| 312 | } |
||
| 313 | echo '<li><label>Toolbox</label></li>'; |
||
| 314 | foreach ($toolbox as $key => $tbitem) { echo $this->makeListItem($key, $tbitem); } |
||
| 315 | } |
||
| 316 | } |
||
| 317 | ?> |
||
| 318 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.