*
*/
require_once( 'SpecialRecentchanges.php' );
-require_once( 'WatchedItem.php' );
/**
- * constructor
+ * Constructor
+ * @todo Document $par parameter.
+ * @param $par String: FIXME
*/
function wfSpecialWatchlist( $par ) {
global $wgUser, $wgOut, $wgLang, $wgMemc, $wgRequest, $wgContLang;
- global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
+ global $wgUseWatchlistCache, $wgWLCacheTimeout;
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
global $wgEnotifWatchlist;
$fname = 'wfSpecialWatchlist';
- $wgOut->setPagetitle( wfMsg( 'watchlist' ) );
- $sub = htmlspecialchars( wfMsg( 'watchlistsub', $wgUser->getName() ) );
- $wgOut->setSubtitle( $sub );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
-
- $specialTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' );
+ $specialTitle = SpecialPage::getTitleFor( 'Watchlist' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ # Anons don't get a watchlist
if( $wgUser->isAnon() ) {
- $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
+ $wgOut->setPageTitle( wfMsg( 'watchnologin' ) );
+ $llink = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogin' ), wfMsgHtml( 'loginreqlink' ), 'returnto=' . $specialTitle->getPrefixedUrl() );
+ $wgOut->addHtml( wfMsgWikiHtml( 'watchlistanontext', $llink ) );
return;
+ } else {
+ $wgOut->setPageTitle( wfMsg( 'watchlist' ) );
+ $wgOut->setSubtitle( wfMsgWikiHtml( 'watchlistfor', htmlspecialchars( $wgUser->getName() ) ) );
}
if( wlHandleClear( $wgOut, $wgRequest, $par ) ) {
/* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
/* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ),
/* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ),
- 'namespace' => 'all',
+ /* ? */ 'namespace' => 'all',
);
extract($defaults);
if( !is_null( $t ) ) {
$wl = WatchedItem::fromUserTitle( $wgUser, $t );
if( $wl->removeWatch() === false ) {
- $wgOut->addHTML( "<br />\n" . wfMsg( 'couldntremove', htmlspecialchars($one) ) );
+ $wgOut->addHTML( wfMsg( 'couldntremove', htmlspecialchars($one) ) . "<br />\n" );
} else {
- $wgOut->addHTML( ' (' . htmlspecialchars($one) . ')' );
+ wfRunHooks('UnwatchArticle', array(&$wgUser, new Article($t)));
+ $wgOut->addHTML( '(' . htmlspecialchars($one) . ')<br />' );
}
} else {
- $wgOut->addHTML( "<br />\n" . wfMsg( 'iteminvalidname', htmlspecialchars($one) ) );
+ $wgOut->addHTML( wfMsg( 'iteminvalidname', htmlspecialchars($one) ) . "<br />\n" );
}
}
- $wgOut->addHTML( "done.</p>\n" );
+ $wgOut->addHTML( "</p>\n<p>" . wfMsg( 'wldone' ) . "</p>\n" );
}
if ( $wgUseWatchlistCache ) {
- $memckey = "$wgDBname:watchlist:id:" . $wgUser->getId();
+ $memckey = wfMemcKey( 'watchlist', 'id', $wgUser->getId() );
$cache_s = @$wgMemc->get( $memckey );
if( $cache_s ){
$wgOut->addWikiText( wfMsg('wlsaved') );
$linkBatch->execute();
if( $dbr->numRows( $res ) > 0 )
$dbr->dataSeek( $res, 0 ); # Let's do the time warp again!
-
- $sk = $wgUser->getSkin();
$list = array();
while( $s = $dbr->fetchObject( $res ) ) {
global $wgContLang;
$toolLinks = array();
$titleText = $titleObj->getPrefixedText();
- $pageLink = $sk->makeLinkObj( $titleObj );
- $toolLinks[] = $sk->makeLinkObj( $titleObj->getTalkPage(), $wgLang->getNsText( NS_TALK ) );
+ $pageLink = Linker::makeLinkObj( $titleObj );
+ $toolLinks[] = Linker::makeLinkObj( $titleObj->getTalkPage(), $wgLang->getNsText( NS_TALK ) );
if( $titleObj->exists() )
- $toolLinks[] = $sk->makeKnownLinkObj( $titleObj, wfMsgHtml( 'history_short' ), 'action=history' );
+ $toolLinks[] = Linker::makeKnownLinkObj( $titleObj, wfMsgHtml( 'history_short' ), 'action=history' );
$toolLinks = '(' . implode( ' | ', $toolLinks ) . ')';
$checkbox = '<input type="checkbox" name="id[]" value="' . htmlspecialchars( $titleObj->getPrefixedText() ) . '" /> ' . ( $wgContLang->isRTL() ? '‏' : '‎' );
if( $redir ) {
$wgOut->addHTML( '</ul>' );
}
$wgOut->addHTML(
- "<input type='submit' name='remove' value=\"" .
- htmlspecialchars( wfMsg( "removechecked" ) ) . "\" />\n" .
- "</form>\n"
+ wfSubmitButton( wfMsg('removechecked'), array('name' => 'remove') ) .
+ "\n</form>\n"
);
return;
$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 ),
+ $header .= wfMsgExt( 'watchdetails', array( 'parsemag' ), $wgLang->formatNum( $nitems ),
$wgLang->formatNum( $npages ), '',
$specialTitle->getFullUrl( 'edit=yes' ) );
$wgOut->addWikiText( $header );
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_last_oldid, rc_id, rc_patrolled,
rc_new AS page_is_new,wl_notificationtimestamp
FROM $watchlist,$recentchanges,$page
WHERE wl_user=$uid
AND wl_title=rc_title
AND rc_timestamp > '$cutoff'
AND rc_cur_id=page_id
+ $andLatest
$andHideOwn
$andHideBots
$nameSpaceClause
- ORDER BY rc_timestamp DESC";
+ ORDER BY rc_timestamp DESC
+ $limitWatchlist";
$res = $dbr->query( $sql, $fname );
$numRows = $dbr->numRows( $res );
/* Start bottom header */
- $wgOut->addHTML( "<hr />\n<p>" );
+ $wgOut->addHTML( "<hr />\n" );
- if($days >= 1)
+ if($days >= 1) {
$wgOut->addWikiText( wfMsg( 'rcnote', $wgLang->formatNum( $numRows ),
- $wgLang->formatNum( $days ) ) . '<br />' , false );
- elseif($days > 0)
+ $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();
+ $thisTitle = SpecialPage::getTitleFor( 'Watchlist' );
$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 );
+ $link = Linker::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 );
+ $link = Linker::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\">" . wfMsg( 'namespace' ) . "</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=\"" . wfMsgHtml( 'allpagessubmit' ) . "\" />\n";
- $nsForm .= "</form>\n";
- $wgOut->addHTML( $nsForm );
+ $wgOut->addHTML( "\n" .
+ wfOpenElement( 'form', array(
+ 'method' => 'post',
+ 'action' => $thisTitle->getLocalURL(),
+ ) ) .
+ wfMsgExt( 'namespace', array( 'parseinline') ) .
+ HTMLnamespaceselector( $nameSpace, '' ) . "\n" .
+ ( $hideOwn ? wfHidden('hideown', 1)."\n" : '' ) .
+ ( $hideBots ? wfHidden('hidebots', 1)."\n" : '' ) .
+ wfHidden( 'days', $days ) . "\n" .
+ wfSubmitButton( wfMsgExt( 'allpagessubmit', array( 'escape') ) ) . "\n" .
+ wfCloseElement( 'form' ) . "\n"
+ );
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 );
}
function wlHoursLink( $h, $page, $options = array() ) {
- global $wgUser, $wgLang, $wgContLang;
- $sk = $wgUser->getSkin();
- $s = $sk->makeKnownLink(
+ global $wgLang, $wgContLang;
+ $s = Linker::makeKnownLink(
$wgContLang->specialPage( $page ),
$wgLang->formatNum( $h ),
wfArrayToCGI( array('days' => ($h / 24.0)), $options ) );
}
function wlDaysLink( $d, $page, $options = array() ) {
- global $wgUser, $wgLang, $wgContLang;
- $sk = $wgUser->getSkin();
- $s = $sk->makeKnownLink(
+ global $wgLang, $wgContLang;
+ $s = Linker::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 );
foreach( $days as $d ) {
$days[$i++] = wlDaysLink( $d, $page, $options );
}
- return wfMsg ('wlshowlast',
+ return wfMsgExt('wlshowlast',
+ array('parseinline', 'replaceafter'),
implode(' | ', $hours),
implode(' | ', $days),
wlDaysLink( 0, $page, $options ) );
* code needs to do something further
*/
function wlHandleClear( &$out, &$request, $par ) {
+ global $wgLang;
+
# Check this function has something to do
if( $request->getText( 'action' ) == 'clear' || $par == 'clear' ) {
global $wgUser;
# 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->addWikiText( wfMsgExt( 'watchlistcleardone', array( 'parsemag', 'escape'), $wgLang->formatNum( $count ) ) );
$out->returnToMain();
} else {
# Confirming, so show a form
- $wlTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' );
+ $wlTitle = SpecialPage::getTitleFor( 'Watchlist' );
$out->addHTML( wfElement( 'form', array( 'method' => 'post', 'action' => $wlTitle->getLocalUrl( 'action=clear' ) ), NULL ) );
- $out->addWikiText( wfMsg( 'watchlistcount', $count ) );
+ $out->addWikiText( wfMsgExt( 'watchlistcount', array( 'parsemag', 'escape'), $wgLang->formatNum( $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' ) );
+ $out->addHTML(
+ wfHidden( 'token', $wgUser->editToken( 'clearwatchlist' ) ) .
+ wfElement( 'input', array( 'type' => 'submit', 'name' => 'submit', 'value' => wfMsgHtml( 'watchlistclearbutton' ) ), '' ) .
+ wfCloseElement( 'form' )
+ );
}
return( true );
} else {
return( false );
}
}
-
?>