示例#1
0
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     OOUI\Theme::setSingleton(new OOUI\MediaWikiTheme());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles(array('oojs-ui.styles', 'oojs-ui.styles.icons', 'oojs-ui.styles.indicators', 'oojs-ui.styles.textures'));
 }
示例#2
0
 /**
  * Helper function to setup the PHP implementation of OOUI to use in this request.
  *
  * @since 1.26
  * @param String $skinName The Skin name to determine the correct OOUI theme
  * @param String $dir Language direction
  */
 public static function setupOOUI($skinName = '', $dir = 'ltr')
 {
     $themes = ExtensionRegistry::getInstance()->getAttribute('SkinOOUIThemes');
     // Make keys (skin names) lowercase for case-insensitive matching.
     $themes = array_change_key_case($themes, CASE_LOWER);
     $theme = isset($themes[$skinName]) ? $themes[$skinName] : 'MediaWiki';
     // For example, 'OOUI\MediaWikiTheme'.
     $themeClass = "OOUI\\{$theme}Theme";
     OOUI\Theme::setSingleton(new $themeClass());
     OOUI\Element::setDefaultDir($dir);
 }
示例#3
0
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     $themes = ExtensionRegistry::getInstance()->getAttribute('SkinOOUIThemes');
     // Make keys (skin names) lowercase for case-insensitive matching.
     $themes = array_change_key_case($themes, CASE_LOWER);
     $skinName = strtolower($this->getSkin()->getSkinName());
     $theme = isset($themes[$skinName]) ? $themes[$skinName] : 'MediaWiki';
     // For example, 'OOUI\MediaWikiTheme'.
     $themeClass = "OOUI\\{$theme}Theme";
     OOUI\Theme::setSingleton(new $themeClass());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles(array('oojs-ui.styles', 'oojs-ui.styles.icons', 'oojs-ui.styles.indicators', 'oojs-ui.styles.textures', 'mediawiki.widgets.styles'));
 }
    return new $class($config);
}
// @codingStandardsIgnoreStart
function unstub(&$value)
{
    // @codingStandardsIgnoreEnd
    if (is_string($value) && substr($value, 0, 13) === '_placeholder_') {
        $value = json_decode(substr($value, 13), true);
        array_walk_recursive($value['config'], 'unstub');
        $value = new_OOUI($value['class'], $value['config']);
    }
}
// Keep synchronized with tests/index.php
$themes = array('ApexTheme', 'MediaWikiTheme');
foreach ($themes as $theme) {
    OOUI\Theme::setSingleton(new_OOUI($theme));
    foreach ($testSuite as $className => $tests) {
        foreach ($tests as $test) {
            // Unstub placeholders
            $config = $test['config'];
            array_walk_recursive($config, 'unstub');
            $config['infusable'] = true;
            $instance = new_OOUI($test['class'], $config);
            $testSuiteOutput[$theme][$className][] = "{$instance}";
        }
    }
}
$testSuiteOutputJSON = json_encode($testSuiteOutput, JSON_PRETTY_PRINT);
echo "var testSuiteConfigs = {$testSuiteJSON};\n\n";
echo "var testSuitePHPOutput = {$testSuiteOutputJSON};\n\n";
echo file_get_contents('JSPHP.test.karma.js');
示例#5
0
<?php

$autoload = '../vendor/autoload.php';
if (!file_exists($autoload)) {
    echo '<h1>Did you forget to run <code>composer install</code>?</h1>';
    exit;
}
require_once $autoload;
$theme = isset($_GET['theme']) && $_GET['theme'] === 'apex' ? 'apex' : 'mediawiki';
$themeClass = 'OOUI\\' . ($theme === 'apex' ? 'Apex' : 'MediaWiki') . 'Theme';
OOUI\Theme::setSingleton(new $themeClass());
$graphicSuffixMap = array('mixed' => '', 'vector' => '.vector', 'raster' => '.raster');
$graphic = isset($_GET['graphic']) && isset($graphicSuffixMap[$_GET['graphic']]) ? $_GET['graphic'] : 'vector';
$graphicSuffix = $graphicSuffixMap[$graphic];
$direction = isset($_GET['direction']) && $_GET['direction'] === 'rtl' ? 'rtl' : 'ltr';
$directionSuffix = $direction === 'rtl' ? '.rtl' : '';
OOUI\Element::setDefaultDir($direction);
$query = array('theme' => $theme, 'graphic' => $graphic, 'direction' => $direction);
$styleFileName = "oojs-ui-{$theme}{$graphicSuffix}{$directionSuffix}.css";
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
	<meta charset="UTF-8">
	<title>OOjs UI Widget Demo</title>
	<link rel="stylesheet" href="../dist/<?php 
echo $styleFileName;
?>
" title="theme">
	<link rel="stylesheet" href="styles/demo<?php 
echo $directionSuffix;
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     OOUI\Theme::setSingleton(new OOUI\MediaWikiTheme());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles('oojs-ui.styles');
 }