codestyle changes

This commit is contained in:
Peter Thaleikis 2015-07-27 22:31:18 +12:00
parent ff4a83f9c8
commit ffb25bd689
2 changed files with 69 additions and 69 deletions

View File

@ -15,11 +15,11 @@
class ArrayData extends ViewableData {
/**
* @var array
* @var array
* @see ArrayData::_construct()
*/
protected $array;
/**
* @param object|array $value An associative array, or an object with simple properties.
* Converts object properties to keys of an associative array.
@ -37,7 +37,7 @@ class ArrayData extends ViewableData {
}
parent::__construct();
}
/**
* Get the source array
*
@ -46,7 +46,7 @@ class ArrayData extends ViewableData {
public function toMap() {
return $this->array;
}
/**
* Gets a field from this object.
*
@ -78,7 +78,7 @@ class ArrayData extends ViewableData {
public function setField($field, $value) {
$this->array[$field] = $value;
}
/**
* Check array to see if field isset
*
@ -88,7 +88,7 @@ class ArrayData extends ViewableData {
public function hasField($f) {
return isset($this->array[$f]);
}
/**
* Converts an associative array to a simple object
*

View File

@ -17,7 +17,7 @@ class Requirements implements Flushable {
/**
* Enable combining of css/javascript files.
*
*
* @param bool $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.
*
*
* @return bool
*/
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
*
*
* @param string $folder Path to 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
* 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.
@ -64,8 +64,8 @@ class Requirements implements Flushable {
}
/**
* Instance of the requirements for storage. You can create your own backend to change the
* default JS and CSS inclusion behaviour.
* Instance of the requirements for storage. You can create your own backend to change the
* default JS and CSS inclusion behaviour.
*
* @var Requirements_Backend
*/
@ -89,7 +89,7 @@ class Requirements implements Flushable {
/**
* Register the given JavaScript file as required.
*
*
* @param string $file Relative to docroot
*/
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|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.
*
* @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')
*/
public static function css($file, $media = null) {
@ -162,13 +162,13 @@ class Requirements implements Flushable {
* Registers the given themeable stylesheet as required.
*
* 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.
*
* @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.
* @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')
*/
public static function themedCSS($name, $module = null, $media = null) {
@ -177,8 +177,8 @@ class Requirements implements Flushable {
/**
* 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.
*
* @param string|int $fileOrID
@ -195,11 +195,11 @@ class Requirements implements Flushable {
}
/**
* Block inclusion of a specific file
*
* The difference between this and {@link clear} is that the calling order does not matter;
* Block inclusion of a specific file
*
* 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
* 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.
*
* 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) {
self::backend()->block($fileOrID);
}
/**
* 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
*
*
* @param 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
* directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js,
* 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,
* 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'
* @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
* @param bool $langOnly Only include language files, not the base libraries
*
*
* @return array
*/
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.
*
* @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
* combined files.
* combined files.
*/
public static function process_combined_files() {
return self::backend()->process_combined_files();
@ -397,11 +397,11 @@ class Requirements implements Flushable {
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
* 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.
*
*
* @var bool
*/
protected $suffix_requirements = true;
@ -442,13 +442,13 @@ class Requirements_Backend {
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.
*/
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.
*
* @var array $disabled
@ -457,10 +457,10 @@ class Requirements_Backend {
/**
* 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
* duplicate a lot of code.
*
*
* Use {@link unblock()} or {@link unblock_all()} to revert changes.
*
* @var array $blocked
@ -488,21 +488,21 @@ class Requirements_Backend {
* @var boolean
*/
public $write_header_comment = true;
/**
* 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
* relative paths.
*
* relative paths.
*
* @var string
*/
protected $combinedFilesFolder = null;
/**
* 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.
*
*
* @var bool
*/
public $write_js_to_body = true;
@ -516,7 +516,7 @@ class Requirements_Backend {
/**
* Enable or disable the combination of CSS and JavaScript files
*
*
* @param $enable
*/
public function set_combined_files_enabled($enable) {
@ -525,7 +525,7 @@ class Requirements_Backend {
/**
* Check whether file combination is enabled.
*
*
* @return bool
*/
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,
* 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.
*
*
* @param string $folder
*/
public function setCombinedFilesFolder($folder) {
@ -589,7 +589,7 @@ class Requirements_Backend {
public function set_force_js_to_bottom($var) {
$this->force_js_to_bottom = $var;
}
/**
* 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
*
*
* @return array
*/
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
// script tag.
$content = preg_replace("/(<\/body[^>]*>)/i", $jsRequirements . "\\1", $content);
// 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) {
// Remove all newlines from code to preserve layout
$jsRequirements = preg_replace('/>\n*/', '>', $jsRequirements);
// 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.
$p2 = stripos($content, '<body');
$p1 = stripos($content, '<script', $p2);
$commentTags = array();
$canWriteToBody = ($p1 !== false)
&&
// Check that the script tag is not inside a html comment tag
!(
preg_match('/.*(?|(<!--)|(-->))/U', $content, $commentTags, 0, $p1)
&&
&&
$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.
*
* 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
* JavaScript, we use the external JSMin library to minify the JavaScript. This can be
* 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
* JavaScript, we use the external JSMin library to minify the JavaScript. This can be
* 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
* mode ({@link Director::isDev()}).
*
* 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
* 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
* 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.
*
@ -1036,7 +1036,7 @@ class Requirements_Backend {
* @param string $combinedFileName Filename of the combined file relative to docroot
* @param array $files Array of filenames relative to docroot
* @param string $media
*
*
* @return bool|void
*/
public function combine_files($combinedFileName, $files, $media = null) {
@ -1236,7 +1236,7 @@ class Requirements_Backend {
$combinedData = "";
foreach(array_diff($fileList, $this->blocked) as $file) {
$fileContent = file_get_contents($base . $file);
try{
$fileContent = $this->minifyFile($file, $fileContent);
}catch(Exception $e){
@ -1258,10 +1258,10 @@ class Requirements_Backend {
fclose($fh);
unset($fh);
}
if($failedToMinify){
// 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);
}
@ -1281,7 +1281,7 @@ class Requirements_Backend {
/**
* Minify the given $content according to the file type indicated in $filename
*
*
* @param string $filename
* @param string $content
* @return string
@ -1319,7 +1319,7 @@ class Requirements_Backend {
$abstheme = $absbase . $theme;
$absproject = $absbase . $project;
$css = "/css/$name.css";
if(file_exists($absproject . $css)) {
$this->css($project . $css, $media);
} elseif($module && file_exists($abstheme . '_' . $module.$css)) {