ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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...
 
 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...
 
 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(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest\getRenderer(), 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 133 of file CopyrightHelper.php.

133 : \Generator
134 {
135 if (!$this->isCopyrightSelectionActive()) {
136 return;
137 }
138
139 foreach ($this->copyright_repo->getAllEntries() as $entry) {
140 yield $this->getCopyrightEntryWrapper($entry);
141 }
142 }
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 211 of file CopyrightHelper.php.

211 : PathInterface
212 {
213 return $this->path_factory->custom()
214 ->withNextStep('rights')
215 ->withNextStep('description')
216 ->withNextStep('string')
217 ->get();
218 }

◆ getCopyrightEntryWrapper()

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

Definition at line 220 of file CopyrightHelper.php.

220 : CopyrightInterface
221 {
222 return new Copyright(
223 $this->renderer,
224 $this->identifier_handler,
225 $entry
226 );
227 }

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:

◆ 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 158 of file CopyrightHelper.php.

161 : SearchClause {
162 $selection_active = $this->isCopyrightSelectionActive();
163 $default_entry_id = 0;
164 if ($selection_active) {
165 $default_entry_id = $this->copyright_repo->getDefaultEntry()->id();
166 }
167
168 $copyright_search_clauses = [];
169 foreach ([$first_copyright_id, ...$further_copyright_ids] as $copyright_id) {
170 $copyright_search_clauses[] = $this->search_clause_factory->getBasicClause(
172 Mode::EQUALS,
173 $copyright_id
174 );
175
176 if (
177 !$selection_active ||
178 !$this->identifier_handler->isIdentifierValid($copyright_id) ||
179 $this->identifier_handler->parseEntryIDFromIdentifier($copyright_id) !== $default_entry_id
180 ) {
181 continue;
182 }
183 $copyright_search_clauses[] = $this->search_clause_factory->getBasicClause(
185 Mode::EQUALS,
186 ''
187 );
188 }
189
190 return $this->search_clause_factory->getJoinedClauses(
192 ...$copyright_search_clauses
193 );
194 }

◆ getNonOutdatedCopyrightPresets()

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

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 147 of file CopyrightHelper.php.

147 : \Generator
148 {
149 if (!$this->isCopyrightSelectionActive()) {
150 return;
151 }
152
153 foreach ($this->copyright_repo->getActiveEntries() as $entry) {
154 yield $this->getCopyrightEntryWrapper($entry);
155 }
156 }

◆ getNullCopyrightEntryWrapper()

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

Definition at line 229 of file CopyrightHelper.php.

229 : CopyrightInterface
230 {
231 return new NullCopyright();
232 }

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 206 of file CopyrightHelper.php.

206 : string
207 {
208 return $reader->firstData($this->getCopyrightDescriptionPath())->value();
209 }
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 196 of file CopyrightHelper.php.

200 return $manipulator->prepareCreateOrUpdate(
202 $value
203 );
204 }
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: