ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMDCopyrightSelectionEntry Class Reference
+ Collaboration diagram for ilMDCopyrightSelectionEntry:

Public Member Functions

 __construct (int $a_entry_id)
 
 getUsage ()
 
 getEntryId ()
 
 getIsDefault ()
 Get if the entry is default No setter for this. More...
 
 setOutdated (bool $a_value)
 
 getOutdated ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setDescription (string $a_desc)
 
 getDescription ()
 
 setCopyright (string $a_copyright)
 
 getCopyright ()
 
 setOrderPosition (int $a_position)
 
 getOrderPosition ()
 
 add ()
 
 update ()
 
 delete ()
 
 validate ()
 

Static Public Member Functions

static _getEntries ()
 
static lookupCopyyrightTitle (string $a_cp_string)
 
static _lookupCopyright (string $a_cp_string)
 
static _lookupCopyrightForExport (string $a_cp_string)
 
static lookupCopyrightFromImport (string $copyright_text)
 
static _extractEntryId (string $a_cp_string)
 
static isEntry ($a_cp_string)
 
static getDefault ()
 
static createIdentifier (int $a_entry_id)
 

Protected Member Functions

 getNextOrderPosition ()
 

Protected Attributes

ilLogger $logger
 
ilDBInterface $db
 
RendererInterface $renderer
 
RepositoryInterface $repository
 
UIRenderer $ui_renderer
 
bool $outdated = false
 
int $order_position = 0
 

Private Member Functions

 read ()
 

Private Attributes

int $entry_id
 
string $title = ''
 
string $description = ''
 
string $copyright = ''
 
int $usage = null
 

Detailed Description

Deprecated:
use ILIAS/MetaData/Copyright/DatabaseRepository
Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 32 of file class.ilMDCopyrightSelectionEntry.php.

Constructor & Destructor Documentation

◆ __construct()

ilMDCopyrightSelectionEntry::__construct ( int  $a_entry_id)

Definition at line 51 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, ILIAS\Repository\logger(), read(), and ILIAS\UI\examples\Deck\repository().

52  {
53  global $DIC;
54 
55  $this->renderer = new Renderer(
56  $DIC->ui()->factory(),
57  $DIC->resourceStorage()
58  );
59  $this->repository = new DatabaseRepository($DIC->database());
60  $this->ui_renderer = $DIC->ui()->renderer();
61  $this->logger = $DIC->logger()->meta();
62  $this->db = $DIC->database();
63  $this->entry_id = $a_entry_id;
64  $this->read();
65  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ _extractEntryId()

static ilMDCopyrightSelectionEntry::_extractEntryId ( string  $a_cp_string)
static

Definition at line 170 of file class.ilMDCopyrightSelectionEntry.php.

References IL_INST_ID.

Referenced by ilMDKeywordExposer\getContentModification(), and ilFileVersionsGUI\getFileZipOptionsForm().

170  : int
171  {
172  if (!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/', $a_cp_string, $matches)) {
173  return 0;
174  }
175  if ($matches[1] != IL_INST_ID) {
176  return 0;
177  }
178  return (int) ($matches[2] ?? 0);
179  }
const IL_INST_ID
Definition: constants.php:40
+ Here is the caller graph for this function:

◆ _getEntries()

static ilMDCopyrightSelectionEntry::_getEntries ( )
static
Returns
ilMDCopyrightSelectionEntry[]

Definition at line 70 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, $ilDB, and $res.

Referenced by ilCronOerHarvester\addCustomSettingsToForm(), ilContainerFilterUtil\getContainerRecordTitle(), and ilMDCopyrightTableGUI\parseSelections().

70  : array
71  {
72  global $DIC;
73 
74  $ilDB = $DIC->database();
75 
76  $query = "SELECT entry_id FROM il_md_cpr_selections ORDER BY is_default DESC, position ASC";
77  $res = $ilDB->query($query);
78 
79  $entries = [];
80  while ($row = $ilDB->fetchObject($res)) {
81  $entries[] = new ilMDCopyrightSelectionEntry((int) $row->entry_id);
82  }
83  return $entries;
84  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookupCopyright()

static ilMDCopyrightSelectionEntry::_lookupCopyright ( string  $a_cp_string)
static

Definition at line 103 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, and ILIAS\MetaData\Copyright\RendererInterface\toUIComponents().

Referenced by ilMDUtils\_parseCopyright().

103  : string
104  {
105  global $DIC;
106 
107  $renderer = new Renderer(
108  $DIC->ui()->factory(),
109  $DIC->resourceStorage()
110  );
111  $repository = new DatabaseRepository($DIC->database());
112  $ui_renderer = $DIC->ui()->renderer();
113 
114  if (!$entry_id = self::_extractEntryId($a_cp_string)) {
115  return $a_cp_string;
116  }
117 
118  $entry = $repository->getEntry($entry_id);
119  $components = $renderer->toUIComponents($entry->copyrightData());
120 
121  return $ui_renderer->render($components);
122  }
toUIComponents(CopyrightData $copyright)
Returns a string in a legacy UI component if only a string can be returned.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupCopyrightForExport()

static ilMDCopyrightSelectionEntry::_lookupCopyrightForExport ( string  $a_cp_string)
static

Definition at line 124 of file class.ilMDCopyrightSelectionEntry.php.

References $data, $DIC, and ILIAS\MetaData\Copyright\RepositoryInterface\getEntry().

Referenced by ilMDRights\toXML().

124  : string
125  {
126  global $DIC;
127 
128  $repository = new DatabaseRepository($DIC->database());
129 
130  if (!$entry_id = self::_extractEntryId($a_cp_string)) {
131  return $a_cp_string;
132  }
133 
134  $data = $repository->getEntry($entry_id)->copyrightData();
135 
136  return (string) ($data->link() ?? $data->fullName());
137  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilMDCopyrightSelectionEntry::add ( )

Definition at line 301 of file class.ilMDCopyrightSelectionEntry.php.

References getDescription(), getNextOrderPosition(), getOutdated(), and getTitle().

301  : bool
302  {
303  $next_id = $this->db->nextId('il_md_cpr_selections');
304 
305  $this->db->insert('il_md_cpr_selections', array(
306  'entry_id' => array('integer', $next_id),
307  'title' => array('text', $this->getTitle()),
308  'description' => array('clob', $this->getDescription()),
309  //'copyright' => array('clob', $this->getCopyright()),
310  'outdated' => array('integer', $this->getOutdated()),
311  'position' => array('integer', $this->getNextOrderPosition())
312  ));
313  $this->entry_id = $next_id;
314  return true;
315  }
+ Here is the call graph for this function:

◆ createIdentifier()

static ilMDCopyrightSelectionEntry::createIdentifier ( int  $a_entry_id)
static

Definition at line 358 of file class.ilMDCopyrightSelectionEntry.php.

References IL_INST_ID.

Referenced by ilMDUtils\_getDefaultCopyright(), ILIAS\Container\Content\Filter\MetadataDBRepo\filterObjIdsByCopyright(), and ilMDRights\parseDescriptionFromImport().

358  : string
359  {
360  return 'il_copyright_entry__' . IL_INST_ID . '__' . $a_entry_id;
361  }
const IL_INST_ID
Definition: constants.php:40
+ Here is the caller graph for this function:

◆ delete()

ilMDCopyrightSelectionEntry::delete ( )

Definition at line 331 of file class.ilMDCopyrightSelectionEntry.php.

331  : void
332  {
333  /*$query = "DELETE FROM il_md_cpr_selections " .
334  "WHERE entry_id = " . $this->db->quote($this->getEntryId(), 'integer') . " ";
335  $res = $this->db->manipulate($query);*/
336  }

◆ getCopyright()

ilMDCopyrightSelectionEntry::getCopyright ( )

Definition at line 277 of file class.ilMDCopyrightSelectionEntry.php.

References $copyright.

277  : string
278  {
279  return $this->copyright;
280  }

◆ getDefault()

static ilMDCopyrightSelectionEntry::getDefault ( )
static

Definition at line 237 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, $res, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilMDUtils\_getDefaultCopyright(), ILIAS\Container\Content\Filter\MetadataDBRepo\filterObjIdsByCopyright(), and ilMDKeywordExposer\getContentModification().

237  : int
238  {
239  global $DIC;
240 
241  $db = $DIC->database();
242 
243  $query = "SELECT entry_id FROM il_md_cpr_selections " .
244  "WHERE is_default = " . $db->quote(1, 'integer');
245 
246  $res = $db->query($query);
247  $row = $db->fetchAssoc($res);
248 
249  return (int) $row['entry_id'];
250  }
$res
Definition: ltiservices.php:69
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilMDCopyrightSelectionEntry::getDescription ( )

Definition at line 267 of file class.ilMDCopyrightSelectionEntry.php.

References $description.

Referenced by add(), and update().

267  : string
268  {
269  return $this->description;
270  }
+ Here is the caller graph for this function:

◆ getEntryId()

ilMDCopyrightSelectionEntry::getEntryId ( )

Definition at line 207 of file class.ilMDCopyrightSelectionEntry.php.

References $entry_id.

Referenced by getUsage(), and update().

207  : int
208  {
209  return $this->entry_id;
210  }
+ Here is the caller graph for this function:

◆ getIsDefault()

ilMDCopyrightSelectionEntry::getIsDefault ( )

Get if the entry is default No setter for this.

Definition at line 216 of file class.ilMDCopyrightSelectionEntry.php.

References $res.

216  : bool
217  {
218  $query = "SELECT is_default FROM il_md_cpr_selections " .
219  "WHERE entry_id = " . $this->db->quote($this->entry_id, 'integer');
220 
221  $res = $this->db->query($query);
222  $row = $this->db->fetchAssoc($res);
223 
224  return (bool) ($row['is_default'] ?? false);
225  }
$res
Definition: ltiservices.php:69

◆ getNextOrderPosition()

ilMDCopyrightSelectionEntry::getNextOrderPosition ( )
protected

Definition at line 292 of file class.ilMDCopyrightSelectionEntry.php.

References $res.

Referenced by add().

292  : int
293  {
294  $query = "SELECT count(entry_id) total FROM il_md_cpr_selections";
295  $res = $this->db->query($query);
296  $row = $this->db->fetchAssoc($res);
297 
298  return $row['total'] + 1;
299  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getOrderPosition()

ilMDCopyrightSelectionEntry::getOrderPosition ( )

Definition at line 287 of file class.ilMDCopyrightSelectionEntry.php.

References $order_position.

Referenced by update().

287  : int
288  {
289  return $this->order_position;
290  }
+ Here is the caller graph for this function:

◆ getOutdated()

ilMDCopyrightSelectionEntry::getOutdated ( )

Definition at line 232 of file class.ilMDCopyrightSelectionEntry.php.

References $outdated.

Referenced by add(), and update().

232  : bool
233  {
234  return $this->outdated;
235  }
+ Here is the caller graph for this function:

◆ getTitle()

ilMDCopyrightSelectionEntry::getTitle ( )

Definition at line 257 of file class.ilMDCopyrightSelectionEntry.php.

References $title.

Referenced by add(), update(), and validate().

257  : string
258  {
259  return $this->title;
260  }
+ Here is the caller graph for this function:

◆ getUsage()

ilMDCopyrightSelectionEntry::getUsage ( )

Definition at line 189 of file class.ilMDCopyrightSelectionEntry.php.

References $res, $usage, getEntryId(), IL_INST_ID, and ILIAS\Repository\int().

189  : int
190  {
191  // do a time-consuming usage count on demand
192  if ($this->usage === null) {
193  $query = "SELECT count(meta_rights_id) used FROM il_meta_rights " .
194  "WHERE description = " . $this->db->quote(
195  'il_copyright_entry__' . IL_INST_ID . '__' . $this->getEntryId(),
196  'text'
197  );
198 
199  $res = $this->db->query($query);
200  $row = $this->db->fetchObject($res);
201  $this->usage = (int) $row->used;
202  }
203 
204  return $this->usage;
205  }
$res
Definition: ltiservices.php:69
const IL_INST_ID
Definition: constants.php:40
+ Here is the call graph for this function:

◆ isEntry()

static ilMDCopyrightSelectionEntry::isEntry (   $a_cp_string)
static

Definition at line 181 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by ilMDUtils\_parseCopyright().

181  : bool
182  {
183  if (!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/', $a_cp_string)) {
184  return false;
185  }
186  return true;
187  }
+ Here is the caller graph for this function:

◆ lookupCopyrightFromImport()

static ilMDCopyrightSelectionEntry::lookupCopyrightFromImport ( string  $copyright_text)
static

Definition at line 139 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, and ILIAS\MetaData\Copyright\RepositoryInterface\getAllEntries().

Referenced by ilMDRights\parseDescriptionFromImport().

139  : int
140  {
141  global $DIC;
142 
143  $repository = new DatabaseRepository($DIC->database());
144 
145  // url should be made to match regardless of scheme
146  $normalized_copyright = str_replace('https://', 'http://', $copyright_text);
147 
148  $matches_by_name = null;
149  foreach ($repository->getAllEntries() as $entry) {
150  $entry_link = (string) $entry->copyrightData()->link();
151  $normalized_link = str_replace('https://', 'http://', $entry_link);
152  if ($normalized_link !== '' && str_contains($normalized_copyright, $normalized_link)) {
153  return $entry->id();
154  }
155 
156  if (
157  is_null($matches_by_name) &&
158  trim($copyright_text) === trim($entry->copyrightData()->fullName())
159  ) {
160  $matches_by_name = $entry->id();
161  }
162  }
163 
164  if (!is_null($matches_by_name)) {
165  return $matches_by_name;
166  }
167  return 0;
168  }
getAllEntries()
The default entry is returned first, and the remaining entries are returned according to their positi...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupCopyyrightTitle()

static ilMDCopyrightSelectionEntry::lookupCopyyrightTitle ( string  $a_cp_string)
static

Definition at line 86 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, $ilDB, $res, and ilDBConstants\T_INTEGER.

Referenced by ilFileVersionsGUI\getFileZipOptionsForm().

86  : string
87  {
88  global $DIC;
89 
90  $ilDB = $DIC->database();
91 
92  if (!$entry_id = self::_extractEntryId($a_cp_string)) {
93  return $a_cp_string;
94  }
95 
96  $query = "SELECT title FROM il_md_cpr_selections " .
97  "WHERE entry_id = " . $ilDB->quote($entry_id, ilDBConstants::T_INTEGER) . " ";
98  $res = $ilDB->query($query);
99  $row = $ilDB->fetchObject($res);
100  return $row->title ?? '';
101  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ read()

ilMDCopyrightSelectionEntry::read ( )
private

Definition at line 343 of file class.ilMDCopyrightSelectionEntry.php.

References ILIAS\UI\examples\Deck\repository(), setCopyright(), setDescription(), setOrderPosition(), setOutdated(), and setTitle().

Referenced by __construct().

343  : void
344  {
345  $entry = $this->repository->getEntry($this->entry_id);
346 
347  $rendered_cp = $this->ui_renderer->render(
348  $this->renderer->toUIComponents($entry->copyrightData())
349  );
350 
351  $this->setTitle($entry->title());
352  $this->setDescription($entry->description());
353  $this->setCopyright($rendered_cp);
354  $this->setOutdated($entry->isOutdated());
355  $this->setOrderPosition($entry->position());
356  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCopyright()

ilMDCopyrightSelectionEntry::setCopyright ( string  $a_copyright)

Definition at line 272 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

272  : void
273  {
274  $this->copyright = $a_copyright;
275  }
+ Here is the caller graph for this function:

◆ setDescription()

ilMDCopyrightSelectionEntry::setDescription ( string  $a_desc)

Definition at line 262 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

262  : void
263  {
264  $this->description = $a_desc;
265  }
+ Here is the caller graph for this function:

◆ setOrderPosition()

ilMDCopyrightSelectionEntry::setOrderPosition ( int  $a_position)

Definition at line 282 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

282  : void
283  {
284  $this->order_position = $a_position;
285  }
+ Here is the caller graph for this function:

◆ setOutdated()

ilMDCopyrightSelectionEntry::setOutdated ( bool  $a_value)

Definition at line 227 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

227  : void
228  {
229  $this->outdated = $a_value;
230  }
+ Here is the caller graph for this function:

◆ setTitle()

ilMDCopyrightSelectionEntry::setTitle ( string  $a_title)

Definition at line 252 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

252  : void
253  {
254  $this->title = $a_title;
255  }
+ Here is the caller graph for this function:

◆ update()

ilMDCopyrightSelectionEntry::update ( )

Definition at line 317 of file class.ilMDCopyrightSelectionEntry.php.

References getDescription(), getEntryId(), getOrderPosition(), getOutdated(), and getTitle().

317  : bool
318  {
319  $this->db->update('il_md_cpr_selections', array(
320  'title' => array('text', $this->getTitle()),
321  'description' => array('clob', $this->getDescription()),
322  //'copyright' => array('clob', $this->getCopyright()),
323  'outdated' => array('integer', $this->getOutdated()),
324  'position' => array('integer', $this->getOrderPosition())
325  ), array(
326  'entry_id' => array('integer', $this->getEntryId())
327  ));
328  return true;
329  }
+ Here is the call graph for this function:

◆ validate()

ilMDCopyrightSelectionEntry::validate ( )

Definition at line 338 of file class.ilMDCopyrightSelectionEntry.php.

References getTitle().

338  : bool
339  {
340  return $this->getTitle() !== '';
341  }
+ Here is the call graph for this function:

Field Documentation

◆ $copyright

string ilMDCopyrightSelectionEntry::$copyright = ''
private

Definition at line 43 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getCopyright().

◆ $db

ilDBInterface ilMDCopyrightSelectionEntry::$db
protected

Definition at line 35 of file class.ilMDCopyrightSelectionEntry.php.

◆ $description

string ilMDCopyrightSelectionEntry::$description = ''
private

Definition at line 42 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getDescription().

◆ $entry_id

int ilMDCopyrightSelectionEntry::$entry_id
private

Definition at line 40 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getEntryId().

◆ $logger

ilLogger ilMDCopyrightSelectionEntry::$logger
protected

Definition at line 34 of file class.ilMDCopyrightSelectionEntry.php.

◆ $order_position

int ilMDCopyrightSelectionEntry::$order_position = 0
protected

Definition at line 49 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getOrderPosition().

◆ $outdated

bool ilMDCopyrightSelectionEntry::$outdated = false
protected

Definition at line 47 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getOutdated().

◆ $renderer

RendererInterface ilMDCopyrightSelectionEntry::$renderer
protected

Definition at line 36 of file class.ilMDCopyrightSelectionEntry.php.

◆ $repository

RepositoryInterface ilMDCopyrightSelectionEntry::$repository
protected

Definition at line 37 of file class.ilMDCopyrightSelectionEntry.php.

◆ $title

string ilMDCopyrightSelectionEntry::$title = ''
private

Definition at line 41 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getTitle().

◆ $ui_renderer

UIRenderer ilMDCopyrightSelectionEntry::$ui_renderer
protected

Definition at line 38 of file class.ilMDCopyrightSelectionEntry.php.

◆ $usage

int ilMDCopyrightSelectionEntry::$usage = null
private

Definition at line 45 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by getUsage().


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