X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=17da161abe3bfbeba3798e057238d34cb6c5c1ef;hb=9e638dbef402377fb1c02f7228ec2fa611ee7aa0;hp=6ff984b1778176e553aa5bb339fe290f87522a8a;hpb=160936a8ddb991d4f9c6668e42b0fa025e3b1ff7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 6ff984b177..17da161abe 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -62,7 +62,7 @@ class Skin extends Linker { } return $wgValidSkinNames; } - + /** * Fetch the list of usable skins in regards to $wgSkipSkins. * Useful for Special:Preferences and other places where you @@ -277,7 +277,7 @@ class Skin extends Linker { $this->userpage = $wgUser->getUserPage()->getPrefixedText(); $this->usercss = false; } - + /** * Set the title * @param Title $t The title to use @@ -285,7 +285,7 @@ class Skin extends Linker { public function setTitle( $t ) { $this->mTitle = $t; } - + /** Get the title */ public function getTitle() { return $this->mTitle; @@ -319,7 +319,7 @@ class Skin extends Linker { $out->out( $out->mBodytext . "\n" ); $out->out( $this->afterContent() ); - + $out->out( $afterContent ); $out->out( $this->bottomScripts() ); @@ -331,44 +331,42 @@ class Skin extends Linker { } static function makeVariablesScript( $data ) { - global $wgJsMimeType; - - $doneFirstVar = false; - $r = array( "\n"; - - return implode( $r ); } /** * Make a " ); - global $wgUseSiteJs; - if( $wgUseSiteJs ) { - $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : ''; - $r[] = ""; - } - if( $allowUserJs && $wgUser->isLoggedIn() ) { - $userpage = $wgUser->getUserPage(); - $userjs = htmlspecialchars( self::makeUrl( - $userpage->getPrefixedText().'/'.$this->getSkinName().'.js', - 'action=raw&ctype='.$wgJsMimeType ) ); - $r[] = '"; - } - return $vars . "\t\t" . implode ( "\n\t\t", $r ); - } - /** * To make it harder for someone to slip a user a fake * user-JavaScript or user-CSS preview, a random token @@ -481,16 +479,17 @@ class Skin extends Linker { * * @param string $action * @return bool - * @private */ - function userCanPreview( $action ) { + public function userCanPreview( $action ) { global $wgRequest, $wgUser; if( $action != 'submit' ) return false; if( !$wgRequest->wasPosted() ) return false; - if( !$this->mTitle->userCanEditCssJsSubpage() ) + if( !$this->mTitle->userCanEditCssSubpage() ) + return false; + if( !$this->mTitle->userCanEditJsSubpage() ) return false; return $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); @@ -507,15 +506,20 @@ class Skin extends Linker { * top. For now Monobook.js will be maintained, but it should be consi- * dered deprecated. * + * @param $force_skin string If set, overrides the skin name + * * @return string */ - public function generateUserJs() { + public function generateUserJs( $skinName = null ) { global $wgStylePath; wfProfileIn( __METHOD__ ); + if( !$skinName ) { + $skinName = $this->getSkinName(); + } $s = "/* generated javascript */\n"; - $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n"; + $s .= "var skin = '" . Xml::escapeJsString($skinName ) . "';\n"; $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';"; $s .= "\n\n/* MediaWiki:Common.js */\n"; $commonJs = wfMsgForContent( 'common.js' ); @@ -523,10 +527,10 @@ class Skin extends Linker { $s .= $commonJs; } - $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n"; + $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n"; // avoid inclusion of non defined user JavaScript (with custom skins only) // by checking for default message content - $msgKey = ucfirst( $this->getSkinName() ).'.js'; + $msgKey = ucfirst( $skinName ) . '.js'; $userJS = wfMsgForContent( $msgKey ); if ( !wfEmptyMsg( $msgKey, $userJS ) ) { $s .= $userJS; @@ -546,7 +550,7 @@ class Skin extends Linker { wfProfileOut( __METHOD__ ); return $s; } - + /** * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue */ @@ -584,6 +588,10 @@ END; if( !$wgUser->getOption( 'editsection' ) ) { $s .= ".editsection { display: none; }\n"; } + $fontstyle = $wgUser->getOption( 'editfont' ); + if ( $fontstyle !== 'default' ) { + $s .= "textarea { font-family: $fontstyle; }\n"; + } return $s; } @@ -604,8 +612,8 @@ END; ); // Add any extension CSS - foreach( $out->getExtStyle() as $tag ) { - $out->addStyle( $tag['href'] ); + foreach ( $out->getExtStyle() as $url ) { + $out->addStyle( $url ); } // If we use the site's dynamic CSS, throw that in, too @@ -644,9 +652,8 @@ END; $action = $wgRequest->getVal( 'action' ); # If we're previewing the CSS page, use it if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) { - $previewCss = $wgRequest->getText( 'wpTextbox1' ); // @FIXME: properly escape the cdata! - $this->usercss = "/**/"; + $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) ); } else { $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css', 'action=raw&ctype=text/css' ) ); @@ -685,12 +692,12 @@ END; $a['onload'] = $wgOut->getOnloadHandler(); $a['class'] = 'mediawiki' . - ' '.( $wgContLang->isRTL() ? 'rtl' : 'ltr' ). + ' '.( $wgContLang->getDir() ). ' '.$this->getPageClasses( $this->mTitle ) . ' skin-'. Sanitizer::escapeClass( $this->getSkinName() ); return $a; } - + function getPageClasses( $title ) { $numeric = 'ns-'.$title->getNamespace(); if( $title->getNamespace() == NS_SPECIAL ) { @@ -749,13 +756,13 @@ END; } elseif( $left ) { $s .= $this->getQuickbarCompensator( $rows ); } - $l = $wgContLang->isRTL() ? 'right' : 'left'; + $l = $wgContLang->alignStart(); $s .= "\n"; $s .= $this->topLinks(); $s .= "

" . $this->pageTitleLinks() . "

\n"; - $r = $wgContLang->isRTL() ? 'left' : 'right'; + $r = $wgContLang->alignEnd(); $s .= "\n"; $s .= $this->nameAndLogin(); $s .= "\n
" . $this->searchForm() . ""; @@ -793,7 +800,7 @@ END; // Use Unicode bidi embedding override characters, // to make sure links don't smash each other up in ugly ways. - $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; + $dir = $wgContLang->getDir(); $embed = ""; $pop = ''; @@ -868,18 +875,21 @@ END; } function getCategories() { - $catlinks=$this->getCategoryLinks(); + $catlinks = $this->getCategoryLinks(); $classes = 'catlinks'; - if( strpos( $catlinks, '