minor codestyle stuff

This commit is contained in:
Peter Thaleikis 2015-07-27 19:17:37 +12:00
parent 7b9bbe17dc
commit bd4fc4afcb
3 changed files with 21 additions and 21 deletions

View File

@ -39,7 +39,7 @@ class HTTP {
$slashPos = -1;
while(($slashPos = strpos($filename, "/", $slashPos+1)) !== false) {
if(substr($filename, 0, $slashPos) == substr($_SERVER['SCRIPT_FILENAME'],0,$slashPos)) {
if(substr($filename, 0, $slashPos) == substr($_SERVER['SCRIPT_FILENAME'], 0, $slashPos)) {
$commonLength = $slashPos;
} else {
break;
@ -56,7 +56,7 @@ class HTTP {
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? "https" : "http";
// Count the number of extra folders the script is in.
// $prefix = str_repeat("../", substr_count(substr($_SERVER[SCRIPT_FILENAME],$commonBaseLength)));
// $prefix = str_repeat("../", substr_count(substr($_SERVER[SCRIPT_FILENAME], $commonBaseLength)));
return "$protocol://". $_SERVER['HTTP_HOST'] . $url;
}
@ -68,7 +68,7 @@ class HTTP {
$html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html);
return HTTP::urlRewriter($html, function($url) {
//no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":")
if(preg_match('/^\w+:/', $url)){
if(preg_match('/^\w+:/', $url)) {
return $url;
}
return Director::absoluteURL($url, true);
@ -83,7 +83,7 @@ class HTTP {
* <ul>
* <li><code>'"../../" . $URL'</code></li>
* <li><code>'myRewriter($URL)'</code></li>
* <li><code>'(substr($URL,0,1)=="/") ? "../" . substr($URL,1) : $URL'</code></li>
* <li><code>'(substr($URL, 0, 1)=="/") ? "../" . substr($URL, 1) : $URL'</code></li>
* </ul>
*
* As of 3.2 $code should be a callable which takes a single parameter and returns
@ -107,7 +107,7 @@ class HTTP {
}
// Replace attributes
$attribs = array("src","background","a" => "href","link" => "href", "base" => "href");
$attribs = array("src", "background", "a" => "href", "link" => "href", "base" => "href");
foreach($attribs as $tag => $attrib) {
if(!is_numeric($tag)) $tagPrefix = "$tag ";
else $tagPrefix = "";

View File

@ -109,8 +109,8 @@ class SS_HTTPRequest implements ArrayAccess {
$this->httpMethod = strtoupper(self::detect_method($httpMethod, $postVars));
$this->setUrl($url);
$this->getVars = (array)$getVars;
$this->postVars = (array)$postVars;
$this->getVars = (array) $getVars;
$this->postVars = (array) $postVars;
$this->body = $body;
}
@ -129,7 +129,7 @@ class SS_HTTPRequest implements ArrayAccess {
// Normalize URL if its relative (strictly speaking), or has leading slashes
if(Director::is_relative_url($url) || preg_match('/^\//', $url)) {
$this->url = preg_replace(array('/\/+/','/^\//', '/\/$/'),array('/','',''), $this->url);
$this->url = preg_replace(array('/\/+/', '/^\//', '/\/$/'),array('/', '', ''), $this->url);
}
if(preg_match('/^(.*)\.([A-Za-z][A-Za-z0-9]*)$/', $this->url, $matches)) {
$this->url = $matches[1];
@ -440,7 +440,7 @@ class SS_HTTPRequest implements ArrayAccess {
// Check for the '//' marker that represents the "shifting point"
$doubleSlashPoint = strpos($pattern, '//');
if($doubleSlashPoint !== false) {
$shiftCount = substr_count(substr($pattern,0,$doubleSlashPoint), '/') + 1;
$shiftCount = substr_count(substr($pattern, 0, $doubleSlashPoint), '/') + 1;
$pattern = str_replace('//', '/', $pattern);
$patternParts = explode('/', $pattern);
@ -462,10 +462,10 @@ class SS_HTTPRequest implements ArrayAccess {
// A variable ending in ! is required
if(substr($part,-1) == '!') {
$varRequired = true;
$varName = substr($part,1,-1);
$varName = substr($part, 1, -1);
} else {
$varRequired = false;
$varName = substr($part,1);
$varName = substr($part, 1);
}
// Fail if a required variable isn't populated
@ -681,7 +681,7 @@ class SS_HTTPRequest implements ArrayAccess {
*/
public function getAcceptMimetypes($includeQuality = false) {
$mimetypes = array();
$mimetypesWithQuality = explode(',',$this->getHeader('Accept'));
$mimetypesWithQuality = explode(', ', $this->getHeader('Accept'));
foreach($mimetypesWithQuality as $mimetypeWithQuality) {
$mimetypes[] = ($includeQuality) ? $mimetypeWithQuality : preg_replace('/;.*/', '', $mimetypeWithQuality);
}
@ -713,7 +713,7 @@ class SS_HTTPRequest implements ArrayAccess {
*/
public static function detect_method($origMethod, $postVars) {
if(isset($postVars['_method'])) {
if(!in_array(strtoupper($postVars['_method']), array('GET','POST','PUT','DELETE','HEAD'))) {
if(!in_array(strtoupper($postVars['_method']), array('GET', 'POST', 'PUT', 'DELETE', 'HEAD'))) {
user_error('Director::direct(): Invalid "_method" parameter', E_USER_ERROR);
}
return strtoupper($postVars['_method']);

View File

@ -30,7 +30,7 @@
* Session::set('MyVar', $var);
*
* // saves an array
* Session::set('MyArrayOfValues', array('1','2','3'));
* Session::set('MyArrayOfValues', array('1', '2', '3'));
*
* // saves an object (you'll have to unserialize it back)
* $object = new Object();
@ -411,7 +411,7 @@ class Session {
public function inst_set($name, $val) {
// Quicker execution path for "."-free names
if(strpos($name,'.') === false) {
if(strpos($name, '.') === false) {
$this->data[$name] = $val;
$this->changedData[$name] = $val;
@ -459,7 +459,7 @@ class Session {
public function inst_get($name) {
// Quicker execution path for "."-free names
if(strpos($name,'.') === false) {
if(strpos($name, '.') === false) {
if(isset($this->data[$name])) return $this->data[$name];
} else {
@ -569,7 +569,7 @@ class Session {
* @param string $message the message you wish to add to it
* @param string $type the type of message
*/
public static function setFormMessage($formname, $message, $type){
public static function setFormMessage($formname, $message, $type) {
Session::set("FormInfo.$formname.formError.message", $message);
Session::set("FormInfo.$formname.formError.type", $type);
}
@ -611,7 +611,7 @@ class Session {
*/
public static function set_timeout($timeout) {
Deprecation::notice('3.2', 'Use the "Session.timeout" config setting instead');
Config::inst()->update('Session', 'timeout', (int)$timeout);
Config::inst()->update('Session', 'timeout', (int) $timeout);
}
/**