Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php |
— | — | @@ -24,4 +24,5 @@ |
25 | 25 | 'Course' => array( 'Course' ), |
26 | 26 | 'Courses' => array( 'Courses' ), |
27 | 27 | 'EducationProgram' => array( 'EducationProgram' ), |
| 28 | + 'EditInstitution' => array( 'EditInstitution' ), |
28 | 29 | ); |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | 'form', |
90 | 90 | array( |
91 | 91 | 'method' => 'post', |
92 | | - 'action' => SpecialPage::getTitleFor( 'Institution' )->getLocalURL(), |
| 92 | + 'action' => SpecialPage::getTitleFor( 'EditInstitution' )->getLocalURL(), |
93 | 93 | ) |
94 | 94 | ) ); |
95 | 95 | |
— | — | @@ -98,9 +98,9 @@ |
99 | 99 | |
100 | 100 | $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ) ); |
101 | 101 | |
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' ) ) ); |
103 | 103 | |
104 | | - $out->addHTML( ' ' . Html::input( 'neworg' ) . ' ' ); |
| 104 | + $out->addHTML( ' ' . Html::input( 'newname' ) . ' ' ); |
105 | 105 | |
106 | 106 | $out->addHTML( Html::input( |
107 | 107 | 'addneworg', |
Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'EditInstitution', 'epadmin', false ); |
| 23 | + parent::__construct( 'EditInstitution', 'epadmin', 'EPOrg', 'Institutions' ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
— | — | @@ -38,21 +38,5 @@ |
39 | 39 | |
40 | 40 | return $this->processFormFields( $fields ); |
41 | 41 | } |
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 | | - } |
58 | 42 | |
59 | 43 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
— | — | @@ -28,25 +28,28 @@ |
29 | 29 | * @since 0.1 |
30 | 30 | * @var EPDBObject|false |
31 | 31 | */ |
32 | | - protected $item; |
| 32 | + protected $item = false; |
33 | 33 | |
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; |
42 | 35 | |
| 36 | + protected $listPage; |
| 37 | + |
43 | 38 | /** |
44 | | - * Gets the name of the list page corresponding to this edit page. |
45 | | - * |
| 39 | + * Constructor. |
| 40 | + * |
46 | 41 | * @since 0.1 |
47 | 42 | * |
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 |
49 | 47 | */ |
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 | + } |
51 | 54 | |
52 | 55 | /** |
53 | 56 | * @see SpecialPage::getDescription |
— | — | @@ -103,7 +106,7 @@ |
104 | 107 | * @return boolean |
105 | 108 | */ |
106 | 109 | 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' ) ); |
108 | 111 | } |
109 | 112 | |
110 | 113 | /** |
— | — | @@ -139,7 +142,7 @@ |
140 | 143 | * @since 0.1 |
141 | 144 | */ |
142 | 145 | protected function showContent() { |
143 | | - $c = $this->getObjectClassName(); |
| 146 | + $c = $this->itemClass; |
144 | 147 | |
145 | 148 | if ( $this->isNew() ) { |
146 | 149 | $data = $this->getNewData(); |
— | — | @@ -158,7 +161,7 @@ |
159 | 162 | } |
160 | 163 | |
161 | 164 | if ( $object === false ) { |
162 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->getListPage() )->getLocalURL() ); |
| 165 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() ); |
163 | 166 | } |
164 | 167 | else { |
165 | 168 | // if ( !$this->isNew() ) { |
— | — | @@ -185,7 +188,7 @@ |
186 | 189 | wfMsg( 'cancel' ), |
187 | 190 | 'cancelEdit', |
188 | 191 | array( |
189 | | - 'target-url' => SpecialPage::getTitleFor( $this->getListPage() )->getFullURL() |
| 192 | + 'target-url' => SpecialPage::getTitleFor( $this->listPage )->getFullURL() |
190 | 193 | ) |
191 | 194 | ); |
192 | 195 | |
— | — | @@ -258,7 +261,7 @@ |
259 | 262 | * @since 0.1 |
260 | 263 | */ |
261 | 264 | public function onSuccess() { |
262 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->getListPage() )->getLocalURL() ); |
| 265 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( $this->listPage )->getLocalURL() ); |
263 | 266 | } |
264 | 267 | |
265 | 268 | /** |
— | — | @@ -281,7 +284,7 @@ |
282 | 285 | } |
283 | 286 | } |
284 | 287 | |
285 | | - $c = $this->getObjectClassName(); |
| 288 | + $c = $this->itemClass; |
286 | 289 | $item = new $c( $fields, is_null( $fields['id'] ) ); |
287 | 290 | |
288 | 291 | $success = $item->writeAllToDB(); |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php'; |
66 | 66 | $wgAutoloadClasses['SpecialEditInstitution'] = dirname( __FILE__ ) . '/specials/SpecialEditInstitution.php'; |
67 | 67 | $wgAutoloadClasses['SpecialEducationProgram'] = dirname( __FILE__ ) . '/specials/SpecialEducationProgram.php'; |
| 68 | +$wgAutoloadClasses['SpecialEPFormPage'] = dirname( __FILE__ ) . '/specials/SpecialEPFormPage.php'; |
68 | 69 | $wgAutoloadClasses['SpecialEPPage'] = dirname( __FILE__ ) . '/specials/SpecialEPPage.php'; |
69 | 70 | $wgAutoloadClasses['SpecialInstitution'] = dirname( __FILE__ ) . '/specials/SpecialInstitution.php'; |
70 | 71 | $wgAutoloadClasses['SpecialInstitutions'] = dirname( __FILE__ ) . '/specials/SpecialInstitutions.php'; |
— | — | @@ -80,6 +81,7 @@ |
81 | 82 | $wgSpecialPages['Course'] = 'SpecialCourse'; |
82 | 83 | $wgSpecialPages['Courses'] = 'SpecialCourses'; |
83 | 84 | $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram'; |
| 85 | +$wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution'; |
84 | 86 | |
85 | 87 | $wgSpecialPageGroups['MyCourses'] = 'education'; |
86 | 88 | $wgSpecialPageGroups['Institution'] = 'education'; |
— | — | @@ -89,6 +91,7 @@ |
90 | 92 | $wgSpecialPageGroups['Course'] = 'education'; |
91 | 93 | $wgSpecialPageGroups['Courses'] = 'education'; |
92 | 94 | $wgSpecialPageGroups['EducationProgram'] = 'education'; |
| 95 | +$wgSpecialPageGroups['EditInstitution'] = 'education'; |
93 | 96 | |
94 | 97 | // API |
95 | 98 | |