3 namespace wcf\data\label
;
5 use wcf\data\DatabaseObject
;
6 use wcf\system\request\IRouteController
;
8 use wcf\util\StringUtil
;
13 * @author Alexander Ebert
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @property-read int $labelID unique id of the label
18 * @property-read int $groupID id of the label group the label belongs to
19 * @property-read string $label label text or name of language item which contains the label text
20 * @property-read string $cssClassName css class name used when displaying the label
21 * @property-read int $showOrder position of the label in relation to the other labels in the label group
23 class Label
extends DatabaseObject
implements IRouteController
26 * Returns the label's textual representation if a label is treated as a
29 public function __toString(): string
31 return $this->getTitle();
37 public function getTitle(): string
39 return WCF
::getLanguage()->get($this->label
);
43 * Returns label CSS class names.
47 public function getClassNames()
49 if ($this->cssClassName
== 'none') {
53 return $this->cssClassName
;
57 * Returns the HTML representation of the label.
59 * @param string $additionalClasses
63 public function render($additionalClasses = '')
65 return '<span class="badge label' . ($this->getClassNames() ?
' ' . $this->getClassNames() : '')
66 . ($additionalClasses ?
' ' . $additionalClasses : '') . '">'
67 . StringUtil
::encodeHTML($this->getTitle()) . '</span>';