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

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 51 of file class.ilMDCopyrightSelectionEntry.php.

References $DIC, ILIAS\Repository\logger(), read(), renderer(), 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(new Wrapper($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  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
renderer()
global $DIC
Definition: shib_login.php:22
+ 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.

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

◆ _getEntries()

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

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

References $DIC, $ilDB, and $res.

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:66
global $DIC
Definition: shib_login.php:22

◆ _lookupCopyright()

static ilMDCopyrightSelectionEntry::_lookupCopyright ( string  $a_cp_string)
static

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

References $components, $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(new Wrapper($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  }
$components
global $DIC
Definition: shib_login.php:22
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 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(new Wrapper($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: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilMDCopyrightSelectionEntry::add ( )

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

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

288  : bool
289  {
290  $next_id = $this->db->nextId('il_md_cpr_selections');
291 
292  $this->db->insert('il_md_cpr_selections', array(
293  'entry_id' => array('integer', $next_id),
294  'title' => array('text', $this->getTitle()),
295  'description' => array('clob', $this->getDescription()),
296  //'copyright' => array('clob', $this->getCopyright()),
297  'outdated' => array('integer', $this->getOutdated()),
298  'position' => array('integer', $this->getNextOrderPosition())
299  ));
300  $this->entry_id = $next_id;
301  return true;
302  }
+ Here is the call graph for this function:

◆ createIdentifier()

static ilMDCopyrightSelectionEntry::createIdentifier ( int  $a_entry_id)
static

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

References IL_INST_ID.

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

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

◆ delete()

ilMDCopyrightSelectionEntry::delete ( )

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

318  : void
319  {
320  /*$query = "DELETE FROM il_md_cpr_selections " .
321  "WHERE entry_id = " . $this->db->quote($this->getEntryId(), 'integer') . " ";
322  $res = $this->db->manipulate($query);*/
323  }

◆ getCopyright()

ilMDCopyrightSelectionEntry::getCopyright ( )

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

References $copyright.

264  : string
265  {
266  return $this->copyright;
267  }

◆ getDefault()

static ilMDCopyrightSelectionEntry::getDefault ( )
static

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

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

Referenced by ilMDUtils\_getDefaultCopyright().

224  : int
225  {
226  global $DIC;
227 
228  $db = $DIC->database();
229 
230  $query = "SELECT entry_id FROM il_md_cpr_selections " .
231  "WHERE is_default = " . $db->quote(1, 'integer');
232 
233  $res = $db->query($query);
234  $row = $db->fetchAssoc($res);
235 
236  return (int) $row['entry_id'];
237  }
$res
Definition: ltiservices.php:66
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: shib_login.php:22
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 254 of file class.ilMDCopyrightSelectionEntry.php.

References $description.

Referenced by add(), and update().

254  : string
255  {
256  return $this->description;
257  }
+ Here is the caller graph for this function:

◆ getEntryId()

ilMDCopyrightSelectionEntry::getEntryId ( )

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

References $entry_id.

Referenced by read(), and update().

194  : int
195  {
196  return $this->entry_id;
197  }
+ Here is the caller graph for this function:

◆ getIsDefault()

ilMDCopyrightSelectionEntry::getIsDefault ( )

Get if the entry is default No setter for this.

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

References $res.

203  : bool
204  {
205  $query = "SELECT is_default FROM il_md_cpr_selections " .
206  "WHERE entry_id = " . $this->db->quote($this->entry_id, 'integer');
207 
208  $res = $this->db->query($query);
209  $row = $this->db->fetchAssoc($res);
210 
211  return (bool) ($row['is_default'] ?? false);
212  }
$res
Definition: ltiservices.php:66

◆ getNextOrderPosition()

ilMDCopyrightSelectionEntry::getNextOrderPosition ( )
protected

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

References $res.

Referenced by add().

279  : int
280  {
281  $query = "SELECT count(entry_id) total FROM il_md_cpr_selections";
282  $res = $this->db->query($query);
283  $row = $this->db->fetchAssoc($res);
284 
285  return $row['total'] + 1;
286  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ getOrderPosition()

ilMDCopyrightSelectionEntry::getOrderPosition ( )

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

References $order_position.

Referenced by update().

274  : int
275  {
276  return $this->order_position;
277  }
+ Here is the caller graph for this function:

◆ getOutdated()

ilMDCopyrightSelectionEntry::getOutdated ( )

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

References $outdated.

Referenced by add(), and update().

219  : bool
220  {
221  return $this->outdated;
222  }
+ Here is the caller graph for this function:

◆ getTitle()

ilMDCopyrightSelectionEntry::getTitle ( )

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

References $title.

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

244  : string
245  {
246  return $this->title;
247  }
+ Here is the caller graph for this function:

◆ getUsage()

ilMDCopyrightSelectionEntry::getUsage ( )

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

References $usage.

189  : int
190  {
191  return $this->usage;
192  }

◆ 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, ILIAS\MetaData\Copyright\RepositoryInterface\getAllEntries(), and null.

Referenced by ilMDRights\parseDescriptionFromImport().

139  : int
140  {
141  global $DIC;
142 
143  $repository = new DatabaseRepository(new Wrapper($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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getAllEntries()
The default entry is returned first, and the remaining entries are returned according to their positi...
global $DIC
Definition: shib_login.php:22
+ 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.

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:66
global $DIC
Definition: shib_login.php:22

◆ read()

ilMDCopyrightSelectionEntry::read ( )
private

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

References $res, getEntryId(), IL_INST_ID, ILIAS\Repository\int(), renderer(), ILIAS\UI\examples\Deck\repository(), setCopyright(), setDescription(), setOrderPosition(), setOutdated(), and setTitle().

Referenced by __construct().

330  : void
331  {
332  $entry = $this->repository->getEntry($this->entry_id);
333 
334  $rendered_cp = $this->ui_renderer->render(
335  $this->renderer->toUIComponents($entry->copyrightData())
336  );
337 
338  $this->setTitle($entry->title());
339  $this->setDescription($entry->description());
340  $this->setCopyright($rendered_cp);
341  $this->setOutdated($entry->isOutdated());
342  $this->setOrderPosition($entry->position());
343 
344  $query = "SELECT count(meta_rights_id) used FROM il_meta_rights " .
345  "WHERE description = " . $this->db->quote(
346  'il_copyright_entry__' . IL_INST_ID . '__' . $this->getEntryId(),
347  'text'
348  );
349 
350  $res = $this->db->query($query);
351  $row = $this->db->fetchObject($res);
352  $this->usage = (int) $row->used;
353  }
$res
Definition: ltiservices.php:66
const IL_INST_ID
Definition: constants.php:40
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
renderer()
+ 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 259 of file class.ilMDCopyrightSelectionEntry.php.

Referenced by read().

259  : void
260  {
261  $this->copyright = $a_copyright;
262  }
+ Here is the caller graph for this function:

◆ setDescription()

ilMDCopyrightSelectionEntry::setDescription ( string  $a_desc)

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

Referenced by read().

249  : void
250  {
251  $this->description = $a_desc;
252  }
+ Here is the caller graph for this function:

◆ setOrderPosition()

ilMDCopyrightSelectionEntry::setOrderPosition ( int  $a_position)

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

Referenced by read().

269  : void
270  {
271  $this->order_position = $a_position;
272  }
+ Here is the caller graph for this function:

◆ setOutdated()

ilMDCopyrightSelectionEntry::setOutdated ( bool  $a_value)

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

Referenced by read().

214  : void
215  {
216  $this->outdated = $a_value;
217  }
+ Here is the caller graph for this function:

◆ setTitle()

ilMDCopyrightSelectionEntry::setTitle ( string  $a_title)

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

Referenced by read().

239  : void
240  {
241  $this->title = $a_title;
242  }
+ Here is the caller graph for this function:

◆ update()

ilMDCopyrightSelectionEntry::update ( )

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

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

304  : bool
305  {
306  $this->db->update('il_md_cpr_selections', array(
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->getOrderPosition())
312  ), array(
313  'entry_id' => array('integer', $this->getEntryId())
314  ));
315  return true;
316  }
+ Here is the call graph for this function:

◆ validate()

ilMDCopyrightSelectionEntry::validate ( )

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

References getTitle().

325  : bool
326  {
327  return $this->getTitle() !== '';
328  }
+ 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 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 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 = 0
private

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

Referenced by getUsage().


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