ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\MetaData\Presentation\Data Class Reference
+ Inheritance diagram for ILIAS\MetaData\Presentation\Data:
+ Collaboration diagram for ILIAS\MetaData\Presentation\Data:

Public Member Functions

 __construct (UtilitiesInterface $utilities, DataHelperInterface $data_helper)
 
 dataValue (ElementsDataInterface $data)
 
 vocabularyValue (string $value)
 
 language (string $language)
 
 datetime (string $datetime)
 
 duration (string $duration)
 

Protected Member Functions

 fillSpaces (string $string)
 
 camelCaseToSpaces (string $string)
 

Protected Attributes

UtilitiesInterface $utilities
 
DataHelperInterface $data_helper
 

Detailed Description

Definition at line 27 of file Data.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Presentation\Data::__construct ( UtilitiesInterface  $utilities,
DataHelperInterface  $data_helper 
)

Definition at line 32 of file Data.php.

References ILIAS\MetaData\Presentation\Data\$data_helper, and ILIAS\MetaData\Presentation\Data\$utilities.

35  {
36  $this->utilities = $utilities;
37  $this->data_helper = $data_helper;
38  }
UtilitiesInterface $utilities
Definition: Data.php:29
DataHelperInterface $data_helper
Definition: Data.php:30

Member Function Documentation

◆ camelCaseToSpaces()

ILIAS\MetaData\Presentation\Data::camelCaseToSpaces ( string  $string)
protected

Definition at line 128 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\vocabularyValue().

128  : string
129  {
130  $string = preg_replace('/(?<=[a-z])(?=[A-Z])/', ' ', $string);
131  return strtolower($string);
132  }
+ Here is the caller graph for this function:

◆ dataValue()

ILIAS\MetaData\Presentation\Data::dataValue ( ElementsDataInterface  $data)

Implements ILIAS\MetaData\Presentation\DataInterface.

Definition at line 40 of file Data.php.

References ILIAS\MetaData\Presentation\Data\datetime(), ILIAS\MetaData\Elements\Data\DURATION, ILIAS\MetaData\Presentation\Data\duration(), ILIAS\MetaData\Presentation\Data\language(), and ILIAS\MetaData\Presentation\Data\vocabularyValue().

40  : string
41  {
42  switch ($data->type()) {
43  case Type::VOCAB_VALUE:
44  return $this->vocabularyValue($data->value());
45 
46  case Type::LANG:
47  return $this->language($data->value());
48 
49  case Type::DATETIME:
50  return $this->datetime($data->value());
51 
52  case Type::DURATION:
53  return $this->duration($data->value());
54 
55  default:
56  return $data->value();
57  }
58  }
language(string $language)
Definition: Data.php:88
duration(string $duration)
Definition: Data.php:99
vocabularyValue(string $value)
Definition: Data.php:60
datetime(string $datetime)
Definition: Data.php:93
+ Here is the call graph for this function:

◆ datetime()

ILIAS\MetaData\Presentation\Data::datetime ( string  $datetime)

Implements ILIAS\MetaData\Presentation\DataInterface.

Definition at line 93 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\dataValue().

93  : string
94  {
95  $date = $this->data_helper->datetimeToObject($datetime);
96  return $this->utilities->getUserDateFormat()->applyTo($date);
97  }
$datetime
+ Here is the caller graph for this function:

◆ duration()

ILIAS\MetaData\Presentation\Data::duration ( string  $duration)

Implements ILIAS\MetaData\Presentation\DataInterface.

Definition at line 99 of file Data.php.

References ILIAS\LTI\ToolProvider\$key.

Referenced by ILIAS\MetaData\Presentation\Data\dataValue().

99  : string
100  {
101  $labels = [
102  ['years', 'year'],
103  ['months', 'month'],
104  ['days', 'day'],
105  ['hours', 'hour'],
106  ['minutes', 'minute'],
107  ['seconds', 'second'],
108  ];
109  $res_array = [];
110  foreach ($this->data_helper->durationToIterator($duration) as $key => $match) {
111  if (!is_null($match)) {
112  $res_array[] =
113  $match . ' ' .
114  ($match === '1' ?
115  $this->utilities->txt($labels[$key][1]) :
116  $this->utilities->txt($labels[$key][0]));
117  }
118  }
119  return implode(', ', $res_array);
120  }
$duration
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ fillSpaces()

ILIAS\MetaData\Presentation\Data::fillSpaces ( string  $string)
protected

Definition at line 122 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\vocabularyValue().

122  : string
123  {
124  $string = str_replace(' ', '_', $string);
125  return strtolower($string);
126  }
+ Here is the caller graph for this function:

◆ language()

ILIAS\MetaData\Presentation\Data::language ( string  $language)

Implements ILIAS\MetaData\Presentation\DataInterface.

Definition at line 88 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\dataValue().

88  : string
89  {
90  return $this->utilities->txt('meta_l_' . $language);
91  }
+ Here is the caller graph for this function:

◆ vocabularyValue()

ILIAS\MetaData\Presentation\Data::vocabularyValue ( string  $value)

Implements ILIAS\MetaData\Presentation\DataInterface.

Definition at line 60 of file Data.php.

References ILIAS\MetaData\Presentation\Data\camelCaseToSpaces(), and ILIAS\MetaData\Presentation\Data\fillSpaces().

Referenced by ILIAS\MetaData\Presentation\Data\dataValue().

60  : string
61  {
62  $value = $this->camelCaseToSpaces($value);
63  $exceptions = [
64  'ispartof' => 'is_part_of', 'haspart' => 'has_part',
65  'isversionof' => 'is_version_of', 'hasversion' => 'has_version',
66  'isformatof' => 'is_format_of', 'hasformat' => 'has_format',
67  'references' => 'references',
68  'isreferencedby' => 'is_referenced_by',
69  'isbasedon' => 'is_based_on', 'isbasisfor' => 'is_basis_for',
70  'requires' => 'requires', 'isrequiredby' => 'is_required_by',
71  'graphical designer' => 'graphicaldesigner',
72  'technical implementer' => 'technicalimplementer',
73  'content provider' => 'contentprovider',
74  'technical validator' => 'technicalvalidator',
75  'educational validator' => 'educationalvalidator',
76  'script writer' => 'scriptwriter',
77  'instructional designer' => 'instructionaldesigner',
78  'subject matter expert' => 'subjectmatterexpert',
79  'diagram' => 'diagramm'
80  ];
81  if (array_key_exists($value, $exceptions)) {
82  $value = $exceptions[$value];
83  }
84 
85  return $this->utilities->txt('meta_' . $this->fillSpaces($value));
86  }
camelCaseToSpaces(string $string)
Definition: Data.php:128
fillSpaces(string $string)
Definition: Data.php:122
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data_helper

DataHelperInterface ILIAS\MetaData\Presentation\Data::$data_helper
protected

Definition at line 30 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\__construct().

◆ $utilities

UtilitiesInterface ILIAS\MetaData\Presentation\Data::$utilities
protected

Definition at line 29 of file Data.php.

Referenced by ILIAS\MetaData\Presentation\Data\__construct().


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