1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Map field to point for pois langitude and longitude positioning |
4
|
|
|
*/ |
5
|
|
|
class MapField extends DatalessField { |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @var int $headingLevel The level of the <h1> to <h6> HTML tag. Default: 2 |
9
|
|
|
*/ |
10
|
|
|
protected $headingLevel = 2; |
11
|
|
|
private $divId; |
12
|
|
|
|
13
|
|
|
function __construct($name, $title = null, $headingLevel = 2, $allowHTML = false, $form = null) { |
|
|
|
|
14
|
|
|
$this->divId = $name; |
15
|
|
|
// legacy handling for old parameters: $title, $heading, ... |
|
|
|
|
16
|
|
|
// instead of new handling: $name, $title, $heading, ... |
|
|
|
|
17
|
|
|
$args = func_get_args(); |
18
|
|
|
if(!isset($args[1]) || is_numeric($args[1])) { |
19
|
|
|
$title = (isset($args[0])) ? $args[0] : null; |
20
|
|
|
// Use "HeaderField(title)" as the default field name for a HeaderField; |
21
|
|
|
// if it's just set to title then we risk causing accidental duplicate-field creation. |
22
|
|
|
|
23
|
|
|
// this means i18nized fields won't be easily accessible through fieldByName() |
24
|
|
|
$name = 'MapField' . $title; |
25
|
|
|
$headingLevel = (isset($args[1])) ? $args[1] : null; |
26
|
|
|
$allowHTML = (isset($args[2])) ? $args[2] : null; |
27
|
|
|
$form = (isset($args[3])) ? $args[3] : null; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
if($headingLevel) $this->headingLevel = $headingLevel; |
|
|
|
|
31
|
|
|
$this->allowHTML = $allowHTML; |
32
|
|
|
parent::__construct($name, $title, null, $allowHTML, $form); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function Field($properties = array()) { |
|
|
|
|
36
|
|
|
Requirements::javascript('framework/thirdparty/jquery/jquery.js'); |
37
|
|
|
Requirements::javascript('framework/thirdparty/jquery-livequery/jquery.livequery.js'); |
38
|
|
|
$attributes = array( |
39
|
|
|
'class' => 'middleColumn', |
40
|
|
|
'id' => $this->divId, |
41
|
|
|
'style' => "width:100%;height:300px;margin:5px 0px 5px 5px;position:relative;" |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
Requirements::css('mappable/css/mapField.css'); |
45
|
|
|
|
46
|
|
|
return '<div class="editableMap">' . $this->createTag( |
|
|
|
|
47
|
|
|
"div", |
48
|
|
|
$attributes |
49
|
|
|
) . '</div>'; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.