mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
codestyle changes
This commit is contained in:
parent
ff4a83f9c8
commit
ffb25bd689
@ -15,11 +15,11 @@
|
|||||||
class ArrayData extends ViewableData {
|
class ArrayData extends ViewableData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
* @see ArrayData::_construct()
|
* @see ArrayData::_construct()
|
||||||
*/
|
*/
|
||||||
protected $array;
|
protected $array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object|array $value An associative array, or an object with simple properties.
|
* @param object|array $value An associative array, or an object with simple properties.
|
||||||
* Converts object properties to keys of an associative array.
|
* Converts object properties to keys of an associative array.
|
||||||
@ -37,7 +37,7 @@ class ArrayData extends ViewableData {
|
|||||||
}
|
}
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the source array
|
* Get the source array
|
||||||
*
|
*
|
||||||
@ -46,7 +46,7 @@ class ArrayData extends ViewableData {
|
|||||||
public function toMap() {
|
public function toMap() {
|
||||||
return $this->array;
|
return $this->array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a field from this object.
|
* Gets a field from this object.
|
||||||
*
|
*
|
||||||
@ -78,7 +78,7 @@ class ArrayData extends ViewableData {
|
|||||||
public function setField($field, $value) {
|
public function setField($field, $value) {
|
||||||
$this->array[$field] = $value;
|
$this->array[$field] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check array to see if field isset
|
* Check array to see if field isset
|
||||||
*
|
*
|
||||||
@ -88,7 +88,7 @@ class ArrayData extends ViewableData {
|
|||||||
public function hasField($f) {
|
public function hasField($f) {
|
||||||
return isset($this->array[$f]);
|
return isset($this->array[$f]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an associative array to a simple object
|
* Converts an associative array to a simple object
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,7 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable combining of css/javascript files.
|
* Enable combining of css/javascript files.
|
||||||
*
|
*
|
||||||
* @param bool $enable
|
* @param bool $enable
|
||||||
*/
|
*/
|
||||||
public static function set_combined_files_enabled($enable) {
|
public static function set_combined_files_enabled($enable) {
|
||||||
@ -26,7 +26,7 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether combining of css/javascript files is enabled.
|
* Checks whether combining of css/javascript files is enabled.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function get_combined_files_enabled() {
|
public static function get_combined_files_enabled() {
|
||||||
@ -35,7 +35,7 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the relative folder e.g. 'assets' for where to store combined files
|
* Set the relative folder e.g. 'assets' for where to store combined files
|
||||||
*
|
*
|
||||||
* @param string $folder Path to folder
|
* @param string $folder Path to folder
|
||||||
*/
|
*/
|
||||||
public static function set_combined_files_folder($folder) {
|
public static function set_combined_files_folder($folder) {
|
||||||
@ -43,7 +43,7 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether to add caching query params to the requests for file-based requirements.
|
* Set whether to add caching query params to the requests for file-based requirements.
|
||||||
* Eg: themes/myTheme/js/main.js?m=123456789. The parameter is a timestamp generated by
|
* Eg: themes/myTheme/js/main.js?m=123456789. The parameter is a timestamp generated by
|
||||||
* filemtime. This has the benefit of allowing the browser to cache the URL infinitely,
|
* filemtime. This has the benefit of allowing the browser to cache the URL infinitely,
|
||||||
* while automatically busting this cache every time the file is changed.
|
* while automatically busting this cache every time the file is changed.
|
||||||
@ -64,8 +64,8 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance of the requirements for storage. You can create your own backend to change the
|
* Instance of the requirements for storage. You can create your own backend to change the
|
||||||
* default JS and CSS inclusion behaviour.
|
* default JS and CSS inclusion behaviour.
|
||||||
*
|
*
|
||||||
* @var Requirements_Backend
|
* @var Requirements_Backend
|
||||||
*/
|
*/
|
||||||
@ -89,7 +89,7 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given JavaScript file as required.
|
* Register the given JavaScript file as required.
|
||||||
*
|
*
|
||||||
* @param string $file Relative to docroot
|
* @param string $file Relative to docroot
|
||||||
*/
|
*/
|
||||||
public static function javascript($file) {
|
public static function javascript($file) {
|
||||||
@ -116,7 +116,7 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given CSS styles into the list of requirements
|
* Register the given CSS styles into the list of requirements
|
||||||
*
|
*
|
||||||
* @param string $script CSS selectors as a string (without enclosing <style> tag)
|
* @param string $script CSS selectors as a string (without enclosing <style> tag)
|
||||||
* @param string|int $uniquenessID A unique ID that ensures a piece of code is only added once
|
* @param string|int $uniquenessID A unique ID that ensures a piece of code is only added once
|
||||||
@ -151,7 +151,7 @@ class Requirements implements Flushable {
|
|||||||
* Register the given stylesheet into the list of requirements.
|
* Register the given stylesheet into the list of requirements.
|
||||||
*
|
*
|
||||||
* @param string $file The CSS file to load, relative to site root
|
* @param string $file The CSS file to load, relative to site root
|
||||||
* @param string $media Comma-separated list of media types to use in the link tag
|
* @param string $media Comma-separated list of media types to use in the link tag
|
||||||
* (e.g. 'screen,projector')
|
* (e.g. 'screen,projector')
|
||||||
*/
|
*/
|
||||||
public static function css($file, $media = null) {
|
public static function css($file, $media = null) {
|
||||||
@ -162,13 +162,13 @@ class Requirements implements Flushable {
|
|||||||
* Registers the given themeable stylesheet as required.
|
* Registers the given themeable stylesheet as required.
|
||||||
*
|
*
|
||||||
* A CSS file in the current theme path name 'themename/css/$name.css' is first searched for,
|
* A CSS file in the current theme path name 'themename/css/$name.css' is first searched for,
|
||||||
* and it that doesn't exist and the module parameter is set then a CSS file with that name in
|
* and it that doesn't exist and the module parameter is set then a CSS file with that name in
|
||||||
* the module is used.
|
* the module is used.
|
||||||
*
|
*
|
||||||
* @param string $name The name of the file - eg '/css/File.css' would have the name 'File'
|
* @param string $name The name of the file - eg '/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
|
* @param string $module The module to fall back to if the css file does not exist in the
|
||||||
* current theme.
|
* current theme.
|
||||||
* @param string $media Comma-separated list of media types to use in the link tag
|
* @param string $media Comma-separated list of media types to use in the link tag
|
||||||
* (e.g. 'screen,projector')
|
* (e.g. 'screen,projector')
|
||||||
*/
|
*/
|
||||||
public static function themedCSS($name, $module = null, $media = null) {
|
public static function themedCSS($name, $module = null, $media = null) {
|
||||||
@ -177,8 +177,8 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear either a single or all requirements
|
* Clear either a single or all requirements
|
||||||
*
|
*
|
||||||
* Caution: Clearing single rules added via customCSS and customScript only works if you
|
* Caution: Clearing single rules added via customCSS and customScript only works if you
|
||||||
* originally specified a $uniquenessID.
|
* originally specified a $uniquenessID.
|
||||||
*
|
*
|
||||||
* @param string|int $fileOrID
|
* @param string|int $fileOrID
|
||||||
@ -195,11 +195,11 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block inclusion of a specific file
|
* Block inclusion of a specific file
|
||||||
*
|
*
|
||||||
* The difference between this and {@link clear} is that the calling order does not matter;
|
* The difference between this and {@link clear} is that the calling order does not matter;
|
||||||
* {@link clear} must be called after the initial registration, whereas {@link block} can be
|
* {@link clear} must be called after the initial registration, whereas {@link block} can be
|
||||||
* used in advance. This is useful, for example, to block scripts included by a superclass
|
* used in advance. This is useful, for example, to block scripts included by a superclass
|
||||||
* without having to override entire functions and duplicate a lot of code.
|
* without having to override entire functions and duplicate a lot of code.
|
||||||
*
|
*
|
||||||
* Note that blocking should be used sparingly because it's hard to trace where an file is
|
* Note that blocking should be used sparingly because it's hard to trace where an file is
|
||||||
@ -210,7 +210,7 @@ class Requirements implements Flushable {
|
|||||||
public static function block($fileOrID) {
|
public static function block($fileOrID) {
|
||||||
self::backend()->block($fileOrID);
|
self::backend()->block($fileOrID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an item from the block list
|
* Remove an item from the block list
|
||||||
*
|
*
|
||||||
@ -242,9 +242,9 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the given
|
* Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the given
|
||||||
* HTTP Response
|
* HTTP Response
|
||||||
*
|
*
|
||||||
* @param SS_HTTPResponse $response
|
* @param SS_HTTPResponse $response
|
||||||
*/
|
*/
|
||||||
public static function include_in_response(SS_HTTPResponse $response) {
|
public static function include_in_response(SS_HTTPResponse $response) {
|
||||||
@ -252,16 +252,16 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add i18n files from the given javascript directory. SilverStripe expects that the given
|
* Add i18n files from the given javascript directory. SilverStripe expects that the given
|
||||||
* directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js,
|
* directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js,
|
||||||
* etc.
|
* etc.
|
||||||
*
|
*
|
||||||
* @param string $langDir The JavaScript lang directory, relative to the site root, e.g.,
|
* @param string $langDir The JavaScript lang directory, relative to the site root, e.g.,
|
||||||
* 'framework/javascript/lang'
|
* 'framework/javascript/lang'
|
||||||
* @param bool $return Return all relative file paths rather than including them in
|
* @param bool $return Return all relative file paths rather than including them in
|
||||||
* requirements
|
* requirements
|
||||||
* @param bool $langOnly Only include language files, not the base libraries
|
* @param bool $langOnly Only include language files, not the base libraries
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function add_i18n_javascript($langDir, $return = false, $langOnly = false) {
|
public static function add_i18n_javascript($langDir, $return = false, $langOnly = false) {
|
||||||
@ -320,7 +320,7 @@ class Requirements implements Flushable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all combined files; keys are the combined file names, values are lists of
|
* Return all combined files; keys are the combined file names, values are lists of
|
||||||
* files being combined.
|
* files being combined.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
@ -355,7 +355,7 @@ class Requirements implements Flushable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do the heavy lifting involved in combining (and, in the case of JavaScript minifying) the
|
* Do the heavy lifting involved in combining (and, in the case of JavaScript minifying) the
|
||||||
* combined files.
|
* combined files.
|
||||||
*/
|
*/
|
||||||
public static function process_combined_files() {
|
public static function process_combined_files() {
|
||||||
return self::backend()->process_combined_files();
|
return self::backend()->process_combined_files();
|
||||||
@ -397,11 +397,11 @@ class Requirements implements Flushable {
|
|||||||
class Requirements_Backend {
|
class Requirements_Backend {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to add caching query params to the requests for file-based requirements.
|
* Whether to add caching query params to the requests for file-based requirements.
|
||||||
* Eg: themes/myTheme/js/main.js?m=123456789. The parameter is a timestamp generated by
|
* Eg: themes/myTheme/js/main.js?m=123456789. The parameter is a timestamp generated by
|
||||||
* filemtime. This has the benefit of allowing the browser to cache the URL infinitely,
|
* filemtime. This has the benefit of allowing the browser to cache the URL infinitely,
|
||||||
* while automatically busting this cache every time the file is changed.
|
* while automatically busting this cache every time the file is changed.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $suffix_requirements = true;
|
protected $suffix_requirements = true;
|
||||||
@ -442,13 +442,13 @@ class Requirements_Backend {
|
|||||||
protected $customCSS = array();
|
protected $customCSS = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All custom HTML markup which is added before the closing <head> tag, e.g. additional
|
* All custom HTML markup which is added before the closing <head> tag, e.g. additional
|
||||||
* metatags.
|
* metatags.
|
||||||
*/
|
*/
|
||||||
protected $customHeadTags = array();
|
protected $customHeadTags = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remembers the file paths or uniquenessIDs of all Requirements cleared through
|
* Remembers the file paths or uniquenessIDs of all Requirements cleared through
|
||||||
* {@link clear()}, so that they can be restored later.
|
* {@link clear()}, so that they can be restored later.
|
||||||
*
|
*
|
||||||
* @var array $disabled
|
* @var array $disabled
|
||||||
@ -457,10 +457,10 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The file paths (relative to docroot) or uniquenessIDs of any included requirements which
|
* The file paths (relative to docroot) or uniquenessIDs of any included requirements which
|
||||||
* should be blocked when executing {@link inlcudeInHTML()}. This is useful, for example,
|
* should be blocked when executing {@link inlcudeInHTML()}. This is useful, for example,
|
||||||
* to block scripts included by a superclass without having to override entire functions and
|
* to block scripts included by a superclass without having to override entire functions and
|
||||||
* duplicate a lot of code.
|
* duplicate a lot of code.
|
||||||
*
|
*
|
||||||
* Use {@link unblock()} or {@link unblock_all()} to revert changes.
|
* Use {@link unblock()} or {@link unblock_all()} to revert changes.
|
||||||
*
|
*
|
||||||
* @var array $blocked
|
* @var array $blocked
|
||||||
@ -488,21 +488,21 @@ class Requirements_Backend {
|
|||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $write_header_comment = true;
|
public $write_header_comment = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where to save combined files. By default they're placed in assets/_combinedfiles, however
|
* Where to save combined files. By default they're placed in assets/_combinedfiles, however
|
||||||
* this may be an issue depending on your setup, especially for CSS files which often contain
|
* this may be an issue depending on your setup, especially for CSS files which often contain
|
||||||
* relative paths.
|
* relative paths.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $combinedFilesFolder = null;
|
protected $combinedFilesFolder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put all JavaScript includes at the bottom of the template before the closing <body> tag,
|
* Put all JavaScript includes at the bottom of the template before the closing <body> tag,
|
||||||
* rather than the default behaviour of placing them at the end of the <head> tag. This means
|
* rather than the default behaviour of placing them at the end of the <head> tag. This means
|
||||||
* script downloads won't block other HTTP requests, which can be a performance improvement.
|
* script downloads won't block other HTTP requests, which can be a performance improvement.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $write_js_to_body = true;
|
public $write_js_to_body = true;
|
||||||
@ -516,7 +516,7 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable the combination of CSS and JavaScript files
|
* Enable or disable the combination of CSS and JavaScript files
|
||||||
*
|
*
|
||||||
* @param $enable
|
* @param $enable
|
||||||
*/
|
*/
|
||||||
public function set_combined_files_enabled($enable) {
|
public function set_combined_files_enabled($enable) {
|
||||||
@ -525,7 +525,7 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether file combination is enabled.
|
* Check whether file combination is enabled.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function get_combined_files_enabled() {
|
public function get_combined_files_enabled() {
|
||||||
@ -534,9 +534,9 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the folder to save combined files in. By default they're placed in assets/_combinedfiles,
|
* Set the folder to save combined files in. By default they're placed in assets/_combinedfiles,
|
||||||
* however this may be an issue depending on your setup, especially for CSS files which often
|
* however this may be an issue depending on your setup, especially for CSS files which often
|
||||||
* contain relative paths.
|
* contain relative paths.
|
||||||
*
|
*
|
||||||
* @param string $folder
|
* @param string $folder
|
||||||
*/
|
*/
|
||||||
public function setCombinedFilesFolder($folder) {
|
public function setCombinedFilesFolder($folder) {
|
||||||
@ -589,7 +589,7 @@ class Requirements_Backend {
|
|||||||
public function set_force_js_to_bottom($var) {
|
public function set_force_js_to_bottom($var) {
|
||||||
$this->force_js_to_bottom = $var;
|
$this->force_js_to_bottom = $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given JavaScript file as required.
|
* Register the given JavaScript file as required.
|
||||||
*
|
*
|
||||||
@ -697,7 +697,7 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of registered CSS file requirements, excluding blocked files
|
* Get the list of registered CSS file requirements, excluding blocked files
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_css() {
|
public function get_css() {
|
||||||
@ -839,25 +839,25 @@ class Requirements_Backend {
|
|||||||
// Forcefully put the scripts at the bottom of the body instead of before the first
|
// Forcefully put the scripts at the bottom of the body instead of before the first
|
||||||
// script tag.
|
// script tag.
|
||||||
$content = preg_replace("/(<\/body[^>]*>)/i", $jsRequirements . "\\1", $content);
|
$content = preg_replace("/(<\/body[^>]*>)/i", $jsRequirements . "\\1", $content);
|
||||||
|
|
||||||
// Put CSS at the bottom of the head
|
// Put CSS at the bottom of the head
|
||||||
$content = preg_replace("/(<\/head>)/i", $requirements . "\\1", $content);
|
$content = preg_replace("/(<\/head>)/i", $requirements . "\\1", $content);
|
||||||
} elseif($this->write_js_to_body) {
|
} elseif($this->write_js_to_body) {
|
||||||
// Remove all newlines from code to preserve layout
|
// Remove all newlines from code to preserve layout
|
||||||
$jsRequirements = preg_replace('/>\n*/', '>', $jsRequirements);
|
$jsRequirements = preg_replace('/>\n*/', '>', $jsRequirements);
|
||||||
|
|
||||||
// If your template already has script tags in the body, then we try to put our script
|
// If your template already has script tags in the body, then we try to put our script
|
||||||
// tags just before those. Otherwise, we put it at the bottom.
|
// tags just before those. Otherwise, we put it at the bottom.
|
||||||
$p2 = stripos($content, '<body');
|
$p2 = stripos($content, '<body');
|
||||||
$p1 = stripos($content, '<script', $p2);
|
$p1 = stripos($content, '<script', $p2);
|
||||||
|
|
||||||
$commentTags = array();
|
$commentTags = array();
|
||||||
$canWriteToBody = ($p1 !== false)
|
$canWriteToBody = ($p1 !== false)
|
||||||
&&
|
&&
|
||||||
// Check that the script tag is not inside a html comment tag
|
// Check that the script tag is not inside a html comment tag
|
||||||
!(
|
!(
|
||||||
preg_match('/.*(?|(<!--)|(-->))/U', $content, $commentTags, 0, $p1)
|
preg_match('/.*(?|(<!--)|(-->))/U', $content, $commentTags, 0, $p1)
|
||||||
&&
|
&&
|
||||||
$commentTags[1] == '-->'
|
$commentTags[1] == '-->'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -992,20 +992,20 @@ class Requirements_Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concatenate several css or javascript files into a single dynamically generated file. This
|
* Concatenate several css or javascript files into a single dynamically generated file. This
|
||||||
* increases performance by fewer HTTP requests.
|
* increases performance by fewer HTTP requests.
|
||||||
*
|
*
|
||||||
* The combined file is regenerated based on every file modification time. Optionally a
|
* The combined file is regenerated based on every file modification time. Optionally a
|
||||||
* rebuild can be triggered by appending ?flush=1 to the URL. If all files to be combined are
|
* rebuild can be triggered by appending ?flush=1 to the URL. If all files to be combined are
|
||||||
* JavaScript, we use the external JSMin library to minify the JavaScript. This can be
|
* JavaScript, we use the external JSMin library to minify the JavaScript. This can be
|
||||||
* controlled using {@link $combine_js_with_jsmin}.
|
* controlled using {@link $combine_js_with_jsmin}.
|
||||||
*
|
*
|
||||||
* All combined files will have a comment on the start of each concatenated file denoting their
|
* All combined files will have a comment on the start of each concatenated file denoting their
|
||||||
* original position. For easier debugging, we only minify JavaScript if not in development
|
* original position. For easier debugging, we only minify JavaScript if not in development
|
||||||
* mode ({@link Director::isDev()}).
|
* mode ({@link Director::isDev()}).
|
||||||
*
|
*
|
||||||
* CAUTION: You're responsible for ensuring that the load order for combined files is
|
* CAUTION: You're responsible for ensuring that the load order for combined files is
|
||||||
* retained - otherwise combining JavaScript files can lead to functional errors in the
|
* retained - otherwise combining JavaScript files can lead to functional errors in the
|
||||||
* JavaScript logic, and combining CSS can lead to incorrect inheritance. You can also
|
* JavaScript logic, and combining CSS can lead to incorrect inheritance. You can also
|
||||||
* only include each file once across all includes and combinations in a single page load.
|
* only include each file once across all includes and combinations in a single page load.
|
||||||
*
|
*
|
||||||
@ -1036,7 +1036,7 @@ class Requirements_Backend {
|
|||||||
* @param string $combinedFileName Filename of the combined file relative to docroot
|
* @param string $combinedFileName Filename of the combined file relative to docroot
|
||||||
* @param array $files Array of filenames relative to docroot
|
* @param array $files Array of filenames relative to docroot
|
||||||
* @param string $media
|
* @param string $media
|
||||||
*
|
*
|
||||||
* @return bool|void
|
* @return bool|void
|
||||||
*/
|
*/
|
||||||
public function combine_files($combinedFileName, $files, $media = null) {
|
public function combine_files($combinedFileName, $files, $media = null) {
|
||||||
@ -1236,7 +1236,7 @@ class Requirements_Backend {
|
|||||||
$combinedData = "";
|
$combinedData = "";
|
||||||
foreach(array_diff($fileList, $this->blocked) as $file) {
|
foreach(array_diff($fileList, $this->blocked) as $file) {
|
||||||
$fileContent = file_get_contents($base . $file);
|
$fileContent = file_get_contents($base . $file);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$fileContent = $this->minifyFile($file, $fileContent);
|
$fileContent = $this->minifyFile($file, $fileContent);
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
@ -1258,10 +1258,10 @@ class Requirements_Backend {
|
|||||||
fclose($fh);
|
fclose($fh);
|
||||||
unset($fh);
|
unset($fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($failedToMinify){
|
if($failedToMinify){
|
||||||
// Failed to minify, use unminified files instead. This warning is raised at the end to allow code execution
|
// Failed to minify, use unminified files instead. This warning is raised at the end to allow code execution
|
||||||
// to complete in case this warning is caught inside a try-catch block.
|
// to complete in case this warning is caught inside a try-catch block.
|
||||||
user_error('Failed to minify '.$file.', exception: '.$e->getMessage(), E_USER_WARNING);
|
user_error('Failed to minify '.$file.', exception: '.$e->getMessage(), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1281,7 +1281,7 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Minify the given $content according to the file type indicated in $filename
|
* Minify the given $content according to the file type indicated in $filename
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return string
|
* @return string
|
||||||
@ -1319,7 +1319,7 @@ class Requirements_Backend {
|
|||||||
$abstheme = $absbase . $theme;
|
$abstheme = $absbase . $theme;
|
||||||
$absproject = $absbase . $project;
|
$absproject = $absbase . $project;
|
||||||
$css = "/css/$name.css";
|
$css = "/css/$name.css";
|
||||||
|
|
||||||
if(file_exists($absproject . $css)) {
|
if(file_exists($absproject . $css)) {
|
||||||
$this->css($project . $css, $media);
|
$this->css($project . $css, $media);
|
||||||
} elseif($module && file_exists($abstheme . '_' . $module.$css)) {
|
} elseif($module && file_exists($abstheme . '_' . $module.$css)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user