r106407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106406‎ | r106407 | r106408 >
Date:03:34, 16 December 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
follow up to r106404 r106405 - cleanup and fixes
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitutions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php
@@ -24,4 +24,5 @@
2525 'Course' => array( 'Course' ),
2626 'Courses' => array( 'Courses' ),
2727 'EducationProgram' => array( 'EducationProgram' ),
 28+ 'EditInstitution' => array( 'EditInstitution' ),
2829 );
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php
@@ -88,7 +88,7 @@
8989 'form',
9090 array(
9191 'method' => 'post',
92 - 'action' => SpecialPage::getTitleFor( 'Institution' )->getLocalURL(),
 92+ 'action' => SpecialPage::getTitleFor( 'EditInstitution' )->getLocalURL(),
9393 )
9494 ) );
9595
@@ -98,9 +98,9 @@
9999
100100 $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ) );
101101
102 - $out->addHTML( Html::element( 'label', array( 'for' => 'neworg' ), wfMsg( 'ep-institutions-newname' ) ) );
 102+ $out->addHTML( Html::element( 'label', array( 'for' => 'newname' ), wfMsg( 'ep-institutions-newname' ) ) );
103103
104 - $out->addHTML( ' ' . Html::input( 'neworg' ) . ' ' );
 104+ $out->addHTML( ' ' . Html::input( 'newname' ) . ' ' );
105105
106106 $out->addHTML( Html::input(
107107 'addneworg',
Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'EditInstitution', 'epadmin', false );
 23+ parent::__construct( 'EditInstitution', 'epadmin', 'EPOrg', 'Institutions' );
2424 }
2525
2626 /**
@@ -38,21 +38,5 @@
3939
4040 return $this->processFormFields( $fields );
4141 }
42 -
43 - /**
44 - * (non-PHPdoc)
45 - * @see SpecialEPFormPage::getListPage()
46 - */
47 - protected function getListPage() {
48 - return 'Institutions';
49 - }
50 -
51 - /**
52 - * (non-PHPdoc)
53 - * @see SpecialEPFormPage::getListPage()
54 - */
55 - protected function getObjectClassName() {
56 - return 'EPOrg';
57 - }
5842
5943 }
Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php
@@ -28,25 +28,28 @@
2929 * @since 0.1
3030 * @var EPDBObject|false
3131 */
32 - protected $item;
 32+ protected $item = false;
3333
34 - /**
35 - * Returns the name of the EPDBObject deriving class this page edits or creates.
36 - *
37 - * @since 0.1
38 - *
39 - * @return string
40 - */
41 - protected abstract function getObjectClassName();
 34+ protected $itemClass;
4235
 36+ protected $listPage;
 37+
4338 /**
44 - * Gets the name of the list page corresponding to this edit page.
45 - *
 39+ * Constructor.
 40+ *
4641 * @since 0.1
4742 *
48 - * @return string
 43+ * @param string $name Name of the page
 44+ * @param string $right Right needed to access the page
 45+ * @param string $itemClass Name of the item class
 46+ * @param string $listPage Name of the page listing the items
4947 */
50 - protected abstract function getListPage();
 48+ public function __construct( $name, $right, $itemClass, $listPage ) {
 49+ $this->itemClass = $itemClass;
 50+ $this->listPage = $listPage;
 51+
 52+ parent::__construct( $name, $right, false );
 53+ }
5154
5255 /**
5356 * @see SpecialPage::getDescription
@@ -103,7 +106,7 @@
104107 * @return boolean
105108 */
106109 protected function isNew() {
107 - return $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) );
 110+ return $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'newEditToken' ) );
108111 }
109112
110113 /**
@@ -139,7 +142,7 @@
140143 * @since 0.1
141144 */
142145 protected function showContent() {
143 - $c = $this->getObjectClassName();
 146+ $c = $this->itemClass;
144147
145148 if ( $this->isNew() ) {
146149 $data = $this->getNewData();
@@ -158,7 +161,7 @@
159162 }
160163
161164 if ( $object === false ) {
162 - $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->getListPage() )->getLocalURL() );
 165+ $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() );
163166 }
164167 else {
165168 // if ( !$this->isNew() ) {
@@ -185,7 +188,7 @@
186189 wfMsg( 'cancel' ),
187190 'cancelEdit',
188191 array(
189 - 'target-url' => SpecialPage::getTitleFor( $this->getListPage() )->getFullURL()
 192+ 'target-url' => SpecialPage::getTitleFor( $this->listPage )->getFullURL()
190193 )
191194 );
192195
@@ -258,7 +261,7 @@
259262 * @since 0.1
260263 */
261264 public function onSuccess() {
262 - $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->getListPage() )->getLocalURL() );
 265+ $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() );
263266 }
264267
265268 /**
@@ -281,7 +284,7 @@
282285 }
283286 }
284287
285 - $c = $this->getObjectClassName();
 288+ $c = $this->itemClass;
286289 $item = new $c( $fields, is_null( $fields['id'] ) );
287290
288291 $success = $item->writeAllToDB();
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -64,6 +64,7 @@
6565 $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php';
6666 $wgAutoloadClasses['SpecialEditInstitution'] = dirname( __FILE__ ) . '/specials/SpecialEditInstitution.php';
6767 $wgAutoloadClasses['SpecialEducationProgram'] = dirname( __FILE__ ) . '/specials/SpecialEducationProgram.php';
 68+$wgAutoloadClasses['SpecialEPFormPage'] = dirname( __FILE__ ) . '/specials/SpecialEPFormPage.php';
6869 $wgAutoloadClasses['SpecialEPPage'] = dirname( __FILE__ ) . '/specials/SpecialEPPage.php';
6970 $wgAutoloadClasses['SpecialInstitution'] = dirname( __FILE__ ) . '/specials/SpecialInstitution.php';
7071 $wgAutoloadClasses['SpecialInstitutions'] = dirname( __FILE__ ) . '/specials/SpecialInstitutions.php';
@@ -80,6 +81,7 @@
8182 $wgSpecialPages['Course'] = 'SpecialCourse';
8283 $wgSpecialPages['Courses'] = 'SpecialCourses';
8384 $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram';
 85+$wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution';
8486
8587 $wgSpecialPageGroups['MyCourses'] = 'education';
8688 $wgSpecialPageGroups['Institution'] = 'education';
@@ -89,6 +91,7 @@
9092 $wgSpecialPageGroups['Course'] = 'education';
9193 $wgSpecialPageGroups['Courses'] = 'education';
9294 $wgSpecialPageGroups['EducationProgram'] = 'education';
 95+$wgSpecialPageGroups['EditInstitution'] = 'education';
9396
9497 // API
9598

Follow-up revisions

RevisionCommit summaryAuthorDate
r106409follow up to r106407, added docs and messagesjeroendedauw03:46, 16 December 2011
r106457follow up to r106407, use Xml:inputLabel so Nikerabbit is happyjeroendedauw18:35, 16 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106404unfinished code, will follow up soonish, from other devicejeroendedauw02:24, 16 December 2011
r106405follow up to r106404 - created base class for form pages taking away most of ...jeroendedauw03:12, 16 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:38, 16 December 2011

Isn't there Xml::inputLabel?

#Comment by Jeroen De Dauw (talk | contribs)   18:35, 16 December 2011

Thnx

Status & tagging log