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.

Tuleap123Template::isCompatibilityViewEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * FusionForge nouveau
4
 *
5
 * Translated from gwicke's previous TAL template version to remove
6
 * dependency on PHPTAL.
7
 *
8
 * @todo document
9
 * @file
10
 * @ingroup Skins
11
 */
12
13
require_once MEDIAWIKI_BASE_DIR.'/MediawikiManager.class.php';
14
15
if ( !defined( 'MEDIAWIKI' ) ) {
16
	die( -1 );
17
}
18
19
/**
20
 * Inherit main code from SkinTemplate, set the CSS and template filter.
21
 * @todo document
22
 * @ingroup Skins
23
 */
24
class SkinTuleap123 extends SkinTemplate {
25
26
    CONST MEDIAWIKI_URL = '/\/plugins\/mediawiki\/wiki\/(.*)\/index.php\//';
27
28
    /** Using fusionforge. */
29
    var $skinname = 'tuleap123', $stylename = 'tuleap123',
30
            $template = 'Tuleap123Template', $useHeadElement = true;
31
32
    function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
33
            $tc = new $classname();
34
            $tc->params = array();
35
            if (($tc->project = $project =
36
                group_get_object_by_name($GLOBALS['fusionforgeproject']))) {
37
                    $tc->params['group'] = $GLOBALS['group_id'] =
38
                        $project->getID();
39
                    $tc->params['toptab'] = 'plugin_mediawiki';
40
                    //$page_name = substr($_SERVER['REQUEST_URI'], (strpos($_SERVER['REQUEST_URI'], 'index.php/') + strlen('index.php/')), strlen($_SERVER['REQUEST_URI']));
41
                    $page_name = preg_replace(self::MEDIAWIKI_URL,'',$_SERVER['REQUEST_URI']);
42
                    $tc->params['title'] = 'Mediawiki-' . $page_name;
43
            }
44
45
            return $tc;
46
    }
47
48
    /**
49
     * @param $out OutputPage
50
     */
51
    function setupSkinUserCss( OutputPage $out ) {
52
            /* add Tuleap styles */
53
            foreach ($GLOBALS['HTML']->getAllStyleSheets() as $sheet) {
54
                    $out->addStyle($sheet['css'], $sheet['media']);
55
            }
56
57
            parent::setupSkinUserCss( $out );
58
59
            $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) );
60
61
            // TODO: Migrate all of these
62
            $out->addStyle( 'Tuleap123/main.css', 'screen');
63
            $out->addStyle( 'Tuleap123/TuleapSkin.css', 'screen');
64
            $out->addStyle( 'Tuleap123/IE60Fixes.css', 'screen', 'IE 6' );
65
            $out->addStyle( 'Tuleap123/IE70Fixes.css', 'screen', 'IE 7' );
66
    }
67
68
    function addToBodyAttributes( $out, &$bodyAttrs ) {
69
        parent::addToBodyAttributes( $out, $bodyAttrs );
70
        $current_user  = UserManager::instance()->getCurrentUser();
71
        $sidebar_state = $current_user->getPreference('sidebar_state');
72
73
        if (! $sidebar_state) {
74
            $sidebar_state = 'sidebar-expanded';
75
        }
76
77
        $bodyAttrs['class'] .= ' has_sidebar ' . $sidebar_state;
78
79
        if ($current_user->getTheme() === 'FlamingParrot') {
80
            $bodyAttrs['class'] .= ' ' . $current_user->getPreference('theme_variant');
81
        }
82
    }
83
}
84
85
/**
86
 * @todo document
87
 * @ingroup Skins
88
 */
89
class Tuleap123Template extends BaseTemplate {
90
91
        public $project = false;
92
93
	/**
94
	 * Template filter callback for FusionForge skin.
95
	 * Takes an associative array of data set from a SkinTemplate-based
96
	 * class, and a wrapper for MediaWiki's localization database, and
97
	 * outputs a formatted page.
98
	 *
99
	 */
100
	public function execute() {
101
            global $wgHtml5;
102
            // Suppress warnings to prevent notices about missing indexes in $this->data
103
            wfSuppressWarnings();
104
105
            $this->html( 'headelement' );
106
107
            echo "\n<!-- FUSIONFORGE BodyHeader BEGIN -->\n";
108
109
            if ($this->isCompatibilityViewEnabled()) {
110
                $this->addForgeBackLinksToSidebar();
111
            } else  {
112
                $GLOBALS['HTML']->header($this->params);
113
                if ($this->IsUserAdmin()) {
114
                    echo '<ul class="nav nav-pills toolbar"><li><a href="/plugins/mediawiki/forge_admin?group_id='.$GLOBALS['group']->getId().'">'.$GLOBALS['Language']->getText('global', 'Administration').'</a></li></ul>';
115
                }
116
            }
117
118
            echo "<div id=\"ff-mw-wrapper\"><div style=\"font-size:x-small;\">\n";
119
            echo "<!-- FUSIONFORGE BodyHeader END -->\n";
120
121
?><div id="globalWrapper">
122
<div id="column-content"><div id="content" class="mw-body-primary" role="main">
123
	<a id="top"></a>
124
	<?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div><?php } ?>
125
126
	<h1 id="firstHeading" class="firstHeading" lang="<?php
127
		$this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
128
		$this->text( 'pageLanguage' );
129
	?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
130
	<div id="bodyContent" class="mw-body">
131
		<div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
132
		<div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div>
133
<?php if ( $this->data['undelete'] ) { ?>
134
		<div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
135
<?php } ?><?php if ( $this->data['newtalk'] ) { ?>
136
		<div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
137
<?php } ?>
138
		<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></div>
139
140
		<!-- start content -->
141
<?php $this->html( 'bodytext' ) ?>
142
		<?php if ( $this->data['catlinks'] ) { $this->html( 'catlinks' ); } ?>
143
		<!-- end content -->
144
		<?php if ( $this->data['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?>
145
		<div class="visualClear"></div>
146
	</div>
147
</div></div>
148
<div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
149
	<h2><?php $this->msg( 'navigation-heading' ) ?></h2>
150
<?php $this->cactions(); ?>
151
	<div class="portlet" id="p-personal" role="navigation">
152
		<h3><?php $this->msg( 'personaltools' ) ?></h3>
153
		<div class="pBody">
154
			<ul<?php $this->html( 'userlangattributes' ) ?>>
155
<?php		foreach ( $this->getPersonalTools() as $key => $item ) { ?>
156
				<?php echo $this->makeListItem( $key, $item ); ?>
157
158
<?php		} ?>
159
			</ul>
160
		</div>
161
	</div>
162
	<?php $class_no_logo = (! $this->data['logopath']) ? 'no-logo' : ''; ?>
163
	<div class="portlet <?php echo $class_no_logo; ?>" id="p-logo" role="banner">
164
<?php
165
			echo Html::element( 'a', array(
0 ignored issues
show
Bug introduced by
The method element() does not exist on HTML. Did you maybe mean isInlineElement()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
166
				'href' => $this->data['nav_urls']['mainpage']['href'],
167
				'style' => "background-image: url({$this->data['logopath']});" )
168
				+ Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?>
169
170
	</div>
171
<?php
172
	$this->renderPortals( $this->data['sidebar'] );
173
?>
174
</div><!-- end of the left (by default at least) column -->
175
<div class="visualClear"></div>
176
<?php
177
	$validFooterIcons = $this->getFooterIcons( "icononly" );
178
	$validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
179
180
	if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
181
<div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
182
<?php
183
		$footerEnd = '</div>';
184
	} else {
185
		$footerEnd = '';
186
	}
187
	foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
188
	<div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
189
<?php foreach ( $footerIcons as $icon ) { ?>
190
		<?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
191
192
<?php }
193
?>
194
	</div>
195
<?php }
196
197
		if ( count( $validFooterLinks ) > 0 ) {
198
?>	<ul id="f-list">
199
<?php
200
			foreach ( $validFooterLinks as $aLink ) { ?>
201
		<li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
202
<?php
203
			}
204
?>
205
	</ul>
206
<?php	}
207
echo $footerEnd;
208
?>
209
210
</div>
211
<?php
212
		$this->printTrail();
213
                echo "</div></div>\n";
214
                $GLOBALS['HTML']->footer($this->params);
215
		echo Html::closeElement( 'body' );
216
		echo Html::closeElement( 'html' );
217
		wfRestoreWarnings();
218
	} // end of execute() method
219
220
     private function IsUserAdmin() {
221
        $pfuser             = UserManager::instance()->getCurrentUser();
222
        $forge_user_manager = new User_ForgeUserGroupPermissionsManager(
223
            new User_ForgeUserGroupPermissionsDao()
224
        );
225
        $has_special_permission = $forge_user_manager->doesUserHavePermission(
226
            $pfuser,
227
            new User_ForgeUserGroupPermission_MediawikiAdminAllProjects()
228
        );
229
230
        return $pfuser->isMember($GLOBALS['group']->getId(), 'A') || $has_special_permission;
231
     }
232
233
     private function isUserAnonymous() {
234
         return UserManager::instance()->getCurrentUser()->isAnonymous();
235
     }
236
237
     private function isCompatibilityViewEnabled() {
238
        $manager = new MediawikiManager(new MediawikiDao());
239
        $project = $GLOBALS['group'];
240
241
        return $manager->isCompatibilityViewEnabled($project);
242
     }
243
244
     private function addForgeBackLinksToSidebar() {
245
        $forge_name    = forge_get_config('sys_fullname');
246
        $added_toolbox = array();
247
248
        if ($this->isUserAnonymous()) {
249
            $added_toolbox[] = array(
250
                'text' => $GLOBALS['Language']->getText('include_menu','login'),
251
                'href' => '/account/login.php?return_to='. $_SERVER['REQUEST_URI']
252
            );
253
        }
254
255
        $added_toolbox[] = array(
256
            'text' => $GLOBALS['Language']->getText('plugin_mediawiki', 'back_to_forge', array($forge_name)),
257
            'href' => '/projects/'.$GLOBALS['group']->getUnixName()
258
        );
259
260
        if ($this->IsUserAdmin()) {
261
            $added_toolbox []= array(
262
                'text' => $GLOBALS['Language']->getText('global', 'Administration'),
263
                'href' => '/plugins/mediawiki/forge_admin?group_id='.$GLOBALS['group']->getId()
264
            );
265
        }
266
267
        $this->data['sidebar'][$forge_name] = $added_toolbox;
268
     }
269
270
     protected function renderPortals( $sidebar ) {
271
		if ( !isset( $sidebar['SEARCH'] ) ) {
272
			$sidebar['SEARCH'] = true;
273
		}
274
		if ( !isset( $sidebar['TOOLBOX'] ) ) {
275
			$sidebar['TOOLBOX'] = true;
276
		}
277
		if ( !isset( $sidebar['LANGUAGES'] ) ) {
278
			$sidebar['LANGUAGES'] = true;
279
		}
280
281
		if (session_loggedin()) {
282
			$efbox_log_text = _('Log Out');
283
			$efbox_log_link = "/account/logout.php?return_to=" .
284
			    urlencode(getStringFromServer('REQUEST_URI'));
285
		} else {
286
			$efbox_log_text = _('Log In');
287
			$efbox_log_link = "/account/login.php?return_to=" .
288
			    urlencode(getStringFromServer('REQUEST_URI'));
289
		}
290
291
                echo '<div class="tuleap-panel">';
292
293
		foreach ( $sidebar as $boxName => $content ) {
294
			if ( $content === false ) {
295
				continue;
296
			}
297
298
			if ( $boxName == 'SEARCH' ) {
299
                            if ($this->isCompatibilityViewEnabled()) {
300
                                $this->searchBox();
301
                            }
302
			} elseif ( $boxName == 'TOOLBOX' ) {
303
				$this->toolbox();
304
			} elseif ( $boxName == 'LANGUAGES' ) {
305
				$this->languageBox();
306
			} else {
307
				$this->customBox( $boxName, $content );
308
			}
309
		}
310
311
                echo '</div>';
312
	}
313
314
        function searchBox() {
315
		global $wgUseTwoButtonsSearchForm;
316
?>
317
	<div id="p-search" class="portlet">
318
		<h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
319
		<div id="searchBody" class="pBody">
320
			<form action="<?php $this->text('wgScript') ?>" id="searchform">
321
				<input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
322
				<?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
323
324
				<?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
325
				if ($wgUseTwoButtonsSearchForm) { ?>&#160;
326
				<?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
327
                                } else { ?>
328
329
				<div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
330
                                } ?>
331
332
			</form>
333
		</div>
334
	</div>
335
<?php
336
	}
337
338
	/**
339
	 * Prints the cactions bar.
340
	 * Shared between MonoBook and Modern
341
	 */
342
	function cactions() {
343
?>
344
	<div id="p-cactions" class="portlet" role="navigation">
345
		<h5><?php $this->msg('views') ?></h5>
346
		<div class="pBody">
347
			<ul><?php
348
				foreach ($this->data['content_actions'] as $key => $tab) {
349
					echo '
350
				' . $this->makeListItem( $key, $tab );
351
				} ?>
352
353
			</ul>
354
<?php		$this->renderAfterPortlet( 'cactions' ); ?>
355
		</div>
356
	</div>
357
<?php
358
	}
359
	/*************************************************************************************************/
360
	function toolbox() {
361
?>
362
	<div class="portlet" id="p-tb" role="navigation">
363
		<h5><?php $this->msg('toolbox') ?></h5>
364
		<div class="pBody">
365
			<ul>
366
<?php
367
		foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
368
				<?php echo $this->makeListItem($key, $tbitem); ?>
369
370
<?php
371
		}
372
		wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
373
		wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
374
?>
375
			</ul>
376
<?php		$this->renderAfterPortlet( 'tb' ); ?>
377
		</div>
378
	</div>
379
<?php
380
	}
