ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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)
 
 toImageOnly (CopyrightDataInterface $copyright)
 
 toLinkOnly (CopyrightDataInterface $copyright)
 Returns a string as a disabled link, if only a string can be returned, or null if the copyright is image only. More...
 
 toString (CopyrightDataInterface $copyright)
 
 toUIComponents (CopyrightDataInterface $copyright)
 Returns a string in a legacy UI component if only a string can be returned. More...
 
 toImageOnly (CopyrightDataInterface $copyright)
 
 toLinkOnly (CopyrightDataInterface $copyright)
 Returns a string as a disabled link, if only a string can be returned, or null if the copyright is image only. More...
 
 toString (CopyrightDataInterface $copyright)
 

Protected Member Functions

 buildIcon (CopyrightDataInterface $copyright)
 
 buildIconFromLink (CopyrightDataInterface $copyright)
 
 buildIconFromFile (CopyrightDataInterface $copyright)
 
 buildFallBackIcon (CopyrightDataInterface $copyright)
 
 getFallBackSrc ()
 
 buildLink (CopyrightDataInterface $copyright, bool $allow_empty_link)
 
 customIcon (string $src, string $alt)
 
 standardLink (string $label, string $action, ?Relationship $relationship, bool $disabled)
 
 textInLegacy (string $text)
 
 getSourceFromIRSS (string $string_id)
 

Protected Attributes

const string 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.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildFallBackIcon()

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

Definition at line 128 of file Renderer.php.

128 : ?Icon
129 {
130 return $this->customIcon(
131 $this->getFallBackSrc(),
132 $copyright->altText()
133 );
134 }
customIcon(string $src, string $alt)
Definition: Renderer.php:157

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

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

+ 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 91 of file Renderer.php.

91 : ?Icon
92 {
93 if (!$copyright->hasImage()) {
94 if ($copyright->fallBackToDefaultImage()) {
95 return $this->buildFallBackIcon($copyright);
96 }
97 return null;
98 }
99 if ($copyright->isImageLink()) {
100 return $this->buildIconFromLink($copyright);
101 } else {
102 return $this->buildIconFromFile($copyright);
103 }
104 }
buildIconFromLink(CopyrightDataInterface $copyright)
Definition: Renderer.php:106
buildIconFromFile(CopyrightDataInterface $copyright)
Definition: Renderer.php:114
buildFallBackIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:128

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\toImageOnly(), and ILIAS\MetaData\Copyright\Renderer\toUIComponents().

+ 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 114 of file Renderer.php.

114 : ?Icon
115 {
116 if ($from_irss = $this->getSourceFromIRSS($copyright->imageFile())) {
117 $src = $from_irss;
118 } else {
119 return null;
120 }
121
122 return $this->customIcon(
123 $src,
124 $copyright->altText()
125 );
126 }
getSourceFromIRSS(string $string_id)
Definition: Renderer.php:183

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().

+ 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 106 of file Renderer.php.

106 : Icon
107 {
108 return $this->customIcon(
109 (string) $copyright->imageLink(),
110 $copyright->altText()
111 );
112 }

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLink()

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

Definition at line 141 of file Renderer.php.

141 : ?Link
142 {
143 if (
144 !$copyright->link() &&
145 (!$allow_empty_link || $copyright->fullName() === '')
146 ) {
147 return null;
148 }
149 return $this->standardLink(
150 $copyright->fullName() !== '' ? $copyright->fullName() : (string) $copyright->link(),
151 (string) $copyright->link(),
152 $copyright->link() !== null ? Relationship::LICENSE : null,
153 $copyright->link() === null
154 );
155 }
standardLink(string $label, string $action, ?Relationship $relationship, bool $disabled)
Definition: Renderer.php:162

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

Referenced by ILIAS\MetaData\Copyright\Renderer\toLinkOnly(), and ILIAS\MetaData\Copyright\Renderer\toUIComponents().

+ 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 157 of file Renderer.php.

157 : Icon
158 {
159 return $this->factory->symbol()->icon()->custom($src, $alt, Icon::MEDIUM);
160 }

References factory(), and 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFallBackSrc()

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

Definition at line 136 of file Renderer.php.

136 : string
137 {
138 return \ilUtil::getImagePath(self::FALLBACK_IMG);
139 }

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

+ Here is the caller graph for this function:

◆ getSourceFromIRSS()

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

Definition at line 183 of file Renderer.php.

183 : string
184 {
185 if ($identifier = $this->irss->manage()->find($string_id)) {
186 return $this->irss->consume()->src($identifier)->getSrc();
187 }
188 return '';
189 }

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

+ Here is the caller graph for this function:

◆ standardLink()

ILIAS\MetaData\Copyright\Renderer::standardLink ( string  $label,
string  $action,
?Relationship  $relationship,
bool  $disabled 
)
protected

Definition at line 162 of file Renderer.php.

167 : Link {
168 $link = $this->factory->link()->standard($label, $action);
169 if ($relationship !== null) {
170 $link = $link->withAdditionalRelationshipToReferencedResource($relationship);
171 }
172 if ($disabled) {
173 $link = $link->withDisabled();
174 }
175 return $link;
176 }

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

+ Here is the caller graph for this function:

◆ textInLegacy()

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

Definition at line 178 of file Renderer.php.

178 : Content
179 {
180 return $this->factory->legacy()->content($text);
181 }
$text
Definition: xapiexit.php:21

References factory().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toImageOnly()

ILIAS\MetaData\Copyright\Renderer::toImageOnly ( CopyrightDataInterface  $copyright)

Implements ILIAS\MetaData\Copyright\RendererInterface.

Definition at line 65 of file Renderer.php.

65 : ?Icon
66 {
67 return $this->buildIcon($copyright);
68 }
buildIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:91

References ILIAS\MetaData\Copyright\Renderer\buildIcon().

+ Here is the call graph for this function:

◆ toLinkOnly()

ILIAS\MetaData\Copyright\Renderer::toLinkOnly ( CopyrightDataInterface  $copyright)

Returns a string as a disabled link, if only a string can be returned, or null if the copyright is image only.

Implements ILIAS\MetaData\Copyright\RendererInterface.

Definition at line 70 of file Renderer.php.

70 : ?Link
71 {
72 return $this->buildLink($copyright, true);
73 }
buildLink(CopyrightDataInterface $copyright, bool $allow_empty_link)
Definition: Renderer.php:141

References ILIAS\MetaData\Copyright\Renderer\buildLink().

+ Here is the call graph for this function:

◆ toString()

ILIAS\MetaData\Copyright\Renderer::toString ( CopyrightDataInterface  $copyright)

Implements ILIAS\MetaData\Copyright\RendererInterface.

Definition at line 75 of file Renderer.php.

75 : string
76 {
77 $full_name = $copyright->fullName();
78 $link = $copyright->link();
79
80 $res = [];
81 if ($full_name !== '') {
82 $res[] = $full_name;
83 }
84 if ($link !== null) {
85 $res[] = (string) $link;
86 }
87
88 return implode(' ', $res);
89 }
$res
Definition: ltiservices.php:69

References $res, ILIAS\MetaData\Copyright\CopyrightDataInterface\fullName(), and ILIAS\MetaData\Copyright\CopyrightDataInterface\link().

+ Here is the call graph for this function:

◆ toUIComponents()

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

Implements ILIAS\MetaData\Copyright\RendererInterface.

Definition at line 48 of file Renderer.php.

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, false))) {
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 }

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

+ 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 string 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: