19 declare(strict_types=1);
31 return "Migration of available copyrights.";
36 return Migration::INFINITE;
50 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
55 $res = $this->db->query(
56 'SELECT entry_id, title, copyright FROM il_md_cpr_selections WHERE migrated = 0 LIMIT 1' 59 if ($row = $this->db->fetchAssoc(
$res)) {
60 if (!isset($row[
'entry_id'])) {
64 (
string) ($row[
'title'] ??
''),
65 (
string) ($row[
'copyright'] ??
'')
69 'il_md_cpr_selections',
78 $res = $this->db->query(
79 'SELECT COUNT(*) AS count FROM il_md_cpr_selections WHERE migrated = 0' 82 $row = $this->db->fetchAssoc(
$res);
83 return (
int) $row[
'count'];
96 if (preg_match(
'/<\s*img((?:.|\n)*?)\/>/i', $copyright, $img_matches)) {
97 if (preg_match(
'/src\s*=\s*(?:"|\')(.*?)(?:"|\')/i', $img_matches[1], $src_matches)) {
98 $image_link = strip_tags($src_matches[1]);
100 if (preg_match(
'/alt\s*=\s*(?:"|\')(.*?)(?:"|\')/i', $img_matches[1], $alt_matches)) {
101 $alt_text = strip_tags($alt_matches[1]);
106 if (preg_match(
'/<\s*a((?:.|\n)[^<]*?)<\s*\/a>/i', $copyright, $link_matches)) {
107 if (preg_match(
'/href\s*=\s*(?:"|\')(.*?)(?:"|\')/i', $link_matches[1], $name_matches)) {
108 $link = strip_tags($name_matches[1]);
110 if (preg_match(
'/>((?:\n|.)*)/i', $link_matches[1], $href_matches)) {
111 $full_name = strip_tags($href_matches[1]);
114 $full_name = strip_tags($copyright);
134 'https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
135 'https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
136 'https://i.creativecommons.org/l/by-nc/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
137 'https://i.creativecommons.org/l/by-nd/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
138 'https://i.creativecommons.org/l/by-sa/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
139 'https://i.creativecommons.org/l/by/4.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
141 'http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
142 'http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
143 'http://i.creativecommons.org/l/by-nc/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
144 'http://i.creativecommons.org/l/by-nd/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
145 'http://i.creativecommons.org/l/by-sa/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
146 'http://i.creativecommons.org/l/by/3.0/88x31.png' =>
'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg' 149 if (key_exists($image_link, $mapping)) {
150 return $mapping[$image_link];
160 $old_titles_by_link = [
161 'http://creativecommons.org/licenses/by-nc-nd/4.0/' =>
'Attribution Non-commercial No Derivatives (by-nc-nd)',
162 'http://creativecommons.org/licenses/by-nc-sa/4.0/' =>
'Attribution Non-commercial Share Alike (by-nc-sa)',
163 'http://creativecommons.org/licenses/by-nc/4.0/' =>
'Attribution Non-commercial (by-nc)',
164 'http://creativecommons.org/licenses/by-nd/4.0/' =>
'Attribution No Derivatives (by-nd)',
165 'http://creativecommons.org/licenses/by-sa/4.0/' =>
'Attribution Share Alike (by-sa)',
166 'http://creativecommons.org/licenses/by/4.0/' =>
'Attribution (by)' 168 $new_titles_by_link = [
169 'http://creativecommons.org/licenses/by-nc-nd/4.0/' =>
'Attribution Non-commercial No Derivatives (BY-NC-ND) 4.0',
170 'http://creativecommons.org/licenses/by-nc-sa/4.0/' =>
'Attribution Non-commercial Share Alike (BY-NC-SA) 4.0',
171 'http://creativecommons.org/licenses/by-nc/4.0/' =>
'Attribution Non-commercial (BY-NC) 4.0',
172 'http://creativecommons.org/licenses/by-nd/4.0/' =>
'Attribution No Derivatives (BY-ND) 4.0',
173 'http://creativecommons.org/licenses/by-sa/4.0/' =>
'Attribution Share Alike (BY-SA) 4.0',
174 'http://creativecommons.org/licenses/by/4.0/' =>
'Attribution (BY) 4.0' 177 key_exists($link, $old_titles_by_link) &&
178 $old_titles_by_link[$link] === $title &&
179 key_exists($link, $new_titles_by_link)
181 return $new_titles_by_link[$link];
191 if ($full_name ===
'This work has all rights reserved by the owner.') {
192 return 'All rights reserved';
updatePreInstalledTitles(string $link, string $title)
see https://mantis.ilias.de/view.php?id=41301
cleanupPreInstalledPublicDomainFullName(string $full_name)
see https://mantis.ilias.de/view.php?id=41301
getPreconditions(Environment $environment)
getRemainingAmountOfSteps()
extractFields(string $title, string $copyright)
getDefaultAmountOfStepsPerRun()
step(Environment $environment)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
prepare(Environment $environment)
translatePreInstalledLinksToSVG(string $image_link)