ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Column.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
28 abstract class Column implements C\Column
29 {
30  use ComponentHelper;
31 
32  protected const SEPERATOR = ', ';
33 
34  protected bool $sortable = true;
35  protected bool $optional = false;
36  protected bool $initially_visible = true;
37  protected bool $highlighted = false;
38  protected int $index;
39  protected ?string $asc_label = null;
40  protected ?string $desc_label = null;
41 
42  public function __construct(
43  protected Language $lng,
44  protected string $title
45  ) {
46  }
47 
48  public function getTitle(): string
49  {
50  return $this->title;
51  }
52 
53  public function getType(): string
54  {
55  $class = explode('\\', $this::class);
56  return array_pop($class);
57  }
58 
59  public function withIsSortable(
60  bool $flag
61  ): self {
62  $clone = clone $this;
63  $clone->sortable = $flag;
64  return $clone;
65  }
66 
67  public function isSortable(): bool
68  {
69  return $this->sortable;
70  }
71 
72  public function withOrderingLabels(
73  ?string $asc_label = null,
74  ?string $desc_label = null
75  ): self {
76  $clone = clone $this;
77  $clone->asc_label = $asc_label;
78  $clone->desc_label = $desc_label;
79  return $clone;
80  }
81 
85  public function getOrderingLabels(): array
86  {
87  return [
88  $this->asc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_generic_ascending'),
89  $this->desc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_generic_descending')
90  ];
91  }
92 
93  public function withIsOptional(bool $is_optional, bool $is_initially_visible = true): self
94  {
95  $clone = clone $this;
96  $clone->optional = $is_optional;
97  $clone->initially_visible = $is_initially_visible;
98  return $clone;
99  }
100 
101  public function isOptional(): bool
102  {
103  return $this->optional;
104  }
105 
106  public function isInitiallyVisible(): bool
107  {
109  }
110 
111  public function withIndex(int $index): self
112  {
113  $clone = clone $this;
114  $clone->index = $index;
115  return $clone;
116  }
117 
118  public function getIndex(): int
119  {
120  return $this->index;
121  }
122 
123  public function withHighlight(bool $flag): self
124  {
125  $clone = clone $this;
126  $clone->highlighted = $flag;
127  return $clone;
128  }
129 
130  public function isHighlighted(): bool
131  {
132  return $this->highlighted;
133  }
134 
135  public function format($value): string|Component
136  {
137  return (string) $value;
138  }
139 }
withOrderingLabels(?string $asc_label=null, ?string $desc_label=null)
Definition: Column.php:72
withIsOptional(bool $is_optional, bool $is_initially_visible=true)
Definition: Column.php:93
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $lng
Definition: privfeed.php:31
__construct(protected Language $lng, protected string $title)
Definition: Column.php:42