r112655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112654‎ | r112655 | r112656 >
Date:23:18, 28 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on org undeletion
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPAction.php (added) (history)
  • /trunk/extensions/EducationProgram/actions/EPEditAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EditCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EditOrgAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EditOrgAction.php
@@ -31,7 +31,7 @@
3232 * @see Action::getName()
3333 */
3434 public function getName() {
35 - return 'editorg';
 35+ return 'edit';
3636 }
3737
3838 /**
Index: trunk/extensions/EducationProgram/actions/EPAction.php
@@ -0,0 +1,90 @@
 2+<?php
 3+
 4+/**
 5+ * Abstract action class holding common EP functionality.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPAction.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 EPAction extends FormlessAction {
 17+
 18+ /**
 19+ * Display a warning that the page has been deleted together with the first
 20+ * few items from its deletion log.
 21+ *
 22+ * @since 0.1
 23+ */
 24+ public function displayDeletionLog() {
 25+ $out = $this->getOutput();
 26+
 27+ LogEventsList::showLogExtract(
 28+ $out,
 29+ array( $this->page->getLogType() ),
 30+ $this->getTitle(),
 31+ '',
 32+ array(
 33+ 'lim' => 10,
 34+ 'conds' => array( 'log_action' => 'remove' ),
 35+ 'showIfEmpty' => false,
 36+ 'msgKey' => array( $this->prefixMsg( 'deleted' ) )
 37+ )
 38+ );
 39+ }
 40+
 41+ /**
 42+ * Display an undeletion link if the user is alloed to undelete and
 43+ * if there are any previous revions that can be used to undelete.
 44+ *
 45+ * @since 0.1
 46+ */
 47+ public function displayUndeletionLink() {
 48+ if ( $this->getUser()->isAllowed( $this->page->getEditRight() ) ) {
 49+ $revisionCount = EPRevisions::singleton()->count( array(
 50+ 'object_identifier' => $this->getTitle()->getText()
 51+ ) );
 52+
 53+ if ( $revisionCount > 0 ) {
 54+ $this->getOutput()->addHTML( $this->msg(
 55+ $this->prefixMsg( 'undelete-revisions' ),
 56+ Message::rawParam( Linker::linkKnown(
 57+ $this->getTitle(),
 58+ $this->msg( $this->prefixMsg( 'undelete-link' ) )->numParams( $revisionCount )->escaped(),
 59+ array(),
 60+ array( 'action' => 'epundelete' )
 61+ ) )
 62+ )->text() );
 63+ }
 64+ }
 65+ }
 66+
 67+ /**
 68+ * Returns a prefixed message name.
 69+ *
 70+ * @since 0.1
 71+ *
 72+ * @param string $name
 73+ *
 74+ * @return string
 75+ */
 76+ protected function prefixMsg( $name ) {
 77+ return strtolower( get_class( $this->page ) ) . '-' . $this->getName() . '-' . $name;
 78+ }
 79+
 80+ /**
 81+ * Returns a salt based on the action and the page name.
 82+ *
 83+ * @since 0.1
 84+ *
 85+ * @return string
 86+ */
 87+ protected function getSalt() {
 88+ return get_class( $this->page ) . $this->getTitle()->getLocalURL();
 89+ }
 90+
 91+}
