X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FInfoAction.php;h=5491f817b44d4bf3900df742c0eb5582e49caecd;hb=3a79a825d071855cfb8cb02246c7514434dfd9fe;hp=203c687eb435f5445a82ef156e5cfc1e7378b9a0;hpb=7f1df682b62457e267831ec6527ca4728723caef;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 203c687eb4..5491f817b4 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -234,7 +234,7 @@ class InfoAction extends FormlessAction { // Display title $displayTitle = $title->getPrefixedText(); - if ( !empty( $pageProperties['displaytitle'] ) ) { + if ( isset( $pageProperties['displaytitle'] ) ) { $displayTitle = $pageProperties['displaytitle']; } @@ -259,7 +259,7 @@ class InfoAction extends FormlessAction { // Default sort key $sortKey = $title->getCategorySortkey(); - if ( !empty( $pageProperties['defaultsort'] ) ) { + if ( isset( $pageProperties['defaultsort'] ) ) { $sortKey = $pageProperties['defaultsort']; } @@ -325,8 +325,27 @@ class InfoAction extends FormlessAction { ) { // Number of page watchers $pageInfo['header-basic'][] = array( - $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] ) + $this->msg( 'pageinfo-watchers' ), + $lang->formatNum( $pageCounts['watchers'] ) ); + if ( + $config->get( 'ShowUpdatedMarker' ) && + isset( $pageCounts['visitingWatchers'] ) + ) { + $minToDisclose = $config->get( 'UnwatchedPageSecret' ); + if ( $pageCounts['visitingWatchers'] > $minToDisclose || + $user->isAllowed( 'unwatchedpages' ) ) { + $pageInfo['header-basic'][] = array( + $this->msg( 'pageinfo-visiting-watchers' ), + $lang->formatNum( $pageCounts['visitingWatchers'] ) + ); + } else { + $pageInfo['header-basic'][] = array( + $this->msg( 'pageinfo-visiting-watchers' ), + $this->msg( 'pageinfo-few-visiting-watchers' ) + ); + } + } } elseif ( $unwatchedPageThreshold !== false ) { $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-watchers' ), @@ -448,7 +467,8 @@ class InfoAction extends FormlessAction { } } $expiry = $title->getRestrictionExpiry( $restrictionType ); - $formattedexpiry = $this->msg( 'parentheses', $this->getLanguage()->formatExpiry( $expiry ) )->escaped(); + $formattedexpiry = $this->msg( 'parentheses', + $this->getLanguage()->formatExpiry( $expiry ) )->escaped(); $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry; // Messages: restriction-edit, restriction-move, restriction-create, @@ -655,11 +675,11 @@ class InfoAction extends FormlessAction { $id = $title->getArticleID(); $config = $this->context->getConfig(); - $dbr = wfGetDB( DB_SLAVE ); + $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' ); $result = array(); // Number of page watchers - $watchers = (int)$dbr->selectField( + $watchers = (int)$dbrWatchlist->selectField( 'watchlist', 'COUNT(*)', array( @@ -670,6 +690,27 @@ class InfoAction extends FormlessAction { ); $result['watchers'] = $watchers; + if ( $config->get( 'ShowUpdatedMarker' ) ) { + // Threshold: last visited about 26 weeks before latest edit + $updated = wfTimestamp( TS_UNIX, $this->page->getTimestamp() ); + $age = $config->get( 'WatchersMaxAge' ); + $threshold = $dbrWatchlist->timestamp( $updated - $age ); + // Number of page watchers who also visited a "recent" edit + $visitingWatchers = (int)$dbrWatchlist->selectField( + 'watchlist', + 'COUNT(*)', + array( + 'wl_namespace' => $title->getNamespace(), + 'wl_title' => $title->getDBkey(), + 'wl_notificationtimestamp >= ' . $dbrWatchlist->addQuotes( $threshold ) . + ' OR wl_notificationtimestamp IS NULL' + ), + __METHOD__ + ); + $result['visitingWatchers'] = $visitingWatchers; + } + + $dbr = wfGetDB( DB_SLAVE ); // Total number of edits $edits = (int)$dbr->selectField( 'revision',