Conditions | 3 |
Paths | 2 |
Total Lines | 53 |
Code Lines | 31 |
Lines | 0 |
Ratio | 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 |
||
55 | public function FieldHolder($properties = array()) { |
||
56 | Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js'); |
||
57 | Requirements::javascript(THIRDPARTY_DIR.'/jquery-livequery/jquery.livequery.js'); |
||
58 | Requirements::javascript(THIRDPARTY_DIR.'/jquery-metadata/jquery.metadata.js'); |
||
59 | Requirements::javascript(MAPPABLE_MODULE_PATH.'/javascript/mapField.js'); |
||
60 | |||
61 | $attributes = array( |
||
62 | 'class' => 'editableMap', |
||
63 | 'id' => 'GoogleMap', |
||
64 | 'data-LatFieldName' => $this->latField, |
||
65 | 'data-LonFieldName' => $this->longField, |
||
66 | 'data-ZoomFieldName' => $this->zoomField, |
||
67 | 'data-UseMapBounds' => false |
||
68 | ); |
||
69 | |||
70 | Requirements::css('mappable/css/mapField.css'); |
||
71 | $guidePointsJSON = ''; |
||
72 | if (!empty($this->guidePoints)) { |
||
73 | $latlongps = array(); |
||
74 | |||
75 | foreach ($this->guidePoints as $guidepoint) { |
||
76 | array_push($latlongps, $guidepoint); |
||
77 | } |
||
78 | |||
79 | $guidePointsJSON = json_encode($latlongps); |
||
80 | // convert the mappable guidepoints to lat lon |
||
81 | |||
82 | $attributes['data-GuidePoints'] = $guidePointsJSON; |
||
83 | |||
84 | // we only wish to change the bounds to those of all the points iff |
||
85 | // the item currently has no location |
||
86 | $attributes['data-useMapBounds'] = true; |
||
87 | } |
||
88 | $content = '<div class="editableMapWrapper">' . $this->createTag( |
||
89 | "div", |
||
90 | $attributes |
||
91 | ) . '</div>'; |
||
92 | |||
93 | $this->FieldList()->push(new LiteralField('locationEditor', $content)); |
||
94 | |||
95 | $content2 = <<<HTML |
||
96 | <div id="mapSearch"> |
||
97 | <input name="location_search" id="location_search" size=80/> |
||
98 | <button class="action" id="searchLocationButton">Search Location Name</button> |
||
99 | <div id="mapSearchResults"> |
||
100 | </div> |
||
101 | </div> |
||
102 | HTML; |
||
103 | |||
104 | $this->FieldList()->push(new LiteralField('mapSearch', $content2)); |
||
105 | |||
106 | return parent::FieldHolder(); |
||
107 | } |
||
108 | |||
139 |