commit 8156cfe1a4179951ca5fb102ce543ef86a081a4a Author: buttle Date: Thu Mar 4 16:33:19 2021 +0100 First commit diff --git a/Module.php b/Module.php new file mode 100644 index 0000000..57a60c6 --- /dev/null +++ b/Module.php @@ -0,0 +1,12 @@ +Other-NOTEVALUATED.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/InC-EDU.svg b/asset/img/blue-text/InC-EDU.svg new file mode 100644 index 0000000..b78f003 --- /dev/null +++ b/asset/img/blue-text/InC-EDU.svg @@ -0,0 +1 @@ +InC-EDUCATIONAL.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/InC-NC.svg b/asset/img/blue-text/InC-NC.svg new file mode 100644 index 0000000..e347ac7 --- /dev/null +++ b/asset/img/blue-text/InC-NC.svg @@ -0,0 +1 @@ +InC-NONCOMMERCIAL.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/InC-OW-EU.svg b/asset/img/blue-text/InC-OW-EU.svg new file mode 100644 index 0000000..cbd414e --- /dev/null +++ b/asset/img/blue-text/InC-OW-EU.svg @@ -0,0 +1 @@ +InC-EU-ORPHAN.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/InC-RUU.svg b/asset/img/blue-text/InC-RUU.svg new file mode 100644 index 0000000..f5cc1a6 --- /dev/null +++ b/asset/img/blue-text/InC-RUU.svg @@ -0,0 +1 @@ +InC-UNKNOWN.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/InC.svg b/asset/img/blue-text/InC.svg new file mode 100644 index 0000000..9a6c429 --- /dev/null +++ b/asset/img/blue-text/InC.svg @@ -0,0 +1 @@ +InC.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/NKC.svg b/asset/img/blue-text/NKC.svg new file mode 100644 index 0000000..a42d0f8 --- /dev/null +++ b/asset/img/blue-text/NKC.svg @@ -0,0 +1 @@ +Other-UNKNOWN.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/NoC-CR.svg b/asset/img/blue-text/NoC-CR.svg new file mode 100644 index 0000000..5863f7f --- /dev/null +++ b/asset/img/blue-text/NoC-CR.svg @@ -0,0 +1 @@ +NoC-CONTRACTUAL.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/NoC-NC.svg b/asset/img/blue-text/NoC-NC.svg new file mode 100644 index 0000000..101e244 --- /dev/null +++ b/asset/img/blue-text/NoC-NC.svg @@ -0,0 +1 @@ +NoC-NONCOMMERCIAL.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/NoC-OKLR.svg b/asset/img/blue-text/NoC-OKLR.svg new file mode 100644 index 0000000..7dd9300 --- /dev/null +++ b/asset/img/blue-text/NoC-OKLR.svg @@ -0,0 +1 @@ +NoC-OTHER.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/NoC-US.svg b/asset/img/blue-text/NoC-US.svg new file mode 100644 index 0000000..1d5bd21 --- /dev/null +++ b/asset/img/blue-text/NoC-US.svg @@ -0,0 +1 @@ +NoC-US.dark-white-interior-blue-type \ No newline at end of file diff --git a/asset/img/blue-text/UND.svg b/asset/img/blue-text/UND.svg new file mode 100644 index 0000000..05ee9fb --- /dev/null +++ b/asset/img/blue-text/UND.svg @@ -0,0 +1 @@ +Other-UNDETERMINED.dark-white-interior-blue-type \ No newline at end of file diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..f5deb61 --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,8 @@ + [ + 'invokables' => [ + 'work_type' => 'CustomLicenseTypes\DataType\LicenseType' + ], + ], +]; diff --git a/config/module.ini b/config/module.ini new file mode 100644 index 0000000..ea0d5f5 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,8 @@ +[info] +name = "Custom License Types" +version = "1.0.0" +author = "Arden Kirkland, based on work by John Flatness" +author_link = "https://github.com/ArdenKirkland" +module_link = "https://github.com/ArdenKirkland/CostumeCoreWorkTypes" +support_link = "https://github.com/ArdenKirkland/CostumeCoreWorkTypes/issues" +omeka_version_constraint = "^1.0.0 || ^2.0.0" diff --git a/src/DataType/LicenseType.php b/src/DataType/LicenseType.php new file mode 100644 index 0000000..dc5545d --- /dev/null +++ b/src/DataType/LicenseType.php @@ -0,0 +1,73 @@ + 'Creative Commons CC-BY 4.0', + 'http://purl.org/NET/rdflicense/cc-by-sa4.0' => 'Creative Commons CC-BY-SA 4.0', + 'http://purl.org/NET/rdflicense/cc-by-nc4.0' => 'Creative Commons CC-BY-NC 4.0', + 'http://purl.org/NET/rdflicense/cc-by-nc-sa4.0' => 'Creative Commons CC-BY-NC-SA 4.0', + 'http://purl.org/NET/rdflicense/cc-by-nd4.0' => 'Creative Commons CC-BY-ND 4.0', + 'http://purl.org/NET/rdflicense/cc-by-nc-nd4.0' => 'Creative Commons CC-BY-NC-ND 4.0', + 'http://purl.org/NET/rdflicense/publicdomain' => 'Public domain', + ]; + + public function getName() + { + return 'license_type'; + } + + public function getLabel() + { + return 'Custom License Types'; + } + + public function form(PhpRenderer $view) + { + $select = new Select('license-type'); + $select + ->setAttribute('data-value-key', '@id') + ->setEmptyOption('Select Below') + ->setValueOptions($this->statements); + return $view->formSelect($select); + + } + + public function isValid(array $valueObject) + { + return parent::isValid($valueObject) && isset($this->statements[$valueObject['@id']]); + } + + public function hydrate(array $valueObject, Value $value, AbstractEntityAdapter $adapter) + { + $uri = $valueObject['@id']; + if (isset($this->statements[$uri])) { + $valueObject['o:label'] = $this->statements[$uri]; + } + parent::hydrate($valueObject, $value, $adapter); + } + + public function render(PhpRenderer $view, ValueRepresentation $value) + { + $hyperlink = $view->plugin('hyperlink'); + $escape = $view->plugin('escapeHtml'); + + $uri = $value->uri(); + $uriLabel = $value->value(); + $content = $escape($uriLabel); + + return $hyperlink->raw($content, $uri, ['class' => 'license-type-link']); + } +}