function Skin() {
$this->linktrail = wfMsgForContent('linktrail');
+
+ # Cache option lookups done very frequently
+ $options = array( 'highlightbroken', 'hover' );
+ foreach( $options as $opt ) {
+ global $wgUser;
+ $this->mOptions[$opt] = $wgUser->getOption( $opt );
+ }
}
function getSkinNames() {
# Force no underline
$s .= "a { text-decoration: none; }\n";
}
- if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
+ if ( 1 == $this->mOptions['highlightbroken'] ) {
$s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
}
if ( 1 == $wgUser->getOption( 'justify' ) ) {
}
function getExternalLinkAttributes( $link, $text, $class='' ) {
- global $wgUser, $wgOut, $wgContLang;
+ global $wgContLang;
$same = ($link == $text);
$link = urldecode( $link );
$r = ($class != '') ? " class='$class'" : " class='external'";
- if ( !$same && $wgUser->getOption( 'hover' ) ) {
+ if( !$same && $this->mOptions['hover'] ) {
$r .= " title=\"{$link}\"";
}
return $r;
}
function getInternalLinkAttributes( $link, $text, $broken = false ) {
- global $wgUser, $wgOut;
-
$link = urldecode( $link );
$link = str_replace( '_', ' ', $link );
$link = htmlspecialchars( $link );
- if ( $broken == 'stub' ) {
+ if( $broken == 'stub' ) {
$r = ' class="stub"';
} else if ( $broken == 'yes' ) {
$r = ' class="new"';
$r = '';
}
- if ( 1 == $wgUser->getOption( 'hover' ) ) {
+ if( $this->mOptions['hover'] ) {
$r .= " title=\"{$link}\"";
}
return $r;
* @param bool $broken
*/
function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
- global $wgUser, $wgOut;
-
- if ( $broken == 'stub' ) {
+ if( $broken == 'stub' ) {
$r = ' class="stub"';
} else if ( $broken == 'yes' ) {
$r = ' class="new"';
$r = '';
}
- if ( 1 == $wgUser->getOption( 'hover' ) ) {
+ if( $this->mOptions['hover'] ) {
$r .= ' title="' . $nt->getEscapedText() . '"';
}
return $r;
* Pass a title object, not a title string
*/
function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- global $wgOut, $wgUser;
-
# Fail gracefully
if ( ! isset($nt) ) {
# wfDebugDieBacktrace();
$trail = $m[2];
}
}
- if ( $wgUser->getOption( 'highlightbroken' ) ) {
+ if ( $this->mOptions['highlightbroken'] ) {
$s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
} else {
$s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
* Pass a title object, not a title string
*/
function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- global $wgOut, $wgUser;
-
$link = $nt->getPrefixedURL();
$u = $nt->escapeLocalURL( $query );
$trail = $m[2];
}
}
- if ( $wgUser->getOption( 'highlightbroken' ) ) {
+ if ( $this->mOptions['highlightbroken'] ) {
$s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
} else {
$s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";