ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 

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\getCopyrightRepository(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest\getEntry(), 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().

53  {
54  $this->settings = $settings;
55  $this->path_factory = $path_factory;
56  $this->copyright_repo = $copyright_repo;
57  $this->identifier_handler = $identifier_handler;
58  $this->renderer = $renderer;
59  $this->search_clause_factory = $search_clause_factory;
60  }
renderer()
+ 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.

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

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, but copyright information can still be added manually to the LOM of objects.
+ Here is the call graph for this function:

◆ getCopyrightDescriptionPath()

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

Definition at line 211 of file CopyrightHelper.php.

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getCopyrightSearchClause(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getRawCopyright(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\prepareCreateOrUpdateOfCopyright().

211  : PathInterface
212  {
213  return $this->path_factory->custom()
214  ->withNextStep('rights')
215  ->withNextStep('description')
216  ->withNextStep('string')
217  ->get();
218  }
+ Here is the caller graph for this function:

◆ getCopyrightEntryWrapper()

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

Definition at line 220 of file CopyrightHelper.php.

References renderer().

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getAllCopyrightPresets(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getCopyrightHelper(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getNonOutdatedCopyrightPresets(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

220  : CopyrightInterface
221  {
222  return new Copyright(
223  $this->renderer,
224  $this->identifier_handler,
225  $entry
226  );
227  }
renderer()
+ 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
::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.

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\getCopyrightDescriptionPath(), ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\isCopyrightSelectionActive(), and ILIAS\MetaData\Search\Clauses\OR.

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(
191  Operator::OR,
192  ...$copyright_search_clauses
193  );
194  }
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.
+ Here is the call graph for this function:

◆ getNonOutdatedCopyrightPresets()

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

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 147 of file CopyrightHelper.php.

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

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  }
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.
+ Here is the call graph for this function:

◆ getNullCopyrightEntryWrapper()

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

Definition at line 229 of file CopyrightHelper.php.

Referenced by ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperTest\getCopyrightHelper(), and ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\readPresetCopyright().

229  : CopyrightInterface
230  {
231  return new NullCopyright();
232  }
+ Here is the caller graph for this function:

◆ getRawCopyright()

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

◆ 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.

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

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  }
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.
+ Here is the call graph for this function:

◆ isCopyrightSelectionActive()

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

◆ prepareCreateOrUpdateOfCopyright()

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

◆ 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
::execute()} to carry out the changes.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 116 of file CopyrightHelper.php.

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\prepareCreateOrUpdateOfCopyright().

119  : ManipulatorInterface {
120  return $this->prepareCreateOrUpdateOfCopyright($manipulator, $copyright_id);
121  }
prepareCreateOrUpdateOfCopyright(ManipulatorInterface $manipulator, string $value)
+ Here is the call graph for this function:

◆ 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
::execute()} to carry out the changes.

Implements ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelperInterface.

Definition at line 123 of file CopyrightHelper.php.

References ILIAS\MetaData\Services\CopyrightHelper\CopyrightHelper\prepareCreateOrUpdateOfCopyright().

126  : ManipulatorInterface {
127  return $this->prepareCreateOrUpdateOfCopyright($manipulator, $custom_copyright);
128  }
prepareCreateOrUpdateOfCopyright(ManipulatorInterface $manipulator, string $value)
+ Here is the call graph for this function:

◆ 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.

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

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  }
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.
+ 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.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
+ 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: