ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilADTExternalLink.php
Go to the documentation of this file.
1 <?php
2 
3 class ilADTExternalLink extends ilADT
4 {
5  const MAX_LENGTH = 500;
6 
10  protected $value;
11 
15  protected $title;
16 
17 
22  protected function isValidDefinition(ilADTDefinition $a_def)
23  {
24  return $a_def instanceof ilADTExternalLinkDefinition;
25  }
26 
30  public function reset()
31  {
32  parent::reset();
33  $this->value = null;
34  $this->title = null;
35  }
36 
41  public function setTitle($a_title = null)
42  {
43  if ($a_title !== null) {
44  $a_title = trim($a_title);
45  }
46  $this->title = $a_title;
47  }
48 
53  public function getTitle()
54  {
55  return $this->title;
56  }
57 
62  public function setUrl($a_value = null)
63  {
64  if ($a_value !== null) {
65  $a_value = trim($a_value);
66  }
67  $this->value = $a_value;
68  }
69 
74  public function getUrl()
75  {
76  return $this->value;
77  }
78 
79 
85  public function equals(ilADT $a_adt)
86  {
87  if ($this->getDefinition()->isComparableTo($a_adt)) {
88  return strcmp($this->getCheckSum(), $a_adt->getCheckSum()) === 0;
89  }
90  }
91 
96  public function isLarger(ilADT $a_adt)
97  {
98  }
99 
104  public function isSmaller(ilADT $a_adt)
105  {
106  }
107 
112  public function isNull()
113  {
114  return (bool) !$this->getLength();
115  }
116 
121  public function getLength()
122  {
123  if (function_exists("mb_strlen")) {
124  return mb_strlen($this->getUrl() . $this->getTitle(), "UTF-8");
125  } else {
126  return strlen($this->getUrl() . $this->getTitle());
127  }
128  }
129 
130 
135  public function isValid()
136  {
137  $valid = parent::isValid();
138 
139  if (!$this->isNull()) {
140  if (self::MAX_LENGTH < $this->getLength()) {
141  $valid = false;
142  $this->addValidationError(self::ADT_VALIDATION_ERROR_MAX_LENGTH);
143  }
144  }
145 
146  return $valid;
147  }
148 
153  public function getCheckSum()
154  {
155  if (!$this->isNull()) {
156  return md5($this->getUrl() . $this->getTitle());
157  }
158  }
159 }
$valid
addValidationError($a_error_code)
Add validation error code.
ADT base class.
Definition: class.ilADT.php:11
getCheckSum()
Get unique checksum.
ADT definition base class.
getDefinition()
Get definition.
Definition: class.ilADT.php:97