| Index: trunk/extensions/CollabWatchlist/CollabWatchlist.i18n.php |
| — | — | @@ -1,6 +1,6 @@ |
| 2 | 2 | <?php |
| 3 | 3 | $messages = array(); |
| 4 | | - |
| | 4 | + |
| 5 | 5 | $messages['en'] = array( |
| 6 | 6 | 'collabwatchlist' => 'Collaborative watchlist', |
| 7 | 7 | 'specialcollabwatchlist' => 'Collaborative watchlist special page', |
| Index: trunk/extensions/CollabWatchlist/CollabWatchlist.php |
| — | — | @@ -1,6 +1,6 @@ |
| 2 | 2 | <?php |
| 3 | 3 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
| 4 | | -if (!defined('MEDIAWIKI')) { |
| | 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | 5 | echo <<<EOT |
| 6 | 6 | To install the CollabWatchlist extension, put the following line in LocalSettings.php: |
| 7 | 7 | require_once( "\$IP/extensions/CollabWatchlist/CollabWatchlist.php" ); |
| — | — | @@ -11,16 +11,15 @@ |
| 12 | 12 | |
| 13 | 13 | $wgExtensionCredits['specialpage'][] = array( |
| 14 | 14 | 'name' => 'CollabWatchlist', |
| 15 | | - 'author' =>'Florian Hackenberger', |
| | 15 | + 'author' => 'Florian Hackenberger', |
| 16 | 16 | 'url' => 'http://www.mediawiki.org/wiki/User:Flohack', |
| 17 | 17 | 'description' => 'Provides collaborative watchlists based on categories', |
| 18 | 18 | 'descriptionmsg' => 'specialcollabwatchlist-desc', |
| 19 | 19 | 'version' => '0.9.0', |
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | | - |
| 23 | 22 | # Autoload our classes |
| 24 | | -$wgDir = dirname(__FILE__) . '/'; |
| | 23 | +$wgDir = dirname( __FILE__ ) . '/'; |
| 25 | 24 | $wgCollabWatchlistIncludes = $wgDir . 'includes/'; |
| 26 | 25 | $wgExtensionMessagesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.i18n.php'; |
| 27 | 26 | $wgExtensionAliasesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.alias.php'; |
| — | — | @@ -38,13 +37,13 @@ |
| 39 | 38 | |
| 40 | 39 | function fnCollabWatchlistDbSchema() { |
| 41 | 40 | global $wgExtNewTables; |
| 42 | | - $wgSql = dirname(__FILE__) . '/sql/'; |
| 43 | | - $wgExtNewTables[] = array('collabwatchlist', $wgSql . 'collabwatchlist.sql'); |
| 44 | | - $wgExtNewTables[] = array('collabwatchlistuser', $wgSql . 'collabwatchlistuser.sql'); |
| 45 | | - $wgExtNewTables[] = array('collabwatchlistcategory', $wgSql . 'collabwatchlistcategory.sql'); |
| 46 | | - $wgExtNewTables[] = array('collabwatchlistrevisiontag', $wgSql . 'collabwatchlistrevisiontag.sql'); |
| 47 | | - $wgExtNewTables[] = array('collabwatchlisttag', $wgSql . 'collabwatchlisttag.sql'); |
| 48 | | - $wgExtNewFields[] = array('change_tag', 'ct_id', $wgSql . 'patch-change_tag_id.sql'); |
| | 41 | + $wgSql = dirname( __FILE__ ) . '/sql/'; |
| | 42 | + $wgExtNewTables[] = array( 'collabwatchlist', $wgSql . 'collabwatchlist.sql' ); |
| | 43 | + $wgExtNewTables[] = array( 'collabwatchlistuser', $wgSql . 'collabwatchlistuser.sql' ); |
| | 44 | + $wgExtNewTables[] = array( 'collabwatchlistcategory', $wgSql . 'collabwatchlistcategory.sql' ); |
| | 45 | + $wgExtNewTables[] = array( 'collabwatchlistrevisiontag', $wgSql . 'collabwatchlistrevisiontag.sql' ); |
| | 46 | + $wgExtNewTables[] = array( 'collabwatchlisttag', $wgSql . 'collabwatchlisttag.sql' ); |
| | 47 | + $wgExtNewFields[] = array( 'change_tag', 'ct_id', $wgSql . 'patch-change_tag_id.sql' ); |
| 49 | 48 | return true; |
| 50 | 49 | } |
| 51 | 50 | |
| — | — | @@ -72,11 +71,11 @@ |
| 73 | 72 | define( 'COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT', 'TrustedEditor' ); // trusted editors are used to filter edits which don't require a review |
| 74 | 73 | |
| 75 | 74 | function fnCollabWatchlistUserTypeToText( $userType ) { |
| 76 | | - if( $userType === COLLABWATCHLISTUSER_OWNER ) |
| | 75 | + if ( $userType === COLLABWATCHLISTUSER_OWNER ) |
| 77 | 76 | return COLLABWATCHLISTUSER_OWNER_TEXT; |
| 78 | | - if( $userType === COLLABWATCHLISTUSER_USER ) |
| | 77 | + if ( $userType === COLLABWATCHLISTUSER_USER ) |
| 79 | 78 | return COLLABWATCHLISTUSER_USER_TEXT; |
| 80 | | - if( $userType === COLLABWATCHLISTUSER_TRUSTED_EDITOR ) |
| | 79 | + if ( $userType === COLLABWATCHLISTUSER_TRUSTED_EDITOR ) |
| 81 | 80 | return COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT; |
| 82 | 81 | } |
| 83 | 82 | /**#@-*/ |
| Index: trunk/extensions/CollabWatchlist/includes/SpecialCollabWatchlist.php |
| — | — | @@ -11,7 +11,7 @@ |
| 12 | 12 | |
| 13 | 13 | // Add feed links |
| 14 | 14 | $wlToken = $wgUser->getOption( 'watchlisttoken' ); |
| 15 | | - if (!$wlToken) { |
| | 15 | + if ( !$wlToken ) { |
| 16 | 16 | $wlToken = sha1( mt_rand() . microtime( true ) ); |
| 17 | 17 | $wgUser->setOption( 'watchlisttoken', $wlToken ); |
| 18 | 18 | $wgUser->saveSettings(); |
| — | — | @@ -20,9 +20,9 @@ |
| 21 | 21 | global $wgFeedClasses; |
| 22 | 22 | $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', |
| 23 | 23 | 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); |
| 24 | | - $feedTemplate = wfScript('api').'?'; |
| | 24 | + $feedTemplate = wfScript( 'api' ) . '?'; |
| 25 | 25 | |
| 26 | | - foreach( $wgFeedClasses as $format => $class ) { |
| | 26 | + foreach ( $wgFeedClasses as $format => $class ) { |
| 27 | 27 | $theseParams = $apiParams + array( 'feedformat' => $format ); |
| 28 | 28 | $url = $feedTemplate . wfArrayToCGI( $theseParams ); |
| 29 | 29 | $wgOut->addFeedLink( $format, $url ); |
| — | — | @@ -33,7 +33,7 @@ |
| 34 | 34 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 35 | 35 | |
| 36 | 36 | # Anons don't get a watchlist |
| 37 | | - if( $wgUser->isAnon() ) { |
| | 37 | + if ( $wgUser->isAnon() ) { |
| 38 | 38 | $wgOut->setPageTitle( wfMsg( 'watchnologin' ) ); |
| 39 | 39 | $llink = $skin->linkKnown( |
| 40 | 40 | SpecialPage::getTitleFor( 'Userlogin' ), |
| — | — | @@ -47,7 +47,7 @@ |
| 48 | 48 | |
| 49 | 49 | $wgOut->setPageTitle( wfMsg( 'collabwatchlist' ) ); |
| 50 | 50 | |
| 51 | | - $listIdsAndNames = CollabWatchlistChangesList::getCollabWatchlistIdAndName($wgUser->getId()); |
| | 51 | + $listIdsAndNames = CollabWatchlistChangesList::getCollabWatchlistIdAndName( $wgUser->getId() ); |
| 52 | 52 | $sub = wfMsgExt( |
| 53 | 53 | 'watchlistfor2', |
| 54 | 54 | array( 'parseinline', 'replaceafter' ), |
| — | — | @@ -62,14 +62,14 @@ |
| 63 | 63 | // The filter form has one checkbox for each tag, build an array |
| 64 | 64 | $postValues = $wgRequest->getValues(); |
| 65 | 65 | $tagFilter = array(); |
| 66 | | - foreach( $postValues as $key => $value ) { |
| 67 | | - if( stripos($key, 'collaborative-watchlist-filtertag-') === 0 ) { |
| | 66 | + foreach ( $postValues as $key => $value ) { |
| | 67 | + if ( stripos( $key, 'collaborative-watchlist-filtertag-' ) === 0 ) { |
| 68 | 68 | $tagFilter[] = $postValues[$key]; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | // Alternative syntax for requests from links (show / hide ...) |
| 72 | | - if( empty($tagFilter) ) { |
| 73 | | - $tagFilter = explode('|', $wgRequest->getVal('filterTags')); |
| | 72 | + if ( empty( $tagFilter ) ) { |
| | 73 | + $tagFilter = explode( '|', $wgRequest->getVal( 'filterTags' ) ); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $defaults = array( |
| — | — | @@ -84,11 +84,11 @@ |
| 85 | 85 | /* int */ 'collabwatchlist' => 0, |
| 86 | 86 | /* ? */ 'globalwatch' => 'all', |
| 87 | 87 | /* ? */ 'invert' => false, |
| 88 | | - /* ? */ 'invertTags'=> false, |
| 89 | | - /* ? */ 'filterTags'=> '', |
| | 88 | + /* ? */ 'invertTags' => false, |
| | 89 | + /* ? */ 'filterTags' => '', |
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | | - extract($defaults); |
| | 92 | + extract( $defaults ); |
| 93 | 93 | |
| 94 | 94 | # Extract variables from the request, falling back to user preferences or |
| 95 | 95 | # other default values if these don't exist |
| — | — | @@ -112,23 +112,23 @@ |
| 113 | 113 | $hideOwn = $wgRequest->getBool( 'hideOwn' , $prefs['hideown'] ); |
| 114 | 114 | $hideListUser = $wgRequest->getBool( 'hideListUser', $prefs['hidelistuser'] ); |
| 115 | 115 | $hidePatrolled = $wgRequest->getBool( 'hidePatrolled' , $prefs['hidepatrolled'] ); |
| 116 | | - $filterTags = implode('|', $tagFilter); |
| | 116 | + $filterTags = implode( '|', $tagFilter ); |
| 117 | 117 | $invertTags = $wgRequest->getBool( 'invertTags' , $prefs['invertTags'] ); |
| 118 | 118 | |
| 119 | 119 | # Get collabwatchlist value, if supplied, and prepare a WHERE fragment |
| 120 | 120 | $collabWatchlist = $wgRequest->getIntOrNull( 'collabwatchlist' ); |
| 121 | 121 | $invert = $wgRequest->getBool( 'invert' ); |
| 122 | | - if( !is_null( $collabWatchlist ) && $collabWatchlist !== 'all') { |
| | 122 | + if ( !is_null( $collabWatchlist ) && $collabWatchlist !== 'all' ) { |
| 123 | 123 | $collabWatchlist = intval( $collabWatchlist ); |
| 124 | 124 | } else { |
| 125 | 125 | $collabWatchlist = 0; |
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | | - if(array_key_exists($collabWatchlist, $listIdsAndNames)) { |
| 129 | | - $wgOut->addHTML( Xml::element('h2', null, $listIdsAndNames[$collabWatchlist]) ); |
| | 128 | + if ( array_key_exists( $collabWatchlist, $listIdsAndNames ) ) { |
| | 129 | + $wgOut->addHTML( Xml::element( 'h2', null, $listIdsAndNames[$collabWatchlist] ) ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | | - if( ( $mode = CollabWatchlistEditor::getMode( $wgRequest, $par ) ) !== false ) { |
| | 132 | + if ( ( $mode = CollabWatchlistEditor::getMode( $wgRequest, $par ) ) !== false ) { |
| 133 | 133 | $editor = new CollabWatchlistEditor(); |
| 134 | 134 | $editor->execute( $collabWatchlist, $listIdsAndNames, $wgOut, $wgRequest, $mode ); |
| 135 | 135 | return; |
| — | — | @@ -138,9 +138,9 @@ |
| 139 | 139 | $recentchanges = $dbr->tableName( 'recentchanges' ); |
| 140 | 140 | |
| 141 | 141 | $nitems = $dbr->selectField( 'collabwatchlistcategory', 'COUNT(*)', |
| 142 | | - $collabWatchlist == 0 ? array() : array('rl_id' => $collabWatchlist |
| | 142 | + $collabWatchlist == 0 ? array() : array( 'rl_id' => $collabWatchlist |
| 143 | 143 | ), __METHOD__ ); |
| 144 | | - if( $nitems == 0 ) { |
| | 144 | + if ( $nitems == 0 ) { |
| 145 | 145 | $wgOut->addWikiMsg( 'nowatchlist' ); |
| 146 | 146 | return; |
| 147 | 147 | } |
| — | — | @@ -148,23 +148,23 @@ |
| 149 | 149 | // Dump everything here |
| 150 | 150 | $nondefaults = array(); |
| 151 | 151 | |
| 152 | | - wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults); |
| | 152 | + wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults ); |
| 153 | 153 | wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); |
| 154 | | - wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults); |
| | 154 | + wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults ); |
| 155 | 155 | wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons, $defaults, $nondefaults ); |
| 156 | 156 | wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu , $defaults, $nondefaults ); |
| 157 | | - wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults); |
| 158 | | - wfAppendToArrayIfNotDefault( 'hideListUser', (int)$hideListUser, $defaults, $nondefaults); |
| 159 | | - wfAppendToArrayIfNotDefault( 'collabwatchlist', $collabWatchlist, $defaults, $nondefaults); |
| | 157 | + wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults ); |
| | 158 | + wfAppendToArrayIfNotDefault( 'hideListUser', (int)$hideListUser, $defaults, $nondefaults ); |
| | 159 | + wfAppendToArrayIfNotDefault( 'collabwatchlist', $collabWatchlist, $defaults, $nondefaults ); |
| 160 | 160 | wfAppendToArrayIfNotDefault( 'hidePatrolled', (int)$hidePatrolled, $defaults, $nondefaults ); |
| 161 | 161 | wfAppendToArrayIfNotDefault( 'filterTags', $filterTags , $defaults, $nondefaults ); |
| 162 | 162 | wfAppendToArrayIfNotDefault( 'invertTags', $invertTags , $defaults, $nondefaults ); |
| 163 | 163 | wfAppendToArrayIfNotDefault( 'invert', $invert , $defaults, $nondefaults ); |
| 164 | 164 | |
| 165 | | - if( $days <= 0 ) { |
| | 165 | + if ( $days <= 0 ) { |
| 166 | 166 | $andcutoff = ''; |
| 167 | 167 | } else { |
| 168 | | - $andcutoff = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'"; |
| | 168 | + $andcutoff = "rc_timestamp > '" . $dbr->timestamp( time() - intval( $days * 86400 ) ) . "'"; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | # If the watchlist is relatively short, it's simplest to zip |
| — | — | @@ -181,12 +181,12 @@ |
| 182 | 182 | $andHideMinor = $hideMinor ? "rc_minor = 0" : ''; |
| 183 | 183 | $andHideLiu = $hideLiu ? "rc_user = 0" : ''; |
| 184 | 184 | $andHideAnons = $hideAnons ? "rc_user != 0" : ''; |
| 185 | | - $andHideListUser = $hideListUser ? $this->wlGetFilterClauseListUser($collabWatchlist) : ''; |
| | 185 | + $andHideListUser = $hideListUser ? $this->wlGetFilterClauseListUser( $collabWatchlist ) : ''; |
| 186 | 186 | $andHidePatrolled = $wgUser->useRCPatrol() && $hidePatrolled ? "rc_patrolled != 1" : ''; |
| 187 | 187 | |
| 188 | 188 | # Toggle watchlist content (all recent edits or just the latest) |
| 189 | | - if( $wgUser->getOption( 'extendwatchlist' )) { |
| 190 | | - $andLatest=''; |
| | 189 | + if ( $wgUser->getOption( 'extendwatchlist' ) ) { |
| | 190 | + $andLatest = ''; |
| 191 | 191 | $limitWatchlist = intval( $wgUser->getOption( 'wllimit' ) ); |
| 192 | 192 | $usePage = false; |
| 193 | 193 | } else { |
| — | — | @@ -197,7 +197,7 @@ |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | # Show a message about slave lag, if applicable |
| 201 | | - if( ( $lag = $dbr->getLag() ) > 0 ) |
| | 201 | + if ( ( $lag = $dbr->getLag() ) > 0 ) |
| 202 | 202 | $wgOut->showLagWarning( $lag ); |
| 203 | 203 | |
| 204 | 204 | # Create output form |
| — | — | @@ -206,21 +206,21 @@ |
| 207 | 207 | # Show watchlist header |
| 208 | 208 | $form .= wfMsgExt( 'collabwatchlist-details', array( 'parseinline' ), $wgLang->formatNum( $nitems ) ); |
| 209 | 209 | |
| 210 | | - if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) { |
| | 210 | + if ( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) { |
| 211 | 211 | $form .= wfMsgExt( 'wlheader-enotif', 'parse' ) . "\n"; |
| 212 | 212 | } |
| 213 | 213 | $form .= '<hr />'; |
| 214 | 214 | |
| 215 | 215 | $tables = array( 'recentchanges', 'categorylinks' ); |
| 216 | 216 | $fields = array( "{$recentchanges}.*" ); |
| 217 | | - $categoryClause = $this->wlGetFilterClauseForCollabWatchlistIds($collabWatchlist, 'cl_to', 'rc_cur_id'); |
| | 217 | + $categoryClause = $this->wlGetFilterClauseForCollabWatchlistIds( $collabWatchlist, 'cl_to', 'rc_cur_id' ); |
| 218 | 218 | // If this collaborative watchlist does not contain any categories, add a clause which gives |
| 219 | 219 | // us an empty result |
| 220 | | - $conds = isset($categoryClause) ? array($categoryClause) : array('false'); |
| | 220 | + $conds = isset( $categoryClause ) ? array( $categoryClause ) : array( 'false' ); |
| 221 | 221 | $join_conds = array( |
| 222 | | - 'categorylinks' => array('LEFT OUTER JOIN', "rc_cur_id=cl_from"), |
| | 222 | + 'categorylinks' => array( 'LEFT OUTER JOIN', "rc_cur_id=cl_from" ), |
| 223 | 223 | ); |
| 224 | | - if( !empty($tagFilter) ) { |
| | 224 | + if ( !empty( $tagFilter ) ) { |
| 225 | 225 | // The tag filter causes a query runtime of O(MxN), where M is relative to the number |
| 226 | 226 | // of recentchanges we select (from a table which is purged periodically, limited to 250) |
| 227 | 227 | // and N is relative the number of change_tag entries for a recentchange. Doing it |
| — | — | @@ -230,7 +230,7 @@ |
| 231 | 231 | // find a common SQL compliant way for using regular expressions which works across Postgre / Mysql |
| 232 | 232 | // Furthermore, ChangeTags does not seem to prevent tags containing ',' from being set, |
| 233 | 233 | // which renders tag_summary quite unusable |
| 234 | | - if( $invertTags ) { |
| | 234 | + if ( $invertTags ) { |
| 235 | 235 | $filter = 'EXISTS '; |
| 236 | 236 | } else { |
| 237 | 237 | $filter = 'NOT EXISTS '; |
| — | — | @@ -238,36 +238,36 @@ |
| 239 | 239 | $filter .= '(select ct_rc_id from change_tag |
| 240 | 240 | JOIN collabwatchlistrevisiontag ON collabwatchlistrevisiontag.ct_id = change_tag.ct_id |
| 241 | 241 | WHERE ct_rc_id = recentchanges.rc_id AND ct_tag '; |
| 242 | | - if( count($tagFilter) > 1 ) |
| 243 | | - $filter .= 'IN (' . $dbr->makeList($tagFilter) . '))'; |
| | 242 | + if ( count( $tagFilter ) > 1 ) |
| | 243 | + $filter .= 'IN (' . $dbr->makeList( $tagFilter ) . '))'; |
| 244 | 244 | else |
| 245 | | - $filter .= ' = ' . $dbr->addQuotes(current($tagFilter)) . ')'; |
| | 245 | + $filter .= ' = ' . $dbr->addQuotes( current( $tagFilter ) ) . ')'; |
| 246 | 246 | $conds[] = $filter; |
| 247 | 247 | } |
| 248 | 248 | $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); |
| 249 | | - if( $limitWatchlist ) { |
| | 249 | + if ( $limitWatchlist ) { |
| 250 | 250 | $options['LIMIT'] = $limitWatchlist; |
| 251 | 251 | } |
| 252 | | - if( $andcutoff ) $conds[] = $andcutoff; |
| 253 | | - if( $andLatest ) $conds[] = $andLatest; |
| 254 | | - if( $andHideOwn ) $conds[] = $andHideOwn; |
| 255 | | - if( $andHideBots ) $conds[] = $andHideBots; |
| 256 | | - if( $andHideMinor ) $conds[] = $andHideMinor; |
| 257 | | - if( $andHideLiu ) $conds[] = $andHideLiu; |
| 258 | | - if( $andHideAnons ) $conds[] = $andHideAnons; |
| 259 | | - if( $andHideListUser ) $conds[] = $andHideListUser; |
| 260 | | - if( $andHidePatrolled ) $conds[] = $andHidePatrolled; |
| | 252 | + if ( $andcutoff ) $conds[] = $andcutoff; |
| | 253 | + if ( $andLatest ) $conds[] = $andLatest; |
| | 254 | + if ( $andHideOwn ) $conds[] = $andHideOwn; |
| | 255 | + if ( $andHideBots ) $conds[] = $andHideBots; |
| | 256 | + if ( $andHideMinor ) $conds[] = $andHideMinor; |
| | 257 | + if ( $andHideLiu ) $conds[] = $andHideLiu; |
| | 258 | + if ( $andHideAnons ) $conds[] = $andHideAnons; |
| | 259 | + if ( $andHideListUser ) $conds[] = $andHideListUser; |
| | 260 | + if ( $andHidePatrolled ) $conds[] = $andHidePatrolled; |
| 261 | 261 | |
| 262 | | - $rollbacker = $wgUser->isAllowed('rollback'); |
| | 262 | + $rollbacker = $wgUser->isAllowed( 'rollback' ); |
| 263 | 263 | if ( $usePage || $rollbacker ) { |
| 264 | 264 | $tables[] = 'page'; |
| 265 | | - $join_conds['page'] = array('LEFT JOIN','rc_cur_id=page.page_id'); |
| 266 | | - if ($rollbacker) |
| | 265 | + $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page.page_id' ); |
| | 266 | + if ( $rollbacker ) |
| 267 | 267 | $fields[] = 'page_latest'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' ); |
| 271 | | - wfRunHooks('SpecialCollabWatchlistQuery', array(&$conds,&$tables,&$join_conds,&$fields) ); |
| | 271 | + wfRunHooks( 'SpecialCollabWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields ) ); |
| 272 | 272 | |
| 273 | 273 | $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds ); |
| 274 | 274 | $numRows = $dbr->numRows( $res ); |
| — | — | @@ -275,7 +275,7 @@ |
| 276 | 276 | /* Start bottom header */ |
| 277 | 277 | |
| 278 | 278 | $wlInfo = ''; |
| 279 | | - if( $days >= 1 ) { |
| | 279 | + if ( $days >= 1 ) { |
| 280 | 280 | $wlInfo = wfMsgExt( 'rcnote', 'parseinline', |
| 281 | 281 | $wgLang->formatNum( $numRows ), |
| 282 | 282 | $wgLang->formatNum( $days ), |
| — | — | @@ -283,10 +283,10 @@ |
| 284 | 284 | $wgLang->date( wfTimestampNow(), true ), |
| 285 | 285 | $wgLang->time( wfTimestampNow(), true ) |
| 286 | 286 | ) . '<br />'; |
| 287 | | - } elseif( $days > 0 ) { |
| | 287 | + } elseif ( $days > 0 ) { |
| 288 | 288 | $wlInfo = wfMsgExt( 'wlnote', 'parseinline', |
| 289 | 289 | $wgLang->formatNum( $numRows ), |
| 290 | | - $wgLang->formatNum( round($days*24) ) |
| | 290 | + $wgLang->formatNum( round( $days * 24 ) ) |
| 291 | 291 | ) . '<br />'; |
| 292 | 292 | } |
| 293 | 293 | |
| — | — | @@ -302,7 +302,7 @@ |
| 303 | 303 | $links[] = $this->wlShowHideLink( $nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn ); |
| 304 | 304 | $links[] = $this->wlShowHideLink( $nondefaults, 'collabwatchlistshowhidelistusers', 'hideListUser', $hideListUser ); |
| 305 | 305 | |
| 306 | | - if( $wgUser->useRCPatrol() ) { |
| | 306 | + if ( $wgUser->useRCPatrol() ) { |
| 307 | 307 | $links[] = $this->wlShowHideLink( $nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled ); |
| 308 | 308 | } |
| 309 | 309 | |
| — | — | @@ -312,49 +312,49 @@ |
| 313 | 313 | $form .= $wgLang->pipeList( $links ); |
| 314 | 314 | $form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $thisTitle->getLocalUrl() ) ); |
| 315 | 315 | $form .= '<hr /><p>'; |
| 316 | | - $tagsAndInfo = CollabWatchlistChangesList::getValidTagsAndInfo(array_keys($listIdsAndNames)); |
| 317 | | - if(count($tagsAndInfo) > 0) { |
| 318 | | - $form .= wfMsg('collabwatchlistfiltertags') . ': '; |
| | 316 | + $tagsAndInfo = CollabWatchlistChangesList::getValidTagsAndInfo( array_keys( $listIdsAndNames ) ); |
| | 317 | + if ( count( $tagsAndInfo ) > 0 ) { |
| | 318 | + $form .= wfMsg( 'collabwatchlistfiltertags' ) . ': '; |
| 319 | 319 | } |
| 320 | | - foreach( $tagsAndInfo as $tag => $tagInfo ) { |
| | 320 | + foreach ( $tagsAndInfo as $tag => $tagInfo ) { |
| 321 | 321 | $tagAttr = array( |
| 322 | 322 | 'name' => 'collaborative-watchlist-filtertag-' . $tag, |
| 323 | 323 | 'type' => 'checkbox', |
| 324 | | - 'value' => $tag); |
| 325 | | - if (in_array($tag, $tagFilter) ) { |
| | 324 | + 'value' => $tag ); |
| | 325 | + if ( in_array( $tag, $tagFilter ) ) { |
| 326 | 326 | $tagAttr['checked'] = 'checked'; |
| 327 | 327 | } |
| 328 | | - $form .= Xml::element('input', $tagAttr) . ' ' . Xml::label( $tag, 'collaborative-watchlist-filtertag-' . $tag ) . ' '; |
| | 328 | + $form .= Xml::element( 'input', $tagAttr ) . ' ' . Xml::label( $tag, 'collaborative-watchlist-filtertag-' . $tag ) . ' '; |
| 329 | 329 | } |
| 330 | | - if(count($tagsAndInfo) > 0) { |
| | 330 | + if ( count( $tagsAndInfo ) > 0 ) { |
| 331 | 331 | $form .= '<br />'; |
| 332 | 332 | } |
| 333 | | - $form .= Xml::checkLabel( wfMsg('collabwatchlistinverttags'), 'invertTags', 'nsinvertTags', $invertTags ) . '<br />'; |
| 334 | | - $form .= CollabWatchlistChangesList::collabWatchlistSelector( $listIdsAndNames, $collabWatchlist, '', 'collabwatchlist', wfMsg( 'collabwatchlist' )) . ' '; |
| 335 | | - $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . ' '; |
| | 333 | + $form .= Xml::checkLabel( wfMsg( 'collabwatchlistinverttags' ), 'invertTags', 'nsinvertTags', $invertTags ) . '<br />'; |
| | 334 | + $form .= CollabWatchlistChangesList::collabWatchlistSelector( $listIdsAndNames, $collabWatchlist, '', 'collabwatchlist', wfMsg( 'collabwatchlist' ) ) . ' '; |
| | 335 | + $form .= Xml::checkLabel( wfMsg( 'invert' ), 'invert', 'nsinvert', $invert ) . ' '; |
| 336 | 336 | $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . '</p>'; |
| 337 | 337 | $form .= Html::hidden( 'days', $days ); |
| 338 | | - if( $hideMinor ) |
| | 338 | + if ( $hideMinor ) |
| 339 | 339 | $form .= Html::hidden( 'hideMinor', 1 ); |
| 340 | | - if( $hideBots ) |
| | 340 | + if ( $hideBots ) |
| 341 | 341 | $form .= Html::hidden( 'hideBots', 1 ); |
| 342 | | - if( $hideAnons ) |
| | 342 | + if ( $hideAnons ) |
| 343 | 343 | $form .= Html::hidden( 'hideAnons', 1 ); |
| 344 | | - if( $hideLiu ) |
| | 344 | + if ( $hideLiu ) |
| 345 | 345 | $form .= Html::hidden( 'hideLiu', 1 ); |
| 346 | | - if( $hideOwn ) |
| | 346 | + if ( $hideOwn ) |
| 347 | 347 | $form .= Html::hidden( 'hideOwn', 1 ); |
| 348 | | - if( $hideListUser ) |
| | 348 | + if ( $hideListUser ) |
| 349 | 349 | $form .= Html::hidden( 'hideListUser', 1 ); |
| 350 | | - if( $wgUser->useRCPatrol() ) |
| 351 | | - if( $hidePatrolled ) |
| 352 | | - $form .= Html::hidden( 'hidePatrolled', 1); |
| | 350 | + if ( $wgUser->useRCPatrol() ) |
| | 351 | + if ( $hidePatrolled ) |
| | 352 | + $form .= Html::hidden( 'hidePatrolled', 1 ); |
| 353 | 353 | $form .= Xml::closeElement( 'form' ); |
| 354 | 354 | $form .= Xml::closeElement( 'fieldset' ); |
| 355 | 355 | $wgOut->addHTML( $form ); |
| 356 | 356 | |
| 357 | 357 | # If there's nothing to show, stop here |
| 358 | | - if( $numRows == 0 ) { |
| | 358 | + if ( $numRows == 0 ) { |
| 359 | 359 | $wgOut->addWikiMsg( 'watchnochange' ); |
| 360 | 360 | return; |
| 361 | 361 | } |
| — | — | @@ -385,7 +385,7 @@ |
| 386 | 386 | $rc = RecentChange::newFromRow( $obj ); |
| 387 | 387 | $rc->counter = $counter++; |
| 388 | 388 | |
| 389 | | - if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) { |
| | 389 | + if ( $wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) { |
| 390 | 390 | $rc->numberofWatchingusers = $dbr->selectField( 'watchlist', |
| 391 | 391 | 'COUNT(*)', |
| 392 | 392 | array( |
| — | — | @@ -397,7 +397,7 @@ |
| 398 | 398 | $rc->numberofWatchingusers = 0; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | | - $tags = $this->wlTagsForRevision($obj->rc_this_oldid, array($collabWatchlist), $invert); |
| | 401 | + $tags = $this->wlTagsForRevision( $obj->rc_this_oldid, array( $collabWatchlist ), $invert ); |
| 402 | 402 | // if( isset($tags) ) { |
| 403 | 403 | // // Filter recentchanges which contain unwanted tags |
| 404 | 404 | // $tagNames = array(); |
| — | — | @@ -410,7 +410,7 @@ |
| 411 | 411 | // } |
| 412 | 412 | $attrs = $rc->getAttributes(); |
| 413 | 413 | $attrs['collabwatchlist_tags'] = $tags; |
| 414 | | - $rc->setAttribs($attrs); |
| | 414 | + $rc->setAttribs( $attrs ); |
| 415 | 415 | |
| 416 | 416 | $s .= $list->recentChangesLine( $rc, false, $counter ); |
| 417 | 417 | } |
| — | — | @@ -440,7 +440,7 @@ |
| 441 | 441 | |
| 442 | 442 | $sk = $wgUser->getSkin(); |
| 443 | 443 | $title = Title::newFromText( $wgContLang->specialPage( $page ) ); |
| 444 | | - $options['days'] = ($h / 24.0); |
| | 444 | + $options['days'] = ( $h / 24.0 ); |
| 445 | 445 | |
| 446 | 446 | $s = $sk->linkKnown( |
| 447 | 447 | $title, |
| — | — | @@ -458,7 +458,7 @@ |
| 459 | 459 | $sk = $wgUser->getSkin(); |
| 460 | 460 | $title = Title::newFromText( $wgContLang->specialPage( $page ) ); |
| 461 | 461 | $options['days'] = $d; |
| 462 | | - $message = ($d ? $wgLang->formatNum( $d ) : wfMsgHtml( 'watchlistall2' ) ); |
| | 462 | + $message = ( $d ? $wgLang->formatNum( $d ) : wfMsgHtml( 'watchlistall2' ) ); |
| 463 | 463 | |
| 464 | 464 | $s = $sk->linkKnown( |
| 465 | 465 | $title, |
| — | — | @@ -479,15 +479,15 @@ |
| 480 | 480 | $hours = array( 1, 2, 6, 12 ); |
| 481 | 481 | $days = array( 1, 3, 7 ); |
| 482 | 482 | $i = 0; |
| 483 | | - foreach( $hours as $h ) { |
| | 483 | + foreach ( $hours as $h ) { |
| 484 | 484 | $hours[$i++] = $this->wlHoursLink( $h, $page, $options ); |
| 485 | 485 | } |
| 486 | 486 | $i = 0; |
| 487 | | - foreach( $days as $d ) { |
| | 487 | + foreach ( $days as $d ) { |
| 488 | 488 | $days[$i++] = $this->wlDaysLink( $d, $page, $options ); |
| 489 | 489 | } |
| 490 | | - return wfMsgExt('wlshowlast', |
| 491 | | - array('parseinline', 'replaceafter'), |
| | 490 | + return wfMsgExt( 'wlshowlast', |
| | 491 | + array( 'parseinline', 'replaceafter' ), |
| 492 | 492 | $wgLang->pipeList( $hours ), |
| 493 | 493 | $wgLang->pipeList( $days ), |
| 494 | 494 | $this->wlDaysLink( 0, $page, $options ) ); |
| — | — | @@ -510,7 +510,7 @@ |
| 511 | 511 | $dbr->freeResult( $res ); |
| 512 | 512 | |
| 513 | 513 | # Halve to remove talk pages if needed |
| 514 | | - if( !$talk ) |
| | 514 | + if ( !$talk ) |
| 515 | 515 | $count = floor( $count / 2 ); |
| 516 | 516 | |
| 517 | 517 | return( $count ); |
| — | — | @@ -532,98 +532,98 @@ |
| 533 | 533 | // Some DB stuff |
| 534 | 534 | $dbr = wfGetDB( DB_SLAVE ); |
| 535 | 535 | $cond = array(); |
| 536 | | - if( isset($rl_ids) && !(count($rl_ids) == 1 && $rl_ids[0] == 0)) { |
| 537 | | - if( $invert ) { |
| 538 | | - $cond[] = "rl_id NOT IN (" . $dbr->makeList($rl_ids) . ")"; |
| 539 | | - }else { |
| 540 | | - $cond = array("rl_id" => $rl_ids); |
| | 536 | + if ( isset( $rl_ids ) && !( count( $rl_ids ) == 1 && $rl_ids[0] == 0 ) ) { |
| | 537 | + if ( $invert ) { |
| | 538 | + $cond[] = "rl_id NOT IN (" . $dbr->makeList( $rl_ids ) . ")"; |
| | 539 | + } else { |
| | 540 | + $cond = array( "rl_id" => $rl_ids ); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | | - if( isset($filterTags) && count($filterTags) > 0) { |
| 544 | | - $cond[] = "ct_tag not in (" . $dbr->makeList($filterTags) . ")"; |
| | 543 | + if ( isset( $filterTags ) && count( $filterTags ) > 0 ) { |
| | 544 | + $cond[] = "ct_tag not in (" . $dbr->makeList( $filterTags ) . ")"; |
| 545 | 545 | } |
| 546 | | - //$table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| 547 | | - $res = $dbr->select( array('change_tag', 'collabwatchlistrevisiontag', 'user'), # Tables |
| 548 | | - array('rl_id', 'ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment'), # Fields |
| 549 | | - array('ct_rev_id' => $rev_id) + $cond, # Conditions |
| | 546 | + // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| | 547 | + $res = $dbr->select( array( 'change_tag', 'collabwatchlistrevisiontag', 'user' ), # Tables |
| | 548 | + array( 'rl_id', 'ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment' ), # Fields |
| | 549 | + array( 'ct_rev_id' => $rev_id ) + $cond, # Conditions |
| 550 | 550 | __METHOD__, array(), |
| 551 | 551 | # Join conditions |
| 552 | | - array( 'collabwatchlistrevisiontag' => array('JOIN', 'change_tag.ct_id = collabwatchlistrevisiontag.ct_id'), |
| 553 | | - 'user' => array('JOIN', 'collabwatchlistrevisiontag.user_id = user.user_id') |
| | 552 | + array( 'collabwatchlistrevisiontag' => array( 'JOIN', 'change_tag.ct_id = collabwatchlistrevisiontag.ct_id' ), |
| | 553 | + 'user' => array( 'JOIN', 'collabwatchlistrevisiontag.user_id = user.user_id' ) |
| 554 | 554 | ) |
| 555 | 555 | ); |
| 556 | 556 | $tags = array(); |
| 557 | | - foreach( $res as $row ) { |
| | 557 | + foreach ( $res as $row ) { |
| 558 | 558 | $tags[] = get_object_vars( $row ); |
| 559 | 559 | } |
| 560 | 560 | return $tags; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | | - function wlGetFilterClauseForCollabWatchlistIds($rl_ids, $catNameCol, $pageIdCol) { |
| | 563 | + function wlGetFilterClauseForCollabWatchlistIds( $rl_ids, $catNameCol, $pageIdCol ) { |
| 564 | 564 | $excludedCatPageIds = array(); |
| 565 | 565 | $includedCatPageIds = array(); |
| 566 | 566 | $includedPageIds = array(); |
| 567 | 567 | $dbr = wfGetDB( DB_SLAVE ); |
| 568 | | - $res = $dbr->select( array('collabwatchlist', 'collabwatchlistcategory', 'page' ), # Tables |
| 569 | | - array('cat_page_id', 'page_title', 'page_namespace', 'subtract'), # Fields |
| 570 | | - $rl_ids != 0 ? array('collabwatchlist.rl_id' => $rl_ids) : array(), # Conditions |
| | 568 | + $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistcategory', 'page' ), # Tables |
| | 569 | + array( 'cat_page_id', 'page_title', 'page_namespace', 'subtract' ), # Fields |
| | 570 | + $rl_ids != 0 ? array( 'collabwatchlist.rl_id' => $rl_ids ) : array(), # Conditions |
| 571 | 571 | __METHOD__, array(), |
| 572 | 572 | # Join conditions |
| 573 | | - array( 'collabwatchlistcategory' => array('JOIN', 'collabwatchlist.rl_id = collabwatchlistcategory.rl_id'), |
| 574 | | - 'page' => array('JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id') ) |
| | 573 | + array( 'collabwatchlistcategory' => array( 'JOIN', 'collabwatchlist.rl_id = collabwatchlistcategory.rl_id' ), |
| | 574 | + 'page' => array( 'JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id' ) ) |
| 575 | 575 | ); |
| 576 | | - foreach( $res as $row ) { |
| 577 | | - if($row->page_namespace == NS_CATEGORY) { |
| 578 | | - if($row->subtract) { |
| | 576 | + foreach ( $res as $row ) { |
| | 577 | + if ( $row->page_namespace == NS_CATEGORY ) { |
| | 578 | + if ( $row->subtract ) { |
| 579 | 579 | $excludedCatPageIds[$row->cat_page_id] = $row->page_title; |
| 580 | | - }else { |
| | 580 | + } else { |
| 581 | 581 | $includedCatPageIds[$row->cat_page_id] = $row->page_title; |
| 582 | 582 | } |
| 583 | | - }else { |
| | 583 | + } else { |
| 584 | 584 | $includedPageIds[$row->cat_page_id] = $row->page_title; |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | | - if($includedCatPageIds) { |
| | 588 | + if ( $includedCatPageIds ) { |
| 589 | 589 | $catTree = new CategoryTreeManip(); |
| 590 | | - $catTree->initialiseFromCategoryNames(array_values($includedCatPageIds)); |
| 591 | | - $catTree->disableCategoryIds(array_keys($excludedCatPageIds)); |
| | 590 | + $catTree->initialiseFromCategoryNames( array_values( $includedCatPageIds ) ); |
| | 591 | + $catTree->disableCategoryIds( array_keys( $excludedCatPageIds ) ); |
| 592 | 592 | $enabledCategoryNames = $catTree->getEnabledCategoryNames(); |
| 593 | | - if(empty($enabledCategoryNames)) |
| | 593 | + if ( empty( $enabledCategoryNames ) ) |
| 594 | 594 | return; |
| 595 | | - $collabWatchlistClause = '(' . $catNameCol . " IN (" . implode(',', $this->addQuotes($dbr, $enabledCategoryNames)) . ") "; |
| 596 | | - if(!empty($includedPageIds)) { |
| 597 | | - $collabWatchlistClause .= ' OR ' . $pageIdCol . ' IN (' . implode(',', $this->addQuotes($dbr, array_keys($includedPageIds))) . ')'; |
| | 595 | + $collabWatchlistClause = '(' . $catNameCol . " IN (" . implode( ',', $this->addQuotes( $dbr, $enabledCategoryNames ) ) . ") "; |
| | 596 | + if ( !empty( $includedPageIds ) ) { |
| | 597 | + $collabWatchlistClause .= ' OR ' . $pageIdCol . ' IN (' . implode( ',', $this->addQuotes( $dbr, array_keys( $includedPageIds ) ) ) . ')'; |
| 598 | 598 | } |
| 599 | 599 | $collabWatchlistClause .= ')'; |
| 600 | | - }else if(!empty($includedPageIds)) { |
| 601 | | - $collabWatchlistClause = $pageIdCol . ' IN (' . implode(',', $this->addQuotes($dbr, array_keys($includedPageIds))) . ')'; |
| | 600 | + } else if ( !empty( $includedPageIds ) ) { |
| | 601 | + $collabWatchlistClause = $pageIdCol . ' IN (' . implode( ',', $this->addQuotes( $dbr, array_keys( $includedPageIds ) ) ) . ')'; |
| 602 | 602 | } |
| 603 | 603 | return $collabWatchlistClause; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | | - function wlGetFilterClauseListUser($rl_id) { |
| | 606 | + function wlGetFilterClauseListUser( $rl_id ) { |
| 607 | 607 | $excludedUserIds = array(); |
| 608 | 608 | $dbr = wfGetDB( DB_SLAVE ); |
| 609 | 609 | $res = $dbr->select( 'collabwatchlistuser', # Tables |
| 610 | 610 | 'user_id', # Fields |
| 611 | | - array('collabwatchlistuser.rl_id' => $rl_id) # Conditions |
| | 611 | + array( 'collabwatchlistuser.rl_id' => $rl_id ) # Conditions |
| 612 | 612 | ); |
| 613 | 613 | $clause = ''; |
| 614 | | - foreach( $res as $row ) { |
| | 614 | + foreach ( $res as $row ) { |
| 615 | 615 | $excludedUserIds[] = $row->user_id; |
| 616 | 616 | } |
| 617 | | - if($res->numRows() > 0) { |
| | 617 | + if ( $res->numRows() > 0 ) { |
| 618 | 618 | $clause = '( rc_user NOT IN ('; |
| 619 | | - $clause .= implode(',', $this->addQuotes($dbr, $excludedUserIds)) . ') )'; |
| | 619 | + $clause .= implode( ',', $this->addQuotes( $dbr, $excludedUserIds ) ) . ') )'; |
| 620 | 620 | } |
| 621 | 621 | return $clause; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | | - public static function addQuotes($db, $strings) { |
| | 624 | + public static function addQuotes( $db, $strings ) { |
| 625 | 625 | $result = array(); |
| 626 | | - foreach($strings as $string) { |
| 627 | | - $result[] = $db->addQuotes($string); |
| | 626 | + foreach ( $strings as $string ) { |
| | 627 | + $result[] = $db->addQuotes( $string ); |
| 628 | 628 | } |
| 629 | 629 | return $result; |
| 630 | 630 | } |
| Index: trunk/extensions/CollabWatchlist/includes/CategoryTreeManip.php |
| — | — | @@ -22,29 +22,29 @@ |
| 23 | 23 | /** |
| 24 | 24 | * Constructor |
| 25 | 25 | */ |
| 26 | | - function __construct($id = NULL, $name = NULL, $root = NULL, $parents = array()) { |
| | 26 | + function __construct( $id = NULL, $name = NULL, $root = NULL, $parents = array() ) { |
| 27 | 27 | $this->id = $id; |
| 28 | 28 | $this->name = $name; |
| 29 | | - if(!is_null($root)) { |
| | 29 | + if ( !is_null( $root ) ) { |
| 30 | 30 | $this->root = $root; |
| 31 | | - }else { |
| | 31 | + } else { |
| 32 | 32 | $this->root = $this; |
| 33 | 33 | } |
| 34 | 34 | $this->parents = $parents; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | | - private function addChildren($children) { |
| 38 | | - if(!is_array($children)) |
| 39 | | - throw new Exception('Argument must be an array'); |
| 40 | | - foreach($children as $child) { |
| | 37 | + private function addChildren( $children ) { |
| | 38 | + if ( !is_array( $children ) ) |
| | 39 | + throw new Exception( 'Argument must be an array' ); |
| | 40 | + foreach ( $children as $child ) { |
| 41 | 41 | $this->children[$child->id] = $child; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | | - private function addParents($parents) { |
| 46 | | - if(!is_array($parents)) |
| 47 | | - throw new Exception('Argument must be an array'); |
| 48 | | - foreach($parents as $parent) { |
| | 45 | + private function addParents( $parents ) { |
| | 46 | + if ( !is_array( $parents ) ) |
| | 47 | + throw new Exception( 'Argument must be an array' ); |
| | 48 | + foreach ( $parents as $parent ) { |
| 49 | 49 | $this->parents[$parent->id] = $parent; |
| 50 | 50 | } |
| 51 | 51 | } |
| — | — | @@ -60,22 +60,22 @@ |
| 61 | 61 | * |
| 62 | 62 | * @param array $catPageIds The page ids of the categories to disable |
| 63 | 63 | */ |
| 64 | | - public function disableCategoryIds($catPageIds) { |
| 65 | | - foreach($catPageIds as $catId) { |
| 66 | | - $node = $this->getNodeForCatPageId($catId); |
| 67 | | - if(isset($node)) { |
| | 64 | + public function disableCategoryIds( $catPageIds ) { |
| | 65 | + foreach ( $catPageIds as $catId ) { |
| | 66 | + $node = $this->getNodeForCatPageId( $catId ); |
| | 67 | + if ( isset( $node ) ) { |
| 68 | 68 | $node->disable(); |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | | - private function recursiveDisable($visitedNodeIds = array()) { |
| 74 | | - if(!$this->enabled || array_key_exists($this->id, $visitedNodeIds)) |
| | 73 | + private function recursiveDisable( $visitedNodeIds = array() ) { |
| | 74 | + if ( !$this->enabled || array_key_exists( $this->id, $visitedNodeIds ) ) |
| 75 | 75 | return; # Break the recursion |
| 76 | 76 | $this->enabled = false; |
| 77 | 77 | $visitedNodeIds[] = $this->id; |
| 78 | | - foreach($this->children as $cat) { |
| 79 | | - $cat->recursiveDisable($visitedNodeIds); |
| | 78 | + foreach ( $this->children as $cat ) { |
| | 79 | + $cat->recursiveDisable( $visitedNodeIds ); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| — | — | @@ -87,7 +87,7 @@ |
| 88 | 88 | public function getEnabledCategoryNames() { |
| 89 | 89 | $enabledNodes = $this->getEnabledNodeMap(); |
| 90 | 90 | $enabledCategories = array(); |
| 91 | | - foreach($enabledNodes as $nodeId => $node) { |
| | 91 | + foreach ( $enabledNodes as $nodeId => $node ) { |
| 92 | 92 | $enabledCategories[] = $node->name; |
| 93 | 93 | } |
| 94 | 94 | return $enabledCategories; |
| — | — | @@ -102,14 +102,14 @@ |
| 103 | 103 | return $this->root->recursiveGetEnabledNodeMap(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | | - private function recursiveGetEnabledNodeMap(&$foundNodes = array()) { |
| 107 | | - if(isset($this->id)) { |
| 108 | | - if(!$this->enabled || array_key_exists($this->id, $foundNodes)) |
| | 106 | + private function recursiveGetEnabledNodeMap( &$foundNodes = array() ) { |
| | 107 | + if ( isset( $this->id ) ) { |
| | 108 | + if ( !$this->enabled || array_key_exists( $this->id, $foundNodes ) ) |
| 109 | 109 | return $foundNodes; # Break the recursion |
| 110 | 110 | $foundNodes[$this->id] = $this; |
| 111 | 111 | } |
| 112 | | - foreach($this->children as $cat) { |
| 113 | | - $cat->recursiveGetEnabledNodeMap($foundNodes); |
| | 112 | + foreach ( $this->children as $cat ) { |
| | 113 | + $cat->recursiveGetEnabledNodeMap( $foundNodes ); |
| 114 | 114 | } |
| 115 | 115 | return $foundNodes; |
| 116 | 116 | } |
| — | — | @@ -119,12 +119,12 @@ |
| 120 | 120 | * @param $catPageId The page id of the category to retrieve |
| 121 | 121 | * @return CategoryTreeManip The node |
| 122 | 122 | */ |
| 123 | | - public function getNodeForCatPageId($catPageId) { |
| 124 | | - if(array_key_exists($catPageId, $this->root->catPageIdToNode)) |
| | 123 | + public function getNodeForCatPageId( $catPageId ) { |
| | 124 | + if ( array_key_exists( $catPageId, $this->root->catPageIdToNode ) ) |
| 125 | 125 | return $this->root->catPageIdToNode[$catPageId]; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | | - private function addNode($node) { |
| | 128 | + private function addNode( $node ) { |
| 129 | 129 | $this->root->catPageIdToNode[$node->id] = $node; |
| 130 | 130 | } |
| 131 | 131 | |
| — | — | @@ -134,41 +134,41 @@ |
| 135 | 135 | * @param array $catNames An array of strings representing category names |
| 136 | 136 | * @return |
| 137 | 137 | */ |
| 138 | | - public function initialiseFromCategoryNames($catNames) { |
| | 138 | + public function initialiseFromCategoryNames( $catNames ) { |
| 139 | 139 | $dbr = wfGetDB( DB_SLAVE ); |
| 140 | | - while($catNames) { |
| 141 | | - $res = $dbr->select( array('categorylinks', 'page' ), # Tables |
| 142 | | - array('cl_to AS parName', 'cl_from AS childId', 'page_title AS childName'), # Fields |
| 143 | | - array('cl_to' => $catNames, 'page_namespace' => NS_CATEGORY), # Conditions |
| | 140 | + while ( $catNames ) { |
| | 141 | + $res = $dbr->select( array( 'categorylinks', 'page' ), # Tables |
| | 142 | + array( 'cl_to AS parName', 'cl_from AS childId', 'page_title AS childName' ), # Fields |
| | 143 | + array( 'cl_to' => $catNames, 'page_namespace' => NS_CATEGORY ), # Conditions |
| 144 | 144 | __METHOD__, array(), |
| 145 | 145 | # Join conditions |
| 146 | | - array('page' => array('JOIN', 'page_id = cl_from') ) |
| | 146 | + array( 'page' => array( 'JOIN', 'page_id = cl_from' ) ) |
| 147 | 147 | ); |
| 148 | 148 | $parentList = array(); |
| 149 | 149 | $childList = array(); |
| 150 | | - foreach( $res as $row ) { |
| 151 | | - $parentList[$row->parName][] = array($row->childId, $row->childName); |
| 152 | | - if(array_key_exists($row->childId, $childList)) { |
| | 150 | + foreach ( $res as $row ) { |
| | 151 | + $parentList[$row->parName][] = array( $row->childId, $row->childName ); |
| | 152 | + if ( array_key_exists( $row->childId, $childList ) ) { |
| 153 | 153 | $childEntry = $childList[$row->childId]; |
| 154 | 154 | $childEntry[1][] = $row->parName; |
| 155 | | - }else { |
| 156 | | - $childList[$row->childId] = array($row->childName, array($row->parName)); |
| | 155 | + } else { |
| | 156 | + $childList[$row->childId] = array( $row->childName, array( $row->parName ) ); |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | | - if(!isset($parentNameToNode) && !empty($parentList)) { |
| | 160 | + if ( !isset( $parentNameToNode ) && !empty( $parentList ) ) { |
| 161 | 161 | // Fetch the page ids of the $catNames and add the parent categories if needed |
| 162 | | - $res = $dbr->select( array('page' ), # Tables |
| 163 | | - array('page_id, page_title'), # Fields |
| 164 | | - array('page_title' => array_keys($parentList)) # Conditions |
| | 162 | + $res = $dbr->select( array( 'page' ), # Tables |
| | 163 | + array( 'page_id, page_title' ), # Fields |
| | 164 | + array( 'page_title' => array_keys( $parentList ) ) # Conditions |
| 165 | 165 | ); |
| 166 | 166 | $parentNameToNode = array(); |
| 167 | | - foreach( $res as $row ) { |
| 168 | | - $node = $this->getNodeForCatPageId($row->page_id); |
| 169 | | - if(!isset($node)) { |
| 170 | | - $node = new CategoryTreeManip($row->page_id, $row->page_title, $this->root); |
| 171 | | - $this->addNode($node); |
| 172 | | - $this->addChildren(array($node)); |
| | 167 | + foreach ( $res as $row ) { |
| | 168 | + $node = $this->getNodeForCatPageId( $row->page_id ); |
| | 169 | + if ( !isset( $node ) ) { |
| | 170 | + $node = new CategoryTreeManip( $row->page_id, $row->page_title, $this->root ); |
| | 171 | + $this->addNode( $node ); |
| | 172 | + $this->addChildren( array( $node ) ); |
| 173 | 173 | } |
| 174 | 174 | $parentNameToNode[$row->page_title] = $node; |
| 175 | 175 | } |
| — | — | @@ -176,23 +176,23 @@ |
| 177 | 177 | |
| 178 | 178 | $newChildNameToNode = array(); |
| 179 | 179 | // Add the new child nodes |
| 180 | | - foreach($childList as $childPageId => $childInfo) { |
| 181 | | - $childNode = $this->getNodeForCatPageId($childPageId); |
| 182 | | - if(!isset($childNode)) { |
| 183 | | - $childNode = new CategoryTreeManip($childPageId, $childInfo[0], $this->root); |
| 184 | | - $this->addNode($childNode); |
| | 180 | + foreach ( $childList as $childPageId => $childInfo ) { |
| | 181 | + $childNode = $this->getNodeForCatPageId( $childPageId ); |
| | 182 | + if ( !isset( $childNode ) ) { |
| | 183 | + $childNode = new CategoryTreeManip( $childPageId, $childInfo[0], $this->root ); |
| | 184 | + $this->addNode( $childNode ); |
| 185 | 185 | $newChildNameToNode[$childInfo[0]] = $childNode; |
| 186 | 186 | } |
| 187 | | - foreach($childInfo[1] as $parentName) { |
| | 187 | + foreach ( $childInfo[1] as $parentName ) { |
| 188 | 188 | $parent = $parentNameToNode[$parentName]; |
| 189 | | - $parent->addChildren(array($childNode)); |
| 190 | | - $childNode->addParents(array($parent)); |
| | 189 | + $parent->addChildren( array( $childNode ) ); |
| | 190 | + $childNode->addParents( array( $parent ) ); |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Prepare for the next loop |
| 195 | 195 | $parentNameToNode = $newChildNameToNode; |
| 196 | | - $catNames = array_keys($parentNameToNode); |
| | 196 | + $catNames = array_keys( $parentNameToNode ); |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
| Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistChangesList.php |
| — | — | @@ -12,7 +12,7 @@ |
| 13 | 13 | * @param Skin $skin |
| 14 | 14 | */ |
| 15 | 15 | public function __construct( $skin, $user ) { |
| 16 | | - parent::__construct($skin); |
| | 16 | + parent::__construct( $skin ); |
| 17 | 17 | $this->user = $user; |
| 18 | 18 | } |
| 19 | 19 | |
| — | — | @@ -23,11 +23,11 @@ |
| 24 | 24 | public function beginRecentChangesList() { |
| 25 | 25 | global $wgRequest; |
| 26 | 26 | $gwlSpeciaPageTitle = SpecialPage::getTitleFor( 'CollabWatchlist' ); |
| 27 | | - $result = Xml::openElement('form', array( |
| | 27 | + $result = Xml::openElement( 'form', array( |
| 28 | 28 | 'class' => 'mw-collaborative-watchlist-addtag-form', |
| 29 | 29 | 'method' => 'post', |
| 30 | | - 'action' => $gwlSpeciaPageTitle->getLocalUrl( array( 'action' => 'setTags' )))); |
| 31 | | - $result .= Xml::input('redirTarget', false, $wgRequest->getFullRequestURL(), array('type' => 'hidden')); |
| | 30 | + 'action' => $gwlSpeciaPageTitle->getLocalUrl( array( 'action' => 'setTags' ) ) ) ); |
| | 31 | + $result .= Xml::input( 'redirTarget', false, $wgRequest->getFullRequestURL(), array( 'type' => 'hidden' ) ); |
| 32 | 32 | $result .= parent::beginRecentChangesList(); |
| 33 | 33 | return $result; |
| 34 | 34 | } |
| — | — | @@ -41,13 +41,13 @@ |
| 42 | 42 | $collabWatchlist = $wgRequest->getIntOrNull( 'collabwatchlist' ); |
| 43 | 43 | $result = ''; |
| 44 | 44 | $result .= parent::endRecentChangesList(); |
| 45 | | - $glWlIdAndName = $this->getCollabWatchlistIdAndName($this->user->getId()); |
| 46 | | - $result .= $this->collabWatchlistAndTagSelectors($glWlIdAndName, $collabWatchlist, null, 'collabwatchlist', wfMsg( 'collabwatchlist' )) . ' '; |
| 47 | | - $result .= Xml::label( wfMsg('collabwatchlisttagcomment'), 'tagcomment' ) . ' ' . Xml::input( 'tagcomment' ) . ' '; |
| 48 | | - if( $this->user->useRCPatrol() ) |
| 49 | | - $result .= Xml::checkLabel( wfMsg('collabwatchlistpatrol'), 'setpatrolled', 'setpatrolled', true ) . ' '; |
| 50 | | - $result .= Xml::submitButton(wfMsg( 'collabwatchlistsettagbutton' )); |
| 51 | | - $result .= Xml::closeElement('form'); |
| | 45 | + $glWlIdAndName = $this->getCollabWatchlistIdAndName( $this->user->getId() ); |
| | 46 | + $result .= $this->collabWatchlistAndTagSelectors( $glWlIdAndName, $collabWatchlist, null, 'collabwatchlist', wfMsg( 'collabwatchlist' ) ) . ' '; |
| | 47 | + $result .= Xml::label( wfMsg( 'collabwatchlisttagcomment' ), 'tagcomment' ) . ' ' . Xml::input( 'tagcomment' ) . ' '; |
| | 48 | + if ( $this->user->useRCPatrol() ) |
| | 49 | + $result .= Xml::checkLabel( wfMsg( 'collabwatchlistpatrol' ), 'setpatrolled', 'setpatrolled', true ) . ' '; |
| | 50 | + $result .= Xml::submitButton( wfMsg( 'collabwatchlistsettagbutton' ) ); |
| | 51 | + $result .= Xml::closeElement( 'form' ); |
| 52 | 52 | return $result; |
| 53 | 53 | } |
| 54 | 54 | |
| — | — | @@ -56,10 +56,10 @@ |
| 57 | 57 | * @see includes/EnhancedChangesList#insertBeforeRCFlags($r, $rcObj) |
| 58 | 58 | */ |
| 59 | 59 | protected function insertBeforeRCFlags( &$r, &$rcObj ) { |
| 60 | | - $r .= Xml::element('input', array( |
| | 60 | + $r .= Xml::element( 'input', array( |
| 61 | 61 | 'name' => 'collaborative-watchlist-addtag-' . $this->tagCheckboxIndex, |
| 62 | 62 | 'type' => 'checkbox', |
| 63 | | - 'value' => ($rcObj->getTitle() . '|' . $rcObj->getAttribute('rc_this_oldid') . '|' . $rcObj->getAttribute('rc_id')))); |
| | 63 | + 'value' => ( $rcObj->getTitle() . '|' . $rcObj->getAttribute( 'rc_this_oldid' ) . '|' . $rcObj->getAttribute( 'rc_id' ) ) ) ); |
| 64 | 64 | $this->tagCheckboxIndex++; |
| 65 | 65 | } |
| 66 | 66 | |
| — | — | @@ -68,10 +68,10 @@ |
| 69 | 69 | * @see includes/EnhancedChangesList#insertBeforeRCFlagsBlock($r, $block) |
| 70 | 70 | */ |
| 71 | 71 | protected function insertBeforeRCFlagsBlock( &$r, &$block ) { |
| 72 | | - $r .= Xml::element('input', array( |
| | 72 | + $r .= Xml::element( 'input', array( |
| 73 | 73 | 'name' => 'collaborative-watchlist-addtag-placeholder', |
| 74 | 74 | 'type' => 'checkbox', |
| 75 | | - 'style' => 'visibility: hidden;')); |
| | 75 | + 'style' => 'visibility: hidden;' ) ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| — | — | @@ -80,9 +80,9 @@ |
| 81 | 81 | */ |
| 82 | 82 | public function insertRollback( &$s, &$rc ) { |
| 83 | 83 | global $wgUser; |
| 84 | | - parent::insertRollback($s, $rc); |
| 85 | | - if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) { |
| 86 | | - if ($wgUser->isAllowed('edit') ) { |
| | 84 | + parent::insertRollback( $s, $rc ); |
| | 85 | + if ( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) { |
| | 86 | + if ( $wgUser->isAllowed( 'edit' ) ) { |
| 87 | 87 | $rev = new Revision( array( |
| 88 | 88 | 'id' => $rc->mAttribs['rc_this_oldid'], |
| 89 | 89 | 'user' => $rc->mAttribs['rc_user'], |
| — | — | @@ -90,8 +90,8 @@ |
| 91 | 91 | 'deleted' => $rc->mAttribs['rc_deleted'] |
| 92 | 92 | ) ); |
| 93 | 93 | $undoAfter = $rev->getPrevious(); |
| 94 | | - $undoLink = $this->generateUndoLink($this->skin, $rc->getTitle(), $rev, $undoAfter); |
| 95 | | - if( isset($undoLink) ) |
| | 94 | + $undoLink = $this->generateUndoLink( $this->skin, $rc->getTitle(), $rev, $undoAfter ); |
| | 95 | + if ( isset( $undoLink ) ) |
| 96 | 96 | $s .= ' ' . $undoLink; |
| 97 | 97 | } |
| 98 | 98 | } |
| — | — | @@ -107,7 +107,7 @@ |
| 108 | 108 | public static function newFromUser( &$user ) { |
| 109 | 109 | $sk = $user->getSkin(); |
| 110 | 110 | $list = NULL; |
| 111 | | - if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { |
| | 111 | + if ( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { |
| 112 | 112 | return new CollabWatchlistChangesList( $sk, $user ); |
| 113 | 113 | } else { |
| 114 | 114 | return $list; |
| — | — | @@ -119,8 +119,8 @@ |
| 120 | 120 | * @see includes/ChangesList#insertTags($s, $rc, $classes) |
| 121 | 121 | */ |
| 122 | 122 | public function insertTags( &$s, &$rc, &$classes ) { |
| 123 | | - if ( !empty($rc->mAttribs['collabwatchlist_tags']) ) { |
| 124 | | - list($tagSummary, $newClasses) = $this->formatReviewSummaryRow( $rc, 'changeslist' ); |
| | 123 | + if ( !empty( $rc->mAttribs['collabwatchlist_tags'] ) ) { |
| | 124 | + list( $tagSummary, $newClasses ) = $this->formatReviewSummaryRow( $rc, 'changeslist' ); |
| 125 | 125 | $classes = array_merge( $classes, $newClasses ); |
| 126 | 126 | $s .= ' ' . $tagSummary; |
| 127 | 127 | } |
| — | — | @@ -158,7 +158,7 @@ |
| 159 | 159 | private function formatReviewSummaryRow( $rc, $page ) { |
| 160 | 160 | global $wgRequest; |
| 161 | 161 | $s = ''; |
| 162 | | - if( !$rc ) |
| | 162 | + if ( !$rc ) |
| 163 | 163 | return $s; |
| 164 | 164 | |
| 165 | 165 | $attr = $rc->mAttribs; |
| — | — | @@ -167,13 +167,13 @@ |
| 168 | 168 | $classes = array(); |
| 169 | 169 | |
| 170 | 170 | $displayTags = array(); |
| 171 | | - foreach( $tagRows as $tagRow ) { |
| | 171 | + foreach ( $tagRows as $tagRow ) { |
| 172 | 172 | $tag = $tagRow['ct_tag']; |
| 173 | 173 | $collabwatchlistTag = Xml::tags( |
| 174 | 174 | 'span', |
| 175 | 175 | array( 'class' => 'mw-collabwatchlist-tag-marker ' . |
| 176 | 176 | Sanitizer::escapeClass( "mw-collabwatchlist-tag-marker-$tag" ), |
| 177 | | - 'title' => $tagRow['rrt_comment']), |
| | 177 | + 'title' => $tagRow['rrt_comment'] ), |
| 178 | 178 | ChangeTags::tagDescription( $tag ) |
| 179 | 179 | ); |
| 180 | 180 | $classes[] = Sanitizer::escapeClass( "mw-collabwatchlist-tag-$tag" ); |
| — | — | @@ -181,7 +181,7 @@ |
| 182 | 182 | /** Insert links to user page, user talk page and eventually a blocking link */ |
| 183 | 183 | $userLink = $this->skin->userLink( $tagRow['user_id'], $tagRow['user_name'] ); |
| 184 | 184 | $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl( $wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['rl_id'], $tag, $attr['rc_id'] ); |
| 185 | | - $delTagLink = Xml::element('a', array('href' => $delTagTarget, 'class' => 'mw-collabwatchlist-unsettag-' . $tag), wfMsg('collabwatchlist-unset-tag')); |
| | 185 | + $delTagLink = Xml::element( 'a', array( 'href' => $delTagTarget, 'class' => 'mw-collabwatchlist-unsettag-' . $tag ), wfMsg( 'collabwatchlist-unset-tag' ) ); |
| 186 | 186 | $displayTags[] = $collabwatchlistTag . ' ' . $delTagLink . ' ' . $userLink; |
| 187 | 187 | } |
| 188 | 188 | $markers = '(' . implode( ', ', $displayTags ) . ')'; |
| — | — | @@ -199,12 +199,12 @@ |
| 200 | 200 | * @param String $tagLabel The label for the tag selector |
| 201 | 201 | * @return A string containing HTML |
| 202 | 202 | */ |
| 203 | | - public static function collabWatchlistAndTagSelectors($glWlIdAndName, $selected = '', $all = null, $element_name = 'collabwatchlist', $rlLabel = null, $rlElementId = 'collabwatchlist', $tagLabel = null) { |
| | 203 | + public static function collabWatchlistAndTagSelectors( $glWlIdAndName, $selected = '', $all = null, $element_name = 'collabwatchlist', $rlLabel = null, $rlElementId = 'collabwatchlist', $tagLabel = null ) { |
| 204 | 204 | global $wgJsMimeType; |
| 205 | 205 | $tagElementIdBase = 'mw-collaborative-watchlist-addtag-selector'; |
| 206 | | - $ret = self::collabWatchlistSelector($glWlIdAndName, $selected, $all, $element_name, $rlLabel, $rlElementId, $tagElementIdBase); |
| | 206 | + $ret = self::collabWatchlistSelector( $glWlIdAndName, $selected, $all, $element_name, $rlLabel, $rlElementId, $tagElementIdBase ); |
| 207 | 207 | $ret .= ' '; |
| 208 | | - $ret .= self::tagSelector(array_keys($glWlIdAndName), $tagLabel); |
| | 208 | + $ret .= self::tagSelector( array_keys( $glWlIdAndName ), $tagLabel ); |
| 209 | 209 | // Make sure the correct tags for the default selection are set |
| 210 | 210 | $ret .= Xml::element( 'script', |
| 211 | 211 | array( |
| — | — | @@ -232,7 +232,7 @@ |
| 233 | 233 | public static function collabWatchlistSelector( $glWlIdAndName, $selected = '', $all = null, $element_name = 'collabwatchlist', $label = null, $element_id = 'collabwatchlist', $tagElementIdBase = null ) { |
| 234 | 234 | global $wgScriptPath, $wgJsMimeType; |
| 235 | 235 | $ret = ''; |
| 236 | | - if(isset($tagElementIdBase)) { |
| | 236 | + if ( isset( $tagElementIdBase ) ) { |
| 237 | 237 | $jsPath = "$wgScriptPath/extensions/CollabWatchlist/js"; |
| 238 | 238 | $ret .= Xml::element( 'script', |
| 239 | 239 | array( |
| — | — | @@ -248,26 +248,26 @@ |
| 249 | 249 | // as strings since PHP is such a shithole. |
| 250 | 250 | // But we also don't want blanks and nulls and "all"s matching 0, |
| 251 | 251 | // so let's convert *just* string ints to clean ints. |
| 252 | | - if( preg_match( '/^\d+$/', $selected ) ) { |
| | 252 | + if ( preg_match( '/^\d+$/', $selected ) ) { |
| 253 | 253 | $selected = intval( $selected ); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | | - if( !is_null( $all ) ) |
| | 256 | + if ( !is_null( $all ) ) |
| 257 | 257 | $glWlIdAndName = array( $all => wfMsg( 'collabwatchlistsall' ) ) + $glWlIdAndName; |
| 258 | | - foreach( $glWlIdAndName as $index => $name ) { |
| 259 | | - if( $index < NS_MAIN ) |
| | 258 | + foreach ( $glWlIdAndName as $index => $name ) { |
| | 259 | + if ( $index < NS_MAIN ) |
| 260 | 260 | continue; |
| 261 | | - if( $index === 0 ) |
| | 261 | + if ( $index === 0 ) |
| 262 | 262 | $name = wfMsg( 'blankcollabwatchlist' ); |
| 263 | | - $options[] = Xml::option( $name, $index, $index === $selected, isset($tagElementIdBase) ? |
| 264 | | - array('onclick' => 'onCollabWatchlistSelection("' . $tagElementIdBase . '", this.value)') : |
| | 263 | + $options[] = Xml::option( $name, $index, $index === $selected, isset( $tagElementIdBase ) ? |
| | 264 | + array( 'onclick' => 'onCollabWatchlistSelection("' . $tagElementIdBase . '", this.value)' ) : |
| 265 | 265 | array() |
| 266 | 266 | ); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $selectorHtml = Xml::openElement( 'select', array( |
| 270 | 270 | 'id' => $element_id, 'name' => $element_name, |
| 271 | | - 'class' => 'collabwatchlistselector', )) |
| | 271 | + 'class' => 'collabwatchlistselector', ) ) |
| 272 | 272 | . "\n" |
| 273 | 273 | . implode( "\n", $options ) |
| 274 | 274 | . "\n" |
| — | — | @@ -290,39 +290,39 @@ |
| 291 | 291 | */ |
| 292 | 292 | public static function tagSelector( $rlIds, $label = '', $elemId = 'mw-collaborative-watchlist-addtag-selector' ) { |
| 293 | 293 | global $wgContLang; |
| 294 | | - $tagsAndInfo = CollabWatchlistChangesList::getValidTagsAndInfo($rlIds); |
| | 294 | + $tagsAndInfo = CollabWatchlistChangesList::getValidTagsAndInfo( $rlIds ); |
| 295 | 295 | $optionsAll = array(); |
| 296 | 296 | $options = array(); |
| 297 | | - foreach( $tagsAndInfo as $tagName => $info ) { |
| | 297 | + foreach ( $tagsAndInfo as $tagName => $info ) { |
| 298 | 298 | $optionsAll[] = Xml::option( $tagName . ' ' . $info['rt_description'], $tagName ); |
| 299 | | - foreach( $info['rl_ids'] as $rlId ) { |
| | 299 | + foreach ( $info['rl_ids'] as $rlId ) { |
| 300 | 300 | $options[$rlId][] = Xml::option( $tagName, $tagName ); |
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | $ret = Xml::openElement( 'select', array( |
| 304 | 304 | 'id' => $elemId, |
| 305 | 305 | 'name' => 'collabwatchlisttag', |
| 306 | | - 'class' => 'mw-collaborative-watchlist-tag-selector')) . |
| 307 | | - implode("\n", $optionsAll) . |
| 308 | | - Xml::closeElement('select'); |
| | 306 | + 'class' => 'mw-collaborative-watchlist-tag-selector' ) ) . |
| | 307 | + implode( "\n", $optionsAll ) . |
| | 308 | + Xml::closeElement( 'select' ); |
| 309 | 309 | if ( !is_null( $label ) ) { |
| 310 | 310 | $ret = Xml::label( $label, $elemId ) . ' ' . $ret; |
| 311 | 311 | } |
| 312 | | - foreach( $options as $rlId => $optionsRl) { |
| | 312 | + foreach ( $options as $rlId => $optionsRl ) { |
| 313 | 313 | $ret .= Xml::openElement( 'select', array( |
| 314 | 314 | 'style' => 'display: none;', |
| 315 | 315 | 'id' => $elemId . '-' . $rlId, |
| 316 | 316 | 'name' => 'collabwatchlisttag-rl', |
| 317 | | - 'class' => 'mw-collaborative-watchlist-tag-selector')) . |
| 318 | | - implode("\n", $optionsRl) . |
| 319 | | - Xml::closeElement('select'); |
| | 317 | + 'class' => 'mw-collaborative-watchlist-tag-selector' ) ) . |
| | 318 | + implode( "\n", $optionsRl ) . |
| | 319 | + Xml::closeElement( 'select' ); |
| 320 | 320 | } |
| 321 | 321 | $ret .= Xml::openElement( 'select', array( |
| 322 | 322 | 'style' => 'display: none;', |
| 323 | 323 | 'id' => $elemId . '-empty', |
| 324 | 324 | 'name' => 'collabwatchlisttag-rl', |
| 325 | | - 'class' => 'mw-collaborative-watchlist-tag-selector')) . |
| 326 | | - Xml::closeElement('select'); |
| | 325 | + 'class' => 'mw-collaborative-watchlist-tag-selector' ) ) . |
| | 326 | + Xml::closeElement( 'select' ); |
| 327 | 327 | |
| 328 | 328 | return $ret; |
| 329 | 329 | } |
| — | — | @@ -336,52 +336,52 @@ |
| 337 | 337 | * @return array Mapping from tag name to info |
| 338 | 338 | */ |
| 339 | 339 | public static function getValidTagsAndInfo( $rlIds ) { |
| 340 | | - if(!isset($rlIds) || empty($rlIds)) { |
| | 340 | + if ( !isset( $rlIds ) || empty( $rlIds ) ) { |
| 341 | 341 | return array(); |
| 342 | 342 | } |
| 343 | 343 | $dbr = wfGetDB( DB_SLAVE ); |
| 344 | | - $res = $dbr->select( array('collabwatchlisttag' ), # Tables |
| 345 | | - array('rt_name', 'rt_description', 'rl_id'), # Fields |
| 346 | | - array('rl_id' => $rlIds), # Conditions |
| | 344 | + $res = $dbr->select( array( 'collabwatchlisttag' ), # Tables |
| | 345 | + array( 'rt_name', 'rt_description', 'rl_id' ), # Fields |
| | 346 | + array( 'rl_id' => $rlIds ), # Conditions |
| 347 | 347 | __METHOD__ |
| 348 | 348 | ); |
| 349 | 349 | $list = array(); |
| 350 | | - foreach( $res as $row ) { |
| 351 | | - if(array_key_exists($row->rt_name, $list)) { |
| | 350 | + foreach ( $res as $row ) { |
| | 351 | + if ( array_key_exists( $row->rt_name, $list ) ) { |
| 352 | 352 | $list[$row->rt_name]['rl_ids'][] = $row->rl_id; |
| 353 | 353 | } else { |
| 354 | | - $list[$row->rt_name] = array('rt_description' => $row->rt_description, 'rl_ids' => array($row->rl_id)); |
| | 354 | + $list[$row->rt_name] = array( 'rt_description' => $row->rt_description, 'rl_ids' => array( $row->rl_id ) ); |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | return $list; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | | - //XXX Cache the result of this method in this class |
| | 360 | + // XXX Cache the result of this method in this class |
| 361 | 361 | /** Get an array mapping from collab watchlist id to its name, filtering by member type |
| 362 | 362 | * The method return only collab watchlist the given user is a member of, restricted by the allowed member types |
| 363 | 363 | * @param int $user_id The id of the collab watchlist user |
| 364 | 364 | * @param array $member_types A list of allowed membership types |
| 365 | 365 | * @return array Mapping from collab watchlist id to its name |
| 366 | 366 | */ |
| 367 | | - public static function getCollabWatchlistIdAndName( $user_id, $member_types = array(COLLABWATCHLISTUSER_OWNER, COLLABWATCHLISTUSER_USER) ) { |
| | 367 | + public static function getCollabWatchlistIdAndName( $user_id, $member_types = array( COLLABWATCHLISTUSER_OWNER, COLLABWATCHLISTUSER_USER ) ) { |
| 368 | 368 | global $wgDBprefix; |
| 369 | 369 | $dbr = wfGetDB( DB_SLAVE ); |
| 370 | 370 | $list = array(); |
| 371 | | - //$table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| 372 | | - $res = $dbr->select( array('collabwatchlist', 'collabwatchlistuser' ), # Tables |
| 373 | | - array($wgDBprefix . 'collabwatchlist.rl_id', 'rl_name'), # Fields |
| 374 | | - array('rlu_type' => $member_types, $wgDBprefix . 'collabwatchlistuser.user_id' => $user_id), # Conditions |
| | 371 | + // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| | 372 | + $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistuser' ), # Tables |
| | 373 | + array( $wgDBprefix . 'collabwatchlist.rl_id', 'rl_name' ), # Fields |
| | 374 | + array( 'rlu_type' => $member_types, $wgDBprefix . 'collabwatchlistuser.user_id' => $user_id ), # Conditions |
| 375 | 375 | __METHOD__, array(), |
| 376 | 376 | # Join conditions |
| 377 | | - array( 'collabwatchlistuser' => array('JOIN', $wgDBprefix . 'collabwatchlist.rl_id = ' . $wgDBprefix . 'collabwatchlistuser.rl_id') ) |
| | 377 | + array( 'collabwatchlistuser' => array( 'JOIN', $wgDBprefix . 'collabwatchlist.rl_id = ' . $wgDBprefix . 'collabwatchlistuser.rl_id' ) ) |
| 378 | 378 | ); |
| 379 | | - foreach( $res as $row ) { |
| | 379 | + foreach ( $res as $row ) { |
| 380 | 380 | $list[$row->rl_id] = $row->rl_name; |
| 381 | 381 | } |
| 382 | 382 | return $list; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | | - //XXX Copied from HistoryPage, we should patch HistoryPage to export that functionality |
| | 385 | + // XXX Copied from HistoryPage, we should patch HistoryPage to export that functionality |
| 386 | 386 | // as a static function |
| 387 | 387 | /** |
| 388 | 388 | * @param Skin $skin |
| — | — | @@ -390,8 +390,8 @@ |
| 391 | 391 | * @param Revision $undoAfterRevision |
| 392 | 392 | * @return String Undo Link |
| 393 | 393 | */ |
| 394 | | - public static function generateUndoLink($skin, $title, $revision, $undoAfterRevision) { |
| 395 | | - if( ! $revision instanceof Revision || ! $undoAfterRevision instanceof Revision || |
| | 394 | + public static function generateUndoLink( $skin, $title, $revision, $undoAfterRevision ) { |
| | 395 | + if ( ! $revision instanceof Revision || ! $undoAfterRevision instanceof Revision || |
| 396 | 396 | ! $title instanceof Title || !$skin instanceof Skin ) |
| 397 | 397 | return null; |
| 398 | 398 | # Create undo tooltip for the first (=latest) line only |
| Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistEditor.php |
| — | — | @@ -34,16 +34,16 @@ |
| 35 | 35 | */ |
| 36 | 36 | public function execute( $rlId, $listIdsAndNames, $output, $request, $mode ) { |
| 37 | 37 | global $wgUser, $wgCollabWatchlistPermissionDeniedPage; |
| 38 | | - if( wfReadOnly() ) { |
| | 38 | + if ( wfReadOnly() ) { |
| 39 | 39 | $output->readOnlyPage(); |
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | | - if( ($mode === self::EDIT_CLEAR || |
| | 42 | + if ( ( $mode === self::EDIT_CLEAR || |
| 43 | 43 | $mode === self::CATEGORIES_EDIT_RAW || |
| 44 | 44 | $mode === self::USERS_EDIT_RAW || |
| 45 | 45 | $mode === self::EDIT_NORMAL || |
| 46 | 46 | $mode === self::TAGS_EDIT_RAW || |
| 47 | | - $mode === self::DELETE_LIST) && (!isset($rlId) || $rlId === 0) ) { |
| | 47 | + $mode === self::DELETE_LIST ) && ( !isset( $rlId ) || $rlId === 0 ) ) { |
| 48 | 48 | $thisTitle = SpecialPage::getTitleFor( 'CollabWatchlist' ); |
| 49 | 49 | $output->redirect( $thisTitle->getLocalURL() ); |
| 50 | 50 | return; |
| — | — | @@ -55,25 +55,25 @@ |
| 56 | 56 | // Pass on to the raw editor, from which it's very easy to clear. |
| 57 | 57 | case self::CATEGORIES_EDIT_RAW: |
| 58 | 58 | $output->setPageTitle( $listIdsAndNames[$rlId] . ' ' . wfMsg( 'collabwatchlistedit-raw-title' ) ); |
| 59 | | - if( $request->wasPosted() ) { |
| 60 | | - if( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| | 59 | + if ( $request->wasPosted() ) { |
| | 60 | + if ( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| 61 | 61 | $output->redirect( $permissionDeniedTarget ); |
| 62 | 62 | break; |
| 63 | 63 | } |
| 64 | 64 | $wanted = $this->extractCollabWatchlistCategories( $request->getText( 'titles' ) ); |
| 65 | 65 | $current = $this->getCollabWatchlistCategories( $rlId ); |
| 66 | | - if( count( $wanted ) > 0 ) { |
| | 66 | + if ( count( $wanted ) > 0 ) { |
| 67 | 67 | $toWatch = array_diff( $wanted, $current ); |
| 68 | 68 | $toUnwatch = array_diff( $current, $wanted ); |
| 69 | 69 | $toWatch = $this->watchTitles( $toWatch, $rlId ); |
| 70 | 70 | $this->unwatchTitles( $toUnwatch, $rlId ); |
| 71 | | - if( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) |
| | 71 | + if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) |
| 72 | 72 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-raw-done', 'parse' ) ); |
| 73 | | - if( ( $count = count( $toWatch ) ) > 0 ) { |
| | 73 | + if ( ( $count = count( $toWatch ) ) > 0 ) { |
| 74 | 74 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-raw-added', 'parse', $count ) ); |
| 75 | 75 | $this->showTitles( $toWatch, $output, $wgUser->getSkin() ); |
| 76 | 76 | } |
| 77 | | - if( ( $count = count( $toUnwatch ) ) > 0 ) { |
| | 77 | + if ( ( $count = count( $toUnwatch ) ) > 0 ) { |
| 78 | 78 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-raw-removed', 'parse', $count ) ); |
| 79 | 79 | $this->showTitles( $toUnwatch, $output, $wgUser->getSkin() ); |
| 80 | 80 | } |
| — | — | @@ -87,36 +87,36 @@ |
| 88 | 88 | break; |
| 89 | 89 | case self::USERS_EDIT_RAW: |
| 90 | 90 | $output->setPageTitle( $listIdsAndNames[$rlId] . ' ' . wfMsg( 'collabwatchlistedit-users-raw-title' ) ); |
| 91 | | - if( $request->wasPosted() ) { |
| 92 | | - if( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| | 91 | + if ( $request->wasPosted() ) { |
| | 92 | + if ( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| 93 | 93 | $output->redirect( $permissionDeniedTarget ); |
| 94 | 94 | break; |
| 95 | 95 | } |
| 96 | 96 | $wanted = $this->extractCollabWatchlistUsers( $request->getText( 'titles' ) ); |
| 97 | 97 | $current = $this->getCollabWatchlistUsers( $rlId ); |
| 98 | | - $isOwnerCb = create_function('$a', 'return stripos($a, "' . COLLABWATCHLISTUSER_OWNER_TEXT . ' ' . '") === 0;'); |
| 99 | | - $wantedOwners = array_filter($wanted, $isOwnerCb); |
| 100 | | - if( count( $wantedOwners ) < 1 ) { |
| | 98 | + $isOwnerCb = create_function( '$a', 'return stripos($a, "' . COLLABWATCHLISTUSER_OWNER_TEXT . ' ' . '") === 0;' ); |
| | 99 | + $wantedOwners = array_filter( $wanted, $isOwnerCb ); |
| | 100 | + if ( count( $wantedOwners ) < 1 ) { |
| 101 | 101 | // Make sure there is at least one owner left |
| 102 | | - $currentOwners = array_filter($current, $isOwnerCb); |
| 103 | | - $reAddedOwner = current($currentOwners); |
| | 102 | + $currentOwners = array_filter( $current, $isOwnerCb ); |
| | 103 | + $reAddedOwner = current( $currentOwners ); |
| 104 | 104 | $wanted[] = $reAddedOwner; |
| 105 | | - list($type, $typeText, $titleText) = $this->extractTypeTypeTextAndUsername( $reAddedOwner ); |
| | 105 | + list( $type, $typeText, $titleText ) = $this->extractTypeTypeTextAndUsername( $reAddedOwner ); |
| 106 | 106 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-users-last-owner', 'parse' ) ); |
| 107 | | - $this->showTitles( array($titleText), $output, $wgUser->getSkin() ); |
| | 107 | + $this->showTitles( array( $titleText ), $output, $wgUser->getSkin() ); |
| 108 | 108 | } |
| 109 | | - if( count( $wanted ) > 0 ) { |
| | 109 | + if ( count( $wanted ) > 0 ) { |
| 110 | 110 | $toAdd = array_diff( $wanted, $current ); |
| 111 | 111 | $toDel = array_diff( $current, $wanted ); |
| 112 | 112 | $toAdd = $this->addUsers( $toAdd, $rlId ); |
| 113 | 113 | $this->delUsers( $toDel, $rlId ); |
| 114 | | - if( count( $toAdd ) > 0 || count( $toDel ) > 0 ) |
| | 114 | + if ( count( $toAdd ) > 0 || count( $toDel ) > 0 ) |
| 115 | 115 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-users-raw-done', 'parse' ) ); |
| 116 | | - if( ( $count = count( $toAdd ) ) > 0 ) { |
| | 116 | + if ( ( $count = count( $toAdd ) ) > 0 ) { |
| 117 | 117 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-users-raw-added', 'parse', $count ) ); |
| 118 | 118 | $this->showTitles( $toAdd, $output, $wgUser->getSkin() ); |
| 119 | 119 | } |
| 120 | | - if( ( $count = count( $toDel ) ) > 0 ) { |
| | 120 | + if ( ( $count = count( $toDel ) ) > 0 ) { |
| 121 | 121 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-users-raw-removed', 'parse', $count ) ); |
| 122 | 122 | $this->showTitles( $toDel, $output, $wgUser->getSkin() ); |
| 123 | 123 | } |
| — | — | @@ -130,25 +130,25 @@ |
| 131 | 131 | break; |
| 132 | 132 | case self::TAGS_EDIT_RAW: |
| 133 | 133 | $output->setPageTitle( $listIdsAndNames[$rlId] . ' ' . wfMsg( 'collabwatchlistedit-tags-raw-title' ) ); |
| 134 | | - if( $request->wasPosted() ) { |
| 135 | | - if( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| | 134 | + if ( $request->wasPosted() ) { |
| | 135 | + if ( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| 136 | 136 | $output->redirect( $permissionDeniedTarget ); |
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | 139 | $wanted = $this->extractCollabWatchlistTags( $request->getText( 'titles' ) ); |
| 140 | 140 | $current = $this->getCollabWatchlistTags( $rlId ); |
| 141 | | - if( count( $wanted ) > 0 ) { |
| | 141 | + if ( count( $wanted ) > 0 ) { |
| 142 | 142 | $newTags = array_diff_assoc( $wanted, $current ); |
| 143 | 143 | $removeTags = array_diff_assoc( $current, $wanted ); |
| 144 | | - $this->removeTags( array_keys($removeTags), $rlId ); |
| | 144 | + $this->removeTags( array_keys( $removeTags ), $rlId ); |
| 145 | 145 | $this->addTags( $newTags, $rlId ); |
| 146 | | - if( count( $newTags ) > 0 || count( $removeTags ) > 0 ) |
| | 146 | + if ( count( $newTags ) > 0 || count( $removeTags ) > 0 ) |
| 147 | 147 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-tags-raw-done', 'parse' ) ); |
| 148 | | - if( ( $count = count( $newTags ) ) > 0 ) { |
| | 148 | + if ( ( $count = count( $newTags ) ) > 0 ) { |
| 149 | 149 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-tags-raw-added', 'parse', $count ) ); |
| 150 | 150 | $this->showTagList( $newTags, $output, $wgUser->getSkin() ); |
| 151 | 151 | } |
| 152 | | - if( ( $count = count( $removeTags ) ) > 0 ) { |
| | 152 | + if ( ( $count = count( $removeTags ) ) > 0 ) { |
| 153 | 153 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-tags-raw-removed', 'parse', $count ) ); |
| 154 | 154 | $this->showTagList( $removeTags, $output, $wgUser->getSkin() ); |
| 155 | 155 | } |
| — | — | @@ -162,8 +162,8 @@ |
| 163 | 163 | break; |
| 164 | 164 | case self::EDIT_NORMAL: |
| 165 | 165 | $output->setPageTitle( $listIdsAndNames[$rlId] . ' ' . wfMsg( 'collabwatchlistedit-normal-title' ) ); |
| 166 | | - if( $request->wasPosted() ) { |
| 167 | | - if( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| | 166 | + if ( $request->wasPosted() ) { |
| | 167 | + if ( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| 168 | 168 | $output->redirect( $permissionDeniedTarget ); |
| 169 | 169 | break; |
| 170 | 170 | } |
| — | — | @@ -177,26 +177,26 @@ |
| 178 | 178 | break; |
| 179 | 179 | case self::SET_TAGS: |
| 180 | 180 | $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(); |
| 181 | | - if( $request->wasPosted() ) { |
| 182 | | - $rlId = $request->getInt('collabwatchlist', -1); |
| 183 | | - if( ! $this->checkPermissions( $wgUser, $rlId, array(COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER) ) ) { |
| | 181 | + if ( $request->wasPosted() ) { |
| | 182 | + $rlId = $request->getInt( 'collabwatchlist', -1 ); |
| | 183 | + if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) { |
| 184 | 184 | $output->redirect( $permissionDeniedTarget ); |
| 185 | 185 | break; |
| 186 | 186 | } |
| 187 | | - $redirTarget = $request->getText('redirTarget', $redirTarget); |
| 188 | | - $tagToAdd = $request->getText('collabwatchlisttag'); |
| 189 | | - $tagcomment = $request->getText('tagcomment'); |
| 190 | | - $setPatrolled = $request->getBool('setpatrolled', false); |
| | 187 | + $redirTarget = $request->getText( 'redirTarget', $redirTarget ); |
| | 188 | + $tagToAdd = $request->getText( 'collabwatchlisttag' ); |
| | 189 | + $tagcomment = $request->getText( 'tagcomment' ); |
| | 190 | + $setPatrolled = $request->getBool( 'setpatrolled', false ); |
| 191 | 191 | $pagesToTag = array(); |
| 192 | | - if( strlen($tagToAdd) !== 0 && $rlId !== -1 ) { |
| | 192 | + if ( strlen( $tagToAdd ) !== 0 && $rlId !== -1 ) { |
| 193 | 193 | $postValues = $request->getValues(); |
| 194 | | - foreach( $postValues as $key => $value ) { |
| 195 | | - if( stripos($key, 'collaborative-watchlist-addtag-') === 0 ) { |
| 196 | | - $pageRevRcId = explode('|', $value); |
| 197 | | - if( count($pageRevRcId) < 3 ) { |
| | 194 | + foreach ( $postValues as $key => $value ) { |
| | 195 | + if ( stripos( $key, 'collaborative-watchlist-addtag-' ) === 0 ) { |
| | 196 | + $pageRevRcId = explode( '|', $value ); |
| | 197 | + if ( count( $pageRevRcId ) < 3 ) { |
| 198 | 198 | continue; |
| 199 | 199 | } |
| 200 | | - $pagesToTag[$pageRevRcId[0]][] = array('rev_id' => $pageRevRcId[1], 'rc_id' => $pageRevRcId[2]); |
| | 200 | + $pagesToTag[$pageRevRcId[0]][] = array( 'rev_id' => $pageRevRcId[1], 'rc_id' => $pageRevRcId[2] ); |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | $this->setTags( $pagesToTag, $tagToAdd, $wgUser->getId(), $rlId, $tagcomment, $setPatrolled ); |
| — | — | @@ -205,48 +205,48 @@ |
| 206 | 206 | $output->redirect( $redirTarget ); |
| 207 | 207 | break; |
| 208 | 208 | case self::UNSET_TAGS: |
| 209 | | - $rlId = $request->getInt('collabwatchlist', -1); |
| 210 | | - if( ! $this->checkPermissions( $wgUser, $rlId, array(COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER) ) ) { |
| | 209 | + $rlId = $request->getInt( 'collabwatchlist', -1 ); |
| | 210 | + if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) { |
| 211 | 211 | $output->redirect( $permissionDeniedTarget ); |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | 214 | $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(); |
| 215 | | - $redirTarget = $request->getText('redirTarget', $redirTarget); |
| 216 | | - $page = $request->getText('collabwatchlistpage'); |
| 217 | | - $tagToDel = $request->getText('collabwatchlisttag'); |
| 218 | | - $rcId = $request->getInt('collabwatchlistrcid', -1); |
| 219 | | - if( strlen($page) !== 0 && strlen($tagToDel) !== 0 && $rlId !== -1 && $rcId !== -1 ) { |
| 220 | | - $pagesToUntag[$page][] = array('rc_id' => $rcId); |
| | 215 | + $redirTarget = $request->getText( 'redirTarget', $redirTarget ); |
| | 216 | + $page = $request->getText( 'collabwatchlistpage' ); |
| | 217 | + $tagToDel = $request->getText( 'collabwatchlisttag' ); |
| | 218 | + $rcId = $request->getInt( 'collabwatchlistrcid', -1 ); |
| | 219 | + if ( strlen( $page ) !== 0 && strlen( $tagToDel ) !== 0 && $rlId !== -1 && $rcId !== -1 ) { |
| | 220 | + $pagesToUntag[$page][] = array( 'rc_id' => $rcId ); |
| 221 | 221 | $this->unsetTags( $pagesToUntag, $tagToDel, $wgUser->getId(), $rlId ); |
| 222 | 222 | } |
| 223 | 223 | $output->redirect( $redirTarget ); |
| 224 | 224 | break; |
| 225 | 225 | case self::NEW_LIST: |
| 226 | | - if( $request->wasPosted() ) { |
| | 226 | + if ( $request->wasPosted() ) { |
| 227 | 227 | $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(); |
| 228 | | - $listId = $this->createNewList($request->getText('listname')); |
| 229 | | - if( isset($listId) ) { |
| | 228 | + $listId = $this->createNewList( $request->getText( 'listname' ) ); |
| | 229 | + if ( isset( $listId ) ) { |
| 230 | 230 | $output->redirect( $redirTarget ); |
| 231 | 231 | } else { |
| 232 | 232 | $output->addHTML( wfMsgExt( 'collabwatchlistnew-name-exists', 'parse' ) ); |
| 233 | 233 | } |
| 234 | 234 | } else { |
| 235 | | - $this->showNewListForm($output); |
| | 235 | + $this->showNewListForm( $output ); |
| 236 | 236 | } |
| 237 | 237 | break; |
| 238 | 238 | case self::DELETE_LIST: |
| 239 | 239 | $output->setPageTitle( $listIdsAndNames[$rlId] . ' ' . wfMsg( 'collabwatchlistdelete-title' ) ); |
| 240 | | - $rlId = $request->getInt('collabwatchlist', -1); |
| 241 | | - if( $request->wasPosted() ) { |
| 242 | | - if( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| | 240 | + $rlId = $request->getInt( 'collabwatchlist', -1 ); |
| | 241 | + if ( $request->wasPosted() ) { |
| | 242 | + if ( ! $this->checkToken( $request, $wgUser, $rlId ) ) { |
| 243 | 243 | $output->redirect( $permissionDeniedTarget ); |
| 244 | 244 | break; |
| 245 | 245 | } |
| 246 | | - $this->deleteList($rlId); |
| | 246 | + $this->deleteList( $rlId ); |
| 247 | 247 | $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(); |
| 248 | 248 | $output->redirect( $redirTarget ); |
| 249 | 249 | } else { |
| 250 | | - $this->showDeleteListForm($output, $rlId); |
| | 250 | + $this->showDeleteListForm( $output, $rlId ); |
| 251 | 251 | } |
| 252 | 252 | break; |
| 253 | 253 | } |
| — | — | @@ -261,14 +261,14 @@ |
| 262 | 262 | * @param $memberTypes Which types of members are allowed |
| 263 | 263 | * @return bool |
| 264 | 264 | */ |
| 265 | | - private function checkToken( $request, $user, $rlId, $memberTypes = array(COLLABWATCHLISTUSER_OWNER) ) { |
| | 265 | + private function checkToken( $request, $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) { |
| 266 | 266 | $tokenOk = $user->matchEditToken( $request->getVal( 'token' ), 'watchlistedit' ) && $request->getVal( 'collabwatchlist' ) !== 0; |
| 267 | | - if( $tokenOk === false ) |
| | 267 | + if ( $tokenOk === false ) |
| 268 | 268 | return $tokenOk; |
| 269 | 269 | return $this->checkPermissions( $user, $rlId, $memberTypes ); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | | - private function checkPermissions( $user, $rlId, $memberTypes = array(COLLABWATCHLISTUSER_OWNER) ) { |
| | 272 | + private function checkPermissions( $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) { |
| 273 | 273 | // Check permissions |
| 274 | 274 | $dbr = wfGetDB( DB_MASTER ); |
| 275 | 275 | $res = $dbr->select( 'collabwatchlistuser', |
| — | — | @@ -289,22 +289,22 @@ |
| 290 | 290 | */ |
| 291 | 291 | private function extractCollabWatchlistCategories( $list ) { |
| 292 | 292 | $titles = array(); |
| 293 | | - if( !is_array( $list ) ) { |
| | 293 | + if ( !is_array( $list ) ) { |
| 294 | 294 | $list = explode( "\n", trim( $list ) ); |
| 295 | | - if( !is_array( $list ) ) |
| | 295 | + if ( !is_array( $list ) ) |
| 296 | 296 | return array(); |
| 297 | 297 | } |
| 298 | | - foreach( $list as $text ) { |
| | 298 | + foreach ( $list as $text ) { |
| 299 | 299 | $subtract = false; |
| 300 | 300 | $text = trim( $text ); |
| 301 | 301 | $titleText = $text; |
| 302 | | - if( stripos($text, '- ') === 0 ) { |
| | 302 | + if ( stripos( $text, '- ' ) === 0 ) { |
| 303 | 303 | $subtract = true; |
| 304 | | - $titleText = trim( substr($text, 2) ); |
| | 304 | + $titleText = trim( substr( $text, 2 ) ); |
| 305 | 305 | } |
| 306 | | - if( strlen( $text ) > 0 ) { |
| | 306 | + if ( strlen( $text ) > 0 ) { |
| 307 | 307 | $title = Title::newFromText( $titleText ); |
| 308 | | - if( $title instanceof Title && $title->isWatchable() ) { |
| | 308 | + if ( $title instanceof Title && $title->isWatchable() ) { |
| 309 | 309 | $titles[] = $subtract ? '- ' . $title->getPrefixedText() : $title->getPrefixedText(); |
| 310 | 310 | } |
| 311 | 311 | } |
| — | — | @@ -317,20 +317,20 @@ |
| 318 | 318 | $typeText = COLLABWATCHLISTUSER_USER_TEXT; |
| 319 | 319 | $text = trim( $typeAndUsernameStr ); |
| 320 | 320 | $titleText = $text; |
| 321 | | - if( stripos($text, COLLABWATCHLISTUSER_OWNER_TEXT . ' ') === 0 ) { |
| | 321 | + if ( stripos( $text, COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) === 0 ) { |
| 322 | 322 | $type = COLLABWATCHLISTUSER_OWNER; |
| 323 | 323 | $typeText = COLLABWATCHLISTUSER_OWNER_TEXT; |
| 324 | | - $titleText = trim( substr($text, strlen(COLLABWATCHLISTUSER_OWNER_TEXT . ' ')) ); |
| 325 | | - }else if( stripos($text, COLLABWATCHLISTUSER_USER_TEXT . ' ') === 0 ) { |
| | 324 | + $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) ) ); |
| | 325 | + } else if ( stripos( $text, COLLABWATCHLISTUSER_USER_TEXT . ' ' ) === 0 ) { |
| 326 | 326 | $type = COLLABWATCHLISTUSER_USER; |
| 327 | 327 | $typeText = COLLABWATCHLISTUSER_USER_TEXT; |
| 328 | | - $titleText = trim( substr($text, strlen(COLLABWATCHLISTUSER_USER_TEXT . ' ')) ); |
| 329 | | - }else if( stripos($text, COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ') === 0 ) { |
| | 328 | + $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_USER_TEXT . ' ' ) ) ); |
| | 329 | + } else if ( stripos( $text, COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) === 0 ) { |
| 330 | 330 | $type = COLLABWATCHLISTUSER_TRUSTED_EDITOR; |
| 331 | 331 | $typeText = COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT; |
| 332 | | - $titleText = trim( substr($text, strlen(COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ')) ); |
| | 332 | + $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) ) ); |
| 333 | 333 | } |
| 334 | | - return array($type, $typeText, $titleText); |
| | 334 | + return array( $type, $typeText, $titleText ); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
| — | — | @@ -342,16 +342,16 @@ |
| 343 | 343 | */ |
| 344 | 344 | private function extractCollabWatchlistUsers( $list ) { |
| 345 | 345 | $titles = array(); |
| 346 | | - if( !is_array( $list ) ) { |
| | 346 | + if ( !is_array( $list ) ) { |
| 347 | 347 | $list = explode( "\n", trim( $list ) ); |
| 348 | | - if( !is_array( $list ) ) |
| | 348 | + if ( !is_array( $list ) ) |
| 349 | 349 | return array(); |
| 350 | 350 | } |
| 351 | | - foreach( $list as $text ) { |
| 352 | | - list($type, $typeText, $titleText) = $this->extractTypeTypeTextAndUsername( $text ); |
| 353 | | - if( strlen( $text ) > 0 ) { |
| 354 | | - $user = User::newFromName($titleText); |
| 355 | | - if( $user instanceof User ) { |
| | 351 | + foreach ( $list as $text ) { |
| | 352 | + list( $type, $typeText, $titleText ) = $this->extractTypeTypeTextAndUsername( $text ); |
| | 353 | + if ( strlen( $text ) > 0 ) { |
| | 354 | + $user = User::newFromName( $titleText ); |
| | 355 | + if ( $user instanceof User ) { |
| 356 | 356 | $titles[] = $typeText . ' ' . $user->getName(); |
| 357 | 357 | } |
| 358 | 358 | } |
| — | — | @@ -368,21 +368,21 @@ |
| 369 | 369 | */ |
| 370 | 370 | private function extractCollabWatchlistTags( $list ) { |
| 371 | 371 | $tags = array(); |
| 372 | | - if( !is_array( $list ) ) { |
| | 372 | + if ( !is_array( $list ) ) { |
| 373 | 373 | $list = explode( "\n", trim( $list ) ); |
| 374 | | - if( !is_array( $list ) ) |
| | 374 | + if ( !is_array( $list ) ) |
| 375 | 375 | return array(); |
| 376 | 376 | } |
| 377 | | - foreach( $list as $text ) { |
| | 377 | + foreach ( $list as $text ) { |
| 378 | 378 | $subtract = false; |
| 379 | | - $text = trim($text); |
| 380 | | - if( strlen( $text ) > 0 ) { |
| 381 | | - $pipepos = stripos($text, '|'); |
| | 379 | + $text = trim( $text ); |
| | 380 | + if ( strlen( $text ) > 0 ) { |
| | 381 | + $pipepos = stripos( $text, '|' ); |
| 382 | 382 | $description = ''; |
| 383 | | - if( $pipepos > 0 ) { |
| 384 | | - if( ($pipepos + 1) < strlen($text) ) |
| 385 | | - $description = trim(substr($text, $pipepos + 1)); |
| 386 | | - $text = trim(substr($text, 0, $pipepos)); |
| | 383 | + if ( $pipepos > 0 ) { |
| | 384 | + if ( ( $pipepos + 1 ) < strlen( $text ) ) |
| | 385 | + $description = trim( substr( $text, $pipepos + 1 ) ); |
| | 386 | + $text = trim( substr( $text, 0, $pipepos ) ); |
| 387 | 387 | } |
| 388 | 388 | $tags[$text] = $description; |
| 389 | 389 | } |
| — | — | @@ -404,10 +404,10 @@ |
| 405 | 405 | $talk = wfMsgHtml( 'talkpagelinktext' ); |
| 406 | 406 | // Do a batch existence check |
| 407 | 407 | $batch = new LinkBatch(); |
| 408 | | - foreach( $titles as $title ) { |
| 409 | | - if( !$title instanceof Title ) |
| | 408 | + foreach ( $titles as $title ) { |
| | 409 | + if ( !$title instanceof Title ) |
| 410 | 410 | $title = Title::newFromText( $title ); |
| 411 | | - if( $title instanceof Title ) { |
| | 411 | + if ( $title instanceof Title ) { |
| 412 | 412 | $batch->addObj( $title ); |
| 413 | 413 | $batch->addObj( $title->getTalkPage() ); |
| 414 | 414 | } |
| — | — | @@ -415,10 +415,10 @@ |
| 416 | 416 | $batch->execute(); |
| 417 | 417 | // Print out the list |
| 418 | 418 | $output->addHTML( "<ul>\n" ); |
| 419 | | - foreach( $titles as $title ) { |
| 420 | | - if( !$title instanceof Title ) |
| | 419 | + foreach ( $titles as $title ) { |
| | 420 | + if ( !$title instanceof Title ) |
| 421 | 421 | $title = Title::newFromText( $title ); |
| 422 | | - if( $title instanceof Title ) { |
| | 422 | + if ( $title instanceof Title ) { |
| 423 | 423 | $output->addHTML( "<li>" . $skin->link( $title ) |
| 424 | 424 | . ' (' . $skin->link( $title->getTalkPage(), $talk ) . ")</li>\n" ); |
| 425 | 425 | } |
| — | — | @@ -439,7 +439,7 @@ |
| 440 | 440 | private function showTagList( $tagsAndDesc, $output, $skin ) { |
| 441 | 441 | // Print out the list |
| 442 | 442 | $output->addHTML( "<ul>\n" ); |
| 443 | | - foreach( $tagsAndDesc as $title => $description ) { |
| | 443 | + foreach ( $tagsAndDesc as $title => $description ) { |
| 444 | 444 | $output->addHTML( "<li>" . $title |
| 445 | 445 | . ' (' . $description . ")</li>\n" ); |
| 446 | 446 | } |
| — | — | @@ -509,19 +509,19 @@ |
| 510 | 510 | $list = array(); |
| 511 | 511 | $dbr = wfGetDB( DB_MASTER ); |
| 512 | 512 | $res = $dbr->select( |
| 513 | | - array('collabwatchlistcategory', 'page'), |
| 514 | | - array('page_title', 'page_namespace', 'subtract'), |
| | 513 | + array( 'collabwatchlistcategory', 'page' ), |
| | 514 | + array( 'page_title', 'page_namespace', 'subtract' ), |
| 515 | 515 | array( |
| 516 | 516 | 'rl_id' => $rlId, |
| 517 | 517 | ), |
| 518 | 518 | __METHOD__, array(), |
| 519 | 519 | # Join conditions |
| 520 | | - array( 'page' => array('JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id') ) |
| | 520 | + array( 'page' => array( 'JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id' ) ) |
| 521 | 521 | ); |
| 522 | | - if( $res->numRows() > 0 ) { |
| 523 | | - foreach( $res as $row ) { |
| | 522 | + if ( $res->numRows() > 0 ) { |
| | 523 | + foreach ( $res as $row ) { |
| 524 | 524 | $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
| 525 | | - if( $title instanceof Title && !$title->isTalkPage() ) |
| | 525 | + if ( $title instanceof Title && !$title->isTalkPage() ) |
| 526 | 526 | $list[] = $row->subtract ? '- ' . $title->getPrefixedText() : $title->getPrefixedText(); |
| 527 | 527 | } |
| 528 | 528 | } |
| — | — | @@ -539,18 +539,18 @@ |
| 540 | 540 | $list = array(); |
| 541 | 541 | $dbr = wfGetDB( DB_MASTER ); |
| 542 | 542 | $res = $dbr->select( |
| 543 | | - array('collabwatchlistuser', 'user'), |
| 544 | | - array('user_name', 'rlu_type'), |
| | 543 | + array( 'collabwatchlistuser', 'user' ), |
| | 544 | + array( 'user_name', 'rlu_type' ), |
| 545 | 545 | array( |
| 546 | 546 | 'rl_id' => $rlId, |
| 547 | 547 | ), |
| 548 | 548 | __METHOD__, array(), |
| 549 | 549 | # Join conditions |
| 550 | | - array( 'user' => array('JOIN', 'user.user_id = collabwatchlistuser.user_id') ) |
| | 550 | + array( 'user' => array( 'JOIN', 'user.user_id = collabwatchlistuser.user_id' ) ) |
| 551 | 551 | ); |
| 552 | | - if( $res->numRows() > 0 ) { |
| 553 | | - foreach( $res as $row ) { |
| 554 | | - $typeText = fnCollabWatchlistUserTypeToText($row->rlu_type); |
| | 552 | + if ( $res->numRows() > 0 ) { |
| | 553 | + foreach ( $res as $row ) { |
| | 554 | + $typeText = fnCollabWatchlistUserTypeToText( $row->rlu_type ); |
| 555 | 555 | $list[] = $typeText . ' ' . $row->user_name; |
| 556 | 556 | } |
| 557 | 557 | } |
| — | — | @@ -568,14 +568,14 @@ |
| 569 | 569 | $list = array(); |
| 570 | 570 | $dbr = wfGetDB( DB_MASTER ); |
| 571 | 571 | $res = $dbr->select( |
| 572 | | - array('collabwatchlisttag'), |
| 573 | | - array('rt_name', 'rt_description'), |
| | 572 | + array( 'collabwatchlisttag' ), |
| | 573 | + array( 'rt_name', 'rt_description' ), |
| 574 | 574 | array( |
| 575 | 575 | 'rl_id' => $rlId, |
| 576 | 576 | ), __METHOD__ |
| 577 | 577 | ); |
| 578 | | - if( $res->numRows() > 0 ) { |
| 579 | | - foreach( $res as $row ) { |
| | 578 | + if ( $res->numRows() > 0 ) { |
| | 579 | + foreach ( $res as $row ) { |
| 580 | 580 | $list[$row->rt_name] = $row->rt_description; |
| 581 | 581 | } |
| 582 | 582 | } |
| — | — | @@ -595,30 +595,30 @@ |
| 596 | 596 | $dbr = wfGetDB( DB_MASTER ); |
| 597 | 597 | |
| 598 | 598 | $res = $dbr->select( |
| 599 | | - array('collabwatchlistcategory', 'page'), |
| 600 | | - array('page_title', 'page_namespace', 'page_id', 'page_len', 'page_is_redirect', 'subtract'), |
| | 599 | + array( 'collabwatchlistcategory', 'page' ), |
| | 600 | + array( 'page_title', 'page_namespace', 'page_id', 'page_len', 'page_is_redirect', 'subtract' ), |
| 601 | 601 | array( |
| 602 | 602 | 'rl_id' => $rlId, |
| 603 | 603 | ), |
| 604 | 604 | __METHOD__, array(), |
| 605 | 605 | # Join conditions |
| 606 | | - array( 'page' => array('JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id') ) |
| | 606 | + array( 'page' => array( 'JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id' ) ) |
| 607 | 607 | ); |
| 608 | 608 | |
| 609 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
| | 609 | + if ( $res && $dbr->numRows( $res ) > 0 ) { |
| 610 | 610 | $cache = LinkCache::singleton(); |
| 611 | | - foreach( $res as $row ) { |
| | 611 | + foreach ( $res as $row ) { |
| 612 | 612 | $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
| 613 | | - if( $title instanceof Title ) { |
| | 613 | + if ( $title instanceof Title ) { |
| 614 | 614 | // Update the link cache while we're at it |
| 615 | | - if( $row->page_id ) { |
| | 615 | + if ( $row->page_id ) { |
| 616 | 616 | $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect ); |
| 617 | 617 | } else { |
| 618 | 618 | $cache->addBadLinkObj( $title ); |
| 619 | 619 | } |
| 620 | 620 | // Ignore non-talk |
| 621 | | - if( !$title->isTalkPage() ) |
| 622 | | - $titles[$row->page_namespace][$row->page_title] = array('redirect' => $row->page_is_redirect, 'subtract' => $row->subtract); |
| | 621 | + if ( !$title->isTalkPage() ) |
| | 622 | + $titles[$row->page_namespace][$row->page_title] = array( 'redirect' => $row->page_is_redirect, 'subtract' => $row->subtract ); |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | } |
| — | — | @@ -634,7 +634,7 @@ |
| 635 | 635 | * @return int |
| 636 | 636 | */ |
| 637 | 637 | private function showItemCount( $output, $rlId ) { |
| 638 | | - if( ( $count = $this->countCollabWatchlistCategories( $rlId ) ) > 0 ) { |
| | 638 | + if ( ( $count = $this->countCollabWatchlistCategories( $rlId ) ) > 0 ) { |
| 639 | 639 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-numitems', 'parse', |
| 640 | 640 | $GLOBALS['wgLang']->formatNum( $count ) ) ); |
| 641 | 641 | } else { |
| — | — | @@ -652,7 +652,7 @@ |
| 653 | 653 | * @return int |
| 654 | 654 | */ |
| 655 | 655 | private function showTagItemCount( $output, $rlId ) { |
| 656 | | - if( ( $count = $this->countCollabWatchlistTags( $rlId ) ) > 0 ) { |
| | 656 | + if ( ( $count = $this->countCollabWatchlistTags( $rlId ) ) > 0 ) { |
| 657 | 657 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-tags-numitems', 'parse', |
| 658 | 658 | $GLOBALS['wgLang']->formatNum( $count ) ) ); |
| 659 | 659 | } else { |
| — | — | @@ -670,7 +670,7 @@ |
| 671 | 671 | * @return int |
| 672 | 672 | */ |
| 673 | 673 | private function showSetTagsItemCount( $output, $rlId ) { |
| 674 | | - if( ( $count = $this->countCollabWatchlistSetTags( $rlId ) ) > 0 ) { |
| | 674 | + if ( ( $count = $this->countCollabWatchlistSetTags( $rlId ) ) > 0 ) { |
| 675 | 675 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-set-tags-numitems', 'parse', |
| 676 | 676 | $GLOBALS['wgLang']->formatNum( $count ) ) ); |
| 677 | 677 | } else { |
| — | — | @@ -688,7 +688,7 @@ |
| 689 | 689 | * @return int |
| 690 | 690 | */ |
| 691 | 691 | private function showUserItemCount( $output, $rlId ) { |
| 692 | | - if( ( $count = $this->countCollabWatchlistUsers( $rlId ) ) > 0 ) { |
| | 692 | + if ( ( $count = $this->countCollabWatchlistUsers( $rlId ) ) > 0 ) { |
| 693 | 693 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-users-numitems', 'parse', |
| 694 | 694 | $GLOBALS['wgLang']->formatNum( $count ) ) ); |
| 695 | 695 | } else { |
| — | — | @@ -720,16 +720,16 @@ |
| 721 | 721 | $dbw = wfGetDB( DB_MASTER ); |
| 722 | 722 | $rows = array(); |
| 723 | 723 | $added = array(); |
| 724 | | - foreach( $titles as $title ) { |
| | 724 | + foreach ( $titles as $title ) { |
| 725 | 725 | $subtract = false; |
| 726 | 726 | $title = trim( $title ); |
| 727 | 727 | $titleText = $title; |
| 728 | | - if( stripos($title, '- ') === 0 ) { |
| | 728 | + if ( stripos( $title, '- ' ) === 0 ) { |
| 729 | 729 | $subtract = true; |
| 730 | | - $titleText = trim( substr($title, 2) ); |
| | 730 | + $titleText = trim( substr( $title, 2 ) ); |
| 731 | 731 | } |
| 732 | 732 | $titleObj = Title::newFromText( $titleText ); |
| 733 | | - if( $titleObj instanceof Title && $titleObj->exists() ) { |
| | 733 | + if ( $titleObj instanceof Title && $titleObj->exists() ) { |
| 734 | 734 | $rows[] = array( |
| 735 | 735 | 'rl_id' => $rlId, |
| 736 | 736 | 'cat_page_id' => $titleObj->getArticleID(), |
| — | — | @@ -754,10 +754,10 @@ |
| 755 | 755 | $dbw = wfGetDB( DB_MASTER ); |
| 756 | 756 | $rows = array(); |
| 757 | 757 | $added = array(); |
| 758 | | - foreach( $users as $userString ) { |
| 759 | | - list($type, $typeText, $titleText) = $this->extractTypeTypeTextAndUsername( $userString ); |
| 760 | | - $user = User::newFromName($titleText); |
| 761 | | - if( $user instanceof User && $user->getId() !== 0) { |
| | 758 | + foreach ( $users as $userString ) { |
| | 759 | + list( $type, $typeText, $titleText ) = $this->extractTypeTypeTextAndUsername( $userString ); |
| | 760 | + $user = User::newFromName( $titleText ); |
| | 761 | + if ( $user instanceof User && $user->getId() !== 0 ) { |
| 762 | 762 | $rows[] = array( |
| 763 | 763 | 'rl_id' => $rlId, |
| 764 | 764 | 'user_id' => $user->getId(), |
| — | — | @@ -770,48 +770,48 @@ |
| 771 | 771 | return $added; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | | - private function setTags( $titlesAndTagInfo, $tag, $userId, $rlId, $comment, $setPatrolled = false) { |
| 775 | | - //XXX Attach a hook to delete tags from the collabwatchlistrevisiontag table as soon as the actual tags are deleted from the change_tags table |
| 776 | | - $allowedTagsAndInfo = $this->getCollabWatchlistTags($rlId); |
| 777 | | - if(!array_key_exists($tag, $allowedTagsAndInfo)) { |
| | 774 | + private function setTags( $titlesAndTagInfo, $tag, $userId, $rlId, $comment, $setPatrolled = false ) { |
| | 775 | + // XXX Attach a hook to delete tags from the collabwatchlistrevisiontag table as soon as the actual tags are deleted from the change_tags table |
| | 776 | + $allowedTagsAndInfo = $this->getCollabWatchlistTags( $rlId ); |
| | 777 | + if ( !array_key_exists( $tag, $allowedTagsAndInfo ) ) { |
| 778 | 778 | return false; |
| 779 | 779 | } |
| 780 | 780 | $dbw = wfGetDB( DB_MASTER ); |
| 781 | | - foreach( $titlesAndTagInfo as $title => $infos ) { |
| | 781 | + foreach ( $titlesAndTagInfo as $title => $infos ) { |
| 782 | 782 | $rcIds = array(); |
| 783 | 783 | // Add entries for the tag to the change_tags table |
| 784 | 784 | // optionally mark edit as patrolled |
| 785 | | - foreach( $infos as $infoKey => $info ) { |
| 786 | | - ChangeTags::addTags($tag, $info['rc_id'], $info['rev_id']); |
| | 785 | + foreach ( $infos as $infoKey => $info ) { |
| | 786 | + ChangeTags::addTags( $tag, $info['rc_id'], $info['rev_id'] ); |
| 787 | 787 | $rcIds[] = $info['rc_id']; |
| 788 | | - if( $setPatrolled ) { |
| 789 | | - RecentChange::markPatrolled($info['rc_id']); |
| | 788 | + if ( $setPatrolled ) { |
| | 789 | + RecentChange::markPatrolled( $info['rc_id'] ); |
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | // Add the tagged revisions to the collaborative watchlist |
| 793 | 793 | $sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_id, rl_id, user_id, rrt_comment) |
| 794 | | - SELECT ct_id, ' . $dbw->strencode($rlId) . ',' . |
| 795 | | - $dbw->strencode($userId) . ',' . |
| 796 | | - $dbw->addQuotes($comment) . ' FROM change_tag WHERE ct_tag = ? AND ct_rc_id '; |
| 797 | | - if( count($rcIds) > 1 ) { |
| 798 | | - $sql .= 'IN (' . $dbw->makeList($rcIds) . ')'; |
| | 794 | + SELECT ct_id, ' . $dbw->strencode( $rlId ) . ',' . |
| | 795 | + $dbw->strencode( $userId ) . ',' . |
| | 796 | + $dbw->addQuotes( $comment ) . ' FROM change_tag WHERE ct_tag = ? AND ct_rc_id '; |
| | 797 | + if ( count( $rcIds ) > 1 ) { |
| | 798 | + $sql .= 'IN (' . $dbw->makeList( $rcIds ) . ')'; |
| 799 | 799 | $params = array( $tag ); |
| 800 | | - }else { |
| | 800 | + } else { |
| 801 | 801 | $sql .= '= ?'; |
| 802 | 802 | $params = array( $tag, $rcIds[0] ); |
| 803 | 803 | } |
| 804 | | - $prepSql = $dbw->prepare($sql); |
| 805 | | - $res = $dbw->execute($prepSql, $params); |
| 806 | | - $dbw->freePrepared($prepSql); |
| | 804 | + $prepSql = $dbw->prepare( $sql ); |
| | 805 | + $res = $dbw->execute( $prepSql, $params ); |
| | 806 | + $dbw->freePrepared( $prepSql ); |
| 807 | 807 | return true; |
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | private function unsetTags( $titlesAndTagInfo, $tag, $userId, $rlId ) { |
| 812 | 812 | $dbw = wfGetDB( DB_MASTER ); |
| 813 | | - foreach( $titlesAndTagInfo as $title => $infos ) { |
| | 813 | + foreach ( $titlesAndTagInfo as $title => $infos ) { |
| 814 | 814 | $rcIds = array(); |
| 815 | | - foreach( $infos as $infoKey => $info ) { |
| | 815 | + foreach ( $infos as $infoKey => $info ) { |
| 816 | 816 | // XXX Remove entries for the tag from the change_tags table |
| 817 | 817 | // ChangeTags::addTags($tag, $info['rc_id'], $info['rev_id']); |
| 818 | 818 | $rcIds[] = $info['rc_id']; |
| — | — | @@ -820,16 +820,16 @@ |
| 821 | 821 | $sql = 'delete collabwatchlistrevisiontag from collabwatchlistrevisiontag JOIN change_tag |
| 822 | 822 | ON change_tag.ct_id = collabwatchlistrevisiontag.ct_id |
| 823 | 823 | WHERE ct_tag = ? AND ct_rc_id '; |
| 824 | | - if( count($rcIds) > 1 ) { |
| 825 | | - $sql .= 'IN (' . $dbw->makeList($rcIds) . ')'; |
| | 824 | + if ( count( $rcIds ) > 1 ) { |
| | 825 | + $sql .= 'IN (' . $dbw->makeList( $rcIds ) . ')'; |
| 826 | 826 | $params = array( $tag ); |
| 827 | | - }else { |
| | 827 | + } else { |
| 828 | 828 | $sql .= '= ?'; |
| 829 | 829 | $params = array( $tag, $rcIds[0] ); |
| 830 | 830 | } |
| 831 | | - $prepSql = $dbw->prepare($sql); |
| 832 | | - $res = $dbw->execute($prepSql, $params); |
| 833 | | - $dbw->freePrepared($prepSql); |
| | 831 | + $prepSql = $dbw->prepare( $sql ); |
| | 832 | + $res = $dbw->execute( $prepSql, $params ); |
| | 833 | + $dbw->freePrepared( $prepSql ); |
| 834 | 834 | } |
| 835 | 835 | } |
| 836 | 836 | |
| — | — | @@ -844,7 +844,7 @@ |
| 845 | 845 | private function addTags( $titles, $rlId ) { |
| 846 | 846 | $dbw = wfGetDB( DB_MASTER ); |
| 847 | 847 | $rows = array(); |
| 848 | | - foreach( $titles as $title => $description ) { |
| | 848 | + foreach ( $titles as $title => $description ) { |
| 849 | 849 | $rows[] = array( |
| 850 | 850 | 'rl_id' => $rlId, |
| 851 | 851 | 'rt_name' => $title, |
| — | — | @@ -865,16 +865,16 @@ |
| 866 | 866 | */ |
| 867 | 867 | private function unwatchTitles( $titles, $rlId ) { |
| 868 | 868 | $dbw = wfGetDB( DB_MASTER ); |
| 869 | | - foreach( $titles as $title ) { |
| | 869 | + foreach ( $titles as $title ) { |
| 870 | 870 | $subtract = false; |
| 871 | 871 | $title = trim( $title ); |
| 872 | 872 | $titleText = $title; |
| 873 | | - if( stripos($title, '- ') === 0 ) { |
| | 873 | + if ( stripos( $title, '- ' ) === 0 ) { |
| 874 | 874 | $subtract = true; |
| 875 | | - $titleText = trim( substr($title, 2) ); |
| | 875 | + $titleText = trim( substr( $title, 2 ) ); |
| 876 | 876 | } |
| 877 | 877 | $title = Title::newFromText( $titleText ); |
| 878 | | - if( $title instanceof Title ) { |
| | 878 | + if ( $title instanceof Title ) { |
| 879 | 879 | $dbw->delete( |
| 880 | 880 | 'collabwatchlistcategory', |
| 881 | 881 | array( |
| — | — | @@ -884,9 +884,9 @@ |
| 885 | 885 | ), |
| 886 | 886 | __METHOD__ |
| 887 | 887 | ); |
| 888 | | - $article = new Article($title); |
| 889 | | - //XXX Check if we can simply rename the hook, or if we need to register it |
| 890 | | - wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); |
| | 888 | + $article = new Article( $title ); |
| | 889 | + // XXX Check if we can simply rename the hook, or if we need to register it |
| | 890 | + wfRunHooks( 'UnwatchArticleComplete', array( &$user, &$article ) ); |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | } |
| — | — | @@ -901,10 +901,10 @@ |
| 902 | 902 | */ |
| 903 | 903 | private function delUsers( $users, $rlId ) { |
| 904 | 904 | $dbw = wfGetDB( DB_MASTER ); |
| 905 | | - foreach( $users as $userString ) { |
| 906 | | - list($type, $typeText, $titleText) = $this->extractTypeTypeTextAndUsername( $userString ); |
| 907 | | - $user = User::newFromName($titleText); |
| 908 | | - if( $user instanceof User && $user->getId() !== 0) { |
| | 905 | + foreach ( $users as $userString ) { |
| | 906 | + list( $type, $typeText, $titleText ) = $this->extractTypeTypeTextAndUsername( $userString ); |
| | 907 | + $user = User::newFromName( $titleText ); |
| | 908 | + if ( $user instanceof User && $user->getId() !== 0 ) { |
| 909 | 909 | $dbw->delete( |
| 910 | 910 | 'collabwatchlistuser', |
| 911 | 911 | array( |
| — | — | @@ -916,8 +916,8 @@ |
| 917 | 917 | ); |
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | | - //XXX Check if we can simply rename the hook, or if we need to register it |
| 921 | | - //wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); |
| | 920 | + // XXX Check if we can simply rename the hook, or if we need to register it |
| | 921 | + // wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | /** |
| — | — | @@ -930,7 +930,7 @@ |
| 931 | 931 | */ |
| 932 | 932 | private function removeTags( $titles, $rlId ) { |
| 933 | 933 | $dbw = wfGetDB( DB_MASTER ); |
| 934 | | - foreach( $titles as $title ) { |
| | 934 | + foreach ( $titles as $title ) { |
| 935 | 935 | $dbw->delete( |
| 936 | 936 | 'collabwatchlisttag', |
| 937 | 937 | array( |
| — | — | @@ -939,9 +939,9 @@ |
| 940 | 940 | ), |
| 941 | 941 | __METHOD__ |
| 942 | 942 | ); |
| 943 | | - //$article = new Article($title); |
| 944 | | - //XXX Check if we can simply rename the hook, or if we need to register it |
| 945 | | - //wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); |
| | 943 | + // $article = new Article($title); |
| | 944 | + // XXX Check if we can simply rename the hook, or if we need to register it |
| | 945 | + // wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); |
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | |
| — | — | @@ -953,7 +953,7 @@ |
| 954 | 954 | */ |
| 955 | 955 | private function showNormalForm( $output, $rlId ) { |
| 956 | 956 | global $wgUser; |
| 957 | | - if( ( $count = $this->showItemCount( $output, $rlId ) ) > 0 ) { |
| | 957 | + if ( ( $count = $this->showItemCount( $output, $rlId ) ) > 0 ) { |
| 958 | 958 | $self = SpecialPage::getTitleFor( 'CollabWatchlist' ); |
| 959 | 959 | $form = Xml::openElement( 'form', array( 'method' => 'post', |
| 960 | 960 | 'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) ); |
| — | — | @@ -976,7 +976,7 @@ |
| 977 | 977 | $form .= Html::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) ); |
| 978 | 978 | $form .= "<fieldset>\n<legend>" . wfMsgHtml( 'collabwatchlistnew-legend' ) . "</legend>"; |
| 979 | 979 | $form .= wfMsgExt( 'collabwatchlistnew-explain', 'parse' ); |
| 980 | | - $form .= Xml::label( wfMsg('collabwatchlistnew-name'), 'listname' ) . ' ' . Xml::input( 'listname' ) . ' '; |
| | 980 | + $form .= Xml::label( wfMsg( 'collabwatchlistnew-name' ), 'listname' ) . ' ' . Xml::input( 'listname' ) . ' '; |
| 981 | 981 | $form .= '<p>' . Xml::submitButton( wfMsg( 'collabwatchlistnew-submit' ) ) . '</p>'; |
| 982 | 982 | $form .= '</fieldset></form>'; |
| 983 | 983 | $output->addHTML( $form ); |
| — | — | @@ -991,16 +991,16 @@ |
| 992 | 992 | $form .= Html::hidden( 'collabwatchlist', $rlId ); |
| 993 | 993 | $form .= "<fieldset>\n<legend>" . wfMsgHtml( 'collabwatchlistdelete-legend' ) . "</legend>"; |
| 994 | 994 | $form .= wfMsgExt( 'collabwatchlistdelete-explain', 'parse' ); |
| 995 | | - $this->showUserItemCount($output, $rlId); |
| 996 | | - $this->showSetTagsItemCount($output, $rlId); |
| | 995 | + $this->showUserItemCount( $output, $rlId ); |
| | 996 | + $this->showSetTagsItemCount( $output, $rlId ); |
| 997 | 997 | $form .= '<p>' . Xml::submitButton( wfMsg( 'collabwatchlistdelete-submit' ) ) . '</p>'; |
| 998 | 998 | $form .= '</fieldset></form>'; |
| 999 | 999 | $output->addHTML( $form ); |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | | - private function createNewList($name) { |
| | 1002 | + private function createNewList( $name ) { |
| 1003 | 1003 | global $wgUser; |
| 1004 | | - if( !isset($name) || empty($name) ) |
| | 1004 | + if ( !isset( $name ) || empty( $name ) ) |
| 1005 | 1005 | return; |
| 1006 | 1006 | $dbw = wfGetDB( DB_MASTER ); |
| 1007 | 1007 | $dbw->begin(); |
| — | — | @@ -1009,13 +1009,13 @@ |
| 1010 | 1010 | $dbw->insert( 'collabwatchlist', array( |
| 1011 | 1011 | 'rl_id' => $rl_id, |
| 1012 | 1012 | 'rl_name' => $name, |
| 1013 | | - 'rl_start' => wfTimestamp(TS_ISO_8601), |
| | 1013 | + 'rl_start' => wfTimestamp( TS_ISO_8601 ), |
| 1014 | 1014 | ), __METHOD__, 'IGNORE' ); |
| 1015 | 1015 | |
| 1016 | 1016 | $affected = $dbw->affectedRows(); |
| 1017 | | - if( $affected ) { |
| | 1017 | + if ( $affected ) { |
| 1018 | 1018 | $newid = $dbw->insertId(); |
| 1019 | | - }else { |
| | 1019 | + } else { |
| 1020 | 1020 | return; |
| 1021 | 1021 | } |
| 1022 | 1022 | $rlu_id = $dbw->nextSequenceValue( 'collabwatchlistuser_rlu_id_seq' ); |
| — | — | @@ -1026,19 +1026,19 @@ |
| 1027 | 1027 | 'rlu_type' => COLLABWATCHLISTUSER_OWNER, |
| 1028 | 1028 | ), __METHOD__, 'IGNORE' ); |
| 1029 | 1029 | $affected = $dbw->affectedRows(); |
| 1030 | | - if( ! $affected ) { |
| | 1030 | + if ( ! $affected ) { |
| 1031 | 1031 | $dbw->rollback(); |
| 1032 | 1032 | return; |
| 1033 | 1033 | } |
| 1034 | 1034 | $dbw->commit(); |
| 1035 | 1035 | return $newid; |
| 1036 | | - }catch(Exception $e) { |
| | 1036 | + } catch ( Exception $e ) { |
| 1037 | 1037 | $dbw->rollback(); |
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | | - private function deleteList($rlId) { |
| 1042 | | - if( !isset($rlId) || empty($rlId) ) |
| | 1041 | + private function deleteList( $rlId ) { |
| | 1042 | + if ( !isset( $rlId ) || empty( $rlId ) ) |
| 1043 | 1043 | return; |
| 1044 | 1044 | $dbw = wfGetDB( DB_MASTER ); |
| 1045 | 1045 | $dbw->begin(); |
| — | — | @@ -1059,13 +1059,13 @@ |
| 1060 | 1060 | 'rl_id' => $rlId, |
| 1061 | 1061 | ), __METHOD__ ); |
| 1062 | 1062 | $affected = $dbw->affectedRows(); |
| 1063 | | - if( ! $affected ) { |
| | 1063 | + if ( ! $affected ) { |
| 1064 | 1064 | $dbw->rollback(); |
| 1065 | 1065 | return; |
| 1066 | 1066 | } |
| 1067 | 1067 | $dbw->commit(); |
| 1068 | 1068 | return $rlId; |
| 1069 | | - }catch(Exception $e) { |
| | 1069 | + } catch ( Exception $e ) { |
| 1070 | 1070 | $dbw->rollback(); |
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| — | — | @@ -1082,7 +1082,7 @@ |
| 1083 | 1083 | $list = ""; |
| 1084 | 1084 | $toc = $skin->tocIndent(); |
| 1085 | 1085 | $tocLength = 0; |
| 1086 | | - foreach( $this->getWatchlistInfo( $rlId ) as $namespace => $pages ) { |
| | 1086 | + foreach ( $this->getWatchlistInfo( $rlId ) as $namespace => $pages ) { |
| 1087 | 1087 | $tocLength++; |
| 1088 | 1088 | $heading = htmlspecialchars( $this->getNamespaceHeading( $namespace ) ); |
| 1089 | 1089 | $anchor = "editwatchlist-ns" . $namespace; |
| — | — | @@ -1091,14 +1091,14 @@ |
| 1092 | 1092 | $toc .= $skin->tocLine( $anchor, $heading, $tocLength, 1 ) . $skin->tocLineEnd(); |
| 1093 | 1093 | |
| 1094 | 1094 | $list .= "<ul>\n"; |
| 1095 | | - foreach( $pages as $dbkey => $info ) { |
| | 1095 | + foreach ( $pages as $dbkey => $info ) { |
| 1096 | 1096 | $title = Title::makeTitleSafe( $namespace, $dbkey ); |
| 1097 | 1097 | $list .= $this->buildRemoveLine( $title, $info, $skin ); |
| 1098 | 1098 | } |
| 1099 | 1099 | $list .= "</ul>\n"; |
| 1100 | 1100 | } |
| 1101 | 1101 | // ISSUE: omit the TOC if the total number of titles is low? |
| 1102 | | - if( $tocLength > 1 ) { |
| | 1102 | + if ( $tocLength > 1 ) { |
| 1103 | 1103 | $list = $skin->tocList( $toc ) . $list; |
| 1104 | 1104 | } |
| 1105 | 1105 | return $list; |
| — | — | @@ -1129,10 +1129,10 @@ |
| 1130 | 1130 | global $wgLang; |
| 1131 | 1131 | |
| 1132 | 1132 | $link = $skin->link( $title ); |
| 1133 | | - if( $catInfo['redirect'] ) |
| | 1133 | + if ( $catInfo['redirect'] ) |
| 1134 | 1134 | $link = '<span class="watchlistredir">' . $link . '</span>'; |
| 1135 | 1135 | $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
| 1136 | | - if( $title->exists() ) { |
| | 1136 | + if ( $title->exists() ) { |
| 1137 | 1137 | $tools[] = $skin->link( |
| 1138 | 1138 | $title, |
| 1139 | 1139 | wfMsgHtml( 'history_short' ), |
| — | — | @@ -1141,7 +1141,7 @@ |
| 1142 | 1142 | array( 'known', 'noclasses' ) |
| 1143 | 1143 | ); |
| 1144 | 1144 | } |
| 1145 | | - if( $title->getNamespace() == NS_USER && !$title->isSubpage() ) { |
| | 1145 | + if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) { |
| 1146 | 1146 | $tools[] = $skin->link( |
| 1147 | 1147 | SpecialPage::getTitleFor( 'Contributions', $title->getText() ), |
| 1148 | 1148 | wfMsgHtml( 'contributions' ), |
| — | — | @@ -1151,7 +1151,7 @@ |
| 1152 | 1152 | ); |
| 1153 | 1153 | } |
| 1154 | 1154 | return "<li>" |
| 1155 | | - . ($catInfo['subtract'] ? '<span class="collabwatchlistsubtract">- </span>' : '') |
| | 1155 | + . ( $catInfo['subtract'] ? '<span class="collabwatchlistsubtract">- </span>' : '' ) |
| 1156 | 1156 | . Xml::check( 'titles[]', false, array( 'value' => $catInfo['subtract'] ? '- ' . $title->getPrefixedText() : $title->getPrefixedText() ) ) |
| 1157 | 1157 | . $link . " (" . $wgLang->pipeList( $tools ) . ")" . "</li>\n"; |
| 1158 | 1158 | } |
| — | — | @@ -1178,7 +1178,7 @@ |
| 1179 | 1179 | $form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles', |
| 1180 | 1180 | 'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) ); |
| 1181 | 1181 | $categories = $this->getCollabWatchlistCategories( $rlId ); |
| 1182 | | - foreach( $categories as $category ) |
| | 1182 | + foreach ( $categories as $category ) |
| 1183 | 1183 | $form .= htmlspecialchars( $category ) . "\n"; |
| 1184 | 1184 | $form .= '</textarea>'; |
| 1185 | 1185 | $form .= '<p>' . Xml::submitButton( wfMsg( 'watchlistedit-raw-submit' ) ) . '</p>'; |
| — | — | @@ -1208,7 +1208,7 @@ |
| 1209 | 1209 | $form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles', |
| 1210 | 1210 | 'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) ); |
| 1211 | 1211 | $tags = $this->getCollabWatchlistTags( $rlId ); |
| 1212 | | - foreach( $tags as $tag => $description ) |
| | 1212 | + foreach ( $tags as $tag => $description ) |
| 1213 | 1213 | $form .= htmlspecialchars( $tag ) . "|" . $description . "\n"; |
| 1214 | 1214 | $form .= '</textarea>'; |
| 1215 | 1215 | $form .= '<p>' . Xml::submitButton( wfMsg( 'collabwatchlistedit-tags-raw-submit' ) ) . '</p>'; |
| — | — | @@ -1238,7 +1238,7 @@ |
| 1239 | 1239 | $form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles', |
| 1240 | 1240 | 'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) ); |
| 1241 | 1241 | $users = $this->getCollabWatchlistUsers( $rlId ); |
| 1242 | | - foreach( $users as $userString ) |
| | 1242 | + foreach ( $users as $userString ) |
| 1243 | 1243 | $form .= htmlspecialchars( $userString ) . "\n"; |
| 1244 | 1244 | $form .= '</textarea>'; |
| 1245 | 1245 | $form .= '<p>' . Xml::submitButton( wfMsg( 'collabwatchlistedit-users-raw-submit' ) ) . '</p>'; |
| — | — | @@ -1302,11 +1302,11 @@ |
| 1303 | 1303 | array(), |
| 1304 | 1304 | array( 'known', 'noclasses' ) |
| 1305 | 1305 | ) . '<br />'; |
| 1306 | | - if( !isset($listIdsAndNames) || empty($listIdsAndNames) ) |
| | 1306 | + if ( !isset( $listIdsAndNames ) || empty( $listIdsAndNames ) ) |
| 1307 | 1307 | return $r; |
| 1308 | | - foreach( $listIdsAndNames as $listId => $listName) { |
| | 1308 | + foreach ( $listIdsAndNames as $listId => $listName ) { |
| 1309 | 1309 | $tools = array(); |
| 1310 | | - foreach( $modes as $mode => $subpage ) { |
| | 1310 | + foreach ( $modes as $mode => $subpage ) { |
| 1311 | 1311 | // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw' |
| 1312 | 1312 | $tools[] = $skin->link( |
| 1313 | 1313 | SpecialPage::getTitleFor( 'CollabWatchlist', $subpage ), |
| — | — | @@ -1331,13 +1331,13 @@ |
| 1332 | 1332 | * @return String an URL string |
| 1333 | 1333 | */ |
| 1334 | 1334 | public static function getUnsetTagUrl( $redirUrl, $pageName, $rlId, $tag, $rcId ) { |
| 1335 | | - return SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(array( |
| | 1335 | + return SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl( array( |
| 1336 | 1336 | 'action' => 'unsetTags', |
| 1337 | 1337 | 'redirTarget' => $redirUrl, |
| 1338 | 1338 | 'collabwatchlisttag' => $tag, |
| 1339 | 1339 | 'collabwatchlist' => $rlId, |
| 1340 | 1340 | 'collabwatchlistpage' => $pageName, |
| 1341 | 1341 | 'collabwatchlistrcid' => $rcId |
| 1342 | | - )); |
| | 1342 | + ) ); |
| 1343 | 1343 | } |
| 1344 | 1344 | } |