ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\XML\Copyright\CopyrightHandler Class Reference
+ Inheritance diagram for ILIAS\MetaData\XML\Copyright\CopyrightHandler:
+ Collaboration diagram for ILIAS\MetaData\XML\Copyright\CopyrightHandler:

Public Member Functions

 __construct (CopyrightRepository $copyright_repository, IdentifierHandler $identifier_handler, SettingsInterface $settings)
 
 copyrightForExport (string $copyright)
 
 copyrightFromExport (string $copyright)
 
 copyrightAsString (string $copyright)
 
 isCopyrightSelectionActive ()
 

Protected Member Functions

 getAllCopyrightEntries ()
 

Protected Attributes

CopyrightRepository $copyright_repository
 
IdentifierHandler $identifier_handler
 
SettingsInterface $settings
 
array $copyright_entries
 

Detailed Description

Definition at line 29 of file CopyrightHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::__construct ( CopyrightRepository  $copyright_repository,
IdentifierHandler  $identifier_handler,
SettingsInterface  $settings 
)

Member Function Documentation

◆ copyrightAsString()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::copyrightAsString ( string  $copyright)

Implements ILIAS\MetaData\XML\Copyright\CopyrightHandlerInterface.

Definition at line 86 of file CopyrightHandler.php.

References ILIAS\MetaData\XML\Copyright\CopyrightHandler\isCopyrightSelectionActive().

Referenced by ILIAS\MetaData\XML\Copyright\CopyrightHandler\copyrightForExport().

86  : string
87  {
88  if (!$this->isCopyrightSelectionActive()) {
89  return $copyright;
90  }
91 
92  if (!$this->identifier_handler->isIdentifierValid($copyright) && $copyright !== '') {
93  return $copyright;
94  }
95 
96  if ($copyright === '') {
97  $entry_data = $this->copyright_repository->getDefaultEntry()->copyrightData();
98  } else {
99  $entry_id = $this->identifier_handler->parseEntryIDFromIdentifier($copyright);
100  $entry_data = $this->copyright_repository->getEntry($entry_id)->copyrightData();
101  }
102  $full_name = $entry_data->fullName();
103  $link = $entry_data->link();
104 
105  if (!is_null($link)) {
106  return (string) $link;
107  }
108  return $full_name;
109  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyrightForExport()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::copyrightForExport ( string  $copyright)

Implements ILIAS\MetaData\XML\Copyright\CopyrightHandlerInterface.

Definition at line 50 of file CopyrightHandler.php.

References ILIAS\MetaData\XML\Copyright\CopyrightHandler\copyrightAsString().

50  : string
51  {
52  return $this->copyrightAsString($copyright);
53  }
+ Here is the call graph for this function:

◆ copyrightFromExport()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::copyrightFromExport ( string  $copyright)

Implements ILIAS\MetaData\XML\Copyright\CopyrightHandlerInterface.

Definition at line 55 of file CopyrightHandler.php.

References ILIAS\MetaData\XML\Copyright\CopyrightHandler\getAllCopyrightEntries(), ILIAS\MetaData\XML\Copyright\CopyrightHandler\isCopyrightSelectionActive(), and null.

55  : string
56  {
57  if (!$this->isCopyrightSelectionActive()) {
58  return $copyright;
59  }
60 
61  // url should be made to match regardless of scheme
62  $normalized_copyright = str_replace('https://', 'http://', $copyright);
63 
64  $matches_by_name = null;
65  foreach ($this->getAllCopyrightEntries() as $entry) {
66  $entry_link = (string) $entry->copyrightData()->link();
67  $normalized_link = str_replace('https://', 'http://', $entry_link);
68  if ($normalized_link !== '' && str_contains($normalized_copyright, $normalized_link)) {
69  return $this->identifier_handler->buildIdentifierFromEntryID($entry->id());
70  }
71 
72  if (
73  is_null($matches_by_name) &&
74  trim($copyright) === trim($entry->copyrightData()->fullName())
75  ) {
76  $matches_by_name = $this->identifier_handler->buildIdentifierFromEntryID($entry->id());
77  }
78  }
79 
80  if (!is_null($matches_by_name)) {
81  return $matches_by_name;
82  }
83  return $copyright;
84  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getAllCopyrightEntries()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::getAllCopyrightEntries ( )
protected
Returns
EntryInterface[]

Definition at line 114 of file CopyrightHandler.php.

References ILIAS\MetaData\XML\Copyright\CopyrightHandler\$copyright_entries, and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

Referenced by ILIAS\MetaData\XML\Copyright\CopyrightHandler\copyrightFromExport().

114  : \Generator
115  {
116  if (!isset($this->copyright_entries)) {
117  $this->copyright_entries = iterator_to_array($this->copyright_repository->getAllEntries());
118  }
120  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCopyrightSelectionActive()

ILIAS\MetaData\XML\Copyright\CopyrightHandler::isCopyrightSelectionActive ( )

Implements ILIAS\MetaData\XML\Copyright\CopyrightHandlerInterface.

Definition at line 122 of file CopyrightHandler.php.

References ILIAS\Repository\settings().

Referenced by ILIAS\MetaData\XML\Copyright\CopyrightHandler\copyrightAsString(), and ILIAS\MetaData\XML\Copyright\CopyrightHandler\copyrightFromExport().

122  : bool
123  {
124  return $this->settings->isCopyrightSelectionActive();
125  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $copyright_entries

array ILIAS\MetaData\XML\Copyright\CopyrightHandler::$copyright_entries
protected

◆ $copyright_repository

CopyrightRepository ILIAS\MetaData\XML\Copyright\CopyrightHandler::$copyright_repository
protected

◆ $identifier_handler

IdentifierHandler ILIAS\MetaData\XML\Copyright\CopyrightHandler::$identifier_handler
protected

◆ $settings

SettingsInterface ILIAS\MetaData\XML\Copyright\CopyrightHandler::$settings
protected

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