ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\MetaData\Settings\Vocabularies\Presentation Class Reference
+ Collaboration diagram for ILIAS\MetaData\Settings\Vocabularies\Presentation:

Public Member Functions

 __construct (ElementsPresentation $elements_presentation, PresentationUtilities $presentation_utils, VocabPresentation $vocab_presentation, SlotHandler $slot_handler, Structure $structure, NavigatorFactory $navigator_factory, PathFactory $path_factory)
 
 txt (string $key)
 
 txtFill (string $key, string ... $values)
 
 makeTypePresentable (VocabType $type)
 
 makeSlotPresentable (SlotIdentifier $slot)
 
 makeValuesPresentable (VocabularyInterface $vocabulary, ?int $limit=null)
 

Protected Member Functions

 translateConditionValue (ConditionInterface $condition, StructureElementInterface $element)
 
 findFirstCommonParent (StructureElementInterface $a, StructureElementInterface $b)
 
 getStructureElementFromPath (PathInterface $path, StructureElementInterface $start)
 

Protected Attributes

const int MAX_PREVIEW_VALUES = 5
 
ElementsPresentation $elements_presentation
 
PresentationUtilities $presentation_utils
 
VocabPresentation $vocab_presentation
 
SlotHandler $slot_handler
 
Structure $structure
 
NavigatorFactory $navigator_factory
 
PathFactory $path_factory
 
array $vocabs
 

Detailed Description

Definition at line 37 of file Presentation.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Settings\Vocabularies\Presentation::__construct ( ElementsPresentation  $elements_presentation,
PresentationUtilities  $presentation_utils,
VocabPresentation  $vocab_presentation,
SlotHandler  $slot_handler,
Structure  $structure,
NavigatorFactory  $navigator_factory,
PathFactory  $path_factory 
)

Definition at line 54 of file Presentation.php.

References ILIAS\MetaData\Settings\Vocabularies\Presentation\$elements_presentation, ILIAS\MetaData\Settings\Vocabularies\Presentation\$navigator_factory, ILIAS\MetaData\Settings\Vocabularies\Presentation\$path_factory, ILIAS\MetaData\Settings\Vocabularies\Presentation\$presentation_utils, ILIAS\MetaData\Settings\Vocabularies\Presentation\$slot_handler, ILIAS\MetaData\Settings\Vocabularies\Presentation\$structure, and ILIAS\MetaData\Settings\Vocabularies\Presentation\$vocab_presentation.

62  {
63  $this->elements_presentation = $elements_presentation;
64  $this->presentation_utils = $presentation_utils;
65  $this->vocab_presentation = $vocab_presentation;
66  $this->slot_handler = $slot_handler;
67  $this->structure = $structure;
68  $this->navigator_factory = $navigator_factory;
69  $this->path_factory = $path_factory;
70  }

Member Function Documentation

◆ findFirstCommonParent()

ILIAS\MetaData\Settings\Vocabularies\Presentation::findFirstCommonParent ( StructureElementInterface  $a,
StructureElementInterface  $b 
)
protected

Definition at line 189 of file Presentation.php.

References Vendor\Package\$a, Vendor\Package\$b, and ILIAS\MetaData\Elements\Structure\StructureElementInterface\getSuperElement().

Referenced by ILIAS\MetaData\Settings\Vocabularies\Presentation\makeSlotPresentable().

