/**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfig($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getVal('image');
     $this->variant = $request->getVal('variant');
     $this->format = $request->getVal('format');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfigSettings($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgContLang;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     $conf = $this->getConfig();
     // Build list of variables
     $vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
     Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
 /**
  * @param $resourceLoader ResourceLoader
  * @param $request WebRequest
  */
 public function __construct($resourceLoader, WebRequest $request)
 {
     global $wgDefaultSkin, $wgResourceLoaderDebug;
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug);
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     // Wikia - change begin - @author: wladek
     $this->sassParams = array();
     foreach ($request->getValues() as $key => $value) {
         if (startsWith($key, 'sass_')) {
             $this->sassParams[substr($key, strlen('sass_'))] = $value;
         }
     }
     ksort($this->sassParams);
     // Wikia - change end
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $wgDefaultSkin;
     }
 }
 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     $this->logger = $resourceLoader->getLogger();
     // Future developers: Avoid use of getVal() in this class, which performs
     // expensive UTF normalisation by default. Use getRawVal() instead.
     // Values here are either one of a finite number of internal IDs,
     // or previously-stored user input (e.g. titles, user names) that were passed
     // to this endpoint by ResourceLoader itself from the canonical value.
     // Values do not come directly from user input and need not match.
     // List of modules
     $modules = $request->getRawVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : [];
     // Various parameters
     $this->user = $request->getRawVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getRawVal('only', null);
     $this->version = $request->getRawVal('version', null);
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getRawVal('image');
     $this->variant = $request->getRawVal('variant');
     $this->format = $request->getRawVal('format');
     $this->skin = $request->getRawVal('skin');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
 /**
  * @param $resourceLoader ResourceLoader
  * @param $request WebRequest
  */
 public function __construct($resourceLoader, WebRequest $request)
 {
     global $wgDefaultSkin, $wgResourceLoaderDebug;
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug);
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $wgDefaultSkin;
     }
 }
 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);
 }
	/**
	 * @param $context ResourceLoaderContext
	 * @return array
	 */
	protected function getConfig( $context ) {
		global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
			$wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
			$wgVariantArticlePath, $wgActionPaths, $wgVersion,
			$wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
			$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
			$wgCookiePrefix, $wgResourceLoaderMaxQueryLength;

		$mainPage = Title::newMainPage();

		/**
		 * Namespace related preparation
		 * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
		 * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
		 */
		$namespaceIds = $wgContLang->getNamespaceIds();
		$caseSensitiveNamespaces = array();
		foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
			$namespaceIds[$wgContLang->lc( $name )] = $index;
			if ( !MWNamespace::isCapitalized( $index ) ) {
				$caseSensitiveNamespaces[] = $index;
			}
		}

		// Build list of variables
		$vars = array(
			'wgLoadScript' => $wgLoadScript,
			'debug' => $context->getDebug(),
			'skin' => $context->getSkin(),
			'stylepath' => $wgStylePath,
			'wgUrlProtocols' => wfUrlProtocols(),
			'wgArticlePath' => $wgArticlePath,
			'wgScriptPath' => $wgScriptPath,
			'wgScriptExtension' => $wgScriptExtension,
			'wgScript' => $wgScript,
			'wgVariantArticlePath' => $wgVariantArticlePath,
			// Force object to avoid "empty" associative array from
			// becoming [] instead of {} in JS (bug 34604)
			'wgActionPaths' => (object)$wgActionPaths,
			'wgServer' => $wgServer,
			'wgUserLanguage' => $context->getLanguage(),
			'wgContentLanguage' => $wgContLang->getCode(),
			'wgVersion' => $wgVersion,
			'wgEnableAPI' => $wgEnableAPI,
			'wgEnableWriteAPI' => $wgEnableWriteAPI,
			'wgMainPageTitle' => $mainPage->getPrefixedText(),
			'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
			'wgNamespaceIds' => $namespaceIds,
			'wgSiteName' => $wgSitename,
			'wgFileExtensions' => array_values( array_unique( $wgFileExtensions ) ),
			'wgDBname' => $wgDBname,
			// This sucks, it is only needed on Special:Upload, but I could
			// not find a way to add vars only for a certain module
			'wgFileCanRotate' => BitmapHandler::canRotate(),
			'wgAvailableSkins' => Skin::getSkinNames(),
			'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
			// MediaWiki sets cookies to have this prefix by default
			'wgCookiePrefix' => $wgCookiePrefix,
			'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
			'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
			'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
		);

		wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );

		return $vars;
	}
Example #10
0
 /**
  * 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;
 }
 /**
  * Displays form showing the list of installed gadgets
  */
 public function showMainForm()
 {
     global $wgContLang;
     $output = $this->getOutput();
     $this->setHeaders();
     $output->setPagetitle($this->msg('gadgets-title'));
     $output->addWikiMsg('gadgets-pagetext');
     $gadgets = GadgetRepo::singleton()->getStructuredList();
     if (!$gadgets) {
         return;
     }
     $lang = $this->getLanguage();
     $langSuffix = "";
     if ($lang->getCode() != $wgContLang->getCode()) {
         $langSuffix = "/" . $lang->getCode();
     }
     $listOpen = false;
     $editInterfaceMessage = $this->getUser()->isAllowed('editinterface') ? 'edit' : 'viewsource';
     foreach ($gadgets as $section => $entries) {
         if ($section !== false && $section !== '') {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-section-{$section}{$langSuffix}");
             $lnkTarget = $t ? Linker::link($t, $this->msg($editInterfaceMessage)->escaped(), array(), array('action' => 'edit')) : htmlspecialchars($section);
             $lnk = "    [{$lnkTarget}]";
             $ttext = $this->msg("gadget-section-{$section}")->parse();
             if ($listOpen) {
                 $output->addHTML(Xml::closeElement('ul') . "\n");
                 $listOpen = false;
             }
             $output->addHTML(Html::rawElement('h2', array(), $ttext . $lnk) . "\n");
         }
         /**
          * @var $gadget Gadget
          */
         foreach ($entries as $gadget) {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$gadget->getName()}{$langSuffix}");
             if (!$t) {
                 continue;
             }
             $links = array();
             $links[] = Linker::link($t, $this->msg($editInterfaceMessage)->escaped(), array(), array('action' => 'edit'));
             $links[] = Linker::link($this->getPageTitle("export/{$gadget->getName()}"), $this->msg('gadgets-export')->escaped());
             $ttext = $this->msg("gadget-{$gadget->getName()}")->parse();
             if (!$listOpen) {
                 $listOpen = true;
                 $output->addHTML(Xml::openElement('ul'));
             }
             $lnk = '  ' . $this->msg('parentheses')->rawParams($lang->pipeList($links))->escaped();
             $output->addHTML(Xml::openElement('li') . $ttext . $lnk . "<br />" . $this->msg('gadgets-uses')->escaped() . $this->msg('colon-separator')->escaped());
             $lnk = array();
             foreach ($gadget->getScriptsAndStyles() as $codePage) {
                 $t = Title::makeTitleSafe(NS_MEDIAWIKI, $codePage);
                 if (!$t) {
                     continue;
                 }
                 $lnk[] = Linker::link($t, htmlspecialchars($t->getText()));
             }
             $output->addHTML($lang->commaList($lnk));
             if ($gadget->getLegacyScripts()) {
                 $output->addHTML('<br />' . Html::rawElement('span', array('class' => 'mw-gadget-legacy errorbox'), $this->msg('gadgets-legacy')->parse()));
             }
             $rights = array();
             foreach ($gadget->getRequiredRights() as $right) {
                 $rights[] = '* ' . $this->msg("right-{$right}")->plain();
             }
             if (count($rights)) {
                 $output->addHTML('<br />' . $this->msg('gadgets-required-rights', implode("\n", $rights), count($rights))->parse());
             }
             $skins = array();
             $validskins = Skin::getSkinNames();
             foreach ($gadget->getRequiredSkins() as $skinid) {
                 if (isset($validskins[$skinid])) {
                     $skins[] = $this->msg("skinname-{$skinid}")->plain();
                 } else {
                     $skins[] = $skinid;
                 }
             }
             if (count($skins)) {
                 $output->addHTML('<br />' . $this->msg('gadgets-required-skins', $lang->commaList($skins))->numParams(count($skins))->parse());
             }
             if ($gadget->isOnByDefault()) {
                 $output->addHTML('<br />' . $this->msg('gadgets-default')->parse());
             }
             $output->addHTML(Xml::closeElement('li') . "\n");
         }
     }
     if ($listOpen) {
         $output->addHTML(Xml::closeElement('ul') . "\n");
     }
 }
Example #12
0
    /**
     * @access private
     */
    function mainPrefsForm($status, $message = '')
    {
        global $wgUser, $wgOut, $wgLang, $wgContLang;
        global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
        global $wgDisableLangConversion;
        global $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifMinorEdits;
        global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
        global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
        global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
        $wgOut->setPageTitle(wfMsg('preferences'));
        $wgOut->setArticleRelated(false);
        $wgOut->setRobotpolicy('noindex,nofollow');
        if ($this->mSuccess || 'success' == $status) {
            $wgOut->addWikitext('<div class="successbox"><strong>' . wfMsg('savedprefs') . '</strong></div>');
        } else {
            if ('error' == $status) {
                $wgOut->addWikitext('<div class="errorbox"><strong>' . $message . '</strong></div>');
            } else {
                if ('' != $status) {
                    $wgOut->addWikitext($message . "\n----");
                }
            }
        }
        $qbs = $wgLang->getQuickbarSettings();
        $skinNames = $wgLang->getSkinNames();
        $mathopts = $wgLang->getMathNames();
        $dateopts = $wgLang->getDateFormats();
        $togs = $wgLang->getUserToggles();
        $titleObj = Title::makeTitle(NS_SPECIAL, 'Preferences');
        $action = $titleObj->escapeLocalURL();
        # Pre-expire some toggles so they won't show if disabled
        $this->mUsedToggles['shownumberswatching'] = true;
        $this->mUsedToggles['showupdated'] = true;
        $this->mUsedToggles['enotifwatchlistpages'] = true;
        $this->mUsedToggles['enotifusertalkpages'] = true;
        $this->mUsedToggles['enotifminoredits'] = true;
        $this->mUsedToggles['enotifrevealaddr'] = true;
        $this->mUsedToggles['uselivepreview'] = true;
        # Enotif
        # <FIXME>
        $this->mUserEmail = htmlspecialchars($this->mUserEmail);
        $this->mRealName = htmlspecialchars($this->mRealName);
        $rawNick = $this->mNick;
        $this->mNick = htmlspecialchars($this->mNick);
        if (!$this->mEmailFlag) {
            $emfc = 'checked="checked"';
        } else {
            $emfc = '';
        }
        if ($wgEmailAuthentication && $this->mUserEmail != '') {
            if ($wgUser->getEmailAuthenticationTimestamp()) {
                $emailauthenticated = wfMsg('emailauthenticated', $wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true)) . '<br />';
                $disableEmailPrefs = false;
            } else {
                $disableEmailPrefs = true;
                $skin = $wgUser->getSkin();
                $emailauthenticated = wfMsg('emailnotauthenticated') . '<br />' . $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Confirmemail'), wfMsg('emailconfirmlink'));
            }
        } else {
            $emailauthenticated = '';
            $disableEmailPrefs = false;
        }
        if ($this->mUserEmail == '') {
            $emailauthenticated = wfMsg('noemailprefs');
        }
        // WERELATE removed
        //		$ps = $this->namespacesCheckboxes();
        $enotifwatchlistpages = $wgEnotifWatchlist ? $this->getToggle('enotifwatchlistpages', false, $disableEmailPrefs) : '';
        $enotifusertalkpages = $wgEnotifUserTalk ? $this->getToggle('enotifusertalkpages', false, $disableEmailPrefs) : '';
        $enotifminoredits = $wgEnotifWatchlist && $wgEnotifMinorEdits ? $this->getToggle('enotifminoredits', false, $disableEmailPrefs) : '';
        $enotifrevealaddr = ($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress ? $this->getToggle('enotifrevealaddr', false, $disableEmailPrefs) : '';
        $prefs_help_email_enotif = $wgEnotifWatchlist || $wgEnotifUserTalk ? ' ' . wfMsg('prefs-help-email-enotif') : '';
        $prefs_help_realname = '';
        # </FIXME>
        $wgOut->addHTML("<form action=\"{$action}\" method='post'>");
        $wgOut->addHTML("<div id='preferences'>");
        # User data
        #
        $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
        $wgOut->addHTML($this->addRow(wfMsg('username'), $wgUser->getName()));
        $wgOut->addHTML($this->addRow(wfMsg('uid'), $wgUser->getID()));
        if ($wgAllowRealName) {
            $wgOut->addHTML($this->addRow('<label for="wpRealName">' . wfMsg('yourrealname') . '</label>', "<input type='text' name='wpRealName' id='wpRealName' value=\"{$this->mRealName}\" size='25' />"));
        }
        if ($wgEnableEmail) {
            $wgOut->addHTML($this->addRow('<label for="wpUserEmail">' . wfMsg('youremail') . '</label>', "<input type='text' name='wpUserEmail' id='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"));
        }
        global $wgParser;
        if (!empty($this->mToggles['fancysig']) && false === $wgParser->validateSig($rawNick)) {
            $invalidSig = $this->addRow('&nbsp;', '<span class="error">' . wfMsgHtml('badsig') . '<span>');
        } else {
            $invalidSig = '';
        }
        $wgOut->addHTML($this->addRow('<label for="wpNick">' . wfMsg('yournick') . '</label>', "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />") . $invalidSig . $this->addRow('&nbsp;', $this->getToggle('fancysig')));
        /**
         * Make sure the site language is in the list; a custom language code
         * might not have a defined name...
         */
        $languages = $wgLang->getLanguageNames();
        if (!array_key_exists($wgContLanguageCode, $languages)) {
            $languages[$wgContLanguageCode] = $wgContLanguageCode;
        }
        ksort($languages);
        /**
         * If a bogus value is set, default to the content language.
         * Otherwise, no default is selected and the user ends up
         * with an Afrikaans interface since it's first in the list.
         */
        $selectedLang = isset($languages[$this->mUserLanguage]) ? $this->mUserLanguage : $wgContLanguageCode;
        $selbox = null;
        foreach ($languages as $code => $name) {
            global $IP;
            /* only add languages that have a file */
            $langfile = "{$IP}/languages/Language" . str_replace('-', '_', ucfirst($code)) . ".php";
            if (file_exists($langfile) || $code == $wgContLanguageCode) {
                $sel = $code == $selectedLang ? ' selected="selected"' : '';
                $selbox .= "<option value=\"{$code}\"{$sel}>{$code} - {$name}</option>\n";
            }
        }
        $wgOut->addHTML($this->addRow('<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>', "<select name='wpUserLanguage' id='wpUserLanguage'>{$selbox}</select>"));
        /* see if there are multiple language variants to choose from*/
        if (!$wgDisableLangConversion) {
            $variants = $wgContLang->getVariants();
            $variantArray = array();
            foreach ($variants as $v) {
                $v = str_replace('_', '-', strtolower($v));
                if (array_key_exists($v, $languages)) {
                    // If it doesn't have a name, we'll pretend it doesn't exist
                    $variantArray[$v] = $languages[$v];
                }
            }
            $selbox = null;
            foreach ($variantArray as $code => $name) {
                $sel = $code == $this->mUserVariant ? 'selected="selected"' : '';
                $selbox .= "<option value=\"{$code}\" {$sel}>{$code} - {$name}</option>";
            }
            if (count($variantArray) > 1) {
                $wgOut->addHtml($this->addRow(wfMsg('yourvariant'), "<select name='wpUserVariant'>{$selbox}</select>"));
            }
        }
        // WERELATE ADDED
        if ($wgUser->getOption('wrnoads') > '') {
            $donateLink = '';
            if ($wgUser->getOption('wrnoads') < wfTimestampNow()) {
                $donateLink = ' - <a href="/wiki/WeRelate:Donate">Donate</a>';
            }
            $wgOut->addHTML($this->addRow('<label for="wrNoAds">' . 'Ads disabled until:' . '</label>', '<span id="wrNoAds">' . $wgLang->date($wgUser->getOption('wrnoads')) . $donateLink . '</span>'));
        }
        $wgOut->addHTML('</table>');
        # Password
        if ($wgAuth->allowPasswordChange()) {
            $this->mOldpass = htmlspecialchars($this->mOldpass);
            $this->mNewpass = htmlspecialchars($this->mNewpass);
            $this->mRetypePass = htmlspecialchars($this->mRetypePass);
            $wgOut->addHTML('<fieldset><legend>' . wfMsg('changepassword') . '</legend><table>');
            $wgOut->addHTML($this->addRow('<label for="wpOldpass">' . wfMsg('oldpassword') . '</label>', "<input type='password' name='wpOldpass' id='wpOldpass' value=\"{$this->mOldpass}\" size='20' />") . $this->addRow('<label for="wpNewpass">' . wfMsg('newpassword') . '</label>', "<input type='password' name='wpNewpass' id='wpNewpass' value=\"{$this->mNewpass}\" size='20' />") . $this->addRow('<label for="wpRetypePass">' . wfMsg('retypenew') . '</label>', "<input type='password' name='wpRetypePass' id='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />") . "</table>\n" . $this->getToggle("rememberpassword") . "</fieldset>\n\n");
        }
        # <FIXME>
        # Enotif
        if ($wgEnableEmail) {
            $wgOut->addHTML('<fieldset><legend>' . wfMsg('email') . '</legend>');
            $wgOut->addHTML($emailauthenticated . $enotifrevealaddr . $enotifwatchlistpages . $enotifusertalkpages . $enotifminoredits);
            if ($wgEnableUserEmail) {
                $emf = wfMsg('allowemail');
                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
                $wgOut->addHTML("<div><input type='checkbox' {$emfc} {$disabled} value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>{$emf}</label></div>");
            }
            $wgOut->addHTML('</fieldset>');
        }
        # </FIXME>
        # Show little "help" tips for the real name and email address options
        if ($wgAllowRealName || $wgEnableEmail) {
            if ($wgAllowRealName) {
                $tips[] = wfMsg('prefs-help-realname');
            }
            if ($wgEnableEmail) {
                $tips[] = wfMsg('prefs-help-email');
            }
            $wgOut->addHtml('<div class="prefsectiontip">' . implode('<br />', $tips) . '</div>');
        }
        $wgOut->addHTML('</fieldset>');
        # Quickbar
        #
        if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
            $wgOut->addHtml("<fieldset>\n<legend>" . wfMsg('qbsettings') . "</legend>\n");
            for ($i = 0; $i < count($qbs); ++$i) {
                if ($i == $this->mQuickbar) {
                    $checked = ' checked="checked"';
                } else {
                    $checked = "";
                }
                $wgOut->addHTML("<div><label><input type='radio' name='wpQuickbar' value=\"{$i}\"{$checked} />{$qbs[$i]}</label></div>\n");
            }
            $wgOut->addHtml("</fieldset>\n\n");
        } else {
            # Need to output a hidden option even if the relevant skin is not in use,
            # otherwise the preference will get reset to 0 on submit
            $wgOut->addHtml(wfHidden('wpQuickbar', $this->mQuickbar));
        }
        # Skin
        #
        $wgOut->addHTML("<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n");
        $mptitle = Title::newMainPage();
        $previewtext = wfMsg('skinpreview');
        # Only show members of Skin::getSkinNames() rather than
        # $skinNames (skins is all skin names from Language.php)
        $validSkinNames = Skin::getSkinNames();
        foreach ($validSkinNames as $skinkey => $skinname) {
            if (in_array($skinkey, $wgSkipSkins)) {
                continue;
            }
            $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
            $sn = isset($skinNames[$skinkey]) ? $skinNames[$skinkey] : $skinname;
            $mplink = htmlspecialchars($mptitle->getLocalURL("useskin={$skinkey}"));
            $previewlink = "<a target='_blank' href=\"{$mplink}\">{$previewtext}</a>";
            if ($skinkey == $wgDefaultSkin) {
                $sn .= ' (' . wfMsg('default') . ')';
            }
            $wgOut->addHTML("<input type='radio' name='wpSkin' id=\"wpSkin{$skinkey}\" value=\"{$skinkey}\"{$checked} /> <label for=\"wpSkin{$skinkey}\">{$sn}</label> {$previewlink}<br />\n");
        }
        $wgOut->addHTML("</fieldset>\n\n");
        # Math
        #
        global $wgUseTeX;
        if ($wgUseTeX) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('math') . '</legend>');
            foreach ($mathopts as $k => $v) {
                $checked = $k == $this->mMath ? ' checked="checked"' : '';
                $wgOut->addHTML("<div><label><input type='radio' name='wpMath' value=\"{$k}\"{$checked} /> " . wfMsg($v) . "</label></div>\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Files
        #
        $wgOut->addHTML("<fieldset>\n\t\t\t<legend>" . wfMsg('files') . "</legend>\n\t\t\t<div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
        $imageLimitOptions = null;
        foreach ($wgImageLimits as $index => $limits) {
            $selected = $index == $this->mImageSize ? 'selected="selected"' : '';
            $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}" . wfMsgHtml('unit-pixel') . "</option>\n";
        }
        $imageThumbOptions = null;
        $wgOut->addHTML("{$imageLimitOptions}</select></div>\n\t\t\t\t<div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
        foreach ($wgThumbLimits as $index => $size) {
            $selected = $index == $this->mThumbSize ? 'selected="selected"' : '';
            $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}" . wfMsgHtml('unit-pixel') . "</option>\n";
        }
        $wgOut->addHTML("{$imageThumbOptions}</select></div></fieldset>\n\n");
        # Date format
        #
        # Date/Time
        #
        $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('datetime') . "</legend>\n");
        if ($dateopts) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n");
            $idCnt = 0;
            $epoch = '20010408091234';
            foreach ($dateopts as $key => $option) {
                if ($key == MW_DATE_DEFAULT) {
                    $formatted = wfMsgHtml('datedefault');
                } else {
                    $formatted = htmlspecialchars($wgLang->timeanddate($epoch, false, $key));
                }
                $key == $this->mDate ? $checked = ' checked="checked"' : ($checked = '');
                $wgOut->addHTML("<div><input type='radio' name=\"wpDate\" id=\"wpDate{$idCnt}\" " . "value=\"{$key}\"{$checked} /> <label for=\"wpDate{$idCnt}\">{$formatted}</label></div>\n");
                $idCnt++;
            }
            $wgOut->addHTML("</fieldset>\n");
        }
        $nowlocal = $wgLang->time($now = wfTimestampNow(), true);
        $nowserver = $wgLang->time($now, false);
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('timezonelegend') . '</legend><table>' . $this->addRow(wfMsg('servertime'), $nowserver) . $this->addRow(wfMsg('localtime'), $nowlocal) . $this->addRow('<label for="wpHourDiff">' . wfMsg('timezoneoffset') . '</label>', "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars($this->mHourDiff) . "\" size='6' />") . "<tr><td colspan='2'>\n\t\t\t\t<input type='button' value=\"" . wfMsg('guesstimezone') . "\"\n\t\t\t\tonclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />\n\t\t\t\t</td></tr></table></fieldset>\n\t\t\t<div class='prefsectiontip'>¹" . wfMsg('timezonetext') . "</div>\n\t\t</fieldset>\n\n");
        # Editing
        #
        global $wgLivePreview, $wgUseRCPatrol;
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('textboxsize') . '</legend>
			<div>' . wfInputLabel(wfMsg('rows'), 'wpRows', 'wpRows', 3, $this->mRows) . ' ' . wfInputLabel(wfMsg('columns'), 'wpCols', 'wpCols', 3, $this->mCols) . "</div>" . $this->getToggles(array('editsection', 'editsectiononrightclick', 'editondblclick', 'editwidth', 'showtoolbar', 'previewonfirst', 'previewontop', 'watchcreations', 'watchdefault', 'minordefault', 'externaleditor', 'externaldiff', $wgLivePreview ? 'uselivepreview' : false, $wgUser->isAllowed('patrol') && $wgUseRCPatrol ? 'autopatrol' : false, 'forceeditsummary')) . '</fieldset>');
        $this->mUsedToggles['autopatrol'] = true;
        # Don't show this up for users who can't; the handler below is dumb and doesn't know it
        $wgOut->addHTML('<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>' . wfInputLabel(wfMsg('recentchangescount'), 'wpRecent', 'wpRecent', 3, $this->mRecent) . $this->getToggles(array('hideminor', $wgRCShowWatchingUsers ? 'shownumberswatching' : false, 'usenewrc')) . '</fieldset>');
        # Watchlist
        $wgOut->addHTML('<fieldset><legend>' . wfMsgHtml('prefs-watchlist') . '</legend>');
        $wgOut->addHTML(wfInputLabel(wfMsg('prefs-watchlist-days'), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays));
        $wgOut->addHTML('<br /><br />');
        # Spacing
        $wgOut->addHTML($this->getToggles(array('watchlisthideown', 'watchlisthidebots', 'extendwatchlist')));
        $wgOut->addHTML(wfInputLabel(wfMsg('prefs-watchlist-edits'), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits));
        $wgOut->addHTML('</fieldset>');
        # Search
        // WERELATE removed
        //		$wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
        //			$this->addRow(
        //				wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
        //				wfInput( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
        //			) .
        //			$this->addRow(
        //				wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
        //				wfInput( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
        //			) .
        //			$this->addRow(
        //				wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
        //				wfInput( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
        //			) .
        //		"</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
        # Misc
        #
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
        $wgOut->addHTML(wfInputLabel(wfMsg('stubthreshold'), 'wpStubs', 'wpStubs', 6, $this->mStubs));
        $msgUnderline = htmlspecialchars(wfMsg('tog-underline'));
        $msgUnderlinenever = htmlspecialchars(wfMsg('underline-never'));
        $msgUnderlinealways = htmlspecialchars(wfMsg('underline-always'));
        $msgUnderlinedefault = htmlspecialchars(wfMsg('underline-default'));
        $uopt = $wgUser->getOption("underline");
        $s0 = $uopt == 0 ? ' selected="selected"' : '';
        $s1 = $uopt == 1 ? ' selected="selected"' : '';
        $s2 = $uopt == 2 ? ' selected="selected"' : '';
        $wgOut->addHTML("\n<div class='toggle'><label for='wpOpunderline'>{$msgUnderline}</label>\n<select name='wpOpunderline' id='wpOpunderline'>\n<option value=\"0\"{$s0}>{$msgUnderlinenever}</option>\n<option value=\"1\"{$s1}>{$msgUnderlinealways}</option>\n<option value=\"2\"{$s2}>{$msgUnderlinedefault}</option>\n</select>\n</div>\n");
        foreach ($togs as $tname) {
            if (!array_key_exists($tname, $this->mUsedToggles)) {
                $wgOut->addHTML($this->getToggle($tname));
            }
        }
        $wgOut->addHTML('</fieldset>');
        $token = $wgUser->editToken();
        $wgOut->addHTML("\n\t<div id='prefsubmit'>\n\t<div>\n\t\t<input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml('saveprefs') . "\" accesskey=\"" . wfMsgHtml('accesskey-save') . "\" title=\"" . wfMsgHtml('tooltip-save') . "\" />\n\t\t<input type='submit' name='wpReset' value=\"" . wfMsgHtml('resetprefs') . "\" />\n\t</div>\n\n\t</div>\n\n\t<input type='hidden' name='wpEditToken' value='{$token}' />\n\t</div></form>\n");
        $wgOut->addWikiText('<div class="prefcache">' . wfMsg('clearyourcache') . '</div>');
    }
Example #13
0
 /**
  * Checks whether the user entered a skin name in uppercase,
  * e.g. "User:Example/Monobook.css" instead of "monobook.css"
  *
  * @return bool
  */
 protected function isWrongCaseCssJsPage()
 {
     if ($this->mTitle->isCssJsSubpage()) {
         $name = $this->mTitle->getSkinFromCssJsSubpage();
         $skins = array_merge(array_keys(Skin::getSkinNames()), array('common'));
         return !in_array($name, $skins) && in_array(strtolower($name), $skins);
     } else {
         return false;
     }
 }
Example #14
0
 /**
  * @static
  * @param User $user
  * @param Array $defaultPreferences
  * @return bool
  */
 public static function onGetPreferences($user, &$defaultPreferences)
 {
     global $wgEnableAnswers, $wgForceSkin, $wgAdminSkin, $wgDefaultSkin, $wgSkinPreviewPage, $wgSkipSkins, $wgSkipOldSkins, $wgEnableUserPreferencesV2Ext;
     // hide default MediaWiki skin fieldset
     unset($defaultPreferences['skin']);
     $mSkin = $user->getGlobalPreference('skin');
     // hacks for Answers
     if (!empty($wgEnableAnswers)) {
         $mSkin = 'answers';
     }
     // no skin settings at all when skin is forced
     if (!empty($wgForceSkin)) {
         return true;
     }
     if (!empty($wgAdminSkin)) {
         $defaultSkinKey = $wgAdminSkin;
     } else {
         if (!empty($wgDefaultTheme)) {
             $defaultSkinKey = $wgDefaultSkin . '-' . $wgDefaultTheme;
         } else {
             $defaultSkinKey = $wgDefaultSkin;
         }
     }
     // load list of skin names
     $validSkinNames = Skin::getSkinNames();
     // and sort them
     foreach ($validSkinNames as $skinkey => &$skinname) {
         if (isset($skinNames[$skinkey])) {
             $skinname = $skinNames[$skinkey];
         }
     }
     asort($validSkinNames);
     $previewtext = wfMsg('skin-preview');
     if (isset($wgSkinPreviewPage) && is_string($wgSkinPreviewPage)) {
         $previewLinkTemplate = Title::newFromText($wgSkinPreviewPage)->getLocalURL('useskin=');
     } else {
         $mptitle = Title::newMainPage();
         $previewLinkTemplate = $mptitle->getLocalURL('useskin=');
     }
     $oldSkinNames = array();
     foreach ($validSkinNames as $skinKey => $skinVal) {
         if ($skinKey == 'oasis' || (in_array($skinKey, $wgSkipSkins) || in_array($skinKey, $wgSkipOldSkins)) && !($skinKey == $mSkin)) {
             continue;
         }
         $oldSkinNames[$skinKey] = $skinVal;
     }
     $skins = array();
     $skins[wfMsg('new-look')] = 'oasis';
     // display radio buttons for rest of skin
     if (count($oldSkinNames) > 0) {
         foreach ($oldSkinNames as $skinKey => $skinVal) {
             $previewlink = $wgEnableUserPreferencesV2Ext ? '' : ' <a target="_blank" href="' . htmlspecialchars($previewLinkTemplate . $skinKey) . '">' . $previewtext . '</a>';
             $skins[$skinVal . $previewlink . ($skinKey == $defaultSkinKey ? ' (' . wfMsg('default') . ')' : '')] = $skinKey;
         }
     }
     $defaultPreferencesTemp = array();
     foreach ($defaultPreferences as $k => $v) {
         $defaultPreferencesTemp[$k] = $v;
         if ($k == 'oldsig') {
             $defaultPreferencesTemp['skin'] = array('type' => 'radio', 'options' => $skins, 'label' => '&nbsp;', 'section' => 'personal/layout');
             $defaultPreferencesTemp['showAds'] = array('type' => 'toggle', 'label-message' => 'tog-showAds', 'section' => 'personal/layout');
         }
     }
     $defaultPreferences = $defaultPreferencesTemp;
     return true;
 }
Example #15
0
 /**
  * Displays form showing the list of installed gadgets
  */
 public function showMainForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgContLang;
     $skin = $wgUser->getSkin();
     $this->setHeaders();
     $wgOut->setPagetitle(wfMsg("gadgets-title"));
     $wgOut->addWikiMsg('gadgets-pagetext');
     $gadgets = Gadget::loadStructuredList();
     if (!$gadgets) {
         return;
     }
     $lang = "";
     if ($wgLang->getCode() != $wgContLang->getCode()) {
         $lang = "/" . $wgLang->getCode();
     }
     $listOpen = false;
     $msgOpt = array('parseinline', 'parsemag');
     $editInterfaceAllowed = $wgUser->isAllowed('editinterface');
     foreach ($gadgets as $section => $entries) {
         if ($section !== false && $section !== '') {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-section-{$section}{$lang}");
             if ($editInterfaceAllowed) {
                 $lnkTarget = $t ? $skin->link($t, wfMsgHTML('edit'), array(), array('action' => 'edit')) : htmlspecialchars($section);
                 $lnk = "&#160; &#160; [{$lnkTarget}]";
             } else {
                 $lnk = '';
             }
             $ttext = wfMsgExt("gadget-section-{$section}", $msgOpt);
             if ($listOpen) {
                 $wgOut->addHTML(Xml::closeElement('ul') . "\n");
                 $listOpen = false;
             }
             $wgOut->addHTML(Html::rawElement('h2', array(), $ttext . $lnk) . "\n");
         }
         foreach ($entries as $gadget) {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$gadget->getName()}{$lang}");
             if (!$t) {
                 continue;
             }
             $links = array();
             if ($editInterfaceAllowed) {
                 $links[] = $skin->link($t, wfMsgHTML('edit'), array(), array('action' => 'edit'));
             }
             $links[] = $skin->link($this->getTitle("export/{$gadget->getName()}"), wfMsgHtml('gadgets-export'));
             $ttext = wfMsgExt("gadget-{$gadget->getName()}", $msgOpt);
             if (!$listOpen) {
                 $listOpen = true;
                 $wgOut->addHTML(Xml::openElement('ul'));
             }
             $lnk = '&#160;&#160;' . wfMsg('parentheses', $wgLang->pipeList($links));
             $wgOut->addHTML(Xml::openElement('li') . $ttext . $lnk . "<br />" . wfMsgHTML('gadgets-uses') . wfMsg('colon-separator'));
             $lnk = array();
             foreach ($gadget->getScriptsAndStyles() as $codePage) {
                 $t = Title::makeTitleSafe(NS_MEDIAWIKI, $codePage);
                 if (!$t) {
                     continue;
                 }
                 $lnk[] = $skin->link($t, htmlspecialchars($t->getText()));
             }
             $wgOut->addHTML($wgLang->commaList($lnk));
             $rights = array();
             foreach ($gadget->getRequiredRights() as $right) {
                 $rights[] = '* ' . wfMessage("right-{$right}")->plain();
             }
             if (count($rights)) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-required-rights', implode("\n", $rights), count($rights))->parse());
             }
             $skins = array();
             $validskins = Skin::getSkinNames();
             foreach ($gadget->getRequiredSkins() as $skinid) {
                 if (isset($validskins[$skinid])) {
                     $skins[] = wfMessage("skinname-{$skinid}")->plain();
                 } else {
                     $skins[] = $skinid;
                 }
             }
             if (count($skins)) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-required-skins', $wgLang->commaList($skins), count($skins))->parse());
             }
             if ($gadget->isOnByDefault()) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-default')->parse());
             }
             $wgOut->addHTML(Xml::closeElement('li') . "\n");
         }
     }
     if ($listOpen) {
         $wgOut->addHTML(Xml::closeElement('ul') . "\n");
     }
 }
    /**
     * @access private
     */
    function mainPrefsForm($status, $message = '')
    {
        global $wgUser, $wgOut, $wgLang, $wgContLang;
        global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
        global $wgDisableLangConversion;
        global $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifMinorEdits;
        global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
        global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
        global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
        $wgOut->setPageTitle(wfMsg('preferences'));
        $wgOut->setArticleRelated(false);
        $wgOut->setRobotpolicy('noindex,nofollow');
        $wgOut->disallowUserJs();
        # Prevent hijacked user scripts from sniffing passwords etc.
        if ($this->mSuccess || 'success' == $status) {
            $wgOut->addWikitext('<div class="successbox"><strong>' . wfMsg('savedprefs') . '</strong></div>');
        } else {
            if ('error' == $status) {
                $wgOut->addWikitext('<div class="errorbox"><strong>' . $message . '</strong></div>');
            } else {
                if ('' != $status) {
                    $wgOut->addWikitext($message . "\n----");
                }
            }
        }
        $qbs = $wgLang->getQuickbarSettings();
        $skinNames = $wgLang->getSkinNames();
        $mathopts = $wgLang->getMathNames();
        $dateopts = $wgLang->getDatePreferences();
        $togs = User::getToggles();
        $titleObj = SpecialPage::getTitleFor('Preferences');
        $action = $titleObj->escapeLocalURL();
        # Pre-expire some toggles so they won't show if disabled
        $this->mUsedToggles['shownumberswatching'] = true;
        $this->mUsedToggles['showupdated'] = true;
        $this->mUsedToggles['enotifwatchlistpages'] = true;
        $this->mUsedToggles['enotifusertalkpages'] = true;
        $this->mUsedToggles['enotifminoredits'] = true;
        $this->mUsedToggles['enotifrevealaddr'] = true;
        $this->mUsedToggles['ccmeonemails'] = true;
        $this->mUsedToggles['uselivepreview'] = true;
        if (!$this->mEmailFlag) {
            $emfc = 'checked="checked"';
        } else {
            $emfc = '';
        }
        if ($wgEmailAuthentication && $this->mUserEmail != '') {
            if ($wgUser->getEmailAuthenticationTimestamp()) {
                $emailauthenticated = wfMsg('emailauthenticated', $wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true)) . '<br />';
                $disableEmailPrefs = false;
            } else {
                $disableEmailPrefs = true;
                $skin = $wgUser->getSkin();
                $emailauthenticated = wfMsg('emailnotauthenticated') . '<br />' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Confirmemail'), wfMsg('emailconfirmlink')) . '<br />';
            }
        } else {
            $emailauthenticated = '';
            $disableEmailPrefs = false;
        }
        if ($this->mUserEmail == '') {
            $emailauthenticated = wfMsg('noemailprefs') . '<br />';
        }
        $ps = $this->namespacesCheckboxes();
        $enotifwatchlistpages = $wgEnotifWatchlist ? $this->getToggle('enotifwatchlistpages', false, $disableEmailPrefs) : '';
        $enotifusertalkpages = $wgEnotifUserTalk ? $this->getToggle('enotifusertalkpages', false, $disableEmailPrefs) : '';
        $enotifminoredits = $wgEnotifWatchlist && $wgEnotifMinorEdits ? $this->getToggle('enotifminoredits', false, $disableEmailPrefs) : '';
        $enotifrevealaddr = ($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress ? $this->getToggle('enotifrevealaddr', false, $disableEmailPrefs) : '';
        # </FIXME>
        $wgOut->addHTML("<form action=\"{$action}\" method='post'>");
        $wgOut->addHTML("<div id='preferences'>");
        # User data
        $wgOut->addHTML(Xml::openElement('fieldset ') . Xml::element('legend', null, wfMsg('prefs-personal')) . Xml::openElement('table') . $this->tableRow(Xml::element('h2', null, wfMsg('prefs-personal'))));
        $userInformationHtml = $this->tableRow(wfMsgHtml('username'), htmlspecialchars($wgUser->getName())) . $this->tableRow(wfMsgHtml('uid'), htmlspecialchars($wgUser->getID())) . $this->tableRow(wfMsgHtml('prefs-edits'), $wgLang->formatNum(User::edits($wgUser->getId())));
        if (wfRunHooks('PreferencesUserInformationPanel', array($this, &$userInformationHtml))) {
            $wgOut->addHtml($userInformationHtml);
        }
        if ($wgAllowRealName) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yourrealname'), 'wpRealName'), Xml::input('wpRealName', 25, $this->mRealName, array('id' => 'wpRealName')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('prefs-help-realname', 'parseinline'))));
        }
        if ($wgEnableEmail) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('youremail'), 'wpUserEmail'), Xml::input('wpUserEmail', 25, $this->mUserEmail, array('id' => 'wpUserEmail')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('prefs-help-email', 'parseinline'))));
        }
        global $wgParser, $wgMaxSigChars;
        if (mb_strlen($this->mNick) > $wgMaxSigChars) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsg('badsiglength', $wgLang->formatNum($wgMaxSigChars))));
        } elseif (!empty($this->mToggles['fancysig']) && false === $wgParser->validateSig($this->mNick)) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsg('badsig')));
        } else {
            $invalidSig = '';
        }
        $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yournick'), 'wpNick'), Xml::input('wpNick', 25, $this->mNick, array('id' => 'wpNick', 'maxlength' => $wgMaxSigChars))) . $invalidSig . $this->tableRow('&nbsp;', $this->getToggle('fancysig')));
        list($lsLabel, $lsSelect) = Xml::languageSelector($this->mUserLanguage);
        $wgOut->addHTML($this->tableRow($lsLabel, $lsSelect));
        /* see if there are multiple language variants to choose from*/
        if (!$wgDisableLangConversion) {
            $variants = $wgContLang->getVariants();
            $variantArray = array();
            $languages = Language::getLanguageNames(true);
            foreach ($variants as $v) {
                $v = str_replace('_', '-', strtolower($v));
                if (array_key_exists($v, $languages)) {
                    // If it doesn't have a name, we'll pretend it doesn't exist
                    $variantArray[$v] = $languages[$v];
                }
            }
            $options = "\n";
            foreach ($variantArray as $code => $name) {
                $selected = $code == $this->mUserVariant;
                $options .= Xml::option("{$code} - {$name}", $code, $selected) . "\n";
            }
            if (count($variantArray) > 1) {
                $wgOut->addHtml($this->tableRow(Xml::label(wfMsg('yourvariant'), 'wpUserVariant'), Xml::tags('select', array('name' => 'wpUserVariant', 'id' => 'wpUserVariant'), $options)));
            }
        }
        # Password
        if ($wgAuth->allowPasswordChange()) {
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('changepassword'))) . $this->tableRow(Xml::label(wfMsg('oldpassword'), 'wpOldpass'), Xml::password('wpOldpass', 25, $this->mOldpass, array('id' => 'wpOldpass'))) . $this->tableRow(Xml::label(wfMsg('newpassword'), 'wpNewpass'), Xml::password('wpNewpass', 25, $this->mNewpass, array('id' => 'wpNewpass'))) . $this->tableRow(Xml::label(wfMsg('retypenew'), 'wpRetypePass'), Xml::password('wpRetypePass', 25, $this->mRetypePass, array('id' => 'wpRetypePass'))) . Xml::tags('tr', null, Xml::tags('td', array('colspan' => '2'), $this->getToggle("rememberpassword"))));
        }
        # <FIXME>
        # Enotif
        if ($wgEnableEmail) {
            $moreEmail = '';
            if ($wgEnableUserEmail) {
                $emf = wfMsg('allowemail');
                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
                $moreEmail = "<input type='checkbox' {$emfc} {$disabled} value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>{$emf}</label>";
            }
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('email'))) . $this->tableRow($emailauthenticated . $enotifrevealaddr . $enotifwatchlistpages . $enotifusertalkpages . $enotifminoredits . $moreEmail . $this->getToggle('ccmeonemails')));
        }
        # </FIXME>
        $wgOut->addHTML(Xml::closeElement('table') . Xml::closeElement('fieldset'));
        # Quickbar
        #
        if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
            $wgOut->addHtml("<fieldset>\n<legend>" . wfMsg('qbsettings') . "</legend>\n");
            for ($i = 0; $i < count($qbs); ++$i) {
                if ($i == $this->mQuickbar) {
                    $checked = ' checked="checked"';
                } else {
                    $checked = "";
                }
                $wgOut->addHTML("<div><label><input type='radio' name='wpQuickbar' value=\"{$i}\"{$checked} />{$qbs[$i]}</label></div>\n");
            }
            $wgOut->addHtml("</fieldset>\n\n");
        } else {
            # Need to output a hidden option even if the relevant skin is not in use,
            # otherwise the preference will get reset to 0 on submit
            $wgOut->addHtml(wfHidden('wpQuickbar', $this->mQuickbar));
        }
        # Skin
        #
        $wgOut->addHTML("<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n");
        $mptitle = Title::newMainPage();
        $previewtext = wfMsg('skinpreview');
        # Only show members of Skin::getSkinNames() rather than
        # $skinNames (skins is all skin names from Language.php)
        $validSkinNames = Skin::getSkinNames();
        # Sort by UI skin name. First though need to update validSkinNames as sometimes
        # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
        foreach ($validSkinNames as $skinkey => &$skinname) {
            if (isset($skinNames[$skinkey])) {
                $skinname = $skinNames[$skinkey];
            }
        }
        asort($validSkinNames);
        foreach ($validSkinNames as $skinkey => $sn) {
            if (in_array($skinkey, $wgSkipSkins)) {
                continue;
            }
            $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
            $mplink = htmlspecialchars($mptitle->getLocalURL("useskin={$skinkey}"));
            $previewlink = "<a target='_blank' href=\"{$mplink}\">{$previewtext}</a>";
            if ($skinkey == $wgDefaultSkin) {
                $sn .= ' (' . wfMsg('default') . ')';
            }
            $wgOut->addHTML("<input type='radio' name='wpSkin' id=\"wpSkin{$skinkey}\" value=\"{$skinkey}\"{$checked} /> <label for=\"wpSkin{$skinkey}\">{$sn}</label> {$previewlink}<br />\n");
        }
        $wgOut->addHTML("</fieldset>\n\n");
        # Math
        #
        global $wgUseTeX;
        if ($wgUseTeX) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('math') . '</legend>');
            foreach ($mathopts as $k => $v) {
                $checked = $k == $this->mMath;
                $wgOut->addHTML(Xml::openElement('div') . Xml::radioLabel(wfMsg($v), 'wpMath', $k, "mw-sp-math-{$k}", $checked) . Xml::closeElement('div') . "\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Files
        #
        $wgOut->addHTML("<fieldset>\n" . Xml::element('legend', null, wfMsg('files')) . "\n");
        $imageLimitOptions = null;
        foreach ($wgImageLimits as $index => $limits) {
            $selected = $index == $this->mImageSize;
            $imageLimitOptions .= Xml::option("{$limits[0]}×{$limits[1]}" . wfMsg('unit-pixel'), $index, $selected);
        }
        $imageSizeId = 'wpImageSize';
        $wgOut->addHTML("<div>" . Xml::label(wfMsg('imagemaxsize'), $imageSizeId) . " " . Xml::openElement('select', array('name' => $imageSizeId, 'id' => $imageSizeId)) . $imageLimitOptions . Xml::closeElement('select') . "</div>\n");
        $imageThumbOptions = null;
        foreach ($wgThumbLimits as $index => $size) {
            $selected = $index == $this->mThumbSize;
            $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index, $selected);
        }
        $thumbSizeId = 'wpThumbSize';
        $wgOut->addHTML("<div>" . Xml::label(wfMsg('thumbsize'), $thumbSizeId) . " " . Xml::openElement('select', array('name' => $thumbSizeId, 'id' => $thumbSizeId)) . $imageThumbOptions . Xml::closeElement('select') . "</div>\n");
        $wgOut->addHTML("</fieldset>\n\n");
        # Date format
        #
        # Date/Time
        #
        $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('datetime') . "</legend>\n");
        if ($dateopts) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n");
            $idCnt = 0;
            $epoch = '20010115161234';
            # Wikipedia day
            foreach ($dateopts as $key) {
                if ($key == 'default') {
                    $formatted = wfMsgHtml('datedefault');
                } else {
                    $formatted = htmlspecialchars($wgLang->timeanddate($epoch, false, $key));
                }
                $key == $this->mDate ? $checked = ' checked="checked"' : ($checked = '');
                $wgOut->addHTML("<div><input type='radio' name=\"wpDate\" id=\"wpDate{$idCnt}\" " . "value=\"{$key}\"{$checked} /> <label for=\"wpDate{$idCnt}\">{$formatted}</label></div>\n");
                $idCnt++;
            }
            $wgOut->addHTML("</fieldset>\n");
        }
        $nowlocal = $wgLang->time($now = wfTimestampNow(), true);
        $nowserver = $wgLang->time($now, false);
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('timezonelegend') . '</legend><table>' . $this->addRow(wfMsg('servertime'), $nowserver) . $this->addRow(wfMsg('localtime'), $nowlocal) . $this->addRow('<label for="wpHourDiff">' . wfMsg('timezoneoffset') . '</label>', "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars($this->mHourDiff) . "\" size='6' />") . "<tr><td colspan='2'>\r\n\t\t\t\t<input type='button' value=\"" . wfMsg('guesstimezone') . "\"\r\n\t\t\t\tonclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />\r\n\t\t\t\t</td></tr></table><div class='prefsectiontip'>¹" . wfMsg('timezonetext') . "</div></fieldset>\r\n\t\t</fieldset>\n\n");
        # Editing
        #
        global $wgLivePreview;
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('textboxsize') . '</legend>
			<div>' . wfInputLabel(wfMsg('rows'), 'wpRows', 'wpRows', 3, $this->mRows) . ' ' . wfInputLabel(wfMsg('columns'), 'wpCols', 'wpCols', 3, $this->mCols) . "</div>" . $this->getToggles(array('editsection', 'editsectiononrightclick', 'editondblclick', 'editwidth', 'showtoolbar', 'previewonfirst', 'previewontop', 'minordefault', 'externaleditor', 'externaldiff', $wgLivePreview ? 'uselivepreview' : false, 'forceeditsummary')) . '</fieldset>');
        # Recent changes
        $wgOut->addHtml('<fieldset><legend>' . wfMsgHtml('prefs-rc') . '</legend>');
        $rc = '<table><tr>';
        $rc .= '<td>' . Xml::label(wfMsg('recentchangesdays'), 'wpRecentDays') . '</td>';
        $rc .= '<td>' . Xml::input('wpRecentDays', 3, $this->mRecentDays, array('id' => 'wpRecentDays')) . '</td>';
        $rc .= '</tr><tr>';
        $rc .= '<td>' . Xml::label(wfMsg('recentchangescount'), 'wpRecent') . '</td>';
        $rc .= '<td>' . Xml::input('wpRecent', 3, $this->mRecent, array('id' => 'wpRecent')) . '</td>';
        $rc .= '</tr></table>';
        $wgOut->addHtml($rc);
        $wgOut->addHtml('<br />');
        $toggles[] = 'hideminor';
        if ($wgRCShowWatchingUsers) {
            $toggles[] = 'shownumberswatching';
        }
        $toggles[] = 'usenewrc';
        $wgOut->addHtml($this->getToggles($toggles));
        $wgOut->addHtml('</fieldset>');
        # Watchlist
        $wgOut->addHtml('<fieldset><legend>' . wfMsgHtml('prefs-watchlist') . '</legend>');
        $wgOut->addHtml(wfInputLabel(wfMsg('prefs-watchlist-days'), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays));
        $wgOut->addHtml('<br /><br />');
        $wgOut->addHtml($this->getToggle('extendwatchlist'));
        $wgOut->addHtml(wfInputLabel(wfMsg('prefs-watchlist-edits'), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits));
        $wgOut->addHtml('<br /><br />');
        $wgOut->addHtml($this->getToggles(array('watchlisthideown', 'watchlisthidebots', 'watchlisthideminor')));
        if ($wgUser->isAllowed('createpage') || $wgUser->isAllowed('createtalk')) {
            $wgOut->addHtml($this->getToggle('watchcreations'));
        }
        foreach (array('edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion') as $action => $toggle) {
            if ($wgUser->isAllowed($action)) {
                $wgOut->addHtml($this->getToggle($toggle));
            }
        }
        $this->mUsedToggles['watchcreations'] = true;
        $this->mUsedToggles['watchdefault'] = true;
        $this->mUsedToggles['watchmoves'] = true;
        $this->mUsedToggles['watchdeletion'] = true;
        $wgOut->addHtml('</fieldset>');
        # Search
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('searchresultshead') . '</legend><table>' . $this->addRow(wfLabel(wfMsg('resultsperpage'), 'wpSearch'), wfInput('wpSearch', 4, $this->mSearch, array('id' => 'wpSearch'))) . $this->addRow(wfLabel(wfMsg('contextlines'), 'wpSearchLines'), wfInput('wpSearchLines', 4, $this->mSearchLines, array('id' => 'wpSearchLines'))) . $this->addRow(wfLabel(wfMsg('contextchars'), 'wpSearchChars'), wfInput('wpSearchChars', 4, $this->mSearchChars, array('id' => 'wpSearchChars'))) . "</table><fieldset><legend>" . wfMsg('defaultns') . "</legend>{$ps}</fieldset></fieldset>");
        # Misc
        #
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
        $wgOut->addHtml('<label for="wpStubs">' . wfMsg('stub-threshold') . '</label>&nbsp;');
        $wgOut->addHtml(Xml::input('wpStubs', 6, $this->mStubs, array('id' => 'wpStubs')));
        $msgUnderline = htmlspecialchars(wfMsg('tog-underline'));
        $msgUnderlinenever = htmlspecialchars(wfMsg('underline-never'));
        $msgUnderlinealways = htmlspecialchars(wfMsg('underline-always'));
        $msgUnderlinedefault = htmlspecialchars(wfMsg('underline-default'));
        $uopt = $wgUser->getOption("underline");
        $s0 = $uopt == 0 ? ' selected="selected"' : '';
        $s1 = $uopt == 1 ? ' selected="selected"' : '';
        $s2 = $uopt == 2 ? ' selected="selected"' : '';
        $wgOut->addHTML("\r\n<div class='toggle'><p><label for='wpOpunderline'>{$msgUnderline}</label>\r\n<select name='wpOpunderline' id='wpOpunderline'>\r\n<option value=\"0\"{$s0}>{$msgUnderlinenever}</option>\r\n<option value=\"1\"{$s1}>{$msgUnderlinealways}</option>\r\n<option value=\"2\"{$s2}>{$msgUnderlinedefault}</option>\r\n</select></p></div>");
        foreach ($togs as $tname) {
            if (!array_key_exists($tname, $this->mUsedToggles)) {
                $wgOut->addHTML($this->getToggle($tname));
            }
        }
        $wgOut->addHTML('</fieldset>');
        wfRunHooks("RenderPreferencesForm", array($this, $wgOut));
        $token = htmlspecialchars($wgUser->editToken());
        $skin = $wgUser->getSkin();
        $wgOut->addHTML("\r\n\t<div id='prefsubmit'>\r\n\t<div>\r\n\t\t<input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml('saveprefs') . '"' . $skin->tooltipAndAccesskey('save') . " />\r\n\t\t<input type='submit' name='wpReset' value=\"" . wfMsgHtml('resetprefs') . "\" />\r\n\t</div>\r\n\r\n\t</div>\r\n\r\n\t<input type='hidden' name='wpEditToken' value=\"{$token}\" />\r\n\t</div></form>\n");
        $wgOut->addHtml(Xml::tags('div', array('class' => "prefcache"), wfMsgExt('clearyourcache', 'parseinline')));
    }
 /**
  * Creates an instance of this class from definition in MediaWiki:Gadgets-definition
  * @param $definition String: Gadget definition
  * @return Mixed: Instance of Gadget class or false if $definition is invalid
  */
 public static function newFromDefinition($definition)
 {
     $m = array();
     if (!preg_match('/^\\*+ *([a-zA-Z](?:[-_:.\\w\\d ]*[a-zA-Z0-9])?)(\\s*\\[.*?\\])?\\s*((\\|[^|]*)+)\\s*$/', $definition, $m)) {
         return false;
     }
     // NOTE: the gadget name is used as part of the name of a form field,
     //      and must follow the rules defined in http://www.w3.org/TR/html4/types.html#type-cdata
     //      Also, title-normalization applies.
     $gadget = new Gadget();
     $gadget->name = trim(str_replace(' ', '_', $m[1]));
     $gadget->definition = $definition;
     $options = trim($m[2], ' []');
     foreach (preg_split('/\\s*\\|\\s*/', $options, -1, PREG_SPLIT_NO_EMPTY) as $option) {
         $arr = preg_split('/\\s*=\\s*/', $option, 2);
         $option = $arr[0];
         if (isset($arr[1])) {
             $params = explode(',', $arr[1]);
             $params = array_map('trim', $params);
         } else {
             $params = array();
         }
         switch ($option) {
             case 'ResourceLoader':
                 $gadget->resourceLoaded = true;
                 break;
             case 'dependencies':
                 $gadget->dependencies = $params;
                 break;
             case 'rights':
                 $gadget->requiredRights = $params;
                 break;
             case 'skins':
                 $gadget->requiredSkins = array_intersect(array_keys(Skin::getSkinNames()), $params);
                 break;
             case 'default':
                 $gadget->onByDefault = true;
                 break;
         }
     }
     foreach (preg_split('/\\s*\\|\\s*/', $m[3], -1, PREG_SPLIT_NO_EMPTY) as $page) {
         $page = "Gadget-{$page}";
         if (preg_match('/\\.js/', $page)) {
             $gadget->scripts[] = $page;
         } elseif (preg_match('/\\.css/', $page)) {
             $gadget->styles[] = $page;
         }
     }
     return $gadget;
 }
Example #18
0
 /**
  * Normalize a skin preference value to a form that can be loaded.
  *
  * If a skin can't be found, it will fall back to the configured default ($wgDefaultSkin), or the
  * hardcoded default ($wgFallbackSkin) if the default skin is unavailable too.
  *
  * @param string $key 'monobook', 'vector', etc.
  * @return string
  */
 static function normalizeKey($key)
 {
     global $wgDefaultSkin, $wgFallbackSkin;
     $skinNames = Skin::getSkinNames();
     // Make keys lowercase for case-insensitive matching.
     $skinNames = array_change_key_case($skinNames, CASE_LOWER);
     $key = strtolower($key);
     $defaultSkin = strtolower($wgDefaultSkin);
     $fallbackSkin = strtolower($wgFallbackSkin);
     if ($key == '' || $key == 'default') {
         // Don't return the default immediately;
         // in a misconfiguration we need to fall back.
         $key = $defaultSkin;
     }
     if (isset($skinNames[$key])) {
         return $key;
     }
     // Older versions of the software used a numeric setting
     // in the user preferences.
     $fallback = array(0 => $defaultSkin, 2 => 'cologneblue');
     if (isset($fallback[$key])) {
         $key = $fallback[$key];
     }
     if (isset($skinNames[$key])) {
         return $key;
     } elseif (isset($skinNames[$defaultSkin])) {
         return $defaultSkin;
     } else {
         return $fallbackSkin;
     }
 }
 /**
  * Gets a list of file paths for all skin style files in the module,
  * for all available skins.
  *
  * @return array A list of file paths collated by media type
  */
 protected function getAllSkinStyleFiles()
 {
     $styleFiles = [];
     $internalSkinNames = array_keys(Skin::getSkinNames());
     $internalSkinNames[] = 'default';
     foreach ($internalSkinNames as $internalSkinName) {
         $styleFiles = array_merge_recursive($styleFiles, $this->getSkinStyleFiles($internalSkinName));
     }
     return $styleFiles;
 }
 public function purgeMemcache($timestamp)
 {
     foreach (Skin::getSkinNames() as $key => $skin) {
         $this->app->wg->Memc->delete($this->getMemcacheKey($timestamp, $key));
     }
 }
