X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/ChangesList.php diff --git a/includes/ChangesList.php b/includes/ChangesList.php deleted file mode 100644 index b8bc4f55..00000000 --- a/includes/ChangesList.php +++ /dev/null @@ -1,1169 +0,0 @@ -mAttribs = $rc->mAttribs; - $rc2->mExtra = $rc->mExtra; - return $rc2; - } -} - -/** - * Base class for all changes lists - */ -class ChangesList { - public $skin; - protected $watchlist = false; - - /** - * Changeslist contructor - * @param $skin Skin - */ - public function __construct( $skin ) { - $this->skin = $skin; - $this->preCacheMessages(); - } - - /** - * Fetch an appropriate changes list class for the specified user - * Some users might want to use an enhanced list format, for instance - * - * @param $user User to fetch the list class for - * @return ChangesList derivative - */ - public static function newFromUser( &$user ) { - global $wgRequest; - - $sk = $user->getSkin(); - $list = null; - if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { - $new = $wgRequest->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); - return $new ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); - } else { - return $list; - } - } - - /** - * Sets the list to use a
  • tag - * @param $value Boolean - */ - public function setWatchlistDivs( $value = true ) { - $this->watchlist = $value; - } - - /** - * As we use the same small set of messages in various methods and that - * they are called often, we call them once and save them in $this->message - */ - private function preCacheMessages() { - if( !isset( $this->message ) ) { - foreach ( explode( ' ', 'cur diff hist last blocklink history ' . - 'semicolon-separator pipe-separator' ) as $msg ) { - $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); - } - } - } - - - /** - * Returns the appropriate flags for new page, minor change and patrolling - * @param $new Boolean - * @param $minor Boolean - * @param $patrolled Boolean - * @param $nothing String to use for empty space - * @param $bot Boolean - * @return String - */ - protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) { - $f = $new ? self::flag( 'newpage' ) : $nothing; - $f .= $minor ? self::flag( 'minor' ) : $nothing; - $f .= $bot ? self::flag( 'bot' ) : $nothing; - $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing; - return $f; - } - - /** - * Provide the element appropriate to a given abbreviated flag, - * namely the flag indicating a new page, a minor edit, a bot edit, or an - * unpatrolled edit. By default in English it will contain "N", "m", "b", - * "!" respectively, plus it will have an appropriate title and class. - * - * @param $key String: 'newpage', 'unpatrolled', 'minor', or 'bot' - * @return String: Raw HTML - */ - public static function flag( $key ) { - static $messages = null; - if ( is_null( $messages ) ) { - foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' . - 'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' . - 'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) { - $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' ); - } - } - # Inconsistent naming, bleh - if ( $key == 'newpage' || $key == 'unpatrolled' ) { - $key2 = $key; - } else { - $key2 = $key . 'edit'; - } - return "" - . $messages["${key2}letter"] - . ''; - } - - /** - * Returns text for the start of the tabular part of RC - * @return String - */ - public function beginRecentChangesList() { - $this->rc_cache = array(); - $this->rcMoveIndex = 0; - $this->rcCacheIndex = 0; - $this->lastdate = ''; - $this->rclistOpen = false; - return ''; - } - - /** - * Show formatted char difference - * @param $old Integer: bytes - * @param $new Integer: bytes - * @returns String - */ - public static function showCharacterDifference( $old, $new ) { - global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode; - $szdiff = $new - $old; - - $code = $wgLang->getCode(); - static $fastCharDiff = array(); - if ( !isset($fastCharDiff[$code]) ) { - $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1'; - } - - $formatedSize = $wgLang->formatNum($szdiff); - - if ( !$fastCharDiff[$code] ) { - $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize ); - } - - if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) { - $tag = 'strong'; - } else { - $tag = 'span'; - } - if( $szdiff === 0 ) { - return "<$tag class='mw-plusminus-null'>($formatedSize)"; - } elseif( $szdiff > 0 ) { - return "<$tag class='mw-plusminus-pos'>(+$formatedSize)"; - } else { - return "<$tag class='mw-plusminus-neg'>($formatedSize)"; - } - } - - /** - * Returns text for the end of RC - * @return String - */ - public function endRecentChangesList() { - if( $this->rclistOpen ) { - return "\n"; - } else { - return ''; - } - } - - public function insertMove( &$s, $rc ) { - # Diff - $s .= '(' . $this->message['diff'] . ') ('; - # Hist - $s .= $this->skin->link( - $rc->getMovedToTitle(), - $this->message['hist'], - array(), - array( 'action' => 'history' ), - array( 'known', 'noclasses' ) - ) . ') . . '; - # "[[x]] moved to [[y]]" - $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir'; - $s .= wfMsg( - $msg, - $this->skin->link( - $rc->getTitle(), - null, - array(), - array( 'redirect' => 'no' ), - array( 'known', 'noclasses' ) - ), - $this->skin->link( - $rc->getMovedToTitle(), - null, - array(), - array(), - array( 'known', 'noclasses' ) - ) - ); - } - - public function insertDateHeader( &$s, $rc_timestamp ) { - global $wgLang; - # Make date header if necessary - $date = $wgLang->date( $rc_timestamp, true, true ); - if( $date != $this->lastdate ) { - if( $this->lastdate != '' ) { - $s .= "\n"; - } - $s .= Xml::element( 'h4', null, $date ) . "\n