Index: trunk/extensions/EducationProgram/actions/EditOrgAction.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | * @see Action::getName() |
33 | 33 | */ |
34 | 34 | public function getName() { |
35 | | - return 'editorg'; |
| 35 | + return 'edit'; |
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
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 |
1 | 92 | + native |
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | * @see Action::getName() |
33 | 33 | */ |
34 | 34 | public function getName() { |
35 | | - return 'editcourse'; |
| 35 | + return 'edit'; |
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | protected function getPageTitle() { |
79 | 79 | $action = $this->isNew() ? 'add' : 'edit'; |
80 | 80 | return wfMsgExt( |
81 | | - 'ep-' . strtolower( $this->getName() ) . '-' . $action, |
| 81 | + $this->prefixMsg( 'title-' . $action ), |
82 | 82 | 'parsemag', |
83 | 83 | $this->getTitle()->getText() |
84 | 84 | ); |
— | — | @@ -100,6 +100,7 @@ |
101 | 101 | } |
102 | 102 | else { |
103 | 103 | if ( $object === false ) { |
| 104 | + $this->displayUndeletionLink(); |
104 | 105 | $this->displayDeletionLog(); |
105 | 106 | |
106 | 107 | $this->isNew = true; |
— | — | @@ -237,7 +238,7 @@ |
238 | 239 | $form->setShowSummary( !$this->isNew() ); |
239 | 240 | |
240 | 241 | $action = $this->isNew() ? 'add' : 'edit'; |
241 | | - $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-' . $action . '-legend' ) ); |
| 242 | + $form->setWrapperLegend( $this->msg( $this->prefixMsg( 'legend-' . $action ) ) ); |
242 | 243 | |
243 | 244 | $form->addButton( |
244 | 245 | 'cancelEdit', |
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
— | — | @@ -285,8 +285,15 @@ |
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
| 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. |
289 | 292 | * |
290 | | - * Enter description here ... |
| 293 | + * @since 0.1 |
| 294 | + * |
| 295 | + * @param EPRevisionAction $revAction |
| 296 | + * |
| 297 | + * @return boolean Success indicator |
291 | 298 | */ |
292 | 299 | public function undelete( EPRevisionAction $revAction ) { |
293 | 300 | $this->setRevisionAction( $revAction ); |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -355,25 +355,26 @@ |
356 | 356 | // Institution editing |
357 | 357 | 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.', |
358 | 358 | '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', |
361 | 361 | 'educationprogram-org-edit-city' => 'City', |
362 | 362 | 'educationprogram-org-edit-country' => 'Country', |
363 | 363 | 'educationprogram-org-submit' => 'Submit', |
364 | 364 | 'ep-addorg' => 'There is no institution with this name yet, but you can add it.', |
365 | 365 | 'ep-editorg' => 'You are editing an existing institution.', |
366 | 366 | '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.''' |
370 | 370 | |
371 | 371 | You should consider whether it is appropriate to continue editing this institution. |
372 | 372 | 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}}', |
374 | 375 | |
375 | 376 | // 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', |
378 | 379 | 'ep-course-edit-term' => 'Term', |
379 | 380 | 'ep-course-edit-org' => 'Institution', |
380 | 381 | 'ep-course-edit-start' => 'Start date', |
— | — | @@ -393,9 +394,9 @@ |
394 | 395 | 'ep-addcourse' => 'There is no course with this name yet, but you can add it.', |
395 | 396 | 'ep-editcourse' => 'You are editing an existing course.', |
396 | 397 | '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.''' |
400 | 401 | |
401 | 402 | You should consider whether it is appropriate to continue editing this course. |
402 | 403 | The deletion log for this course is provided below for convenience:", |
— | — | @@ -404,8 +405,8 @@ |
405 | 406 | 'ep-course-invalid-token' => 'The token needs to be at least contain $1 {{PLURAL:$1|character|characters}}.', |
406 | 407 | 'ep-course-invalid-description' => 'The description needs to be at least contain $1 {{PLURAL:$1|character|characters}}.', |
407 | 408 | '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}}', |
410 | 411 | |
411 | 412 | // ep.pager |
412 | 413 | 'ep-pager-confirm-delete' => 'Are you sure you want to delete this item?', |