Skip to content

Commit

Permalink
Correct line length and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwelsh committed Aug 21, 2013
1 parent ba6fde6 commit 151baee
Show file tree
Hide file tree
Showing 30 changed files with 137 additions and 88 deletions.
6 changes: 4 additions & 2 deletions admin/tests/LeftAndMainTest.php
Expand Up @@ -49,8 +49,10 @@ public function testExtraCssAndJavascript() {
$this->session()->inst_set('loggedInAs', $admin->ID);
$response = $this->get('LeftAndMainTest_Controller');

$this->assertRegExp('/tests\/assets\/LeftAndMainTest.css/i', $response->getBody(), "body should contain custom css");
$this->assertRegExp('/tests\/assets\/LeftAndMainTest.js/i', $response->getBody(), "body should contain custom js");
$this->assertRegExp('/tests\/assets\/LeftAndMainTest.css/i', $response->getBody(),
"body should contain custom css");
$this->assertRegExp('/tests\/assets\/LeftAndMainTest.js/i', $response->getBody(),
"body should contain custom js");
}

/**
Expand Down
1 change: 0 additions & 1 deletion api/XMLDataFormatter.php
Expand Up @@ -96,7 +96,6 @@ public function convertDataObjectWithoutHeader(DataObject $obj, $fields = null,
$items = $obj->$relName();
if ($items) {
foreach($items as $item) {
//$href = Director::absoluteURL($this->config()->api_base . "$className/$id/$relName/$item->ID");
$href = Director::absoluteURL($this->config()->api_base . "$relClass/$item->ID");
$xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\"></$relClass>\n";
}
Expand Down
2 changes: 1 addition & 1 deletion cache/Cache.php
Expand Up @@ -257,7 +257,7 @@ public static function factory($for, $frontend='Output', $frontendOptions=null)

foreach(array('any', $for) as $name) {
if(isset(self::$backend_picks[$name])) {
if(self::$backend_picks[$name]['priority'] > $backend_priority) {
if(self::$backend_picks[$name]['priority'] > $backend_priority) {
$backend_name = self::$backend_picks[$name]['name'];
$backend_priority = self::$backend_picks[$name]['priority'];
}
Expand Down
3 changes: 2 additions & 1 deletion cli-script.php
Expand Up @@ -75,7 +75,8 @@
if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
echo "\nPlease configure your database connection details. You can do this by creating a file
called _ss_environment.php in either of the following locations:\n\n";
echo " - " . BASE_PATH . DIRECTORY_SEPARATOR . "_ss_environment.php\n - " . dirname(BASE_PATH) . DIRECTORY_SEPARATOR . "_ss_environment.php\n\n";
echo " - " . BASE_PATH . DIRECTORY_SEPARATOR . "_ss_environment.php\n - ";
echo dirname(BASE_PATH) . DIRECTORY_SEPARATOR . "_ss_environment.php\n\n";
echo <<<ENVCONTENT
Put the following content into this file:
Expand Down
30 changes: 15 additions & 15 deletions dev/BehatFixtureFactory.php
Expand Up @@ -4,20 +4,20 @@
* @subpackage testing
*/
class BehatFixtureFactory extends \FixtureFactory {
public function createObject($name, $identifier, $data = null) {
if(!$data) $data = array();
public function createObject($name, $identifier, $data = null) {
if(!$data) $data = array();

// Copy identifier to some visible property unless its already defined.
// Exclude files, since they generate their own named based on the file path.
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
foreach(array('Name', 'Title') as $fieldName) {
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
$data[$fieldName] = $identifier;
break;
}
}
}
// Copy identifier to some visible property unless its already defined.
// Exclude files, since they generate their own named based on the file path.
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
foreach(array('Name', 'Title') as $fieldName) {
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
$data[$fieldName] = $identifier;
break;
}
}
}

