From 816edabd3f5ea2b02ae31a7d4349f055d4dd2aba Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Fri, 4 May 2012 13:39:08 +1200 Subject: [PATCH] MINOR Added public keyword for methods (style guidelines) --- code/formfields/FieldEditor.php | 10 +++---- code/formfields/SubmittedFormReportField.php | 8 +++--- code/model/UserDefinedForm.php | 26 +++++++++---------- .../formfields/EditableCheckboxGroupField.php | 4 +-- code/model/formfields/EditableDateField.php | 4 +-- code/model/formfields/EditableDropdown.php | 2 +- code/model/formfields/EditableEmailField.php | 2 +- code/model/formfields/EditableFormField.php | 10 +++---- code/model/formfields/EditableFormHeading.php | 8 +++--- .../model/formfields/EditableLiteralField.php | 6 ++--- .../formfields/EditableMemberListField.php | 6 ++--- code/model/formfields/EditableRadioField.php | 2 +- code/model/formfields/EditableTextField.php | 4 +-- code/model/submissions/SubmittedFileField.php | 4 +-- code/model/submissions/SubmittedFormField.php | 2 +- code/tasks/UserFormsVersionedTask.php | 2 +- tests/FieldEditorTest.php | 2 +- 17 files changed, 51 insertions(+), 51 deletions(-) diff --git a/code/formfields/FieldEditor.php b/code/formfields/FieldEditor.php index 064ed92..ccceeec 100755 --- a/code/formfields/FieldEditor.php +++ b/code/formfields/FieldEditor.php @@ -13,7 +13,7 @@ class FieldEditor extends FormField { * * @return String */ - function FieldHolder() { + public function FieldHolder() { return $this->renderWith("FieldEditor"); } @@ -46,7 +46,7 @@ class FieldEditor extends FormField { * * @return ViewableData_Customised */ - function performReadonlyTransformation() { + public function performReadonlyTransformation() { $clone = clone $this; $clone->readonly = true; $fields = $clone->Fields(); @@ -62,7 +62,7 @@ class FieldEditor extends FormField { * * @return DataObjectSet */ - function Fields() { + public function Fields() { // Don't return any fields unless we actually have the dependent parameters set on the form field if($this->form && $this->form->getRecord() && $this->name) { $relationName = $this->name; @@ -89,7 +89,7 @@ class FieldEditor extends FormField { * * @return DataObjectSet */ - function CreatableFields() { + public function CreatableFields() { $fields = ClassInfo::subclassesFor('EditableFormField'); if($fields) { @@ -117,7 +117,7 @@ class FieldEditor extends FormField { * * @param DataObject Record to Save it In */ - function saveInto(DataObject $record) { + public function saveInto(DataObject $record) { $name = $this->name; $fieldSet = $record->$name(); diff --git a/code/formfields/SubmittedFormReportField.php b/code/formfields/SubmittedFormReportField.php index 5ca3729..5091d3f 100755 --- a/code/formfields/SubmittedFormReportField.php +++ b/code/formfields/SubmittedFormReportField.php @@ -7,7 +7,7 @@ class SubmittedFormReportField extends FormField { - function Field() { + public function Field() { Requirements::css(FRAMEWORK_DIR . "/css/SubmittedFormReportField.css"); Requirements::javascript("userforms/javascript/UserForm.js"); return $this->renderWith("SubmittedFormReportField"); @@ -18,7 +18,7 @@ class SubmittedFormReportField extends FormField { * * @return ComponentSet */ - function Submissions() { + public function Submissions() { $pageStart = isset($_REQUEST['start']) && is_numeric($_REQUEST['start']) ? $_REQUEST['start'] : 0; $pageLength = 10; @@ -37,7 +37,7 @@ class SubmittedFormReportField extends FormField { return $items; } - function getSubmissions() { + public function getSubmissions() { return $this->customise(array( 'Submissions' => $this->Submissions() ))->renderWith(array('SubmittedFormReportField')); @@ -48,7 +48,7 @@ class SubmittedFormReportField extends FormField { * * @return int */ - function RecordID() { + public function RecordID() { return $this->form->getRecord()->ID; } diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 7527f4f..af97772 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -221,8 +221,8 @@ class UserDefinedForm extends Page { * * @return Page */ - public function duplicate() { - $page = parent::duplicate(); + public function duplicate($doWrite = true) { + $page = parent::duplicate($doWrite); // the form fields if($this->Fields()) { @@ -329,7 +329,7 @@ class UserDefinedForm_Controller extends Page_Controller { * * @return Form|false */ - function Form() { + public function Form() { $fields = $this->getFormFields(); if(!$fields) return false; @@ -359,7 +359,7 @@ class UserDefinedForm_Controller extends Page_Controller { * * @return FieldSet */ - function getFormFields() { + public function getFormFields() { $fields = new FieldList(); if($this->Fields()) { @@ -417,7 +417,7 @@ class UserDefinedForm_Controller extends Page_Controller { * * @return FieldSet */ - function getFormActions() { + public function getFormActions() { $submitText = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t('UserDefinedForm.SUBMITBUTTON', 'Submit'); $actions = new FieldList( @@ -439,7 +439,7 @@ class UserDefinedForm_Controller extends Page_Controller { * * @return RequiredFields */ - function getRequiredFields() { + public function getRequiredFields() { $required = new RequiredFields(); $rules = array(); @@ -496,7 +496,7 @@ JS * Allows complex rules to be created * @return void */ - function generateConditionalJavascript() { + public function generateConditionalJavascript() { $default = ""; $rules = ""; @@ -625,7 +625,7 @@ JS * @param Array array to convert * @return JSON */ - function array2json($array) { + public function array2json($array) { foreach($array as $key => $value) if(is_array( $value )) { $result[] = "$key:" . $this->array2json($value); @@ -643,7 +643,7 @@ JS * @param Form Form * @return Redirection */ - function process($data, $form) { + public function process($data, $form) { Session::set("FormInfo.{$form->FormName()}.data",$data); Session::clear("FormInfo.{$form->FormName()}.errors"); @@ -797,7 +797,7 @@ JS * * @return ViewableData */ - function finished() { + public function finished() { $referrer = isset($_GET['referrer']) ? urldecode($_GET['referrer']) : null; return $this->customise(array( @@ -879,11 +879,11 @@ class UserDefinedForm_EmailRecipient extends DataObject { return $fields; } - function canEdit() { + public function canEdit() { return $this->Form()->canEdit(); } - function canDelete() { + public function canDelete() { return $this->Form()->canDelete(); } } @@ -899,7 +899,7 @@ class UserDefinedForm_SubmittedFormEmail extends Email { protected $ss_template = "SubmittedFormEmail"; protected $data; - function __construct() { + public function __construct() { parent::__construct(); } } \ No newline at end of file diff --git a/code/model/formfields/EditableCheckboxGroupField.php b/code/model/formfields/EditableCheckboxGroupField.php index 5c2b663..4366421 100755 --- a/code/model/formfields/EditableCheckboxGroupField.php +++ b/code/model/formfields/EditableCheckboxGroupField.php @@ -13,7 +13,7 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField { static $plural_name = "Checkbox Groups"; - function getFormField() { + public function getFormField() { $optionSet = $this->Options(); $options = array(); @@ -22,7 +22,7 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField { return new CheckboxSetField($this->Name, $this->Title, $optionMap); } - function getValueFromData($data) { + public function getValueFromData($data) { $result = ''; $entries = (isset($data[$this->Name])) ? $data[$this->Name] : false; diff --git a/code/model/formfields/EditableDateField.php b/code/model/formfields/EditableDateField.php index 018f59b..78400b9 100755 --- a/code/model/formfields/EditableDateField.php +++ b/code/model/formfields/EditableDateField.php @@ -13,7 +13,7 @@ class EditableDateField extends EditableFormField { static $plural_name = 'Date Fields'; - function getFieldConfiguration() { + public function getFieldConfiguration() { $default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false; $label = _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?'); @@ -22,7 +22,7 @@ class EditableDateField extends EditableFormField { ); } - function populateFromPostData($data) { + public function populateFromPostData($data) { $fieldPrefix = 'Default-'; if(empty($data['Default']) && !empty($data[$fieldPrefix.'Year']) && !empty($data[$fieldPrefix.'Month']) && !empty($data[$fieldPrefix.'Day'])) { diff --git a/code/model/formfields/EditableDropdown.php b/code/model/formfields/EditableDropdown.php index 7bc0515..24db8eb 100755 --- a/code/model/formfields/EditableDropdown.php +++ b/code/model/formfields/EditableDropdown.php @@ -16,7 +16,7 @@ class EditableDropdown extends EditableMultipleOptionField { /** * @return DropdownField */ - function getFormField() { + public function getFormField() { $optionSet = $this->Options(); $options = array(); diff --git a/code/model/formfields/EditableEmailField.php b/code/model/formfields/EditableEmailField.php index 041e722..8870c3a 100755 --- a/code/model/formfields/EditableEmailField.php +++ b/code/model/formfields/EditableEmailField.php @@ -13,7 +13,7 @@ class EditableEmailField extends EditableFormField { static $plural_name = 'Email Fields'; - function getFormField() { + public function getFormField() { return new EmailField($this->Name, $this->Title); } diff --git a/code/model/formfields/EditableFormField.php b/code/model/formfields/EditableFormField.php index c1cbd7f..3d289a6 100755 --- a/code/model/formfields/EditableFormField.php +++ b/code/model/formfields/EditableFormField.php @@ -65,7 +65,7 @@ class EditableFormField extends DataObject { * * @return String */ - function EditSegment() { + public function EditSegment() { return $this->renderWith('EditableFormField'); } @@ -113,7 +113,7 @@ class EditableFormField extends DataObject { * * @return bool */ - function getShowOnLoad() { + public function getShowOnLoad() { return ($this->getSetting('ShowOnLoad') == "Show" || $this->getSetting('ShowOnLoad') == '') ? true : false; } @@ -260,7 +260,7 @@ class EditableFormField extends DataObject { * * @return TextField */ - function TitleField() { + public function TitleField() { $label = _t('EditableFormField.ENTERQUESTION', 'Enter Question'); $field = new TextField('Title', $label, $this->getField('Title')); @@ -274,7 +274,7 @@ class EditableFormField extends DataObject { } /** Returns the Title for rendering in the front-end (with XML values escaped) */ - function getTitle() { + public function getTitle() { return Convert::raw2att($this->getField('Title')); } @@ -443,7 +443,7 @@ class EditableFormField extends DataObject { * * @return bool */ - function showInReports() { + public function showInReports() { return true; } diff --git a/code/model/formfields/EditableFormHeading.php b/code/model/formfields/EditableFormHeading.php index 4b791ac..7486c95 100755 --- a/code/model/formfields/EditableFormHeading.php +++ b/code/model/formfields/EditableFormHeading.php @@ -11,7 +11,7 @@ class EditableFormHeading extends EditableFormField { static $plural_name = 'Headings'; - function getFieldConfiguration() { + public function getFieldConfiguration() { $levels = array( '1' => '1', '2' => '2', @@ -37,18 +37,18 @@ class EditableFormHeading extends EditableFormField { return $options; } - function getFormField() { + public function getFormField() { $labelField = new HeaderField($this->Name,$this->Title, $this->getSetting('Level')); $labelField->addExtraClass('FormHeading'); return $labelField; } - function showInReports() { + public function showInReports() { return false; } - function getFieldValidationOptions() { + public function getFieldValidationOptions() { return false; } } \ No newline at end of file diff --git a/code/model/formfields/EditableLiteralField.php b/code/model/formfields/EditableLiteralField.php index eda10d4..fa38427 100644 --- a/code/model/formfields/EditableLiteralField.php +++ b/code/model/formfields/EditableLiteralField.php @@ -13,7 +13,7 @@ class EditableLiteralField extends EditableFormField { static $plural_name = 'HTML Blocks'; - function getFieldConfiguration() { + public function getFieldConfiguration() { return new FieldList( new TextareaField( $this->getSettingName('Content'), @@ -27,7 +27,7 @@ class EditableLiteralField extends EditableFormField { ); } - function getFormField() { + public function getFormField() { return new LiteralField("LiteralField[$this->ID]", "
@@ -36,7 +36,7 @@ class EditableLiteralField extends EditableFormField { ); } - function showInReports() { + public function showInReports() { return (!$this->getSetting('HideFromReports')); } } \ No newline at end of file diff --git a/code/model/formfields/EditableMemberListField.php b/code/model/formfields/EditableMemberListField.php index 25cc65a..dbdec00 100644 --- a/code/model/formfields/EditableMemberListField.php +++ b/code/model/formfields/EditableMemberListField.php @@ -11,7 +11,7 @@ class EditableMemberListField extends EditableFormField { static $plural_name = 'Member List Fields'; - function getFieldConfiguration() { + public function getFieldConfiguration() { $groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0; $groups = DataObject::get("Group"); @@ -24,7 +24,7 @@ class EditableMemberListField extends EditableFormField { return $fields; } - function getFormField() { + public function getFormField() { if ($this->getSetting('GroupID')) { $members = Member::mapInGroups($this->getSetting('GroupID')); @@ -34,7 +34,7 @@ class EditableMemberListField extends EditableFormField { return false; } - function getValueFromData($data) { + public function getValueFromData($data) { if(isset($data[$this->Name])) { $value = Convert::raw2sql($data[$this->Name]); diff --git a/code/model/formfields/EditableRadioField.php b/code/model/formfields/EditableRadioField.php index 317c301..b8f0605 100755 --- a/code/model/formfields/EditableRadioField.php +++ b/code/model/formfields/EditableRadioField.php @@ -13,7 +13,7 @@ class EditableRadioField extends EditableMultipleOptionField { static $plural_name = 'Radio fields'; - function getFormField() { + public function getFormField() { $optionSet = $this->Options(); $options = array(); diff --git a/code/model/formfields/EditableTextField.php b/code/model/formfields/EditableTextField.php index 5a4f52b..55fabb9 100755 --- a/code/model/formfields/EditableTextField.php +++ b/code/model/formfields/EditableTextField.php @@ -13,7 +13,7 @@ class EditableTextField extends EditableFormField { static $plural_name = 'Text Fields'; - function getFieldConfiguration() { + public function getFieldConfiguration() { $fields = parent::getFieldConfiguration(); $min = ($this->getSetting('MinLength')) ? $this->getSetting('MinLength') : ''; @@ -37,7 +37,7 @@ class EditableTextField extends EditableFormField { /** * @return TextareaField|TextField */ - function getFormField() { + public function getFormField() { if($this->getSetting('Rows') && $this->getSetting('Rows') > 1) { return new TextareaField($this->Name, $this->Title, $this->getSetting('Rows')); } diff --git a/code/model/submissions/SubmittedFileField.php b/code/model/submissions/SubmittedFileField.php index 17a5791..c57a9b0 100755 --- a/code/model/submissions/SubmittedFileField.php +++ b/code/model/submissions/SubmittedFileField.php @@ -18,7 +18,7 @@ class SubmittedFileField extends SubmittedFormField { * * @return string */ - function getFormattedValue() { + public function getFormattedValue() { $link = $this->getLink(); $title = _t('SubmittedFileField.DOWNLOADFILE', 'Download File'); @@ -34,7 +34,7 @@ class SubmittedFileField extends SubmittedFormField { * * @return string */ - function getLink() { + public function getLink() { if($file = $this->UploadedFile()) { if(trim($file->getFilename(), '/') != trim(ASSETS_DIR,'/')) { return $this->UploadedFile()->URL; diff --git a/code/model/submissions/SubmittedFormField.php b/code/model/submissions/SubmittedFormField.php index 3bca04a..4e4da48 100755 --- a/code/model/submissions/SubmittedFormField.php +++ b/code/model/submissions/SubmittedFormField.php @@ -24,7 +24,7 @@ class SubmittedFormField extends DataObject { * * @return String */ - function getFormattedValue() { + public function getFormattedValue() { return nl2br($this->dbObject('Value')->ATT()); } } diff --git a/code/tasks/UserFormsVersionedTask.php b/code/tasks/UserFormsVersionedTask.php index 0dd5774..e9a3e03 100644 --- a/code/tasks/UserFormsVersionedTask.php +++ b/code/tasks/UserFormsVersionedTask.php @@ -20,7 +20,7 @@ class UserFormsVersionedTask extends MigrationTask { * Publish the existing forms. * */ - function run($request) { + public function run($request) { $forms = Versioned::get_by_stage('UserDefinedForm', 'Live'); if($forms) { diff --git a/tests/FieldEditorTest.php b/tests/FieldEditorTest.php index c2606e9..d0efda7 100644 --- a/tests/FieldEditorTest.php +++ b/tests/FieldEditorTest.php @@ -40,7 +40,7 @@ class FieldEditorTest extends FunctionalTest { class FieldEditorTest_Controller extends Controller { - function Form() { + public function Form() { return new Form($this, 'Form', new FieldList(new FieldEditor('Fields')), new FieldList()); } } \ No newline at end of file