Index: trunk/extensions/EducationProgram/actions/ViewOrgAction.php |
— | — | @@ -45,12 +45,13 @@ |
46 | 46 | |
47 | 47 | $out->addElement( 'h2', array(), wfMsg( 'ep-institution-courses' ) ); |
48 | 48 | |
49 | | - $out->addHTML( EPCourse::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) ) ); |
| 49 | + $out->addHTML( EPCourse::getPager( $this->getContext(), array( 'org_id' => $org->getId() ) ) ); |
50 | 50 | |
51 | 51 | if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
52 | 52 | $out->addElement( 'h2', array(), wfMsg( 'ep-institution-add-course' ) ); |
53 | 53 | |
54 | | - EPCourse::displayAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) ); |
| 54 | + $out->addModules( 'ep.addcourse' ); |
| 55 | + $out->addHTML( EPCourse::getAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) ) ); |
55 | 56 | } |
56 | 57 | } |
57 | 58 | |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
— | — | @@ -31,7 +31,6 @@ |
32 | 32 | * @param string|null $subPage |
33 | 33 | */ |
34 | 34 | public function execute( $subPage ) { |
35 | | - |
36 | 35 | parent::execute( $subPage ); |
37 | 36 | |
38 | 37 | if ( $this->subPage === '' ) { |
— | — | @@ -41,10 +40,10 @@ |
42 | 41 | |
43 | 42 | if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
44 | 43 | $this->getOutput()->addModules( 'ep.addorg' ); |
45 | | - $this->addCachedHTML( 'EPOrg::getAddNewControl', array( $this->getContext() ) ); |
| 44 | + $this->addCachedHTML( 'EPOrg::getAddNewControl' ); |
46 | 45 | } |
47 | 46 | |
48 | | - $this->addCachedHTML( 'EPOrg::getPager', array( $this->getContext() ) ); |
| 47 | + $this->addCachedHTML( 'EPOrg::getPager', $this->getContext() ); |
49 | 48 | |
50 | 49 | $this->saveCache(); |
51 | 50 | } |
— | — | @@ -60,8 +59,12 @@ |
61 | 60 | protected function getCacheKey() { |
62 | 61 | $values = $this->getRequest()->getValues(); |
63 | 62 | |
64 | | - $values[] = $this->getUser()->getId(); |
| 63 | + $user = $this->getUser(); |
65 | 64 | |
| 65 | + $values[] = $user->isAllowed( 'ep-org' ); |
| 66 | + $values[] = $user->isAllowed( 'ep-bulkdelorgs' ); |
| 67 | + $values[] = $user->getOption( 'ep_bulkdelorgs' ); |
| 68 | + |
66 | 69 | return array_merge( $values, parent::getCacheKey() ); |
67 | 70 | } |
68 | 71 | |
Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
— | — | @@ -36,18 +36,42 @@ |
37 | 37 | if ( $this->subPage === '' ) { |
38 | 38 | $this->displayNavigation(); |
39 | 39 | |
40 | | - $this->addCachedHTML( |
41 | | - function( IContextSource $context ) { |
42 | | - return |
43 | | - EPCourse::getAddNewRegion( $context ) . // FIXME |
44 | | - EPCourse::getPager( $context ); |
45 | | - }, |
46 | | - $this->getContext() |
47 | | - ); |
| 40 | + $this->startCache( 900 ); |
| 41 | + |
| 42 | + if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
| 43 | + $this->getOutput()->addModules( 'ep.addcourse' ); |
| 44 | + |
| 45 | + $this->addCachedHTML( |
| 46 | + function( IContextSource $context ) { |
| 47 | + return |
| 48 | + EPCourse::getAddNewRegion( $context ) . // FIXME |
| 49 | + EPCourse::getPager( $context ); |
| 50 | + }, |
| 51 | + $this->getContext() |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + $this->saveCache(); |
48 | 56 | } |
49 | 57 | else { |
50 | 58 | $this->getOutput()->redirect( Title::newFromText( $this->subPage, EP_NS_COURSE )->getLocalURL() ); |
51 | 59 | } |
52 | 60 | } |
53 | 61 | |
| 62 | + /** |
| 63 | + * @see SpecialCachedPage::getCacheKey |
| 64 | + * @return array |
| 65 | + */ |
| 66 | + protected function getCacheKey() { |
| 67 | + $values = $this->getRequest()->getValues(); |
| 68 | + |
| 69 | + $user = $this->getUser(); |
| 70 | + |
| 71 | + $values[] = $user->isAllowed( 'ep-course' ); |
| 72 | + $values[] = $user->isAllowed( 'ep-bulkdelcourses' ); |
| 73 | + $values[] = $user->getOption( 'ep_bulkdelcourses' ); |
| 74 | + |
| 75 | + return array_merge( $values, parent::getCacheKey() ); |
| 76 | + } |
| 77 | + |
54 | 78 | } |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -140,12 +140,11 @@ |
141 | 141 | * |
142 | 142 | * @since 0.1 |
143 | 143 | * |
144 | | - * @param IContextSource $context |
145 | 144 | * @param array $args |
146 | 145 | * |
147 | 146 | * @return string |
148 | 147 | */ |
149 | | - public static function getAddNewControl( IContextSource $context, array $args = array() ) { |
| 148 | + public static function getAddNewControl( array $args = array() ) { |
150 | 149 | $html = ''; |
151 | 150 | |
152 | 151 | $html .= Html::openElement( |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -293,32 +293,30 @@ |
294 | 294 | * @param IContextSource $context |
295 | 295 | * @param array $args |
296 | 296 | * |
297 | | - * @return boolean |
| 297 | + * @return string |
298 | 298 | */ |
299 | | - public static function displayAddNewControl( IContextSource $context, array $args ) { |
| 299 | + public static function getAddNewControl( IContextSource $context, array $args ) { |
300 | 300 | if ( !$context->getUser()->isAllowed( 'ep-course' ) ) { |
301 | | - return false; |
| 301 | + return ''; |
302 | 302 | } |
303 | 303 | |
304 | | - $out = $context->getOutput(); |
305 | | - |
306 | | - $out->addModules( 'ep.addcourse' ); |
| 304 | + $html = ''; |
307 | 305 | |
308 | | - $out->addHTML( Html::openElement( |
| 306 | + $html .= Html::openElement( |
309 | 307 | 'form', |
310 | 308 | array( |
311 | 309 | 'method' => 'post', |
312 | 310 | 'action' => EPCourses::singleton()->getTitleFor( 'NAME_PLACEHOLDER' )->getLocalURL( array( 'action' => 'edit' ) ), |
313 | 311 | ) |
314 | | - ) ); |
| 312 | + ); |
315 | 313 | |
316 | | - $out->addHTML( '<fieldset>' ); |
| 314 | + $html .= '<fieldset>'; |
317 | 315 | |
318 | | - $out->addHTML( '<legend>' . wfMsgHtml( 'ep-courses-addnew' ) . '</legend>' ); |
| 316 | + $html .= '<legend>' . $context->msg( 'ep-courses-addnew' )->escaped() . '</legend>'; |
319 | 317 | |
320 | | - $out->addElement( 'p', array(), wfMsg( 'ep-courses-namedoc' ) ); |
| 318 | + $html .= '<p>' . $context->msg( 'ep-courses-namedoc' )->escaped() . '</p>'; |
321 | 319 | |
322 | | - $out->addElement( 'label', array( 'for' => 'neworg' ), wfMsg( 'ep-courses-neworg' ) ); |
| 320 | + $html .= Html::element( 'label', array( 'for' => 'neworg' ), $context->msg( 'ep-courses-neworg' ) ); |
323 | 321 | |
324 | 322 | $select = new XmlSelect( |
325 | 323 | 'neworg', |
— | — | @@ -327,39 +325,39 @@ |
328 | 326 | ); |
329 | 327 | |
330 | 328 | $select->addOptions( EPOrgs::singleton()->getOrgOptions() ); |
331 | | - $out->addHTML( $select->getHTML() ); |
| 329 | + $html .= $select->getHTML(); |
332 | 330 | |
333 | | - $out->addHTML( ' ' . Xml::inputLabel( |
334 | | - wfMsg( 'ep-courses-newname' ), |
| 331 | + $html .= ' ' . Xml::inputLabel( |
| 332 | + $context->msg( 'ep-courses-newname' )->escaped(), |
335 | 333 | 'newname', |
336 | 334 | 'newname', |
337 | 335 | 20, |
338 | 336 | array_key_exists( 'name', $args ) ? $args['name'] : false |
339 | | - ) ); |
| 337 | + ); |
340 | 338 | |
341 | | - $out->addHTML( ' ' . Xml::inputLabel( |
342 | | - wfMsg( 'ep-courses-newterm' ), |
| 339 | + $html .= ' ' . Xml::inputLabel( |
| 340 | + $context->msg( 'ep-courses-newterm' )->escaped(), |
343 | 341 | 'newterm', |
344 | 342 | 'newterm', |
345 | 343 | 10, |
346 | 344 | array_key_exists( 'term', $args ) ? $args['term'] : false |
347 | | - ) ); |
| 345 | + ); |
348 | 346 | |
349 | | - $out->addHTML( ' ' . Html::input( |
| 347 | + $html .= ' ' . Html::input( |
350 | 348 | 'addnewcourse', |
351 | | - wfMsg( 'ep-courses-add' ), |
| 349 | + $context->msg( 'ep-courses-add' )->escaped(), |
352 | 350 | 'submit', |
353 | 351 | array( |
354 | 352 | 'disabled' => 'disabled', |
355 | 353 | 'class' => 'ep-course-add', |
356 | 354 | ) |
357 | | - ) ); |
| 355 | + ); |
358 | 356 | |
359 | | - $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
| 357 | + $html .= Html::hidden( 'isnew', 1 ); |
360 | 358 | |
361 | | - $out->addHTML( '</fieldset></form>' ); |
| 359 | + $html .= '</fieldset></form>'; |
362 | 360 | |
363 | | - return true; |
| 361 | + return $html; |
364 | 362 | } |
365 | 363 | |
366 | 364 | /** |
— | — | @@ -370,13 +368,15 @@ |
371 | 369 | * |
372 | 370 | * @param IContextSource $context |
373 | 371 | * @param array $args |
| 372 | + * |
| 373 | + * @return string |
374 | 374 | */ |
375 | | - public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
| 375 | + public static function getAddNewRegion( IContextSource $context, array $args = array() ) { |
376 | 376 | if ( EPOrgs::singleton()->has() ) { |
377 | | - EPCourse::displayAddNewControl( $context, $args ); |
| 377 | + return EPCourse::getAddNewControl( $context, $args ); |
378 | 378 | } |
379 | | - elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) { |
380 | | - $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' ); |
| 379 | + else { |
| 380 | + return $context->msg( 'ep-courses-addorgfirst' )->escaped(); |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |