X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=159daefc86e2e1e2f46c440b89fc4320048596cc;hb=9ea27c314149f1686b40cd63c9d026068efcd8a4;hp=8e087ceb922e1e4e67f259003b3c4401baba0d85;hpb=52bb460dc45f1593b20a77e9e20ebdfb89943ad0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 8e087ceb92..159daefc86 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,31 +1,54 @@ 'Standard', - 'nostalgia' => 'Nostalgia', - 'cologneblue' => 'CologneBlue' -); -if( $wgUsePHPTal ) { - #$wgValidSkinNames[] = 'PHPTal'; - #$wgValidSkinNames['davinci'] = 'DaVinci'; - #$wgValidSkinNames['mono'] = 'Mono'; - $wgValidSkinNames['monobook'] = 'MonoBook'; - $wgValidSkinNames['myskin'] = 'MySkin'; - #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + +$skinDir = dir($IP.'/skins'); + +# while code from www.php.net +while (false !== ($file = $skinDir->read())) { + if(preg_match('/^([^.].*)\.php$/',$file, $matches)) { + $aSkin = $matches[1]; + $wgValidSkinNames[strtolower($aSkin)] = $aSkin; + } } +$skinDir->close(); +unset($matches); require_once( 'RecentChange.php' ); +global $wgLinkHolders; +$wgLinkHolders = array( + 'namespaces' => array(), + 'dbkeys' => array(), + 'queries' => array(), + 'texts' => array(), + 'titles' => array() +); +global $wgInterwikiLinkHolders; +$wgInterwikiLinkHolders = array(); + +/** + * @todo document + * @package MediaWiki + */ class RCCacheEntry extends RecentChange { var $secureName, $link; @@ -41,41 +64,40 @@ class RCCacheEntry extends RecentChange } } ; -class Skin { - /* private */ var $lastdate, $lastline; - var $linktrail ; # linktrail regexp +/** + * The main skin class that provide methods and properties for all other skins + * including PHPTal skins. + * This base class is also the "Standard" skin. + * @package MediaWiki + */ +class Skin extends Linker { + /**#@+ + * @access private + */ + var $lastdate, $lastline; var $rc_cache ; # Cache for Enhanced Recent Changes var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle var $rcMoveIndex; - var $postParseLinkColour = true; + /**#@-*/ - function Skin() - { - $this->linktrail = wfMsg('linktrail'); - } + /** Constructor, call parent constructor */ + function Skin() { parent::Linker(); } - function getSkinNames() - { + function getSkinNames() { global $wgValidSkinNames; return $wgValidSkinNames; } - function getStylesheet() - { - return 'wikistandard.css'; - } - function getSkinName() { - return "standard"; - } + /** @return string path to the skin stylesheet */ + function getStylesheet() { return 'common/wikistandard.css'; } - # Get/set accessor for delayed link colouring - function postParseLinkColour( $setting = NULL ) { - return wfSetVar( $this->postParseLinkColour, $setting ); + /** @return string skin name */ + function getSkinName() { + return 'standard'; } - function qbSetting() - { + function qbSetting() { global $wgOut, $wgUser; if ( $wgOut->isQuickbarSuppressed() ) { return 0; } @@ -84,8 +106,7 @@ class Skin { return $q; } - function initPage( &$out ) - { + function initPage( &$out ) { $fname = 'Skin::initPage'; wfProfileIn( $fname ); @@ -162,55 +183,88 @@ class Skin { } function getHeadScripts() { - global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs; - $r = "\n"; - if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in - $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); - $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript')); + global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs; + $r = "\n"; + if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { + $userpage = $wgUser->getUserPage(); + $userjs = htmlspecialchars( $this->makeUrl( + $userpage->getPrefixedText().'/'.$this->getSkinName().'.js', + 'action=raw&ctype=text/javascript')); $r .= '\n"; } return $r; } + /** + * To make it harder for someone to slip a user a fake + * user-JavaScript or user-CSS preview, a random token + * is associated with the login session. If it's not + * passed back with the preview request, we won't render + * the code. + * + * @param string $action + * @return bool + * @access private + */ + function userCanPreview( $action ) { + global $wgTitle, $wgRequest, $wgUser; + + if( $action != 'submit' ) + return false; + if( !$wgRequest->wasPosted() ) + return false; + if( !$wgTitle->userCanEditCssJsSubpage() ) + return false; + return $wgUser->matchEditToken( + $wgRequest->getVal( 'wpEditToken' ) ); + } + # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way) function getUserStylesheet() { - global $wgOut, $wgStylePath, $wgLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss; + global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss; $sheet = $this->getStylesheet(); $action = $wgRequest->getText('action'); $s = "@import \"$wgStylePath/$sheet\";\n"; - if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common_rtl.css\";\n"; - if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in - if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) { + if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n"; + if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in + if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) { $s .= $wgRequest->getText('wpTextbox1'); } else { - $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); - $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n"; + $userpage = $wgUser->getUserPage(); + $s.= '@import "'.$this->makeUrl( + $userpage->getPrefixedText().'/'.$this->getSkinName().'.css', + 'action=raw&ctype=text/css').'";'."\n"; } } $s .= $this->doGetUserStyles(); return $s."\n"; } - # placeholder, returns generated js in monobook - function getUserJs() { - return; - } - function getUserStyles() - { + /** + * placeholder, returns generated js in monobook + */ + function getUserJs() { return; } + + /** + * Return html code that include User stylesheets + */ + function getUserStyles() { global $wgOut, $wgStylePath, $wgLang; $s = "\n"; return $s; } - function doGetUserStyles() - { - global $wgUser, $wgLang; + /** + * Some styles that are set by user through the user settings interface. + */ + function doGetUserStyles() { + global $wgUser, $wgContLang; - $csspage = $wgLang->getNsText( NS_MEDIAWIKI ) . ":" . $this->getSkinName() . ".css"; + $csspage = $wgContLang->getNsText( NS_MEDIAWIKI ) . ':' . $this->getSkinName() . '.css'; $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n"; if ( 1 == $wgUser->getOption( 'underline' ) ) { @@ -220,7 +274,7 @@ class Skin { # 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' ) ) { @@ -229,8 +283,7 @@ class Skin { return $s; } - function getBodyOptions() - { + function getBodyOptions() { global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest; extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) ); @@ -240,14 +293,14 @@ class Skin { } else $a = array( 'bgcolor' => '#FFFFFF' ); if($wgOut->isArticle() && $wgUser->getOption('editondblclick') && - (!$wgTitle->isProtected() || $wgUser->isSysop()) ) { + (!$wgTitle->isProtected() || $wgUser->isAllowed('protect')) ) { $t = wfMsg( 'editthispage' ); $oid = $red = ''; - if ( !empty($redirect) ) { + if ( !empty($redirect) && $redirect == 'no' ) { $red = "&redirect={$redirect}"; } if ( !empty($oldid) && ! isset( $diff ) ) { - $oid = "&oldid={$oldid}"; + $oid = "&oldid=" . IntVal( $oldid ); } $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" ); $s = 'document.location = "' .$s .'";'; @@ -258,82 +311,24 @@ class Skin { return $a; } - function getExternalLinkAttributes( $link, $text, $class='' ) - { - global $wgUser, $wgOut, $wgLang; - - $link = urldecode( $link ); - $link = $wgLang->checkTitleEncoding( $link ); - $link = str_replace( '_', ' ', $link ); - $link = wfEscapeHTML( $link ); - - $r = ($class != '') ? " class='$class'" : " class='external'"; - - if ( 1 == $wgUser->getOption( 'hover' ) ) { - $r .= " title=\"{$link}\""; - } - return $r; - } - - function getInternalLinkAttributes( $link, $text, $broken = false ) - { - global $wgUser, $wgOut; - - $link = urldecode( $link ); - $link = str_replace( '_', ' ', $link ); - $link = wfEscapeHTML( $link ); - - if ( $broken == 'stub' ) { - $r = ' class="stub"'; - } else if ( $broken == 'yes' ) { - $r = ' class="new"'; - } else { - $r = ''; - } - - if ( 1 == $wgUser->getOption( 'hover' ) ) { - $r .= " title=\"{$link}\""; - } - return $r; - } - - function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) - { - global $wgUser, $wgOut; - - if ( $broken == 'stub' ) { - $r = ' class="stub"'; - } else if ( $broken == 'yes' ) { - $r = ' class="new"'; - } else { - $r = ''; - } - - if ( 1 == $wgUser->getOption( 'hover' ) ) { - $r .= ' title ="' . $nt->getEscapedText() . '"'; - } - return $r; - } - - function getLogo() - { + /** + * URL to the logo + */ + function getLogo() { global $wgLogo; return $wgLogo; } - # This will be called immediately after the
tag. Split into - # two functions to make it easier to subclass. - # - function beforeContent() - { - global $wgUser, $wgOut; - + /** + * This will be called immediately after the tag. Split into + * two functions to make it easier to subclass. + */ + function beforeContent() { return $this->doBeforeContent(); } - function doBeforeContent() - { - global $wgUser, $wgOut, $wgTitle, $wgLang, $wgSiteNotice; + function doBeforeContent() { + global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice; $fname = 'Skin::doBeforeContent'; wfProfileIn( $fname ); @@ -354,7 +349,7 @@ class Skin { $shove = ($qb != 0); $left = ($qb == 1 || $qb == 3); - if($wgLang->isRTL()) $left = !$left; + if($wgContLang->isRTL()) $left = !$left; if ( !$shove ) { $s .= "" . $this->pageTitleLinks() . "
\n"; - $r = $wgLang->isRTL() ? "left" : "right"; + $r = $wgContLang->isRTL() ? "left" : "right"; $s .= "