Example #21
0
 /**
  * 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;
 }
Example #22
0
 /**
  * Get the javascript or css text content from a given classKey
  *
  * @param {String} $resourceName Resource Key to grab text for
  * @param {String} [$filePath] Optional file path to get js text
  * @return unknown
  */
 function getResourceText($resourceName)
 {
     $output = '';
     // Special case: title classes
     if (substr($resourceName, 0, 3) == 'WT:') {
         global $wgUser;
         // Get just the title part
         $titleBlock = substr($resourceName, 3);
         if ($titleBlock[0] == '-') {
             // Special case of "-" title
             $parts = explode('|', $titleBlock);
             $title = array_shift($parts);
             $titleParams = array();
             foreach ($parts as $titleParam) {
                 list($key, $val) = explode('=', $titleParam);
                 $titleParams[$key] = $val;
             }
             /*
              * The "-" is a special key to user / site js system sucks
              * here is some code to handle it ... but it really
              * should be depreciated for some more logical system
              * like directly referencing the titles that we have a script-loader
              */
             $sk = $wgUser->getSkin();
             if (isset($titleParams['useskin'])) {
                 // Make sure the skin name is valid
                 $skinNames = Skin::getSkinNames();
                 $skinNames = array_keys($skinNames);
                 if (in_array(strtolower($titleParams['useskin']), $skinNames)) {
                     if ($titleParams['gen'] == 'css') {
                         return $sk->generateUserStylesheet();
                     }
                     // If in debug mode, add a comment with wiki title and rev:
                     if ($this->debug) {
                         $output .= "\n/**\n* GenerateUserJs: \n*/\n";
                     }
                     return $sk->generateUserJs($titleParams['useskin']) . "\n";
                 }
             } else {
                 if (isset($titleParams['gen']) && $titleParams['gen'] == 'css') {
                     return $sk->generateUserStylesheet();
                 }
             }
         } else {
             $ext = substr($titleBlock, strrpos($titleBlock, '.') + 1);
             // Make sure the wiki title ends with .js or .css
             if (self::validFileExtension($ext)) {
                 $this->errorMsg .= 'WikiTitle includes should end with .js or .css';
                 return false;
             }
             // It's a wiki title, append the output of the wikitext:
             $t = Title::newFromText($titleBlock);
             $a = new Article($t);
             // Only get the content if the page is not empty:
             if ($a->getID() !== 0) {
                 // If in debug mode, add a comment with wiki title and rev:
                 if ($this->debug) {
                     $output .= "\n/**\n* ScriptLoader WikiPage: " . xml::escapeJsString($titleBlock) . " rev: " . $a->getID() . " \n*/\n";
                 }
                 $fileContents = $a->getContent() . "\n";
                 // transform the output if the file is of type css:
                 $output .= $ext == 'css' ? $this->transformCssOutput($resourceName, $fileContents) : $fileContents;
                 return $output;
             }
         }
     }
     // Deal with the classKey as a file:
     $filePath = self::getPathFromClass($resourceName);
     if (!$filePath) {
         $this->errorMsg .= "\nError could not get file path: " . xml::escapeJsString($resourceName) . "\n";
         return false;
     }
     // Get the file extension:
     $ext = substr($filePath, strrpos($filePath, '.') + 1);
     // Dealing with files
     if (trim($filePath) != '') {
         $fileContents = $this->getFileContents($filePath) . "\n";
         if ($fileContents) {
             // Add the file name if debug is enabled
             if ($this->debug) {
                 $output .= "\n\n/**\n* File: " . xml::escapeJsString($filePath) . "\n*/\n";
             }
             // Transform the css output if the file is css
             $output .= $ext == 'css' ? $this->transformCssOutput($resourceName, $fileContents, $filePath) : $fileContents;
             return $output;
         } else {
             $this->errorMsg .= "\nError could not read file: " . xml::escapeJsString($filePath) . "\n";
             return false;
         }
     }
     // If we did not return some js
     $this->errorMsg .= "\nUnknown error in getting scriptText for key: " . xml::escapeJsString($resourceName) . "\n";
     return false;
 }
Example #23
0
 /**
  * Is this a *valid* .css or .js subpage of a user page?
  * Check that the corresponding skin exists
  */
 public function isValidCssJsSubpage()
 {
     if ($this->isCssJsSubpage()) {
         $skinNames = Skin::getSkinNames();
         return array_key_exists($this->getSkinFromCssJsSubpage(), $skinNames);
     } else {
         return false;
     }
 }
 public function appendSkins($property)
 {
     $data = array();
     foreach (Skin::getSkinNames() as $name => $displayName) {
         $skin = array('code' => $name);
         ApiResult::setContent($skin, $displayName);
         $data[] = $skin;
     }
     $this->getResult()->setIndexedTagName($data, 'skin');
     return $this->getResult()->addValue('query', $property, $data);
 }
Example #25
0
 /**
  * Load a skin if it doesn't exist or return it
  * @todo FIXME : need to check the old failback system [AV]
  */
 function &getSkin()
 {
     global $IP, $wgRequest, $wgStyleDirectory;
     if (!isset($this->mSkin)) {
         $fname = 'User::getSkin';
         wfProfileIn($fname);
         # get all skin names available
         $skinNames = Skin::getSkinNames();
         # get the user skin
         $userSkin = $this->getOption('skin');
         $userSkin = $wgRequest->getText('useskin', $userSkin);
         if ($userSkin == '') {
             $userSkin = 'monobook';
         }
         if (!isset($skinNames[$userSkin])) {
             # in case the user skin could not be found find a replacement
             $fallback = array(0 => 'Standard', 1 => 'Nostalgia', 2 => 'CologneBlue');
             # if phptal is enabled we should have monobook skin that
             # superseed the good old SkinStandard.
             if (isset($skinNames['monobook'])) {
                 $fallback[0] = 'MonoBook';
             }
             if (is_numeric($userSkin) && isset($fallback[$userSkin])) {
                 $sn = $fallback[$userSkin];
             } else {
                 $sn = $fallback[0];
             }
         } else {
             # The user skin is available
             $sn = $skinNames[$userSkin];
         }
         # Grab the skin class and initialise it. Each skin checks for PHPTal
         # and will not load if it's not enabled.
         require_once $wgStyleDirectory . '/' . $sn . '.php';
         # Check if we got if not failback to default skin
         $className = 'Skin' . $sn;
         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.
             $className = 'SkinStandard';
             require_once $wgStyleDirectory . '/Standard.php';
         }
         $this->mSkin =& new $className();
         wfProfileOut($fname);
     }
     return $this->mSkin;
 }
Example #26
0
 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;
 }
 protected function _executeAdminister($wgFarmer)
 {
     global $wgOut, $wgUser, $wgRequest;
     $currentWiki = MediaWikiFarmer_Wiki::factory($wgFarmer->getActiveWiki());
     $action = $this->getTitle('admin')->escapeLocalURL();
     if (!(MediaWikiFarmer::userIsFarmerAdmin($wgUser) || $currentWiki->userIsAdmin($wgUser))) {
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-permissiondenied');
         $wgOut->addWikiMsg('farmer-permissiondenied-text1');
         return;
     }
     $wgOut->wrapWikiMsg('== $1 ==', 'farmer-basic-title');
     $wiki = $wgFarmer->getActiveWiki();
     if ($title = $wgRequest->getVal('wikiTitle')) {
         $wiki->title = MediaWikiFarmer_Wiki::sanitizeTitle($title);
         $wiki->save();
         $wgFarmer->updateFarmList();
     }
     if ($description = $wgRequest->getVal('wikiDescription')) {
         $wiki->description = $description;
         $wiki->save();
         $wgFarmer->updateFarmList();
     }
     if (!$wiki->title) {
         $wgOut->wrapWikiMsg('=== $1 ===', 'farmer-basic-title1');
         $wgOut->addWikiMsg('farmer-basic-title1-text');
         $wgOut->addHTML('<form method="post" name="wikiTitle" action="' . $action . '">' . '<input name="wikiTitle" size="30" value="' . $wiki->title . '" />' . '<input type="submit" name="submit" value="' . wfMsgHtml('farmer-button-submit') . '" />' . '</form>');
     }
     $wgOut->wrapWikiMsg('=== $1 ===', 'farmer-basic-description');
     $wgOut->addWikiMsg('farmer-basic-description-text');
     $wgOut->addHTML('<form method="post" name="wikiDescription" action="' . $action . '">' . '<textarea name="wikiDescription" rows="5" cols="30">' . htmlspecialchars($wiki->description) . '</textarea>' . '<input type="submit" name="submit" value="' . wfMsgHtml('farmer-button-submit') . '" />' . '</form>');
     # Permissions stuff
     if (wfRunHooks('FarmerAdminPermissions', array($wgFarmer))) {
         # Import
         if ($wgRequest->wasPosted() && ($permissions = $wgRequest->getArray('permission'))) {
             foreach ($permissions['*'] as $k => $v) {
                 $wiki->setPermissionForAll($k, $v);
             }
             foreach ($permissions['user'] as $k => $v) {
                 $wiki->setPermissionForUsers($k, $v);
             }
             $wiki->save();
         }
         # Form
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-basic-permission');
         $wgOut->addWikiMsg('farmer-basic-permission-text');
         $wgOut->addHTML('<form method="post" name="permissions" action="' . $action . '">');
         $wgOut->wrapWikiMsg('=== $1 ===', 'farmer-basic-permission-visitor');
         $wgOut->addWikiMsg('farmer-basic-permission-visitor-text');
         $doArray = array(array('read', wfMsg('right-read')), array('edit', wfMsg('right-edit')), array('createpage', wfMsg('right-createpage')), array('createtalk', wfMsg('right-createtalk')));
         foreach ($doArray as $arr) {
             $this->_doPermissionInput($wgOut, $wiki, '*', $arr[0], $arr[1]);
         }
         $wgOut->wrapWikiMsg('=== $1 ===', 'farmer-basic-permission-user');
         $wgOut->addWikiMsg('farmer-basic-permission-user-text');
         $doArray = array(array('read', wfMsg('right-read')), array('edit', wfMsg('right-edit')), array('createpage', wfMsg('right-createpage')), array('createtalk', wfMsg('right-createtalk')), array('move', wfMsg('right-move')), array('upload', wfMsg('right-upload')), array('reupload', wfMsg('right-reupload')), array('minoredit', wfMsg('right-minoredit')));
         foreach ($doArray as $arr) {
             $this->_doPermissionInput($wgOut, $wiki, 'user', $arr[0], $arr[1]);
         }
         $wgOut->addHTML('<input type="submit" name="setPermissions" value="' . wfMsg('farmer-setpermission') . '" />');
         $wgOut->addHTML("</form>\n\n\n");
     }
     # Default skin
     if (wfRunHooks('FarmerAdminSkin', array($wgFarmer))) {
         # Import
         if ($wgRequest->wasPosted() && ($newSkin = $wgRequest->getVal('defaultSkin'))) {
             $wiki->wgDefaultSkin = $newSkin;
             $wiki->save();
         }
         # Form
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-defaultskin');
         $defaultSkin = $wgFarmer->getActiveWiki()->wgDefaultSkin;
         if (!$defaultSkin) {
             $defaultSkin = 'MonoBook';
         }
         $skins = Skin::getSkinNames();
         global $wgSkipSkins;
         foreach ($wgSkipSkins as $skin) {
             if (array_key_exists($skin, $skins)) {
                 unset($skins[$skin]);
             }
         }
         $wgOut->addHTML('<form method="post" name="formDefaultSkin" action="' . $action . '">');
         foreach ($skins as $k => $skin) {
             $toAdd = '<input type="radio" name="defaultSkin" value="' . $k . '"';
             if ($k == $defaultSkin) {
                 $toAdd .= ' checked="checked" ';
             }
             $toAdd .= '/>' . $skin;
             $wgOut->addHTML($toAdd . "<br />\n");
         }
         $wgOut->addHTML('<input type="submit" name="submitDefaultSkin" value="' . wfMsgHtml('farmer-defaultskin-button') . '" />');
         $wgOut->addHTML('</form>');
     }
     # Manage active extensions
     if (wfRunHooks('FarmerAdminExtensions', array($wgFarmer))) {
         $extensions = $wgFarmer->getExtensions();
         // if we post a list of new extensions, wipe the old list from the wiki
         if ($wgRequest->wasPosted() && $wgRequest->getCheck('submitExtension')) {
             $wiki->extensions = array();
             // go through all posted extensions and add the appropriate ones
             foreach ((array) $wgRequest->getArray('extension') as $k => $e) {
                 if (array_key_exists($k, $extensions)) {
                     $wiki->addExtension($extensions[$k]);
                 }
             }
             $wiki->save();
         }
         # Form
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-extensions');
         $wgOut->addHTML('<form method="post" name="formActiveExtensions" action="' . $action . '">');
         foreach ($extensions as $extension) {
             $toAdd = '<input type="checkbox" name="extension[' . $extension->name . ']" ';
             if ($wiki->hasExtension($extension)) {
                 $toAdd .= 'checked="checked" ';
             }
             $toAdd .= ' /><strong>' . htmlspecialchars($extension->name) . '</strong> - ' . htmlspecialchars($extension->description) . "<br />\n";
             $wgOut->addHTML($toAdd);
         }
         $wgOut->addHTML('<input type="submit" name="submitExtension" value="' . wfMsgHtml('farmer-extensions-button') . '" />');
         $wgOut->addHTML('</form>');
     }
 }
Example #28
0
 /**
  * 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;
 }
Example #29
0
 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);
 }
Example #30
0
 /**
  * Get list of all URLs to be purged for a given Title
  *
  * @param Title $title page to be purged
  * @param Array $urls list of URLs to be purged
  * @return mixed true - it's a hook
  */
 public static function onTitleGetSquidURLs(Title $title, array $urls)
 {
     // if this is a site css or js purge it as well
     global $wgUseSiteCss, $wgAllowUserJs;
     global $wgSquidMaxage, $wgJsMimeType;
     wfProfileIn(__METHOD__);
     if ($wgUseSiteCss && $title->getNamespace() == NS_MEDIAWIKI) {
         global $wgServer;
         $urls[] = $wgServer . '/__am/';
         $urls[] = $wgServer . '/__wikia_combined/';
         $query = array('usemsgcache' => 'yes', 'ctype' => 'text/css', 'smaxage' => $wgSquidMaxage, 'action' => 'raw', 'maxage' => $wgSquidMaxage);
         if ($title->getText() == 'Common.css' || $title->getText() == 'Wikia.css') {
             // BugId:20929 - tell (or trick) varnish to store the latest revisions of Wikia.css and Common.css.
             $oTitleCommonCss = Title::newFromText('Common.css', NS_MEDIAWIKI);
             $oTitleWikiaCss = Title::newFromText('Wikia.css', NS_MEDIAWIKI);
             $query['maxrev'] = max((int) $oTitleWikiaCss->getLatestRevID(), (int) $oTitleCommonCss->getLatestRevID());
             unset($oTitleWikiaCss, $oTitleCommonCss);
             $urls[] = $title->getInternalURL($query);
         } else {
             foreach (Skin::getSkinNames() as $skinkey => $skinname) {
                 if ($title->getText() == ucfirst($skinkey) . '.css') {
                     $urls[] = str_replace('text%2Fcss', 'text/css', $title->getInternalURL($query));
                     // For Artur
                     $urls[] = $title->getInternalURL($query);
                     // For Artur
                     break;
                 } elseif ($title->getText() == 'Common.js') {
                     $urls[] = Skin::makeUrl('-', "action=raw&smaxage=86400&gen=js&useskin=" . urlencode($skinkey));
                 }
             }
         }
     } elseif ($wgAllowUserJs && $title->isCssJsSubpage()) {
         if ($title->isJsSubpage()) {
             $urls[] = $title->getInternalURL('action=raw&ctype=' . $wgJsMimeType);
         } elseif ($title->isCssSubpage()) {
             $urls[] = $title->getInternalURL('action=raw&ctype=text/css');
         }
     }
     // purge Special:RecentChanges too
     $urls[] = SpecialPage::getTitleFor('RecentChanges')->getInternalURL();
     wfProfileOut(__METHOD__);
     return true;
 }