/**
*
* @package MediaWiki
+ * @subpackage Skins
*/
/**
# See skin.doc
require_once( 'Image.php' );
-# These are the INTERNAL names, which get mapped directly to class names and
-# file names in ./skins/. For display purposes, the Language class has
-# internationalized names
-#
-/*
-$wgValidSkinNames = array(
- 'standard' => 'Standard',
- 'nostalgia' => 'Nostalgia',
- 'cologneblue' => 'CologneBlue'
-);
-if( $wgUsePHPTal ) {
- #$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
'texts' => array(),
'titles' => array()
);
+global $wgInterwikiLinkHolders;
+$wgInterwikiLinkHolders = array();
/**
* @todo document
var $rc_cache ; # Cache for Enhanced Recent Changes
var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
var $rcMoveIndex;
- var $postParseLinkColour = true;
+ var $postParseLinkColour = false;
/**#@-*/
function Skin() {
- global $wgUseOldExistenceCheck;
- $postParseLinkColour = !$wgUseOldExistenceCheck;
$this->linktrail = wfMsg('linktrail');
}
}
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 .'";';
return $s;
}
+
function getCategoryLinks () {
global $wgOut, $wgTitle, $wgUser, $wgParser;
global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
$s .= '<br/><hr/>';
# get a big array of the parents tree
- $parenttree = $wgTitle->getCategorieBrowser();
+ $parenttree = $wgTitle->getParentCategoryTree();
# Render the array as a serie of links
function walkThrough ($tree) {
# add our current element to the list
$eltitle = Title::NewFromText($element);
# FIXME : should be makeLink() [AV]
- $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > ';
+ $return .= $sk->makeLink($element, $eltitle->getText()).' > ';
}
return $return;
}
}
function doAfterContent() {
- global $wgUser, $wgOut, $wgContLang;
- $fname = 'Skin::doAfterContent';
- wfProfileIn( $fname );
- wfProfileIn( $fname.'-1' );
-
- $s = "\n</div><br style=\"clear:both\" />\n";
- $s .= "\n<div id='footer'>";
- $s .= '<table border="0" cellspacing="0"><tr>';
-
- wfProfileOut( $fname.'-1' );
- wfProfileIn( $fname.'-2' );
-
- $qb = $this->qbSetting();
- $shove = ($qb != 0);
- $left = ($qb == 1 || $qb == 3);
- if($wgContLang->isRTL()) $left = !$left;
-
- if ( $shove && $left ) { # Left
- $s .= $this->getQuickbarCompensator();
- }
- wfProfileOut( $fname.'-2' );
- wfProfileIn( $fname.'-3' );
- $l = $wgContLang->isRTL() ? 'right' : 'left';
- $s .= "<td class='bottom' align='$l' valign='top'>";
-
- $s .= $this->bottomLinks();
- $s .= "\n<br />" . $this->mainPageLink()
- . ' | ' . $this->aboutLink()
- . ' | ' . $this->specialLink( 'recentchanges' )
- . ' | ' . $this->searchForm()
- . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
-
- $s .= "</td>";
- if ( $shove && !$left ) { # Right
- $s .= $this->getQuickbarCompensator();
- }
- $s .= "</tr></table>\n</div>\n</div>\n";
-
- wfProfileOut( $fname.'-3' );
- wfProfileIn( $fname.'-4' );
- if ( 0 != $qb ) { $s .= $this->quickBar(); }
- wfProfileOut( $fname.'-4' );
- wfProfileOut( $fname );
- return $s;
+ # overloaded by derived classes
}
function pageTitleLinks() {
$action = $wgRequest->getText( 'action' );
$s = $this->printableLink();
- if ( wfMsg ( 'disclaimers' ) != '-' )
- $s .= ' | ' . $this->makeKnownLink(
- wfMsgForContent( 'disclaimerpage' ),
- wfMsg( 'disclaimers' ) ) ;
+ $disclaimer = $this->disclaimerLink(); # may be empty
+ if( $disclaimer ) {
+ $s .= ' | ' . $disclaimer;
+ }
if ( $wgOut->isArticleRelated() ) {
if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
$s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
# disable caching
$wgOut->setSquidMaxage(0);
+ $wgOut->enableClientCache(false);
}
}
function getUndeleteLink() {
global $wgUser, $wgTitle, $wgContLang, $action;
- if( $wgUser->isSysop() &&
+ if( $wgUser->isAllowed('rollback') &&
(($wgTitle->getArticleId() == 0) || ($action == "history")) &&
($n = $wgTitle->isDeleted() ) ) {
return wfMsg( 'thisisdeleted',
global $wgOut, $wgTitle, $wgUser;
$s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
- if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
+ if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
return $s;
}
}
}
}
- if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
- $s .= "\n<br />" . $this->deleteThisPage() .
- $sep . $this->protectThisPage() .
- $sep . $this->moveThisPage();
+ if ( $wgTitle->getArticleId() ) {
+ $s .= "\n<br />";
+ if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
+ if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
+ if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
}
$s .= "<br />\n" . $this->otherLanguages();
}
$oldid = $wgRequest->getVal( 'oldid' );
$diff = $wgRequest->getVal( 'diff' );
- if ( !is_null( $oldid ) && is_null( $diff ) && wfMsg( 'history_copyright' ) !== '-' ) {
+ if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
$msg = 'history_copyright';
} else {
$msg = 'copyright';
# Give up now
return $out;
}
- $out .= wfMsg( $msg, $link );
+ $out .= wfMsgForContent( $msg, $link );
return $out;
}
return $s;
}
- function quickBar() {
- global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
- global $wgDisableUploads, $wgRemoteUploads;
-
- $fname = 'Skin::quickBar';
- wfProfileIn( $fname );
-
- $action = $wgRequest->getText( 'action' );
- $wpPreview = $wgRequest->getBool( 'wpPreview' );
- $tns=$wgTitle->getNamespace();
-
- $s = "\n<div id='quickbar'>";
- $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
-
- $sep = "\n<br />";
- $s .= $this->mainPageLink()
- . $sep . $this->specialLink( 'recentchanges' )
- . $sep . $this->specialLink( 'randompage' );
- if ($wgUser->getID()) {
- $s.= $sep . $this->specialLink( 'watchlist' ) ;
- $s .= $sep .$this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
- wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
-
- }
- // only show watchlist link if logged in
- if ( wfMsg ( 'currentevents' ) != '-' )
- $s .= $sep . $this->makeKnownLink( wfMsgForContent( 'currentevents' ), '' ) ;
- $s .= "\n<br /><hr class='sep' />";
- $articleExists = $wgTitle->getArticleId();
- if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
- if($wgOut->isArticle()) {
- $s .= '<strong>' . $this->editThisPage() . '</strong>';
- } else { # backlink to the article in edit or history mode
- if($articleExists){ # no backlink if no article
- switch($tns) {
- case 0:
- $text = wfMsg('articlepage');
- break;
- case 1:
- $text = wfMsg('viewtalkpage');
- break;
- case 2:
- $text = wfMsg('userpage');
- break;
- case 3:
- $text = wfMsg('viewtalkpage');
- break;
- case 4:
- $text = wfMsg('wikipediapage');
- break;
- case 5:
- $text = wfMsg('viewtalkpage');
- break;
- case 6:
- $text = wfMsg('imagepage');
- break;
- case 7:
- $text = wfMsg('viewtalkpage');
- break;
- default:
- $text= wfMsg('articlepage');
- }
-
- $link = $wgTitle->getText();
- if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
- $link = $nstext . ':' . $link ;
- }
-
- $s .= $this->makeLink( $link, $text );
- } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
- # we just throw in a "New page" text to tell the user that he's in edit mode,
- # and to avoid messing with the separator that is prepended to the next item
- $s .= '<strong>' . wfMsg('newpage') . '</strong>';
- }
-
- }
-
-
- if( $tns%2 && $action!='edit' && !$wpPreview) {
- $s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new');
- }
-
- /*
- watching could cause problems in edit mode:
- if user edits article, then loads "watch this article" in background and then saves
- article with "Watch this article" checkbox disabled, the article is transparently
- unwatched. Therefore we do not show the "Watch this page" link in edit mode
- */
- if ( 0 != $wgUser->getID() && $articleExists) {
- if($action!='edit' && $action != 'submit' )
- {
- $s .= $sep . $this->watchThisPage();
- }
- if ( $wgTitle->userCanEdit() )
- $s .= $sep . $this->moveThisPage();
- }
- if ( $wgUser->isSysop() and $articleExists ) {
- $s .= $sep . $this->deleteThisPage() .
- $sep . $this->protectThisPage();
- }
- $s .= $sep . $this->talkLink();
- if ($articleExists && $action !='history') {
- $s .= $sep . $this->historyLink();
- }
- $s.=$sep . $this->whatLinksHere();
-
- if($wgOut->isArticleRelated()) {
- $s .= $sep . $this->watchPageLinksLink();
- }
-
- if ( Namespace::getUser() == $wgTitle->getNamespace()
- || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
- ) {
-
- $id=User::idFromName($wgTitle->getText());
- $ip=User::isIP($wgTitle->getText());
-
- if($id||$ip) {
- $s .= $sep . $this->userContribsLink();
- }
- if ( 0 != $wgUser->getID() ) {
- if($id) { # can only email real users
- $s .= $sep . $this->emailUserLink();
- }
- }
- }
- $s .= "\n<br /><hr class='sep' />";
- }
-
- if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
- $s .= $this->specialLink( 'upload' ) . $sep;
- }
- $s .= $this->specialLink( 'specialpages' )
- . $sep . $this->bugReportsLink();
-
- global $wgSiteSupportPage;
- if( $wgSiteSupportPage ) {
- $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
- '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
- }
-
- $s .= "\n<br /></div>\n";
- wfProfileOut( $fname );
- return $s;
- }
-
+ /**
+ * show a drop-down box of special pages
+ * @TODO crash bug913. Need to be rewrote completly.
+ */
function specialPagesList() {
global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
require_once('SpecialPage.php');
function disclaimerLink() {
- $s = $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
- wfMsg( 'disclaimers' ) );
- return $s;
+ $disclaimers = wfMsg( 'disclaimers' );
+ if ($disclaimers == '-') {
+ return "";
+ } else {
+ return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
+ $disclaimers );
+ }
}
function editThisPage() {
global $wgUser, $wgOut, $wgTitle, $wgRequest;
$diff = $wgRequest->getVal( 'diff' );
- if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
+ if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
$n = $wgTitle->getPrefixedText();
$t = wfMsg( 'deletethispage' );
global $wgUser, $wgOut, $wgTitle, $wgRequest;
$diff = $wgRequest->getVal( 'diff' );
- if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
+ if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
$n = $wgTitle->getPrefixedText();
if ( $wgTitle->isProtected() ) {
$trail = $m[2];
}
}
- $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
+ # Assume $this->postParseLinkColour(). This prevents
+ # interwiki links from being parsed as external links.
+ global $wgInterwikiLinkHolders;
+ $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
+ $nr = array_push($wgInterwikiLinkHolders, $t);
+ $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
} elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} elseif ( ( -1 == $nt->getNamespace() ) ||
- ( Namespace::getImage() == $nt->getNamespace() ) ) {
+ ( NS_IMAGE == $nt->getNamespace() ) ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} else {
if ( $this->postParseLinkColour() ) {
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
}
+
+ # If url string starts with http, consider as external URL, else
+ # internal
+ /*static*/ function makeInternalOrExternalUrl( $name ) {
+ if ( strncmp( $name, 'http', 4 ) == 0 ) {
+ return $name;
+ } else {
+ return $this->makeUrl( $name );
+ }
+ }
+
# this can be passed the NS number as defined in Language.php
/*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
$title = Title::makeTitleSafe( $namespace, $name );
function makeImage( $url, $alt = '' ) {
global $wgOut;
-
if ( '' == $alt ) {
$alt = $this->fnamePart( $url );
}
function makeImageLinkObj( $nt, $alt = '' ) {
global $wgContLang, $wgUseImageResize;
$img = Image::newFromTitle( $nt );
- $url = $img->getURL();
+ $url = $img->getViewURL();
$align = '';
$prefix = $postfix = '';
- if ( $wgUseImageResize ) {
- # Check if the alt text is of the form "options|alt text"
- # Options are:
- # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
- # * left no resizing, just left align. label is used for alt= only
- # * right same, but right aligned
- # * none same, but not aligned
- # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
- # * center center the image
- # * framed Keep original image size, no magnify-button.
-
- $part = explode( '|', $alt);
-
- $mwThumb =& MagicWord::get( MAG_IMG_THUMBNAIL );
- $mwLeft =& MagicWord::get( MAG_IMG_LEFT );
- $mwRight =& MagicWord::get( MAG_IMG_RIGHT );
- $mwNone =& MagicWord::get( MAG_IMG_NONE );
- $mwWidth =& MagicWord::get( MAG_IMG_WIDTH );
- $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
- $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
- $alt = $part[count($part)-1];
-
- $height = $framed = $thumb = false;
- $manual_thumb = "" ;
-
- foreach( $part as $key => $val ) {
- $val_parts = explode ( "=" , $val , 2 ) ;
- $left_part = array_shift ( $val_parts ) ;
- if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
- $thumb=true;
- } elseif ( count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
- # use manually specified thumbnail
- $thumb=true;
- $manual_thumb = array_shift ( $val_parts ) ;
- } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'right';
- } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'left';
- } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'center';
- } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'none';
- } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
- # $match is the image width in pixels
- if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
- $width = intval( $m[1] );
- $height = intval( $m[2] );
- } else {
- $width = intval($match);
- }
- } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
- $framed=true;
+ # Check if the alt text is of the form "options|alt text"
+ # Options are:
+ # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
+ # * left no resizing, just left align. label is used for alt= only
+ # * right same, but right aligned
+ # * none same, but not aligned
+ # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
+ # * center center the image
+ # * framed Keep original image size, no magnify-button.
+
+ $part = explode( '|', $alt);
+
+ $mwThumb =& MagicWord::get( MAG_IMG_THUMBNAIL );
+ $mwLeft =& MagicWord::get( MAG_IMG_LEFT );
+ $mwRight =& MagicWord::get( MAG_IMG_RIGHT );
+ $mwNone =& MagicWord::get( MAG_IMG_NONE );
+ $mwWidth =& MagicWord::get( MAG_IMG_WIDTH );
+ $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
+ $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
+ $alt = '';
+
+ $height = $framed = $thumb = false;
+ $manual_thumb = "" ;
+
+ foreach( $part as $key => $val ) {
+ $val_parts = explode ( "=" , $val , 2 ) ;
+ $left_part = array_shift ( $val_parts ) ;
+ if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
+ $thumb=true;
+ } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
+ # use manually specified thumbnail
+ $thumb=true;
+ $manual_thumb = array_shift ( $val_parts ) ;
+ } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
+ # remember to set an alignment, don't render immediately
+ $align = 'right';
+ } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
+ # remember to set an alignment, don't render immediately
+ $align = 'left';
+ } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
+ # remember to set an alignment, don't render immediately
+ $align = 'center';
+ } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
+ # remember to set an alignment, don't render immediately
+ $align = 'none';
+ } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
+ # $match is the image width in pixels
+ if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
+ $width = intval( $m[1] );
+ $height = intval( $m[2] );
+ } else {
+ $width = intval($match);
}
+ } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
+ $framed=true;
+ } else {
+ $alt = $val;
}
- if ( 'center' == $align )
- {
- $prefix = '<span style="text-align: center">';
- $postfix = '</span>';
- $align = 'none';
- }
-
- if ( $thumb || $framed ) {
-
- # Create a thumbnail. Alignment depends on language
- # writing direction, # right aligned for left-to-right-
- # languages ("Western languages"), left-aligned
- # for right-to-left-languages ("Semitic languages")
- #
- # If thumbnail width has not been provided, it is set
- # here to 180 pixels
- if ( $align == '' ) {
- $align = $wgContLang->isRTL() ? 'left' : 'right';
- }
- if ( ! isset($width) ) {
- $width = 180;
- }
- return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
+ }
+ if ( 'center' == $align )
+ {
+ $prefix = '<div class="center">';
+ $postfix = '</div>';
+ $align = 'none';
+ }
+
+ if ( $thumb || $framed ) {
+
+ # Create a thumbnail. Alignment depends on language
+ # writing direction, # right aligned for left-to-right-
+ # languages ("Western languages"), left-aligned
+ # for right-to-left-languages ("Semitic languages")
+ #
+ # If thumbnail width has not been provided, it is set
+ # here to 180 pixels
+ if ( $align == '' ) {
+ $align = $wgContLang->isRTL() ? 'left' : 'right';
+ }
+ if ( ! isset($width) ) {
+ $width = 180;
+ }
+ return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
- } elseif ( isset($width) ) {
+ } elseif ( isset($width) ) {
- # Create a resized image, without the additional thumbnail
- # features
+ # Create a resized image, without the additional thumbnail
+ # features
- if ( ( ! $height === false )
- && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
- print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
- print 'rescaling by factor '. $height / $img->getHeight() . "<br>\n";
- $width = $img->getWidth() * $height / $img->getHeight();
- }
- if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
+ if ( ( ! $height === false )
+ && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
+ $width = $img->getWidth() * $height / $img->getHeight();
}
- } # endif $wgUseImageResize
-
- if ( empty( $alt ) ) {
- $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
+ if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
}
- $alt = htmlspecialchars( $alt );
+
+ $alt = preg_replace( '/<[^>]*>/', '', $alt );
+ $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
+ $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
$u = $nt->escapeLocalURL();
- if ( $url == '' )
- {
+ if ( $url == '' ) {
$s = wfMsg( 'missingimage', $img->getName() );
$s .= "<br>{$alt}<br>{$url}<br>\n";
} else {
$s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
- '<img src="'.$url.'" alt="'.$alt.'" /></a>';
+ '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
}
if ( '' != $align ) {
$s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
global $wgStylePath, $wgContLang;
# $image = Title::makeTitleSafe( NS_IMAGE, $name );
- $url = $img->getURL();
+ $url = $img->getViewURL();
#$label = htmlspecialchars( $label );
$alt = preg_replace( '/<[^>]*>/', '', $label);
- $alt = htmlspecialchars( $alt );
+ $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
+ $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
$width = $height = 0;
if ( $img->exists() )
{
$manual_title = Title::makeTitleSafe( NS_IMAGE, $manual_thumb ); #new Title ( $manual_thumb ) ;
$manual_img = Image::newFromTitle( $manual_title );
- $thumbUrl = $manual_img->getURL();
+ $thumbUrl = $manual_img->getViewURL();
if ( $manual_img->exists() )
{
$width = $manual_img->getWidth();
} else {
$s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
'<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
- 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
+ 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
+ 'longdesc="'.$u.'" /></a>';
if ( $framed ) {
$zoomicon="";
} else {
}
function makeMediaLink( $name, $url, $alt = '' ) {
- $nt = Title::makeTitleSafe( Namespace::getMedia(), $name );
+ $nt = Title::makeTitleSafe( NS_IMAGE, $name );
return $this->makeMediaLinkObj( $nt, $alt );
}
- function makeMediaLinkObj( $nt, $alt = '' ) {
+ function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
if ( ! isset( $nt ) )
{
### HOTFIX. Instead of breaking, return empty string.
$s = $alt;
} else {
- $name = $nt->getDBKey();
- $url = Image::wfImageUrl( $name );
+ $name = $nt->getDBKey();
+ $img = Image::newFromTitle( $nt );
+ $url = $img->getURL();
+ # $nourl can be set by the parser
+ # this is a hack to mask absolute URLs, so the parser doesn't
+ # linkify them (it is currently not context-aware)
+ # 2004-10-25
+ if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
if ( empty( $alt ) ) {
$alt = preg_replace( '/\.(.+?)^/', '', $name );
}
-
$u = htmlspecialchars( $url );
- $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
+ $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
}
return $s;
}
if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$r .= ' ';
} else {
- # M & N (minor & new)
+ # M, N and !
$M = wfMsg( 'minoreditletter' );
$N = wfMsg( 'newpageletter' );
} else {
$r .= ' ' ;
}
+ if ( $rcObj->unpatrolled ) {
+ $r .= '!';
+ } else {
+ $r .= ' ';
+ }
}
# Timestamp
# Collate list of users
$isnew = false ;
+ $unpatrolled = false;
$userlinks = array () ;
foreach ( $block AS $rcObj ) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
- if ( $rcObj->mAttribs['rc_new'] ) $isnew = true ;
+ if ( $rcObj->mAttribs['rc_new'] ) {
+ $isnew = true ;
+ }
$u = $rcObj->userlink ;
- if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
+ if ( !isset ( $userlinks[$u] ) ) {
+ $userlinks[$u] = 0 ;
+ }
+ if ( $rcObj->unpatrolled ) {
+ $unpatrolled = true;
+ }
$userlinks[$u]++ ;
}
$rcm = 'RCM'.$this->rcCacheIndex ;
$toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
$arrowdir = $wgContLang->isRTL() ? 'l' : 'r';
- $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
- $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
+ $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
+ $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" alt="-" /></a></span>' ;
$r .= $tl ;
# Main line
if ( $isnew ) $r .= $N ;
else $r .= ' ' ;
$r .= ' ' ; # Minor
+ if ( $unpatrolled ) {
+ $r .= "!";
+ } else {
+ $r .= " ";
+ }
# Timestamp
$r .= ' '.$block[0]->timestamp.' ' ;
$r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
$r .= '<tt> ' ;
- if ( $rc_new ) $r .= $N ;
- else $r .= ' ' ;
- if ( $rc_minor ) $r .= $M ;
- else $r .= ' ' ;
- $r .= '</tt>' ;
+ if ( $rc_new ) {
+ $r .= $N ;
+ } else {
+ $r .= ' ' ;
+ }
+
+ if ( $rc_minor ) {
+ $r .= $M ;
+ } else {
+ $r .= ' ' ;
+ }
+
+ if ( $rcObj->unpatrolled ) {
+ $r .= "!";
+ } else {
+ $r .= " ";
+ }
+
+ $r .= ' </tt>' ;
$o = '' ;
if ( $rc_last_oldid != 0 ) {
extract( $rc->mAttribs );
$curIdEq = 'curid=' . $rc_cur_id;
+ # Should patrol-related stuff be shown?
+ $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
+ ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
+
# Make date header if necessary
$date = $wgContLang->date( $rc_timestamp, true);
$uidate = $wgLang->date( $rc_timestamp, true);
$s = '';
if ( $date != $this->lastdate ) {
if ( '' != $this->lastdate ) { $s .= "</ul>\n"; }
- $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
+ $s .= "<h4>{$uidate}</h4>\n<ul class=\"special\">";
$this->lastdate = $date;
$this->rclistOpen = true;
}
- # If this edit has not yet been patrolled, make it stick out
- $s .= ( ! $wgUseRCPatrol || $rc_patrolled ) ? '<li> ' : '<li class="not_patrolled"> ';
+ $s .= '<li>';
if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
# Diff
if ( $rc_type == RC_NEW || $rc_type == RC_LOG ) {
$diffLink = wfMsg( 'diff' );
} else {
- if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
- ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
+ if ( $unpatrolled )
$rcidparam = "&rcid={$rc_id}";
else
$rcidparam = "";
$s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
$s .= ') . . ';
- # M and N (minor and new)
+ # M, N and ! (minor, new and unpatrolled)
if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
if ( $rc_type == RC_NEW ) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
+ if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
# Article link
# If it's a new article, there is no diff link, but if it hasn't been
# patrolled yet, we need to give users a way to do so
- if ( $wgUseRCPatrol && $rc_type == RC_NEW && $rc_patrolled == 0 &&
- $wgUser->getID() != 0 && ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
+ if ( $unpatrolled && $rc_type == RC_NEW )
$articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
else
$articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
}
# Block link
$blockLink='';
- if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
+ if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
$blockLink = $this->makeKnownLink( $wgContLang->specialPage(
'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
function recentChangesLineNew( &$baseRC, $watched = false ) {
global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
-
+ global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
+
# Create a specialised object
$rc = RCCacheEntry::newFromParent( $baseRC ) ;
$ret .= "<h4>{$uidate}</h4>\n";
$this->lastdate = $date;
}
-
+
+ # Should patrol-related stuff be shown?
+ if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
+ ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) {
+ $rc->unpatrolled = !$rc_patrolled;
+ } else {
+ $rc->unpatrolled = false;
+ }
+
# Make article link
if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
$logtype = $matches[1];
$logname = LogPage::logName( $logtype );
$clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
+ } elseif ( $rc->unpatrolled && $rc_type == RC_NEW ) {
+ # Unpatrolled new page, give rc_id in query
+ $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
} else {
$clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
}
# Make "last" link
$titleObj = $rc->getTitle();
+ if ( $rc->unpatrolled ) {
+ $rcIdQuery = "&rcid={$rc_id}";
+ } else {
+ $rcIdQuery = '';
+ }
if ( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$lastLink = wfMsg( 'last' );
} else {
$lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
- $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
+ $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
}
# Make user link (or user contributions for unregistered users)
$userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
global $wgDisableAnonTalk;
- if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
+ if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
$blockLink = $this->makeKnownLink( $wgContLang->specialPage(
'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
if( $wgDisableAnonTalk )
if ( $iscur ) {
$url = Image::wfImageUrl( $img );
$rlink = $cur;
- if ( $wgUser->isSysop() ) {
+ if ( $wgUser->isAllowed('delete') ) {
$link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
'&action=delete' );
$style = $this->getInternalLinkAttributes( $link, $delall );
$hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
return
'<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
- '<b>'.wfMsg('toc').'</b>' .
+ '<b>'.wfMsgForContent('toc').'</b>' .
$hideline .
'</td></tr><tr id="tocinside"><td>'."\n".
$toc."</td></tr></table>\n";
return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
}
- function editSectionScript( $section, $head ) {
- global $wgTitle, $wgRequest;
+ function editSectionScript( $nt, $section, $head ) {
+ global $wgRequest;
if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
return $head;
}
- $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
+ $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
}
function editSectionLinkForOther( $title, $section ) {
global $wgRequest;
- global $wgUser, $wgContLang;
+ global $wgContLang;
$title = Title::newFromText($title);
$editurl = '§ion='.$section;
}
- function editSectionLink( $section ) {
+ function editSectionLink( $nt, $section ) {
global $wgRequest;
- global $wgTitle, $wgUser, $wgContLang;
+ global $wgContLang;
if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
# Section edit links would be out of sync on an old page.
}
$editurl = '§ion='.$section;
- $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
+ $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
if( $wgContLang->isRTL() ) {
$farside = 'left';