ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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:
will be removed with ILIAS 11, please use the new API (see {
See also
../docs/api.md})
Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilMDCopyrightSelectionEntry::__construct ( int  $a_entry_id)

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

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

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

Member Function Documentation

◆ _extractEntryId()

static ilMDCopyrightSelectionEntry::_extractEntryId ( string  $a_cp_string)
static

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

References IL_INST_ID.

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

◆ _getEntries()

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

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

References $DIC, $ilDB, and $res.

71  : array
72  {
73  global $DIC;
74 
75  $ilDB = $DIC->database();
76 
77  $query = "SELECT entry_id FROM il_md_cpr_selections ORDER BY is_default DESC, position ASC";
78  $res = $ilDB->query($query);
79 
80  $entries = [];
81  while ($row = $ilDB->fetchObject($res)) {
82  $entries[] = new ilMDCopyrightSelectionEntry((int) $row->entry_id);
83  }
84  return $entries;
85  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25

◆ _lookupCopyright()

static ilMDCopyrightSelectionEntry::_lookupCopyright ( string  $a_cp_string)
static

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

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

Referenced by ilMDUtils\_parseCopyright().

104  : string
105  {
106  global $DIC;
107 
108  $renderer = new Renderer(
109  $DIC->ui()->factory(),
110  $DIC->resourceStorage()
111  );
112  $repository = new DatabaseRepository(new Wrapper($DIC->database()));
113  $ui_renderer = $DIC->ui()->renderer();
114 
115  if (!$entry_id = self::_extractEntryId($a_cp_string)) {
116  return $a_cp_string;
117  }
118 
119  $entry = $repository->getEntry($entry_id);
120  $components = $renderer->toUIComponents($entry->copyrightData());
121 
122  return $ui_renderer->render($components);
123  }
$components
global $DIC
Definition: shib_login.php:25
toUIComponents(CopyrightDataInterface $copyright)
Returns a string in a legacy UI component if only a string can be returned.
+ 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 125 of file class.ilMDCopyrightSelectionEntry.php.

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

Referenced by ilMDRights\toXML().

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

◆ add()

ilMDCopyrightSelectionEntry::add ( )

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

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

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

◆ createIdentifier()

static ilMDCopyrightSelectionEntry::createIdentifier ( int  $a_entry_id)
static

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

References IL_INST_ID.

Referenced by ilMDUtils\_getDefaultCopyright(), and ilMDRights\parseDescriptionFromImport().

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

◆ delete()

ilMDCopyrightSelectionEntry::delete ( )

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

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

◆ getCopyright()

ilMDCopyrightSelectionEntry::getCopyright ( )

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

References $copyright.

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

◆ getDefault()

static ilMDCopyrightSelectionEntry::getDefault ( )
static

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

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

Referenced by ilMDUtils\_getDefaultCopyright().

238  : int
239  {
240  global $DIC;
241 
242  $db = $DIC->database();
243 
244  $query = "SELECT entry_id FROM il_md_cpr_selections " .
245  "WHERE is_default = " . $db->quote(1, 'integer');
246 
247  $res = $db->query($query);
248  $row = $db->fetchAssoc($res);
249 
250  return (int) $row['entry_id'];
251  }
$res
Definition: ltiservices.php:69
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: shib_login.php:25
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 268 of file class.ilMDCopyrightSelectionEntry.php.

References $description.

Referenced by add(), and update().

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

◆ getEntryId()

ilMDCopyrightSelectionEntry::getEntryId ( )

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

References $entry_id.

Referenced by getUsage(), and update().

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

◆ getIsDefault()

ilMDCopyrightSelectionEntry::getIsDefault ( )

Get if the entry is default No setter for this.

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

References $res.

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

◆ getNextOrderPosition()

ilMDCopyrightSelectionEntry::getNextOrderPosition ( )
protected

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

References $res.

Referenced by add().

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

◆ getOrderPosition()

ilMDCopyrightSelectionEntry::getOrderPosition ( )

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

References $order_position.

Referenced by update().

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

◆ getOutdated()

ilMDCopyrightSelectionEntry::getOutdated ( )

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

References $outdated.

Referenced by add(), and update().

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

◆ getTitle()

ilMDCopyrightSelectionEntry::getTitle ( )

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

References $title.

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

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

◆ getUsage()

ilMDCopyrightSelectionEntry::getUsage ( )

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

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

190  : int
191  {
192  // do a time-consuming usage count on demand
193  if ($this->usage === null) {
194  $query = "SELECT count(meta_rights_id) used FROM il_meta_rights " .
195  "WHERE description = " . $this->db->quote(
196  'il_copyright_entry__' . IL_INST_ID . '__' . $this->getEntryId(),
197  'text'
198  );
199 
200  $res = $this->db->query($query);
201  $row = $this->db->fetchObject($res);
202  $this->usage = (int) $row->used;
203  }
204 
205  return $this->usage;
206  }
$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 182 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by ilMDUtils\_parseCopyright().

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

◆ lookupCopyrightFromImport()

static ilMDCopyrightSelectionEntry::lookupCopyrightFromImport ( string  $copyright_text)
static

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

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

Referenced by ilMDRights\parseDescriptionFromImport().

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

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

87  : string
88  {
89  global $DIC;
90 
91  $ilDB = $DIC->database();
92 
93  if (!$entry_id = self::_extractEntryId($a_cp_string)) {
94  return $a_cp_string;
95  }
96 
97  $query = "SELECT title FROM il_md_cpr_selections " .
98  "WHERE entry_id = " . $ilDB->quote($entry_id, ilDBConstants::T_INTEGER) . " ";
99  $res = $ilDB->query($query);
100  $row = $ilDB->fetchObject($res);
101  return $row->title ?? '';
102  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25

◆ read()

ilMDCopyrightSelectionEntry::read ( )
private

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

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

Referenced by __construct().

344  : void
345  {
346  $entry = $this->repository->getEntry($this->entry_id);
347 
348  $rendered_cp = $this->ui_renderer->render(
349  $this->renderer->toUIComponents($entry->copyrightData())
350  );
351 
352  $this->setTitle($entry->title());
353  $this->setDescription($entry->description());
354  $this->setCopyright($rendered_cp);
355  $this->setOutdated($entry->isOutdated());
356  $this->setOrderPosition($entry->position());
357  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
+ 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 273 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

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

◆ setDescription()

ilMDCopyrightSelectionEntry::setDescription ( string  $a_desc)

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

Referenced by read().

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

◆ setOrderPosition()

ilMDCopyrightSelectionEntry::setOrderPosition ( int  $a_position)

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

Referenced by read().

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

◆ setOutdated()

ilMDCopyrightSelectionEntry::setOutdated ( bool  $a_value)

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

Referenced by read().

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

◆ setTitle()

ilMDCopyrightSelectionEntry::setTitle ( string  $a_title)

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

Referenced by read().

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

◆ update()

ilMDCopyrightSelectionEntry::update ( )

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

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

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

◆ validate()

ilMDCopyrightSelectionEntry::validate ( )

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

References getTitle().

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

Field Documentation

◆ $copyright

string ilMDCopyrightSelectionEntry::$copyright = ''
private

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

Referenced by getCopyright().

◆ $db

ilDBInterface ilMDCopyrightSelectionEntry::$db
protected

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

◆ $description

string ilMDCopyrightSelectionEntry::$description = ''
private

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

Referenced by getDescription().

◆ $entry_id

int ilMDCopyrightSelectionEntry::$entry_id
private

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

Referenced by getEntryId().

◆ $logger

ilLogger ilMDCopyrightSelectionEntry::$logger
protected

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

◆ $order_position

int ilMDCopyrightSelectionEntry::$order_position = 0
protected

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

Referenced by getOrderPosition().

◆ $outdated

bool ilMDCopyrightSelectionEntry::$outdated = false
protected

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

Referenced by getOutdated().

◆ $renderer

RendererInterface ilMDCopyrightSelectionEntry::$renderer
protected

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

◆ $repository

RepositoryInterface ilMDCopyrightSelectionEntry::$repository
protected

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

◆ $title

string ilMDCopyrightSelectionEntry::$title = ''
private

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

Referenced by getTitle().

◆ $ui_renderer

UIRenderer ilMDCopyrightSelectionEntry::$ui_renderer
protected

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

◆ $usage

int ilMDCopyrightSelectionEntry::$usage = null
private

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

Referenced by getUsage().


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