ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTLocation Class Reference
+ Inheritance diagram for ilADTLocation:
+ Collaboration diagram for ilADTLocation:

Public Member Functions

 reset ()
 Init property defaults. More...
 
 setLongitude (?float $a_value=null)
 
 getLongitude ()
 
 setLatitude (?float $a_value=null)
 
 getLatitude ()
 
 getZoom ()
 
 setZoom ($a_value)
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isNull ()
 Is currently null. More...
 
 isValid ()
 
 translateErrorCode (string $a_code)
 @inheritcoc More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 
- Public Member Functions inherited from ilADT
 __construct (ilADTDefinition $a_def)
 
 getType ()
 Get type (from class/instance) More...
 
 reset ()
 Init property defaults. More...
 
 getCopyOfDefinition ()
 Get copy of definition. More...
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isLargerOrEqual (ilADT $a_adt)
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isSmallerOrEqual (ilADT $a_adt)
 Check if given ADT is smaller or equal than self. More...
 
 isInbetween (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (exclusive) More...
 
 isInbetweenOrEqual (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (inclusive) More...
 
 isNull ()
 Is currently null. More...
 
 isValid ()
 
 getValidationErrors ()
 Get all validation error codes. More...
 
 translateErrorCode (string $a_code)
 Translate error-code to human-readable message. More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 

Data Fields

const ADT_VALIDATION_ERROR_LONGITUDE = "loc1"
 
const ADT_VALIDATION_ERROR_LATITUDE = "loc2"
 
- Data Fields inherited from ilADT
const ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"
 
const ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"
 
const ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"
 
const ADT_VALIDATION_ERROR_MIN = "adt4"
 
const ADT_VALIDATION_ERROR_MAX = "adt5"
 
const ADT_VALIDATION_DATE = "adt6"
 
const ADT_VALIDATION_ERROR_INVALID_NODE = 'adt7'
 

Protected Member Functions

 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
- Protected Member Functions inherited from ilADT
 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
 setDefinition (ilADTDefinition $a_def)
 Set definition. More...
 
 getDefinition ()
 Get definition. More...
 
 addValidationError (string $a_error_code)
 

Protected Attributes

float $longitude
 
float $latitude
 
int $zoom
 
- Protected Attributes inherited from ilADT
ilADTDefinition $definition
 
ilLanguage $lng
 
array $validation_errors = []
 

Detailed Description

Definition at line 21 of file class.ilADTLocation.php.

Member Function Documentation

◆ equals()

ilADTLocation::equals ( ilADT  $a_adt)

Check if given ADT equals self.

Parameters
ilADT$a_adt
Returns
bool|null

Reimplemented from ilADT.

Definition at line 81 of file class.ilADTLocation.php.

81 : ?bool
82 {
83 if ($this->getDefinition()->isComparableTo($a_adt)) {
84 return ($this->getLongitude() == $a_adt->getLongitude() &&
85 $this->getLatitude() == $a_adt->getLatitude());
86 }
87 return null;
88 }
getDefinition()
Get definition.

References ilADT\getDefinition(), and getLongitude().

+ Here is the call graph for this function:

◆ exportStdClass()

ilADTLocation::exportStdClass ( )

Export value as stdClass.

Returns
stdClass | null

Reimplemented from ilADT.

Definition at line 159 of file class.ilADTLocation.php.

159 : ?stdClass
160 {
161 if (!$this->isNull()) {
162 $obj = new stdClass();
163 $obj->lat = $this->getLatitude();
164 $obj->long = $this->getLongitude();
165 $obj->zoom = $this->getZoom();
166 return $obj;
167 }
168 return null;
169 }
isNull()
Is currently null.

References getLatitude(), getLongitude(), getZoom(), and isNull().

+ Here is the call graph for this function:

◆ getCheckSum()

ilADTLocation::getCheckSum ( )

Get unique checksum.

Returns
string | null

Reimplemented from ilADT.

Definition at line 149 of file class.ilADTLocation.php.

149 : ?string
150 {
151 if (!$this->isNull()) {
152 return md5($this->getLongitude() .
153 "#" . $this->getLatitude() .
154 "#" . $this->getZoom());
155 }
156 return null;
157 }

References getLatitude(), getLongitude(), getZoom(), and isNull().

+ Here is the call graph for this function:

◆ getLatitude()

ilADTLocation::getLatitude ( )

Definition at line 64 of file class.ilADTLocation.php.

64 : ?float
65 {
66 return $this->latitude;
67 }

References $latitude.

Referenced by exportStdClass(), getCheckSum(), isNull(), and isValid().

+ Here is the caller graph for this function:

◆ getLongitude()

ilADTLocation::getLongitude ( )

Definition at line 54 of file class.ilADTLocation.php.

54 : ?float
55 {
56 return $this->longitude;
57 }

References $longitude.

Referenced by equals(), exportStdClass(), getCheckSum(), isNull(), and isValid().

+ Here is the caller graph for this function:

◆ getZoom()

ilADTLocation::getZoom ( )

Definition at line 69 of file class.ilADTLocation.php.

69 : ?int
70 {
71 return $this->zoom;
72 }

References $zoom.

Referenced by exportStdClass(), and getCheckSum().

+ Here is the caller graph for this function:

◆ importStdClass()

ilADTLocation::importStdClass ( ?stdClass  $a_std)

Import value from stdClass.

Parameters
stdClass  |  null$a_std

Reimplemented from ilADT.

Definition at line 171 of file class.ilADTLocation.php.

171 : void
172 {
173 if (is_object($a_std)) {
174 $this->setLatitude($a_std->lat);
175 $this->setLongitude($a_std->long);
176 $this->setZoom($a_std->zoom);
177 }
178 }
setLongitude(?float $a_value=null)
setLatitude(?float $a_value=null)

References setLatitude(), setLongitude(), and setZoom().

+ Here is the call graph for this function:

◆ isLarger()

ilADTLocation::isLarger ( ilADT  $a_adt)

Check if given ADT is larger than self.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADT.

Definition at line 90 of file class.ilADTLocation.php.

90 : ?bool
91 {
92 return null;
93 }

◆ isNull()

ilADTLocation::isNull ( )

Is currently null.

Returns
bool | null

Reimplemented from ilADT.

Definition at line 102 of file class.ilADTLocation.php.

102 : bool
103 {
104 return $this->getLongitude() === null && $this->getLatitude() === null;
105 }

References getLatitude(), and getLongitude().

Referenced by exportStdClass(), and getCheckSum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSmaller()

ilADTLocation::isSmaller ( ilADT  $a_adt)

Check if given ADT is smaller than self.

Parameters
ilADT$a_adt
Returns
bool | null

Reimplemented from ilADT.

Definition at line 95 of file class.ilADTLocation.php.

95 : ?bool
96 {
97 return null;
98 }

◆ isValid()

ilADTLocation::isValid ( )

Reimplemented from ilADT.

Definition at line 109 of file class.ilADTLocation.php.

109 : bool
110 {
111 $valid = parent::isValid();
112 $long = $this->getLongitude();
113 $lat = $this->getLatitude();
114 if ($long !== null && $lat !== null) {
115 // 0 - (+-)180
116 if ($long < -180 || $long > 180) {
117 $this->addValidationError(self::ADT_VALIDATION_ERROR_LONGITUDE);
118 $valid = false;
119 }
120 // 0 - (+-)90
121 if ($lat < -90 || $lat > 90) {
122 $this->addValidationError(self::ADT_VALIDATION_ERROR_LATITUDE);
123 $valid = false;
124 }
125 }
126 return $valid;
127 }
addValidationError(string $a_error_code)
$valid

References $valid, ilADT\addValidationError(), getLatitude(), and getLongitude().

+ Here is the call graph for this function:

◆ isValidDefinition()

ilADTLocation::isValidDefinition ( ilADTDefinition  $a_def)
protected

Check if definition is valid for ADT.

Parameters
ilADTDefinition$a_def
Returns
bool

Reimplemented from ilADT.

Definition at line 32 of file class.ilADTLocation.php.

32 : bool
33 {
34 return $a_def instanceof ilADTLocationDefinition;
35 }

◆ reset()

ilADTLocation::reset ( )

Init property defaults.

Reimplemented from ilADT.

Definition at line 39 of file class.ilADTLocation.php.

39 : void
40 {
41 parent::reset();
42 $this->setZoom(9);
43 $this->setLatitude();
44 $this->setLongitude();
45 }

References setLatitude(), setLongitude(), and setZoom().

+ Here is the call graph for this function:

◆ setLatitude()

ilADTLocation::setLatitude ( ?float  $a_value = null)

Definition at line 59 of file class.ilADTLocation.php.

59 : void
60 {
61 $this->latitude = $a_value;
62 }

Referenced by importStdClass(), and reset().

+ Here is the caller graph for this function:

◆ setLongitude()

ilADTLocation::setLongitude ( ?float  $a_value = null)

Definition at line 49 of file class.ilADTLocation.php.

49 : void
50 {
51 $this->longitude = $a_value;
52 }

Referenced by importStdClass(), and reset().

+ Here is the caller graph for this function:

◆ setZoom()

ilADTLocation::setZoom (   $a_value)

Definition at line 74 of file class.ilADTLocation.php.

74 : void
75 {
76 $this->zoom = max(1, abs((int) $a_value));
77 }

Referenced by importStdClass(), and reset().

+ Here is the caller graph for this function:

◆ translateErrorCode()

ilADTLocation::translateErrorCode ( string  $a_code)

@inheritcoc

Reimplemented from ilADT.

Definition at line 135 of file class.ilADTLocation.php.

135 : string
136 {
137 switch ($a_code) {
139 return $this->lng->txt("adt_error_longitude");
140
142 return $this->lng->txt("adt_error_latitude");
143
144 default:
145 return parent::translateErrorCode($a_code);
146 }
147 }
const ADT_VALIDATION_ERROR_LONGITUDE
const ADT_VALIDATION_ERROR_LATITUDE

References ADT_VALIDATION_ERROR_LATITUDE, ADT_VALIDATION_ERROR_LONGITUDE, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $latitude

float ilADTLocation::$latitude
protected

Definition at line 24 of file class.ilADTLocation.php.

Referenced by getLatitude().

◆ $longitude

float ilADTLocation::$longitude
protected

Definition at line 23 of file class.ilADTLocation.php.

Referenced by getLongitude().

◆ $zoom

int ilADTLocation::$zoom
protected

Definition at line 25 of file class.ilADTLocation.php.

Referenced by getZoom().

◆ ADT_VALIDATION_ERROR_LATITUDE

const ilADTLocation::ADT_VALIDATION_ERROR_LATITUDE = "loc2"

Definition at line 28 of file class.ilADTLocation.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_LONGITUDE

const ilADTLocation::ADT_VALIDATION_ERROR_LONGITUDE = "loc1"

Definition at line 27 of file class.ilADTLocation.php.

Referenced by translateErrorCode().


The documentation for this class was generated from the following file: