33 protected $type =
'string';
37 protected $parent = NULL;
50 if (isset($data[
'attributes'])) {
56 if (isset($data[
'label'])) {
57 $label = $data[
'label'];
65 $this->parent = $parent;
66 $this->label = $label;
70 protected function setAttributesVar (
string $var, array
$attributes = NULL)
75 function setTemplateAttributes (array
$attributes = NULL)
77 $this->setAttributesVar(
'templateAttributes',
$attributes);
80 function isSortable ():
bool 85 function isExportable ():
bool 87 return !empty($this->attributes);
90 function getHtmlProps ():
string 95 function getHtmlCellProps ():
string 100 function getLabel ():
string 102 if (isset($this->label)) {
103 return _($this->label);
109 function fillNeededAttributes (array &$attrs)
111 if (isset($this->attributes)) {
112 foreach ($this->attributes as $attr) {
113 if (($attr ==
'mainAttr') || ($attr ==
'nameAttr')) {
116 } elseif ($attr ==
'dn') {
118 $attrs[$attr] =
'raw';
127 function fillSearchedAttributes (array &$attrs)
129 if (isset($this->attributes)) {
130 foreach ($this->attributes as $attr) {
131 if (($attr ==
'mainAttr') || ($attr ==
'nameAttr')) {
142 function fillRowClasses (array &$classes,
ListingEntry $entry)
146 protected function getAttributeValues (
ListingEntry $entry): array
149 if (isset($this->templateAttributes) && $entry->isTemplate()) {
153 foreach ($attrs as $attr) {
154 if (($attr ==
'mainAttr') || ($attr ==
'nameAttr')) {
155 $infos = objects::infos($entry->getTemplatedType());
156 $attr = $infos[$attr];
158 if (isset($entry[$attr])) {
159 if (is_array($entry[$attr])) {
160 return $entry[$attr];
163 return [$entry[$attr]];
173 $values = $this->getAttributeValues($entry);
174 if (empty($values)) {
177 return implode(
"<br/>\n",
179 function ($value) use ($entry)
181 return $this->renderSingleValue($entry, $value);
189 protected function renderSingleValue (
ListingEntry $entry,
string $value):
string 194 function getRawExportValues (
ListingEntry $entry): array
196 return $this->getAttributeValues($entry);
201 $a = $this->getAttributeValues($ao)[0] ??
'';
202 $b = $this->getAttributeValues($bo)[0] ??
'';
205 switch ($this->type) {
207 return strnatcmp($a, $b);
219 list($d, $m, $y) = explode(
'.', $a);
220 $a = (int)sprintf(
'%04d%02d%02d', $y, $m, $d);
221 list($d, $m, $y) = explode(
'.', $b);
222 $b = (int)sprintf(
'%04d%02d%02d', $y, $m, $d);
226 $parts_a = explode(
'.', $a, 4);
227 $parts_b = explode(
'.', $b, 4);
228 for ($i = 0; $i < 4; $i++) {
229 if ((
int)($parts_a[$i]) != (
int)($parts_b[$i])) {
230 return (
int)($parts_a[$i]) - (
int)($parts_b[$i]);
238 return strcoll($a, $b);
htmlescape(string $str)
Escape string for HTML output.
$attributes
Array of attributes to look for, ordered by priority The first non-empty attribute will be displayed...
static build(managementListing $parent, string $type, array $data)
Builds a column object from given data.
This class handles the entries list for a management instance.
$templateAttributes
Same thing for templates, if it differs.