diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-01-11 19:06:07 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-01-11 19:06:07 +0000 |
commit | a58285fd06c8113c45377c655dd43cef6337e815 (patch) | |
tree | dfe31d3d12652352fe44890b4811eda0728faefb /includes/SpecialContributions.php | |
parent | 20194986f6638233732ba1fc3e838f117d3cc9ea (diff) |
Aktualisierung auf MediaWiki 1.9.0
Diffstat (limited to 'includes/SpecialContributions.php')
-rw-r--r-- | includes/SpecialContributions.php | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 8477b6bc..0a1ef6ee 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -9,6 +9,10 @@ class ContribsFinder { var $username, $offset, $limit, $namespace; var $dbr; + /** + * Constructor + * @param $username Username as a string + */ function ContribsFinder( $username ) { $this->username = $username; $this->namespace = false; @@ -27,11 +31,17 @@ class ContribsFinder { $this->offset = $offset; } + /** + * Get timestamp of either first or last contribution made by the user. + * @todo Maybe it should be private ? + * @param $dir string 'ASC' or 'DESC'. + * @return Revision timestamp (rev_timestamp). + */ function getEditLimit( $dir ) { list( $index, $usercond ) = $this->getUserCond(); $nscond = $this->getNamespaceCond(); $use_index = $this->dbr->useIndexClause( $index ); - extract( $this->dbr->tableNames( 'revision', 'page' ) ); + list( $revision, $page) = $this->dbr->tableNamesN( 'revision', 'page' ); $sql = "SELECT rev_timestamp " . " FROM $page,$revision $use_index " . " WHERE rev_page=page_id AND $usercond $nscond" . @@ -46,6 +56,10 @@ class ContribsFinder { } } + /** + * Get timestamps of first and last contributions made by the user. + * @return Array containing first rev_timestamp and last rev_timestamp. + */ function getEditLimits() { return array( $this->getEditLimit( "ASC" ), @@ -77,12 +91,15 @@ class ContribsFinder { return ''; } + /** + * @return Timestamp of first entry in previous page. + */ function getPreviousOffsetForPaging() { list( $index, $usercond ) = $this->getUserCond(); $nscond = $this->getNamespaceCond(); $use_index = $this->dbr->useIndexClause( $index ); - extract( $this->dbr->tableNames( 'page', 'revision' ) ); + list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' ); $sql = "SELECT rev_timestamp FROM $page, $revision $use_index " . "WHERE page_id = rev_page AND rev_timestamp > '" . $this->offset . "' AND " . @@ -90,7 +107,7 @@ class ContribsFinder { $sql .= " ORDER BY rev_timestamp ASC"; $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); $res = $this->dbr->query( $sql ); - + $numRows = $this->dbr->numRows( $res ); if ( $numRows ) { $this->dbr->dataSeek( $res, $numRows - 1 ); @@ -103,10 +120,13 @@ class ContribsFinder { return $offset; } + /** + * @return Timestamp of first entry in next page. + */ function getFirstOffsetForPaging() { list( $index, $usercond ) = $this->getUserCond(); $use_index = $this->dbr->useIndexClause( $index ); - extract( $this->dbr->tableNames( 'page', 'revision' ) ); + list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' ); $nscond = $this->getNamespaceCond(); $sql = "SELECT rev_timestamp FROM $page, $revision $use_index " . "WHERE page_id = rev_page AND " . @@ -114,7 +134,7 @@ class ContribsFinder { $sql .= " ORDER BY rev_timestamp ASC"; $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); $res = $this->dbr->query( $sql ); - + $numRows = $this->dbr->numRows( $res ); if ( $numRows ) { $this->dbr->dataSeek( $res, $numRows - 1 ); @@ -128,13 +148,13 @@ class ContribsFinder { } /* private */ function makeSql() { - $userCond = $condition = $index = $offsetQuery = ''; + $offsetQuery = ''; - extract( $this->dbr->tableNames( 'page', 'revision' ) ); + list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' ); list( $index, $userCond ) = $this->getUserCond(); if ( $this->offset ) - $offsetQuery = "AND rev_timestamp <= '{$this->offset}'"; + $offsetQuery = "AND rev_timestamp < '{$this->offset}'"; $nscond = $this->getNamespaceCond(); $use_index = $this->dbr->useIndexClause( $index ); @@ -149,6 +169,11 @@ class ContribsFinder { return $sql; } + /** + * This do the search for the user given when creating the object. + * It should probably be the only public function in this class. + * @return Array of contributions. + */ function find() { $contribs = array(); $res = $this->dbr->query( $this->makeSql(), __METHOD__ ); @@ -168,7 +193,6 @@ class ContribsFinder { */ function wfSpecialContributions( $par = null ) { global $wgUser, $wgOut, $wgLang, $wgRequest; - $fname = 'wfSpecialContributions'; $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' ); if ( !strlen( $target ) ) { @@ -190,7 +214,7 @@ function wfSpecialContributions( $par = null ) { if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) ) $options['offset'] = ''; - $title = Title::makeTitle( NS_SPECIAL, 'Contributions' ); + $title = SpecialPage::getTitleFor( 'Contributions' ); $options['target'] = $target; $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() ); @@ -316,17 +340,17 @@ function contributionsSub( $nt ) { } $talk = $nt->getTalkPage(); if( $talk ) { - # Talk page link + # Talk page link $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ); if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { # Block link if( $wgUser->isAllowed( 'block' ) ) - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Blockip/' . $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); # Block log link - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-blocklog' ), 'type=block&page=' . $nt->getPrefixedUrl() ); } # Other logs link - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() ); $ul .= ' (' . implode( ' | ', $tools ) . ')'; } return $ul; @@ -369,12 +393,6 @@ function contributionsForm( $options ) { * privileges. The rollback link restores the most recent version that was not * written by the target user. * - * If the contributions page is called with the parameter &bot=1, all rollback - * links also get that parameter. It causes the edit itself and the rollback - * to be marked as "bot" edits. Bot edits are hidden by default from recent - * changes, so this allows sysops to combat a busy vandal without bothering - * other users. - * * @todo This would probably look a lot nicer in a table. */ function ucListEdit( $sk, $row ) { @@ -390,7 +408,7 @@ function ucListEdit( $sk, $row ) { } $rev = new Revision( $row ); - + $page = Title::makeTitle( $row->page_namespace, $row->page_title ); $link = $sk->makeKnownLinkObj( $page ); $difftext = $topmarktext = ''; @@ -403,12 +421,7 @@ function ucListEdit( $sk, $row ) { } if( $wgUser->isAllowed( 'rollback' ) ) { - $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : ''; - $extraRollback .= '&token=' . urlencode( - $wgUser->editToken( array( $page->getPrefixedText(), $row->rev_user_text ) ) ); - $topmarktext .= ' ['. $sk->makeKnownLinkObj( $page, - $messages['rollbacklink'], - 'action=rollback&from=' . urlencode( $row->rev_user_text ) . $extraRollback ) .']'; + $topmarktext .= ' '.$sk->generateRollback( $rev ); } } @@ -421,7 +434,7 @@ function ucListEdit( $sk, $row ) { $comment = $sk->revComment( $rev ); $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); - + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { $d = '<span class="history-deleted">' . $d . '</span>'; } |