https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112450

Revision: 112450
Author:   jeroendedauw
Date:     2012-02-26 22:25:49 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------
some refactoring

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.hooks.php
    trunk/extensions/EducationProgram/EducationProgram.php
    trunk/extensions/EducationProgram/actions/EPDeleteAction.php
    trunk/extensions/EducationProgram/actions/EPEditAction.php
    trunk/extensions/EducationProgram/actions/EPHistoryAction.php
    trunk/extensions/EducationProgram/actions/EPViewAction.php
    trunk/extensions/EducationProgram/actions/EditCourseAction.php
    trunk/extensions/EducationProgram/actions/ViewCourseAction.php
    trunk/extensions/EducationProgram/includes/EPCoursePager.php
    trunk/extensions/EducationProgram/includes/EPCourses.php
    trunk/extensions/EducationProgram/includes/EPOrgPager.php
    trunk/extensions/EducationProgram/includes/EPOrgs.php
    trunk/extensions/EducationProgram/includes/EPPageObject.php
    trunk/extensions/EducationProgram/includes/EPPageTable.php
    trunk/extensions/EducationProgram/includes/EPRevisionPager.php
    trunk/extensions/EducationProgram/pages/CoursePage.php
    trunk/extensions/EducationProgram/pages/EPPage.php
    trunk/extensions/EducationProgram/pages/OrgPage.php

Modified: trunk/extensions/EducationProgram/EducationProgram.hooks.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.hooks.php        
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/EducationProgram.hooks.php        
2012-02-26 22:25:49 UTC (rev 112450)
@@ -255,8 +255,7 @@
                        $links['actions'] = array();
 
                        $user = $sktemplate->getUser();
-                       $class = $classes[$title->getNamespace()];
-                       $exists = $class::singleton()->hasIdentifier( 
$title->getText() );
+                       $exists = 
$classes[$title->getNamespace()]::singleton()->hasIdentifier( $title->getText() 
);
                        $type = $sktemplate->getRequest()->getText( 'action' );
                        $isSpecial = $sktemplate->getTitle()->isSpecialPage();
 
@@ -268,7 +267,7 @@
                                );
                        }
                        
-                       if ( $user->isAllowed( 
$class::singleton()->getEditRight() ) ) {
+                       if ( $user->isAllowed( EPPage::factory( $title 
)->getEditRight() ) ) {
                                $links['views']['edit'] = array(
                                        'class' => $type === 'edit' ? 
'selected' : false,
                                        'text' => wfMsg( $exists ? 
'ep-tab-edit' : 'ep-tab-create' ),
@@ -341,30 +340,4 @@
                return true;
        }
        
-       /**
-        * Used to add new query-string actions.
-        * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnknownAction
-        *
-        * @since 0.1
-        *
-        * @param string $action
-        * @param Page $page
-        *
-        * @return true
-        */
-       public static function onUnknownAction( $action, Page $page ) {
-               // Action does not allow us to associate actions that are not 
known to core
-               // with a single page, hence the less ideal handling in this 
hook.
-               if ( method_exists( $page, 'getActions' ) ) {
-                       $actions = $page->getActions();
-                       
-                       if ( array_key_exists( $action, $actions ) ) {
-                               $action = new $actions[$action]( $page, 
$page->getContext() );
-                               $action->show();
-                       }
-               }
-               
-               return true;
-       }
-
 }

Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php      2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/EducationProgram.php      2012-02-26 
22:25:49 UTC (rev 112450)
@@ -60,8 +60,6 @@
 $wgAutoloadClasses['EPSettings']                                       = 
dirname( __FILE__ ) . '/EducationProgram.settings.php';
 
 $wgAutoloadClasses['CourseHistoryAction']                      = dirname( 
__FILE__ ) . '/actions/CourseHistoryAction.php';
-//$wgAutoloadClasses['DeleteCourseAction']                     = dirname( 
__FILE__ ) . '/actions/DeleteCourseAction.php';
-//$wgAutoloadClasses['DeleteOrgAction']                                = 
dirname( __FILE__ ) . '/actions/DeleteOrgAction.php';
 $wgAutoloadClasses['EditCourseAction']                                 = 
