ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilADTLocalizedTextPresentationBridge.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
11 {
12  public function __construct(ilADT $a_adt)
13  {
14  parent::__construct($a_adt);
15  }
16 
17  protected function isValidADT(ilADT $a_adt): bool
18  {
19  return $a_adt instanceof ilADTLocalizedText;
20  }
21 
22  public function getHTML(): string
23  {
24  if (!$this->getADT()->isNull()) {
25  return $this->decorate(nl2br($this->getTextForCurrentLanguageIfAvailable()));
26  }
27  return '';
28  }
29 
30  public function getSortable(): string
31  {
32  if (!$this->getADT()->isNull()) {
33  return strtolower($this->getTextForCurrentLanguageIfAvailable());
34  }
35  return '';
36  }
37 
38  private function getTextForCurrentLanguageIfAvailable(): string
39  {
40  $language = $this->lng->getLangKey();
41  if (!$this->getADT()->getCopyOfDefinition()->getMultilingualValueSupport()) {
42  $language = $this->getADT()->getCopyOfDefinition()->getDefaultLanguage();
43  }
44  return $this->getADT()->getTextForLanguage($language);
45  }
46 }
decorate($a_value)
Decorate value.
ADT base class.
Definition: class.ilADT.php:11
Class ilADTLocalizedText.
__construct(VocabulariesInterface $vocabularies)