Allow skins/extensions to define custom OOUI themes
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 17 Mar 2017 02:14:05 +0000 (03:14 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 10 Jul 2019 20:08:14 +0000 (22:08 +0200)
commit77f4bab8b749ed43438cc77dd6b2330ef0f99b8a
tree465ede91496e1933c04e69a7291d8e4d01752321
parentd72f24589b3eece35b334d080e6e609b048fc22f
Allow skins/extensions to define custom OOUI themes

This change follows I39cc2a735d9625c87bf4ede6f5fb0ec441d47dcc.

docs/extension.schema.v1.json
docs/extension.schema.v2.json
includes/registration/ExtensionProcessor.php
* The new extension attribute 'OOUIThemePaths' can be used to define
  custom OOUI themes. See I9187a63e509b601b8558ea82850fa828e5c8cc0a
  for an example usage.

includes/resourceloader/ResourceLoaderOOUIModule.php
* Add support for 'OOUIThemePaths'.
* Defining 'images' is now optional. I figure custom themes are
  unlikely to have or need them.
* Use ResourceLoaderFilePath objects to allow skin-/extension-defined
  OOUI module files to use skin/extension's base paths.
  This was previously used to support $wgResourceModuleSkinStyles,
  but only for 'skinStyles' - now ResourceLoaderFileModule needs
  to also handle it for 'skinScripts', and ResourceLoaderImageModule
  for 'images').

includes/resourceloader/ResourceLoaderFilePath.php
* Add getters for local/remote base paths, for when we need to
  construct a new ResourceLoaderFilePath based on existing one.

includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderImageModule.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
* Add or improve handling of ResourceLoaderFilePaths:
  * Replace `(array)` casts with explicit array wrapping, to avoid
    casting objects into associative arrays.
  * Use getLocalPath() instead of string concatenation.

tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php
* Some basic checks for the above.

Bug: T100896
Change-Id: I74362f0fc215b26f1f104ce7bdbbac1e106736ad
18 files changed:
docs/extension.schema.v1.json
docs/extension.schema.v2.json
includes/registration/ExtensionProcessor.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderFilePath.php
includes/resourceloader/ResourceLoaderImage.php
includes/resourceloader/ResourceLoaderImageModule.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
includes/resourceloader/ResourceLoaderOOUIModule.php
tests/phpunit/data/rlfilepath/eye.svg [new file with mode: 0644]
tests/phpunit/data/rlfilepath/flag-ltr.svg [new file with mode: 0644]
tests/phpunit/data/rlfilepath/flag-rtl.svg [new file with mode: 0644]
tests/phpunit/data/rlfilepath/script.js [new file with mode: 0644]
tests/phpunit/data/rlfilepath/skinStyle.css [new file with mode: 0644]
tests/phpunit/data/rlfilepath/style.css [new file with mode: 0644]
tests/phpunit/data/rlfilepath/template.html [new file with mode: 0644]
tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php