381
382
	/*************************************************************************************************/
383
	function languageBox() {
384
		if( $this->data['language_urls'] !== false ) {
385
?>
386
	<div id="p-lang" class="portlet" role="navigation">
387
		<h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
388
		<div class="pBody">
389
			<ul>
390
<?php		foreach ($this->data['language_urls'] as $key => $langlink) { ?>
391
				<?php echo $this->makeListItem($key, $langlink); ?>
392
393
<?php		} ?>
394
			</ul>
395
<?php		$this->renderAfterPortlet( 'lang' ); ?>
396
		</div>
397
	</div>
398
<?php
399
		}
400
	}
401
402
	/*************************************************************************************************/
403
        /**
404
	 * @param $bar string
405
	 * @param $cont array|string
406
	 */
407
	function customBox( $bar, $cont ) {
408
		$portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ), 'role' => 'navigation' );
409
		$tooltip = Linker::titleAttrib( "p-$bar" );
410
		if ( $tooltip !== false ) {
411
			$portletAttribs['title'] = $tooltip;
412
		}
413
		echo '	' . Html::openElement( 'div', $portletAttribs );
414
?>
415
416
		<h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
417
		<div class='pBody'>
418
<?php   if ( is_array( $cont ) ) { ?>
419
			<ul>
420
<?php 			foreach ( $cont as $key => $val) { ?>
421
				<?php echo $this->makeListItem($key, $val); ?>
422
423
<?php			} ?>
424
			</ul>
425
<?php   } else {
426
			# allow raw HTML block to be defined by extensions
427
			print $cont;
428
		}
429
430
                $this->renderAfterPortlet( $bar );
431
?>
432
		</div>
433
	</div>
434
<?php
435
	}
436
} // end of class
437