r107181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107180‎ | r107181 | r107182 >
Date:21:06, 23 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
Follow up to r107179; fixes and cleanup
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourses.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitution.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitutions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php
@@ -36,14 +36,15 @@
3737 $out = $this->getOutput();
3838
3939 if ( $this->subPage === '' ) {
40 - EPCourse::displayPager()
 40+ EPCourse::displayAddNewRegion( $this->getContext() );
 41+ EPCourse::displayPager( $this->getContext() );
4142 }
4243 else {
4344 $org = EPOrg::has( array( 'name' => $this->subPage ) );
4445
4546 if ( $org === false ) {
4647 $this->showError( wfMessage( 'ep-courses-nosuchcourses', $this->subPage ) );
47 - EPCourse::displayAddNewRegion( $this->getContext() );
 48+ EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) );
4849 }
4950 else {
5051 $out->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() );
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php
@@ -44,7 +44,7 @@
4545 if ( $org === false ) {
4646 if ( $this->getUser()->isAllowed( 'epadmin' ) ) {
4747 $out->addWikiMsg( 'ep-institution-create', 'parsemag', $this->subPage );
48 - EPOrg::displayAddNewControl( $this->getContext(), $this->subPage );
 48+ EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $this->subPage ) );
4949 }
5050 else {
5151 $out->addWikiMsg( 'ep-institution-none', 'parsemag', $this->subPage );
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php
@@ -36,28 +36,12 @@
3737 $out = $this->getOutput();
3838
3939 if ( $this->subPage === '' ) {
40 - $this->displayPage();
 40+ EPOrg::displayAddNewControl( $this->getContext() );
 41+ EPOrg::displayPager( $this->getContext() );
4142 }
4243 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() );
5245 }
5346 }
5447
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 -
6448 }
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -124,7 +124,7 @@
125125
126126 /**
127127 * 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.
129129 *
130130 * @since 0.1
131131 *
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -112,7 +112,16 @@
113113 }
114114 }
115115
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() ) {
117126 $out = $context->getOutput();
118127
119128 $out->addHTML( Html::openElement(
@@ -129,7 +138,13 @@
130139
131140 $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ) );
132141
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+ ) );
134149
135150 $out->addHTML( ' ' . Html::input(
136151 'addneworg',
@@ -142,4 +157,29 @@
143158 $out->addHTML( '</fieldset></form>' );
144159 }
145160
 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+
146186 }

Sign-offs

UserFlagDate
Nikerabbitinspected12:20, 24 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107179restructuring some stuff and initial work on display of cousres, orgs and ter...jeroendedauw20:40, 23 December 2011

Status & tagging log