dirname( __FILE__ ) . '/actions/EditCourseAction.php';
 $wgAutoloadClasses['EditOrgAction']                            = dirname( 
__FILE__ ) . '/actions/EditOrgAction.php';
 $wgAutoloadClasses['EPAddArticleAction']                       = dirname( 
__FILE__ ) . '/actions/EPAddArticleAction.php';
@@ -78,10 +76,6 @@
 $wgAutoloadClasses['OrgHistoryAction']                                 = 
dirname( __FILE__ ) . '/actions/OrgHistoryAction.php';
 $wgAutoloadClasses['ViewCourseAction']                                 = 
dirname( __FILE__ ) . '/actions/ViewCourseAction.php';
 $wgAutoloadClasses['ViewOrgAction']                            = dirname( 
__FILE__ ) . '/actions/ViewOrgAction.php';
-//$wgAutoloadClasses['CourseUndoAction']                               = 
dirname( __FILE__ ) . '/actions/CourseUndoAction.php';
-//$wgAutoloadClasses['OrgUndoAction']                          = dirname( 
__FILE__ ) . '/actions/OrgUndoAction.php';
-//$wgAutoloadClasses['CourseRestoreAction']                    = dirname( 
__FILE__ ) . '/actions/CourseRestoreAction.php';
-//$wgAutoloadClasses['OrgRestoreAction']                               = 
dirname( __FILE__ ) . '/actions/OrgRestoreAction.php';
 
 $wgAutoloadClasses['ApiDeleteEducation']                       = dirname( 
__FILE__ ) . '/api/ApiDeleteEducation.php';
 $wgAutoloadClasses['ApiEnlist']                                        = 
dirname( __FILE__ ) . '/api/ApiEnlist.php';
@@ -199,7 +193,6 @@
 $wgHooks['ArticleFromTitle'][]                                                 
= 'EPHooks::onArticleFromTitle';
 $wgHooks['CanonicalNamespaces'][]                                      = 
'EPHooks::onCanonicalNamespaces';
 $wgHooks['TitleIsAlwaysKnown'][]                                       = 
'EPHooks::onTitleIsAlwaysKnown';
-//$wgHooks['UnknownAction'][]                                          = 
'EPHooks::onUnknownAction';
 
 // Actions
 $wgActions['epremarticle'] = 'EPRemoveArticleAction';

Modified: trunk/extensions/EducationProgram/actions/EPDeleteAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPDeleteAction.php        
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/EPDeleteAction.php        
2012-02-26 22:25:49 UTC (rev 112450)
@@ -35,7 +35,7 @@
         * @see Action::getRestriction()
         */
        public function getRestriction() {
-               $this->page->getTable()->getEditRight();
+               $this->page->getEditRight();
        }
 
        /**

Modified: trunk/extensions/EducationProgram/actions/EPEditAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPEditAction.php  2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/EPEditAction.php  2012-02-26 
22:25:49 UTC (rev 112450)
@@ -100,7 +100,7 @@
                }
                else {
                        if ( $object === false ) {
-                               $this->table->displayDeletionLog(
+                               $this->page->displayDeletionLog(
                                        $this->getContext(),
                                        'ep-' . strtolower( $this->getName() ) 
. '-deleted'
                                );

Modified: trunk/extensions/EducationProgram/actions/EPHistoryAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-26 22:25:49 UTC (rev 112450)
@@ -56,7 +56,7 @@
        protected function displayNoRevisions() {
                $this->getOutput()->addWikiMsg( 'ep-' . strtolower( 
$this->getName() ) . '-norevs' );
 
-               $this->table->displayDeletionLog(
+               $this->page->displayDeletionLog(
                        $this->getContext(),
                        'ep-' . strtolower( $this->getName() ) . '-deleted' 
                );

Modified: trunk/extensions/EducationProgram/actions/EPViewAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPViewAction.php  2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/EPViewAction.php  2012-02-26 
22:25:49 UTC (rev 112450)
@@ -70,13 +70,13 @@
                if ( $object === false ) {
                        $this->displayNavigation();
 
-                       if ( $this->getUser()->isAllowed( 
$this->table->getEditRight() ) ) {
+                       if ( $this->getUser()->isAllowed( 
$this->page->getEditRight() ) ) {
                                $out->redirect( $this->getTitle()->getLocalURL( 
array( 'action' => 'edit' ) ) );
                        }
                        else {
                                $out->addWikiMsg( strtolower( 
get_called_class() ) . '-none', $name );
 
-                               $this->table->displayDeletionLog(
+                               $this->page->displayDeletionLog(
                                        $this->getContext(),
                                        'ep-' . strtolower( $this->getName() ) 
. '-deleted' 
                                );

Modified: trunk/extensions/EducationProgram/actions/EditCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-02-26 22:25:49 UTC (rev 112450)
@@ -58,7 +58,7 @@
                $this->getOutput()->addModules( array( 'ep.datepicker', 
'ep.combobox' ) );
 
                if ( !$this->isNewPost() && !$this->table->hasIdentifier( 
$this->getTitle()->getText() ) ) {
-                       $this->table->displayDeletionLog(
+                       $this->page->displayDeletionLog(
                                $this->getContext(),
                                'ep-' . strtolower( $this->getName() ) . 
'-deleted' 
                        );

Modified: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/ViewCourseAction.php      
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/actions/ViewCourseAction.php      
2012-02-26 22:25:49 UTC (rev 112450)
@@ -83,7 +83,7 @@
                $stats = array();
 
                $orgName = EPOrgs::singleton()->selectFieldsRow( 'name', array( 
'id' => $course->getField( 'org_id' ) ) );
-               $stats['org'] = EPOrgs::singleton()->getLinkFor( $orgName );
+               $stats['org'] = OrgPage::getLinkFor( $orgName );
 
                $lang = $this->getLanguage();
 

Modified: trunk/extensions/EducationProgram/includes/EPCoursePager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCoursePager.php        
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPCoursePager.php        
2012-02-26 22:25:49 UTC (rev 112450)
@@ -72,7 +72,7 @@
        public function getFormattedValue( $name, $value ) {
                switch ( $name ) {
                        case 'name':
-                               $value = EPCourses::getLinkFor( $value );
+                               $value = CoursePage::getLinkFor( $value );
                                break;
                        case 'org_id':
                                $org = EPOrgs::singleton()->selectRow( 'name', 
array( 'id' => $value ) );

Modified: trunk/extensions/EducationProgram/includes/EPCourses.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourses.php    2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPCourses.php    2012-02-26 
22:25:49 UTC (rev 112450)
@@ -13,20 +13,6 @@
  */
 class EPCourses extends EPPageTable {
 
-       protected static $info = array(
-               'ns' => EP_NS_COURSE,
-               'actions' => array(
-                       'view' => false,
-                       'edit' => 'ep-course',
-                       'history' => false,
-                       'enroll' => 'ep-enroll',
-               ),
-               'edit-right' => 'ep-course',
-               'identifier' => 'name',
-               'list' => 'Courses',
-               'log-type' => 'course',
-       );
-       
        /**
         * (non-PHPdoc)
         * @see DBTable::getDBTable()
@@ -145,4 +131,20 @@
                ) );
        }
        
+       /**
+        * (non-PHPdoc)
+        * @see EPPageObject::getIdentifierField()
+        */
+       public function getIdentifierField() {
+               return 'name';
+       }
+       
+       /**
+        * (non-PHPdoc)
+        * @see EPPageObject::getNamespace()
+        */
+       public function getNamespace() {
+               return EP_NS_COURSE;
+       }
+       
 }

