diff --git a/classes/codelist/CodelistItem.php b/classes/codelist/CodelistItem.php index b705c86cba9..5a44eab0e35 100644 --- a/classes/codelist/CodelistItem.php +++ b/classes/codelist/CodelistItem.php @@ -42,7 +42,7 @@ public function getText(): string */ public function setText(string $text): void { - return $this->setData('text', $text); + $this->setData('text', $text); } /** @@ -56,9 +56,9 @@ public function getCode(): string /** * Set codelist code. */ - public function setCode(string $code) + public function setCode(string $code): void { - return $this->setData('code', $code); + $this->setData('code', $code); } /** diff --git a/classes/codelist/ONIXCodelistItem.php b/classes/codelist/ONIXCodelistItem.php index 6155fd75289..c517a6ab250 100644 --- a/classes/codelist/ONIXCodelistItem.php +++ b/classes/codelist/ONIXCodelistItem.php @@ -40,9 +40,9 @@ public function getText() * * @param string $text */ - public function setText($text) + public function setText($text): void { - return $this->setData('text', $text); + $this->setData('text', $text); } /** @@ -60,9 +60,9 @@ public function getCode() * * @param string $code */ - public function setCode($code) + public function setCode($code): void { - return $this->setData('code', $code); + $this->setData('code', $code); } } diff --git a/classes/codelist/ONIXCodelistItemDAO.php b/classes/codelist/ONIXCodelistItemDAO.php index 5fe1eaf4523..d7e2fd0c36b 100644 --- a/classes/codelist/ONIXCodelistItemDAO.php +++ b/classes/codelist/ONIXCodelistItemDAO.php @@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Cache; use PKP\core\Registry; +use PKP\db\DAO; use PKP\db\XMLDAO; use PKP\facades\Locale; use PKP\file\FileManager; @@ -27,7 +28,7 @@ use PKP\plugins\Hook; use PKP\xslt\XSLTransformer; -class ONIXCodelistItemDAO extends \PKP\db\DAO +class ONIXCodelistItemDAO extends DAO { /** @var string The name of the codelist we are interested in */ public string $_list; @@ -45,8 +46,7 @@ public function _getCache(?string $locale = null): array // Reload locale registry file $xmlDao = new XMLDAO(); - $listName = $this->getListName(); // i.e., 'List30' - $handler = new ONIXParserDOMHandler($listName); + $listName = $this->getListName(); // i.e., '30' $temporaryFileManager = new TemporaryFileManager(); $fileManager = new FileManager(); @@ -63,7 +63,13 @@ public function _getCache(?string $locale = null): array $xslTransformer->setRegisterPHPFunctions(true); $xslFile = 'lib/pkp/xml/onixFilter.xsl'; - $filteredXml = $xslTransformer->transform($filename, XSLTransformer::XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSLTransformer::XSL_TRANSFORMER_DOCTYPE_FILE, XSLTransformer::XSL_TRANSFORMER_DOCTYPE_STRING); + $filteredXml = $xslTransformer->transform( + $filename, + XSLTransformer::XSL_TRANSFORMER_DOCTYPE_FILE, + $xslFile, + XSLTransformer::XSL_TRANSFORMER_DOCTYPE_FILE, + XSLTransformer::XSL_TRANSFORMER_DOCTYPE_STRING + ); if (!$filteredXml) { throw new \Exception('Unable to generate filtered XML!'); } @@ -74,6 +80,7 @@ public function _getCache(?string $locale = null): array $fp = fopen($tmpName, 'wb'); fwrite($fp, $filteredXml); fclose($fp); + $handler = new ONIXParserDOMHandler($listName); $data = $xmlDao->parseWithHandler($tmpName, $handler); $fileManager->deleteByPath($tmpName); } else { @@ -101,13 +108,13 @@ public function _getCache(?string $locale = null): array public function getFilename(string $locale): string { $masterLocale = LocaleInterface::DEFAULT_LOCALE; - $localizedFile = "locale/{$locale}/ONIX_BookProduct_CodeLists.xsd"; + $localizedFile = "locale/{$locale}/ONIX_BookProduct_CodeLists.xml"; if (Locale::isLocaleValid($locale) && file_exists($localizedFile)) { return $localizedFile; } // Fall back on the version for the master locale. - return "locale/{$masterLocale}/ONIX_BookProduct_CodeLists.xsd"; + return "locale/{$masterLocale}/ONIX_BookProduct_CodeLists.xml"; } /** diff --git a/classes/codelist/ONIXParserDOMHandler.php b/classes/codelist/ONIXParserDOMHandler.php index 644efd1f19a..97701f0067b 100644 --- a/classes/codelist/ONIXParserDOMHandler.php +++ b/classes/codelist/ONIXParserDOMHandler.php @@ -11,12 +11,12 @@ * * @see XMLParser * - * @brief This parser extracts a specific xs:simpleType based on a name attribute - * representing a code list within it. It returns the xs:enumeration values - * within it along with the xs:documentation elements which serve as textual - * descriptions of the Codelist values. + * @brief This parser extracts a specific CodeList based on a CodeListNumber + * representing a code list within it. It returns the Code values + * within it along with the CodeDescription elements which serve as textual + * descriptions of the Code values. * - * Example: ... + * Example: 28 */ namespace APP\codelist; @@ -28,19 +28,28 @@ class ONIXParserDOMHandler extends XMLParserDOMHandler { - /** @var The list being searched for */ - public string $_listName; + /** @var string The list being searched for */ + public string $listName; - public bool $_foundRequestedList = false; + public bool $foundRequestedList = false; - /** @var List of items the parser eventually returns */ - public ?array $_listItems = []; + /** @var ?array List of items the parser eventually returns */ + public ?array $listItems = []; - /** @var string to store the current character data */ - public ?string $_currentValue = null; + /** @var ?string to store the current character data */ + public ?string $currentValue = null; - /** @var bool currently inside an xs:documentation element */ - public bool $_insideDocumentation = false; + /** @var bool currently inside a CodeListNumber element */ + public bool $inCodeListNumber = false; + + /** @var bool currently inside a CodeValue element */ + public bool $inCodeValue = false; + + /** @var bool currently inside a CodeDescription element */ + public bool $inDescription = false; + + /** @var bool currently inside a DeprecatedNumber element */ + public bool $inDeprecated = false; /** * Constructor. @@ -48,7 +57,7 @@ class ONIXParserDOMHandler extends XMLParserDOMHandler public function __construct(string $listName) { parent::__construct(); - $this->_listName = $listName; + $this->listName = $listName; } /** @@ -59,21 +68,19 @@ public function startElement(PKPXMLParser|XMLParser $parser, string $tag, array $this->currentData = null; switch ($tag) { - case 'xs:simpleType': - if ($attributes['name'] == $this->_listName) { - $this->_foundRequestedList = true; - } + case 'CodeListNumber': + $this->inCodeListNumber = true; break; - case 'xs:enumeration': - if ($this->_foundRequestedList) { - $this->_currentValue = $attributes['value']; - $this->_listItems[$this->_currentValue] = []; // initialize the array cell + case 'CodeValue': + if ($this->foundRequestedList) { + $this->inCodeValue = true; } break; - case 'xs:documentation': - if ($this->_foundRequestedList) { - $this->_insideDocumentation = true; - } + case 'CodeDescription': + $this->inDescription = true; + break; + case 'DeprecatedNumber': + $this->inDeprecated = true; break; } @@ -92,30 +99,53 @@ public function startElement(PKPXMLParser|XMLParser $parser, string $tag, array /** * Callback function to act as the character data handler. */ - public function characterData(PKPXMLParser|XMLParser $parser, string $data) + public function characterData(PKPXMLParser|XMLParser $parser, string $data): void { - if ($this->_insideDocumentation) { - if (count($this->_listItems[$this->_currentValue]) == 1) { - $this->_listItems[$this->_currentValue][0] .= $data; + if ($this->inCodeListNumber && $this->listName = $data) { + $this->foundRequestedList = true; // @TODO may not need this + } + + if ($this->inCodeValue) { + $this->currentValue = $data; + $this->listItems[$data] = []; // initialize the array cell + } + + if ($this->inDescription) { + if (count($this->listItems[$this->currentValue]) == 1) { + $this->listItems[$this->currentValue][0] .= $data; } else { - $this->_listItems[$this->_currentValue][0] = $data; + $this->listItems[$this->currentValue][0] = $data; } } + + if ($this->inDeprecated) { + $this->listItems[$this->currentValue]['deprecated'] = 1; + } } /** * Callback function to act as the end element handler. */ - public function endElement(PKPXMLParser|XMLParser $parser, string $tag) + public function endElement(PKPXMLParser|XMLParser $parser, string $tag): void { switch ($tag) { - case 'xs:simpleType': - $this->_foundRequestedList = false; + case 'CodeListNumber': + $this->inCodeListNumber = false; break; - case 'xs:documentation': - $this->_insideDocumentation = false; + case 'CodeValue': + $this->inCodeValue = false; + break; + case 'CodeDescription': + $this->inDescription = false; + break; + case 'DeprecatedNumber': + $this->inDeprecated = false; break; } + + $this->currentNode->setValue($this->currentData); + $this->currentNode = & $this->currentNode->getParent(); + $this->currentData = null; } /** @@ -123,7 +153,7 @@ public function endElement(PKPXMLParser|XMLParser $parser, string $tag) */ public function getResult(): mixed { - return [$this->_listName => $this->_listItems]; + return [$this->listName => $this->listItems]; } } diff --git a/classes/components/forms/context/MastheadForm.php b/classes/components/forms/context/MastheadForm.php index ccd9816de65..13ac48bdbf6 100644 --- a/classes/components/forms/context/MastheadForm.php +++ b/classes/components/forms/context/MastheadForm.php @@ -32,7 +32,7 @@ public function __construct($action, $locales, $context, $imageUploadUrl) /** @var ONIXCodelistItemDAO */ $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); - $codeTypes = $onixCodelistItemDao->getCodes('List44'); + $codeTypes = $onixCodelistItemDao->getCodes('44'); $codeTypeOptions = array_map(function ($code, $name) { return ['value' => $code, 'label' => $name]; }, array_keys($codeTypes), $codeTypes); diff --git a/classes/components/forms/submission/AudienceForm.php b/classes/components/forms/submission/AudienceForm.php index bb127b59eb1..8850b91bd29 100644 --- a/classes/components/forms/submission/AudienceForm.php +++ b/classes/components/forms/submission/AudienceForm.php @@ -43,9 +43,9 @@ public function __construct($action, $submission) /** @var ONIXCodelistItemDAO */ $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); - $audienceCodes = $this->getOptions($onixCodelistItemDao->getCodes('List28')); - $audienceRangeQualifiers = $this->getOptions($onixCodelistItemDao->getCodes('List30')); - $audienceRanges = $this->getOptions($onixCodelistItemDao->getCodes('List77')); + $audienceCodes = $this->getOptions($onixCodelistItemDao->getCodes('28')); + $audienceRangeQualifiers = $this->getOptions($onixCodelistItemDao->getCodes('30')); + $audienceRanges = $this->getOptions($onixCodelistItemDao->getCodes('77')); $this->addField(new FieldSelect('audience', [ 'label' => __('monograph.audience'), diff --git a/classes/monograph/Representative.php b/classes/monograph/Representative.php index 8991930e9d0..772d39e8809 100644 --- a/classes/monograph/Representative.php +++ b/classes/monograph/Representative.php @@ -38,15 +38,15 @@ public function getMonographId() * * @param int $monographId */ - public function setMonographId($monographId) + public function setMonographId($monographId): void { - return $this->setData('monographId', $monographId); + $this->setData('monographId', $monographId); } /** * Set the ONIX code for this representative role (List93 for Suppliers, List69 for Agents) */ - public function setRole($role) + public function setRole($role): void { $this->setData('role', $role); } @@ -62,7 +62,7 @@ public function getRole() } /** - * Get the human readable name for this ONIX code + * Get the human-readable name for this ONIX code * * @return string */ @@ -70,11 +70,11 @@ public function getNameForONIXCode() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ if ($this->getIsSupplier()) { - $listName = 'List93'; // List93 -> Publisher to retailers, Wholesaler, etc + $listName = '93'; // List 93 -> Supplier role } else { - $listName = 'List69'; // List93 -> Local Publisher, Sales Agent, etc + $listName = '69'; // List 69 -> Agent role } - $codes = & $onixCodelistItemDao->getCodes($listName); + $codes = $onixCodelistItemDao->getCodes($listName); return $codes[$this->getRole()]; } diff --git a/classes/publicationFormat/IdentificationCode.php b/classes/publicationFormat/IdentificationCode.php index 125a3b8e65f..aaf6e0edfd9 100644 --- a/classes/publicationFormat/IdentificationCode.php +++ b/classes/publicationFormat/IdentificationCode.php @@ -39,7 +39,7 @@ public function getPublicationFormatId() */ public function setPublicationFormatId($publicationFormatId) { - return $this->setData('publicationFormatId', $publicationFormatId); + $this->setData('publicationFormatId', $publicationFormatId); } /** @@ -63,14 +63,14 @@ public function getCode() } /** - * Get the human readable name for this ONIX code + * Get the human-readable name for this ONIX code * * @return string */ public function getNameForONIXCode() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $codes = & $onixCodelistItemDao->getCodes('List5'); // List5 is for ISBN, GTIN-13, etc. + $codes = $onixCodelistItemDao->getCodes('5'); // List 5 is for product identifier type return $codes[$this->getCode()]; } diff --git a/classes/publicationFormat/PublicationDate.php b/classes/publicationFormat/PublicationDate.php index dfdf2fa8e00..e82b9ffb88c 100644 --- a/classes/publicationFormat/PublicationDate.php +++ b/classes/publicationFormat/PublicationDate.php @@ -35,7 +35,7 @@ class PublicationDate extends DataObject public function __construct() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $this->dateFormats = & $onixCodelistItemDao->getCodes('List55'); + $this->dateFormats = & $onixCodelistItemDao->getCodes('55'); parent::__construct(); } @@ -101,14 +101,14 @@ public function getDateFormat() } /** - * Get the human readable name for this ONIX code + * Get the human-readable name for this ONIX code * * @return string */ public function getNameForONIXCode() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $codes = & $onixCodelistItemDao->getCodes('List163'); // List163 is for Publication date, Embargo date, Announcement date, etc + $codes = $onixCodelistItemDao->getCodes('163'); // List 163 is for publishing date role return $codes[$this->getRole()]; } @@ -206,7 +206,7 @@ public function getReadableDates() $separator = '-'; $containsMonth = false; - for ($i = 0 ; $i < count($formatCharacters) ; $i ++) { + for ($i = 0 ; $i < count($formatCharacters) ; $i++) { switch ($formatCharacters[$i]) { // if there is a Time included, change the separator. // Do not include the number, add a space instead. diff --git a/classes/publicationFormat/PublicationFormat.php b/classes/publicationFormat/PublicationFormat.php index aaf5b88ff55..e99d4976183 100644 --- a/classes/publicationFormat/PublicationFormat.php +++ b/classes/publicationFormat/PublicationFormat.php @@ -3,8 +3,8 @@ /** * @file classes/publicationFormat/PublicationFormat.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class PublicationFormat @@ -54,9 +54,9 @@ public function getPhysicalFormat() * * @param bool $physicalFormat */ - public function setPhysicalFormat($physicalFormat) + public function setPhysicalFormat($physicalFormat): void { - return $this->setData('physicalFormat', $physicalFormat); + $this->setData('physicalFormat', $physicalFormat); } /** @@ -78,14 +78,14 @@ public function setEntryKey($entryKey) } /** - * Get the human readable name for this ONIX code + * Get the human-readable name for this ONIX code * * @return string */ public function getNameForONIXCode() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $codes = $onixCodelistItemDao->getCodes('List7'); // List7 is for object formats + $codes = $onixCodelistItemDao->getCodes('150'); // List 150 is for product forms return $codes[$this->getEntryKey()]; } @@ -104,9 +104,9 @@ public function getCountryManufactureCode() * * @param string $countryManufactureCode */ - public function setCountryManufactureCode($countryManufactureCode) + public function setCountryManufactureCode($countryManufactureCode): void { - return $this->setData('countryManufactureCode', $countryManufactureCode); + $this->setData('countryManufactureCode', $countryManufactureCode); } /** @@ -124,9 +124,9 @@ public function getProductAvailabilityCode() * * @param string $productAvailabilityCode */ - public function setProductAvailabilityCode($productAvailabilityCode) + public function setProductAvailabilityCode($productAvailabilityCode): void { - return $this->setData('productAvailabilityCode', $productAvailabilityCode); + $this->setData('productAvailabilityCode', $productAvailabilityCode); } /** @@ -144,9 +144,9 @@ public function getHeight() * * @param string $height */ - public function setHeight($height) + public function setHeight($height): void { - return $this->setData('height', $height); + $this->setData('height', $height); } /** @@ -164,9 +164,9 @@ public function getHeightUnitCode() * * @param string $heightUnitCode */ - public function setHeightUnitCode($heightUnitCode) + public function setHeightUnitCode($heightUnitCode): void { - return $this->setData('heightUnitCode', $heightUnitCode); + $this->setData('heightUnitCode', $heightUnitCode); } /** @@ -184,9 +184,9 @@ public function getWidth() * * @param string $width */ - public function setWidth($width) + public function setWidth($width): void { - return $this->setData('width', $width); + $this->setData('width', $width); } /** @@ -204,9 +204,9 @@ public function getWidthUnitCode() * * @param string $widthUnitCode */ - public function setWidthUnitCode($widthUnitCode) + public function setWidthUnitCode($widthUnitCode): void { - return $this->setData('widthUnitCode', $widthUnitCode); + $this->setData('widthUnitCode', $widthUnitCode); } /** @@ -224,9 +224,9 @@ public function getThickness() * * @param string $thickness */ - public function setThickness($thickness) + public function setThickness($thickness): void { - return $this->setData('thickness', $thickness); + $this->setData('thickness', $thickness); } /** @@ -244,9 +244,9 @@ public function getThicknessUnitCode() * * @param string $thicknessUnitCode */ - public function setThicknessUnitCode($thicknessUnitCode) + public function setThicknessUnitCode($thicknessUnitCode): void { - return $this->setData('thicknessUnitCode', $thicknessUnitCode); + $this->setData('thicknessUnitCode', $thicknessUnitCode); } /** @@ -264,13 +264,13 @@ public function getWeight() * * @param string $weight */ - public function setWeight($weight) + public function setWeight($weight): void { - return $this->setData('weight', $weight); + $this->setData('weight', $weight); } /** - * Get the weight unit code (ONIX value) of the monograph format (List95). + * Get the weight unit code (ONIX value) of the monograph format (List50). * * @return string */ @@ -284,9 +284,9 @@ public function getWeightUnitCode() * * @param string $weightUnitCode */ - public function setWeightUnitCode($weightUnitCode) + public function setWeightUnitCode($weightUnitCode): void { - return $this->setData('weightUnitCode', $weightUnitCode); + $this->setData('weightUnitCode', $weightUnitCode); } /** @@ -333,9 +333,9 @@ public function getCalculatedFileSize() * * @param string $fileSize */ - public function setFileSize($fileSize) + public function setFileSize($fileSize): void { - return $this->setData('fileSize', $fileSize); + $this->setData('fileSize', $fileSize); } /** @@ -397,9 +397,9 @@ public function getProductFormDetailCode() * * @param string $productFormDetailCode */ - public function setProductFormDetailCode($productFormDetailCode) + public function setProductFormDetailCode($productFormDetailCode): void { - return $this->setData('productFormDetailCode', $productFormDetailCode); + $this->setData('productFormDetailCode', $productFormDetailCode); } /** @@ -417,9 +417,9 @@ public function getProductCompositionCode() * * @param string $productCompositionCode */ - public function setProductCompositionCode($productCompositionCode) + public function setProductCompositionCode($productCompositionCode): void { - return $this->setData('productCompositionCode', $productCompositionCode); + $this->setData('productCompositionCode', $productCompositionCode); } /** @@ -437,9 +437,9 @@ public function getFrontMatter() * * @param string $frontMatter */ - public function setFrontMatter($frontMatter) + public function setFrontMatter($frontMatter): void { - return $this->setData('frontMatter', $frontMatter); + $this->setData('frontMatter', $frontMatter); } /** @@ -457,9 +457,9 @@ public function getBackMatter() * * @param string $backMatter */ - public function setBackMatter($backMatter) + public function setBackMatter($backMatter): void { - return $this->setData('backMatter', $backMatter); + $this->setData('backMatter', $backMatter); } /** @@ -477,9 +477,9 @@ public function getImprint() * * @param string $imprint */ - public function setImprint($imprint) + public function setImprint($imprint): void { - return $this->setData('imprint', $imprint); + $this->setData('imprint', $imprint); } /** @@ -497,9 +497,9 @@ public function getTechnicalProtectionCode() * * @param string $technicalProtectionCode */ - public function setTechnicalProtectionCode($technicalProtectionCode) + public function setTechnicalProtectionCode($technicalProtectionCode): void { - return $this->setData('technicalProtectionCode', $technicalProtectionCode); + $this->setData('technicalProtectionCode', $technicalProtectionCode); } /** @@ -517,13 +517,13 @@ public function getReturnableIndicatorCode() * * @param string $returnableIndicatorCode */ - public function setReturnableIndicatorCode($returnableIndicatorCode) + public function setReturnableIndicatorCode($returnableIndicatorCode): void { - return $this->setData('returnableIndicatorCode', $returnableIndicatorCode); + $this->setData('returnableIndicatorCode', $returnableIndicatorCode); } /** - * Get whether or not this format is available in the catalog. + * Get whether this format is available in the catalog. * * @return int */ @@ -533,13 +533,13 @@ public function getIsAvailable() } /** - * Set whether or not this format is available in the catalog. + * Set whether this format is available in the catalog. * * @param int $isAvailable */ - public function setIsAvailable($isAvailable) + public function setIsAvailable($isAvailable): void { - return $this->setData('isAvailable', $isAvailable); + $this->setData('isAvailable', $isAvailable); } /** @@ -575,7 +575,10 @@ public function hasNeededONIXFields() */ public function _checkRequiredFieldsAssigned() { - $requiredFields = ['productCompositionCode' => 'grid.catalogEntry.codeRequired', 'productAvailabilityCode' => 'grid.catalogEntry.productAvailabilityRequired']; + $requiredFields = [ + 'productCompositionCode' => 'grid.catalogEntry.codeRequired', + 'productAvailabilityCode' => 'grid.catalogEntry.productAvailabilityRequired' + ]; $errors = []; diff --git a/classes/publicationFormat/SalesRights.php b/classes/publicationFormat/SalesRights.php index 954df4998cb..1e8564a325a 100644 --- a/classes/publicationFormat/SalesRights.php +++ b/classes/publicationFormat/SalesRights.php @@ -38,7 +38,7 @@ public function getPublicationFormatId() */ public function setPublicationFormatId($publicationFormatId) { - return $this->setData('publicationFormatId', $publicationFormatId); + $this->setData('publicationFormatId', $publicationFormatId); } /** @@ -62,14 +62,14 @@ public function getType() } /** - * Get the human readable name for this ONIX code + * Get the human-readable name for this ONIX code * * @return string */ public function getNameForONIXCode() { $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $codes = & $onixCodelistItemDao->getCodes('List46'); // List46 is for things like 'unrestricted sale with exclusive rights', etc. + $codes = $onixCodelistItemDao->getCodes('46'); // List 46 is for sales rights types return $codes[$this->getType()]; } @@ -184,7 +184,7 @@ public function setRegionsExcluded($regionsExcluded) */ public function _removeEmptyElements($value) { - return (trim($value) != '') ? true : false; + return trim($value) != ''; } } diff --git a/classes/services/ContextService.php b/classes/services/ContextService.php index 3e90ae8c03c..76760ed7958 100644 --- a/classes/services/ContextService.php +++ b/classes/services/ContextService.php @@ -189,7 +189,7 @@ public function validateContext($hookName, $args) if (!empty($props['codeType'])) { /** @var ONIXCodelistItemDAO */ $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); - if (!$onixCodelistItemDao->codeExistsInList($props['codeType'], 'List44')) { + if (!$onixCodelistItemDao->codeExistsInList($props['codeType'], '44')) { $errors['codeType'] = [__('manager.settings.publisherCodeType.invalid')]; } } diff --git a/controllers/grid/catalogEntry/MarketsGridCellProvider.php b/controllers/grid/catalogEntry/MarketsGridCellProvider.php index e656b357f3e..45fbbfe55c7 100644 --- a/controllers/grid/catalogEntry/MarketsGridCellProvider.php +++ b/controllers/grid/catalogEntry/MarketsGridCellProvider.php @@ -20,6 +20,7 @@ use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridColumn; use PKP\controllers\grid\GridRow; +use PKP\core\DataObject; class MarketsGridCellProvider extends DataObjectGridCellProvider { @@ -39,7 +40,7 @@ public function getTemplateVarsFromRowColumn($row, $column) { $element = $row->getData(); $columnId = $column->getId(); - assert(is_a($element, 'DataObject') && !empty($columnId)); + assert($element instanceof DataObject && !empty($columnId)); /** @var Market $element */ switch ($columnId) { case 'territory': diff --git a/controllers/grid/catalogEntry/PublicationDateGridCellProvider.php b/controllers/grid/catalogEntry/PublicationDateGridCellProvider.php index 071a1c4f215..8f7b147842c 100644 --- a/controllers/grid/catalogEntry/PublicationDateGridCellProvider.php +++ b/controllers/grid/catalogEntry/PublicationDateGridCellProvider.php @@ -20,6 +20,7 @@ use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridColumn; use PKP\controllers\grid\GridRow; +use PKP\core\DataObject; class PublicationDateGridCellProvider extends DataObjectGridCellProvider { @@ -39,7 +40,7 @@ public function getTemplateVarsFromRowColumn($row, $column) { $element = $row->getData(); $columnId = $column->getId(); - assert(is_a($element, 'DataObject') && !empty($columnId)); + assert($element instanceof DataObject && !empty($columnId)); /** @var PublicationDate $element */ switch ($columnId) { case 'code': diff --git a/controllers/grid/catalogEntry/PublicationFormatCategoryGridDataProvider.php b/controllers/grid/catalogEntry/PublicationFormatCategoryGridDataProvider.php index f66e6a37d2e..238161cdbb9 100644 --- a/controllers/grid/catalogEntry/PublicationFormatCategoryGridDataProvider.php +++ b/controllers/grid/catalogEntry/PublicationFormatCategoryGridDataProvider.php @@ -111,7 +111,7 @@ public function loadData($filter = []) */ public function loadCategoryData($request, $categoryDataElement, $filter = null, $reviewRound = null) { - assert(is_a($categoryDataElement, 'Representation')); + assert($categoryDataElement instanceof Representation); // Retrieve all submission files for the given file stage. /** @var Representation $categoryDataElement */ diff --git a/controllers/grid/catalogEntry/RepresentativesGridCellProvider.php b/controllers/grid/catalogEntry/RepresentativesGridCellProvider.php index 8de478eb28e..cfe48bd1570 100644 --- a/controllers/grid/catalogEntry/RepresentativesGridCellProvider.php +++ b/controllers/grid/catalogEntry/RepresentativesGridCellProvider.php @@ -19,6 +19,7 @@ use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridColumn; use PKP\controllers\grid\GridRow; +use PKP\core\DataObject; use PKP\submission\Representation; class RepresentativesGridCellProvider extends DataObjectGridCellProvider @@ -40,7 +41,7 @@ public function getTemplateVarsFromRowColumn($row, $column) $element = $row->getData(); $columnId = $column->getId(); - assert(is_a($element, 'DataObject') && !empty($columnId)); + assert($element instanceof DataObject && !empty($columnId)); /** @var Representation $element */ switch ($columnId) { case 'role': diff --git a/controllers/grid/catalogEntry/SalesRightsGridCellProvider.php b/controllers/grid/catalogEntry/SalesRightsGridCellProvider.php index 1ac5059a16f..41735173060 100644 --- a/controllers/grid/catalogEntry/SalesRightsGridCellProvider.php +++ b/controllers/grid/catalogEntry/SalesRightsGridCellProvider.php @@ -20,6 +20,7 @@ use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridColumn; use PKP\controllers\grid\GridRow; +use PKP\core\DataObject; class SalesRightsGridCellProvider extends DataObjectGridCellProvider { @@ -39,7 +40,7 @@ public function getTemplateVarsFromRowColumn($row, $column) { $element = $row->getData(); $columnId = $column->getId(); - assert(is_a($element, 'DataObject') && !empty($columnId)); + assert($element instanceof DataObject && !empty($columnId)); /** @var SalesRights $element */ switch ($columnId) { case 'type': diff --git a/controllers/grid/catalogEntry/form/IdentificationCodeForm.php b/controllers/grid/catalogEntry/form/IdentificationCodeForm.php index 84eb6efd095..a1f5232a7aa 100644 --- a/controllers/grid/catalogEntry/form/IdentificationCodeForm.php +++ b/controllers/grid/catalogEntry/form/IdentificationCodeForm.php @@ -181,7 +181,7 @@ public function fetch($request, $template = null, $display = false) if ($context->areDoisEnabled()) { $assignedCodes[] = '06'; // 06 is DOI in ONIX-speak. } - $codes = $onixCodelistItemDao->getCodes('List5', $assignedCodes); // ONIX list for these + $codes = $onixCodelistItemDao->getCodes('5', $assignedCodes); // ONIX list for these $templateMgr->assign('identificationCodes', $codes); } else { throw new \Exception('Format not in authorized submission'); diff --git a/controllers/grid/catalogEntry/form/MarketForm.php b/controllers/grid/catalogEntry/form/MarketForm.php index 07f214dd436..13fc0129c62 100644 --- a/controllers/grid/catalogEntry/form/MarketForm.php +++ b/controllers/grid/catalogEntry/form/MarketForm.php @@ -162,15 +162,15 @@ public function fetch($request, $template = null, $display = false) $market = $this->getMarket(); $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ $templateMgr->assign([ - 'countryCodes' => $onixCodelistItemDao->getCodes('List91'), // countries (CA, US, GB, etc) - 'regionCodes' => $onixCodelistItemDao->getCodes('List49'), // regions (British Columbia, England, etc) - 'publicationDateFormats' => $onixCodelistItemDao->getCodes('List55'), // YYYYMMDD, YYMMDD, etc - 'publicationDateRoles' => $onixCodelistItemDao->getCodes('List163'), - 'currencyCodes' => $onixCodelistItemDao->getCodes('List96'), // GBP, USD, CAD, etc - 'priceTypeCodes' => $onixCodelistItemDao->getCodes('List58'), // without tax, with tax, etc - 'extentTypeCodes' => $onixCodelistItemDao->getCodes('List23'), // word count, FM page count, BM page count, main page count, etc - 'taxRateCodes' => $onixCodelistItemDao->getCodes('List62'), // higher rate, standard rate, zero rate - 'taxTypeCodes' => $onixCodelistItemDao->getCodes('List171'), // VAT, GST + 'countryCodes' => $onixCodelistItemDao->getCodes('91'), // countries (CA, US, GB, etc) + 'regionCodes' => $onixCodelistItemDao->getCodes('49'), // regions (British Columbia, England, etc) + 'publicationDateFormats' => $onixCodelistItemDao->getCodes('55'), // YYYYMMDD, YYMMDD, etc + 'publicationDateRoles' => $onixCodelistItemDao->getCodes('163'), + 'currencyCodes' => $onixCodelistItemDao->getCodes('96'), // GBP, USD, CAD, etc + 'priceTypeCodes' => $onixCodelistItemDao->getCodes('58'), // without tax, with tax, etc + 'extentTypeCodes' => $onixCodelistItemDao->getCodes('23'), // word count, FM page count, BM page count, main page count, etc + 'taxRateCodes' => $onixCodelistItemDao->getCodes('62'), // higher rate, standard rate, zero rate + 'taxTypeCodes' => $onixCodelistItemDao->getCodes('171'), // VAT, GST ]); /** @var RepresentativeDAO */ diff --git a/controllers/grid/catalogEntry/form/PublicationDateForm.php b/controllers/grid/catalogEntry/form/PublicationDateForm.php index bc30f363629..6fc556a155c 100644 --- a/controllers/grid/catalogEntry/form/PublicationDateForm.php +++ b/controllers/grid/catalogEntry/form/PublicationDateForm.php @@ -64,7 +64,7 @@ function ($date) use ($form) { if (!$dateFormat) { return false; } - $dateFormats = $onixCodelistItemDao->getCodes('List55'); + $dateFormats = $onixCodelistItemDao->getCodes('55'); $format = $dateFormats[$dateFormat]; if (stristr($format, 'string') && $date != '') { return true; @@ -201,11 +201,11 @@ public function fetch($request, $template = null, $display = false) $assignedRoles = array_diff($assignedRoles, [$publicationDate->getRole()]); } // allow existing roles to keep their value $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $roles = $onixCodelistItemDao->getCodes('List163', $assignedRoles); // ONIX list for these + $roles = $onixCodelistItemDao->getCodes('163', $assignedRoles); // ONIX list for these $templateMgr->assign('publicationDateRoles', $roles); //load our date formats - $dateFormats = $onixCodelistItemDao->getCodes('List55'); + $dateFormats = $onixCodelistItemDao->getCodes('55'); $templateMgr->assign('publicationDateFormats', $dateFormats); } else { throw new Exception('Format not in authorized submission'); diff --git a/controllers/grid/catalogEntry/form/PublicationFormatForm.php b/controllers/grid/catalogEntry/form/PublicationFormatForm.php index d0cde414703..83d0f6410be 100644 --- a/controllers/grid/catalogEntry/form/PublicationFormatForm.php +++ b/controllers/grid/catalogEntry/form/PublicationFormatForm.php @@ -173,7 +173,7 @@ public function fetch($request, $template = null, $display = false) { $templateMgr = TemplateManager::getManager($request); $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $templateMgr->assign('entryKeys', $onixCodelistItemDao->getCodes('List7')); // List7 is for object formats + $templateMgr->assign('entryKeys', $onixCodelistItemDao->getCodes('150')); // List150 is for object formats $monograph = $this->getMonograph(); $templateMgr->assign('submissionId', $monograph->getId()); diff --git a/controllers/grid/catalogEntry/form/PublicationFormatMetadataForm.php b/controllers/grid/catalogEntry/form/PublicationFormatMetadataForm.php index f231c80d37c..2526e662f6d 100644 --- a/controllers/grid/catalogEntry/form/PublicationFormatMetadataForm.php +++ b/controllers/grid/catalogEntry/form/PublicationFormatMetadataForm.php @@ -3,8 +3,8 @@ /** * @file controllers/grid/catalogEntry/form/PublicationFormatMetadataForm.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class PublicationFormatMetadataForm @@ -26,6 +26,10 @@ use Exception; use PKP\db\DAORegistry; use PKP\form\Form; +use PKP\form\validation\FormValidator; +use PKP\form\validation\FormValidatorCSRF; +use PKP\form\validation\FormValidatorPost; +use PKP\form\validation\FormValidatorRegExp; use PKP\notification\Notification; use PKP\plugins\PKPPubIdPluginHelper; use PKP\plugins\PluginRegistry; @@ -86,11 +90,11 @@ public function __construct($submission, $publication, $representation, $isPhysi $this->_remoteURL = $remoteURL; $this->_formParams = $formParams; - $this->addCheck(new \PKP\form\validation\FormValidator($this, 'productAvailabilityCode', 'required', 'grid.catalogEntry.productAvailabilityRequired')); - $this->addCheck(new \PKP\form\validation\FormValidatorRegExp($this, 'directSalesPrice', 'optional', 'grid.catalogEntry.validPriceRequired', '/^[0-9]*(\.[0-9]+)?$/')); - $this->addCheck(new \PKP\form\validation\FormValidator($this, 'productCompositionCode', 'required', 'grid.catalogEntry.productCompositionRequired')); - $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); - $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); + $this->addCheck(new FormValidator($this, 'productAvailabilityCode', 'required', 'grid.catalogEntry.productAvailabilityRequired')); + $this->addCheck(new FormValidatorRegExp($this, 'directSalesPrice', 'optional', 'grid.catalogEntry.validPriceRequired', '/^[0-9]*(\.[0-9]+)?$/')); + $this->addCheck(new FormValidator($this, 'productCompositionCode', 'required', 'grid.catalogEntry.productCompositionRequired')); + $this->addCheck(new FormValidatorPost($this)); + $this->addCheck(new FormValidatorCSRF($this)); } /** @@ -126,15 +130,15 @@ public function fetch($request, $template = null, $display = false) // get the lists associated with the select elements on these publication format forms. $codes = [ - 'productCompositionCodes' => 'List2', // single item, multiple item, trade-only, etc - 'measurementUnitCodes' => 'List50', // grams, inches, millimeters - 'weightUnitCodes' => 'List95', // pounds, grams, ounces - 'measurementTypeCodes' => 'List48', // height, width, depth - 'productFormDetailCodes' => 'List175', // refinement of product form (SACD, Mass market (rack) paperback, etc) - 'productAvailabilityCodes' => 'List65', // Available, In Stock, Print On Demand, Not Yet Available, etc - 'technicalProtectionCodes' => 'List144', // None, DRM, Apple DRM, etc - 'returnableIndicatorCodes' => 'List66', // No, not returnable, Yes, full copies only, (required for physical items only) - 'countriesIncludedCodes' => 'List91', // country region codes + 'productCompositionCodes' => '2', // single item, multiple item, trade-only, etc + 'measurementUnitCodes' => '50', // grams, inches, millimeters + 'weightUnitCodes' => '50', // pounds, grams, ounces + 'measurementTypeCodes' => '48', // height, width, depth + 'productFormDetailCodes' => '175', // refinement of product form (SACD, Mass market (rack) paperback, etc) + 'productAvailabilityCodes' => '65', // Available, In Stock, Print On Demand, Not Yet Available, etc + 'technicalProtectionCodes' => '144', // None, DRM, Apple DRM, etc + 'returnableIndicatorCodes' => '66', // No, not returnable, Yes, full copies only, (required for physical items only) + 'countriesIncludedCodes' => '91', // country region codes ]; foreach ($codes as $templateVarName => $list) { @@ -166,7 +170,7 @@ public function initData() $this->_data = [ 'fileSize' => (bool) $publicationFormat->getFileSize() ? $publicationFormat->getFileSize() : $publicationFormat->getCalculatedFileSize(), - 'override' => (bool) $publicationFormat->getData('fileSize') ? true : false, + 'override' => (bool) $publicationFormat->getData('fileSize'), 'frontMatter' => $publicationFormat->getFrontMatter(), 'backMatter' => $publicationFormat->getBackMatter(), 'height' => $publicationFormat->getHeight(), diff --git a/controllers/grid/catalogEntry/form/RepresentativeForm.php b/controllers/grid/catalogEntry/form/RepresentativeForm.php index 476e6dca831..e6792699ee8 100644 --- a/controllers/grid/catalogEntry/form/RepresentativeForm.php +++ b/controllers/grid/catalogEntry/form/RepresentativeForm.php @@ -54,7 +54,7 @@ function ($isSupplier) use ($form) { $agentRole = $request->getUserVar('agentRole'); $supplierRole = $request->getUserVar('supplierRole'); $onixDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixDao */ - return (!$isSupplier && $onixDao->codeExistsInList($agentRole, 'List69')) || ($isSupplier && $onixDao->codeExistsInList($supplierRole, 'List93')); + return (!$isSupplier && $onixDao->codeExistsInList($agentRole, '69')) || ($isSupplier && $onixDao->codeExistsInList($supplierRole, '93')); } )); $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); @@ -144,9 +144,9 @@ public function fetch($request, $template = null, $display = false) $representative = $this->getRepresentative(); $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ $templateMgr->assign([ - 'idTypeCodes' => $onixCodelistItemDao->getCodes('List92'), // GLN, etc - 'agentRoleCodes' => $onixCodelistItemDao->getCodes('List69'), // Sales Agent, etc - 'supplierRoleCodes' => $onixCodelistItemDao->getCodes('List93'), // wholesaler, publisher to retailer, etc + 'idTypeCodes' => $onixCodelistItemDao->getCodes('92'), // GLN, etc + 'agentRoleCodes' => $onixCodelistItemDao->getCodes('69'), // Sales Agent, etc + 'supplierRoleCodes' => $onixCodelistItemDao->getCodes('93'), // wholesaler, publisher to retailer, etc 'isSupplier' => true, ]); // default to 'supplier' on the form. @@ -160,7 +160,7 @@ public function fetch($request, $template = null, $display = false) 'phone' => $representative->getPhone(), 'email' => $representative->getEmail(), 'url' => $representative->getUrl(), - 'isSupplier' => $representative->getIsSupplier() ? true : false, + 'isSupplier' => (bool)$representative->getIsSupplier(), ]); } else { $templateMgr->assign('representativeIdType', '06'); @@ -225,7 +225,7 @@ public function execute(...$functionArgs) $representative->setPhone($this->getData('phone')); $representative->setEmail($this->getData('email')); $representative->setUrl($this->getData('url')); - $representative->setIsSupplier($this->getData('isSupplier') ? true : false); + $representative->setIsSupplier((bool)$this->getData('isSupplier')); if ($existingRepresentative) { $representativeDao->updateObject($representative); diff --git a/controllers/grid/catalogEntry/form/SalesRightsForm.php b/controllers/grid/catalogEntry/form/SalesRightsForm.php index 1988f980861..07ba5474002 100644 --- a/controllers/grid/catalogEntry/form/SalesRightsForm.php +++ b/controllers/grid/catalogEntry/form/SalesRightsForm.php @@ -169,8 +169,8 @@ public function fetch($request, $template = null, $display = false) $templateMgr->assign('publicationId', $this->getPublication()->getId()); $salesRights = $this->getSalesRights(); $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $templateMgr->assign('countryCodes', $onixCodelistItemDao->getCodes('List91')); // countries (CA, US, GB, etc) - $templateMgr->assign('regionCodes', $onixCodelistItemDao->getCodes('List49')); // regions (British Columbia, England, etc) + $templateMgr->assign('countryCodes', $onixCodelistItemDao->getCodes('91')); // countries (CA, US, GB, etc) + $templateMgr->assign('regionCodes', $onixCodelistItemDao->getCodes('49')); // regions (British Columbia, England, etc) if ($salesRights) { $templateMgr->assign('salesRightsId', $salesRights->getId()); @@ -199,7 +199,7 @@ public function fetch($request, $template = null, $display = false) $assignedTypes = array_diff($assignedTypes, [$salesRights->getType()]); } // allow existing codes to keep their value - $types = $onixCodelistItemDao->getCodes('List46', $assignedTypes); // ONIX list for these + $types = $onixCodelistItemDao->getCodes('46', $assignedTypes); // ONIX list for these $templateMgr->assign('salesRights', $types); } else { throw new Exception('Format not in authorized submission'); diff --git a/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php b/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php index 1a046e9e9d2..cd2ae596199 100644 --- a/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php +++ b/plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php @@ -391,7 +391,7 @@ public function createProductNode($doc, $submission, $publicationFormat) $languageNode = $doc->createElementNS($deployment->getNamespace(), 'Language'); $languageNode->appendChild($this->_buildTextNode($doc, 'LanguageRole', '01')); - $onixLanguageCode = $onixCodelistItemDao->getCodeFromValue($submission->getData('locale'), 'List74'); + $onixLanguageCode = $onixCodelistItemDao->getCodeFromValue($submission->getData('locale'), '74'); if ($onixLanguageCode != '') { $languageNode->appendChild($this->_buildTextNode($doc, 'LanguageCode', $onixLanguageCode)); $descDetailNode->appendChild($languageNode); diff --git a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php index db8e924758c..8e953bf64e2 100755 --- a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php +++ b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php @@ -3,8 +3,8 @@ /** * @file plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2000-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2000-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class Dc11SchemaPublicationFormatAdapter @@ -147,7 +147,7 @@ public function extractMetadataFromDataObject(&$publicationFormat) // Format $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO'); /** @var ONIXCodelistItemDAO $onixCodelistItemDao */ - $entryKeys = $onixCodelistItemDao->getCodes('List7'); // List7 is for object formats + $entryKeys = $onixCodelistItemDao->getCodes('150'); // List150 is for object formats if ($publicationFormat->getEntryKey()) { $formatName = $entryKeys[$publicationFormat->getEntryKey()]; $dc11Description->addStatement('dc:format', $formatName);