r112597 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112596‎ | r112597 | r112598 >
Date:14:29, 28 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some refactoring
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/CourseHistoryAction.php (deleted) (history)
  • /trunk/extensions/EducationProgram/actions/EPHistoryAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/OrgHistoryAction.php (deleted) (history)
  • /trunk/extensions/EducationProgram/pages/CoursePage.php (modified) (history)
  • /trunk/extensions/EducationProgram/pages/OrgPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -59,7 +59,6 @@
6060 $wgAutoloadClasses['EPHooks'] = dirname( __FILE__ ) . '/EducationProgram.hooks.php';
6161 $wgAutoloadClasses['EPSettings'] = dirname( __FILE__ ) . '/EducationProgram.settings.php';
6262
63 -$wgAutoloadClasses['CourseHistoryAction'] = dirname( __FILE__ ) . '/actions/CourseHistoryAction.php';
6463 $wgAutoloadClasses['EditCourseAction'] = dirname( __FILE__ ) . '/actions/EditCourseAction.php';
6564 $wgAutoloadClasses['EditOrgAction'] = dirname( __FILE__ ) . '/actions/EditOrgAction.php';
6665 $wgAutoloadClasses['EPAddArticleAction'] = dirname( __FILE__ ) . '/actions/EPAddArticleAction.php';
@@ -73,7 +72,6 @@
7473 $wgAutoloadClasses['EPRestoreAction'] = dirname( __FILE__ ) . '/actions/EPRestoreAction.php';
7574 $wgAutoloadClasses['EPUndoAction'] = dirname( __FILE__ ) . '/actions/EPUndoAction.php';
7675 $wgAutoloadClasses['EPViewAction'] = dirname( __FILE__ ) . '/actions/EPViewAction.php';
77 -$wgAutoloadClasses['OrgHistoryAction'] = dirname( __FILE__ ) . '/actions/OrgHistoryAction.php';
7876 $wgAutoloadClasses['ViewCourseAction'] = dirname( __FILE__ ) . '/actions/ViewCourseAction.php';
7977 $wgAutoloadClasses['ViewOrgAction'] = dirname( __FILE__ ) . '/actions/ViewOrgAction.php';
8078
Index: trunk/extensions/EducationProgram/pages/CoursePage.php
@@ -16,14 +16,7 @@
1717
1818 protected static $info = array(
1919 'ns' => EP_NS_COURSE,
20 - 'actions' => array(
21 - 'view' => false,
22 - 'edit' => 'ep-course',
23 - 'history' => false,
24 - 'enroll' => 'ep-enroll',
25 - ),
2620 'edit-right' => 'ep-course',
27 - 'identifier' => 'name',
2821 'list' => 'Courses',
2922 'log-type' => 'course',
3023 );
@@ -36,7 +29,7 @@
3730 return array(
3831 'view' => 'ViewCourseAction',
3932 'edit' => 'EditCourseAction',
40 - 'history' => 'CourseHistoryAction',
 33+ 'history' => 'EPHistoryAction',
4134 'delete' => 'EPDeleteAction',
4235 );
4336 }
Index: trunk/extensions/EducationProgram/pages/OrgPage.php
@@ -16,13 +16,7 @@
1717
1818 protected static $info = array(
1919 'ns' => EP_NS_INSTITUTION,
20 - 'actions' => array(
21 - 'view' => false,
22 - 'edit' => 'ep-org',
23 - 'history' => false,
24 - ),
2520 'edit-right' => 'ep-org',
26 - 'identifier' => 'name',
2721 'list' => 'Institutions',
2822 'log-type' => 'institution',
2923 );
@@ -35,7 +29,7 @@
3630 return array(
3731 'view' => 'ViewOrgAction',
3832 'edit' => 'EditOrgAction',
39 - 'history' => 'OrgHistoryAction',
 33+ 'history' => 'EPHistoryAction',
4034 'delete' => 'EPDeleteAction',
4135 );
4236 }
Index: trunk/extensions/EducationProgram/actions/OrgHistoryAction.php
@@ -1,42 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Action to view the history of orgs.
6 - *
7 - * @since 0.1
8 - *
9 - * @file OrgHistoryAction.php
10 - * @ingroup EducationProgram
11 - * @ingroup Action
12 - *
13 - * @licence GNU GPL v3+
14 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
15 - */
16 -class OrgHistoryAction extends EPHistoryAction {
17 -
18 - /**
19 - * Constructor.
20 - *
21 - * @since 0.1
22 - *
23 - * @param Page $page
24 - * @param IContextSource $context
25 - */
26 - protected function __construct( Page $page, IContextSource $context = null ) {
27 - parent::__construct( $page, $context, EPOrgs::singleton() );
28 - }
29 -
30 - public function getName() {
31 - return 'orghistory';
32 - }
33 -
34 - protected function getDescription() {
35 - return Linker::linkKnown(
36 - SpecialPage::getTitleFor( 'Log' ),
37 - $this->msg( 'ep-org-history' )->escaped(),
38 - array(),
39 - array( 'page' => $this->getTitle()->getPrefixedText() )
40 - );
41 - }
42 -
43 -}
\ No newline at end of file
Index: trunk/extensions/EducationProgram/actions/CourseHistoryAction.php
@@ -1,42 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Action to view the history of courses.
6 - *
7 - * @since 0.1
8 - *
9 - * @file CourseHistoryAction.php
10 - * @ingroup EducationProgram
11 - * @ingroup Action
12 - *
13 - * @licence GNU GPL v3+
14 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
15 - */
16 -class CourseHistoryAction extends EPHistoryAction {
17 -
18 - /**
19 - * Constructor.
20 - *
21 - * @since 0.1
22 - *
23 - * @param Page $page
24 - * @param IContextSource $context
25 - */
26 - protected function __construct( Page $page, IContextSource $context = null ) {
27 - parent::__construct( $page, $context, EPCourses::singleton() );
28 - }
29 -
30 - public function getName() {
31 - return 'coursehistory';
32 - }
33 -
34 - protected function getDescription() {
35 - return Linker::linkKnown(
36 - SpecialPage::getTitleFor( 'Log' ),
37 - $this->msg( 'ep-course-history' )->escaped(),
38 - array(),
39 - array( 'page' => $this->getTitle()->getPrefixedText() )
40 - );
41 - }
42 -
43 -}
\ No newline at end of file
Index: trunk/extensions/EducationProgram/actions/EPHistoryAction.php
@@ -12,26 +12,14 @@
1313 * @licence GNU GPL v3+
1414 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1515 */
16 -abstract class EPHistoryAction extends FormlessAction {
 16+class EPHistoryAction extends FormlessAction {
1717
1818 /**
19 - * @since 0.1
20 - * @var EPPageTable
 19+ * (non-PHPdoc)
 20+ * @see Action::getName()
2121 */
22 - protected $table;
23 -
24 - /**
25 - * Constructor.
26 - *
27 - * @since 0.1
28 - *
29 - * @param Page $page
30 - * @param IContextSource $context
31 - * @param DBTable $table
32 - */
33 - protected function __construct( Page $page, IContextSource $context = null, EPPageTable $table ) {
34 - $this->table = $table;
35 - parent::__construct( $page, $context );
 22+ public function getName() {
 23+ return 'history';
3624 }
3725
3826 /**
@@ -41,7 +29,7 @@
4230 public function onView() {
4331 $this->getOutput()->setPageTitle( $this->getPageTitle() );
4432
45 - $object = $this->table->get( $this->getTitle()->getText() );
 33+ $object = $this->page->getTable()->get( $this->getTitle()->getText() );
4634
4735 if ( $object === false ) {
4836 $this->displayNoRevisions();
@@ -54,11 +42,11 @@
5543 }
5644
5745 protected function displayNoRevisions() {
58 - $this->getOutput()->addWikiMsg( 'ep-' . strtolower( $this->getName() ) . '-norevs' );
 46+ $this->getOutput()->addWikiMsg( $this->prefixMsg( 'norevs' ) );
5947
6048 $this->page->displayDeletionLog(
6149 $this->getContext(),
62 - 'ep-' . strtolower( $this->getName() ) . '-deleted'
 50+ $this->prefixMsg( 'deleted' )
6351 );
6452 }
6553
@@ -71,7 +59,7 @@
7260 */
7361 protected function getPageTitle() {
7462 return wfMsgExt(
75 - 'ep-' . strtolower( $this->getName() ) . '-title',
 63+ $this->prefixMsg( 'title' ),
7664 'parsemag',
7765 $this->getTitle()->getText()
7866 );
@@ -132,7 +120,7 @@
133121 '</fieldset></form>'
134122 );
135123
136 - $pager = new EPRevisionPager( $this->getContext(), $this->table, $conditions );
 124+ $pager = new EPRevisionPager( $this->getContext(), $this->page->getTable(), $conditions );
137125
138126 if ( $pager->getNumRows() ) {
139127 $out->addHTML(
@@ -145,5 +133,31 @@
146134 // TODO
147135 }
148136 }
 137+
 138+ /**
 139+ * (non-PHPdoc)
 140+ * @see Action::getDescription()
 141+ */
 142+ protected function getDescription() {
 143+ return Linker::linkKnown(
 144+ SpecialPage::getTitleFor( 'Log' ),
 145+ $this->msg( $this->prefixMsg( 'description' ) )->escaped(),
 146+ array(),
 147+ array( 'page' => $this->getTitle()->getPrefixedText() )
 148+ );
 149+ }
 150+
 151+ /**
 152+ * Returns a prefixed message name.
 153+ *
 154+ * @since 0.1
 155+ *
 156+ * @param string $name
 157+ *
 158+ * @return string
 159+ */
 160+ protected function prefixMsg( $name ) {
 161+ return strtolower( get_class( $this->page ) ) . '-' . $this->getName() . '-' . $name;
 162+ }
149163
150 -}
\ No newline at end of file
 164+}
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -457,16 +457,16 @@
458458 'ep-viewcourse-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
459459
460460 // Institution history
461 - 'ep-org-history' => 'View logs for this institution',
462 - 'ep-orghistory-title' => 'Revision history of institution "$1"',
463 - 'ep-orghistory-norevs' => 'There is no edit history for this institution.',
464 - 'ep-orghistory-deleted' => 'This institution has been deleted. The deletion log for the institution is provided below for reference.',
 461+ 'orgpage-history-description' => 'View logs for this institution',
 462+ 'orgpage-history-title' => 'Revision history of institution "$1"',
 463+ 'orgpage-history-norevs' => 'There is no edit history for this institution.',
 464+ 'orgpage-history-deleted' => 'This institution has been deleted. The deletion log for the institution is provided below for reference.',
465465
466466 // Course history
467 - 'ep-course-history' => 'View logs for this course',
468 - 'ep-coursehistory-title' => 'Revision history of course "$1"',
469 - 'ep-coursehistory-norevs' => 'There is no edit history for this course.',
470 - 'ep-coursehistory-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
 467+ 'coursepage-history-description' => 'View logs for this course',
 468+ 'coursepage-history-title' => 'Revision history of course "$1"',
 469+ 'coursepage-history-norevs' => 'There is no edit history for this course.',
 470+ 'coursepage-history-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
471471
472472 // Course deletion
473473 'coursepage-delete-text' => 'You are about to delete course $1. This will remove all associated students!',

Status & tagging log