jenkins-bot has submitted this change and it was merged. Change subject: Remove unused global and use context ......................................................................
Remove unused global and use context Also: - trailing whitespace was automatically removed for touched files. - update some docs Change-Id: I3969dc0f0523ae9f9fa3cf80dc9dcbd0e3448505 --- M specials/SpecialSemanticWatchlist.php M specials/SpecialWatchlistConditions.php 2 files changed, 124 insertions(+), 124 deletions(-) Approvals: Ckoerner: Looks good to me, but someone else must approve Mwjames: Looks good to me, but someone else must approve Jeroen De Dauw: Looks good to me, approved jenkins-bot: Verified diff --git a/specials/SpecialSemanticWatchlist.php b/specials/SpecialSemanticWatchlist.php index 7c13427..0b6d7ba 100644 --- a/specials/SpecialSemanticWatchlist.php +++ b/specials/SpecialSemanticWatchlist.php @@ -2,47 +2,47 @@ /** * Semantic watchlist page listing changes to watched properties. - * + * * @since 0.1 - * + * * @file SemanticWatchlist.php * @ingroup SemanticWatchlist - * + * * @licence GNU GPL v3 or later * @author Jeroen De Dauw < [email protected] > */ class SpecialSemanticWatchlist extends SpecialPage { - + /** * MediaWiki timestamp of when the watchlist was last viewed by the current user. - * + * * @since 0.1 - * + * * @var integer */ protected $lastViewed; - + /** * Constructor. - * + * * @since 0.1 */ public function __construct() { parent::__construct( 'SemanticWatchlist', 'semanticwatch' ); } - + /** * @see SpecialPage::getDescription - * + * * @since 0.1 */ public function getDescription() { - return wfMessage( 'special-' . strtolower( $this->getName() )->text() ); + return $this->msg( 'special-' . strtolower( $this->getName() )->text() ); } - + /** * Sets headers - this should be called from the execute() method of all derived classes! - * + * * @since 0.1 */ public function setHeaders() { @@ -50,39 +50,39 @@ $wgOut->setArticleRelated( false ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->setPageTitle( $this->getDescription() ); - } - + } + /** * Main method. - * + * * @since 0.1 - * - * @param string $arg + * + * @param string $subPage */ public function execute( $subPage ) { global $wgOut, $wgUser; - + $this->setHeaders(); $this->outputHeader(); - + // If the user is authorized, display the page, if not, show an error. if ( !$this->userCanExecute( $wgUser ) ) { $this->displayRestrictionError(); return; } - + $this->registerUserView( $wgUser ); - + $wgOut->addHTML( '<p>' ); - + if ( $wgUser->isAllowed( 'semanticwatchgroups' ) ) { $wgOut->addHTML( wfMsgExt( 'swl-watchlist-can-mod-groups', 'parseinline', 'Special:WatchlistConditions' ) . ' ' ); } - + if ( $this->userHasWatchlistGroups( $wgUser ) ) { $wgOut->addHTML( wfMsgExt( 'swl-watchlist-can-mod-prefs', 'parseinline', 'Special:Preferences#mw-prefsection-swl' ) ); $wgOut->addHTML( '</p>' ); - + $this->getAndDisplaySets( $subPage ); } else { @@ -90,36 +90,36 @@ $wgOut->addHTML( '</p>' ); } } - + /** * Obtains the change sets and displays them by calling displayWatchlist. * Also takes care of pagination and displaying appropriate message when there are no results. - * + * * @since 0.1 - * + * * @param string $subPage */ protected function getAndDisplaySets( $subPage ) { global $wgRequest, $wgOut, $wgLang; - + $limit = $wgRequest->getInt( 'limit', 20 ); $offset = $wgRequest->getInt( 'offset', 0 ); $continue = $wgRequest->getVal( 'continue' ); - + $changeSetData = $this->getChangeSetsData( $limit, $continue ); - + $sets = array(); - + foreach ( $changeSetData['sets'] as $set ) { $sets[] = SWLChangeSet::newFromArray( $set ); - } - + } + $newContinue = false; - + if ( array_key_exists( 'query-continue', $changeSetData ) ) { $newContinue = $changeSetData['query-continue']['semanticwatchlist']['swcontinue']; } - + if ( $offset != 0 || count( $sets ) > 0 ) { $wgOut->addHTML( '<p>' . wfMsgExt( 'swl-watchlist-position', @@ -127,50 +127,50 @@ $wgLang->formatNum( count( $sets ) ), $wgLang->formatNum( $offset + 1 ) ) . '</p>' ); - + $wgOut->addHTML( $this->getPagingControlHTML( $limit, $continue, $subPage, $newContinue, $offset ) ); } - + if ( count( $sets ) > 0 ) { $this->displayWatchlist( $sets ); } else { $wgOut->addWikiMsg( 'swl-watchlist-no-items' ); - } + } } - + /** * Register the user viewed the watchlist, * so we know that following chnages should * result into notification emails is desired. - * + * * @since 0.1 - * + * * @param User $user */ protected function registerUserView( User $user ) { $this->lastViewed = $user->getOption( 'swl_last_view' ); - + if ( is_null( $this->lastViewed ) ) { $this->lastViewed = wfTimestampNow(); } - + $user->setOption( 'swl_last_view', wfTimestampNow() ); $user->setOption( 'swl_mail_count',0 ); - $user->saveSettings(); + $user->saveSettings(); } - + /** * @since 0.1 - * + * * @return string */ protected function getPagingControlHTML( $limit, $currentContinue, $subPage, $newContinue, $offset ) { global $wgLang; - + $nextMsg = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $limit ); $firstMsg = wfMsgExt( 'swl-watchlist-firstn', array( 'parsemag', 'escape' ), $limit ); - + if ( $newContinue === false ) { $nextLink = $nextMsg; } @@ -189,16 +189,16 @@ $nextMsg ); } - + $limitLinks = array(); $limitLinkArgs = array(); - + if ( $currentContinue == '' ) { $firstLink = $firstMsg; } else { $limitLinkArgs['continue'] = $currentContinue; - + $firstLink = Html::element( 'a', array( @@ -206,15 +206,15 @@ 'title' => wfMsgExt( 'swl-watchlist-firstn-title', array( 'parsemag', 'escape' ), $limit ) ), $firstMsg - ); + ); } - + foreach ( array( 20, 50, 100, 250, 500 ) as $limitValue ) { $limitLinkArgs['limit'] = $limitValue; if ( $offset != 0 ) { $limitLinkArgs['offset'] = $offset; } - + $limitLinks[] = Html::element( 'a', array( @@ -224,67 +224,67 @@ $wgLang->formatNum( $limitValue ) ); } - + return Html::rawElement( 'p', array(), wfMsgHtml( 'swl-watchlist-pagincontrol', $wgLang->pipeList( array( $firstLink, $nextLink ) ), $wgLang->pipeList( $limitLinks ) ) ); } - + /** * Displays the watchlist. - * + * * @since 0.1 - * - * @param array of SWLChangeSet $sets + * + * @param array $sets Array of SWLChangeSet */ protected function displayWatchlist( array $sets ) { global $wgOut, $wgLang; - + $changeSetsHTML = array(); - + foreach ( $sets as /* SWLChangeSet */ $set ) { $dayKey = substr( $set->getEdit()->getTime(), 0, 8 ); // Get the YYYYMMDD part. - + if ( !array_key_exists( $dayKey, $changeSetsHTML ) ) { $changeSetsHTML[$dayKey] = array(); } - + $changeSetsHTML[$dayKey][] = $this->getChangeSetHTML( $set ); } - + krsort( $changeSetsHTML ); - + foreach ( $changeSetsHTML as $dayKey => $daySets ) { $wgOut->addHTML( Html::element( 'h4', array(), $wgLang->date( str_pad( $dayKey, 14, '0' ) ) ) ); - + $wgOut->addHTML( '<ul>' ); - + foreach ( $daySets as $setHTML ) { $wgOut->addHTML( $setHTML ); } - + $wgOut->addHTML( '</ul>' ); } - + SMWOutputs::commitToOutputPage( $wgOut ); - + $wgOut->addModules( 'ext.swl.watchlist' ); } - + /** * Returns the response of an internal request to the API semanticwatchlist query module. - * + * * @since 0.1 - * + * * @param integer $limit * @param string $continue - * + * * @return array */ protected function getChangeSetsData( $limit, $continue ) { @@ -297,31 +297,31 @@ 'swcontinue' => $continue, 'swmerge' => '1' ); - + $api = new ApiMain( new FauxRequest( $requestData, true ), true ); $api->execute(); return $api->getResultData(); } - + /** * Gets the HTML for a single change set (edit). - * + * * @since 0.1 - * + * * @param SWLChangeSet $changeSet - * + * * @return string */ protected function getChangeSetHTML( SWLChangeSet $changeSet ) { global $wgLang; - + $edit = $changeSet->getEdit(); - + $html = ''; - + $html .= '<li>'; - - $html .= + + $html .= '<p>' . $wgLang->time( $edit->getTime(), true ) . ' ' . Html::element( @@ -332,7 +332,7 @@ Html::element( 'a', array( 'href' => $edit->getTitle()->getLocalURL( 'action=history' ) ), - wfMessage( 'hist' )->text() + $this->msg( 'hist' )->text() ) . ') . . ' . Html::element( 'a', @@ -342,49 +342,49 @@ Html::element( 'a', array( 'href' => $edit->getUser()->getTalkPage()->getLocalURL() ), - wfMessage( 'talkpagelinktext' )->text() + $this->msg( 'talkpagelinktext' )->text() ) . ' | ' . ( $edit->getUser()->isAnon() ? '' : Html::element( 'a', array( 'href' => SpecialPage::getTitleFor( 'Contributions', $edit->getUser()->getName() )->getLocalURL() ), - wfMessage( 'contribslink' )->text() + $this->msg( 'contribslink' )->text() ) . ' | ' ) . Html::element( 'a', array( 'href' => SpecialPage::getTitleFor( 'Block', $edit->getUser()->getName() )->getLocalURL() ), - wfMessage( 'blocklink' )->text() + $this->msg( 'blocklink' )->text() ) . ')' . - ( $edit->getTime() > $this->lastViewed ? ' <b>' . wfMessage( 'swl-new-item' )->text() . '</b>' : '' ) . + ( $edit->getTime() > $this->lastViewed ? ' <b>' . $this->msg( 'swl-new-item' )->text() . '</b>' : '' ) . '</p>' ; - + $propertyHTML= array(); - + foreach ( $changeSet->getAllProperties() as /* SMWDIProperty */ $property ) { $propertyHTML[] = $this->getPropertyHTML( $property, $changeSet->getAllPropertyChanges( $property ) ); } - + $html .= implode( '', $propertyHTML ); - + $html .= '</li>'; - + return $html; } - + /** * Returns the HTML for the changes to a single propety. - * + * * @param SMWDIProperty $property - * @param array of SWLPropertyChange $changes - * + * @param array $changes Array of SWLPropertyChange + * * @return string */ protected function getPropertyHTML( SMWDIProperty $property, array $changes ) { $insertions = array(); $deletions = array(); - + // Convert the changes into a list of insertions and a list of deletions. foreach ( $changes as /* SWLPropertyChange */ $change ) { if ( !is_null( $change->getOldValue() ) ) { @@ -394,51 +394,51 @@ $insertions[] = SMWDataValueFactory::newDataItemValue( $change->getNewValue(), $property )->getLongHTMLText(); } } - + $lines = array(); - + if ( count( $deletions ) > 0 ) { - $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-deletions' ), wfMessage( 'swl-watchlist-deletions' )->text() ) . ' ' . implode( ', ', $deletions ); - } - - if ( count( $insertions ) > 0 ) { - $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-insertions' ), wfMessage( 'swl-watchlist-insertions' )->text() ) . ' ' . implode( ', ', $insertions ); + $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-deletions' ), $this->msg( 'swl-watchlist-deletions' )->text() ) . ' ' . implode( ', ', $deletions ); } - + + if ( count( $insertions ) > 0 ) { + $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-insertions' ), $this->msg( 'swl-watchlist-insertions' )->text() ) . ' ' . implode( ', ', $insertions ); + } + $html = Html::element( 'span', array( 'class' => 'swl-watchlist-prop' ), $property->getLabel() ); - + $html .= Html::rawElement( 'div', array( 'class' => 'swl-prop-div' ), implode( '<br />', $lines ) ); - + return $html; } - + /** * Rteurns if the specified user has any watchlist groups in his notification list. - * + * * @since 0.1 - * + * * @param User $user - * + * * @return boolean */ protected function userHasWatchlistGroups( User $user ) { if ( !$user->isLoggedIn() ) { return false; } - + $dbr = wfGetDB( DB_SLAVE ); - + $group = $dbr->selectRow( 'swl_users_per_group', array( 'upg_group_id' ), array( 'upg_user_id' => $user->getId() ) ); - + return $group !== false; } - + } diff --git a/specials/SpecialWatchlistConditions.php b/specials/SpecialWatchlistConditions.php index d5b1270..a7ff67a 100644 --- a/specials/SpecialWatchlistConditions.php +++ b/specials/SpecialWatchlistConditions.php @@ -28,7 +28,7 @@ * @since 0.1 */ public function getDescription() { - return wfMessage( 'special-' . strtolower( $this->getName() )->text() ); + return $this->msg( 'special-' . strtolower( $this->getName() )->text() ); } /** @@ -51,7 +51,7 @@ * @param string $arg */ public function execute( $arg ) { - global $wgOut, $wgUser, $wgRequest; + global $wgOut, $wgUser; $this->setHeaders(); $this->outputHeader(); @@ -63,7 +63,7 @@ } $wgOut->addHTML( - '<strong><p class="saveMessage" style=" display:none;width: 100px; alight:center;text-align:center; background: #f9f9aa; border: 1px solid #dd9">' . wfMessage( 'swl-group-saved' )->text() . '</p></strong>' + '<strong><p class="saveMessage" style=" display:none;width: 100px; alight:center;text-align:center; background: #f9f9aa; border: 1px solid #dd9">' . $this->msg( 'swl-group-saved' )->text() . '</p></strong>' ); $groupsHtml = array(); @@ -81,7 +81,7 @@ 'input', array( 'type' => 'button', - 'value' => wfMessage( 'swl-group-add-group' )->text(), + 'value' => $this->msg( 'swl-group-add-group' )->text(), 'id' => 'swl-add-group-button' ) ) . "</p>\n" ); @@ -90,7 +90,7 @@ 'input', array( 'type' => 'button', - 'value' => wfMessage( 'swl-group-save' )->text(), + 'value' => $this->msg( 'swl-group-save' )->text(), 'id' => 'swl-save-all' ) ) . "</p>\n" ); @@ -130,7 +130,7 @@ Html::element( 'legend', array(), - wfMessage( 'swl-group-legend' )->text() + $this->msg( 'swl-group-legend' )->text() ) ); } -- To view, visit https://gerrit.wikimedia.org/r/168224 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3969dc0f0523ae9f9fa3cf80dc9dcbd0e3448505 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/SemanticWatchlist Gerrit-Branch: master Gerrit-Owner: Siebrand <[email protected]> Gerrit-Reviewer: Ckoerner <[email protected]> Gerrit-Reviewer: Jeroen De Dauw <[email protected]> Gerrit-Reviewer: Mwjames <[email protected]> Gerrit-Reviewer: Nemo bis <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> Gerrit-Reviewer: Yaron Koren <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
