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 The level of the <h1> to <h6> HTML tag. Default: 2 |
9
|
|
|
*/ |
10
|
|
|
protected $headingLevel = 2; |
11
|
|
|
private $divId; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param string $name |
15
|
|
|
* @param string $title |
16
|
|
|
*/ |
17
|
2 |
|
public function __construct($name, $title = null, $headingLevel = 2, $allowHTML = false, $form = null) |
18
|
|
|
{ |
19
|
2 |
|
$this->divId = $name; |
20
|
|
|
// legacy handling for old parameters: $title, $heading, ... |
21
|
|
|
// instead of new handling: $name, $title, $heading, ... |
22
|
2 |
|
$args = func_get_args(); |
23
|
2 |
|
if (!isset($args[1]) || is_numeric($args[1])) { |
24
|
1 |
|
$title = (isset($args[0])) ? $args[0] : null; |
25
|
|
|
// Use "HeaderField(title)" as the default field name for a HeaderField; |
26
|
|
|
// if it's just set to title then we risk causing accidental duplicate-field creation. |
27
|
|
|
|
28
|
|
|
// this means i18nized fields won't be easily accessible through fieldByName() |
29
|
1 |
|
$name = 'MapField'.$title; |
30
|
1 |
|
$headingLevel = (isset($args[1])) ? $args[1] : null; |
31
|
1 |
|
$allowHTML = (isset($args[2])) ? $args[2] : null; |
32
|
1 |
|
$form = (isset($args[3])) ? $args[3] : null; |
33
|
1 |
|
} |
34
|
|
|
|
35
|
2 |
|
if ($headingLevel) { |
36
|
1 |
|
$this->headingLevel = $headingLevel; |
|
|
|
|
37
|
1 |
|
} |
38
|
2 |
|
$this->allowHTML = $allowHTML; |
39
|
2 |
|
parent::__construct($name, $title, null, $allowHTML, $form); |
|
|
|
|
40
|
2 |
|
} |
41
|
|
|
|
42
|
2 |
|
public function Field($properties = array()) |
|
|
|
|
43
|
|
|
{ |
44
|
2 |
|
Requirements::javascript('framework/thirdparty/jquery/jquery.js'); |
45
|
2 |
|
Requirements::javascript('framework/thirdparty/jquery-livequery/jquery.livequery.js'); |
46
|
|
|
$attributes = array( |
47
|
2 |
|
'class' => 'middleColumn', |
48
|
2 |
|
'id' => $this->divId, |
49
|
2 |
|
'style' => 'width:100%;height:300px;margin:5px 0px 5px 5px;position:relative;', |
50
|
2 |
|
); |
51
|
|
|
|
52
|
2 |
|
Requirements::css('mappable/css/mapField.css'); |
53
|
|
|
|
54
|
2 |
|
return '<div class="editableMap">'.$this->createTag( |
|
|
|
|
55
|
2 |
|
'div', |
56
|
|
|
$attributes |
57
|
2 |
|
).'</div>'; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.