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

Public Member Functions

 __construct (Factory $factory, IRSS $irss)
 
 toUIComponents (CopyrightDataInterface $copyright)
 

Protected Member Functions

 buildIcon (CopyrightDataInterface $copyright)
 
 buildIconFromLink (CopyrightDataInterface $copyright)
 
 buildIconFromFile (CopyrightDataInterface $copyright)
 
 buildFallBackIcon (CopyrightDataInterface $copyright)
 
 getFallBackSrc ()
 
 buildLink (CopyrightDataInterface $copyright)
 
 customIcon (string $src, string $alt)
 
 standardLink (string $label, string $action)
 
 textInLegacy (string $text)
 
 getSourceFromIRSS (string $string_id)
 

Protected Attributes

const FALLBACK_IMG = 'copyrights\all_rights_reserved.svg'
 
Factory $factory
 
IRSS $irss
 

Detailed Description

Definition at line 30 of file Renderer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Copyright\Renderer::__construct ( Factory  $factory,
IRSS  $irss 
)

Definition at line 37 of file Renderer.php.

References ILIAS\MetaData\Copyright\Renderer\$factory, and ILIAS\MetaData\Copyright\Renderer\$irss.

40  {
41  $this->factory = $factory;
42  $this->irss = $irss;
43  }

Member Function Documentation

◆ buildFallBackIcon()

ILIAS\MetaData\Copyright\Renderer::buildFallBackIcon ( CopyrightDataInterface  $copyright)
protected

Definition at line 102 of file Renderer.php.

References ILIAS\MetaData\Copyright\CopyrightDataInterface\altText(), ILIAS\MetaData\Copyright\Renderer\customIcon(), and ILIAS\MetaData\Copyright\Renderer\getFallBackSrc().

Referenced by ILIAS\MetaData\Copyright\Renderer\buildIcon().

102  : ?Icon
103  {
104  return $this->customIcon(
105  $this->getFallBackSrc(),
106  $copyright->altText()
107  );
108  }
customIcon(string $src, string $alt)
Definition: Renderer.php:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildIcon()

ILIAS\MetaData\Copyright\Renderer::buildIcon ( CopyrightDataInterface  $copyright)
protected

Definition at line 65 of file Renderer.php.

References ILIAS\MetaData\Copyright\Renderer\buildFallBackIcon(), ILIAS\MetaData\Copyright\Renderer\buildIconFromFile(), ILIAS\MetaData\Copyright\Renderer\buildIconFromLink(), ILIAS\MetaData\Copyright\CopyrightDataInterface\fallBackToDefaultImage(), ILIAS\MetaData\Copyright\CopyrightDataInterface\hasImage(), and ILIAS\MetaData\Copyright\CopyrightDataInterface\isImageLink().

Referenced by ILIAS\MetaData\Copyright\Renderer\toUIComponents().

65  : ?Icon
66  {
67  if (!$copyright->hasImage()) {
68  if ($copyright->fallBackToDefaultImage()) {
69  return $this->buildFallBackIcon($copyright);
70  }
71  return null;
72  }
73  if ($copyright->isImageLink()) {
74  return $this->buildIconFromLink($copyright);
75  } else {
76  return $this->buildIconFromFile($copyright);
77  }
78  }
buildFallBackIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:102
buildIconFromLink(CopyrightDataInterface $copyright)
Definition: Renderer.php:80
buildIconFromFile(CopyrightDataInterface $copyright)
Definition: Renderer.php:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildIconFromFile()

ILIAS\MetaData\Copyright\Renderer::buildIconFromFile ( CopyrightDataInterface  $copyright)
protected

Definition at line 88 of file Renderer.php.

References ILIAS\MetaData\Copyright\CopyrightDataInterface\altText(), ILIAS\MetaData\Copyright\Renderer\customIcon(), ILIAS\MetaData\Copyright\Renderer\getSourceFromIRSS(), and ILIAS\MetaData\Copyright\CopyrightDataInterface\imageFile().

Referenced by ILIAS\MetaData\Copyright\Renderer\buildIcon().

88  : ?Icon
89  {
90  if ($from_irss = $this->getSourceFromIRSS($copyright->imageFile())) {
91  $src = $from_irss;
92  } else {
93  return null;
94  }
95 
96  return $this->customIcon(
97  $src,
98  $copyright->altText()
99  );
100  }
getSourceFromIRSS(string $string_id)
Definition: Renderer.php:141
customIcon(string $src, string $alt)
Definition: Renderer.php:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildIconFromLink()

ILIAS\MetaData\Copyright\Renderer::buildIconFromLink ( CopyrightDataInterface  $copyright)
protected

Definition at line 80 of file Renderer.php.

References ILIAS\MetaData\Copyright\CopyrightDataInterface\altText(), ILIAS\MetaData\Copyright\Renderer\customIcon(), and ILIAS\MetaData\Copyright\CopyrightDataInterface\imageLink().