Modified: trunk/extensions/EducationProgram/includes/EPOrgPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrgPager.php   2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPOrgPager.php   2012-02-26 
22:25:49 UTC (rev 112450)
@@ -62,7 +62,7 @@
        public function getFormattedValue( $name, $value ) {
                switch ( $name ) {
                        case 'name':
-                               $value = EPOrgs::getLinkFor( $value );
+                               $value = OrgPage::getLinkFor( $value );
                                break;
                        case 'country':
                                $countries = array_flip( 
EPUtils::getCountryOptions( $this->getLanguage()->getCode() ) );

Modified: trunk/extensions/EducationProgram/includes/EPOrgs.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrgs.php       2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPOrgs.php       2012-02-26 
22:25:49 UTC (rev 112450)
@@ -13,19 +13,6 @@
  */
 class EPOrgs extends EPPageTable {
 
-       protected static $info = array(
-               'ns' => EP_NS_INSTITUTION,
-               'actions' => array(
-                       'view' => false,
-                       'edit' => 'ep-org',
-                       'history' => false,
-               ),
-               'edit-right' => 'ep-org',
-               'identifier' => 'name',
-               'list' => 'Institutions',
-               'log-type' => 'institution',
-       );
-       
        /**
         * (non-PHPdoc)
         * @see DBTable::getDBTable()
@@ -141,4 +128,20 @@
                return $options;
        }
        
+       /**
+        * (non-PHPdoc)
+        * @see EPPageObject::getIdentifierField()
+        */
+       public function getIdentifierField() {
+               return 'name';
+       }
+       
+       /**
+        * (non-PHPdoc)
+        * @see EPPageObject::getNamespace()
+        */
+       public function getNamespace() {
+               return EP_NS_INSTITUTION;
+       }
+       
 }

Modified: trunk/extensions/EducationProgram/includes/EPPageObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-02-26 
22:25:49 UTC (rev 112450)
@@ -13,13 +13,17 @@
  */
 abstract class EPPageObject extends EPRevisionedObject {
 
+       /**
+        * (non-PHPdoc)
+        * @see EPRevisionedObject::getIdentifier()
+        */
        public function getIdentifier() {
                return $this->getField( $this->table->getIdentifierField() );
        }
-
+       
        /**
+        * Returns the title of the page representing the object.
         *
-        *
         * @since 0.1
         *
         * @return Title
@@ -29,27 +33,39 @@
        }
        
        /**
+        * Gets a link to the page representing the object.
+        * 
+        * @since 0.1
+        * 
+        * @param string $action
+        * @param string $html
+        * @param array $customAttribs
+        * @param array $query
+        * 
+        * @return string
+        */
+       public function getLink( $action = 'view', $html = null, array 
$customAttribs = array(), array $query = array() ) {
+               return $this->table->getLinkFor(
+                       $this->getIdentifier(),
+                       $action,
+                       $html,
+                       $customAttribs,
+                       $query
+               );
+       }
+       
+       /**
         * (non-PHPdoc)
         * @see DBDataObject::save()
         */
        public function save() {
-               if ( $this->hasField( $this->table->getIdentifierField() ) && 
is_null( $this->getTitle() ) ) {
+               if ( $this->hasField( $this->getIdentifierField() ) && is_null( 
$this->getTitle() ) ) {
                        throw new MWException( 'The title for a EPPageObject 
needs to be valid when saving.' );
                        return false;
                }
                
                return parent::save();
        }
-       
-       public function getLink( $action = 'view', $html = null, $customAttribs 
= array(), $query = array() ) {
-               return $this->table->getLinkFor(
-                       $this->getIdentifier(),
-                       $action,
-                       $html,
-                       $customAttribs,
-                       $query
-               );
-       }
 
        /**
         * (non-PHPdoc)

Modified: trunk/extensions/EducationProgram/includes/EPPageTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPPageTable.php  2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPPageTable.php  2012-02-26 
22:25:49 UTC (rev 112450)
@@ -13,46 +13,32 @@
  */
 abstract class EPPageTable extends DBTable {
 
-       public function getIdentifierField() {
-               return static::$info['identifier'];
-       }
-
-       public function getEditRight() {
-               return static::$info['edit-right'];
-       }
-
-       public static function getTitleFor( $identifierValue ) {
-               return Title::newFromText(
-                       $identifierValue,
-                       static::$info['ns']
-               );
-       }
-
-       public static function getLinkFor( $identifierValue, $action = 'view', 
$html = null, $customAttribs = array(), $query = array() ) {
-               if ( $action !== 'view' ) {
-                       $query['action'] = $action;
-               }
-
-               return Linker::linkKnown( // Linker has no hook that allows us 
to figure out if the page actually exists :(
-                       self::getTitleFor( $identifierValue, $action ),
-                       is_null( $html ) ? htmlspecialchars( $identifierValue ) 
: $html,
-                       $customAttribs,
-                       $query
-               );
-       }
-
+       /**
+        * Returns the field use to identify this object, ie the part used as 
page title.
+        * 
+        * @since 0.1
+        * 
+        * @return string
+        */
+       public abstract function getIdentifierField();
+       
+       /**
+        * Returns the namespace in which objects of this type reside.
+        * 
+        * @since 0.1
+        * 
+        * @return integer
+        */
+       public abstract function getNamespace();
+       
        public function hasIdentifier( $identifier ) {
                return $this->has( array( $this->getIdentifierField() => 
$identifier ) );
        }
 
        public function get( $identifier, $fields = null ) {
-               return static::selectRow( $fields, array( 
$this->getIdentifierField() => $identifier ) );
+               return $this->selectRow( $fields, array( 
$this->getIdentifierField() => $identifier ) );
        }
 
-       public function getListPage() {
-               return static::$info['list'];
-       }
-
        /**
         * Delete all objects matching the provided condirions.
         *
@@ -92,40 +78,48 @@
                        'title' => $title,
                );
        }
-
-       public static function getTypeForNS( $ns ) {
-               foreach ( static::$info as $type => $info ) {
-                       if ( $info['ns'] === $ns ) {
-                               return $type;
-                       }
-               }
-
-               throw new MWException( 'Unknown EPPageObject ns' );
-       }
-
-       public static function getLatestRevForTitle( Title $title, $conditions 
= array() ) {
-               $conds = array(
-                       'type' => self::getTypeForNS( $title->getNamespace() ),
-                       'object_identifier' => $title->getText(),
+       
+       /**
+        * Construct a new title for an object of this type with the provided 
identifier value.
+        * 
+        * @since 0.1
+        * 
+        * @param string $identifierValue
+        * 
+        * @return Title
+        */
+       public function getTitleFor( $identifierValue ) {
+               return Title::newFromText(
+                       $identifierValue,
+                       $this->getNamespace()
                );
-
-               return EPRevision::getLastRevision( array_merge( $conds, 
$conditions ) );
        }
 
-       public static function displayDeletionLog( IContextSource $context, 
$messageKey ) {
-               $out = $context->getOutput();
+       /**
+        * Returns a link to the page representing the object of this type with 
the provided identifier value.
+        * 
+        * @since 0.1
+        * 
+        * @param string $identifierValue
+        * @param string $action
+        * @param string $html
+        * @param array $customAttribs
+        * @param array $query
+        * 
+        * @return string
+        */
+       public function getLinkFor( $identifierValue, $action = 'view', $html = 
null, array $customAttribs = array(), array $query = array() ) {
+               if ( $action !== 'view' ) {
+                       $query['action'] = $action;
+               }
 
-               LogEventsList::showLogExtract(
-                       $out,
-                       array( static::$info['log-type'] ),
-                       $context->getTitle(),
-                       '',
-                       array(
-                               'lim' => 10,
-                               'conds' => array( 'log_action' => 'remove' ),
-                               'showIfEmpty' => false,
-                               'msgKey' => array( $messageKey )
-                       )
+               // Linker has no hook that allows us to figure out if the page 
actually exists :(
+               // FIXME: now it does
+               return Linker::linkKnown( 
+                       $this->getTitleFor( $identifierValue, $action ),
+                       is_null( $html ) ? htmlspecialchars( $identifierValue ) 
: $html,
+                       $customAttribs,
+                       $query
                );
        }
 

Modified: trunk/extensions/EducationProgram/includes/EPRevisionPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRevisionPager.php      
2012-02-26 21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/includes/EPRevisionPager.php      
2012-02-26 22:25:49 UTC (rev 112450)
@@ -107,7 +107,8 @@
                        );
                }
                
-               if ( $this->getUser()->isAllowed( $this->table->getEditRight() 
) ) {
+               // TODO: $this->getUser()->isAllowed( 
$this->table->getEditRight() )
+               if ( false ) {
                        $actionLinks = array();
                        
                        if ( $this->mOffset !== '' || $this->rowNr < 
$this->mResult->numRows() - 1 ) {

Modified: trunk/extensions/EducationProgram/pages/CoursePage.php
===================================================================
--- trunk/extensions/EducationProgram/pages/CoursePage.php      2012-02-26 
21:44:36 UTC (rev 112449)
+++ trunk/extensions/EducationProgram/pages/CoursePage.php      2012-02-26 
22:25:49 UTC (rev 112450)
@@ -14,6 +14,20 @@
  */
 class CoursePage extends EPPage {
        
+       protected static $info = array(
+               'ns' => EP_NS_COURSE,
+               'actions' => array(
+                       'view' => false,
+                       'edit' => 'ep-course',
+                       'history' => false,
+                       'enroll' => 'ep-enroll',
+               ),
+               'edit-right' => 'ep-course',
+               'identifier' => 'name',
+               'list' => 'Courses',
+               'log-type' => 'course',
+       );
+       
        /**
         * (non-PHPdoc)
         * @see EPPage::getActions()

Modified: trunk/extensions/EducationProgram/pages/EPPage.php
===================================================================
--- trunk/extensions/EducationProgram/pages/EPPage.php  2012-02-26 21:44:36 UTC 
(rev 112449)
+++ trunk/extensions/EducationProgram/pages/EPPage.php  2012-02-26 22:25:49 UTC 
(rev 112450)
@@ -2,6 +2,8 @@
 
 /**
  * Abstract Page for interacting with a EPPageObject.
+ * 
+ * Forced to implement a bunch of stuff that better should be in Page... :/
  *
  * @since 0.1
  *
@@ -49,8 +51,32 @@
                $this->page = new WikiPage( $title );
        }
        
+       /**
+        * Returns a new instance based on the namespace of the provided title,
+        * or throws an exception if the namespace is not handled.
+        * 
+        * @since 0.1
+        * 
+        * @param Title $title
+        * 
+        * @return EPPage
+        * @throws MWException
+        */
+       public static function factory( Title $title ) {
+               switch ( $title->getNamespace() ) {
+                       case EP_NS_COURSE:
+                               return new CoursePage( $title );
+                               break;
+                       case EP_NS_INSTITUTION:
+                               return new OrgPage( $title );
+                               break;
+                       default:
+                               throw new MWException( 'Namespace not handled 
by EPPage' );
+               }
+       }
+       
        public function view() {
-       //      MediaWiki::articleFromTitle($title, $context)
+       
        }
        
        public function setContext( IContextSource $context ) {
@@ -131,4 +157,29 @@
                return $this->getLanguage();
        }
        
+       public function getEditRight() {
+               return static::$info['edit-right'];
+       }
+
+       public function getListPage() {
+               return static::$info['list'];
+       }
+       
+       public static function displayDeletionLog( IContextSource $context, 
$messageKey ) {
+               $out = $context->getOutput();
+
+               LogEventsList::showLogExtract(
+                       $out,
+                       array( static::$info['log-type'] ),
+                       $context->getTitle(),
+                       '',
+                       array(
+                               'lim' => 10,
+                               'conds' => array( 'log_action' => 'remove' ),
+                               'showIfEmpty' => false,
+                               'msgKey' => array( $messageKey )
+                       )
+               );
+       }
+       
 }

Modified: trunk/extensions/EducationProgram/pages/OrgPage.php
===================================================================
--- trunk/extensions/EducationProgram/pages/OrgPage.php 2012-02-26 21:44:36 UTC 
(rev 112449)
+++ trunk/extensions/EducationProgram/pages/OrgPage.php 2012-02-26 22:25:49 UTC 
(rev 112450)
@@ -14,6 +14,19 @@
  */
 class OrgPage extends EPPage {
        
+       protected static $info = array(
+               'ns' => EP_NS_INSTITUTION,
+               'actions' => array(
+                       'view' => false,
+                       'edit' => 'ep-org',
+                       'history' => false,
+               ),
+               'edit-right' => 'ep-org',
+               'identifier' => 'name',
+               'list' => 'Institutions',
+               'log-type' => 'institution',
+       );
+       
        /**
         * (non-PHPdoc)
         * @see EPPage::getActions()


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to