@@ -2,95 +2,95 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class LatLongField extends FieldGroup { |
| 4 | 4 | |
| 5 | - protected $latField; |
|
| 5 | + protected $latField; |
|
| 6 | 6 | |
| 7 | - protected $longField; |
|
| 7 | + protected $longField; |
|
| 8 | 8 | |
| 9 | - protected $zoomField; |
|
| 9 | + protected $zoomField; |
|
| 10 | 10 | |
| 11 | - protected $buttonText; |
|
| 11 | + protected $buttonText; |
|
| 12 | 12 | |
| 13 | - private $guidePoints = null; |
|
| 13 | + private $guidePoints = null; |
|
| 14 | 14 | |
| 15 | - private static $ctr = 0; |
|
| 15 | + private static $ctr = 0; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @param string[] $buttonText |
|
| 19 | - */ |
|
| 20 | - public function __construct($children = array(), $buttonText = null) { |
|
| 21 | - self::$ctr++; |
|
| 17 | + /** |
|
| 18 | + * @param string[] $buttonText |
|
| 19 | + */ |
|
| 20 | + public function __construct($children = array(), $buttonText = null) { |
|
| 21 | + self::$ctr++; |
|
| 22 | 22 | |
| 23 | - if ((sizeof($children) < 2) || (sizeof($children) > 3) || |
|
| 24 | - (!$children[0] instanceof FormField) || |
|
| 25 | - (!$children[1] instanceof FormField) |
|
| 26 | - ) user_error('LatLongField argument 1 must be an array containing at least two FormField '. |
|
| 27 | - 'objects for Lat/Long values, respectively.', E_USER_ERROR); |
|
| 23 | + if ((sizeof($children) < 2) || (sizeof($children) > 3) || |
|
| 24 | + (!$children[0] instanceof FormField) || |
|
| 25 | + (!$children[1] instanceof FormField) |
|
| 26 | + ) user_error('LatLongField argument 1 must be an array containing at least two FormField '. |
|
| 27 | + 'objects for Lat/Long values, respectively.', E_USER_ERROR); |
|
| 28 | 28 | |
| 29 | - parent::__construct($children); |
|
| 29 | + parent::__construct($children); |
|
| 30 | 30 | |
| 31 | - $this->buttonText = $buttonText ? $buttonText : _t('LatLongField.LOOKUP', 'Search'); |
|
| 32 | - $this->latField = $children[0]->getName(); |
|
| 33 | - $this->longField = $children[1]->getName(); |
|
| 31 | + $this->buttonText = $buttonText ? $buttonText : _t('LatLongField.LOOKUP', 'Search'); |
|
| 32 | + $this->latField = $children[0]->getName(); |
|
| 33 | + $this->longField = $children[1]->getName(); |
|
| 34 | 34 | |
| 35 | - if (sizeof($children) == 3) { |
|
| 36 | - $this->zoomField = $children[2]->getName(); |
|
| 37 | - } |
|
| 38 | - $name = ""; |
|
| 39 | - foreach ($children as $field) { |
|
| 40 | - $name .= $field->getName(); |
|
| 41 | - } |
|
| 35 | + if (sizeof($children) == 3) { |
|
| 36 | + $this->zoomField = $children[2]->getName(); |
|
| 37 | + } |
|
| 38 | + $name = ""; |
|
| 39 | + foreach ($children as $field) { |
|
| 40 | + $name .= $field->getName(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // hide the lat long and zoom fields from the interface |
|
| 44 | - foreach ($this->FieldList() as $fieldToHide) { |
|
| 45 | - $fieldToHide->addExtraClass('hide'); |
|
| 46 | - } |
|
| 43 | + // hide the lat long and zoom fields from the interface |
|
| 44 | + foreach ($this->FieldList() as $fieldToHide) { |
|
| 45 | + $fieldToHide->addExtraClass('hide'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $this->name = $name; |
|
| 49 | - } |
|
| 48 | + $this->name = $name; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - public function FieldHolder($properties = array()) { |
|
| 53 | - Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js'); |
|
| 54 | - Requirements::javascript(THIRDPARTY_DIR.'/jquery-livequery/jquery.livequery.js'); |
|
| 55 | - Requirements::javascript(THIRDPARTY_DIR.'/jquery-metadata/jquery.metadata.js'); |
|
| 56 | - Requirements::javascript(MAPPABLE_MODULE_PATH.'/javascript/mapField.js'); |
|
| 52 | + public function FieldHolder($properties = array()) { |
|
| 53 | + Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js'); |
|
| 54 | + Requirements::javascript(THIRDPARTY_DIR.'/jquery-livequery/jquery.livequery.js'); |
|
| 55 | + Requirements::javascript(THIRDPARTY_DIR.'/jquery-metadata/jquery.metadata.js'); |
|
| 56 | + Requirements::javascript(MAPPABLE_MODULE_PATH.'/javascript/mapField.js'); |
|
| 57 | 57 | |
| 58 | - $attributes = array( |
|
| 59 | - 'class' => 'editableMap', |
|
| 60 | - 'id' => 'GoogleMap', |
|
| 61 | - 'data-LatFieldName' => $this->latField, |
|
| 62 | - 'data-LonFieldName' => $this->longField, |
|
| 63 | - 'data-ZoomFieldName' => $this->zoomField, |
|
| 64 | - 'data-UseMapBounds' => false |
|
| 65 | - ); |
|
| 58 | + $attributes = array( |
|
| 59 | + 'class' => 'editableMap', |
|
| 60 | + 'id' => 'GoogleMap', |
|
| 61 | + 'data-LatFieldName' => $this->latField, |
|
| 62 | + 'data-LonFieldName' => $this->longField, |
|
| 63 | + 'data-ZoomFieldName' => $this->zoomField, |
|
| 64 | + 'data-UseMapBounds' => false |
|
| 65 | + ); |
|
| 66 | 66 | |
| 67 | - Requirements::css('mappable/css/mapField.css'); |
|
| 67 | + Requirements::css('mappable/css/mapField.css'); |
|
| 68 | 68 | |
| 69 | - // check for and if required add guide points |
|
| 70 | - if (!empty($this->guidePoints)) { |
|
| 71 | - $latlongps = array(); |
|
| 69 | + // check for and if required add guide points |
|
| 70 | + if (!empty($this->guidePoints)) { |
|
| 71 | + $latlongps = array(); |
|
| 72 | 72 | |
| 73 | - foreach ($this->guidePoints as $guidepoint) { |
|
| 74 | - array_push($latlongps, $guidepoint); |
|
| 75 | - } |
|
| 73 | + foreach ($this->guidePoints as $guidepoint) { |
|
| 74 | + array_push($latlongps, $guidepoint); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $guidePointsJSON = json_encode($latlongps); |
|
| 78 | - // convert the mappable guidepoints to lat lon |
|
| 77 | + $guidePointsJSON = json_encode($latlongps); |
|
| 78 | + // convert the mappable guidepoints to lat lon |
|
| 79 | 79 | |
| 80 | - $attributes['data-GuidePoints'] = $guidePointsJSON; |
|
| 80 | + $attributes['data-GuidePoints'] = $guidePointsJSON; |
|
| 81 | 81 | |
| 82 | - // we only wish to change the bounds to those of all the points iff |
|
| 83 | - // the item currently has no location |
|
| 84 | - $attributes['data-useMapBounds'] = true; |
|
| 85 | - } |
|
| 86 | - $content = '<div class="editableMapWrapper">'.$this->create_tag( |
|
| 87 | - "div", |
|
| 88 | - $attributes |
|
| 89 | - ).'</div>'; |
|
| 82 | + // we only wish to change the bounds to those of all the points iff |
|
| 83 | + // the item currently has no location |
|
| 84 | + $attributes['data-useMapBounds'] = true; |
|
| 85 | + } |
|
| 86 | + $content = '<div class="editableMapWrapper">'.$this->create_tag( |
|
| 87 | + "div", |
|
| 88 | + $attributes |
|
| 89 | + ).'</div>'; |
|
| 90 | 90 | |
| 91 | - $this->FieldList()->push(new LiteralField('locationEditor', $content)); |
|
| 91 | + $this->FieldList()->push(new LiteralField('locationEditor', $content)); |
|
| 92 | 92 | |
| 93 | - $content2 = <<<HTML |
|
| 93 | + $content2 = <<<HTML |
|
| 94 | 94 | <div id="mapSearch"> |
| 95 | 95 | <input name="location_search" id="location_search" size=80/> |
| 96 | 96 | <button class="action" id="searchLocationButton">Search Location Name</button> |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | </div> |
| 100 | 100 | HTML; |
| 101 | 101 | |
| 102 | - $this->FieldList()->push(new LiteralField('mapSearch', $content2)); |
|
| 102 | + $this->FieldList()->push(new LiteralField('mapSearch', $content2)); |
|
| 103 | 103 | |
| 104 | - return parent::FieldHolder(); |
|
| 105 | - } |
|
| 104 | + return parent::FieldHolder(); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /* |
|
| 107 | + /* |
|
| 108 | 108 | Set guidance points for the map being edited. For example in a photographic set show the map |
| 109 | 109 | position of some other images so that subsequent photo edits do not start with a map centred |
| 110 | 110 | at the origin |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | @var newGuidePoints array of points expressed as associative arrays containing keys latitude |
| 113 | 113 | and longitude mapping to geographical locations |
| 114 | 114 | */ |
| 115 | - public function setGuidePoints($newGuidePoints) { |
|
| 116 | - $this->guidePoints = $newGuidePoints; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Accessor to guidepoints. For testing purposes |
|
| 121 | - * @return array guidepoints |
|
| 122 | - */ |
|
| 123 | - public function getGuidePoints() { |
|
| 124 | - return $this->guidePoints; |
|
| 125 | - } |
|
| 115 | + public function setGuidePoints($newGuidePoints) { |
|
| 116 | + $this->guidePoints = $newGuidePoints; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Accessor to guidepoints. For testing purposes |
|
| 121 | + * @return array guidepoints |
|
| 122 | + */ |
|
| 123 | + public function getGuidePoints() { |
|
| 124 | + return $this->guidePoints; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | } |