+
+ function cleanupForIRC( $text ) {
+ return str_replace(array("\n", "\r"), array("", ""), $text);
+ }
+
+ function getIRCLine() {
+ global $wgUseRCPatrol;
+
+ // FIXME: Would be good to replace these 2 extract() calls with something more explicit
+ // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
+ extract($this->mAttribs);
+ extract($this->mExtra);
+
+ $titleObj =& $this->getTitle();
+ if ( $rc_type == RC_LOG ) {
+ $title = Namespace::getCanonicalName( $titleObj->getNamespace() ) . $titleObj->getText();
+ } else {
+ $title = $titleObj->getPrefixedText();
+ }
+ $title = $this->cleanupForIRC( $title );
+
+ $bad = array("\n", "\r");
+ $empty = array("", "");
+ $title = $titleObj->getPrefixedText();
+ $title = str_replace($bad, $empty, $title);
+
+ // FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26
+ if ( $rc_type == RC_LOG ) {
+ $url = '';
+ } elseif ( $rc_new && $wgUseRCPatrol ) {
+ $url = $titleObj->getInternalURL("rcid=$rc_id");
+ } else if ( $rc_new ) {
+ $url = $titleObj->getInternalURL();
+ } else if ( $wgUseRCPatrol ) {
+ $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid&rcid=$rc_id");
+ } else {
+ $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid");
+ }
+
+ if ( isset( $oldSize ) && isset( $newSize ) ) {
+ $szdiff = $newSize - $oldSize;
+ if ($szdiff < -500) {
+ $szdiff = "\002$szdiff\002";
+ } elseif ($szdiff >= 0) {
+ $szdiff = '+' . $szdiff ;
+ }
+ $szdiff = '(' . $szdiff . ')' ;
+ } else {
+ $szdiff = '';
+ }
+
+ $user = $this->cleanupForIRC( $rc_user_text );
+
+ if ( $rc_type == RC_LOG ) {
+ $logTargetText = $logTarget->getPrefixedText();
+ $comment = $this->cleanupForIRC( str_replace( $logTargetText, "\00302$logTargetText\00310", $rc_comment ) );
+ $flag = $logAction;
+ } else {
+ $comment = $this->cleanupForIRC( $rc_comment );
+ $flag = ($rc_minor ? "M" : "") . ($rc_new ? "N" : "");
+ }
+ # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
+ # no colour (\003) switches back to the term default
+ $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
+ "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
+ return $fullString;
+ }
+
+ /**
+ * Returns the change size (HTML).
+ * The lengths can be given optionally.
+ */
+ function getCharacterDifference( $old = 0, $new = 0 ) {
+ global $wgRCChangedSizeThreshold, $wgLang;
+
+ if( $old === 0 ) {
+ $old = $this->mAttribs['rc_old_len'];
+ }
+ if( $new === 0 ) {
+ $new = $this->mAttribs['rc_new_len'];
+ }
+
+ if( $old === NULL || $new === NULL ) {
+ return '';
+ }
+
+ $szdiff = $new - $old;
+ $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'),
+ $wgLang->formatNum($szdiff) );
+
+ if( $szdiff < $wgRCChangedSizeThreshold ) {
+ return '<strong class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</strong>';
+ } elseif( $szdiff === 0 ) {
+ return '<span class=\'mw-plusminus-null\'>(' . $formatedSize . ')</span>';
+ } elseif( $szdiff > 0 ) {
+ return '<span class=\'mw-plusminus-pos\'>(+' . $formatedSize . ')</span>';
+ } else {
+ return '<span class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</span>';
+ }
+ }