X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=262c497f4ea81b0388a4a87bf822932fdf3fe416;hb=d42c91a23cf7c59a3cc1cc88438d087ca0d8bf6b;hp=336a868c5888b47a40e1548bb751d971fea3cb47;hpb=81f17df33b1b8d2a2d50feb04e368f3ac6e134f6;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Skin.php b/includes/Skin.php
index 336a868c58..262c497f4e 100644
--- a/includes/Skin.php
+++ b/includes/Skin.php
@@ -1,33 +1,66 @@
"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['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" );
+require_once( 'RecentChange.php' );
+/**
+ * @todo document
+ * @package MediaWiki
+ */
class RCCacheEntry extends RecentChange
{
var $secureName, $link;
- var $curlink , $lastlink , $usertalklink , $versionlink ;
+ var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
var $userlink, $timestamp, $watched;
function newFromParent( $rc )
@@ -39,52 +72,71 @@ 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()
- {
- $this->linktrail = wfMsg("linktrail");
+ 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 qbSetting()
- {
+ function getSkinName() {
+ return 'standard';
+ }
+
+ /**
+ * 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; }
- $q = $wgUser->getOption( "quickbar" );
- if ( "" == $q ) { $q = 0; }
+ $q = $wgUser->getOption( 'quickbar' );
+ if ( '' == $q ) { $q = 0; }
return $q;
}
- function initPage( &$out )
- {
- $fname = "Skin::initPage";
+ function initPage( &$out ) {
+ $fname = 'Skin::initPage';
wfProfileIn( $fname );
-
- $out->addLink( array( "rel" => "shortcut icon", "href" => "/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;
@@ -95,16 +147,16 @@ class Skin {
$out->addMetadataLink( array(
'title' => 'Creative Commons',
'type' => 'application/rdf+xml',
- 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) );
+ 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
}
if( $wgEnableDublinCoreRdf ) {
$out->addMetadataLink( array(
'title' => 'Dublin Core',
'type' => 'application/rdf+xml',
- 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) );
+ 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
}
}
- $copyright = "";
+ $copyright = '';
if( $wgRightsPage ) {
$copy = Title::newFromText( $wgRightsPage );
if( $copy ) {
@@ -116,15 +168,15 @@ class Skin {
}
if( $copyright ) {
$out->addLink( array(
- "rel" => "copyright",
- "href" => $copyright ) );
+ 'rel' => 'copyright',
+ 'href' => $copyright ) );
}
}
-
+
function outputPage( &$out ) {
global $wgDebugComments;
-
- wfProfileIn( "Skin::outputPage" );
+
+ wfProfileIn( 'Skin::outputPage' );
$this->initPage( $out );
$out->out( $out->headElement() );
@@ -143,7 +195,7 @@ class Skin {
$out->out( $out->mBodytext . "\n" );
$out->out( $this->afterContent() );
-
+
wfProfileClose();
$out->out( $out->reportTime() );
@@ -151,170 +203,196 @@ class Skin {
}
function getHeadScripts() {
- global $wgStylePath;
- $r = "\n";
+ global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs;
+ $r = "\n";
+ if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
+ $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
+ $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
+ $r .= '\n";
+ }
return $r;
}
- function getUserStyles()
- {
- global $wgOut, $wgStylePath, $wgLang;
+ # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
+ function getUserStylesheet() {
+ global $wgOut, $wgStylePath, $wgLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
$sheet = $this->getStylesheet();
- $s = "\n";
return $s;
}
- function doGetUserStyles()
- {
- global $wgUser;
+ /**
+ * Some styles that are set by user through the user settings interface.
+ */
+ function doGetUserStyles() {
+ global $wgUser, $wgLang;
- $s = "";
- if ( 1 == $wgUser->getOption( "underline" ) ) {
+ $csspage = $wgLang->getNsText( NS_MEDIAWIKI ) . ':' . $this->getSkinName() . '.css';
+ $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
+
+ if ( 1 == $wgUser->getOption( 'underline' ) ) {
# Don't override browser settings
} else {
# CHECK MERGE @@@
# Force no underline
- $s .= "a { " .
- "text-decoration: none; }\n";
+ $s .= "a { text-decoration: none; }\n";
}
- if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
+ if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
$s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
}
- if ( 1 == $wgUser->getOption( "justify" ) ) {
+ if ( 1 == $wgUser->getOption( 'justify' ) ) {
$s .= "#article { text-align: justify; }\n";
}
return $s;
}
- function getBodyOptions()
- {
+ function getBodyOptions() {
global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
-
+
extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
if ( 0 != $wgTitle->getNamespace() ) {
- $a = array( "bgcolor" => "#ffffec" );
+ $a = array( 'bgcolor' => '#ffffec' );
}
- else $a = array( "bgcolor" => "#FFFFFF" );
- if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
+ else $a = array( 'bgcolor' => '#FFFFFF' );
+ if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
(!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
- $t = wfMsg( "editthispage" );
- $oid = $red = "";
- if ( !empty($redirect) ) {
- $red = "&redirect={$redirect}";
+ $t = wfMsg( 'editthispage' );
+ $oid = $red = '';
+ if ( !empty($redirect) ) {
+ $red = "&redirect={$redirect}";
}
if ( !empty($oldid) && ! isset( $diff ) ) {
$oid = "&oldid={$oldid}";
}
$s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
- $s = "document.location = \"" .$s ."\";";
- $a += array ("ondblclick" => $s);
+ $s = 'document.location = "' .$s .'";';
+ $a += array ('ondblclick' => $s);
}
$a['onload'] = $wgOut->getOnloadHandler();
return $a;
}
- function getExternalLinkAttributes( $link, $text )
- {
+ function getExternalLinkAttributes( $link, $text, $class='' ) {
global $wgUser, $wgOut, $wgLang;
$link = urldecode( $link );
$link = $wgLang->checkTitleEncoding( $link );
- $link = str_replace( "_", " ", $link );
- $link = wfEscapeHTML( $link );
+ $link = str_replace( '_', ' ', $link );
+ $link = htmlspecialchars( $link );
- $r = " class='external'";
+ $r = ($class != '') ? " class='$class'" : " class='external'";
- if ( 1 == $wgUser->getOption( "hover" ) ) {
+ if ( 1 == $wgUser->getOption( 'hover' ) ) {
$r .= " title=\"{$link}\"";
}
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 = str_replace( '_', ' ', $link );
+ $link = htmlspecialchars( $link );
- if ( $broken == "stub" ) {
- $r = " class='stub'";
- } else if ( $broken == "yes" ) {
- $r = " class='new'";
- } else {
- $r = "";
+ if ( $broken == 'stub' ) {
+ $r = ' class="stub"';
+ } else if ( $broken == 'yes' ) {
+ $r = ' class="new"';
+ } else {
+ $r = '';
}
- if ( 1 == $wgUser->getOption( "hover" ) ) {
+ if ( 1 == $wgUser->getOption( 'hover' ) ) {
$r .= " title=\"{$link}\"";
}
return $r;
}
-
- function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
- {
+
+ /**
+ * @param bool $broken
+ */
+ function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
global $wgUser, $wgOut;
- if ( $broken == "stub" ) {
- $r = " class='stub'";
- } else if ( $broken == "yes" ) {
- $r = " class='new'";
- } else {
- $r = "";
+ if ( $broken == 'stub' ) {
+ $r = ' class="stub"';
+ } else if ( $broken == 'yes' ) {
+ $r = ' class="new"';
+ } else {
+ $r = '';
}
- if ( 1 == $wgUser->getOption( "hover" ) ) {
+ if ( 1 == $wgUser->getOption( 'hover' ) ) {
$r .= ' title ="' . $nt->getEscapedText() . '"';
}
return $r;
- }
-
- function getLogo()
- {
+ }
+
+ /**
+ * URL to the logo
+ */
+ function getLogo() {
global $wgLogo;
return $wgLogo;
}
- # This will be called immediately after the
tag. Split into
- # two functions to make it easier to subclass.
- #
- function beforeContent()
- {
- global $wgUser, $wgOut, $wgSiteNotice;
+ /**
+ * This will be called immediately after the tag. Split into
+ * two functions to make it easier to subclass.
+ */
+ function beforeContent() {
+ global $wgUser, $wgOut;
- if( $wgSiteNotice ) {
- $note = "\n$wgSiteNotice
\n";
- } else {
- $note = "";
- }
- return $this->doBeforeContent() . $note;
+ return $this->doBeforeContent();
}
- function doBeforeContent()
- {
- global $wgUser, $wgOut, $wgTitle, $wgLang;
- $fname = "Skin::doBeforeContent";
+ function doBeforeContent() {
+ global $wgUser, $wgOut, $wgTitle, $wgLang, $wgSiteNotice;
+ $fname = 'Skin::doBeforeContent';
wfProfileIn( $fname );
- $s = "";
+ $s = '';
$qb = $this->qbSetting();
if( $langlinks = $this->otherLanguages() ) {
$rows = 2;
- $borderhack = "";
+ $borderhack = '';
} else {
$rows = 1;
$langlinks = false;
- $borderhack = "class='top'";
+ $borderhack = 'class="top"';
}
$s .= "\n\n
\n" .
@@ -323,14 +401,14 @@ class Skin {
$shove = ($qb != 0);
$left = ($qb == 1 || $qb == 3);
if($wgLang->isRTL()) $left = !$left;
-
+
if ( !$shove ) {
$s .= "
\n" .
- $this->logoText() . " | ";
+ $this->logoText() . '';
} elseif( $left ) {
$s .= $this->getQuickbarCompensator( $rows );
}
- $l = $wgLang->isRTL() ? "right" : "left";
+ $l = $wgLang->isRTL() ? 'right' : 'left';
$s .= "
\n";
$s .= $this->topLinks() ;
@@ -351,63 +429,110 @@ class Skin {
$s .= "\n\n\n";
$s .= "\n\n";
+ if( $wgSiteNotice ) {
+ $s .= "\n $wgSiteNotice \n";
+ }
$s .= $this->pageTitle();
$s .= $this->pageSubtitle() ;
$s .= $this->getCategories();
wfProfileOut( $fname );
return $s;
}
-
- function getCategories () {
+
+ function getCategoryLinks () {
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 " $s ";
- }
-
- function getQuickbarCompensator( $rows = 1 )
- {
+ global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
+
+ if( !$wgUseCategoryMagic ) return '' ;
+ if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
+
+ # Taken out so that they will be displayed in previews -- TS
+ #if( !$wgOut->isArticle() ) return '';
+
+ $t = implode ( ' | ' , $wgOut->mCategoryLinks ) ;
+ $s = $this->makeKnownLink( 'Special:Categories',
+ 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 .= '
';
+
+ # get a big array of the parents tree
+ $parenttree = $wgTitle->getCategorieBrowser();
+
+ # Render the array as a serie of links
+ function walkThrough ($tree) {
+ global $wgUser;
+ $sk = $wgUser->getSkin();
+ $return = '';
+ foreach($tree as $element => $parent) {
+ if(empty($parent)) {
+ # element start a new list
+ $return .= ' ';
+ } else {
+ # grab the others elements
+ $return .= walkThrough($parent);
+ }
+ # add our current element to the list
+ $eltitle = Title::NewFromText($element);
+ # FIXME : should be makeLink() [AV]
+ $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > ';
+ }
+ return $return;
+ }
+
+ $s .= walkThrough($parenttree);
+ }
+
+ return $s;
+ }
+
+ function getCategories() {
+ $catlinks=$this->getCategoryLinks();
+ if(!empty($catlinks)) {
+ return " {$catlinks} ";
+ }
+ }
+
+ function getQuickbarCompensator( $rows = 1 ) {
return " | ";
}
# This gets called immediately before the tag.
#
- function afterContent()
- {
+ function afterContent() {
global $wgUser, $wgOut, $wgServer;
global $wgTitle, $wgLang;
-
+
$printfooter = "\n";
return $printfooter . $this->doAfterContent();
}
-
- function printFooter() {
+
+ function printSource() {
global $wgTitle;
$url = htmlspecialchars( $wgTitle->getFullURL() );
- return " " . 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";
+ $fname = 'Skin::doAfterContent';
wfProfileIn( $fname );
- wfProfileIn( "$fname-1" );
+ wfProfileIn( $fname.'-1' );
$s = "\n \n";
$s .= "\n |