19 declare(strict_types=1);
    56             $DIC->ui()->factory(),
    57             $DIC->resourceStorage()
    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;
    74         $ilDB = $DIC->database();
    76         $query = 
"SELECT entry_id FROM il_md_cpr_selections ORDER BY is_default DESC, position ASC";
    90         $ilDB = $DIC->database();
    92         if (!$entry_id = self::_extractEntryId($a_cp_string)) {
    96         $query = 
"SELECT title FROM il_md_cpr_selections " .
   100         return $row->title ?? 
'';
   108             $DIC->ui()->factory(),
   109             $DIC->resourceStorage()
   112         $ui_renderer = $DIC->ui()->renderer();
   114         if (!$entry_id = self::_extractEntryId($a_cp_string)) {
   118         $entry = $repository->getEntry($entry_id);
   121         return $ui_renderer->render($components);
   130         if (!$entry_id = self::_extractEntryId($a_cp_string)) {
   136         return (
string) (
$data->link() ?? 
$data->fullName());
   146         $normalized_copyright = str_replace(
'https://', 
'http://', $copyright_text);
   148         $matches_by_name = null;
   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)) {
   157                 is_null($matches_by_name) &&
   158                 trim($copyright_text) === trim($entry->copyrightData()->fullName())
   160                 $matches_by_name = $entry->id();
   164         if (!is_null($matches_by_name)) {
   165             return $matches_by_name;
   172         if (!preg_match(
'/il_copyright_entry__([0-9]+)__([0-9]+)/', $a_cp_string, $matches)) {
   178         return (
int) ($matches[2] ?? 0);
   181     public static function isEntry($a_cp_string): bool
   183         if (!preg_match(
'/il_copyright_entry__([0-9]+)__([0-9]+)/', $a_cp_string)) {
   192         if ($this->usage === null) {
   193             $query = 
"SELECT count(meta_rights_id) used FROM il_meta_rights " .
   194                 "WHERE description = " . $this->db->quote(
   199             $res = $this->db->query($query);
   200             $row = $this->db->fetchObject(
$res);
   201             $this->usage = (
int) $row->used;
   218         $query = 
"SELECT is_default FROM il_md_cpr_selections " .
   219             "WHERE entry_id = " . $this->db->quote($this->entry_id, 
'integer');
   221         $res = $this->db->query($query);
   222         $row = $this->db->fetchAssoc(
$res);
   224         return (
bool) ($row[
'is_default'] ?? 
false);
   229         $this->outdated = $a_value;
   241         $db = $DIC->database();
   243         $query = 
"SELECT entry_id FROM il_md_cpr_selections " .
   244             "WHERE is_default = " . $db->
quote(1, 
'integer');
   249         return (
int) $row[
'entry_id'];
   254         $this->title = $a_title;
   264         $this->description = $a_desc;
   274         $this->copyright = $a_copyright;
   284         $this->order_position = $a_position;
   294         $query = 
"SELECT count(entry_id) total FROM il_md_cpr_selections";
   295         $res = $this->db->query($query);
   296         $row = $this->db->fetchAssoc(
$res);
   298         return $row[
'total'] + 1;
   301     public function add(): bool
   303         $next_id = $this->db->nextId(
'il_md_cpr_selections');
   305         $this->db->insert(
'il_md_cpr_selections', array(
   306             'entry_id' => array(
'integer', $next_id),
   307             'title' => array(
'text', $this->
getTitle()),
   310             'outdated' => array(
'integer', $this->
getOutdated()),
   313         $this->entry_id = $next_id;
   319         $this->db->update(
'il_md_cpr_selections', array(
   320             'title' => array(
'text', $this->
getTitle()),
   323             'outdated' => array(
'integer', $this->
getOutdated()),
   326             'entry_id' => array(
'integer', $this->
getEntryId())
   331     public function delete(): 
void   345         $entry = $this->
repository->getEntry($this->entry_id);
   347         $rendered_cp = $this->ui_renderer->render(
   348             $this->renderer->toUIComponents($entry->copyrightData())
   360         return 'il_copyright_entry__' . 
IL_INST_ID . 
'__' . $a_entry_id;
 
static _extractEntryId(string $a_cp_string)
 
fetchAssoc(ilDBStatement $statement)
 
static _lookupCopyrightForExport(string $a_cp_string)
 
setCopyright(string $a_copyright)
 
quote($value, string $type)
 
RepositoryInterface $repository
 
static isEntry($a_cp_string)
 
setDescription(string $a_desc)
 
query(string $query)
Run a (read-only) Query on the database. 
 
__construct(int $a_entry_id)
 
static _lookupCopyright(string $a_cp_string)
 
static lookupCopyrightFromImport(string $copyright_text)
 
setOrderPosition(int $a_position)
 
getIsDefault()
Get if the entry is default No setter for this. 
 
RendererInterface $renderer
 
setTitle(string $a_title)
 
static createIdentifier(int $a_entry_id)
 
static lookupCopyyrightTitle(string $a_cp_string)
 
setOutdated(bool $a_value)