@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // doi |
| 36 | 36 | $metsDoi = $metsXml->xpath("//mods:identifier[@type='doi']"); |
| 37 | - if(!empty($metsDoi)) { |
|
| 37 | + if (!empty($metsDoi)) { |
|
| 38 | 38 | $dataCiteDoi = $metsDoi[0]; |
| 39 | 39 | } else { |
| 40 | 40 | $dataCiteDoi = '10.1000/1'; // http://www.doi.org/index.html as default |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | // creators |
| 44 | 44 | $metsCreator = $metsXml->xpath("//mods:name[@type='personal']"); |
| 45 | - $dataCiteCreator = array(); |
|
| 46 | - foreach($metsCreator as $creator) |
|
| 45 | + $dataCiteCreator = array (); |
|
| 46 | + foreach ($metsCreator as $creator) |
|
| 47 | 47 | { |
| 48 | 48 | $creator->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
| 49 | 49 | $role = $creator->xpath(".//mods:roleTerm[@type='code']"); |
| 50 | - if($role[0] != 'aut' && $role[0] != 'cmp') { |
|
| 50 | + if ($role[0] != 'aut' && $role[0] != 'cmp') { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | - $names = array(); |
|
| 53 | + $names = array (); |
|
| 54 | 54 | $givenName = $creator->xpath(".//mods:namePart[@type='given']"); |
| 55 | 55 | $familyName = $creator->xpath(".//mods:namePart[@type='family']"); |
| 56 | 56 | $creatorName = $creator->xpath(".//mods:namePart[@type='displayForm']"); |
| 57 | - if(empty($creatorName)) { |
|
| 58 | - if(!empty($givenName) && !empty($familyName)) { |
|
| 57 | + if (empty($creatorName)) { |
|
| 58 | + if (!empty($givenName) && !empty($familyName)) { |
|
| 59 | 59 | $creatorName = "<creatorName>{$familyName[0]}, {$givenName[0]}</creatorName>"; |
| 60 | 60 | } else { |
| 61 | 61 | $creatorName = ""; |
@@ -77,36 +77,36 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | // subtitles |
| 79 | 79 | $metsSubTitles = $metsXml->xpath("//mods:titleInfo[@usage='primary']/mods:subTitle"); |
| 80 | - foreach($metsSubTitles as $title) { |
|
| 80 | + foreach ($metsSubTitles as $title) { |
|
| 81 | 81 | $dataCiteTitle .= (!empty($title)) ? "<title titleType=\"Subtitle\">{$title}</title>" : ""; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // publisher |
| 85 | 85 | $metsPublisher = $metsXml->xpath("//mods:name[@type='corporate']"); |
| 86 | 86 | $dataCitePublisher = ''; |
| 87 | - foreach($metsPublisher as $corporation) { |
|
| 87 | + foreach ($metsPublisher as $corporation) { |
|
| 88 | 88 | $corporation->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
| 89 | 89 | $role = $corporation->xpath(".//mods:roleTerm[@type='code']"); |
| 90 | 90 | $role = (string) $role[0]; |
| 91 | 91 | $name = $corporation->xpath(".//mods:namePart"); |
| 92 | 92 | $name = (string) $name[0]; |
| 93 | - if($role == 'pbl') { |
|
| 93 | + if ($role == 'pbl') { |
|
| 94 | 94 | $dataCitePublisher = $name; |
| 95 | 95 | break; |
| 96 | - } elseif($role == 'dgg' || ($role == 'edt' && $dataCitePublisher == '')) { |
|
| 96 | + } elseif ($role == 'dgg' || ($role == 'edt' && $dataCitePublisher == '')) { |
|
| 97 | 97 | $dataCitePublisher = $name; |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // publication year |
| 102 | 102 | $metsPublicationYear = $metsXml->xpath("//mods:originInfo[@eventType='publication']/mods:dateIssued"); |
| 103 | - if(!empty($metsPublicationYear)) { |
|
| 103 | + if (!empty($metsPublicationYear)) { |
|
| 104 | 104 | $dataCitePublicationYear = $metsPublicationYear[0]; |
| 105 | 105 | } else { |
| 106 | 106 | $metsPublicationYear = $metsXml->xpath("//mods:originInfo/mods:dateIssued"); |
| 107 | 107 | $dataCitePublicationYear = (!empty($metsPublicationYear)) ? $metsPublicationYear[0] : ""; |
| 108 | 108 | } |
| 109 | - if(strlen($dataCitePublicationYear) != 4) { |
|
| 109 | + if (strlen($dataCitePublicationYear) != 4) { |
|
| 110 | 110 | $dataCitePublicationYear = substr($dataCitePublicationYear, 0, 4); |
| 111 | 111 | } |
| 112 | 112 | $dataCitePublicationYear = (preg_match('/(19|20)\d{2}/', $dataCitePublicationYear)) ? $dataCitePublicationYear : ""; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // subjects |
| 115 | 115 | $metsSubjects = $metsXml->xpath("//mods:classification[@authority='z']"); |
| 116 | 116 | $dataCiteSubjects = ''; |
| 117 | - foreach(GeneralUtility::trimExplode(',', $metsSubjects[0]) as $subject) { |
|
| 117 | + foreach (GeneralUtility::trimExplode(',', $metsSubjects[0]) as $subject) { |
|
| 118 | 118 | $dataCiteSubjects .= "<subject>{$subject}</subject>"; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -16,8 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
| 18 | 18 | |
| 19 | -class DataCiteXml |
|
| 20 | -{ |
|
| 19 | +class DataCiteXml { |
|
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * Generates DataCite.xml from a given METS.xml |
@@ -25,8 +24,7 @@ discard block |
||
| 25 | 24 | * @param string $metsXml |
| 26 | 25 | * @return string $dataCiteXml |
| 27 | 26 | */ |
| 28 | - public static function convertFromMetsXml($metsXml) |
|
| 29 | - { |
|
| 27 | + public static function convertFromMetsXml($metsXml) { |
|
| 30 | 28 | |
| 31 | 29 | $metsXml = simplexml_load_string($metsXml, NULL, NULL, "http://www.w3.org/2001/XMLSchema-instance"); |
| 32 | 30 | $metsXml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
@@ -43,8 +41,7 @@ discard block |
||
| 43 | 41 | // creators |
| 44 | 42 | $metsCreator = $metsXml->xpath("//mods:name[@type='personal']"); |
| 45 | 43 | $dataCiteCreator = array(); |
| 46 | - foreach($metsCreator as $creator) |
|
| 47 | - { |
|
| 44 | + foreach($metsCreator as $creator) { |
|
| 48 | 45 | $creator->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
| 49 | 46 | $role = $creator->xpath(".//mods:roleTerm[@type='code']"); |
| 50 | 47 | if($role[0] != 'aut' && $role[0] != 'cmp') { |