Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -60,10 +60,13 @@ |
61 | 61 | $wgAutoloadClasses['EPSettings'] = dirname( __FILE__ ) . '/EducationProgram.settings.php'; |
62 | 62 | |
63 | 63 | $wgAutoloadClasses['CourseHistoryAction'] = dirname( __FILE__ ) . '/actions/CourseHistoryAction.php'; |
| 64 | +$wgAutoloadClasses['DeleteCourseAction'] = dirname( __FILE__ ) . '/actions/DeleteCourseAction.php'; |
| 65 | +$wgAutoloadClasses['DeleteOrgAction'] = dirname( __FILE__ ) . '/actions/DeleteOrgAction.php'; |
64 | 66 | $wgAutoloadClasses['EditCourseAction'] = dirname( __FILE__ ) . '/actions/EditCourseAction.php'; |
65 | 67 | $wgAutoloadClasses['EditOrgAction'] = dirname( __FILE__ ) . '/actions/EditOrgAction.php'; |
66 | 68 | $wgAutoloadClasses['EPAddArticleAction'] = dirname( __FILE__ ) . '/actions/EPAddArticleAction.php'; |
67 | 69 | $wgAutoloadClasses['EPAddReviewerAction'] = dirname( __FILE__ ) . '/actions/EPAddReviewerAction.php'; |
| 70 | +$wgAutoloadClasses['EPDeleteAction'] = dirname( __FILE__ ) . '/actions/EPDeleteAction.php'; |
68 | 71 | $wgAutoloadClasses['EPEditAction'] = dirname( __FILE__ ) . '/actions/EPEditAction.php'; |
69 | 72 | $wgAutoloadClasses['EPHistoryAction'] = dirname( __FILE__ ) . '/actions/EPHistoryAction.php'; |
70 | 73 | $wgAutoloadClasses['EPRemoveArticleAction'] = dirname( __FILE__ ) . '/actions/EPRemoveArticleAction.php'; |
Index: trunk/extensions/EducationProgram/pages/CoursePage.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | 'view' => 'ViewCourseAction', |
21 | 21 | 'edit' => 'EditCourseAction', |
22 | 22 | 'history' => 'CourseHistoryAction', |
| 23 | + 'delete' => 'DeleteCourseAction', |
23 | 24 | ); |
24 | 25 | } |
25 | 26 | |
Index: trunk/extensions/EducationProgram/pages/OrgPage.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | 'view' => 'ViewOrgAction', |
21 | 21 | 'edit' => 'EditOrgAction', |
22 | 22 | 'history' => 'OrgHistoryAction', |
| 23 | + 'delete' => 'DeleteOrgAction', |
23 | 24 | ); |
24 | 25 | } |
25 | 26 | |
Index: trunk/extensions/EducationProgram/actions/DeleteOrgAction.php |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Page for deleting an institution. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file DeleteOrgAction.php |
| 10 | + * @ingroup EducationProgram |
| 11 | + * @ingroup Action |
| 12 | + * |
| 13 | + * @licence GNU GPL v3+ |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class DeleteOrgAction extends EPDeleteAction { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + * |
| 23 | + * @param Page $page |
| 24 | + * @param IContextSource $context |
| 25 | + */ |
| 26 | + protected function __construct( Page $page, IContextSource $context = null ) { |
| 27 | + parent::__construct( $page, $context, EPOrgs::singleton() ); |
| 28 | + } |
| 29 | + |
| 30 | + public function getName() { |
| 31 | + return 'deleteorg'; |
| 32 | + } |
| 33 | + |
| 34 | + public function getRestriction() { |
| 35 | + return 'ep-org'; |
| 36 | + } |
| 37 | + |
| 38 | +} |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/actions/DeleteCourseAction.php |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Page for deleting a course. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file DeleteCourseAction.php |
| 10 | + * @ingroup EducationProgram |
| 11 | + * @ingroup Action |
| 12 | + * |
| 13 | + * @licence GNU GPL v3+ |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class DeleteCourseAction extends EPDeleteAction { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + * |
| 23 | + * @param Page $page |
| 24 | + * @param IContextSource $context |
| 25 | + */ |
| 26 | + protected function __construct( Page $page, IContextSource $context = null ) { |
| 27 | + parent::__construct( $page, $context, EPCourses::singleton() ); |
| 28 | + } |
| 29 | + |
| 30 | + public function getName() { |
| 31 | + return 'deletecourse'; |
| 32 | + } |
| 33 | + |
| 34 | + public function getRestriction() { |
| 35 | + return 'ep-course'; |
| 36 | + } |
| 37 | + |
| 38 | +} |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/actions/EPDeleteAction.php |
— | — | @@ -0,0 +1,144 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Abstract action for deleting EPPageObject items. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPDeleteAction.php |
| 10 | + * @ingroup EducationProgram |
| 11 | + * @ingroup Action |
| 12 | + * |
| 13 | + * @licence GNU GPL v3+ |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +abstract class EPDeleteAction extends FormlessAction { |
| 17 | + |
| 18 | + /** |
| 19 | + * @since 0.1 |
| 20 | + * @var DBTable |
| 21 | + */ |
| 22 | + protected $table; |
| 23 | + |
| 24 | + /** |
| 25 | + * Constructor. |
| 26 | + * |
| 27 | + * @since 0.1 |
| 28 | + * |
| 29 | + * @param Page $page |
| 30 | + * @param IContextSource $context |
| 31 | + * @param DBTable $table |
| 32 | + */ |
| 33 | + protected function __construct( Page $page, IContextSource $context = null, DBTable $table ) { |
| 34 | + $this->table = $table; |
| 35 | + parent::__construct( $page, $context ); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * (non-PHPdoc) |
| 40 | + * @see Action::getDescription() |
| 41 | + */ |
| 42 | + protected function getDescription() { |
| 43 | + return $this->msg( 'backlinksubtitle' )->rawParams( Linker::link( $this->getTitle() ) ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Do something exciting on successful processing of the form. This might be to show |
| 48 | + * a confirmation message (watch, rollback, etc) or to redirect somewhere else (edit, |
| 49 | + * protect, etc). |
| 50 | + */ |
| 51 | + public function onSuccess() { |
| 52 | + $title = SpecialPage::getTitleFor( $this->table->getListPage() ); |
| 53 | + $this->getOutput()->getRedirect( $title->getLocalURL( array( 'deleted' => $this->getTitle()->getText() ) ) ); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * (non-PHPdoc) |
| 58 | + * @see FormlessAction::onView() |
| 59 | + */ |
| 60 | + public function onView() { |
| 61 | + $this->getOutput()->setPageTitle( $this->getPageTitle() ); |
| 62 | + |
| 63 | + $object = $this->table->get( $this->getTitle()->getText() ); |
| 64 | + |
| 65 | + if ( $object === false ) { |
| 66 | + // TODO |
| 67 | + throw new ErrorPageError( $this->getTitle(), $this->prefixMsg( 'none' ) ); |
| 68 | + } |
| 69 | + else { |
| 70 | + $this->displayForm( $object ); |
| 71 | + } |
| 72 | + |
| 73 | + return ''; |
| 74 | + } |
| 75 | + |
| 76 | + protected function displayForm( EPPageObject $object ) { |
| 77 | + $out = $this->getOutput(); |
| 78 | + |
| 79 | + $out->addWikiMsg( $this->prefixMsg( 'text' ), $object->getField( 'name' ) ); |
| 80 | + |
| 81 | + $out->addHTML( Html::openElement( |
| 82 | + 'form', |
| 83 | + array( |
| 84 | + 'method' => 'post', |
| 85 | + 'action' => $this->getTitle()->getLocalURL(), |
| 86 | + ) |
| 87 | + ) ); |
| 88 | + |
| 89 | + $out->addHTML( ' ' . Xml::inputLabel( |
| 90 | + wfMsg( $this->prefixMsg( 'summary' ) ), |
| 91 | + 'summary', |
| 92 | + 'summary', |
| 93 | + 65, |
| 94 | + false, |
| 95 | + array( |
| 96 | + 'maxlength' => 250, |
| 97 | + 'spellcheck' => true, |
| 98 | + ) |
| 99 | + ) ); |
| 100 | + |
| 101 | + $out->addHTML( '<br />' ); |
| 102 | + |
| 103 | + $out->addHTML( Html::input( |
| 104 | + 'delete', |
| 105 | + wfMsg( $this->prefixMsg( 'delete-button' ) ), |
| 106 | + 'submit', |
| 107 | + array( |
| 108 | + 'class' => 'ep-disenroll', |
| 109 | + ) |
| 110 | + ) ); |
| 111 | + |
| 112 | + $out->addElement( |
| 113 | + 'button', |
| 114 | + array( |
| 115 | + 'class' => 'ep-delete-cancel', |
| 116 | + 'target-url' => $this->getTitle()->getLocalURL(), |
| 117 | + ), |
| 118 | + wfMsg( $this->prefixMsg( 'cancel-button' ) ) |
| 119 | + ); |
| 120 | + |
| 121 | + $out->addHTML( Html::hidden( 'deleteToken', $this->getUser()->getEditToken( 'delete' . $this->getTitle()->getLocalURL() ) ) ); |
| 122 | + |
| 123 | + $out->addHTML( '</form>' ); |
| 124 | + } |
| 125 | + |
| 126 | + protected function prefixMsg( $name ) { |
| 127 | + return strtolower( get_called_class() ) . '-' . $name; |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Returns the page title. |
| 132 | + * |
| 133 | + * @since 0.1 |
| 134 | + * |
| 135 | + * @return string |
| 136 | + */ |
| 137 | + protected function getPageTitle() { |
| 138 | + return wfMsgExt( |
| 139 | + $this->prefixMsg( 'title' ), |
| 140 | + 'parsemag', |
| 141 | + $this->getTitle()->getText() |
| 142 | + ); |
| 143 | + } |
| 144 | + |
| 145 | +} |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/includes/EPPageTable.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | */ |
15 | 15 | abstract class EPPageTable extends DBTable { |
16 | 16 | |
| 17 | + // TODO |
17 | 18 | protected static $info = array( |
18 | 19 | 'EPCourses' => array( |
19 | 20 | 'ns' => EP_NS_COURSE, |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | 'ep-tab-history' => 'View history', |
37 | 37 | 'ep-tab-enroll' => 'Enroll', |
38 | 38 | 'ep-tab-disenroll' => 'Disenroll', |
| 39 | + 'ep-tab-delete' => 'Delete', |
39 | 40 | |
40 | 41 | // Tooltips |
41 | 42 | 'tooltip-ep-form-save' => 'Save', |
— | — | @@ -446,6 +447,20 @@ |
447 | 448 | 'ep-coursehistory-norevs' => 'There is no edit history for this course.', |
448 | 449 | 'ep-coursehistory-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.', |
449 | 450 | |
| 451 | + // Course deletion |
| 452 | + 'deletecourseaction-text' => 'You are about to delete course $1. This will remove all associated students!', |
| 453 | + 'deletecourseaction-summary' => 'Reason for deletion:', |
| 454 | + 'deletecourseaction-title' => 'Delete course "$1"', |
| 455 | + 'deletecourseaction-cancel-button' => 'Cancel', |
| 456 | + 'deletecourseaction-delete-button' => 'Delete course', |
| 457 | + |
| 458 | + // Institution deletion |
| 459 | + 'deleteorgaction-text' => "You are about to delete institution $1. This will remove all it's courses and their associated students!", |
| 460 | + 'deleteorgaction-summary' => 'Reason for deletion:', |
| 461 | + 'deleteorgaction-title' => 'Delete institution "$1"', |
| 462 | + 'deleteorgaction-cancel-button' => 'Cancel', |
| 463 | + 'deleteorgaction-delete-button' => 'Delete institution', |
| 464 | + |
450 | 465 | // Special:Ambassador |
451 | 466 | 'ep-ambassador-does-not-exist' => 'There is no ambassador with name "$1". See [[Special:Ambassadors|here]] for a list of ambassadors.', |
452 | 467 | 'ep-ambassador-title' => 'Ambassador: $1', |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -258,6 +258,14 @@ |
259 | 259 | 'text' => wfMsg( $exists ? 'ep-tab-edit' : 'ep-tab-create' ), |
260 | 260 | 'href' => $title->getLocalUrl( array( 'action' => 'edit' ) ) |
261 | 261 | ); |
| 262 | + |
| 263 | + if ( $exists ) { |
| 264 | + $links['actions']['delete'] = array( |
| 265 | + 'class' => $type === 'delete' ? 'selected' : false, |
| 266 | + 'text' => wfMsg( 'ep-tab-delete' ), |
| 267 | + 'href' => $title->getLocalUrl( array( 'action' => 'delete' ) ) |
| 268 | + ); |
| 269 | + } |
262 | 270 | } |
263 | 271 | |
264 | 272 | if ( $exists ) { |