Merge "style: indent tweaks to Title.php"
[lhc/web/wiklou.git] / includes / RecentChange.php
index 2bdcab4..f63e95c 100644 (file)
@@ -55,6 +55,7 @@
  *  lang            the interwiki prefix, automatically set in save()
  *  oldSize         text size before the change
  *  newSize         text size after the change
+ *  pageStatus      status of the page: created, deleted, moved, restored, changed
  *
  * temporary:       not stored in the database
  *      notificationtimestamp
@@ -79,7 +80,7 @@ class RecentChange {
         * @var Title
         */
        var $mMovedToTitle = false;
-       var $numberofWatchingusers = 0 ; # Dummy to prevent error message in SpecialRecentchangeslinked
+       var $numberofWatchingusers = 0; # Dummy to prevent error message in SpecialRecentchangeslinked
        var $notificationtimestamp;
 
        # Factory methods
@@ -234,6 +235,9 @@ class RecentChange {
                        unset( $this->mAttribs['rc_ip'] );
                }
 
+               # Trim spaces on user supplied text
+               $this->mAttribs['rc_comment'] = trim( $this->mAttribs['rc_comment'] );
+
                # Make sure summary is truncated (whole multibyte characters)
                $this->mAttribs['rc_comment'] = $wgContLang->truncate( $this->mAttribs['rc_comment'], 255 );
 
@@ -273,7 +277,8 @@ class RecentChange {
                                        $this->mAttribs['rc_timestamp'],
                                        $this->mAttribs['rc_comment'],
                                        $this->mAttribs['rc_minor'],
-                                       $this->mAttribs['rc_last_oldid'] );
+                                       $this->mAttribs['rc_last_oldid'],
+                                       $this->mExtra['pageStatus'] );
                        }
                }
        }
@@ -461,6 +466,7 @@ class RecentChange {
                        'lastTimestamp' => $lastTimestamp,
                        'oldSize'       => $oldSize,
                        'newSize'       => $newSize,
+                       'pageStatus'   => 'changed'
                );
                $rc->save();
                return $rc;
@@ -518,7 +524,8 @@ class RecentChange {
                        'prefixedDBkey' => $title->getPrefixedDBkey(),
                        'lastTimestamp' => 0,
                        'oldSize' => 0,
-                       'newSize' => $size
+                       'newSize' => $size,
+                       'pageStatus' => 'created'
                );
                $rc->save();
                return $rc;
@@ -572,6 +579,27 @@ class RecentChange {
                $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' ) {
                global $wgRequest;
 
+               ## Get pageStatus for email notification
+               switch ( $type . '-' . $action ) {
+                       case 'delete-delete':
+                               $pageStatus = 'deleted';
+                               break;
+                       case 'move-move':
+                       case 'move-move_redir':
+                               $pageStatus = 'moved';
+                               break;
+                       case 'delete-restore':
+                               $pageStatus = 'restored';
+                               break;
+                       case 'upload-upload':
+                               $pageStatus = 'created';
+                               break;
+                       case 'upload-overwrite':
+                       default:
+                               $pageStatus = 'changed';
+                               break;
+               }
+
                $rc = new RecentChange;
                $rc->mTitle = $target;
                $rc->mPerformer = $user;
@@ -605,6 +633,7 @@ class RecentChange {
                        'prefixedDBkey' => $title->getPrefixedDBkey(),
                        'lastTimestamp' => 0,
                        'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
+                       'pageStatus'    => $pageStatus,
                        'actionCommentIRC' => $actionCommentIRC
                );
                return $rc;
@@ -683,7 +712,7 @@ class RecentChange {
                        $trail = "curid=" . (int)( $this->mAttribs['rc_cur_id'] ) .
                                "&oldid=" . (int)( $this->mAttribs['rc_last_oldid'] );
                        if ( $forceCur ) {
-                               $trail .= '&diff=0' ;
+                               $trail .= '&diff=0';
                        } else {
                                $trail .= '&diff=' . (int)( $this->mAttribs['rc_this_oldid'] );
                        }
@@ -732,10 +761,10 @@ class RecentChange {
                        if ( $szdiff < -500 ) {
                                $szdiff = "\002$szdiff\002";
                        } elseif ( $szdiff >= 0 ) {
-                               $szdiff = '+' . $szdiff ;
+                               $szdiff = '+' . $szdiff;
                        }
                        // @todo i18n with parentheses in content language?
-                       $szdiff = '(' . $szdiff . ')' ;
+                       $szdiff = '(' . $szdiff . ')';
                } else {
                        $szdiff = '';
                }
@@ -771,7 +800,7 @@ class RecentChange {
                # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
                # no colour (\003) switches back to the term default
                $fullString = "$titleString\0034 $flag\00310 " .
-                                         "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
+                       "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
 
                return $fullString;
        }