return parent::createObject($name, $identifier, $data);
}
}
return parent::createObject($name, $identifier, $data);
}
}
3 changes: 2 additions & 1 deletion dev/CsvBulkLoader.php
Expand Up @@ -210,7 +210,8 @@ public function findExistingObject($record) {
if(is_string($duplicateCheck)) {
$SQL_fieldName = Convert::raw2sql($duplicateCheck);

if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) { //skip current duplicate check if field value is empty
if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) {
//skip current duplicate check if field value is empty
continue;
}

Expand Down
16 changes: 14 additions & 2 deletions dev/SapphireTest.php
Expand Up @@ -501,12 +501,24 @@ public function tearDown() {
}
}

public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) {
public static function assertContains(
$needle,
$haystack,
$message = '',
$ignoreCase = FALSE,
$checkForObjectIdentity = TRUE
) {
if ($haystack instanceof DBField) $haystack = (string)$haystack;
parent::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity);
}

public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) {
public static function assertNotContains(
$needle,
$haystack,
$message = '',
$ignoreCase = FALSE,
$checkForObjectIdentity = TRUE
) {
if ($haystack instanceof DBField) $haystack = (string)$haystack;
parent::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity);
}
Expand Down
8 changes: 5 additions & 3 deletions filesystem/ImagickBackend.php
Expand Up @@ -255,12 +255,14 @@ public function croppedResize($width, $height) {
$new->setBackgroundColor($backgroundColor);

if(($geo['width']/$width) < ($geo['height']/$height)){
$new->cropImage($geo['width'], floor($height*$geo['width']/$width), 0, (($geo['height']-($height*$geo['width']/$width))/2));
$new->cropImage($geo['width'], floor($height*$geo['width']/$width),
0, (($geo['height']-($height*$geo['width']/$width))/2));
}else{
$new->cropImage(ceil($width*$geo['height']/$height), $geo['height'], (($geo['width']-($width*$geo['height']/$height))/2), 0);
$new->cropImage(ceil($width*$geo['height']/$height), $geo['height'],
(($geo['width']-($width*$geo['height']/$height))/2), 0);
}
$new->ThumbnailImage($width,$height,true);
return $new;
}
}
}
}
4 changes: 3 additions & 1 deletion forms/CheckboxField.php
Expand Up @@ -56,7 +56,9 @@ public function performReadonlyTransformation() {
}

public function Value() {
return Convert::raw2xml($this->value ? _t('CheckboxField.YESANSWER', 'Yes') : _t('CheckboxField.NOANSWER', 'No'));
return Convert::raw2xml($this->value ?
_t('CheckboxField.YESANSWER', 'Yes') :
_t('CheckboxField.NOANSWER', 'No'));
}

}
3 changes: 2 additions & 1 deletion forms/CheckboxSetField.php
Expand Up @@ -181,7 +181,8 @@ public function setValue($value, $obj = null) {
public function saveInto(DataObjectInterface $record) {
$fieldname = $this->name;
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
if($fieldname && $record && $relation &&
($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
$idList = array();
if($this->value) foreach($this->value as $id => $bool) {
if($bool) {
Expand Down
2 changes: 1 addition & 1 deletion forms/ConfirmedPasswordField.php
Expand Up @@ -66,7 +66,7 @@ class ConfirmedPasswordField extends FormField {
*
* @var FieldList
*/
public $children;
public $children;

/**
* @param string $name
Expand Down
6 changes: 4 additions & 2 deletions forms/HtmlEditorField.php
Expand Up @@ -360,7 +360,8 @@ public function MediaForm() {
'<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'),
$remoteURL = new TextField('RemoteURL', 'http://'),
new LiteralField('addURLImage',
'<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">'._t('HtmlEditorField.BUTTONADDURL', 'Add url').'</button>')
'<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' .
_t('HtmlEditorField.BUTTONADDURL', 'Add url').'</button>')
);

$remoteURL->addExtraClass('remoteurl');
Expand Down Expand Up @@ -640,7 +641,8 @@ protected function getFieldsForFlash($url, $file) {
*/
protected function getFieldsForImage($url, $file) {
if($file->File instanceof Image) {
$formattedImage = $file->File->generateFormattedImage('SetWidth', Config::inst()->get('Image', 'asset_preview_width'));
$formattedImage = $file->File->generateFormattedImage('SetWidth',
Config::inst()->get('Image', 'asset_preview_width'));
$thumbnailURL = $formattedImage ? $formattedImage->URL : $url;
} else {
$thumbnailURL = $url;
Expand Down
3 changes: 2 additions & 1 deletion forms/ListboxField.php
Expand Up @@ -179,7 +179,8 @@ public function saveInto(DataObjectInterface $record) {
if($this->multiple) {
$fieldname = $this->name;
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
if($fieldname && $record && $relation &&
($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
$idList = (is_array($this->value)) ? array_values($this->value) : array();
if(!$record->ID) {
$record->write(); // record needs to have an ID in order to set relationships
Expand Down
6 changes: 4 additions & 2 deletions i18n/i18n.php
Expand Up @@ -676,7 +676,8 @@ public static function get_time_format() {
),
'be' => array(
'name' => 'Belarusian',
'native' => '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
'native' =>
'&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
),
'bn' => array(
'name' => 'Bengali',
Expand Down Expand Up @@ -1024,7 +1025,8 @@ public static function get_time_format() {
),
'be_BY' => array(
'name' => 'Belarusian',
'native' => '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
'native' =>
'&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
),
'bn_BD' => array(
'name' => 'Bengali',
Expand Down
4 changes: 2 additions & 2 deletions model/Database.php
Expand Up @@ -1157,7 +1157,7 @@ public function table() {
$result .= "<tr>";
foreach($record as $k => $v) {
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
}
}
$result .= "</tr> \n";
}

Expand Down Expand Up @@ -1234,7 +1234,7 @@ public function next() {
*/
public function valid() {
if(!$this->queryHasBegun) $this->next();
return $this->currentRecord !== false;
return $this->currentRecord !== false;
}

/**
Expand Down
10 changes: 6 additions & 4 deletions model/Hierarchy.php
Expand Up @@ -98,13 +98,15 @@ public function validate(ValidationResult $validationResult) {
* should not change this.
* @param int $nodeCountThreshold See {@link self::$node_threshold_total}
* @param callable $nodeCountCallback Called with the node count, which gives the callback an opportunity
* to intercept the query. Useful e.g. to avoid excessive children listings (Arguments: $parent, $numChildren)
* to intercept the query. Useful e.g. to avoid excessive children listings
* (Arguments: $parent, $numChildren)
*
* @return string
*/
public function getChildrenAsUL($attributes = "", $titleEval = '"<li>" . $child->Title', $extraArg = null,
$limitToMarked = false, $childrenMethod = "AllChildrenIncludingDeleted",
$numChildrenMethod = "numChildren", $rootCall = true, $nodeCountThreshold = null, $nodeCountCallback = null) {
$numChildrenMethod = "numChildren", $rootCall = true,
$nodeCountThreshold = null, $nodeCountCallback = null) {

if(!is_numeric($nodeCountThreshold)) {
$nodeCountThreshold = Config::inst()->get('Hierarchy', 'node_threshold_total');
Expand Down Expand Up @@ -154,8 +156,8 @@ public function getChildrenAsUL($attributes = "", $titleEval = '"<li>" . $child-
$output .= $nodeCountWarning;
$child->markClosed();
} else {
$output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod,
$numChildrenMethod, false, $nodeCountThreshold);
$output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked,
$childrenMethod, $numChildrenMethod, false, $nodeCountThreshold);
}
} elseif($child->isTreeOpened()) {
// Since we're not loading children, don't mark it as open either
Expand Down
24 changes: 15 additions & 9 deletions parsers/ShortcodeParser.php
Expand Up @@ -245,12 +245,14 @@ protected function extractTags($content) {

if ($i == 0) {
$err = 'Close tag "'.$tags[$i]['close'].'" is the first found tag, so has no related open tag';
}
}
else if (!$tags[$i-1]['open']) {
$err = 'Close tag "'.$tags[$i]['close'].'" preceded by another close tag "'.$tags[$i-1]['close'].'"';
$err = 'Close tag "'.$tags[$i]['close'].'" preceded by another close tag "'.
$tags[$i-1]['close'].'"';
}
else if ($tags[$i]['close'] != $tags[$i-1]['open']) {
$err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.$tags[$i-1]['open'].'"';
$err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.
$tags[$i-1]['open'].'"';
}

if($err) {
Expand Down Expand Up @@ -332,7 +334,8 @@ protected function replaceAttributeTagsWithContent($htmlvalue) {
$tags = $this->extractTags($node->nodeValue);

if($tags) {
$node->nodeValue = $this->replaceTagsWithText($node->nodeValue, $tags, function($idx, $tag) use ($parser){
$node->nodeValue = $this->replaceTagsWithText($node->nodeValue, $tags,
function($idx, $tag) use ($parser){
$content = $parser->callShortcode($tag['open'], $tag['attrs'], $tag['content']);

if ($content === false) {
Expand Down Expand Up @@ -381,7 +384,8 @@ protected function findParentsForMarkers($nodes) {
do {
$parent = $parent->parentNode;
}
while($parent instanceof DOMElement && !in_array(strtolower($parent->tagName), self::$block_level_elements));
while($parent instanceof DOMElement &&
!in_array(strtolower($parent->tagName), self::$block_level_elements));

$node->setAttribute('data-parentid', count($parents));
$parents[] = $parent;
Expand Down Expand Up @@ -451,7 +455,8 @@ protected function moveMarkerToCompliantHome($node, $parent, $location) {
else if($location == self::INLINE) {
if(in_array(strtolower($node->tagName), self::$block_level_elements)) {
user_error(
'Requested to insert block tag '.$node->tagName.' inline - probably this will break HTML compliance',
'Requested to insert block tag '.$node->tagName.
' inline - probably this will break HTML compliance',
E_USER_WARNING
);
}
Expand All @@ -461,7 +466,7 @@ protected function moveMarkerToCompliantHome($node, $parent, $location) {
user_error('Unknown value for $location argument '.$location, E_USER_ERROR);
}
}

/**
* Given a node with represents a shortcode marker and some information about the shortcode, call the
* shortcode handler & replace the marker with the actual content
Expand All @@ -484,7 +489,7 @@ protected function replaceMarkerWithContent($node, $tag) {
$content = $tag['text'];
}
else {
// self::$error_behavior == self::STRIP - NOP
// self::$error_behavior == self::STRIP - NOP
}
}

Expand Down Expand Up @@ -549,7 +554,8 @@ public function parse($content) {

if(!$parent) {
if($location !== self::INLINE) {
user_error("Parent block for shortcode couldn't be found, but location wasn't INLINE", E_USER_ERROR);
user_error("Parent block for shortcode couldn't be found, but location wasn't INLINE",
E_USER_ERROR);
}
}
else {
Expand Down
6 changes: 4 additions & 2 deletions security/Group.php
Expand Up @@ -113,11 +113,13 @@ public function getCMSFields() {
} elseif($record && $record->ID) {
// TODO Mark disabled once chosen.js supports it
// $groupsField->setDisabledItems(array($group->ID));
$form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
$form->Fields()->replaceField('DirectGroups',
$groupsField->performReadonlyTransformation());
}
}
});
$memberList = GridField::create('Members',false, $this->DirectMembers(), $config)->addExtraClass('members_grid');
$memberList = GridField::create('Members',false, $this->DirectMembers(), $config)
->addExtraClass('members_grid');
// @todo Implement permission checking on GridField
//$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
$fields->addFieldToTab('Root.Members', $memberList);
Expand Down
2 changes: 1 addition & 1 deletion security/Security.php
Expand Up @@ -689,7 +689,7 @@ public function changepassword() {
* @return Form Returns the lost password form
*/
public function ChangePasswordForm() {
return Object::create('ChangePasswordForm', $this, 'ChangePasswordForm');
return Object::create('ChangePasswordForm', $this, 'ChangePasswordForm');
}

/**
Expand Down

0 comments on commit 151baee

Please sign in to comment.