r112067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112066‎ | r112067 | r112068 >
Date:00:03, 22 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
adding dedicated deletion pages for courses and orgs
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/DeleteCourseAction.php (added) (history)
  • /trunk/extensions/EducationProgram/actions/DeleteOrgAction.php (added) (history)
  • /trunk/extensions/EducationProgram/actions/EPDeleteAction.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/pages/CoursePage.php (modified) (history)
  • /trunk/extensions/EducationProgram/pages/OrgPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -60,10 +60,13 @@
6161 $wgAutoloadClasses['EPSettings'] = dirname( __FILE__ ) . '/EducationProgram.settings.php';
6262
6363 $wgAutoloadClasses['CourseHistoryAction'] = dirname( __FILE__ ) . '/actions/CourseHistoryAction.php';
 64+$wgAutoloadClasses['DeleteCourseAction'] = dirname( __FILE__ ) . '/actions/DeleteCourseAction.php';
 65+$wgAutoloadClasses['DeleteOrgAction'] = dirname( __FILE__ ) . '/actions/DeleteOrgAction.php';
6466 $wgAutoloadClasses['EditCourseAction'] = dirname( __FILE__ ) . '/actions/EditCourseAction.php';
6567 $wgAutoloadClasses['EditOrgAction'] = dirname( __FILE__ ) . '/actions/EditOrgAction.php';
6668 $wgAutoloadClasses['EPAddArticleAction'] = dirname( __FILE__ ) . '/actions/EPAddArticleAction.php';
6769 $wgAutoloadClasses['EPAddReviewerAction'] = dirname( __FILE__ ) . '/actions/EPAddReviewerAction.php';
 70+$wgAutoloadClasses['EPDeleteAction'] = dirname( __FILE__ ) . '/actions/EPDeleteAction.php';
6871 $wgAutoloadClasses['EPEditAction'] = dirname( __FILE__ ) . '/actions/EPEditAction.php';
6972 $wgAutoloadClasses['EPHistoryAction'] = dirname( __FILE__ ) . '/actions/EPHistoryAction.php';
7073 $wgAutoloadClasses['EPRemoveArticleAction'] = dirname( __FILE__ ) . '/actions/EPRemoveArticleAction.php';
Index: trunk/extensions/EducationProgram/pages/CoursePage.php
@@ -19,6 +19,7 @@
2020 'view' => 'ViewCourseAction',
2121 'edit' => 'EditCourseAction',
2222 'history' => 'CourseHistoryAction',
 23+ 'delete' => 'DeleteCourseAction',
2324 );
2425 }
2526
Index: trunk/extensions/EducationProgram/pages/OrgPage.php
@@ -19,6 +19,7 @@
2020 'view' => 'ViewOrgAction',
2121 'edit' => 'EditOrgAction',
2222 'history' => 'OrgHistoryAction',
 23+ 'delete' => 'DeleteOrgAction',
2324 );
2425 }
2526
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( '&#160;' . 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 @@
1414 */
1515 abstract class EPPageTable extends DBTable {
1616
 17+ // TODO
1718 protected static $info = array(
1819 'EPCourses' => array(
1920 'ns' => EP_NS_COURSE,
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -35,6 +35,7 @@
3636 'ep-tab-history' => 'View history',
3737 'ep-tab-enroll' => 'Enroll',
3838 'ep-tab-disenroll' => 'Disenroll',
 39+ 'ep-tab-delete' => 'Delete',
3940
4041 // Tooltips
4142 'tooltip-ep-form-save' => 'Save',
@@ -446,6 +447,20 @@
447448 'ep-coursehistory-norevs' => 'There is no edit history for this course.',
448449 'ep-coursehistory-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
449450
 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+
450465 // Special:Ambassador
451466 'ep-ambassador-does-not-exist' => 'There is no ambassador with name "$1". See [[Special:Ambassadors|here]] for a list of ambassadors.',
452467 'ep-ambassador-title' => 'Ambassador: $1',
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -258,6 +258,14 @@
259259 'text' => wfMsg( $exists ? 'ep-tab-edit' : 'ep-tab-create' ),
260260 'href' => $title->getLocalUrl( array( 'action' => 'edit' ) )
261261 );
 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+ }
262270 }
263271
264272 if ( $exists ) {

Status & tagging log