r111041 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111040‎ | r111041 | r111042 >
Date:15:45, 9 February 2012
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
work on revisioning and logging
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPEditAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPHistoryAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EPViewAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPViewAction.php
@@ -65,6 +65,11 @@
6666 }
6767 else {
6868 $out->addWikiMsg( strtolower( get_called_class() ) . '-none', $name );
 69+
 70+ $class::displayDeletionLog(
 71+ $this->getContext(),
 72+ 'ep-' . strtolower( $this->getName() ) . '-deleted'
 73+ );
6974 }
7075 }
7176 else {
Index: trunk/extensions/EducationProgram/actions/EPHistoryAction.php
@@ -35,25 +35,7 @@
3636 $object = $c::get( $this->getTitle()->getText() );
3737
3838 if ( $object === false ) {
39 - $this->getOutput()->addWikiMsg( 'ep-' . strtolower( $this->getName() ) . '-norevs' );
40 -
41 - $lastRev = EPRevision::selectRow(
42 - null,
43 - array(
44 - 'type' => EPPageObject::getTypeForNS( $this->getTitle()->getNamespace() ),
45 - 'object_identifier' => $this->getTitle()->getText(),
46 - 'deleted' => true,
47 - ),
48 - array(
49 - 'SORT BY' => EPRevision::getPrefixedField( 'time' ),
50 - 'ORDER' => 'DESC',
51 - )
52 - );
53 -
54 - if ( $lastRev !== false ) {
55 - // TODO: show available info about deletion
56 - $this->getOutput()->addWikiMsg( 'ep-' . strtolower( $this->getName() ) . '-deleted' );
57 - }
 39+ $this->displayNoRevisions();
5840 }
5941 else {
6042 $this->displayRevisions( $object );
@@ -62,6 +44,15 @@
6345 return '';
6446 }
6547
 48+ protected function displayNoRevisions() {
 49+ $this->getOutput()->addWikiMsg( 'ep-' . strtolower( $this->getName() ) . '-norevs' );
 50+
 51+ $c::displayDeletionLog(
 52+ $this->getContext(),
 53+ 'ep-' . strtolower( $this->getName() ) . '-deleted'
 54+ );
 55+ }
 56+
6657 /**
6758 * Returns the page title.
6859 *
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -89,6 +89,11 @@
9090 }
9191 else {
9292 if ( $object === false ) {
 93+ $c::displayDeletionLog(
 94+ $this->getContext(),
 95+ 'ep-' . strtolower( $this->getName() ) . '-deleted'
 96+ );
 97+
9398 $this->isNew = true;
9499 $object = new $c( $data, true );
95100 }
Index: trunk/extensions/EducationProgram/includes/EPRevision.php
@@ -147,5 +147,16 @@
148148
149149 return $this->user;
150150 }
 151+
 152+ public static function getLastRevision( array $conditions ) {
 153+ return EPRevision::selectRow(
 154+ null,
 155+ $conditions,
 156+ array(
 157+ 'SORT BY' => EPRevision::getPrefixedField( 'time' ),
 158+ 'ORDER' => 'DESC',
 159+ )
 160+ );
 161+ }
151162
152163 }
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php
@@ -40,16 +40,6 @@
4141 'log-type' => 'institution',
4242 ),
4343 );
44 -
45 - public static function getTypeForNS( $ns ) {
46 - foreach ( self::$info as $type => $info ) {
47 - if ( $info['ns'] === $ns ) {
48 - return $type;
49 - }
50 - }
51 -
52 - throw new MWException( 'Unknown EPPageObject ns' );
53 - }
5444
5545 public static function getIdentifierField() {
5646 return self::$info[get_called_class()]['identifier'];
@@ -156,4 +146,40 @@
157147 );
158148 }
159149
 150+ public static function getTypeForNS( $ns ) {
 151+ foreach ( self::$info as $type => $info ) {
 152+ if ( $info['ns'] === $ns ) {
 153+ return $type;
 154+ }
 155+ }
 156+
 157+ throw new MWException( 'Unknown EPPageObject ns' );
 158+ }
 159+
 160+ public static function getLatestRevForTitle( Title $title, $conditions = array() ) {
 161+ $conds = array(
 162+ 'type' => self::getTypeForNS( $title->getNamespace() ),
 163+ 'object_identifier' => $title->getText(),
 164+ );
 165+
 166+ return EPRevision::getLastRevision( array_merge( $conds, $conditions ) );
 167+ }
 168+
 169+ public static function displayDeletionLog( IContextSource $context, $messageKey ) {
 170+ $out = $context->getOutput();
 171+
 172+ LogEventsList::showLogExtract(
 173+ $out,
 174+ array( self::$info[get_called_class()]['log-type'] ),
 175+ $context->getTitle(),
 176+ '',
 177+ array(
 178+ 'lim' => 10,
 179+ 'conds' => array( 'log_action' => 'remove' ),
 180+ 'showIfEmpty' => false,
 181+ 'msgKey' => array( $messageKey )
 182+ )
 183+ );
 184+ }
 185+
160186 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -283,7 +283,10 @@
284284 'ep-editorg-exists-already' => 'This institution already exists. You are editing it.',
285285 'ep-editorg-edit' => 'Editing institution: $1',
286286 'ep-editorg-add' => 'Adding institution: $1',
 287+ 'ep-editorg-deleted' => "'''Warning: You are recreating an institution that was previously deleted.'''
287288
 289+You should consider whether it is appropriate to continue editing this institution.
 290+The deletion log for this institution is provided below for convenience:",
288291
289292 // Course editing
290293 'editcourse-add-legend' => 'Add course',
@@ -306,7 +309,11 @@
307310 'ep-editcourse-exists-already' => 'This course already exists. You are editing it.',
308311 'ep-editcourse-edit' => 'Editing course: $1',
309312 'ep-editcourse-add' => 'Adding course: $1',
 313+ 'ep-editcourse-deleted' => "'''Warning: You are recreating a course that was previously deleted.'''
310314
 315+You should consider whether it is appropriate to continue editing this course.
 316+The deletion log for this course is provided below for convenience:",
 317+
311318 'ep-course-invalid-org' => 'This institution does not exist.',
312319 'ep-course-invalid-token' => 'The token needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
313320 'ep-course-invalid-description' => 'The description needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
@@ -332,6 +339,7 @@
333340 'ep-institution-inactive' => 'Inactive',
334341 'ep-institution-active' => 'Active',
335342 'ep-institution-courses' => 'Courses',
 343+ 'ep-vieworg-deleted' => 'This institution has been deleted. The deletion log for the institution is provided below for reference.',
336344
337345 // Course viewing
338346 'ep-course-title' => 'Course: $1',
@@ -363,18 +371,19 @@
364372 'ep-instructor-summary' => 'Summary:',
365373 'ep-online-summary' => 'Summary:',
366374 'ep-campus-summary' => 'Summary:',
 375+ 'ep-viewcourse-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
367376
368377 // Institution history
369378 'ep-org-history' => 'View logs for this institution',
370379 'ep-orghistory-title' => 'Revision history of institution "$1"',
371380 'ep-orghistory-norevs' => 'There is no edit history for this institution.',
372 - 'ep-orghistory-deleted' => 'This institution has been deleted.',
 381+ 'ep-orghistory-deleted' => 'This institution has been deleted. The deletion log for the institution is provided below for reference.',
373382
374383 // Course history
375384 'ep-course-history' => 'View logs for this course',
376385 'ep-coursehistory-title' => 'Revision history of course "$1"',
377386 'ep-coursehistory-norevs' => 'There is no edit history for this course.',
378 - 'ep-coursehistory-deleted' => 'This course has been deleted.',
 387+ 'ep-coursehistory-deleted' => 'This course has been deleted. The deletion log for the course is provided below for reference.',
379388
380389 // Special:Ambassador
381390 'ep-ambassador-does-not-exist' => 'There is no ambassador with name "$1". See [[Special:Ambassadors|here]] for a list of ambassadors.',

Follow-up revisions

RevisionCommit summaryAuthorDate
r111164fix several minor issues, inc follow up to r111041 to add undefined varjeroendedauw15:40, 10 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:49, 10 February 2012

$c looks undefined in certain places.

Status & tagging log