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

Revision: 112597
Author:   jeroendedauw
Date:     2012-02-28 14:29:16 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
some refactoring

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/EducationProgram.php
    trunk/extensions/EducationProgram/actions/EPHistoryAction.php
    trunk/extensions/EducationProgram/pages/CoursePage.php
    trunk/extensions/EducationProgram/pages/OrgPage.php

Removed Paths:
-------------
    trunk/extensions/EducationProgram/actions/CourseHistoryAction.php
    trunk/extensions/EducationProgram/actions/OrgHistoryAction.php

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-28 
14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-28 
14:29:16 UTC (rev 112597)
@@ -457,16 +457,16 @@
        'ep-viewcourse-deleted' => 'This course has been deleted. The deletion 
log for the course is provided below for reference.',
 
        // Institution history
-       'ep-org-history' => 'View logs for this institution',
-       'ep-orghistory-title' => 'Revision history of institution "$1"',
-       'ep-orghistory-norevs' => 'There is no edit history for this 
institution.',
-       'ep-orghistory-deleted' => 'This institution has been deleted. The 
deletion log for the institution is provided below for reference.',
+       'orgpage-history-description' => 'View logs for this institution',
+       'orgpage-history-title' => 'Revision history of institution "$1"',
+       'orgpage-history-norevs' => 'There is no edit history for this 
institution.',
+       'orgpage-history-deleted' => 'This institution has been deleted. The 
deletion log for the institution is provided below for reference.',
 
        // Course history
-       'ep-course-history' => 'View logs for this course',
-       'ep-coursehistory-title' => 'Revision history of course "$1"',
-       'ep-coursehistory-norevs' => 'There is no edit history for this 
course.',
-       'ep-coursehistory-deleted' => 'This course has been deleted. The 
deletion log for the course is provided below for reference.',
+       'coursepage-history-description' => 'View logs for this course',
+       'coursepage-history-title' => 'Revision history of course "$1"',
+       'coursepage-history-norevs' => 'There is no edit history for this 
course.',
+       'coursepage-history-deleted' => 'This course has been deleted. The 
deletion log for the course is provided below for reference.',
 
        // Course deletion
        'coursepage-delete-text' => 'You are about to delete course $1. This 
will remove all associated students!',

Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php      2012-02-28 
14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/EducationProgram.php      2012-02-28 
14:29:16 UTC (rev 112597)
@@ -59,7 +59,6 @@
 $wgAutoloadClasses['EPHooks']                                          = 
dirname( __FILE__ ) . '/EducationProgram.hooks.php';
 $wgAutoloadClasses['EPSettings']                                       = 
dirname( __FILE__ ) . '/EducationProgram.settings.php';
 
-$wgAutoloadClasses['CourseHistoryAction']                      = dirname( 
__FILE__ ) . '/actions/CourseHistoryAction.php';
 $wgAutoloadClasses['EditCourseAction']                                 = 
dirname( __FILE__ ) . '/actions/EditCourseAction.php';
 $wgAutoloadClasses['EditOrgAction']                            = dirname( 
__FILE__ ) . '/actions/EditOrgAction.php';
 $wgAutoloadClasses['EPAddArticleAction']                       = dirname( 
__FILE__ ) . '/actions/EPAddArticleAction.php';
@@ -73,7 +72,6 @@
 $wgAutoloadClasses['EPRestoreAction']                          = dirname( 
__FILE__ ) . '/actions/EPRestoreAction.php';
 $wgAutoloadClasses['EPUndoAction']                                     = 
dirname( __FILE__ ) . '/actions/EPUndoAction.php';
 $wgAutoloadClasses['EPViewAction']                                     = 
dirname( __FILE__ ) . '/actions/EPViewAction.php';
-$wgAutoloadClasses['OrgHistoryAction']                                 = 
dirname( __FILE__ ) . '/actions/OrgHistoryAction.php';
 $wgAutoloadClasses['ViewCourseAction']                                 = 
dirname( __FILE__ ) . '/actions/ViewCourseAction.php';
 $wgAutoloadClasses['ViewOrgAction']                            = dirname( 
__FILE__ ) . '/actions/ViewOrgAction.php';
 

Deleted: trunk/extensions/EducationProgram/actions/CourseHistoryAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/CourseHistoryAction.php   
2012-02-28 14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/actions/CourseHistoryAction.php   
2012-02-28 14:29:16 UTC (rev 112597)
@@ -1,42 +0,0 @@
-<?php
-
-/**
- * Action to view the history of courses.
- *
- * @since 0.1
- *
- * @file CourseHistoryAction.php
- * @ingroup EducationProgram
- * @ingroup Action
- *
- * @licence GNU GPL v3+
- * @author Jeroen De Dauw < [email protected] >
- */
-class CourseHistoryAction extends EPHistoryAction {
-
-       /**
-        * Constructor.
-        *
-        * @since 0.1
-        *
-        * @param Page $page
-        * @param IContextSource $context
-        */
-       protected function __construct( Page $page, IContextSource $context = 
null ) {
-               parent::__construct( $page, $context, EPCourses::singleton() );
-       }
-
-       public function getName() {
-               return 'coursehistory';
-       }
-
-       protected function getDescription() {
-               return Linker::linkKnown(
-                       SpecialPage::getTitleFor( 'Log' ),
-                       $this->msg( 'ep-course-history' )->escaped(),
-                       array(),
-                       array( 'page' => $this->getTitle()->getPrefixedText() )
-               );
-       }
-       
-}
\ No newline at end of file

Modified: trunk/extensions/EducationProgram/actions/EPHistoryAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-28 14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-28 14:29:16 UTC (rev 112597)
@@ -12,26 +12,14 @@
  * @licence GNU GPL v3+
  * @author Jeroen De Dauw < [email protected] >
  */
