specialwatchlist.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 514 行 · 第 1/2 页
PHP
514 行
# Show watchlist header $header = ''; if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) { $header .= wfMsg( 'wlheader-enotif' ) . "\n"; } if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) { $header .= wfMsg( 'wlheader-showupdated' ) . "\n"; } # Toggle watchlist content (all recent edits or just the latest) if( $wgUser->getOption( 'extendwatchlist' )) { $andLatest=''; $limitWatchlist = 'LIMIT ' . intval( $wgUser->getOption( 'wllimit' ) ); } else { $andLatest= 'AND rc_this_oldid=page_latest'; $limitWatchlist = ''; } # TODO: Consider removing the third parameter $header .= wfMsg( 'watchdetails', $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), '', $specialTitle->getFullUrl( 'edit=yes' ) ); $wgOut->addWikiText( $header ); if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) { $wgOut->addHTML( '<form action="' . $specialTitle->escapeLocalUrl() . '" method="post"><input type="submit" name="dummy" value="' . htmlspecialchars( wfMsg( 'enotif_reset' ) ) . '" /><input type="hidden" name="reset" value="all" /></form>' . "\n\n" ); } $sql = "SELECT rc_namespace AS page_namespace, rc_title AS page_title, rc_comment AS rev_comment, rc_cur_id AS page_id, rc_user AS rev_user, rc_user_text AS rev_user_text, rc_timestamp AS rev_timestamp, rc_minor AS rev_minor_edit, rc_this_oldid AS rev_id, rc_last_oldid, rc_id, rc_patrolled, rc_new AS page_is_new,wl_notificationtimestamp FROM $watchlist,$recentchanges,$page WHERE wl_user=$uid AND wl_namespace=rc_namespace AND wl_title=rc_title AND rc_timestamp > '$cutoff' AND rc_cur_id=page_id $andLatest $andHideOwn $andHideBots $nameSpaceClause ORDER BY rc_timestamp DESC $limitWatchlist"; $res = $dbr->query( $sql, $fname ); $numRows = $dbr->numRows( $res ); /* Start bottom header */ $wgOut->addHTML( "<hr />\n<p>" ); if($days >= 1) $wgOut->addWikiText( wfMsg( 'rcnote', $wgLang->formatNum( $numRows ), $wgLang->formatNum( $days ), $wgLang->timeAndDate( wfTimestampNow(), true ) ) . '<br />' , false ); elseif($days > 0) $wgOut->addWikiText( wfMsg( 'wlnote', $wgLang->formatNum( $numRows ), $wgLang->formatNum( round($days*24) ) ) . '<br />' , false ); $wgOut->addHTML( "\n" . wlCutoffLinks( $days, 'Watchlist', $nondefaults ) . "<br />\n" ); # Spit out some control panel links $thisTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' ); $skin = $wgUser->getSkin(); $linkElements = array( 'hideOwn' => 'wlhideshowown', 'hideBots' => 'wlhideshowbots' ); # Problems encountered using the fancier method $label = $hideBots ? wfMsgHtml( 'show' ) : wfMsgHtml( 'hide' ); $linkBits = wfArrayToCGI( array( 'hideBots' => 1 - (int)$hideBots ), $nondefaults ); $link = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); $links[] = wfMsgHtml( 'wlhideshowbots', $link ); $label = $hideOwn ? wfMsgHtml( 'show' ) : wfMsgHtml( 'hide' ); $linkBits = wfArrayToCGI( array( 'hideOwn' => 1 - (int)$hideOwn ), $nondefaults ); $link = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); $links[] = wfMsgHtml( 'wlhideshowown', $link ); $wgOut->addHTML( implode( ' | ', $links ) ); # Form for namespace filtering $thisAction = $thisTitle->escapeLocalUrl(); $nsForm = "<form method=\"post\" action=\"{$thisAction}\">\n"; $nsForm .= "<label for=\"namespace\">" . wfMsgExt( 'namespace', array( 'parseinline') ) . "</label> "; $nsForm .= HTMLnamespaceselector( $nameSpace, '' ) . "\n"; $nsForm .= ( $hideOwn ? "<input type=\"hidden\" name=\"hideown\" value=\"1\" />\n" : "" ); $nsForm .= ( $hideBots ? "<input type=\"hidden\" name=\"hidebots\" value=\"1\" />\n" : "" ); $nsForm .= "<input type=\"hidden\" name=\"days\" value=\"" . $days . "\" />\n"; $nsForm .= "<input type=\"submit\" name=\"submit\" value=\"" . wfMsgExt( 'allpagessubmit', array( 'escape') ) . "\" />\n"; $nsForm .= "</form>\n"; $wgOut->addHTML( $nsForm ); if ( $numRows == 0 ) { $wgOut->addWikitext( "<br />" . wfMsg( 'watchnochange' ), false ); $wgOut->addHTML( "</p>\n" ); return; } $wgOut->addHTML( "</p>\n" ); /* End bottom header */ $list = ChangesList::newFromUser( $wgUser ); $s = $list->beginRecentChangesList(); $counter = 1; while ( $obj = $dbr->fetchObject( $res ) ) { # Make fake RC entry $rc = RecentChange::newFromCurRow( $obj, $obj->rc_last_oldid ); $rc->counter = $counter++; if ( $wgShowUpdatedMarker ) { $updated = $obj->wl_notificationtimestamp; } else { // Same visual appearance as MW 1.4 $updated = true; } if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) { $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" .wfStrencode($obj->page_title). "' AND wl_namespace='{$obj->page_namespace}'" ; $res3 = $dbr->query( $sql3, DB_READ, $fname ); $x = $dbr->fetchObject( $res3 ); $rc->numberofWatchingusers = $x->n; } else { $rc->numberofWatchingusers = 0; } $s .= $list->recentChangesLine( $rc, $updated ); } $s .= $list->endRecentChangesList(); $dbr->freeResult( $res ); $wgOut->addHTML( $s ); if ( $wgUseWatchlistCache ) { $wgMemc->set( $memckey, $s, $wgWLCacheTimeout); }}function wlHoursLink( $h, $page, $options = array() ) { global $wgUser, $wgLang, $wgContLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), $wgLang->formatNum( $h ), wfArrayToCGI( array('days' => ($h / 24.0)), $options ) ); return $s;}function wlDaysLink( $d, $page, $options = array() ) { global $wgUser, $wgLang, $wgContLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), ($d ? $wgLang->formatNum( $d ) : wfMsgHtml( 'watchlistall2' ) ), wfArrayToCGI( array('days' => $d), $options ) ); return $s;}/** * Returns html */function wlCutoffLinks( $days, $page = 'Watchlist', $options = array() ) { $hours = array( 1, 2, 6, 12 ); $days = array( 1, 3, 7 ); $cl = ''; $i = 0; foreach( $hours as $h ) { $hours[$i++] = wlHoursLink( $h, $page, $options ); } $i = 0; foreach( $days as $d ) { $days[$i++] = wlDaysLink( $d, $page, $options ); } return wfMsgExt('wlshowlast', array('parseinline', 'replaceafter'), implode(' | ', $hours), implode(' | ', $days), wlDaysLink( 0, $page, $options ) );}/** * Count the number of items on a user's watchlist * * @param $talk Include talk pages * @return integer */function wlCountItems( &$user, $talk = true ) { $dbr =& wfGetDB( DB_SLAVE ); # Fetch the raw count $res = $dbr->select( 'watchlist', 'COUNT(*) AS count', array( 'wl_user' => $user->mId ), 'wlCountItems' ); $row = $dbr->fetchObject( $res ); $count = $row->count; $dbr->freeResult( $res ); # Halve to remove talk pages if needed if( !$talk ) $count = floor( $count / 2 ); return( $count ); }/** * Allow the user to clear their watchlist * * @param $out Output object * @param $request Request object * @param $par Parameters passed to the watchlist page * @return bool True if it's been taken care of; false indicates the watchlist * code needs to do something further */function wlHandleClear( &$out, &$request, $par ) { # Check this function has something to do if( $request->getText( 'action' ) == 'clear' || $par == 'clear' ) { global $wgUser; $out->setPageTitle( wfMsgHtml( 'clearwatchlist' ) ); $count = wlCountItems( $wgUser ); if( $count > 0 ) { # See if we're clearing or confirming if( $request->wasPosted() && $wgUser->matchEditToken( $request->getText( 'token' ), 'clearwatchlist' ) ) { # Clearing, so do it and report the result $dbw =& wfGetDB( DB_MASTER ); $dbw->delete( 'watchlist', array( 'wl_user' => $wgUser->mId ), 'wlHandleClear' ); $out->addWikiText( wfMsg( 'watchlistcleardone', $count ) ); $out->returnToMain(); } else { # Confirming, so show a form $wlTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' ); $out->addHTML( wfElement( 'form', array( 'method' => 'post', 'action' => $wlTitle->getLocalUrl( 'action=clear' ) ), NULL ) ); $out->addWikiText( wfMsg( 'watchlistcount', $count ) ); $out->addWikiText( wfMsg( 'watchlistcleartext' ) ); $out->addHTML( wfElement( 'input', array( 'type' => 'hidden', 'name' => 'token', 'value' => $wgUser->editToken( 'clearwatchlist' ) ), '' ) ); $out->addHTML( wfElement( 'input', array( 'type' => 'submit', 'name' => 'submit', 'value' => wfMsgHtml( 'watchlistclearbutton' ) ), '' ) ); $out->addHTML( wfCloseElement( 'form' ) ); } return( true ); } else { # Nothing on the watchlist; nothing to do here $out->addWikiText( wfMsg( 'nowatchlist' ) ); $out->returnToMain(); return( true ); } } else { return( false ); }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?