https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112655

Revision: 112655
Author:   jeroendedauw
Date:     2012-02-28 23:18:52 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
work on org undeletion

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/actions/EPEditAction.php
    trunk/extensions/EducationProgram/actions/EditCourseAction.php
    trunk/extensions/EducationProgram/actions/EditOrgAction.php
    trunk/extensions/EducationProgram/includes/EPRevisionedObject.php

Added Paths:
-----------
    trunk/extensions/EducationProgram/actions/EPAction.php

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-28 
23:18:11 UTC (rev 112654)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-28 
23:18:52 UTC (rev 112655)
@@ -355,25 +355,26 @@
        // Institution editing
        'editinstitution-text' => 'Enter the institution details below and 
click submit to save your changes.',
        'educationprogram-org-edit-name' => 'Institution name',
-       'editorg-add-legend' => 'Add institution',
-       'editorg-edit-legend' => 'Edit institution',
+       'orgpage-edit-legend-add' => 'Add institution',
+       'orgpage-edit-legend-edit' => 'Edit institution',
        'educationprogram-org-edit-city' => 'City',
        'educationprogram-org-edit-country' => 'Country',
        'educationprogram-org-submit' => 'Submit',
        'ep-addorg' => 'There is no institution with this name yet, but you can 
add it.',
        'ep-editorg' => 'You are editing an existing institution.',
        'ep-editorg-exists-already' => 'This institution already exists. You 
are editing it.',
-       'ep-editorg-edit' => 'Editing institution: $1',
-       'ep-editorg-add' => 'Adding institution: $1',
-       'orgpage-editorg-deleted' => "'''Warning: You are recreating an 
institution that was previously deleted.'''
+       'orgpage-edit-title-edit' => 'Editing institution: $1',
+       'orgpage-edit-title-add' => 'Adding institution: $1',
+       'orgpage-edit-deleted' => "'''Warning: You are recreating an 
institution that was previously deleted.'''
 
 You should consider whether it is appropriate to continue editing this 
institution.
 The deletion log for this institution is provided below for convenience:",
-       'orgpage-editorg-undelete-link' => 'restore $1 
{{PLURAL:$1|revision|revisions}}',
+       'orgpage-edit-undelete-revisions' => 'This institution has been 
deleted. You can $1.',
+       'orgpage-edit-undelete-link' => 'restore $1 
{{PLURAL:$1|revision|revisions}}',
 
        // Course editing
-       'editcourse-add-legend' => 'Add course',
-       'editcourse-edit-legend' => 'Edit course',
+       'orgpage-edit-legend-add' => 'Add course',
+       'orgpage-edit-legend-edit' => 'Edit course',
        'ep-course-edit-term' => 'Term',
        'ep-course-edit-org' => 'Institution',
        'ep-course-edit-start' => 'Start date',
@@ -393,9 +394,9 @@
        'ep-addcourse' => 'There is no course with this name yet, but you can 
add it.',
        'ep-editcourse' => 'You are editing an existing course.',
        'ep-editcourse-exists-already' => 'This course already exists. You are 
editing it.',
-       'ep-editcourse-edit' => 'Editing course: $1',
-       'ep-editcourse-add' => 'Adding course: $1',
-       'coursepage-editcourse-deleted' => "'''Warning: You are recreating a 
course that was previously deleted.'''
+       'coursepage-edit-title-edit' => 'Editing course: $1',
+       'coursepage-edit-title-add' => 'Adding course: $1',
+       'coursepage-edit-deleted' => "'''Warning: You are recreating a course 
that was previously deleted.'''
 
 You should consider whether it is appropriate to continue editing this course.
 The deletion log for this course is provided below for convenience:",
@@ -404,8 +405,8 @@
        'ep-course-invalid-token' => 'The token needs to be at least contain $1 
{{PLURAL:$1|character|characters}}.',
        'ep-course-invalid-description' => 'The description needs to be at 
least contain $1 {{PLURAL:$1|character|characters}}.',
        'ep-course-invalid-lang' => 'This language is not valid.',
-       'coursepage-editcourse-undelete-revisions' => 'This page has been 
deleted. You can $1.',
-       'coursepage-editcourse-undelete-link' => 'restore $1 
{{PLURAL:$1|revision|revisions}}',
+       'coursepage-edit-undelete-revisions' => 'This course has been deleted. 
You can $1.',
+       'coursepage-edit-undelete-link' => 'restore $1 
{{PLURAL:$1|revision|revisions}}',
 
        // ep.pager
        'ep-pager-confirm-delete' => 'Are you sure you want to delete this 
item?',

Added: trunk/extensions/EducationProgram/actions/EPAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPAction.php                      
        (rev 0)
+++ trunk/extensions/EducationProgram/actions/EPAction.php      2012-02-28 
23:18:52 UTC (rev 112655)
@@ -0,0 +1,90 @@
+<?php
+
+/**
+ * Abstract action class holding common EP functionality.
+ *
+ * @since 0.1
+ *
+ * @file EPAction.php
+ * @ingroup EducationProgram
+ * @ingroup Action
+ *
+ * @licence GNU GPL v3+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+abstract class EPAction extends FormlessAction {
+       
+       /**
+        * Display a warning that the page has been deleted together with the 
first
+        * few items from its deletion log.
+        * 
+        * @since 0.1
+        */
+       public function displayDeletionLog() {
+               $out = $this->getOutput();
+               
+               LogEventsList::showLogExtract(
+                       $out,
+                       array( $this->page->getLogType() ),
+                       $this->getTitle(),
+                       '',
+                       array(
+                               'lim' => 10,
+                               'conds' => array( 'log_action' => 'remove' ),
+                               'showIfEmpty' => false,
+                               'msgKey' => array( $this->prefixMsg( 'deleted' 
)  )
+                       )
+               );
+       }
+       
+       /**
+        * Display an undeletion link if the user is alloed to undelete and 
+        * if there are any previous revions that can be used to undelete.
+        * 
+        * @since 0.1
+        */
+       public function displayUndeletionLink() {
+               if ( $this->getUser()->isAllowed( $this->page->getEditRight() ) 
) {
+                       $revisionCount = EPRevisions::singleton()->count( array(
+                               'object_identifier' => 
$this->getTitle()->getText()
+                       ) );
+                       
+                       if ( $revisionCount > 0 ) {
+                               $this->getOutput()->addHTML( $this->msg(
+                                       $this->prefixMsg( 'undelete-revisions' 
),
+                                       Message::rawParam( Linker::linkKnown(
+                                               $this->getTitle(),
+                                               $this->msg( $this->prefixMsg( 
'undelete-link' ) )->numParams( $revisionCount )->escaped(),
+                                               array(),
+                                               array( 'action' => 'epundelete' 
)
+                                       ) )
+                               )->text() );
+                       }
+               }
+       }
+       
+       /**
+        * Returns a prefixed message name.
+        * 
+        * @since 0.1
+        * 
+        * @param string $name
+        * 
+        * @return string
+        */
+       protected function prefixMsg( $name ) {
+               return strtolower( get_class( $this->page ) ) . '-' . 
$this->getName() . '-' . $name;
+       }
+       
+       /**
+        * Returns a salt based on the action and the page name.
+        * 
+        * @since 0.1
+        * 
+        * @return string
+        */
+       protected function getSalt() {
+               return get_class( $this->page ) . 
$this->getTitle()->getLocalURL();
+       }
+               
+}


Property changes on: trunk/extensions/EducationProgram/actions/EPAction.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EducationProgram/actions/EPEditAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPEditAction.php  2012-02-28 
23:18:11 UTC (rev 112654)
+++ trunk/extensions/EducationProgram/actions/EPEditAction.php  2012-02-28 
23:18:52 UTC (rev 112655)
@@ -77,7 +77,7 @@
        protected function getPageTitle() {
                $action = $this->isNew() ? 'add' : 'edit';
                return wfMsgExt(
-                       'ep-' . strtolower( $this->getName() ) . '-' . $action,
+                       $this->prefixMsg( 'title-' . $action ),
                        'parsemag',
                        $this->getTitle()->getText()
                );
@@ -100,6 +100,7 @@
                }
                else {
                        if ( $object === false ) {
+                               $this->displayUndeletionLink();
                                $this->displayDeletionLog();
                
                                $this->isNew = true;
@@ -237,7 +238,7 @@
                $form->setShowSummary( !$this->isNew() );
                
                $action = $this->isNew() ? 'add' : 'edit';
-               $form->setWrapperLegend( $this->msg( strtolower( 
$this->getName() ) . '-' . $action . '-legend' ) );
+               $form->setWrapperLegend( $this->msg( $this->prefixMsg( 
'legend-' . $action ) ) );
 
                $form->addButton(
                        'cancelEdit',

Modified: trunk/extensions/EducationProgram/actions/EditCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-02-28 23:18:11 UTC (rev 112654)
+++ trunk/extensions/EducationProgram/actions/EditCourseAction.php      
2012-02-28 23:18:52 UTC (rev 112655)
@@ -31,7 +31,7 @@
         * @see Action::getName()
         */
        public function getName() {
-               return 'editcourse';
+               return 'edit';
        }
 
        /**

Modified: trunk/extensions/EducationProgram/actions/EditOrgAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EditOrgAction.php 2012-02-28 
23:18:11 UTC (rev 112654)
+++ trunk/extensions/EducationProgram/actions/EditOrgAction.php 2012-02-28 
23:18:52 UTC (rev 112655)
@@ -31,7 +31,7 @@
         * @see Action::getName()
         */
        public function getName() {
-               return 'editorg';
+               return 'edit';
        }
 
        /**

Modified: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRevisionedObject.php   
2012-02-28 23:18:11 UTC (rev 112654)
+++ trunk/extensions/EducationProgram/includes/EPRevisionedObject.php   
2012-02-28 23:18:52 UTC (rev 112655)
@@ -285,8 +285,15 @@
        }
        
        /**
+        * Undeletes ab object by inserting the current object.
+        * Only call this method when the object does not exist in
+        * it's database table and has the current version in the revision 
table.
         * 
-        * Enter description here ...
+        * @since 0.1
+        * 
+        * @param EPRevisionAction $revAction
+        * 
+        * @return boolean Success indicator
         */
        public function undelete( EPRevisionAction $revAction ) {
                $this->setRevisionAction( $revAction );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to