From: Alexandre Emsenhuber Date: Sun, 27 Nov 2011 09:39:24 +0000 (+0000) Subject: * Use WikiPage instead of Article in Skin and SkinTemplate X-Git-Tag: 1.31.0-rc.0~26274 X-Git-Url: http://git.cyclocoop.org//%27http:/code.google.com/p/ie7-js//%27?a=commitdiff_plain;h=d1d31c75fb7a984023ad7e24ad90ed8d642f4f1c;p=lhc%2Fweb%2Fwiklou.git * Use WikiPage instead of Article in Skin and SkinTemplate * Added $context parameter to Action::factory() to allow callers passing a WikiPage object in addition to Article (otherwise this would throw a fatal error in getContext() since WikiPage::getContext() does not exist) --- diff --git a/includes/Action.php b/includes/Action.php index 951c74a3b5..09d590af75 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -27,7 +27,7 @@ abstract class Action { /** * Page on which we're performing the action - * @var Article + * @var Page */ protected $page; @@ -72,14 +72,15 @@ abstract class Action { /** * Get an appropriate Action subclass for the given action * @param $action String - * @param $page Article + * @param $page Page + * @param $context IContextSource * @return Action|false|null false if the action is disabled, null * if it is not recognised */ - public final static function factory( $action, Page $page ) { + public final static function factory( $action, Page $page, IContextSource $context = null ) { $class = self::getClass( $action, $page->getActionOverrides() ); if ( $class ) { - $obj = new $class( $page ); + $obj = new $class( $page, $context ); return $obj; } return $class; @@ -183,10 +184,12 @@ abstract class Action { /** * Protected constructor: use Action::factory( $action, $page ) to actually build * these things in the real world - * @param Page $page + * @param $page Page + * @param $context IContextSource */ - protected function __construct( Page $page ) { + protected function __construct( Page $page, IContextSource $context = null ) { $this->page = $page; + $this->context = $context; } /** diff --git a/includes/Skin.php b/includes/Skin.php index dc697a363a..5d0f877bec 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -790,14 +790,14 @@ abstract class Skin extends ContextSource { /** * Get the timestamp of the latest revision, formatted in user language * - * @param $article Article object. Used if we're working with the current revision + * @param $page WikiPage object. Used if we're working with the current revision * @return String */ - protected function lastModified( $article ) { + protected function lastModified( $page ) { if ( !$this->isRevisionCurrent() ) { $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() ); } else { - $timestamp = $article->getTimestamp(); + $timestamp = $page->getTimestamp(); } if ( $timestamp ) { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 2eb0a778c3..c211e04d33 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -329,9 +329,9 @@ class SkinTemplate extends Skin { $tpl->set( 'numberofwatchingusers', false ); if ( $out->isArticle() && $this->getTitle()->exists() ) { if ( $this->isRevisionCurrent() ) { - $article = new Article( $this->getTitle(), 0 ); + $page = WikiPage::factory( $this->getTitle() ); if ( !$wgDisableCounters ) { - $viewcount = $article->getCount(); + $viewcount = $page->getCount(); if ( $viewcount ) { $tpl->set( 'viewcount', $this->msg( 'viewcount' )->numParams( $viewcount )->parse() ); } @@ -351,9 +351,9 @@ class SkinTemplate extends Skin { } if ( $wgMaxCredits != 0 ) { - $tpl->set( 'credits', Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); + $tpl->set( 'credits', Action::factory( 'credits', $page, $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); } else { - $tpl->set( 'lastmod', $this->lastModified( $article ) ); + $tpl->set( 'lastmod', $this->lastModified( $page ) ); } } $tpl->set( 'copyright', $this->getCopyright() );