-abstract class EPHistoryAction extends FormlessAction {
+class EPHistoryAction extends FormlessAction {
 
        /**
-        * @since 0.1
-        * @var EPPageTable
+        * (non-PHPdoc)
+        * @see Action::getName()
         */
-       protected $table;
-
-       /**
-        * Constructor.
-        *
-        * @since 0.1
-        *
-        * @param Page $page
-        * @param IContextSource $context
-        * @param DBTable $table
-        */
-       protected function __construct( Page $page, IContextSource $context = 
null, EPPageTable $table ) {
-               $this->table = $table;
-               parent::__construct( $page, $context );
+       public function getName() {
+               return 'history';
        }
        
        /**
@@ -41,7 +29,7 @@
        public function onView() {
                $this->getOutput()->setPageTitle( $this->getPageTitle() );
                
-               $object = $this->table->get( $this->getTitle()->getText() );
+               $object = $this->page->getTable()->get( 
$this->getTitle()->getText() );
 
                if ( $object === false ) {
                        $this->displayNoRevisions();
@@ -54,11 +42,11 @@
        }
        
        protected function displayNoRevisions() {
-               $this->getOutput()->addWikiMsg( 'ep-' . strtolower( 
$this->getName() ) . '-norevs' );
+               $this->getOutput()->addWikiMsg( $this->prefixMsg( 'norevs' ) );
 
                $this->page->displayDeletionLog(
                        $this->getContext(),
-                       'ep-' . strtolower( $this->getName() ) . '-deleted' 
+                       $this->prefixMsg( 'deleted' ) 
                );
        }
        
@@ -71,7 +59,7 @@
         */
        protected function getPageTitle() {
                return wfMsgExt(
-                       'ep-' . strtolower( $this->getName() ) . '-title',
+                       $this->prefixMsg( 'title' ),
                        'parsemag',
                        $this->getTitle()->getText()
                );
@@ -132,7 +120,7 @@
                                '</fieldset></form>'
                );
 
-               $pager = new EPRevisionPager( $this->getContext(), 
$this->table, $conditions );
+               $pager = new EPRevisionPager( $this->getContext(), 
$this->page->getTable(), $conditions );
 
                if ( $pager->getNumRows() ) {
                        $out->addHTML(
@@ -145,5 +133,31 @@
                        // TODO
                }
        }
+       
+       /**
+        * (non-PHPdoc)
+        * @see Action::getDescription()
+        */
+       protected function getDescription() {
+               return Linker::linkKnown(
+                       SpecialPage::getTitleFor( 'Log' ),
+                       $this->msg( $this->prefixMsg( 'description' ) 
)->escaped(),
+                       array(),
+                       array( 'page' => $this->getTitle()->getPrefixedText() )
+               );
+       }
+       
+       /**
+        * Returns a prefixed message name.
+        * 
+        * @since 0.1
+        * 
+        * @param string $name
+        * 
+        * @return string
+        */
+       protected function prefixMsg( $name ) {
+               return strtolower( get_class( $this->page ) ) . '-' . 
$this->getName() . '-' . $name;
+       }
 
-}
\ No newline at end of file
+}

Deleted: trunk/extensions/EducationProgram/actions/OrgHistoryAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/OrgHistoryAction.php      
2012-02-28 14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/actions/OrgHistoryAction.php      
2012-02-28 14:29:16 UTC (rev 112597)
@@ -1,42 +0,0 @@
-<?php
-
-/**
- * Action to view the history of orgs.
- *
- * @since 0.1
- *
- * @file OrgHistoryAction.php
- * @ingroup EducationProgram
- * @ingroup Action
- *
- * @licence GNU GPL v3+
- * @author Jeroen De Dauw < [email protected] >
- */
-class OrgHistoryAction extends EPHistoryAction {
-
-       /**
-        * Constructor.
-        *
-        * @since 0.1
-        *
-        * @param Page $page
-        * @param IContextSource $context
-        */
-       protected function __construct( Page $page, IContextSource $context = 
null ) {
-               parent::__construct( $page, $context, EPOrgs::singleton() );
-       }
-       
-       public function getName() {
-               return 'orghistory';
-       }
-
-       protected function getDescription() {
-               return Linker::linkKnown(
-                       SpecialPage::getTitleFor( 'Log' ),
-                       $this->msg( 'ep-org-history' )->escaped(),
-                       array(),
-                       array( 'page' => $this->getTitle()->getPrefixedText() )
-               );
-       }
-
-}
\ No newline at end of file

Modified: trunk/extensions/EducationProgram/pages/CoursePage.php
===================================================================
--- trunk/extensions/EducationProgram/pages/CoursePage.php      2012-02-28 
14:24:37 UTC (rev 112596)
+++ trunk/extensions/EducationProgram/pages/CoursePage.php      2012-02-28 
14:29:16 UTC (rev 112597)
@@ -16,14 +16,7 @@
        
        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',
        );
@@ -36,7 +29,7 @@
                return array(
                        'view' => 'ViewCourseAction',
                        'edit' => 'EditCourseAction',
-                       'history' => 'CourseHistoryAction',
+                       'history' => 'EPHistoryAction',
                        'delete' => 'EPDeleteAction',
                );
        }

Modified: trunk/extensions/EducationProgram/pages/OrgPage.php
===================================================================
--- trunk/extensions/EducationProgram/pages/OrgPage.php 2012-02-28 14:24:37 UTC 
(rev 112596)
+++ trunk/extensions/EducationProgram/pages/OrgPage.php 2012-02-28 14:29:16 UTC 
(rev 112597)
@@ -16,13 +16,7 @@
        
        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',
        );
@@ -35,7 +29,7 @@
                return array(
                        'view' => 'ViewOrgAction',
                        'edit' => 'EditOrgAction',
-                       'history' => 'OrgHistoryAction',
+                       'history' => 'EPHistoryAction',
                        'delete' => 'EPDeleteAction',
                );
        }


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

Reply via email to