- static $mValidNamespaces = null;
-
- if ( is_null( $mValidNamespaces ) ) {
- global $wgContLang;
- $mValidNamespaces = array();
- foreach ( array_keys( $wgContLang->getNamespaces() ) as $ns ) {
- if ( $ns >= 0 ) {
- $mValidNamespaces[] = $ns;
+ return MWNamespace::getValidNamespaces();
+ }
+
+ /**
+ * Return true if we're to watch the page, false if not, null if no change.
+ * @param $watchlist String Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
+ * @param $titleObj Title the page under consideration
+ * @param $userOption String The user option to consider when $watchlist=preferences.
+ * If not set will magically default to either watchdefault or watchcreations
+ * @returns Boolean
+ */
+ protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
+
+ $userWatching = $titleObj->userIsWatching();
+
+ global $wgUser;
+ switch ( $watchlist ) {
+ case 'watch':
+ return true;
+
+ case 'unwatch':
+ return false;
+
+ case 'preferences':
+ # If the user is already watching, don't bother checking
+ if ( $userWatching ) {
+ return true;