ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper Class Reference
+ Inheritance diagram for ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper:
+ Collaboration diagram for ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper:

Public Member Functions

 __construct (SettingsInterface $settings, PathFactory $path_factory, CopyrightRepository $copyright_repo, IdentifierHandler $identifier_handler, RendererInterface $renderer, SearchClauseFactory $search_clause_factory)
 
 isCopyrightSelectionActive ()
 If copyright selection is not active, there are no copyright presets to choose from, but copyright information can still be added manually to the LOM of objects. More...
 
 hasPresetCopyright (ReaderInterface $reader)
 Is the copyright in the LOM of the reader's object selected from the presets? If not, custom copyright information was entered manually. More...
 
 readPresetCopyright (ReaderInterface $reader)
 If possible, returns the preset copyright selected for the reader's object. More...
 
 readCustomCopyright (ReaderInterface $reader)
 Returns the custom copyright information from the LOM of the reader's object. More...
 
 prepareCreateOrUpdateOfCopyrightFromPreset (ManipulatorInterface $manipulator, string $copyright_id)
 The preset copyright with the given identifier is set to be selected for the manipulator's object. More...
 
 prepareCreateOrUpdateOfCustomCopyright (ManipulatorInterface $manipulator, string $custom_copyright)
 The given copyright information is set to be written to the LOM of the manipulator's object. More...
 
 getCopyrightPreset (string $copyright_id)
 Returns the preset copyright entry with the given identifier, or a null object if copyright selection is not active (or if the identifier does not exist). More...
 
 getAllCopyrightPresets ()
 
 getNonOutdatedCopyrightPresets ()
 
 getCopyrightSearchClause (string $first_copyright_id, string ... $further_copyright_ids)
 Get a search clause that finds object with one of the given copyright entries in their LOM, to be used in {. More...
 
 isCopyrightSelectionActive ()
 If copyright selection is not active, there are no copyright presets to choose from, but copyright information can still be added manually to the LOM of objects. More...
 
 hasPresetCopyright (ReaderInterface $reader)
 Is the copyright in the LOM of the reader's object selected from the presets? If not, custom copyright information was entered manually. More...
 
 readPresetCopyright (ReaderInterface $reader)
 If possible, returns the preset copyright selected for the reader's object. More...
 
 readCustomCopyright (ReaderInterface $reader)
 Returns the custom copyright information from the LOM of the reader's object. More...
 
 prepareCreateOrUpdateOfCopyrightFromPreset (ManipulatorInterface $manipulator, string $copyright_id)
 The preset copyright with the given identifier is set to be selected for the manipulator's object. More...
 
 prepareCreateOrUpdateOfCustomCopyright (ManipulatorInterface $manipulator, string $custom_copyright)
 The given copyright information is set to be written to the LOM of the manipulator's object. More...
 
 getCopyrightPreset (string $copyright_id)
 Returns the preset copyright entry with the given identifier, or a null object if copyright selection is not active (or if the identifier does not exist). More...
 
 getAllCopyrightPresets ()
 Returns all preset copyright entries, or nothing if copyright selection is not active. More...
 
 getNonOutdatedCopyrightPresets ()
 Returns all preset copyright entries that are not marked as outdated, or nothing if copyright selection is not active. More...
 
 getCopyrightSearchClause (string $first_copyright_id, string ... $further_copyright_ids)
 Get a search clause that finds object with one of the given copyright entries in their LOM, to be used in {. More...
 

Protected Member Functions

 prepareCreateOrUpdateOfCopyright (ManipulatorInterface $manipulator, string $value)
 
 getRawCopyright (ReaderInterface $reader)
 
 getCopyrightDescriptionPath ()
 
 getCopyrightEntryWrapper (EntryInterface $entry)
 
 getNullCopyrightEntryWrapper ()
 

Protected Attributes

SettingsInterface $settings
 
PathFactory $path_factory
 
IdentifierHandler $identifier_handler
 
CopyrightRepository $copyright_repo
 
RendererInterface $renderer
 
SearchClauseFactory $search_clause_factory
 

Detailed Description

Definition at line 37 of file CopyrightHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::__construct ( SettingsInterface  $settings,
PathFactory  $path_factory,
CopyrightRepository  $copyright_repo,
IdentifierHandler  $identifier_handler,
RendererInterface  $renderer,
SearchClauseFactory  $search_clause_factory 
)

Definition at line 46 of file CopyrightHelper.php.

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$copyright_repo, ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$identifier_handler, ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$path_factory, ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$renderer, ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$search_clause_factory, ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\$settings, renderer(), and ILIAS\Repository\settings().

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getClauseFactory(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getCopyrightEntry(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getCopyrightHelper(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getPathFactory(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getReader(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getSettings().

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

Member Function Documentation

◆ getAllCopyrightPresets()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getAllCopyrightPresets ( )
Returns
CopyrightInterface[]

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 141 of file CopyrightHelper.php.

141 : \Generator
142 {
143 if (!$this->isCopyrightSelectionActive()) {
144 return;
145 }
146
147 foreach ($this->copyright_repo->getAllEntries() as $entry) {
148 yield $this->getCopyrightEntryWrapper($entry);
149 }
150 }
isCopyrightSelectionActive()
If copyright selection is not active, there are no copyright presets to choose from,...

◆ getCopyrightDescriptionPath()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getCopyrightDescriptionPath ( )
protected

Definition at line 219 of file CopyrightHelper.php.

219 : PathInterface
220 {
221 return $this->path_factory->custom()
222 ->withNextStep('rights')
223 ->withNextStep('description')
224 ->withNextStep('string')
225 ->get();
226 }

◆ getCopyrightEntryWrapper()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getCopyrightEntryWrapper ( EntryInterface  $entry)
protected

Definition at line 228 of file CopyrightHelper.php.

228 : CopyrightInterface
229 {
230 return new Copyright(
231 $this->renderer,
232 $this->identifier_handler,
233 $entry
234 );
235 }

References renderer().

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

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

◆ getCopyrightPreset()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getCopyrightPreset ( string  $copyright_id)

Returns the preset copyright entry with the given identifier, or a null object if copyright selection is not active (or if the identifier does not exist).

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 130 of file CopyrightHelper.php.

130 : CopyrightInterface
131 {
132 $entry = $this->copyright_repo->getEntry(
133 $this->identifier_handler->parseEntryIDFromIdentifier($copyright_id)
134 );
135 return $this->getCopyrightEntryWrapper($entry);
136 }

◆ getCopyrightSearchClause()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getCopyrightSearchClause ( string  $first_copyright_id,
string ...  $further_copyright_ids 
)

Get a search clause that finds object with one of the given copyright entries in their LOM, to be used in {.

See also
\ILIAS\MetaData\Services\Search\SearcherInterface::execute()}.

If copyright selection is active, objects without any copyright information are treated as if they had the default copyright.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 166 of file CopyrightHelper.php.

169 : SearchClause {
170 $selection_active = $this->isCopyrightSelectionActive();
171 $default_entry_id = 0;
172 if ($selection_active) {
173 $default_entry_id = $this->copyright_repo->getDefaultEntry()->id();
174 }
175
176 $copyright_search_clauses = [];
177 foreach ([$first_copyright_id, ...$further_copyright_ids] as $copyright_id) {
178 $copyright_search_clauses[] = $this->search_clause_factory->getBasicClause(
180 Mode::EQUALS,
181 $copyright_id
182 );
183
184 if (
185 !$selection_active ||
186 !$this->identifier_handler->isIdentifierValid($copyright_id) ||
187 $this->identifier_handler->parseEntryIDFromIdentifier($copyright_id) !== $default_entry_id
188 ) {
189 continue;
190 }
191 $copyright_search_clauses[] = $this->search_clause_factory->getBasicClause(
193 Mode::EQUALS,
194 ''
195 );
196 }
197
198 return $this->search_clause_factory->getJoinedClauses(
200 ...$copyright_search_clauses
201 );
202 }

◆ getNonOutdatedCopyrightPresets()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getNonOutdatedCopyrightPresets ( )
Returns
CopyrightInterface[]

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 155 of file CopyrightHelper.php.

155 : \Generator
156 {
157 if (!$this->isCopyrightSelectionActive()) {
158 return;
159 }
160
161 foreach ($this->copyright_repo->getActiveEntries() as $entry) {
162 yield $this->getCopyrightEntryWrapper($entry);
163 }
164 }

◆ getNullCopyrightEntryWrapper()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getNullCopyrightEntryWrapper ( )
protected

Definition at line 237 of file CopyrightHelper.php.

237 : CopyrightInterface
238 {
239 return new NullCopyright();
240 }

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

+ Here is the caller graph for this function:

◆ getRawCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::getRawCopyright ( ReaderInterface  $reader)
protected

Definition at line 214 of file CopyrightHelper.php.

214 : string
215 {
216 return $reader->firstData($this->getCopyrightDescriptionPath())->value();
217 }
firstData(PathInterface $path)
Get the data of the first of the elements specified by the path.

References ILIAS\MetaData\Services\Reader\ReaderInterface\firstData().

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\hasPresetCopyright(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readCustomCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

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

◆ hasPresetCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::hasPresetCopyright ( ReaderInterface  $reader)

Is the copyright in the LOM of the reader's object selected from the presets? If not, custom copyright information was entered manually.

If no copyright is assigned to the object, it is treated like it has the default copyright licence, and true is returned here.

Always returns false if copyright selection is not active.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 67 of file CopyrightHelper.php.

67 : bool
68 {
69 if (!$this->isCopyrightSelectionActive()) {
70 return false;
71 }
72 $raw = $this->getRawCopyright($reader);
73
74 if ($raw === '') {
75 return true;
76 }
77
78 return $this->identifier_handler->isIdentifierValid($this->getRawCopyright($reader));
79 }

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getRawCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\isCopyrightSelectionActive().

+ Here is the call graph for this function:

◆ isCopyrightSelectionActive()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::isCopyrightSelectionActive ( )

If copyright selection is not active, there are no copyright presets to choose from, but copyright information can still be added manually to the LOM of objects.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 62 of file CopyrightHelper.php.

62 : bool
63 {
64 return $this->settings->isCopyrightSelectionActive();
65 }

References ILIAS\Repository\settings().

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getSettings(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\hasPresetCopyright(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readCustomCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

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

◆ prepareCreateOrUpdateOfCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::prepareCreateOrUpdateOfCopyright ( ManipulatorInterface  $manipulator,
string  $value 
)
protected

Definition at line 204 of file CopyrightHelper.php.

208 return $manipulator->prepareCreateOrUpdate(
210 $value
211 );
212 }
prepareCreateOrUpdate(PathInterface $path, string ... $values)
The values are set to be inserted into the elements specified by the path in order.

◆ prepareCreateOrUpdateOfCopyrightFromPreset()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::prepareCreateOrUpdateOfCopyrightFromPreset ( ManipulatorInterface  $manipulator,
string  $copyright_id 
)

The preset copyright with the given identifier is set to be selected for the manipulator's object.

Note that this will also overwrite custom copyright information.

Call {

See also
\ILIAS\MetaData\Services\Manipulator\ManipulatorInterface::execute()} to carry out the changes.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 116 of file CopyrightHelper.php.

120 return $this->prepareCreateOrUpdateOfCopyright($manipulator, $copyright_id);
121 }
prepareCreateOrUpdateOfCopyright(ManipulatorInterface $manipulator, string $value)

◆ prepareCreateOrUpdateOfCustomCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::prepareCreateOrUpdateOfCustomCopyright ( ManipulatorInterface  $manipulator,
string  $custom_copyright 
)

The given copyright information is set to be written to the LOM of the manipulator's object.

Note that this will also overwrite any selected preset copyright.

Call {

See also
\ILIAS\MetaData\Services\Manipulator\ManipulatorInterface::execute()} to carry out the changes.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 123 of file CopyrightHelper.php.

127 return $this->prepareCreateOrUpdateOfCopyright($manipulator, $custom_copyright);
128 }

◆ readCustomCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::readCustomCopyright ( ReaderInterface  $reader)

Returns the custom copyright information from the LOM of the reader's object.

If copyright selection is inactive, or one of the preset copyright options was selected for the object, this returns an empty string.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 103 of file CopyrightHelper.php.

103 : string
104 {
105 $copyright = $this->getRawCopyright($reader);
106
107 if (
108 !$this->isCopyrightSelectionActive() ||
109 $this->identifier_handler->isIdentifierValid($copyright)
110 ) {
111 return '';
112 }
113 return $copyright;
114 }

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getRawCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\isCopyrightSelectionActive().

+ Here is the call graph for this function:

◆ readPresetCopyright()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::readPresetCopyright ( ReaderInterface  $reader)

If possible, returns the preset copyright selected for the reader's object.

For objects which have no copyright information in their LOM, the default copyright is returned (as long as copyright selection is active).

Returns a null object if copyright selection is not active, or if the object has custom copyright information.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 81 of file CopyrightHelper.php.

81 : CopyrightInterface
82 {
83 if (!$this->isCopyrightSelectionActive()) {
84 return $this->getNullCopyrightEntryWrapper();
85 }
86 $raw = $this->getRawCopyright($reader);
87
88 $entry = null;
89 if ($this->identifier_handler->isIdentifierValid($raw)) {
90 $entry = $this->copyright_repo->getEntry(
91 $this->identifier_handler->parseEntryIDFromIdentifier($raw)
92 );
93 } elseif ($raw === '') {
94 $entry = $this->copyright_repo->getDefaultEntry();
95 }
96
97 if (is_null($entry)) {
98 return $this->getNullCopyrightEntryWrapper();
99 }
100 return $this->getCopyrightEntryWrapper($entry);
101 }

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getCopyrightEntryWrapper(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getNullCopyrightEntryWrapper(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getRawCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\isCopyrightSelectionActive().

+ Here is the call graph for this function:

Field Documentation

◆ $copyright_repo

CopyrightRepository ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$copyright_repo
protected

◆ $identifier_handler

IdentifierHandler ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$identifier_handler
protected

◆ $path_factory

PathFactory ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$path_factory
protected

◆ $renderer

RendererInterface ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$renderer
protected

◆ $search_clause_factory

SearchClauseFactory ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$search_clause_factory
protected

◆ $settings

SettingsInterface ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper::$settings
protected

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