X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=9b40f6d3036279f89c2508b191808445a147af60;hb=60c94987aab3141a19d735fbc003d5cb646a8502;hp=5c16a87fb12e1952750b09eb3528c4b84b7d294f;hpb=d4f0bb5ca3c1563b74ef21b5cce30b85de5cd893;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 5c16a87fb1..9b40f6d303 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,29 +1,71 @@ 'Standard', - 'nostalgia' => 'Nostalgia', - 'cologneblue' => 'CologneBlue' +/* +$wgValidSkinNames = array( + 'standard' => 'Standard', + 'nostalgia' => 'Nostalgia', + 'cologneblue' => 'CologneBlue' ); if( $wgUsePHPTal ) { - #$wgValidSkinNames[] = 'PHPTal'; - #$wgValidSkinNames['davinci'] = 'DaVinci'; - #$wgValidSkinNames['mono'] = 'Mono'; - $wgValidSkinNames['monobook'] = 'MonoBook'; - $wgValidSkinNames['myskin'] = 'MySkin'; - #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + #$wgValidSkinNames[] = 'PHPTal'; + #$wgValidSkinNames['davinci'] = 'DaVinci'; + #$wgValidSkinNames['mono'] = 'Mono'; + #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + $wgValidSkinNames['monobook'] = 'MonoBook'; + $wgValidSkinNames['myskin'] = 'MySkin'; + $wgValidSkinNames['chick'] = 'Chick'; } +*/ + +# Get a list of all skins available in /skins/ +# Build using the regular expression '^(.*).php$' +# Array keys are all lower case, array value keep the case used by filename +# + +$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() +); + +/** + * @todo document + * @package MediaWiki + */ class RCCacheEntry extends RecentChange { var $secureName, $link; @@ -39,35 +81,52 @@ class RCCacheEntry extends RecentChange } } ; -class Skin { - /* private */ var $lastdate, $lastline; +/** + * 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 { + /**#@+ + * @access private + */ + var $lastdate, $lastline; var $linktrail ; # linktrail regexp var $rc_cache ; # Cache for Enhanced Recent Changes var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle var $rcMoveIndex; + var $postParseLinkColour = true; + /**#@-*/ - function Skin() - { + function Skin() { + global $wgUseOldExistenceCheck; + $postParseLinkColour = !$wgUseOldExistenceCheck; $this->linktrail = wfMsg('linktrail'); } - function getSkinNames() - { + function getSkinNames() { global $wgValidSkinNames; return $wgValidSkinNames; } - function getStylesheet() - { - return 'wikistandard.css'; + function getStylesheet() { + return 'common/wikistandard.css'; } + function getSkinName() { - return "standard"; + return 'standard'; } - function qbSetting() - { + /** + * Get/set accessor for delayed link colouring + */ + function postParseLinkColour( $setting = NULL ) { + return wfSetVar( $this->postParseLinkColour, $setting ); + } + + function qbSetting() { global $wgOut, $wgUser; if ( $wgOut->isQuickbarSuppressed() ) { return 0; } @@ -76,8 +135,7 @@ class Skin { return $q; } - function initPage( &$out ) - { + function initPage( &$out ) { $fname = 'Skin::initPage'; wfProfileIn( $fname ); @@ -155,7 +213,7 @@ class Skin { function getHeadScripts() { global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs; - $r = "\n"; + $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')); @@ -170,7 +228,7 @@ class Skin { $sheet = $this->getStylesheet(); $action = $wgRequest->getText('action'); $s = "@import \"$wgStylePath/$sheet\";\n"; - if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common_rtl.css\";\n"; + if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n"; if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) { $s .= $wgRequest->getText('wpTextbox1'); @@ -182,27 +240,32 @@ class Skin { $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() - { + /** + * Some styles that are set by user through the user settings interface. + */ + function doGetUserStyles() { global $wgUser, $wgLang; - $csspage = $wgLang->getNsText( NS_MEDIAWIKI ) . ":" . $this->getSkinName() . ".css"; + $csspage = $wgLang->getNsText( NS_MEDIAWIKI ) . ':' . $this->getSkinName() . '.css'; $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n"; if ( 1 == $wgUser->getOption( 'underline' ) ) { @@ -221,8 +284,7 @@ class Skin { return $s; } - function getBodyOptions() - { + function getBodyOptions() { global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest; extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) ); @@ -250,14 +312,13 @@ class Skin { return $a; } - function getExternalLinkAttributes( $link, $text, $class='' ) - { + function getExternalLinkAttributes( $link, $text, $class='' ) { global $wgUser, $wgOut, $wgLang; $link = urldecode( $link ); $link = $wgLang->checkTitleEncoding( $link ); $link = str_replace( '_', ' ', $link ); - $link = wfEscapeHTML( $link ); + $link = htmlspecialchars( $link ); $r = ($class != '') ? " class='$class'" : " class='external'"; @@ -267,13 +328,12 @@ class Skin { return $r; } - function getInternalLinkAttributes( $link, $text, $broken = false ) - { + function getInternalLinkAttributes( $link, $text, $broken = false ) { global $wgUser, $wgOut; $link = urldecode( $link ); $link = str_replace( '_', ' ', $link ); - $link = wfEscapeHTML( $link ); + $link = htmlspecialchars( $link ); if ( $broken == 'stub' ) { $r = ' class="stub"'; @@ -289,8 +349,10 @@ class Skin { return $r; } - function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) - { + /** + * @param bool $broken + */ + function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) { global $wgUser, $wgOut; if ( $broken == 'stub' ) { @@ -307,24 +369,25 @@ class Skin { 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() - { + /** + * This will be called immediately after the tag. Split into + * two functions to make it easier to subclass. + */ + function beforeContent() { global $wgUser, $wgOut; return $this->doBeforeContent(); } - function doBeforeContent() - { + function doBeforeContent() { global $wgUser, $wgOut, $wgTitle, $wgLang, $wgSiteNotice; $fname = 'Skin::doBeforeContent'; wfProfileIn( $fname ); @@ -400,10 +463,36 @@ class Skin { wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) ) . ': ' . $t; + # optional 'dmoz-like' category browser. Will be shown under the list + # of categories an article belong to if($wgUseCategoryBrowser) { $s .= '" . wfMsg( "retrievedfrom", "$url" ) . + return wfMsg( "retrievedfrom", "$url" ); + } + + function printFooter() { + return "
" . $this->printSource() . "
\n\n" . $this->pageStats() . "
\n"; } - function doAfterContent() - { + function doAfterContent() { global $wgUser, $wgOut, $wgLang; $fname = 'Skin::doAfterContent'; wfProfileIn( $fname ); @@ -487,8 +577,7 @@ class Skin { return $s; } - function pageTitleLinks() - { + function pageTitleLinks() { global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest; extract( $wgRequest->getValues( 'oldid', 'diff' ) ); @@ -500,7 +589,7 @@ class Skin { if ( $wgOut->isArticleRelated() ) { if ( $wgTitle->getNamespace() == Namespace::getImage() ) { $name = $wgTitle->getDBkey(); - $link = wfEscapeHTML( Image::wfImageUrl( $name ) ); + $link = htmlspecialchars( Image::wfImageUrl( $name ) ); $style = $this->getInternalLinkAttributes( $link, $name ); $s .= " | {$name}"; } @@ -510,7 +599,7 @@ class Skin { $t = $wgTitle->getDBkey(); $name = 'Approve this article' ; $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ; - #wfEscapeHTML( wfImageUrl( $name ) ); + #htmlspecialchars( wfImageUrl( $name ) ); $style = $this->getExternalLinkAttributes( $link, $name ); $s .= " | {$name}" ; } @@ -531,6 +620,8 @@ class Skin { Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", wfMsg('newmessageslink') ); $s.= ' | '. wfMsg( 'newmessages', $tl ) . ''; + # disable caching + $wgOut->setSquidMaxage(0); } } @@ -554,8 +645,7 @@ class Skin { return ''; } - function printableLink() - { + function printableLink() { global $wgOut, $wgFeedClasses, $wgRequest; $baseurl = $_SERVER['REQUEST_URI']; @@ -577,8 +667,7 @@ class Skin { return $s; } - function pageTitle() - { + function pageTitle() { global $wgOut, $wgTitle, $wgUser; $s = '$subpages":'';
@@ -601,8 +689,7 @@ class Skin {
return $s;
}
- function subPageSubtitle()
- {
+ function subPageSubtitle() {
global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
$subpages = '';
if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
@@ -631,8 +718,7 @@ class Skin {
return $subpages;
}
- function nameAndLogin()
- {
+ function nameAndLogin() {
global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP;
$li = $wgLang->specialPage( 'Userlogin' );
@@ -689,8 +775,7 @@ class Skin {
return htmlspecialchars( $this->getSearchLink() );
}
- function searchForm()
- {
+ function searchForm() {
global $wgRequest;
$search = $wgRequest->getText( 'search' );
@@ -704,8 +789,7 @@ class Skin {
return $s;
}
- function topLinks()
- {
+ function topLinks() {
global $wgOut;
$sep = " |\n";
@@ -722,8 +806,7 @@ class Skin {
return $s;
}
- function bottomLinks()
- {
+ function bottomLinks() {
global $wgOut, $wgUser, $wgTitle;
$sep = " |\n";
@@ -764,8 +847,7 @@ class Skin {
return $s;
}
- function pageStats()
- {
+ function pageStats() {
global $wgOut, $wgLang, $wgArticle, $wgRequest;
global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
@@ -838,13 +920,12 @@ class Skin {
function getPoweredBy() {
global $wgStylePath;
- $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
+ $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
$img = ' " . wfMsg( 'imghistlegend' ) . "';
return $img;
}
- function lastModified()
- {
+ function lastModified() {
global $wgLang, $wgArticle;
$timestamp = $wgArticle->getTimestamp();
@@ -857,21 +938,24 @@ class Skin {
return $s;
}
- function logoText( $align = '' )
- {
- if ( '' != $align ) { $a = ' align="'.$align.'"'; }
+ function logoText( $align = '' ) {
+ if ( '' != $align ) { $a = " align='{$align}'"; }
else { $a = ''; }
$mp = wfMsg( 'mainpage' );
$titleObj = Title::newFromText( $mp );
- $s = '
";
+ if ( is_object( $titleObj ) ) {
+ $url = $titleObj->escapeLocalURL();
+ } else {
+ $url = '';
+ }
+
+ $logourl = $this->getLogo();
+ $s = "
";
return $s;
}
- function quickBar()
- {
+ function quickBar() {
global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
global $wgDisableUploads, $wgRemoteUploads;
@@ -1016,8 +1100,7 @@ class Skin {
return $s;
}
- function specialPagesList()
- {
+ function specialPagesList() {
global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
require_once('SpecialPage.php');
$a = array();
@@ -1057,37 +1140,32 @@ class Skin {
return $s;
}
- function mainPageLink()
- {
+ function mainPageLink() {
$mp = wfMsg( 'mainpage' );
$s = $this->makeKnownLink( $mp, $mp );
return $s;
}
- function copyrightLink()
- {
+ function copyrightLink() {
$s = $this->makeKnownLink( wfMsg( 'copyrightpage' ),
wfMsg( 'copyrightpagename' ) );
return $s;
}
- function aboutLink()
- {
+ function aboutLink() {
$s = $this->makeKnownLink( wfMsg( 'aboutpage' ),
- wfMsg( 'aboutwikipedia' ) );
+ wfMsg( 'aboutsite' ) );
return $s;
}
- function disclaimerLink()
- {
+ function disclaimerLink() {
$s = $this->makeKnownLink( wfMsg( 'disclaimerpage' ),
wfMsg( 'disclaimers' ) );
return $s;
}
- function editThisPage()
- {
+ function editThisPage() {
global $wgOut, $wgTitle, $wgRequest;
$oldid = $wgRequest->getVal( 'oldid' );
@@ -1108,15 +1186,14 @@ class Skin {
if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
if ( $oldid && ! isset( $diff ) ) {
- $oid = "&oldid={$oldid}";
+ $oid = '&oldid='.$oldid;
}
$s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
}
return $s;
}
- function deleteThisPage()
- {
+ function deleteThisPage() {
global $wgUser, $wgOut, $wgTitle, $wgRequest;
$diff = $wgRequest->getVal( 'diff' );
@@ -1131,8 +1208,7 @@ class Skin {
return $s;
}
- function protectThisPage()
- {
+ function protectThisPage() {
global $wgUser, $wgOut, $wgTitle, $wgRequest;
$diff = $wgRequest->getVal( 'diff' );
@@ -1153,8 +1229,7 @@ class Skin {
return $s;
}
- function watchThisPage()
- {
+ function watchThisPage() {
global $wgUser, $wgOut, $wgTitle;
if ( $wgOut->isArticleRelated() ) {
@@ -1174,8 +1249,7 @@ class Skin {
return $s;
}
- function moveThisPage()
- {
+ function moveThisPage() {
global $wgTitle, $wgLang;
if ( $wgTitle->userCanEdit() ) {
@@ -1185,8 +1259,7 @@ class Skin {
return $s;
}
- function historyLink()
- {
+ function historyLink() {
global $wgTitle;
$s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
@@ -1194,8 +1267,7 @@ class Skin {
return $s;
}
- function whatLinksHere()
- {
+ function whatLinksHere() {
global $wgTitle, $wgLang;
$s = $this->makeKnownLink( $wgLang->specialPage( 'Whatlinkshere' ),
@@ -1203,8 +1275,7 @@ class Skin {
return $s;
}
- function userContribsLink()
- {
+ function userContribsLink() {
global $wgTitle, $wgLang;
$s = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
@@ -1212,8 +1283,7 @@ class Skin {
return $s;
}
- function emailUserLink()
- {
+ function emailUserLink() {
global $wgTitle, $wgLang;
$s = $this->makeKnownLink( $wgLang->specialPage( 'Emailuser' ),
@@ -1221,8 +1291,7 @@ class Skin {
return $s;
}
- function watchPageLinksLink()
- {
+ function watchPageLinksLink() {
global $wgOut, $wgTitle, $wgLang;
if ( ! $wgOut->isArticleRelated() ) {
@@ -1235,8 +1304,7 @@ class Skin {
return $s;
}
- function otherLanguages()
- {
+ function otherLanguages() {
global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
$a = $wgOut->getLanguageLinks();
@@ -1279,15 +1347,13 @@ class Skin {
return $s;
}
- function bugReportsLink()
- {
+ function bugReportsLink() {
$s = $this->makeKnownLink( wfMsg( 'bugreportspage' ),
wfMsg( 'bugreports' ) );
return $s;
}
- function dateLink()
- {
+ function dateLink() {
global $wgLinkCache;
$t1 = Title::newFromText( gmdate( 'F j' ) );
$t2 = Title::newFromText( gmdate( 'Y' ) );
@@ -1315,8 +1381,7 @@ class Skin {
return $s;
}
- function talkLink()
- {
+ function talkLink() {
global $wgLang, $wgTitle, $wgLinkCache;
$tns = $wgTitle->getNamespace();
@@ -1358,8 +1423,7 @@ class Skin {
return $s;
}
- function commentLink()
- {
+ function commentLink() {
global $wgLang, $wgTitle, $wgLinkCache;
$tns = $wgTitle->getNamespace();
@@ -1381,17 +1445,19 @@ class Skin {
return $s;
}
- # After all the page content is transformed into HTML, it makes
- # a final pass through here for things like table backgrounds.
- #
- function transformContent( $text )
- {
+ /**
+ * After all the page content is transformed into HTML, it makes
+ * a final pass through here for things like table backgrounds.
+ * @todo probably deprecated [AV]
+ */
+ function transformContent( $text ) {
return $text;
}
- # Note: This function MUST call getArticleID() on the link,
- # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
- #
+ /**
+ * Note: This function MUST call getArticleID() on the link,
+ * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
+ */
function makeLink( $title, $text = '', $query = '', $trail = '' ) {
wfProfileIn( 'Skin::makeLink' );
$nt = Title::newFromText( $title );
@@ -1436,12 +1502,17 @@ class Skin {
}
}
- # Pass a title object, not a title string
- function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' )
- {
- global $wgOut, $wgUser;
+ /**
+ * Pass a title object, not a title string
+ */
+ function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
+ global $wgOut, $wgUser, $wgLinkHolders;
$fname = 'Skin::makeLinkObj';
+ # Fail gracefully
+ if ( ! isset($nt) )
+ return "{$prefix}{$text}{$trail}";
+
if ( $nt->isExternal() ) {
$u = $nt->getFullURL();
$link = $nt->getPrefixedURL();
@@ -1462,42 +1533,61 @@ class Skin {
( Namespace::getImage() == $nt->getNamespace() ) ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} else {
- $aid = $nt->getArticleID() ;
- if ( 0 == $aid ) {
- $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
+ if ( $this->postParseLinkColour() ) {
+ $inside = '';
+ if ( '' != $trail ) {
+ if ( preg_match( $this->linktrail, $trail, $m ) ) {
+ $inside = $m[1];
+ $trail = $m[2];
+ }
+ }
+
+ # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
+ $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
+ $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
+ $wgLinkHolders['queries'][] = $query;
+ $wgLinkHolders['texts'][] = $prefix.$text.$inside;
+ $wgLinkHolders['titles'][] = $nt;
+
+ $retVal = '{$trail}";
} else {
- $threshold = $wgUser->getOption('stubthreshold') ;
- if ( $threshold > 0 ) {
- $s = $dbr->getArray( 'cur',
- array( 'LENGTH(cur_text) AS x', 'cur_namespace', 'cur_is_redirect' ),
- array( 'cur_id' => $aid ),
- $fname
- );
-
- if ( $s !== false ) {
- $size = $s->x;
- if ( $s->cur_is_redirect OR $s->cur_namespace != 0 ) {
+ # Work out link colour immediately
+ $aid = $nt->getArticleID() ;
+ if ( 0 == $aid ) {
+ $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
+ } else {
+ $threshold = $wgUser->getOption('stubthreshold') ;
+ if ( $threshold > 0 ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
+ 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
+ if ( $s !== false ) {
+ $size = $s->x;
+ if ( $s->cur_is_redirect OR $s->cur_namespace != 0 ) {
+ $size = $threshold*2 ; # Really big
+ }
+ $dbr->freeResult( $res );
+ } else {
$size = $threshold*2 ; # Really big
}
} else {
- $size = $threshold*2 ; # Really big
+ $size = 1 ;
+ }
+ if ( $size < $threshold ) {
+ $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
+ } else {
+ $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
}
- } else {
- $size = 1 ;
- }
- if ( $size < $threshold ) {
- $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
- } else {
- $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
}
}
}
return $retVal;
}
- # Pass a title object, not a title string
- function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '')
- {
+ /**
+ * Pass a title object, not a title string
+ */
+ function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
global $wgOut, $wgTitle, $wgInputEncoding;
$fname = 'Skin::makeKnownLinkObj';
@@ -1507,6 +1597,8 @@ class Skin {
return $text;
}
$link = $nt->getPrefixedURL();
+# if ( '' != $section && substr($section,0,1) != "#" ) {
+# $section = ''
if ( '' == $link ) {
$u = '';
@@ -1541,11 +1633,16 @@ class Skin {
return $r;
}
- # Pass a title object, not a title string
- function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
- {
+ /**
+ * Pass a title object, not a title string
+ */
+ function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
global $wgOut, $wgUser;
+ # Fail gracefully
+ if ( ! isset($nt) )
+ return "{$prefix}{$text}{$trail}";
+
$fname = 'Skin::makeBrokenLinkObj';
wfProfileIn( $fname );
@@ -1578,9 +1675,10 @@ class Skin {
return $s;
}
- # Pass a title object, not a title string
- function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
- {
+ /**
+ * Pass a title object, not a title string
+ */
+ function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
global $wgOut, $wgUser;
$link = $nt->getPrefixedURL();
@@ -1607,8 +1705,7 @@ class Skin {
return $s;
}
- function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
- {
+ function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
$u = $nt->escapeLocalURL( $query );
if ( '' == $text ) {
$text = htmlspecialchars( $nt->getPrefixedText() );
@@ -1642,7 +1739,7 @@ class Skin {
return $title->getLocalURL( $urlaction );
}
/*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
- $title = Title::newFromText( wfMsg($name) );
+ $title = Title::newFromText( wfMsgForContent($name) );
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
}
@@ -1653,7 +1750,7 @@ class Skin {
}
# this can be passed the NS number as defined in Language.php
/*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
- $title = Title::makeTitle( $namespace, $name );
+ $title = Title::makeTitleSafe( $namespace, $name );
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
}
@@ -1686,7 +1783,7 @@ class Skin {
);
}
/*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
- $title = Title::newFromText( wfMsg($name) );
+ $title = Title::newFromText( wfMsgForContent($name) );
$this->checkTitle($title, $name);
return array(
'href' => $title->getLocalURL( $urlaction ),
@@ -1704,25 +1801,28 @@ class Skin {
}
}
- function fnamePart( $url )
- {
+ function fnamePart( $url ) {
$basename = strrchr( $url, '/' );
- if ( false === $basename ) { $basename = $url; }
- else { $basename = substr( $basename, 1 ); }
- return wfEscapeHTML( $basename );
+ if ( false === $basename ) {
+ $basename = $url;
+ } else {
+ $basename = substr( $basename, 1 );
+ }
+ return htmlspecialchars( $basename );
}
- function makeImage( $url, $alt = '' )
- {
+ function makeImage( $url, $alt = '' ) {
global $wgOut;
- if ( '' == $alt ) { $alt = $this->fnamePart( $url ); }
+ if ( '' == $alt ) {
+ $alt = $this->fnamePart( $url );
+ }
$s = '
';
return $s;
}
function makeImageLink( $name, $url, $alt = '' ) {
- $nt = Title::makeTitle( Namespace::getImage(), $name );
+ $nt = Title::makeTitleSafe( NS_IMAGE, $name );
return $this->makeImageLinkObj( $nt, $alt );
}
@@ -1839,7 +1939,7 @@ class Skin {
$u = $nt->escapeLocalURL();
if ( $url == '' )
{
- $s = str_replace( "$1", $img->getName(), wfMsg('missingimage') );
+ $s = wfMsg( 'missingimage', $img->getName() );
$s .= "
{$alt}
{$url}
\n";
} else {
$s = '' .
@@ -1851,23 +1951,33 @@ class Skin {
return str_replace("\n", ' ',$prefix.$s.$postfix);
}
-
+ /**
+ * Make HTML for a thumbnail including image, border and caption
+ * $img is an Image object
+ */
function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
global $wgStylePath, $wgLang;
- # $image = Title::makeTitle( Namespace::getImage(), $name );
+ # $image = Title::makeTitleSafe( NS_IMAGE, $name );
$url = $img->getURL();
#$label = htmlspecialchars( $label );
$alt = preg_replace( '/<[^>]*>/', '', $label);
$alt = htmlspecialchars( $alt );
+ $width = $height = 0;
if ( $img->exists() )
{
$width = $img->getWidth();
$height = $img->getHeight();
- } else {
+ }
+ if ( 0 == $width || 0 == $height )
+ {
$width = $height = 200;
}
+ if ( $boxwidth == 0 )
+ {
+ $boxwidth = 200;
+ }
if ( $framed )
{
// Use image dimensions, don't scale
@@ -1889,7 +1999,7 @@ class Skin {
if ( $manual_thumb != '' ) # Use manually specified thumbnail
{
- $manual_title = Title::makeTitle( Namespace::getImage(), $manual_thumb ); #new Title ( $manual_thumb ) ;
+ $manual_title = Title::makeTitleSafe( NS_IMAGE, $manual_thumb ); #new Title ( $manual_thumb ) ;
$manual_img = Image::newFromTitle( $manual_title );
$thumbUrl = $manual_img->getURL();
if ( $manual_img->exists() )
@@ -1910,7 +2020,7 @@ class Skin {
$s = "" . wfMsg( 'imghistory' ) . "
\n" .
"';
return $s;
}
- # Returns text for the end of RC
- # If enhanced RC is in use, returns pretty much all the text
- function endRecentChangesList()
- {
+ /**
+ * Returns text for the end of RC
+ * If enhanced RC is in use, returns pretty much all the text
+ */
+ function endRecentChangesList() {
$s = $this->recentChangesBlock() ;
if( $this->rclistOpen ) {
$s .= "
\n";
@@ -2004,9 +2111,10 @@ class Skin {
return $s;
}
- # Enhanced RC ungrouped line
- function recentChangesBlockLine ( $rcObj )
- {
+ /**
+ * Enhanced RC ungrouped line
+ */
+ function recentChangesBlockLine ( $rcObj ) {
global $wgStylePath, $wgLang ;
# Get rc_xxxx variables
@@ -2016,7 +2124,7 @@ class Skin {
# Spacer image
$r = '' ;
- $r .= '' ;
+ $r .= '
' ;
$r .= '' ;
if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
@@ -2061,7 +2169,7 @@ class Skin {
# Comment
if ( $rc_comment != '' && $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
- $rc_comment=$this->formatComment($rc_comment);
+ $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
$r .= $wgLang->emphasize( ' ('.$rc_comment.')' );
}
@@ -2069,9 +2177,10 @@ class Skin {
return $r ;
}
- # Enhanced RC group
- function recentChangesBlockGroup ( $block )
- {
+ /**
+ * Enhanced RC group
+ */
+ function recentChangesBlockGroup ( $block ) {
global $wgStylePath, $wgLang ;
$r = '' ;
@@ -2106,8 +2215,8 @@ class Skin {
$rcm = 'RCM'.$this->rcCacheIndex ;
$toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
$arrowdir = $wgLang->isRTL() ? 'l' : 'r';
- $tl = '
' ;
- $tl .= ' ' ;
+ $tl = '
' ;
+ $tl .= ' ' ;
$r .= $tl ;
# Main line
@@ -2149,7 +2258,7 @@ class Skin {
# Get rc_xxxx variables
extract( $rcObj->mAttribs );
- $r .= '
';
+ $r .= '
';
$r .= ' ' ;
if ( $rc_new ) $r .= $N ;
else $r .= ' ' ;
@@ -2176,7 +2285,7 @@ class Skin {
$r .= ') . . '.$rcObj->userlink ;
$r .= $rcObj->usertalklink ;
if ( $rc_comment != '' ) {
- $rc_comment=$this->formatComment($rc_comment);
+ $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
$r .= $wgLang->emphasize( ' ('.$rc_comment.')' ) ;
}
$r .= "
\n" ;
@@ -2187,10 +2296,11 @@ class Skin {
return $r ;
}
- # If enhanced RC is in use, this function takes the previously cached
- # RC lines, arranges them, and outputs the HTML
- function recentChangesBlock ()
- {
+ /**
+ * If enhanced RC is in use, this function takes the previously cached
+ * RC lines, arranges them, and outputs the HTML
+ */
+ function recentChangesBlock () {
global $wgStylePath ;
if ( count ( $this->rc_cache ) == 0 ) return '' ;
$blockOut = '';
@@ -2205,10 +2315,11 @@ class Skin {
return '
';
if($level) {
@@ -2580,7 +2726,16 @@ class Skin {
$toc."\n";
}
- # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
+ /**
+ * These two do not check for permissions: check $wgTitle->userCanEdit
+ * before calling them
+ */
+ function editSectionScriptForOther( $title, $section, $head ) {
+ $ttl = Title::newFromText( $title );
+ $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
+ return ''.$head.'';
+ }
+
function editSectionScript( $section, $head ) {
global $wgTitle, $wgRequest;
if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
@@ -2590,6 +2745,25 @@ class Skin {
return ''.$head.'';
}
+ function editSectionLinkForOther( $title, $section ) {
+ global $wgRequest;
+ global $wgUser, $wgLang;
+
+ $title = Title::newFromText($title);
+ $editurl = '§ion='.$section;
+ $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
+
+ if( $wgLang->isRTL() ) {
+ $farside = 'left';
+ $nearside = 'right';
+ } else {
+ $farside = 'right';
+ $nearside = 'left';
+ }
+ return "