ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 
 toString (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 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.

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

40  {
41  $this->factory = $factory;
42  $this->irss = $irss;
43  }
factory()
+ Here is the call graph for this function:

Member Function Documentation

◆ buildFallBackIcon()

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

Definition at line 118 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().

118  : ?Icon
119  {
120  return $this->customIcon(
121  $this->getFallBackSrc(),
122  $copyright->altText()
123  );
124  }
customIcon(string $src, string $alt)
Definition: Renderer.php:142
+ 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 81 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(), ILIAS\MetaData\Copyright\CopyrightDataInterface\isImageLink(), and null.

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

81  : ?Icon
82  {
83  if (!$copyright->hasImage()) {
84  if ($copyright->fallBackToDefaultImage()) {
85  return $this->buildFallBackIcon($copyright);
86  }
87  return null;
88  }
89  if ($copyright->isImageLink()) {
90  return $this->buildIconFromLink($copyright);
91  } else {
92  return $this->buildIconFromFile($copyright);
93  }
94  }
buildFallBackIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:118
buildIconFromLink(CopyrightDataInterface $copyright)
Definition: Renderer.php:96
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildIconFromFile(CopyrightDataInterface $copyright)
Definition: Renderer.php:104
+ 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 104 of file Renderer.php.

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

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

104  : ?Icon
105  {
106  if ($from_irss = $this->getSourceFromIRSS($copyright->imageFile())) {
107  $src = $from_irss;
108  } else {
109  return null;
110  }
111 
112  return $this->customIcon(
113  $src,
114  $copyright->altText()
115  );
116  }
getSourceFromIRSS(string $string_id)
Definition: Renderer.php:157
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
customIcon(string $src, string $alt)
Definition: Renderer.php:142
+ 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 96 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().

96  : Icon
97  {
98  return $this->customIcon(
99  (string) $copyright->imageLink(),
100  $copyright->altText()
101  );
102  }
customIcon(string $src, string $alt)
Definition: Renderer.php:142
+ 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 131 of file Renderer.php.

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

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

131  : ?Link
132  {
133  if (!$copyright->link()) {
134  return null;
135  }
136  return $this->standardLink(
137  $copyright->fullName() !== '' ? $copyright->fullName() : (string) $copyright->link(),
138  (string) $copyright->link()
139  )->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE);
140  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
standardLink(string $label, string $action)
Definition: Renderer.php:147
+ 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 142 of file Renderer.php.

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

142  : Icon
143  {
144  return $this->factory->symbol()->icon()->custom($src, $alt, Icon::MEDIUM);
145  }
factory()
+ 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 126 of file Renderer.php.

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

126  : string
127  {
128  return \ilUtil::getImagePath(self::FALLBACK_IMG);
129  }
+ Here is the caller graph for this function:

◆ getSourceFromIRSS()

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

Definition at line 157 of file Renderer.php.

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

157  : string
158  {
159  if ($identifier = $this->irss->manage()->find($string_id)) {
160  return $this->irss->consume()->src($identifier)->getSrc();
161  }
162  return '';
163  }
+ Here is the caller graph for this function:

◆ standardLink()

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

Definition at line 147 of file Renderer.php.

References factory().

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

147  : Link
148  {
149  return $this->factory->link()->standard($label, $action);
150  }
factory()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textInLegacy()

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

Definition at line 152 of file Renderer.php.

References factory().

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

152  : Content
153  {
154  return $this->factory->legacy()->content($text);
155  }
factory()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

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

Implements ILIAS\MetaData\Copyright\RendererInterface.

Definition at line 65 of file Renderer.php.

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

65  : string
66  {
67  $full_name = $copyright->fullName();
68  $link = $copyright->link();
69 
70  $res = [];
71  if ($full_name !== '') {
72  $res[] = $full_name;
73  }
74  if ($link !== null) {
75  $res[] = (string) $link;
76  }
77 
78  return implode(' ', $res);
79  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

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:66
buildIcon(CopyrightDataInterface $copyright)
Definition: Renderer.php:81
buildLink(CopyrightDataInterface $copyright)
Definition: Renderer.php:131
+ 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: