mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Updated Requirements::themedCSS() to take two parameters - the CSS name and a fallback module. It first looks for the CSS file inside the current theme, then falls back to the CSS file inside the module. This eliminates the need for a CSS manifest.
This commit is contained in:
parent
bc0a1b7a05
commit
7df8929bc0
@ -143,13 +143,22 @@ class Requirements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given "themeable stylesheet" as required. See {@link Requirements_Backend::themedCSS()}
|
* Registers the given themeable stylesheet as required.
|
||||||
*
|
*
|
||||||
* @param $name String The identifier of the file. For example, css/MyFile.css would have the identifier "MyFile"
|
* A CSS file in the current theme path name "themename/css/$name.css" is
|
||||||
* @param $media String Comma-separated list of media-types (e.g. "screen,projector")
|
* first searched for, and it that doesn't exist and the module parameter is
|
||||||
|
* set then a CSS file with that name in the module is used.
|
||||||
|
*
|
||||||
|
* NOTE: This API is experimental and may change in the future.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the file - e.g. "/css/File.css" would have
|
||||||
|
* the name "File".
|
||||||
|
* @param string $module The module to fall back to if the css file does not
|
||||||
|
* exist in the current theme.
|
||||||
|
* @param string $media The CSS media attribute.
|
||||||
*/
|
*/
|
||||||
static function themedCSS($name, $media = null) {
|
public static function themedCSS($name, $module = null, $media = null) {
|
||||||
return self::backend()->themedCSS($name, $media);
|
return self::backend()->themedCSS($name, $module, $media);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1046,25 +1055,20 @@ class Requirements_Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given "themeable stylesheet" as required.
|
* @see Requirements::themedCSS()
|
||||||
* Themeable stylesheets have globally unique names, just like templates and PHP files.
|
|
||||||
* Because of this, they can be replaced by similarly named CSS files in the theme directory.
|
|
||||||
*
|
|
||||||
* @param $name String The identifier of the file. For example, css/MyFile.css would have the identifier "MyFile"
|
|
||||||
* @param $media String Comma-separated list of media-types (e.g. "screen,projector")
|
|
||||||
*/
|
*/
|
||||||
function themedCSS($name, $media = null) {
|
public function themedCSS($name, $module = null, $media = null) {
|
||||||
global $_CSS_MANIFEST;
|
|
||||||
|
|
||||||
$theme = SSViewer::current_theme();
|
$theme = SSViewer::current_theme();
|
||||||
|
$path = SSViewer::get_theme_folder() . "/css/$name.css";
|
||||||
|
|
||||||
if($theme && isset($_CSS_MANIFEST[$name]) && isset($_CSS_MANIFEST[$name]['themes'])
|
if (file_exists(BASE_PATH . '/' . $path)) {
|
||||||
&& isset($_CSS_MANIFEST[$name]['themes'][$theme]))
|
$this->css($path, $media);
|
||||||
$this->css($_CSS_MANIFEST[$name]['themes'][$theme], $media);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
else if(isset($_CSS_MANIFEST[$name]) && isset($_CSS_MANIFEST[$name]['unthemed'])) $this->css($_CSS_MANIFEST[$name]['unthemed'], $media);
|
if ($module) {
|
||||||
// Normal requirements fails quietly when there is no css - we should do the same
|
$this->css("$module/css/$name.css");
|
||||||
// else user_error("themedCSS - No CSS file '$name.css' found.", E_USER_WARNING);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug() {
|
function debug() {
|
||||||
|
Loading…
Reference in New Issue
Block a user