Referenced by ILIAS\MetaData\Copyright\Renderer\buildIcon().

80  : Icon
81  {
82  return $this->customIcon(
83  (string) $copyright->imageLink(),
84  $copyright->altText()
85  );
86  }
customIcon(string $src, string $alt)
Definition: Renderer.php:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLink()

ILIAS\MetaData\Copyright\Renderer::buildLink ( CopyrightDataInterface  $copyright)
protected

Definition at line 115 of file Renderer.php.

References ILIAS\MetaData\Copyright\CopyrightDataInterface\fullName(), ILIAS\MetaData\Copyright\CopyrightDataInterface\link(), and ILIAS\MetaData\Copyright\Renderer\standardLink().

Referenced by ILIAS\MetaData\Copyright\Renderer\toUIComponents().

115  : ?Link
116  {
117  if (!$copyright->link()) {
118  return null;
119  }
120  return $this->standardLink(
121  $copyright->fullName() !== '' ? $copyright->fullName() : (string) $copyright->link(),
122  (string) $copyright->link()
123  )->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE);
124  }
standardLink(string $label, string $action)
Definition: Renderer.php:131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ customIcon()

ILIAS\MetaData\Copyright\Renderer::customIcon ( string  $src,
string  $alt 
)
protected

Definition at line 126 of file Renderer.php.

References ILIAS\UI\Component\Symbol\Icon\Icon\MEDIUM.

Referenced by ILIAS\MetaData\Copyright\Renderer\buildFallBackIcon(), ILIAS\MetaData\Copyright\Renderer\buildIconFromFile(), and ILIAS\MetaData\Copyright\Renderer\buildIconFromLink().

126  : Icon
127  {
128  return $this->factory->symbol()->icon()->custom($src, $alt, Icon::MEDIUM);
129  }
+ Here is the caller graph for this function:

◆ getFallBackSrc()

ILIAS\MetaData\Copyright\Renderer::getFallBackSrc ( )
protected

Definition at line 110 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\buildFallBackIcon().

110  : string
111  {
112  return \ilUtil::getImagePath(self::FALLBACK_IMG);
113  }
+ Here is the caller graph for this function:

◆ getSourceFromIRSS()

ILIAS\MetaData\Copyright\Renderer::getSourceFromIRSS ( string  $string_id)
protected

Definition at line 141 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\buildIconFromFile().

141  : string
142  {
143  if ($identifier = $this->irss->manage()->find($string_id)) {
144  return $this->irss->consume()->src($identifier)->getSrc();
145  }
146  return '';
147  }
+ Here is the caller graph for this function:

◆ standardLink()

ILIAS\MetaData\Copyright\Renderer::standardLink ( string  $label,
string  $action 
)
protected

Definition at line 131 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\buildLink().

131  : Link
132  {
133  return $this->factory->link()->standard($label, $action);
134  }
+ Here is the caller graph for this function:

◆ textInLegacy()

ILIAS\MetaData\Copyright\Renderer::textInLegacy ( string  $text)
protected

Definition at line 136 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\toUIComponents().

136  : Legacy
137  {
138  return $this->factory->legacy($text);
139  }
+ Here is the caller graph for this function:

◆ toUIComponents()

ILIAS\MetaData\Copyright\Renderer::toUIComponents ( CopyrightDataInterface  $copyright)
Returns
Icon[]|Link[]|Legacy[]

Definition at line 48 of file Renderer.php.

References $res, ILIAS\MetaData\Copyright\Renderer\buildIcon(), ILIAS\MetaData\Copyright\Renderer\buildLink(), ILIAS\MetaData\Copyright\CopyrightDataInterface\fullName(), and ILIAS\MetaData\Copyright\Renderer\textInLegacy().

48  : array
49  {
50  $res = [];
51  $has_link = false;
52  if (!is_null($image = $this->buildIcon($copyright))) {
53  $res[] = $image;
54  }
55  if (!is_null($link = $this->buildLink($copyright))) {
56  $res[] = $link;
57  $has_link = true;
58  }
59  if ($copyright->fullName() && !$has_link) {
60  $res[] = $this->textInLegacy($copyright->fullName());
61  }
62  return $res;
63  }
$res
Definition: ltiservices.php:69
buildIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:65
buildLink(CopyrightDataInterface $copyright)
Definition: Renderer.php:115
+ Here is the call graph for this function:

Field Documentation

◆ $factory

Factory ILIAS\MetaData\Copyright\Renderer::$factory
protected

Definition at line 34 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\__construct().

◆ $irss

IRSS ILIAS\MetaData\Copyright\Renderer::$irss
protected

Definition at line 35 of file Renderer.php.

Referenced by ILIAS\MetaData\Copyright\Renderer\__construct().

◆ FALLBACK_IMG

const ILIAS\MetaData\Copyright\Renderer::FALLBACK_IMG = 'copyrights\all_rights_reserved.svg'
protected

Definition at line 32 of file Renderer.php.


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