ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ILIAS\UI\Implementation\Component Namespace Reference

Namespaces

 Breadcrumbs
 
 Button
 
 Card
 
 Chart
 
 Counter
 
 Deck
 
 Divider
 
 Dropdown
 
 Dropzone
 
 Glyph
 
 Icon
 
 Image
 
 Item
 
 Legacy
 
 
 Listing
 
 Modal
 
 Panel
 
 Popover
 
 ViewControl
 

Data Structures

class  Signal
 
class  SignalGenerator
 
interface  SignalGeneratorInterface
 
class  TriggeredSignal
 
interface  TriggeredSignalInterface
 

Functions

 getCanonicalName ()
 Default implementation uses the namespace of the component up to and excluding "Component", reverses the order and adds spaces. More...
 
 getCanonicalNameByFullyQualifiedName ()
 Does the calculation required for getCanonicalName. More...
 
 checkArg ($which, $check, $message)
 /** Throw an InvalidArgumentException containing the message if $check is false. More...
 
 checkIntArg ($which, $value)
 Throw an InvalidArgumentException if $value is no int. More...
 
 checkStringArg ($which, $value)
 Throw an InvalidArgumentException if $value is no string. More...
 
 checkFloatArg ($which, $value)
 Throw an InvalidArgumentException if $value is not a float. More...
 
 checkArgInstanceOf ($which, $value, $class)
 Throw an InvalidArgumentException if $value is not an instance of $class. More...
 
 checkArgIsElement ($which, $value, $array, $name)
 Throw an InvalidArgumentException if $value is not an element of array. More...
 
 checkArgList ($which, array &$values, \Closure $check, \Closure $message)
 Check every key and value of the list with a supplied closure. More...
 
 checkArgListElements ($which, array &$values, &$classes)
 Check every element of the list if it is an instance of one of the given classes. More...
 
 toArray ($value)
 Wrap the given value in an array if it is no array. More...
 
 wrongTypeMessage ($expected, $value)
 
 withOnLoadCode (\Closure $binder)
 
 withAdditionalOnLoadCode (\Closure $binder)
 
 getOnLoadCode ()
 
 checkBinder (\Closure $binder)
 
 appendTriggeredSignal (Component\Signal $signal, $event)
 Append a triggered signal to other signals of the same event. More...
 
 addTriggeredSignal (Component\Signal $signal, $event)
 Add a triggered signal, replacing any other signals registered on the same event. More...
 
 getTriggeredSignals ()
 
 withResetTriggeredSignals ()
 
 flattenArray (array $array)
 Flatten a multidimensional array to a single dimension. More...
 

Variables

trait ComponentHelper
 Provides common functionality for component implementations. More...
 
trait JavaScriptBindable
 Trait for components implementing JavaScriptBindable providing standard implementation. More...
 
trait Triggerer
 

Function Documentation

◆ addTriggeredSignal()

ILIAS\UI\Implementation\Component\addTriggeredSignal ( Component\Signal  $signal,
  $event 
)
protected

Add a triggered signal, replacing any other signals registered on the same event.

Parameters
Component\Signal$signal
string$event
Returns
$this

Definition at line 46 of file Triggerer.php.

References array.

Referenced by ILIAS\UI\Implementation\Component\Dropdown\Dropdown\withOnClick(), ILIAS\UI\Implementation\Component\Button\Button\withOnClick(), ILIAS\UI\Implementation\Component\Glyph\Glyph\withOnClick(), ILIAS\UI\Implementation\Component\Dropzone\File\File\withOnDrop(), ILIAS\UI\Implementation\Component\Dropdown\Dropdown\withOnHover(), ILIAS\UI\Implementation\Component\Button\Button\withOnHover(), ILIAS\UI\Implementation\Component\Modal\Modal\withOnLoad(), and ILIAS\UI\Implementation\Component\ViewControl\Sortation\withOnSort().

47  {
48  $clone = clone $this;
49  $clone->triggered_signals[$event] = array();
50  $clone->triggered_signals[$event][] = new TriggeredSignal($signal, $event);
51  return $clone;
52  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ appendTriggeredSignal()

ILIAS\UI\Implementation\Component\appendTriggeredSignal ( Component\Signal  $signal,
  $event 
)
protected

Append a triggered signal to other signals of the same event.

Parameters
Component\Signal$signal
string$event
Returns
$this

Definition at line 29 of file Triggerer.php.

References array.

Referenced by ILIAS\UI\Implementation\Component\Dropdown\Dropdown\appendOnClick(), ILIAS\UI\Implementation\Component\Button\Button\appendOnClick(), ILIAS\UI\Implementation\Component\Glyph\Glyph\appendOnClick(), ILIAS\UI\Implementation\Component\Dropdown\Dropdown\appendOnHover(), ILIAS\UI\Implementation\Component\Button\Button\appendOnHover(), ILIAS\UI\Implementation\Component\Modal\Modal\appendOnLoad(), and ILIAS\UI\Implementation\Component\Dropzone\File\File\withAdditionalDrop().

30  {
31  $clone = clone $this;
32  if (!is_array($clone->triggered_signals[$event])) {
33  $clone->triggered_signals[$event] = array();
34  }
35  $clone->triggered_signals[$event][] = new TriggeredSignal($signal, $event);
36  return $clone;
37  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ checkArg()

ILIAS\UI\Implementation\Component\checkArg (   $which,
  $check,
  $message 
)
protected

/** Throw an InvalidArgumentException containing the message if $check is false.

Parameters
string$which
bool$check
string$message
Exceptions

Definition at line 59 of file ComponentHelper.php.

Referenced by ComponentMock\_checkArg().

60  {
61  assert(is_string($which));
62  assert(is_bool($check));
63  assert(is_string($message));
64  if (!$check) {
65  throw new \InvalidArgumentException("Argument '$which': $message");
66  }
67  }
catch(Exception $e) $message
+ Here is the caller graph for this function:

◆ checkArgInstanceOf()

ILIAS\UI\Implementation\Component\checkArgInstanceOf (   $which,
  $value,
  $class 
)
protected

Throw an InvalidArgumentException if $value is not an instance of $class.

Parameters
string$which
mixed$value
string$class
Exceptions

Definition at line 117 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\ViewControl\Section\__construct(), ILIAS\UI\Implementation\Component\Modal\LightboxImagePage\__construct(), ComponentMock\_checkArgInstanceOf(), ILIAS\UI\Implementation\Component\Breadcrumbs\Breadcrumbs\withAppendedItem(), ILIAS\UI\Implementation\Component\Button\Tag\withBackgroundColor(), ILIAS\UI\Implementation\Component\Dropzone\File\File\withFileSizeLimit(), and ILIAS\UI\Implementation\Component\Button\Tag\withForegroundColor().

118  {
119  $this->checkArg($which, $value instanceof $class, $this->wrongTypeMessage($class, $value));
120  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
+ Here is the caller graph for this function:

◆ checkArgIsElement()

ILIAS\UI\Implementation\Component\checkArgIsElement (   $which,
  $value,
  $array,
  $name 
)
protected

Throw an InvalidArgumentException if $value is not an element of array.

Parameters
string$which
mixed$value
array$array
string$nameused in the exception
Exceptions

Definition at line 132 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\Icon\Custom\__construct(), ILIAS\UI\Implementation\Component\Deck\Deck\__construct(), ILIAS\UI\Implementation\Component\Counter\Counter\__construct(), ILIAS\UI\Implementation\Component\Image\Image\__construct(), ILIAS\UI\Implementation\Component\Glyph\Glyph\__construct(), ILIAS\UI\Implementation\Component\Icon\Standard\__construct(), ComponentMock\_checkArgIsElement(), ILIAS\UI\Implementation\Component\Deck\Deck\withCardsSize(), ILIAS\UI\Implementation\Component\Button\Tag\withRelevance(), and ILIAS\UI\Implementation\Component\Icon\Icon\withSize().

133  {
134  if (!is_object($value)) {
135  $message = "expected $name, got '$value'";
136  } else {
137  $message = "expected $name, got object.";
138  }
139  $message =
140  $this->checkArg($which, in_array($value, $array), $message);
141  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
catch(Exception $e) $message
+ Here is the caller graph for this function:

◆ checkArgList()

ILIAS\UI\Implementation\Component\checkArgList (   $which,
array $values,
\Closure  $check,
\Closure  $message 
)
protected

Check every key and value of the list with a supplied closure.

Parameters
string$which
mixed[]&$values
\Closure$checktakes key and value, should return false if those don't fit
\Closure$messagecreate an error message from key and value
Exceptions

Definition at line 153 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\Listing\Descriptive\__construct(), ComponentMock\_checkArgList(), and ILIAS\UI\Implementation\Component\Listing\Descriptive\withItems().

154  {
155  $failed_k = null;
156  $failed_v = null;
157  foreach ($values as $key => $value) {
158  $ok = $check($key, $value);
159  if (!$ok) {
160  $failed_k = $key;
161  $failed_v = $value;
162  break;
163  }
164  }
165 
166  if ($failed_k !== null) {
167  $m = $message($failed_k, $failed_v);
168  } else {
169  $m = "";
170  }
171 
172  $this->checkArg($which, $failed_k === null, $m);
173  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
catch(Exception $e) $message
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ checkArgListElements()

ILIAS\UI\Implementation\Component\checkArgListElements (   $which,
array $values,
$classes 
)
protected

Check every element of the list if it is an instance of one of the given classes.

Throw an InvalidArgumentException if that is not the case.

Parameters
string$which
mixed[]&$values
string|string[]$classes name(s) of classes
Exceptions

Definition at line 185 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\Breadcrumbs\Breadcrumbs\__construct(), ILIAS\UI\Implementation\Component\Panel\Report\__construct(), ILIAS\UI\Implementation\Component\Modal\Lightbox\__construct(), ILIAS\UI\Implementation\Component\Popover\Standard\__construct(), ILIAS\UI\Implementation\Component\Popover\Listing\__construct(), ILIAS\UI\Implementation\Component\Deck\Deck\__construct(), ILIAS\UI\Implementation\Component\Listing\Listing\__construct(), ILIAS\UI\Implementation\Component\Dropzone\File\Wrapper\__construct(), ILIAS\UI\Implementation\Component\Panel\Panel\__construct(), ILIAS\UI\Implementation\Component\Modal\RoundTrip\__construct(), ComponentMock\_checkArgListElements(), ILIAS\UI\Implementation\Component\Modal\RoundTrip\withActionButtons(), ILIAS\UI\Implementation\Component\Modal\Interruptive\withAffectedItems(), ILIAS\UI\Implementation\Component\Deck\Deck\withCards(), ILIAS\UI\Implementation\Component\Dropzone\File\Wrapper\withContent(), ILIAS\UI\Implementation\Component\Listing\Listing\withItems(), and ILIAS\UI\Implementation\Component\Card\Card\withSections().

186  {
187  $classes = $this->toArray($classes);
188  $this->checkArgList($which, $values, function ($_, $value) use (&$classes) {
189  foreach ($classes as $cls) {
190  if ($cls === "string" && is_string($value)) {
191  return true;
192  }
193  if ($cls === "int" && is_int($value)) {
194  return true;
195  } elseif ($value instanceof $cls) {
196  return true;
197  }
198  }
199  return false;
200  }, function ($_, $failed) use (&$classes) {
201  return $this->wrongTypeMessage(implode(", ", $classes), $failed);
202  });
203  }
checkArgList($which, array &$values, \Closure $check, \Closure $message)
Check every key and value of the list with a supplied closure.
$failed
Definition: Utf8Test.php:85
toArray($value)
Wrap the given value in an array if it is no array.
+ Here is the caller graph for this function:

◆ checkBinder()

ILIAS\UI\Implementation\Component\checkBinder ( \Closure  $binder)
private
Parameters
\Closure$binder
Exceptions

Definition at line 58 of file JavaScriptBindable.php.

References array.

Referenced by ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

59  {
60  $refl = new \ReflectionFunction($binder);
61  $args = array_map(function ($arg) {
62  return $arg->name;
63  }, $refl->getParameters());
64  if (array("id") !== $args) {
65  throw new \InvalidArgumentException('Expected closure "$binder" to have exactly one argument "$id".');
66  }
67  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ checkFloatArg()

ILIAS\UI\Implementation\Component\checkFloatArg (   $which,
  $value 
)
protected

Throw an InvalidArgumentException if $value is not a float.

Parameters
string$which
mixed$value
Exceptions

Definition at line 103 of file ComponentHelper.php.

Referenced by ComponentMock\_checkFloatArg().

104  {
105  $this->checkArg($which, is_float($value), $this->wrongTypeMessage("float", $value));
106  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
+ Here is the caller graph for this function:

◆ checkIntArg()

ILIAS\UI\Implementation\Component\checkIntArg (   $which,
  $value 
)
protected

Throw an InvalidArgumentException if $value is no int.

Parameters
string$which
mixed$value
Exceptions

Definition at line 77 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\Counter\Counter\__construct(), ComponentMock\_checkIntArg(), and ILIAS\UI\Implementation\Component\Dropzone\File\File\withMaxFiles().

78  {
79  $this->checkArg($which, is_int($value), $this->wrongTypeMessage("integer", $value));
80  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
+ Here is the caller graph for this function:

◆ checkStringArg()

ILIAS\UI\Implementation\Component\checkStringArg (   $which,
  $value 
)
protected

Throw an InvalidArgumentException if $value is no string.

Parameters
string$which
mixed$value
Exceptions

Definition at line 90 of file ComponentHelper.php.

Referenced by ILIAS\UI\Implementation\Component\Icon\Custom\__construct(), ILIAS\UI\Implementation\Component\Link\Standard\__construct(), ILIAS\UI\Implementation\Component\Link\Link\__construct(), ILIAS\UI\Implementation\Component\Legacy\Legacy\__construct(), ILIAS\UI\Implementation\Component\ViewControl\Mode\__construct(), ILIAS\UI\Implementation\Component\Panel\Listing\Listing\__construct(), ILIAS\UI\Implementation\Component\Panel\Panel\__construct(), ILIAS\UI\Implementation\Component\Item\Group\__construct(), ILIAS\UI\Implementation\Component\Modal\RoundTrip\__construct(), ILIAS\UI\Implementation\Component\Modal\LightboxImagePage\__construct(), ILIAS\UI\Implementation\Component\Modal\InterruptiveItem\__construct(), ILIAS\UI\Implementation\Component\Item\Item\__construct(), ILIAS\UI\Implementation\Component\Card\Card\__construct(), ILIAS\UI\Implementation\Component\Button\Button\__construct(), ILIAS\UI\Implementation\Component\Image\Image\__construct(), ILIAS\UI\Implementation\Component\Modal\Interruptive\__construct(), ILIAS\UI\Implementation\Component\Dropzone\File\File\__construct(), ILIAS\UI\Implementation\Component\Glyph\Glyph\__construct(), ILIAS\UI\Implementation\Component\Icon\Standard\__construct(), ComponentMock\_checkStringArg(), ILIAS\UI\Implementation\Component\Icon\Icon\withAbbreviation(), ILIAS\UI\Implementation\Component\Image\Image\withAction(), ILIAS\UI\Implementation\Component\ViewControl\Mode\withActive(), ILIAS\UI\Implementation\Component\Image\Image\withAlt(), ILIAS\UI\Implementation\Component\Button\Button\withAriaLabel(), ILIAS\UI\Implementation\Component\Popover\Popover\withAsyncContentUrl(), ILIAS\UI\Implementation\Component\Popover\ReplaceContentSignal\withAsyncRenderUrl(), ILIAS\UI\Implementation\Component\Modal\Modal\withAsyncRenderUrl(), ILIAS\UI\Implementation\Component\Button\Tag\withClasses(), ILIAS\UI\Implementation\Component\Item\Item\withDescription(), ILIAS\UI\Implementation\Component\Modal\Interruptive\withFormAction(), ILIAS\UI\Implementation\Component\Divider\Horizontal\withLabel(), ILIAS\UI\Implementation\Component\Dropdown\Dropdown\withLabel(), ILIAS\UI\Implementation\Component\Button\Button\withLabel(), ILIAS\UI\Implementation\Component\ViewControl\Sortation\withLabel(), ILIAS\UI\Implementation\Component\Item\Item\withLeadText(), ILIAS\UI\Implementation\Component\Dropzone\File\Standard\withMessage(), ILIAS\UI\Implementation\Component\Dropzone\File\File\withParameterName(), ILIAS\UI\Implementation\Component\Button\Tag\withRelevance(), ILIAS\UI\Implementation\Component\Image\Image\withSource(), ILIAS\UI\Implementation\Component\ViewControl\Sortation\withTargetURL(), ILIAS\UI\Implementation\Component\Card\Card\withTitle(), ILIAS\UI\Implementation\Component\Popover\Popover\withTitle(), ILIAS\UI\Implementation\Component\Card\Card\withTitleAction(), and ILIAS\UI\Implementation\Component\Dropzone\File\File\withUploadUrl().

91  {
92  $this->checkArg($which, is_string($value), $this->wrongTypeMessage("string", $value));
93  }
checkArg($which, $check, $message)
/** Throw an InvalidArgumentException containing the message if $check is false.
+ Here is the caller graph for this function:

◆ flattenArray()

ILIAS\UI\Implementation\Component\flattenArray ( array  $array)
private

Flatten a multidimensional array to a single dimension.

Parameters
array$array
Returns
array

Definition at line 78 of file Triggerer.php.

References array.

Referenced by ILIAS\UI\Implementation\Component\getTriggeredSignals().

79  {
80  $flatten = array();
81  array_walk_recursive($array, function ($a) use (&$flatten) {
82  $flatten[] = $a;
83  });
84  return $flatten;
85  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getCanonicalName()

ILIAS\UI\Implementation\Component\getCanonicalName ( )

Default implementation uses the namespace of the component up to and excluding "Component", reverses the order and adds spaces.

Also does caching.

Returns
string

Definition at line 23 of file ComponentHelper.php.

References ILIAS\UI\Implementation\Component\getCanonicalNameByFullyQualifiedName().

24  {
25  if ($this->canonical_name === null) {
26  $this->canonical_name = $this->getCanonicalNameByFullyQualifiedName();
27  }
28  return $this->canonical_name;
29  }
getCanonicalNameByFullyQualifiedName()
Does the calculation required for getCanonicalName.
+ Here is the call graph for this function:

◆ getCanonicalNameByFullyQualifiedName()

ILIAS\UI\Implementation\Component\getCanonicalNameByFullyQualifiedName ( )
protected

Does the calculation required for getCanonicalName.

Returns
string

Definition at line 36 of file ComponentHelper.php.

References $name.

Referenced by ILIAS\UI\Implementation\Component\getCanonicalName().

37  {
38  $cls = explode("\\", get_class($this));
39  $name = [];
40  $cur = array_pop($cls);
41  while ($cur !== "Component" && count($cls) > 0) {
42  $name[] = preg_replace("%([a-z])([A-Z])%", "$1 $2", $cur);
43  $cur = array_pop($cls);
44  }
45  return implode(" ", $name);
46  }
if($format !==null) $name
Definition: metadata.php:146
+ Here is the caller graph for this function:

◆ getOnLoadCode()

ILIAS\UI\Implementation\Component\getOnLoadCode ( )
See also
getOnLoadCode

Definition at line 48 of file JavaScriptBindable.php.

Referenced by ilSCORM2004PageGUI\postOutputProcessing(), and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

49  {
50  return $this->on_load_code_binder;
51  }
+ Here is the caller graph for this function:

◆ getTriggeredSignals()

ILIAS\UI\Implementation\Component\getTriggeredSignals ( )
Returns
[]

Definition at line 57 of file Triggerer.php.

References ILIAS\UI\Implementation\Component\flattenArray().

58  {
59  return $this->flattenArray($this->triggered_signals);
60  }
flattenArray(array $array)
Flatten a multidimensional array to a single dimension.
Definition: Triggerer.php:78
+ Here is the call graph for this function:

◆ toArray()

◆ withAdditionalOnLoadCode()

ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode ( \Closure  $binder)
See also
withAdditionalOnLoadCode

Definition at line 32 of file JavaScriptBindable.php.

References $id, ILIAS\UI\Implementation\Component\checkBinder(), ILIAS\UI\Implementation\Component\getOnLoadCode(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by JavaScriptBindableTest\test_withAdditionalOnLoadCode().

33  {
34  $current_binder = $this->getOnLoadCode();
35  if ($current_binder === null) {
36  return $this->withOnLoadCode($binder);
37  }
38 
39  $this->checkBinder($binder);
40  return $this->withOnLoadCode(function ($id) use ($current_binder, $binder) {
41  return $current_binder($id) . "\n" . $binder($id);
42  });
43  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withOnLoadCode()

ILIAS\UI\Implementation\Component\withOnLoadCode ( \Closure  $binder)
See also
withOnLoadCode

Definition at line 21 of file JavaScriptBindable.php.

References ILIAS\UI\Implementation\Component\checkBinder().

Referenced by ilCalendarBlockGUI\addMiniMonth(), ilGroupAddToGroupActionGUI\confirmAddUser(), ilGroupAddToGroupActionGUI\confirmCreateGroupAndAddUser(), ilOnScreenChatMenuGUI\getMainMenuHTML(), ilInternalLinkGUI\getUserSearchResult(), ilGroupAddToGroupActionGUI\sendResponse(), ilGroupAddToGroupActionGUI\show(), and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

22  {
23  $this->checkBinder($binder);
24  $clone = clone $this;
25  $clone->on_load_code_binder = $binder;
26  return $clone;
27  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withResetTriggeredSignals()

ILIAS\UI\Implementation\Component\withResetTriggeredSignals ( )
Returns
$this

Definition at line 65 of file Triggerer.php.

References array.

66  {
67  $clone = clone $this;
68  $clone->triggered_signals = array();
69  return $clone;
70  }
Create styles array
The data for the language used.

◆ wrongTypeMessage()

ILIAS\UI\Implementation\Component\wrongTypeMessage (   $expected,
  $value 
)
protected

Definition at line 219 of file ComponentHelper.php.

220  {
221  $type = gettype($value);
222  if (!is_object($value) && !is_array($value)) {
223  return "expected $expected, got $type '$value'";
224  } else {
225  if (is_object($value)) {
226  $type = get_class($value);
227  }
228  return "expected $expected, got $type";
229  }
230  }
$type

Variable Documentation

◆ ComponentHelper

trait ILIAS::UI::Implementation::Component\ComponentHelper
Initial value:
{
private $canonical_name = null

Provides common functionality for component implementations.

Definition at line 11 of file ComponentHelper.php.

◆ JavaScriptBindable

Initial value:
{
private $on_load_code_binder = null

Trait for components implementing JavaScriptBindable providing standard implementation.

Definition at line 12 of file JavaScriptBindable.php.

◆ Triggerer

Initial value:
{
protected $triggered_signals = array()
Create styles array
The data for the language used.

Definition at line 15 of file Triggerer.php.