X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=c4686d12d50b1425f6edcd151f9f79d67ad8a35e;hb=6267cadb18e9537753e69d1af7ff144cbc12f410;hp=6a416c864c60fd48040d23bbaf426b03cd362775;hpb=471346b622339afefaef18e3d411039b9d1171b5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 6a416c864c..c4686d12d5 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,6 +1,7 @@ "Standard", + 'standard' => "Standard", 'nostalgia' => "Nostalgia", 'cologneblue' => "CologneBlue" ); -if( $wgUseSmarty ) { - $wgValidSkinNames['smarty'] = "Smarty"; - $wgValidSkinNames['montparnasse'] = "Montparnasse"; -} if( $wgUsePHPTal ) { #$wgValidSkinNames[] = "PHPTal"; #$wgValidSkinNames['davinci'] = "DaVinci"; @@ -27,23 +24,6 @@ if( $wgUsePHPTal ) { include_once( "RecentChange.php" ); -# For some odd PHP bug, this function can't be part of a class -function getCategories () -{ - global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser , $wgParser ; - if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return "" ; - if ( count ( $wgOut->mCategoryLinks ) == 0 ) return "" ; - if ( !$wgOut->isArticle() ) return "" ; - $sk = $wgUser->getSkin() ; - $s = "" ; - $s .= "\n
\n"; - $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ; - $t = implode ( " | " , $wgOut->mCategoryLinks ) ; - if ( $t != "" ) $s .= " : " ; - $s .= $t ; - return $s ; -} - class RCCacheEntry extends RecentChange { var $secureName, $link; @@ -95,15 +75,52 @@ class Skin { function initPage( &$out ) { - global $wgStyleSheetPath; $fname = "Skin::initPage"; wfProfileIn( $fname ); - $out->addLink( "shortcut icon", "", "/favicon.ico" ); + $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) ); + $this->addMetadataLinks($out); + wfProfileOut( $fname ); } + function addMetadataLinks( &$out ) { + global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action; + global $wgRightsPage, $wgRightsUrl; + + if( $out->isArticleRelated() ) { + # note: buggy CC software only reads first "meta" link + if( $wgEnableCreativeCommonsRdf ) { + $out->addMetadataLink( array( + 'title' => 'Creative Commons', + 'type' => 'application/rdf+xml', + 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) ); + } + if( $wgEnableDublinCoreRdf ) { + $out->addMetadataLink( array( + 'title' => 'Dublin Core', + 'type' => 'application/rdf+xml', + 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) ); + } + } + $copyright = ""; + if( $wgRightsPage ) { + $copy = Title::newFromText( $wgRightsPage ); + if( $copy ) { + $copyright = $copy->getLocalURL(); + } + } + if( !$copyright && $wgRightsUrl ) { + $copyright = $wgRightsUrl; + } + if( $copyright ) { + $out->addLink( array( + "rel" => "copyright", + "href" => $copyright ) ); + } + } + function outputPage( &$out ) { global $wgDebugComments; @@ -134,18 +151,18 @@ class Skin { } function getHeadScripts() { - global $wgStyleSheetPath; - $r = "\n"; + global $wgStylePath; + $r = "\n"; return $r; } function getUserStyles() { - global $wgOut, $wgStyleSheetPath; + global $wgOut, $wgStylePath; $sheet = $this->getStylesheet(); $s = "\n"; @@ -162,7 +179,7 @@ class Skin { } else { # CHECK MERGE @@@ # Force no underline - $s .= "a.stub, a.new, a.internal, a.external { " . + $s .= "a { " . "text-decoration: none; }\n"; } if ( 1 == $wgUser->getOption( "highlightbroken" ) ) { @@ -188,7 +205,7 @@ class Skin { (!$wgTitle->isProtected() || $wgUser->isSysop()) ) { $t = wfMsg( "editthispage" ); $oid = $red = ""; - if ( $redirect ) { + if ( !empty($redirect) ) { $red = "&redirect={$redirect}"; } if ( !empty($oldid) && ! isset( $diff ) ) { @@ -307,7 +324,7 @@ class Skin { if($wgLang->isRTL()) $left = !$left; if ( !$shove ) { - $s .= "\n" . + $s .= "\n" . $this->logoText() . ""; } elseif( $left ) { $s .= $this->getQuickbarCompensator( $rows ); @@ -335,10 +352,24 @@ class Skin { $s .= $this->pageTitle(); $s .= $this->pageSubtitle() ; - $s .= getCategories(); // For some odd reason, zhis can't be a function of the object + $s .= $this->getCategories(); wfProfileOut( $fname ); return $s; } + + function getCategories () { + global $wgOut, $wgTitle, $wgUser, $wgParser; + global $wgUseCategoryMagic; + if( !$wgUseCategoryMagic ) return "" ; + if( count( $wgOut->mCategoryLinks ) == 0 ) return ""; + if( !$wgOut->isArticle() ) return ""; + + $t = implode ( " | " , $wgOut->mCategoryLinks ) ; + $s = $this->makeKnownLink( "Special:Categories", + wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) ) + . ": " . $t; + return ""; + } function getQuickbarCompensator( $rows = 1 ) { @@ -424,7 +455,7 @@ class Skin { if ( $wgOut->isArticleRelated() ) { if ( $wgTitle->getNamespace() == Namespace::getImage() ) { $name = $wgTitle->getDBkey(); - $link = wfEscapeHTML( wfImageUrl( $name ) ); + $link = wfEscapeHTML( Image::wfImageUrl( $name ) ); $style = $this->getInternalLinkAttributes( $link, $name ); $s .= " | {$name}"; } @@ -495,24 +526,33 @@ class Skin { { global $wgOut, $wgTitle, $wgUser; - $s = "

" . $wgOut->getPageTitle() . "

"; + $s = "

" . htmlspecialchars( $wgOut->getPageTitle() ) . "

"; if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);} return $s; } function pageSubtitle() { - global $wgOut,$wgTitle,$wgNamespacesWithSubpages; + global $wgOut; $sub = $wgOut->getSubtitle(); if ( "" == $sub ) { global $wgExtraSubtitle; $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle; } - if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) { + $subpages = $this->subPageSubtitle(); + $sub .= !empty($subpages)?"

$subpages":''; + $s = "

{$sub}

\n"; + return $s; + } + + function subPageSubtitle() + { + global $wgOut,$wgTitle,$wgNamespacesWithSubpages; + $subpages = ''; + if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) { $ptext=$wgTitle->getPrefixedText(); if(preg_match("/\//",$ptext)) { - $sub.="

"; $links=explode("/",$ptext); $c=0; $growinglink=""; @@ -523,19 +563,17 @@ class Skin { $getlink = $this->makeLink( $growinglink, $link ); if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time if ($c>1) { - $sub .= " | "; + $subpages .= " | "; } else { - $sub .="< "; + $subpages .="< "; } - $sub .= $getlink; + $subpages .= $getlink; $growinglink.="/"; } - } } } - $s = "

{$sub}

\n"; - return $s; + return $subpages; } function nameAndLogin() @@ -586,15 +624,23 @@ class Skin { return $s; } - + + function getSearchLink() { + $searchPage =& Title::makeTitle( NS_SPECIAL, "Search" ); + return $searchPage->getLocalURL(); + } + + function escapeSearchLink() { + return htmlspecialchars( $this->getSearchLink() ); + } + function searchForm() { global $wgRequest; - - $search = $wgRequest->getText( 'search' );; - + $search = $wgRequest->getText( 'search' ); + $s = "
\n" + . $this->escapeSearchLink() . "\">\n" . "\n" . " " @@ -667,7 +713,7 @@ class Skin { { global $wgOut, $wgLang, $wgArticle, $wgRequest; global $wgDisableCounters; - + extract( $wgRequest->getValues( 'oldid', 'diff' ) ); if ( ! $wgOut->isArticle() ) { return ""; } if ( isset( $oldid ) || isset( $diff ) ) { return ""; } @@ -680,9 +726,133 @@ class Skin { $s = wfMsg( "viewcount", $count ); } } - $s .= $this->lastModified(); - $s .= " " . wfMsg( "gnunote" ); - return $s; + + $s .= " " . $this->getCredits(); + + return $s . " " . $this->getCopyright(); + } + + function getCredits() { + global $wgMaxCredits; + + $s = ''; + + if (!isset($wgMaxCredits) || $wgMaxCredits == 0) { + $s = $this->lastModified(); + } else { + $s = $this->getAuthorCredits(); + if ($wgMaxCredits > 1) { + $s .= " " . $this->getContributorCredits(); + } + } + + return $s; + } + + function getAuthorCredits() { + global $wgLang, $wgArticle; + + $last_author = $wgArticle->getUser(); + + if ($last_author == 0) { + $author_credit = wfMsg("anonymous"); + } else { + $real_name = User::whoIsReal($last_author); + if (!empty($real_name)) { + $author_credit = $real_name; + } else { + $author_credit = wfMsg("siteuser", User::whoIs($last_author)); + } + } + + $timestamp = $wgArticle->getTimestamp(); + if ( $timestamp ) { + $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true ); + } else { + $d = ""; + } + return wfMsg("lastmodifiedby", $d, $author_credit); + } + + function getContributorCredits() { + + global $wgArticle, $wgMaxCredits, $wgLang; + + # don't count last editor + + $contributors = $wgArticle->getContributors($wgMaxCredits - 1); + + $real_names = array(); + $user_names = array(); + + # Sift for real versus user names + + foreach ($contributors as $user_id => $user_parts) { + if ($user_id != 0) { + if (!empty($user_parts[1])) { + $real_names[$user_id] = $user_parts[1]; + } else { + $user_names[$user_id] = $user_parts[0]; + } + } + } + + $real = $wgLang->listToText(array_values($real_names)); + $user = $wgLang->listToText(array_values($user_names)); + + if (!empty($user)) { + $user = wfMsg("siteusers", $user); + } + + if ($contributors[0] && $contributors[0][0] > 0) { + $anon = wfMsg("anonymous"); + } else { + $anon = ''; + } + + $creds = $wgLang->listToText(array($real, $user, $anon)); + + return wfMsg("othercontribs", $creds); + } + + function getCopyright() { + global $wgRightsPage, $wgRightsUrl, $wgRightsText; + $out = ""; + if( $wgRightsPage ) { + $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText ); + } elseif( $wgRightsUrl ) { + $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText ); + } else { + # Give up now + return $out; + } + $out .= wfMsg( "copyright", $link ); + return $out; + } + + function getCopyrightIcon() { + global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon; + $out = ""; + if( $wgRightsIcon ) { + $icon = htmlspecialchars( $wgRightsIcon ); + if( $wgRightsUrl ) { + $url = htmlspecialchars( $wgRightsUrl ); + $out .= ""; + } + $text = htmlspecialchars( $wgRightsText ); + $out .= "$text"; + if( $wgRightsUrl ) { + $out .= ""; + } + } + return $out; + } + + function getPoweredBy() { + global $wgStylePath; + $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" ); + $img = "MediaWiki"; + return $img; } function lastModified() @@ -780,7 +950,7 @@ class Skin { $link = $nstext . ":" . $link ; } - $s .= $this->makeLink( $link, $text ); + $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 @@ -892,7 +1062,7 @@ class Skin { $spp = $wgLang->specialPage( "Specialpages" ); $s = "\n"; + "action=\"" . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n"; $s .= "\n"; - $s .= "\n"; + $s .= "\n"; $s .= "
\n"; return $s; } @@ -1244,21 +1414,21 @@ class Skin { function makeLink( $title, $text = "", $query = "", $trail = "" ) { wfProfileIn( "Skin::makeLink" ); $nt = Title::newFromText( $title ); - if ($nt) { + if ($nt) { $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail ); } else { wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" ); $result = $text == "" ? $title : $text; - } - + } + wfProfileOut( "Skin::makeLink" ); return $result; } - function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) { + function makeKnownLink( $title, $text = "", $query = "", $trail = "", $prefix = '',$aprops = '') { $nt = Title::newFromText( $title ); - if ($nt) { - return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail ); + if ($nt) { + return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops ); } else { wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" ); return $text == "" ? $title : $text; @@ -1267,7 +1437,7 @@ class Skin { function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) { $nt = Title::newFromText( $title ); - if ($nt) { + if ($nt) { return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail ); } else { wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" ); @@ -1291,6 +1461,7 @@ class Skin { global $wgOut, $wgUser; if ( $nt->isExternal() ) { $u = $nt->getFullURL(); + $link = $nt->getPrefixedURL(); if ( "" == $text ) { $text = $nt->getPrefixedText(); } $style = $this->getExternalLinkAttributes( $link, $text ); @@ -1328,7 +1499,7 @@ class Skin { } } else { $size = 1 ; - } + } if ( $size < $threshold ) { $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); } else { @@ -1340,7 +1511,7 @@ class Skin { } # Pass a title object, not a title string - function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" ) + function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" , $aprops = '') { global $wgOut, $wgTitle; @@ -1351,14 +1522,18 @@ class Skin { if ( "" == $link ) { $u = ""; - if ( "" == $text ) { $text = $nt->getFragment(); } + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getFragment() ); + } } else { $u = $nt->escapeLocalURL( $query ); } if ( "" != $nt->getFragment() ) { - $u .= "#" . wfEscapeHTML( $nt->getFragment() ); + $u .= "#" . htmlspecialchars( $nt->getFragment() ); + } + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); } - if ( "" == $text ) { $text = $nt->getPrefixedText(); } $style = $this->getInternalLinkAttributesObj( $nt, $text ); $inside = ""; @@ -1368,16 +1543,16 @@ class Skin { $trail = $m[2]; } } - $r = "{$prefix}{$text}{$inside}{$trail}"; + $r = "{$prefix}{$text}{$inside}{$trail}"; wfProfileOut( $fname ); return $r; } - + # Pass a title object, not a title string function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" ) { global $wgOut, $wgUser; - + $fname = "Skin::makeBrokenLinkObj"; wfProfileIn( $fname ); @@ -1388,7 +1563,9 @@ class Skin { } $u = $nt->escapeLocalURL( $q ); - if ( "" == $text ) { $text = $nt->getPrefixedText(); } + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); + } $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" ); $inside = ""; @@ -1417,7 +1594,9 @@ class Skin { $u = $nt->escapeLocalURL( $query ); - if ( "" == $text ) { $text = $nt->getPrefixedText(); } + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); + } $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" ); $inside = ""; @@ -1434,6 +1613,61 @@ class Skin { } return $s; } + + function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" ) + { + $u = $nt->escapeLocalURL( $query ); + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); + } + $inside = ""; + if ( "" != $trail ) { + if ( preg_match( $this->linktrail, $trail, $m ) ) { + $inside = $m[1]; + $trail = $m[2]; + } + } + return "{$prefix}{$text}{$inside}{$trail}"; + } + + /* these are used extensively in SkinPHPTal, but also some other places */ + /*static*/ function makeSpecialUrl( $name, $urlaction='' ) { + $title = Title::makeTitle( NS_SPECIAL, $name ); + $this->checkTitle(&$title, &$name); + return $title->getLocalURL( $urlaction ); + } + /*static*/ function makeTalkUrl ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $title = $title->getTalkPage(); + $this->checkTitle(&$title, &$name); + return $title->getLocalURL( $urlaction ); + } + /*static*/ function makeArticleUrl ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $title= $title->getSubjectPage(); + $this->checkTitle(&$title, &$name); + return $title->getLocalURL( $urlaction ); + } + /*static*/ function makeI18nUrl ( $name, $urlaction='' ) { + $title = Title::newFromText( wfMsg($name) ); + $this->checkTitle(&$title, &$name); + return $title->getLocalURL( $urlaction ); + } + /*static*/ function makeUrl ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $this->checkTitle(&$title, &$name); + return $title->getLocalURL( $urlaction ); + } + + # make sure we have some title to operate on, mind the '&' + /*static*/ function &checkTitle ( $title, $name ) { + if(!is_object($title)) { + $title = Title::newFromText( $name ); + if(!is_object($title)) { + $title = Title::newFromText( '' ); + } + } + } function fnamePart( $url ) { @@ -1459,8 +1693,9 @@ class Skin { function makeImageLinkObj( $nt, $alt = "" ) { global $wgLang, $wgUseImageResize; - $name = $nt->getDBKey(); - $url = wfImageUrl( $name ); + $img = Image::newFromTitle( $nt ); + $url = $img->getURL(); + $align = ""; $prefix = $postfix = ""; @@ -1472,6 +1707,8 @@ class Skin { # * 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); @@ -1481,9 +1718,10 @@ class Skin { $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]; - $thumb=false; + $framed=$thumb=false; foreach( $part as $key => $val ) { if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) { @@ -1503,6 +1741,8 @@ class Skin { } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) { # $match is the image width in pixels $width = intval($match); + } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) { + $framed=true; } } if ( "center" == $align ) @@ -1512,7 +1752,7 @@ class Skin { $align = "none"; } - if ( $thumb ) { + if ( $thumb || $framed ) { # Create a thumbnail. Alignment depends on language # writing direction, # right aligned for left-to-right- @@ -1527,180 +1767,93 @@ class Skin { if ( ! isset($width) ) { $width = 180; } - return $prefix.$this->makeThumbLinkObj( $nt, $alt, $align, $width ).$postfix; + return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $framed ).$postfix; } elseif ( isset($width) ) { # Create a resized image, without the additional thumbnail # features - $url = $this->createThumb( $name, $width ); + $url = $img->createThumb( $width ); } } # endif $wgUseImageResize if ( empty( $alt ) ) { - $alt = preg_replace( '/\.(.+?)^/', '', $name ); + $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() ); } $alt = htmlspecialchars( $alt ); $u = $nt->escapeLocalURL(); if ( $url == "" ) { - $s = str_replace( "$1", $name, wfMsg("missingimage") ); + $s = str_replace( "$1", $img->getName(), wfMsg("missingimage") ); + $s .= "
{$alt}
{$url}
\n"; } else { - $s = "\n \n" . - " \"{$alt}\"\n "; + $s = "" . + "\"{$alt}\""; } if ( "" != $align ) { - $s = "
{$s}\n
"; + $s = "
{$s}\n
"; } return $prefix.$s.$postfix; } - function createThumb( $name, $width ) { - global $wgUploadDirectory; - global $wgImageMagickConvertCommand; - global $wgUseImageMagick; - global $wgUseSquid, $wgInternalServer; - $imgPath = wfImagePath( $name ); - $thumbName = $width."px-".$icon.$name; - $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName; - $thumbUrl = wfImageThumbUrl( $thumbName ); - if ( ! file_exists( $imgPath ) ) - { - # If there is no image, there will be no thumbnail - return ""; - } - - if ( (! file_exists( $thumbPath ) ) - || ( filemtime($thumbPath) < filemtime($imgPath) ) ) { - # Squid purging - if ( $wgUseSquid ) { - $urlArr = Array( - $wgInternalServer.$thumbUrl - ); - wfPurgeSquidServers($urlArr); - } - - if ( $wgUseImageMagick ) { - # use ImageMagick - $cmd = $wgImageMagickConvertCommand . - " -quality 85 -geometry {$width} ". - escapeshellarg($imgPath) . " " . - escapeshellarg($thumbPath); - $conv = shell_exec( $cmd ); - } else { - # Use PHP's builtin GD library functions. - # - # First find out what kind of file this is, and select the correct - # input routine for this. - list($src_width, $src_height, $src_type, $src_attr) = getimagesize( $imgPath ); - switch( $src_type ) { - case 1: # GIF - $src_image = imagecreatefromgif( $imgPath ); - break; - case 2: # JPG - $src_image = imagecreatefromjpeg( $imgPath ); - break; - case 3: # PNG - $src_image = imagecreatefrompng( $imgPath ); - break; - case 15: # WBMP for WML - $src_image = imagecreatefromwbmp( $imgPath ); - break; - case 16: # XBM - $src_image = imagecreatefromxbm( $imgPath ); - break; - default: - return "Image type not supported"; - break; - } - $height = floor( $src_height * ( $width/$src_width ) ); - $dst_image = imagecreatetruecolor( $width, $height ); - imagecopyresampled( $dst_image, $src_image, - 0,0,0,0, - $width, $height, $src_width, $src_height ); - switch( $src_type ) { - case 1: # GIF - case 3: # PNG - case 15: # WBMP - case 16: # XBM - #$thumbUrl .= ".png"; - #$thumbPath .= ".png"; - imagepng( $dst_image, $thumbPath ); - break; - case 2: # JPEG - #$thumbUrl .= ".jpg"; - #$thumbPath .= ".jpg"; - imageinterlace( $dst_image ); - imagejpeg( $dst_image, $thumbPath, 95 ); - break; - default: - break; - } - imagedestroy( $dst_image ); - imagedestroy( $src_image ); - - - } - # - # Check for zero-sized thumbnails. Those can be generated when - # no disk space is available or some other error occurs - # - $thumbstat = stat( $thumbPath ); - $imgstat = stat( $imgPath ); - if( $thumbstat["size"] == 0 ) - { - unlink( $thumbPath ); - } - - } - return $thumbUrl; - } - - function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) { - global $wgUploadPath, $wgLang; - $name = $nt->getDBKey(); - $image = Title::makeTitle( Namespace::getImage(), $name ); - $url = wfImageUrl( $name ); - $path = wfImagePath( $name ); + function makeThumbLinkObj( $img, $label = "", $align = "right", $boxwidth = 180, $framed=false ) { + global $wgStylePath, $wgLang; + # $image = Title::makeTitle( Namespace::getImage(), $name ); + $url = $img->getURL(); #$label = htmlspecialchars( $label ); $alt = preg_replace( "/<[^>]*>/", "", $label); $alt = htmlspecialchars( $alt ); - if ( file_exists( $path ) ) + if ( $img->exists() ) { - list($width, $height, $type, $attr) = getimagesize( $path ); + $width = $img->getWidth(); + $height = $img->getHeight(); } else { $width = $height = 200; } - $boxheight = intval( $height/($width/$boxwidth) ); - if ( $boxwidth > $width ) { + if ( $framed ) + { + // Use image dimensions, don't scale $boxwidth = $width; $boxheight = $height; + $thumbUrl = $url; + } else { + $boxheight = intval( $height/($width/$boxwidth) ); + # if ( $boxwidth > $width ) { + # $boxwidth = $width; + # $boxheight = $height; + #} + $thumbUrl = $img->createThumb( $boxwidth ); } - - $thumbUrl = $this->createThumb( $name, $boxwidth ); + $oboxwidth = $boxwidth + 2; - $u = $nt->escapeLocalURL(); + $u = $img->getEscapeLocalURL(); $more = htmlspecialchars( wfMsg( "thumbnail-more" ) ); $magnifyalign = $wgLang->isRTL() ? "left" : "right"; - $textalign = $wgLang->isRTL() ? " style=\"text-align:right\"" : ""; + $textalign = $wgLang->isRTL() ? ' style="text-align:right"' : ""; - $s = "
"; + $s = "
"; if ( $thumbUrl == "" ) { - $s .= str_replace( "$1", $name, wfMsg("missingimage") ); + $s .= str_replace( "$1", $img->getName(), wfMsg("missingimage") ); + $zoomicon = ''; } else { - $s .= "\n".' '."\n". - ' '.$alt.'' ."\n". - ' ' ."\n". - ' '.$more.' '."\n"; - } - $s .= ' '.$label."

\n
"; + $s .= ''. + ''.$alt.''; + if ( $framed ) { + $zoomicon=""; + } else { + $zoomicon = '
'. + ''. + ''.$more.'
'; + } + } + $s .= '
'.$zoomicon.$label."
\n
"; return $s; } @@ -1712,7 +1865,7 @@ class Skin { function makeMediaLinkObj( $nt, $alt = "" ) { $name = $nt->getDBKey(); - $url = wfImageUrl( $name ); + $url = Image::wfImageUrl( $name ); if ( empty( $alt ) ) { $alt = preg_replace( '/\.(.+?)^/', '', $name ); } @@ -1731,6 +1884,15 @@ class Skin { return $this->makeKnownLink( $wgLang->specialPage( $pn ), wfMsg( $key ) ); } + + function makeExternalLink( $url, $text, $escape = true ) { + $style = $this->getExternalLinkAttributes( $url, $text ); + $url = htmlspecialchars( $url ); + if( $escape ) { + $text = htmlspecialchars( $text ); + } + return "$text"; + } # Called by history lists and recent changes # @@ -1742,13 +1904,14 @@ class Skin { $this->rcMoveIndex = 0; $this->rcCacheIndex = 0 ; $this->lastdate = ""; + $this->rclistOpen = false; return ""; } function beginImageHistoryList() { $s = "\n

" . wfMsg( "imghistory" ) . "

\n" . - "

" . wfMsg( "imghistlegend" ) . "\n

\n"; + } return $s; } # Enhanced RC ungrouped line function recentChangesBlockLine ( $rcObj ) { - global $wgUploadPath, $wgLang ; + global $wgStylePath, $wgLang ; # Get rc_xxxx variables extract( $rcObj->mAttribs ) ; @@ -1773,7 +1938,7 @@ class Skin { # Spacer image $r = "" ; - $r .= "" ; $r .= "" ; + $r .= "" ; $r .= "" ; if ( $rc_type == RC_MOVE ) { $r .= "  "; @@ -1828,7 +1993,7 @@ class Skin { # Enhanced RC group function recentChangesBlockGroup ( $block ) { - global $wgUploadPath, $wgLang ; + global $wgStylePath, $wgLang ; $r = "" ; $M = wfMsg( "minoreditletter" ); @@ -1844,7 +2009,7 @@ class Skin { if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ; $userlinks[$u]++ ; } - + # Sort the list and convert to text krsort ( $userlinks ) ; asort ( $userlinks ) ; @@ -1862,8 +2027,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 @@ -1905,7 +2070,7 @@ class Skin { # Get rc_xxxx variables extract( $rcObj->mAttribs ); - $r .= ""; + $r .= ""; $r .= "       " ; if ( $rc_new ) $r .= $N ; else $r .= " " ; @@ -1947,7 +2112,7 @@ class Skin { # RC lines, arranges them, and outputs the HTML function recentChangesBlock () { - global $wgUploadPath ; + global $wgStylePath ; if ( count ( $this->rc_cache ) == 0 ) return "" ; $blockOut = ""; foreach ( $this->rc_cache AS $secureName => $block ) { @@ -1989,6 +2154,7 @@ class Skin { if ( "" != $this->lastdate ) { $s .= "\n"; } $s .= "

{$date}

\n
    "; $this->lastdate = $date; + $this->rclistOpen = true; } $s .= "
  • "; @@ -2010,7 +2176,7 @@ class Skin { $diffLink = wfMsg( "diff" ); } else { $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ), - "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ); + "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ,'' ,'' , ' tabindex="'.$rc->counter.'"'); } $s .= "($diffLink) ("; @@ -2120,7 +2286,7 @@ class Skin { $curLink = wfMsg( "cur" ); } else { $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ), - "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ); + "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ,'' ,'' , ' tabindex="'.$baseRC->counter.'"' ); } # Make "last" link @@ -2188,16 +2354,51 @@ class Skin { /* This function is called by all recent changes variants, by the page history, and by the user contributions list. It is responsible for formatting edit comments. It escapes any HTML in the comment, but adds some CSS to format - auto-generated comments (from section editing). + auto-generated comments (from section editing) and formats [[wikilinks]]. + Main author: Erik Möller (moeller@scireview.de) */ function formatComment($comment) { + global $wgLang; $comment=wfEscapeHTML($comment); - - # format text between /* .. */ with autocomment CSS class - $comment=preg_replace("/\/\*\s*(.*?)\s*\*\//i", - "$1",$comment); + + # The pattern for autogen comments is / * foo * /, which makes for + # some nasty regex. + # We look for all comments, match any text before and after the comment, + # add a separator where needed and format the comment itself with CSS + while (preg_match("/(.*)\/\*\s*(.*?)\s*\*\/(.*)/", $comment,$match)) { + $pre=$match[1]; + $auto=$match[2]; + $post=$match[3]; + $sep="-"; + if($pre) { $auto="$sep ".$auto; } + if($post) { $auto.=" $sep"; } + $auto="".$auto.""; + $comment=$pre.$auto.$post; + } + + # format regular and media links - all other wiki formatting + # is ignored + while(preg_match("/\[\[(.*?)(\|(.*?))*\]\]/",$comment,$match)) { + + $medians = $wgLang->getNsText(Namespace::getMedia()); + $func="makeLink"; + if(preg_match("/^".$medians."/i",$match[1])) { + $func="makeMediaLink"; + } + if(isset($match[3]) ) { + $comment= + preg_replace("/\[\[(.*?)\]\]/", + $this->$func($match[1],$match[3]),$comment,1); + } else { + $comment= + preg_replace("/\[\[(.*?)\]\]/", + $this->$func($match[1],$match[1]),$comment,1); + } + } + return $comment; + } function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c ) @@ -2209,7 +2410,7 @@ class Skin { $cur = wfMsg( "cur" ); if ( $iscur ) { - $url = wfImageUrl( $img ); + $url = Image::wfImageUrl( $img ); $rlink = $cur; if ( $wgUser->isSysop() ) { $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . @@ -2247,7 +2448,8 @@ class Skin { . " . . {$ul} ({$nb})"; if ( "" != $c && "*" != $c ) { - $s .= $wgLang->emphasize(" (" . wfEscapeHTML( $c ) . ")"); + $sk=$wgUser->getSkin(); + $s .= $wgLang->emphasize(" (" . $sk->formatComment($c) . ")"); } $s .= "
  • \n"; return $s; @@ -2323,81 +2525,102 @@ class Skin { // toolbar for common editing functions. It can be disabled in the user preferences. // The necsesary JavaScript code can be found in style/wikibits.js. function getEditToolbar() { - global $wgUploadPath, $wgLang, $wgMimeType; + global $wgStylePath, $wgLang, $wgMimeType; // toolarray an array of arrays which each include the filename of // the button image (without path), the opening tag, the closing tag, // and optionally a sample text that is inserted between the two when no // selection is highlighted. // The tip text is shown when the user moves the mouse over the button. + + // Already here are accesskeys (key), which are not used yet until someone + // can figure out a way to make them work in IE. However, we should make + // sure these keys are not defined on the edit page. $toolarray=array( array( "image"=>"button_bold.png", "open"=>"\'\'\'", "close"=>"\'\'\'", "sample"=>wfMsg("bold_sample"), - "tip"=>wfMsg("bold_tip")), + "tip"=>wfMsg("bold_tip"), + "key"=>"B" + ), array( "image"=>"button_italic.png", "open"=>"\'\'", "close"=>"\'\'", "sample"=>wfMsg("italic_sample"), - "tip"=>wfMsg("italic_tip")), + "tip"=>wfMsg("italic_tip"), + "key"=>"I" + ), array( "image"=>"button_link.png", "open"=>"[[", "close"=>"]]", "sample"=>wfMsg("link_sample"), - "tip"=>wfMsg("link_tip")), + "tip"=>wfMsg("link_tip"), + "key"=>"L" + ), array( "image"=>"button_extlink.png", "open"=>"[", "close"=>"]", "sample"=>wfMsg("extlink_sample"), - "tip"=>wfMsg("extlink_tip")), + "tip"=>wfMsg("extlink_tip"), + "key"=>"X" + ), array( "image"=>"button_headline.png", "open"=>"\\n== ", "close"=>" ==\\n", "sample"=>wfMsg("headline_sample"), - "tip"=>wfMsg("headline_tip")), + "tip"=>wfMsg("headline_tip"), + "key"=>"H" + ), array( "image"=>"button_image.png", "open"=>"[[".$wgLang->getNsText(NS_IMAGE).":", "close"=>"]]", "sample"=>wfMsg("image_sample"), - "tip"=>wfMsg("image_tip")), + "tip"=>wfMsg("image_tip"), + "key"=>"D" + ), array( "image"=>"button_media.png", "open"=>"[[".$wgLang->getNsText(NS_MEDIA).":", "close"=>"]]", "sample"=>wfMsg("media_sample"), - "tip"=>wfMsg("media_tip")), + "tip"=>wfMsg("media_tip"), + "key"=>"M" + ), array( "image"=>"button_math.png", "open"=>"\\", "close"=>"\\", "sample"=>wfMsg("math_sample"), - "tip"=>wfMsg("math_tip")), + "tip"=>wfMsg("math_tip"), + "key"=>"C" + ), array( "image"=>"button_nowiki.png", "open"=>"\\", "close"=>"\\", "sample"=>wfMsg("nowiki_sample"), - "tip"=>wfMsg("nowiki_tip")), + "tip"=>wfMsg("nowiki_tip"), + "key"=>"N" + ), array( "image"=>"button_sig.png", "open"=>"--~~~~", "close"=>"", "sample"=>"", - "tip"=>wfMsg("sig_tip")), + "tip"=>wfMsg("sig_tip"), + "key"=>"Y" + ), array( "image"=>"button_hr.png", "open"=>"\\n----\\n", "close"=>"", "sample"=>"", - "tip"=>wfMsg("hr_tip")) + "tip"=>wfMsg("hr_tip"), + "key"=>"R" + ) ); - $toolbar =""; + $toolbar.="/*]]>*/\n"; return $toolbar; } } @@ -2425,9 +2648,6 @@ include_once( "SkinStandard.php" ); include_once( "SkinNostalgia.php" ); include_once( "SkinCologneBlue.php" ); -if( $wgUseSmarty ) { - include_once( "SkinSmarty.php" ); -} if( $wgUsePHPTal ) { include_once( "SkinPHPTal.php" ); }