Page MenuHomePhabricator

charDiff.patch

Authored By
bzimport
Nov 21 2014, 8:01 PM
Size
3 KB
Referenced Files
None
Subscribers
None

charDiff.patch

Index: skins/monobook/main.css
===================================================================
--- skins/monobook/main.css (Revision 16523)
+++ skins/monobook/main.css (Arbeitskopie)
@@ -1488,3 +1488,7 @@
.imagelist .TablePager_col_links { background-color: #eeeeff }
.imagelist .TablePager_col_img_description { white-space: normal }
.imagelist th.TablePager_sort { background-color: #ccccff }
+
+.plusminus {
+ font-weight: normal
+}
\ Kein Zeilenvorschub am Ende der Datei
Index: includes/SpecialRecentchanges.php
===================================================================
--- includes/SpecialRecentchanges.php (Revision 16523)
+++ includes/SpecialRecentchanges.php (Arbeitskopie)
@@ -270,7 +270,43 @@
$wgOut->addHTML( $s );
}
}
+/**
+ * Calculates the difference of the character count
+ * between two revisions for recent changes,
+ * which are specified by id.
+ * @param $curid revision id of the newer revision
+ * @param $oldid revision id of the older revision
+ * @return string HTML <span> tag with the difference
+ */
+function rcCharacterDiff( $curid, $oldid )
+{
+ $currev = Revision::newFromId( intval( $curid ) );
+ if( is_object( $currev ) )
+ {
+ $curtext = $currev->getText();
+ }
+ $oldrev = Revision::newFromId( intval( $oldid ) );
+ if( is_object( $oldrev ) )
+ {
+ $oldtext = $oldrev->getText();
+ }
+ $diff = ( int ) ( mb_strlen( $curtext, "UTF8" ) - mb_strlen( $oldtext, "UTF8" ) );
+ if( $diff > 0 )
+ {
+ $diff = ( string ) "<span class='plusminus'>+</span>" . $diff;
+ } elseif( $diff === 0 )
+ {
+ $diff = ( string ) "<span class='plusminus'>&plusmn;</span>" . $diff;
+ } else
+ {
+ $diff = ( string ) "<span class='plusminus'>-</span>" . abs( $diff );
+ }
+ unset( $curtext );
+ unset( $oldtext );
+ return $diff;
+}
+
function rcFilterByCategories ( &$rows , $categories , $any ) {
require_once ( 'Categoryfinder.php' ) ;
Index: includes/ChangesList.php
===================================================================
--- includes/ChangesList.php (Revision 16523)
+++ includes/ChangesList.php (Arbeitskopie)
@@ -166,7 +166,12 @@
wfArrayToCGI( array(
'curid' => $rc->mAttribs['rc_cur_id'],
'action' => 'history' ) ) );
- $s .= ') . . ';
+ $s .= ') ';
+
+ # Character diff
+ $curid = $rc->mAttribs['rc_this_oldid'];
+ $oldid = $rc->mAttribs['rc_last_oldid'];
+ $s .= "(" . rcCharacterDiff( $curid, $oldid ) . ") . . ";
}
function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
@@ -450,6 +455,11 @@
$r .= ' '.$block[0]->timestamp.' ';
$r .= '</tt>';
+ # Character diff
+ $curid = $rcObj->mAttribs['rc_this_oldid'];
+ $oldid = $rcObj->mAttribs['rc_last_oldid'];
+ $r .= "(" . rcCharacterDiff( $curid, $oldid ) . ") ";
+
# Article link
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
$r .= $wgContLang->getDirMark();
@@ -599,6 +609,11 @@
}
$r .= ' '.$rcObj->timestamp.' </tt>';
+ # Character diff
+ $curid = $rcObj->mAttribs['rc_this_oldid'];
+ $oldid = $rcObj->mAttribs['rc_last_oldid'];
+ $r .= "(" . rcCharacterDiff( $curid, $oldid ) . ") ";
+
# Article link
$r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched );

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1307
Default Alt Text
charDiff.patch (3 KB)

Event Timeline