Property changes on: trunk/extensions/EducationProgram/actions/EPAction.php
___________________________________________________________________
Added: svn:eol-style
192 + native
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php
@@ -31,7 +31,7 @@
3232 * @see Action::getName()
3333 */
3434 public function getName() {
35 - return 'editcourse';
 35+ return 'edit';
3636 }
3737
3838 /**
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -77,7 +77,7 @@
7878 protected function getPageTitle() {
7979 $action = $this->isNew() ? 'add' : 'edit';
8080 return wfMsgExt(
81 - 'ep-' . strtolower( $this->getName() ) . '-' . $action,
 81+ $this->prefixMsg( 'title-' . $action ),
8282 'parsemag',
8383 $this->getTitle()->getText()
8484 );
@@ -100,6 +100,7 @@
101101 }
102102 else {
103103 if ( $object === false ) {
 104+ $this->displayUndeletionLink();
104105 $this->displayDeletionLog();
105106
106107 $this->isNew = true;
@@ -237,7 +238,7 @@
238239 $form->setShowSummary( !$this->isNew() );
239240
240241 $action = $this->isNew() ? 'add' : 'edit';
241 - $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-' . $action . '-legend' ) );
 242+ $form->setWrapperLegend( $this->msg( $this->prefixMsg( 'legend-' . $action ) ) );
242243
243244 $form->addButton(
244245 'cancelEdit',
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -285,8 +285,15 @@
286286 }
287287
288288 /**
 289+ * Undeletes ab object by inserting the current object.
 290+ * Only call this method when the object does not exist in
 291+ * it's database table and has the current version in the revision table.
289292 *
290 - * Enter description here ...
 293+ * @since 0.1
 294+ *
 295+ * @param EPRevisionAction $revAction
 296+ *
 297+ * @return boolean Success indicator
291298 */
292299 public function undelete( EPRevisionAction $revAction ) {
293300 $this->setRevisionAction( $revAction );
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -355,25 +355,26 @@
356356 // Institution editing
357357 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.',
358358 'educationprogram-org-edit-name' => 'Institution name',
359 - 'editorg-add-legend' => 'Add institution',
360 - 'editorg-edit-legend' => 'Edit institution',
 359+ 'orgpage-edit-legend-add' => 'Add institution',
 360+ 'orgpage-edit-legend-edit' => 'Edit institution',
361361 'educationprogram-org-edit-city' => 'City',
362362 'educationprogram-org-edit-country' => 'Country',
363363 'educationprogram-org-submit' => 'Submit',
364364 'ep-addorg' => 'There is no institution with this name yet, but you can add it.',
365365 'ep-editorg' => 'You are editing an existing institution.',
366366 'ep-editorg-exists-already' => 'This institution already exists. You are editing it.',
367 - 'ep-editorg-edit' => 'Editing institution: $1',
368 - 'ep-editorg-add' => 'Adding institution: $1',
369 - 'orgpage-editorg-deleted' => "'''Warning: You are recreating an institution that was previously deleted.'''
 367+ 'orgpage-edit-title-edit' => 'Editing institution: $1',
 368+ 'orgpage-edit-title-add' => 'Adding institution: $1',
 369+ 'orgpage-edit-deleted' => "'''Warning: You are recreating an institution that was previously deleted.'''
370370
371371 You should consider whether it is appropriate to continue editing this institution.
372372 The deletion log for this institution is provided below for convenience:",
373 - 'orgpage-editorg-undelete-link' => 'restore $1 {{PLURAL:$1|revision|revisions}}',
 373+ 'orgpage-edit-undelete-revisions' => 'This institution has been deleted. You can $1.',
 374+ 'orgpage-edit-undelete-link' => 'restore $1 {{PLURAL:$1|revision|revisions}}',
374375
375376 // Course editing
376 - 'editcourse-add-legend' => 'Add course',
377 - 'editcourse-edit-legend' => 'Edit course',
 377+ 'orgpage-edit-legend-add' => 'Add course',
 378+ 'orgpage-edit-legend-edit' => 'Edit course',
378379 'ep-course-edit-term' => 'Term',
379380 'ep-course-edit-org' => 'Institution',
380381 'ep-course-edit-start' => 'Start date',
@@ -393,9 +394,9 @@
394395 'ep-addcourse' => 'There is no course with this name yet, but you can add it.',
395396 'ep-editcourse' => 'You are editing an existing course.',
396397 'ep-editcourse-exists-already' => 'This course already exists. You are editing it.',
397 - 'ep-editcourse-edit' => 'Editing course: $1',
398 - 'ep-editcourse-add' => 'Adding course: $1',
399 - 'coursepage-editcourse-deleted' => "'''Warning: You are recreating a course that was previously deleted.'''
 398+ 'coursepage-edit-title-edit' => 'Editing course: $1',
 399+ 'coursepage-edit-title-add' => 'Adding course: $1',
 400+ 'coursepage-edit-deleted' => "'''Warning: You are recreating a course that was previously deleted.'''
400401
401402 You should consider whether it is appropriate to continue editing this course.
402403 The deletion log for this course is provided below for convenience:",
@@ -404,8 +405,8 @@
405406 'ep-course-invalid-token' => 'The token needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
406407 'ep-course-invalid-description' => 'The description needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
407408 'ep-course-invalid-lang' => 'This language is not valid.',
408 - 'coursepage-editcourse-undelete-revisions' => 'This page has been deleted. You can $1.',
409 - 'coursepage-editcourse-undelete-link' => 'restore $1 {{PLURAL:$1|revision|revisions}}',
 409+ 'coursepage-edit-undelete-revisions' => 'This course has been deleted. You can $1.',
 410+ 'coursepage-edit-undelete-link' => 'restore $1 {{PLURAL:$1|revision|revisions}}',
410411
411412 // ep.pager
412413 'ep-pager-confirm-delete' => 'Are you sure you want to delete this item?',

Status & tagging log