/** * Factory method for loading a skin of a given type * @param string $key 'monobook', 'standard', etc * @return Skin * @static */ static function &newFromKey($key) { global $wgStyleDirectory; $key = Skin::normalizeKey($key); $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; $className = 'Skin' . ucfirst($key); # Grab the skin class and initialise it. if (!class_exists($className)) { // Preload base classes to work around APC/PHP5 bug $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; if (file_exists($deps)) { include_once $deps; } require_once "{$wgStyleDirectory}/{$skinName}.php"; # Check if we got if not failback to default skin if (!class_exists($className)) { # DO NOT die if the class isn't found. This breaks maintenance # scripts and can cause a user account to be unrecoverable # except by SQL manipulation if a previously valid skin name # is no longer valid. wfDebug("Skin class does not exist: {$className}\n"); $className = 'SkinMonobook'; require_once "{$wgStyleDirectory}/MonoBook.php"; } } $skin = new $className(); return $skin; }
/** * Combine the language default options with any site-specific options * and add the default language variants. * * @return array Array of String options */ public static function getDefaultOptions() { global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin; static $defOpt = null; if (!defined('MW_PHPUNIT_TEST') && $defOpt !== null) { // Disabling this for the unit tests, as they rely on being able to change $wgContLang // mid-request and see that change reflected in the return value of this function. // Which is insane and would never happen during normal MW operation return $defOpt; } $defOpt = $wgDefaultUserOptions; // Default language setting $defOpt['language'] = $wgContLang->getCode(); foreach (LanguageConverter::$languagesWithVariants as $langCode) { $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-{$langCode}"] = $langCode; } foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) { $defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]); } $defOpt['skin'] = Skin::normalizeKey($wgDefaultSkin); Hooks::run('UserGetDefaultOptions', array(&$defOpt)); return $defOpt; }
/** * @access private */ function resetPrefs() { global $wgUser, $wgLang, $wgContLang, $wgAllowRealName; $this->mOldpass = $this->mNewpass = $this->mRetypePass = ''; $this->mUserEmail = $wgUser->getEmail(); $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = $wgAllowRealName ? $wgUser->getRealName() : ''; $this->mUserLanguage = $wgUser->getOption('language'); if (empty($this->mUserLanguage)) { # Quick hack for conversions, where this value is blank global $wgContLanguageCode; $this->mUserLanguage = $wgContLanguageCode; } $this->mUserVariant = $wgUser->getOption('variant'); $this->mEmailFlag = $wgUser->getOption('disablemail') == 1 ? 1 : 0; $this->mNick = $wgUser->getOption('nickname'); $this->mQuickbar = $wgUser->getOption('quickbar'); $this->mSkin = Skin::normalizeKey($wgUser->getOption('skin')); $this->mMath = $wgUser->getOption('math'); $this->mDate = $wgUser->getOption('date'); $this->mRows = $wgUser->getOption('rows'); $this->mCols = $wgUser->getOption('cols'); $this->mStubs = $wgUser->getOption('stubthreshold'); $this->mHourDiff = $wgUser->getOption('timecorrection'); // WERELATE removed // $this->mSearch = $wgUser->getOption( 'searchlimit' ); // $this->mSearchLines = $wgUser->getOption( 'contextlines' ); // $this->mSearchChars = $wgUser->getOption( 'contextchars' ); $this->mImageSize = $wgUser->getOption('imagesize'); $this->mThumbSize = $wgUser->getOption('thumbsize'); $this->mRecent = $wgUser->getOption('rclimit'); $this->mWatchlistEdits = $wgUser->getOption('wllimit'); $this->mUnderline = $wgUser->getOption('underline'); $this->mWatchlistDays = $wgUser->getOption('watchlistdays'); $togs = $wgLang->getUserToggles(); foreach ($togs as $tname) { $ttext = wfMsg('tog-' . $tname); $this->mToggles[$tname] = $wgUser->getOption($tname); } // WERELATE removed // $namespaces = $wgContLang->getNamespaces(); // foreach ( $namespaces as $i => $namespace ) { // if ( $i >= NS_MAIN ) { // $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i ); // } // } }
/** * Get the Skin object * * @return Skin */ public function getSkin() { if ($this->skin === null) { $skin = null; Hooks::run('RequestContextCreateSkin', [$this, &$skin]); $factory = SkinFactory::getDefaultInstance(); // If the hook worked try to set a skin from it if ($skin instanceof Skin) { $this->skin = $skin; } elseif (is_string($skin)) { // Normalize the key, just in case the hook did something weird. $normalized = Skin::normalizeKey($skin); $this->skin = $factory->makeSkin($normalized); } // If this is still null (the hook didn't run or didn't work) // then go through the normal processing to load a skin if ($this->skin === null) { if (!in_array('skin', $this->getConfig()->get('HiddenPrefs'))) { # get the user skin $userSkin = $this->getUser()->getOption('skin'); $userSkin = $this->getRequest()->getVal('useskin', $userSkin); } else { # if we're not allowing users to override, then use the default $userSkin = $this->getConfig()->get('DefaultSkin'); } // Normalize the key in case the user is passing gibberish // or has old preferences (bug 69566). $normalized = Skin::normalizeKey($userSkin); // Skin::normalizeKey will also validate it, so // this won't throw an exception $this->skin = $factory->makeSkin($normalized); } // After all that set a context on whatever skin got created $this->skin->setContext($this); } return $this->skin; }
/** * Factory method for loading a skin of a given type * @param string $key 'monobook', 'standard', etc. * @return Skin */ static function &newFromKey($key) { global $wgStyleDirectory; $key = Skin::normalizeKey($key); $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; $className = "Skin{$skinName}"; # Grab the skin class and initialise it. if (!MWInit::classExists($className)) { if (!defined('MW_COMPILED')) { require_once "{$wgStyleDirectory}/{$skinName}.php"; } # Check if we got if not fallback to default skin if (!MWInit::classExists($className)) { # DO NOT die if the class isn't found. This breaks maintenance # scripts and can cause a user account to be unrecoverable # except by SQL manipulation if a previously valid skin name # is no longer valid. wfDebug("Skin class does not exist: {$className}\n"); $className = 'SkinVector'; if (!defined('MW_COMPILED')) { require_once "{$wgStyleDirectory}/Vector.php"; } } } $skin = new $className($key); return $skin; }
/** * @access private */ function resetPrefs() { global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName, $wgLocalTZoffset; $this->mUserEmail = $wgUser->getEmail(); $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = $wgAllowRealName ? $wgUser->getRealName() : ''; # language value might be blank, default to content language $this->mUserLanguage = $wgUser->getOption('language', $wgContLanguageCode); $this->mUserVariant = $wgUser->getOption('variant'); $this->mEmailFlag = $wgUser->getOption('disablemail') == 1 ? 1 : 0; $this->mNick = $wgUser->getOption('nickname'); $this->mQuickbar = $wgUser->getOption('quickbar'); $this->mSkin = Skin::normalizeKey($wgUser->getOption('skin')); $this->mMath = $wgUser->getOption('math'); $this->mDate = $wgUser->getDatePreference(); $this->mRows = $wgUser->getOption('rows'); $this->mCols = $wgUser->getOption('cols'); $this->mStubs = $wgUser->getOption('stubthreshold'); $tz = $wgUser->getOption('timecorrection'); $data = explode('|', $tz, 3); $minDiff = null; switch ($data[0]) { case 'ZoneInfo': $this->mTimeZone = $tz; # Check if the specified TZ exists, and change to 'Offset' if # not. if (!function_exists('timezone_open') || @timezone_open($data[2]) === false) { $this->mTimeZone = 'Offset'; $minDiff = intval($data[1]); } break; case '': case 'System': $this->mTimeZone = 'System|' . $wgLocalTZoffset; break; case 'Offset': $this->mTimeZone = 'Offset'; $minDiff = intval($data[1]); break; default: $this->mTimeZone = 'Offset'; $data = explode(':', $tz, 2); if (count($data) == 2) { $data[0] = intval($data[0]); $data[1] = intval($data[1]); $minDiff = abs($data[0]) * 60 + $data[1]; if ($data[0] < 0) { $minDiff = -$minDiff; } } else { $minDiff = intval($data[0]) * 60; } break; } if (is_null($minDiff)) { $this->mHourDiff = ''; } else { $this->mHourDiff = sprintf('%+03d:%02d', floor($minDiff / 60), abs($minDiff) % 60); } $this->mSearch = $wgUser->getOption('searchlimit'); $this->mSearchLines = $wgUser->getOption('contextlines'); $this->mSearchChars = $wgUser->getOption('contextchars'); $this->mImageSize = $wgUser->getOption('imagesize'); $this->mThumbSize = $wgUser->getOption('thumbsize'); $this->mRecent = $wgUser->getOption('rclimit'); $this->mRecentDays = $wgUser->getOption('rcdays'); $this->mWatchlistEdits = $wgUser->getOption('wllimit'); $this->mUnderline = $wgUser->getOption('underline'); $this->mWatchlistDays = $wgUser->getOption('watchlistdays'); $this->mDisableMWSuggest = $wgUser->getBoolOption('disablesuggest'); $togs = User::getToggles(); foreach ($togs as $tname) { $this->mToggles[$tname] = $wgUser->getOption($tname); } $namespaces = $wgContLang->getNamespaces(); foreach ($namespaces as $i => $namespace) { if ($i >= NS_MAIN) { $this->mSearchNs[$i] = $wgUser->getOption('searchNs' . $i); } } wfRunHooks('ResetPreferences', array($this, $wgUser)); }
/** * Factory method for loading a skin of a given type * @param string $key 'monobook', 'vector', etc. * @return Skin * @deprecated since 1.24; Use SkinFactory instead */ static function &newFromKey($key) { wfDeprecated(__METHOD__, '1.24'); $key = Skin::normalizeKey($key); $factory = SkinFactory::getDefaultInstance(); // normalizeKey() guarantees that a skin with this key will exist. $skin = $factory->makeSkin($key); return $skin; }
public function appendSkins($property) { $data = array(); $allowed = Skin::getAllowedSkins(); $default = Skin::normalizeKey('default'); foreach (Skin::getSkinNames() as $name => $displayName) { $msg = $this->msg("skinname-{$name}"); $code = $this->getParameter('inlanguagecode'); if ($code && Language::isValidCode($code)) { $msg->inLanguage($code); } else { $msg->inContentLanguage(); } if ($msg->exists()) { $displayName = $msg->text(); } $skin = array('code' => $name); ApiResult::setContentValue($skin, 'name', $displayName); if (!isset($allowed[$name])) { $skin['unusable'] = true; } if ($name === $default) { $skin['default'] = true; } $data[] = $skin; } ApiResult::setIndexedTagName($data, 'skin'); return $this->getResult()->addValue('query', $property, $data); }
public function appendSkins($property) { $data = array(); $allowed = Skin::getAllowedSkins(); $default = Skin::normalizeKey('default'); foreach (Skin::getSkinNames() as $name => $displayName) { $skin = array('code' => $name); ApiResult::setContent($skin, $displayName); if (!isset($allowed[$name])) { $skin['unusable'] = ''; } if ($name === $default) { $skin['default'] = ''; } $data[] = $skin; } $this->getResult()->setIndexedTagName($data, 'skin'); return $this->getResult()->addValue('query', $property, $data); }
/** * @access private */ function resetPrefs() { global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName; $this->mOldpass = $this->mNewpass = $this->mRetypePass = ''; $this->mUserEmail = $wgUser->getEmail(); $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = $wgAllowRealName ? $wgUser->getRealName() : ''; # language value might be blank, default to content language $this->mUserLanguage = $wgUser->getOption('language', $wgContLanguageCode); $this->mUserVariant = $wgUser->getOption('variant'); $this->mEmailFlag = $wgUser->getOption('disablemail') == 1 ? 1 : 0; $this->mNick = $wgUser->getOption('nickname'); $this->mQuickbar = $wgUser->getOption('quickbar'); $this->mSkin = Skin::normalizeKey($wgUser->getOption('skin')); $this->mMath = $wgUser->getOption('math'); $this->mDate = $wgUser->getDatePreference(); $this->mRows = $wgUser->getOption('rows'); $this->mCols = $wgUser->getOption('cols'); $this->mStubs = $wgUser->getOption('stubthreshold'); $this->mHourDiff = $wgUser->getOption('timecorrection'); $this->mSearch = $wgUser->getOption('searchlimit'); $this->mSearchLines = $wgUser->getOption('contextlines'); $this->mSearchChars = $wgUser->getOption('contextchars'); $this->mImageSize = $wgUser->getOption('imagesize'); $this->mThumbSize = $wgUser->getOption('thumbsize'); $this->mRecent = $wgUser->getOption('rclimit'); $this->mRecentDays = $wgUser->getOption('rcdays'); $this->mWatchlistEdits = $wgUser->getOption('wllimit'); $this->mUnderline = $wgUser->getOption('underline'); $this->mWatchlistDays = $wgUser->getOption('watchlistdays'); $togs = User::getToggles(); foreach ($togs as $tname) { $this->mToggles[$tname] = $wgUser->getOption($tname); } $namespaces = $wgContLang->getNamespaces(); foreach ($namespaces as $i => $namespace) { // BizzWiki begin {{ if (!$wgUser->isAllowed('search', $i)) { continue; } // BizzWiki end }} if ($i >= NS_MAIN) { $this->mSearchNs[$i] = $wgUser->getOption('searchNs' . $i); } } }
/** * @access private */ function resetPrefs() { global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName; $this->mOldpass = $this->mNewpass = $this->mRetypePass = ''; $this->mUserEmail = $wgUser->getEmail(); $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); $this->mRealName = $wgAllowRealName ? $wgUser->getRealName() : ''; # language value might be blank, default to content language $this->mUserLanguage = $wgUser->getOption('language', $wgContLanguageCode); $this->mUserVariant = $wgUser->getOption('variant'); $this->mContentFilter = $wgUser->getOption('contentfilter', 0); $this->mEmailFlag = $wgUser->getOption('disablemail') == 1 ? 1 : 0; //XXADDED Marketing emails $this->mMarketingEmailFlag = $wgUser->getOption('disablemarketingemail') == 1 ? 1 : 0; $this->mAuthorEmailNotifications = $wgUser->getOption('enableauthoremail') == 1 ? 1 : 0; $this->mUserTalkNotifications = $wgUser->getOption('usertalknotifications'); if (class_exists('ThumbsUp')) { $this->mThumbsNotifications = $wgUser->getOption('thumbsnotifications'); $this->mThumbsEmailNotifications = $wgUser->getOption('thumbsemailnotifications'); } if (class_exists('RCTest')) { $this->mRCTest = $wgUser->getOption('rctest'); } $this->mNick = $wgUser->getOption('nickname'); $this->mQuickbar = $wgUser->getOption('quickbar'); $this->mSkin = Skin::normalizeKey($wgUser->getOption('skin')); $this->mMath = $wgUser->getOption('math'); $this->mDate = $wgUser->getDatePreference(); $this->mRows = $wgUser->getOption('rows'); $this->mCols = $wgUser->getOption('cols'); $this->mStubs = $wgUser->getOption('stubthreshold'); $this->mHourDiff = $wgUser->getOption('timecorrection'); $this->mImageSize = $wgUser->getOption('imagesize'); $this->mThumbSize = $wgUser->getOption('thumbsize'); $this->mRecent = $wgUser->getOption('rclimit'); $this->mRecentDays = $wgUser->getOption('rcdays'); $this->mWatchlistEdits = $wgUser->getOption('wllimit'); $this->mUnderline = $wgUser->getOption('underline'); $this->mWatchlistDays = $wgUser->getOption('watchlistdays'); // XXADDED $this->mDefaultEditor = $wgUser->getOption("defaulteditor"); $this->mIgnoreFanMail = $wgUser->getOption('ignorefanmail'); $this->mScrollTalk = $wgUser->getOption('scrolltalk'); $this->mHidePersistantSaveBar = $wgUser->getOption('hidepersistantsavebar'); $togs = User::getToggles(); foreach ($togs as $tname) { $this->mToggles[$tname] = $wgUser->getOption($tname); } wfRunHooks('ResetPreferences', array($this, $wgUser)); }
/** * Factory method for loading a skin of a given type * @param string $key 'monobook', 'standard', etc * @return Skin * @static */ function &newFromKey($key) { global $wgStyleDirectory; $key = Skin::normalizeKey($key); $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; # Grab the skin class and initialise it. wfSuppressWarnings(); // Preload base classes to work around APC/PHP5 bug include_once "{$wgStyleDirectory}/{$skinName}.deps.php"; wfRestoreWarnings(); require_once "{$wgStyleDirectory}/{$skinName}.php"; # Check if we got if not failback to default skin $className = 'Skin' . $skinName; if (!class_exists($className)) { # DO NOT die if the class isn't found. This breaks maintenance # scripts and can cause a user account to be unrecoverable # except by SQL manipulation if a previously valid skin name # is no longer valid. wfDebug("Skin class does not exist: {$className}\n"); $className = 'SkinStandard'; require_once "{$wgStyleDirectory}/Standard.php"; } $skin =& new $className(); return $skin; }
public static function getSkin($context, &$skin) { //there's probably a better way to check for this... if (!isset($_GET['useskin'])) { $key = $GLOBALS['wgDefaultSkin']; if (self::$pageSkin) { $key = new self::$pageSkin(); } $key = \Skin::normalizeKey($key); $skinNames = \Skin::getSkinNames(); $skinName = $skinNames[$key]; $className = "\\Skin{$skinName}"; $skin = new $className(); if (isset(self::$skinLayout)) { $skin->setLayout(self::$skinLayout); } } self::$skin = $skin; return true; }
/** * Combine the language default options with any site-specific options * and add the default language variants. * * @return array Array of String options */ public static function getDefaultOptions() { global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin; static $defOpt = null; static $defOptLang = null; if ($defOpt !== null && $defOptLang === $wgContLang->getCode()) { // $wgContLang does not change (and should not change) mid-request, // but the unit tests change it anyway, and expect this method to // return values relevant to the current $wgContLang. return $defOpt; } $defOpt = $wgDefaultUserOptions; // Default language setting $defOptLang = $wgContLang->getCode(); $defOpt['language'] = $defOptLang; foreach (LanguageConverter::$languagesWithVariants as $langCode) { $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-{$langCode}"] = $langCode; } // NOTE: don't use SearchEngineConfig::getSearchableNamespaces here, // since extensions may change the set of searchable namespaces depending // on user groups/permissions. foreach ($wgNamespacesToBeSearchedDefault as $nsnum => $val) { $defOpt['searchNs' . $nsnum] = (bool) $val; } $defOpt['skin'] = Skin::normalizeKey($wgDefaultSkin); Hooks::run('UserGetDefaultOptions', [&$defOpt]); return $defOpt; }