192  : StructureElementInterface {
193  $a_supers = [];
194  while ($a) {
195  $a_supers[] = $a;
196  $a = $a->getSuperElement();
197  }
198  while ($b) {
199  if (in_array($b, $a_supers, true)) {
200  return $b;
201  }
202  $b = $b->getSuperElement();
203  }
204  return $a;
205  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStructureElementFromPath()

ILIAS\MetaData\Settings\Vocabularies\Presentation::getStructureElementFromPath ( PathInterface  $path,
StructureElementInterface  $start 
)
protected

Definition at line 207 of file Presentation.php.

Referenced by ILIAS\MetaData\Settings\Vocabularies\Presentation\makeSlotPresentable(), and ILIAS\MetaData\Settings\Vocabularies\Presentation\translateConditionValue().

210  : StructureElementInterface {
211  return $this->navigator_factory->structureNavigator(
212  $path,
213  $start
214  )->elementAtFinalStep();
215  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ makeSlotPresentable()

ILIAS\MetaData\Settings\Vocabularies\Presentation::makeSlotPresentable ( SlotIdentifier  $slot)

Definition at line 93 of file Presentation.php.

References ILIAS\MetaData\Settings\Vocabularies\Presentation\findFirstCommonParent(), ILIAS\MetaData\Settings\Vocabularies\Presentation\getStructureElementFromPath(), null, and ILIAS\MetaData\Settings\Vocabularies\Presentation\translateConditionValue().

93  : string
94  {
95  //skip the name of the element if it does not add any information
96  $skip_data = ['string', 'value'];
97 
98  $element = $this->getStructureElementFromPath(
99  $this->slot_handler->pathForSlot($slot),
100  $this->structure->getRoot()
101  );
102  $element_name = $this->elements_presentation->nameWithParents(
103  $element,
104  null,
105  false,
106  in_array($element->getDefinition()->name(), $skip_data),
107  );
108 
109  if (!$this->slot_handler->isSlotConditional($slot)) {
110  return $element_name;
111  }
112 
113  $condition = $this->slot_handler->conditionForSlot($slot);
114 
115  $condition_element = $this->getStructureElementFromPath(
116  $condition->path(),
117  $element
118  );
119  $condition_element_name = $this->elements_presentation->nameWithParents(
120  $condition_element,
121  $this->findFirstCommonParent($element, $condition_element)->getSuperElement(),
122  false,
123  in_array($element->getDefinition()->name(), $skip_data),
124  );
125 
126  return $this->presentation_utils->txtFill(
127  'md_vocab_element_with_condition',
128  $element_name,
129  $condition_element_name,
130  $this->translateConditionValue($condition, $element)
131  );
132  }
translateConditionValue(ConditionInterface $condition, StructureElementInterface $element)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getStructureElementFromPath(PathInterface $path, StructureElementInterface $start)
findFirstCommonParent(StructureElementInterface $a, StructureElementInterface $b)
+ Here is the call graph for this function:

◆ makeTypePresentable()

ILIAS\MetaData\Settings\Vocabularies\Presentation::makeTypePresentable ( VocabType  $type)

Definition at line 82 of file Presentation.php.

References ILIAS\MetaData\Vocabularies\COPYRIGHT.

82  : string
83  {
84  return match ($type) {
85  VocabType::STANDARD => $this->presentation_utils->txt('md_vocab_type_standard'),
86  VocabType::CONTROLLED_STRING => $this->presentation_utils->txt('md_vocab_type_controlled_string'),
87  VocabType::CONTROLLED_VOCAB_VALUE => $this->presentation_utils->txt('md_vocab_type_controlled_vocab_value'),
88  VocabType::COPYRIGHT => $this->presentation_utils->txt('md_vocab_type_copyright'),
89  default => '',
90  };
91  }

◆ makeValuesPresentable()

ILIAS\MetaData\Settings\Vocabularies\Presentation::makeValuesPresentable ( VocabularyInterface  $vocabulary,
?int  $limit = null 
)
Returns
string[]

Definition at line 137 of file Presentation.php.

References ILIAS\MetaData\Vocabularies\COPYRIGHT, null, and ILIAS\MetaData\Vocabularies\VocabularyInterface\type().

140  : array {
141  $presentable_values = [];
142  $i = 0;
143 
144  $labelled_values = $this->vocab_presentation->labelsForVocabulary(
145  $this->presentation_utils,
146  $vocabulary
147  );
148  foreach ($labelled_values as $labelled_value) {
149  if ($limit !== null && $i >= $limit) {
150  $presentable_values[] = '...';
151  break;
152  }
153  $i++;
154 
155  if (
156  $vocabulary->type() === VocabType::STANDARD ||
157  $vocabulary->type() === VocabType::COPYRIGHT
158  ) {
159  $presentable_values[] = $this->presentation_utils->sanitizeForHTML($labelled_value->label());
160  continue;
161  }
162 
163  $presentable_value = $labelled_value->value();
164  if ($labelled_value->label() !== '') {
165  $presentable_value = $labelled_value->label() . ' (' . $presentable_value . ')';
166  }
167  $presentable_values[] = $this->presentation_utils->sanitizeForHTML($presentable_value);
168  }
169 
170  return $presentable_values;
171  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ translateConditionValue()

ILIAS\MetaData\Settings\Vocabularies\Presentation::translateConditionValue ( ConditionInterface  $condition,
StructureElementInterface  $element 
)
protected

Definition at line 173 of file Presentation.php.

References ILIAS\MetaData\Settings\Vocabularies\Presentation\getStructureElementFromPath(), null, ILIAS\MetaData\Vocabularies\Slots\Conditions\ConditionInterface\path(), and ILIAS\MetaData\Vocabularies\Slots\Conditions\ConditionInterface\value().

Referenced by ILIAS\MetaData\Settings\Vocabularies\Presentation\makeSlotPresentable().

176  : string {
177  $path_from_root = $this->path_factory->toElement(
178  $this->getStructureElementFromPath($condition->path(), $element),
179  );
180  $slot = $this->slot_handler->identiferFromPathAndCondition($path_from_root, null, null);
181  return (string) $this->vocab_presentation->presentableLabels(
182  $this->presentation_utils,
183  $slot,
184  false,
185  $condition->value()
186  )->current()?->label();
187  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getStructureElementFromPath(PathInterface $path, StructureElementInterface $start)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txt()

ILIAS\MetaData\Settings\Vocabularies\Presentation::txt ( string  $key)

Definition at line 72 of file Presentation.php.

72  : string
73  {
74  return $this->presentation_utils->txt($key);
75  }

◆ txtFill()

ILIAS\MetaData\Settings\Vocabularies\Presentation::txtFill ( string  $key,
string ...  $values 
)

Definition at line 77 of file Presentation.php.

77  : string
78  {
79  return $this->presentation_utils->txtFill($key, ...$values);
80  }

Field Documentation

◆ $elements_presentation

ElementsPresentation ILIAS\MetaData\Settings\Vocabularies\Presentation::$elements_presentation
protected

◆ $navigator_factory

NavigatorFactory ILIAS\MetaData\Settings\Vocabularies\Presentation::$navigator_factory
protected

◆ $path_factory

PathFactory ILIAS\MetaData\Settings\Vocabularies\Presentation::$path_factory
protected

◆ $presentation_utils

PresentationUtilities ILIAS\MetaData\Settings\Vocabularies\Presentation::$presentation_utils
protected

◆ $slot_handler

SlotHandler ILIAS\MetaData\Settings\Vocabularies\Presentation::$slot_handler
protected

◆ $structure

Structure ILIAS\MetaData\Settings\Vocabularies\Presentation::$structure
protected

◆ $vocab_presentation

VocabPresentation ILIAS\MetaData\Settings\Vocabularies\Presentation::$vocab_presentation
protected

◆ $vocabs

array ILIAS\MetaData\Settings\Vocabularies\Presentation::$vocabs
protected

Definition at line 52 of file Presentation.php.

◆ MAX_PREVIEW_VALUES

const int ILIAS\MetaData\Settings\Vocabularies\Presentation::MAX_PREVIEW_VALUES = 5
protected

Definition at line 39 of file Presentation.php.


The documentation for this class was generated from the following file: