Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
— | — | @@ -36,14 +36,15 @@ |
37 | 37 | $out = $this->getOutput(); |
38 | 38 | |
39 | 39 | if ( $this->subPage === '' ) { |
40 | | - EPCourse::displayPager() |
| 40 | + EPCourse::displayAddNewRegion( $this->getContext() ); |
| 41 | + EPCourse::displayPager( $this->getContext() ); |
41 | 42 | } |
42 | 43 | else { |
43 | 44 | $org = EPOrg::has( array( 'name' => $this->subPage ) ); |
44 | 45 | |
45 | 46 | if ( $org === false ) { |
46 | 47 | $this->showError( wfMessage( 'ep-courses-nosuchcourses', $this->subPage ) ); |
47 | | - EPCourse::displayAddNewRegion( $this->getContext() ); |
| 48 | + EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
48 | 49 | } |
49 | 50 | else { |
50 | 51 | $out->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | if ( $org === false ) { |
46 | 46 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
47 | 47 | $out->addWikiMsg( 'ep-institution-create', 'parsemag', $this->subPage ); |
48 | | - EPOrg::displayAddNewControl( $this->getContext(), $this->subPage ); |
| 48 | + EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $this->subPage ) ); |
49 | 49 | } |
50 | 50 | else { |
51 | 51 | $out->addWikiMsg( 'ep-institution-none', 'parsemag', $this->subPage ); |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
— | — | @@ -36,28 +36,12 @@ |
37 | 37 | $out = $this->getOutput(); |
38 | 38 | |
39 | 39 | if ( $this->subPage === '' ) { |
40 | | - $this->displayPage(); |
| 40 | + EPOrg::displayAddNewControl( $this->getContext() ); |
| 41 | + EPOrg::displayPager( $this->getContext() ); |
41 | 42 | } |
42 | 43 | else { |
43 | | - $org = EPOrg::has( array( 'name' => $this->subPage ) ); |
44 | | - |
45 | | - if ( $org === false ) { |
46 | | - $this->showError( wfMessage( 'ep-institutions-nosuchinstitution', $this->subPage ) ); |
47 | | - $this->displayPage(); |
48 | | - } |
49 | | - else { |
50 | | - $out->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
51 | | - } |
| 44 | + $out->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
52 | 45 | } |
53 | 46 | } |
54 | 47 | |
55 | | - /** |
56 | | - * Display all the stuff that should be on the page. |
57 | | - * |
58 | | - * @since 0.1 |
59 | | - */ |
60 | | - protected function displayPage() { |
61 | | - |
62 | | - } |
63 | | - |
64 | 48 | } |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Adds a control to add a new course to the provided context. |
128 | | - * An org id can be provided to set the initially selected org. |
| 128 | + * Adittional arguments can be provided to set the default values for the control fields. |
129 | 129 | * |
130 | 130 | * @since 0.1 |
131 | 131 | * |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -112,7 +112,16 @@ |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | | - public static function displayAddNewControl( IContextSource $context, $name = false ) { |
| 116 | + /** |
| 117 | + * Adds a control to add a new org to the provided context. |
| 118 | + * Adittional arguments can be provided to set the default values for the control fields. |
| 119 | + * |
| 120 | + * @since 0.1 |
| 121 | + * |
| 122 | + * @param IContextSource $context |
| 123 | + * @param array $args |
| 124 | + */ |
| 125 | + public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
117 | 126 | $out = $context->getOutput(); |
118 | 127 | |
119 | 128 | $out->addHTML( Html::openElement( |
— | — | @@ -129,7 +138,13 @@ |
130 | 139 | |
131 | 140 | $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ) ); |
132 | 141 | |
133 | | - $out->addHTML( Xml::inputLabel( wfMsg( 'ep-institutions-newname' ), 'newname', 'newname', false, $name ) ); |
| 142 | + $out->addHTML( Xml::inputLabel( |
| 143 | + wfMsg( 'ep-institutions-newname' ), |
| 144 | + 'newname', |
| 145 | + 'newname', |
| 146 | + false, |
| 147 | + array_key_exists( 'name', $args ) ? $args['name'] : false |
| 148 | + ) ); |
134 | 149 | |
135 | 150 | $out->addHTML( ' ' . Html::input( |
136 | 151 | 'addneworg', |
— | — | @@ -142,4 +157,29 @@ |
143 | 158 | $out->addHTML( '</fieldset></form>' ); |
144 | 159 | } |
145 | 160 | |
| 161 | + /** |
| 162 | + * Display a pager with courses. |
| 163 | + * |
| 164 | + * @since 0.1 |
| 165 | + * |
| 166 | + * @param IContextSource $context |
| 167 | + * @param array $conditions |
| 168 | + */ |
| 169 | + public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 170 | + $pager = new EPOrgPager( $context, $conditions ); |
| 171 | + |
| 172 | + if ( $pager->getNumRows() ) { |
| 173 | + $context->getOutput()->addHTML( |
| 174 | + $pager->getFilterControl() . |
| 175 | + $pager->getNavigationBar() . |
| 176 | + $pager->getBody() . |
| 177 | + $pager->getNavigationBar() |
| 178 | + ); |
| 179 | + } |
| 180 | + else { |
| 181 | + $context->getOutput()->addHTML( $pager->getFilterControl( true ) ); |
| 182 | + $context->getOutput()->addWikiMsg( 'ep-orgs-noresults' ); |
| 183 | + } |
| 184 | + } |
| 185 | + |
146 | 186 | } |