| Conditions | 3 |
| Paths | 4 |
| Total Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 31 | public function updateCMSFields(FieldList $fields) |
||
| 32 | { |
||
| 33 | $individualPageNoteWith = _t("ShareThis.INDIVIDUAL_PAGE_NOTE_WITH", " (with the ability to turn them off/on on individual pages) "); |
||
| 34 | $individualPageNoteWithout = _t("ShareThis.INDIVIDUAL_PAGE_NOTE_WITHOUT", " (without the ability to turn them off/on on individual pages) "); |
||
| 35 | $shareThisExtra = '<h3 style="margin-top: 50px">Select Icons</h3>'; |
||
| 36 | /* if($this->CanEditShareIcons()) { |
||
| 37 | $addedLinks = array(); |
||
| 38 | $obj = singleton('ShareThisDataObject'); |
||
| 39 | $addedLinksShort['edit'] = DataObjectOneFieldUpdateController::popup_link('ShareThisDataObject', 'IncludeThisIcon'); |
||
| 40 | $addedLinksLong['edit'] = DataObjectOneFieldUpdateController::popup_link('ShareThisDataObject', 'IncludeThisIconInExtendedList'); |
||
| 41 | $addedLinksShort['sort'] = $obj->dataObjectSorterPopupLink('IncludeThisIcon', 1); |
||
| 42 | $addedLinksLong['sort'] = $obj->dataObjectSorterPopupLink('IncludeThisIconInExtendedList', 1); |
||
| 43 | if(count($addedLinksShort)) { |
||
| 44 | $shareThisExtra .= '<p>main list: ' . implode(', ', $addedLinksShort) . '.</p>'; |
||
| 45 | } |
||
| 46 | if(count($addedLinksLong)) { |
||
| 47 | $shareThisExtra .= '<p>long list: ' . implode(', ', $addedLinksLong) . '.</p>'; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | */ |
||
| 51 | $shareThisTableField = new GridField('Share this options', null, ShareThisDataObject::get(), GridFieldConfig_RecordEditor::create()); |
||
| 52 | //$shareThisTableField->setPermissions(array("edit", "add")); |
||
| 53 | $socialNetworkExtra = '<h3 style="margin-top: 50px">Add / Edit / Delete Your Social Networking Home Pages (e.g. www.facebook.com/our-company-page)</h3>'; |
||
| 54 | $socialNetworkTableField = new GridField('Join Us', null, SocialNetworkingLinksDataObject::get(), GridFieldConfig_RecordEditor::create()); |
||
| 55 | //$socialNetworkTableField->setPermissions(array("edit", "add", "delete", "view")); |
||
| 56 | if ($this->owner->AlwaysIncludeShareThisLinks) { |
||
| 57 | $defaultShareThisCheckbox = new HiddenField('IncludeByDefaultShareThisLinks', true); |
||
| 58 | } else { |
||
| 59 | $defaultShareThisCheckbox = new CheckboxField('IncludeByDefaultShareThisLinks', 'Show links on every page by default '.$individualPageNoteWith); |
||
| 60 | } |
||
| 61 | if ($this->owner->AlwaysIncludeSocialNetworkingLinks) { |
||
| 62 | $defaultSocialNetworkingCheckbox = new HiddenField('IncludeByDefaultSocialNetworkingLinks', true); |
||
| 63 | } else { |
||
| 64 | $defaultSocialNetworkingCheckbox = new CheckboxField('IncludeByDefaultSocialNetworkingLinks', 'Include on every page by default '.$individualPageNoteWith); |
||
| 65 | } |
||
| 66 | $fields->addFieldToTab( |
||
| 67 | 'Root.SocialMedia', |
||
| 68 | new TabSet( |
||
| 69 | 'SocialNetworkingOptions', |
||
| 70 | new Tab( |
||
| 71 | 'ShareThis', |
||
| 72 | new CheckboxField('AlwaysIncludeShareThisLinks', 'Show links on every page '.$individualPageNoteWithout), |
||
| 73 | $defaultShareThisCheckbox, |
||
| 74 | new CheckboxField('ShareThisAllInOne', 'Add a \'share\' all-in-one button'), |
||
| 75 | new LiteralField('shareThisExtra', $shareThisExtra), |
||
| 76 | $shareThisTableField |
||
| 77 | ), |
||
| 78 | new Tab( |
||
| 79 | 'JoinUs', |
||
| 80 | new CheckboxField('AlwaysIncludeSocialNetworkingLinks', 'Show links on every page '.$individualPageNoteWithout), |
||
| 81 | $defaultSocialNetworkingCheckbox, |
||
| 82 | new LiteralField('socialNetworkExtra', $socialNetworkExtra), |
||
| 83 | $socialNetworkTableField |
||
| 84 | ) |
||
| 85 | ) |
||
| 86 | ); |
||
| 87 | return $fields; |
||
| 88 | } |
||
| 89 | |||
| 104 |