Skip to content

Commit 80b79ca

Browse files
committed
Line continuation
1 parent c0ac155 commit 80b79ca

File tree

1 file changed

+76
-36
lines changed

1 file changed

+76
-36
lines changed

DCAT.php

Lines changed: 76 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function makeDataBlob(){
7171
* @param string $dumpDate the date of the dumpfile, null for live data
7272
*/
7373
function dumpDistributionExtras(XMLWriter $xml, $data, $dumpDate){
74-
$url = str_replace( '$1', "$dumpDate.json.gz", $data['config']['dump-info']['accessURL'] );
74+
$url = str_replace( '$1', "$dumpDate.json.gz",
75+
$data['config']['dump-info']['accessURL'] );
7576

7677
$xml->startElementNS( 'dcat', 'accessURL', null );
7778
$xml->writeAttributeNS( 'rdf', 'resource', null, $url );
@@ -81,10 +82,12 @@ function dumpDistributionExtras(XMLWriter $xml, $data, $dumpDate){
8182
$xml->writeAttributeNS( 'rdf', 'resource', null, $url );
8283
$xml->endElement();
8384

84-
$xml->writeElementNS( 'dcterms', 'issued', null, $data['dumps'][$dumpDate]['timestamp'] );
85+
$xml->writeElementNS( 'dcterms', 'issued', null,
86+
$data['dumps'][$dumpDate]['timestamp'] );
8587

8688
$xml->startElementNS( 'dcat', 'byteSize', null );
87-
$xml->writeAttributeNS( 'rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#decimal' );
89+
$xml->writeAttributeNS( 'rdf', 'datatype', null,
90+
'http://www.w3.org/2001/XMLSchema#decimal' );
8891
$xml->text( $data['dumps'][$dumpDate]['byteSize'] );
8992
$xml->endElement();
9093
}
@@ -111,16 +114,19 @@ function writeDistribution(XMLWriter $xml, $data, $distribId, $prefix, $dumpDate
111114
$xml->writeAttributeNS( 'rdf', 'about', null, $id );
112115

113116
$xml->startElementNS( 'rdf', 'type', null );
114-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Distribution' );
117+
$xml->writeAttributeNS( 'rdf', 'resource', null,
118+
'http://www.w3.org/ns/dcat#Distribution' );
115119
$xml->endElement();
116120

117121
$xml->startElementNS( 'dcterms', 'license', null );
118-
$xml->writeAttributeNS( 'rdf', 'resource', null, $data['config']["$prefix-info"]['license'] );
122+
$xml->writeAttributeNS( 'rdf', 'resource', null,
123+
$data['config']["$prefix-info"]['license'] );
119124
$xml->endElement();
120125

121126
if ( is_null( $dumpDate ) ) {
122127
$xml->startElementNS( 'dcat', 'accessURL', null );
123-
$xml->writeAttributeNS( 'rdf', 'resource', null, $data['config']["$prefix-info"]['accessURL'] );
128+
$xml->writeAttributeNS( 'rdf', 'resource', null,
129+
$data['config']["$prefix-info"]['accessURL'] );
124130
$xml->endElement();
125131
}
126132
else {
@@ -156,7 +162,9 @@ function writeDistribution(XMLWriter $xml, $data, $distribId, $prefix, $dumpDate
156162
* @param string $contactPoint the nodeId of the contactPoint
157163
* @param array $distribution array of the distribution identifiers
158164
*/
159-
function writeDataset(XMLWriter $xml, $data, $dumpDate, $datasetId, $publisher, $contactPoint, $distribution){
165+
function writeDataset(XMLWriter $xml, $data, $dumpDate, $datasetId,
166+
$publisher, $contactPoint, $distribution){
167+
160168
$type = 'dump';
161169
if ( is_null( $dumpDate ) ) {
162170
$type = 'live';
@@ -168,7 +176,8 @@ function writeDataset(XMLWriter $xml, $data, $dumpDate, $datasetId, $publisher,
168176
$xml->writeAttributeNS( 'rdf', 'about', null, $id );
169177

170178
$xml->startElementNS( 'rdf', 'type', null );
171-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Dataset' );
179+
$xml->writeAttributeNS( 'rdf', 'resource', null,
180+
'http://www.w3.org/ns/dcat#Dataset' );
172181
$xml->endElement();
173182

174183
$xml->startElementNS( 'adms', 'contactPoint', null );
@@ -181,7 +190,8 @@ function writeDataset(XMLWriter $xml, $data, $dumpDate, $datasetId, $publisher,
181190

182191
if ( $type === 'live' ) {
183192
$xml->startElementNS( 'dcterms', 'accrualPeriodicity', null );
184-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://purl.org/cld/freq/continuous' );
193+
$xml->writeAttributeNS( 'rdf', 'resource', null,
194+
'http://purl.org/cld/freq/continuous' );
185195
$xml->endElement();
186196
}
187197

@@ -193,7 +203,8 @@ function writeDataset(XMLWriter $xml, $data, $dumpDate, $datasetId, $publisher,
193203
// add themes
194204
foreach ( $data['config']['themes'] as $key => $keyword ) {
195205
$xml->startElementNS( 'dcat', 'theme', null );
196-
$xml->writeAttributeNS( 'rdf', 'resource', null, "http://eurovoc.europa.eu/$keyword" );
206+
$xml->writeAttributeNS( 'rdf', 'resource', null,
207+
"http://eurovoc.europa.eu/$keyword" );
197208
$xml->endElement();
198209
}
199210

@@ -243,19 +254,24 @@ function writePublisher(XMLWriter $xml, $data, $publisher){
243254
$xml->writeAttributeNS( 'rdf', 'nodeID', null, $publisher );
244255

245256
$xml->startElementNS( 'rdf', 'type', null );
246-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://xmlns.com/foaf/0.1/Agent' );
257+
$xml->writeAttributeNS( 'rdf', 'resource', null,
258+
'http://xmlns.com/foaf/0.1/Agent' );
247259
$xml->endElement();
248260

249-
$xml->writeElementNS( 'foaf', 'name', null, $data['config']['publisher']['name'] );
261+
$xml->writeElementNS( 'foaf', 'name', null,
262+
$data['config']['publisher']['name'] );
250263

251264
$xml->startElementNS( 'dcterms', 'type', null );
252-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://purl.org/adms/publishertype/'.$data['config']['publisher']['publisherType'] );
265+
$xml->writeAttributeNS( 'rdf', 'resource', null,
266+
'http://purl.org/adms/publishertype/'.$data['config']['publisher']['publisherType'] );
253267
$xml->endElement();
254268

255-
$xml->writeElementNS( 'foaf', 'homepage', null, $data['config']['publisher']['homepage'] );
269+
$xml->writeElementNS( 'foaf', 'homepage', null,
270+
$data['config']['publisher']['homepage'] );
256271

257272
$xml->startElementNS( 'vcard', 'hasEmail', null );
258-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'mailto:'.$data['config']['publisher']['email'] );
273+
$xml->writeAttributeNS( 'rdf', 'resource', null,
274+
'mailto:'.$data['config']['publisher']['email'] );
259275
$xml->endElement();
260276

261277
$xml->endElement();
@@ -273,14 +289,17 @@ function writeContactPoint(XMLWriter $xml, $data, $contactPoint){
273289
$xml->writeAttributeNS( 'rdf', 'nodeID', null, $contactPoint );
274290

275291
$xml->startElementNS( 'rdf', 'type', null );
276-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://www.w3.org/2006/vcard/ns#'.$data['config']['contactPoint']['vcardType'] );
292+
$xml->writeAttributeNS( 'rdf', 'resource', null,
293+
'http://www.w3.org/2006/vcard/ns#'.$data['config']['contactPoint']['vcardType'] );
277294
$xml->endElement();
278295

279296
$xml->startElementNS( 'vcard', 'hasEmail', null );
280-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'mailto:'.$data['config']['contactPoint']['email'] );
297+
$xml->writeAttributeNS( 'rdf', 'resource', null,
298+
'mailto:'.$data['config']['contactPoint']['email'] );
281299
$xml->endElement();
282300

283-
$xml->writeElementNS( 'vcard', 'fn', null, $data['config']['contactPoint']['name'] );
301+
$xml->writeElementNS( 'vcard', 'fn', null,
302+
$data['config']['contactPoint']['name'] );
284303

285304
$xml->endElement();
286305
}
@@ -295,23 +314,29 @@ function writeContactPoint(XMLWriter $xml, $data, $contactPoint){
295314
*/
296315
function writeCatalog(XMLWriter $xml, $data, $publisher, $dataset){
297316
$xml->startElementNS( 'rdf', 'Description', null );
298-
$xml->writeAttributeNS( 'rdf', 'about', null, $data['config']['uri'].'#catalog' );
317+
$xml->writeAttributeNS( 'rdf', 'about', null,
318+
$data['config']['uri'].'#catalog' );
299319

300320
$xml->startElementNS( 'rdf', 'type', null );
301-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Catalog' );
321+
$xml->writeAttributeNS( 'rdf', 'resource', null,
322+
'http://www.w3.org/ns/dcat#Catalog' );
302323
$xml->endElement();
303324

304325
$xml->startElementNS( 'dcterms', 'license', null );
305-
$xml->writeAttributeNS( 'rdf', 'resource', null, $data['config']['catalog-license'] );
326+
$xml->writeAttributeNS( 'rdf', 'resource', null,
327+
$data['config']['catalog-license'] );
306328
$xml->endElement();
307329

308330
$xml->startElementNS( 'dcat', 'themeTaxonomy', null );
309-
$xml->writeAttributeNS( 'rdf', 'resource', null, 'http://eurovoc.europa.eu/' );
331+
$xml->writeAttributeNS( 'rdf', 'resource', null,
332+
'http://eurovoc.europa.eu/' );
310333
$xml->endElement();
311334

312-
$xml->writeElementNS( 'foaf', 'homepage', null, 'https://www.wikidata.org' );
335+
$xml->writeElementNS( 'foaf', 'homepage', null,
336+
'https://www.wikidata.org' );
313337
$xml->writeElementNS( 'dcterms', 'modified', null, date( 'Y-m-d' ) );
314-
$xml->writeElementNS( 'dcterms', 'issued', null, $data['config']['catalog-issued'] );
338+
$xml->writeElementNS( 'dcterms', 'issued', null,
339+
$data['config']['catalog-issued'] );
315340

316341
$xml->startElementNS( 'dcterms', 'publisher', null );
317342
$xml->writeAttributeNS( 'rdf', 'nodeID', null, $publisher );
@@ -320,7 +345,8 @@ function writeCatalog(XMLWriter $xml, $data, $publisher, $dataset){
320345
// add language, title and description in each language
321346
foreach ( $data['i18n'] as $langCode => $langData ) {
322347
$xml->startElementNS( 'dcterms', 'language', null );
323-
$xml->writeAttributeNS( 'rdf', 'resource', null, "http://id.loc.gov/vocabulary/iso639-1/$langCode" );
348+
$xml->writeAttributeNS( 'rdf', 'resource', null,
349+
"http://id.loc.gov/vocabulary/iso639-1/$langCode" );
324350
$xml->endElement();
325351

326352
if ( array_key_exists( 'catalog-title', $langData ) ) {
@@ -366,12 +392,18 @@ function outputXml($data){
366392
// set namespaces
367393
$xml->startDocument( '1.0', 'UTF-8' );
368394
$xml->startElementNS( 'rdf', 'RDF', null );
369-
$xml->writeAttributeNS( 'xmlns', 'rdf', null, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' );
370-
$xml->writeAttributeNS( 'xmlns', 'dcterms', null, 'http://purl.org/dc/terms/' );
371-
$xml->writeAttributeNS( 'xmlns', 'dcat', null, 'http://www.w3.org/ns/dcat#' );
372-
$xml->writeAttributeNS( 'xmlns', 'foaf', null, 'http://xmlns.com/foaf/0.1/' );
373-
$xml->writeAttributeNS( 'xmlns', 'adms', null, 'http://www.w3.org/ns/adms#' );
374-
$xml->writeAttributeNS( 'xmlns', 'vcard', null, 'http://www.w3.org/2006/vcard/ns#' );
395+
$xml->writeAttributeNS( 'xmlns', 'rdf', null,
396+
'http://www.w3.org/1999/02/22-rdf-syntax-ns#' );
397+
$xml->writeAttributeNS( 'xmlns', 'dcterms', null,
398+
'http://purl.org/dc/terms/' );
399+
$xml->writeAttributeNS( 'xmlns', 'dcat', null,
400+
'http://www.w3.org/ns/dcat#' );
401+
$xml->writeAttributeNS( 'xmlns', 'foaf', null,
402+
'http://xmlns.com/foaf/0.1/' );
403+
$xml->writeAttributeNS( 'xmlns', 'adms', null,
404+
'http://www.w3.org/ns/adms#' );
405+
$xml->writeAttributeNS( 'xmlns', 'vcard', null,
406+
'http://www.w3.org/2006/vcard/ns#' );
375407

376408
// Calls previously declared functions to construct xml
377409
writePublisher( $xml, $data, $data['ids']['publisher'] );
@@ -380,22 +412,30 @@ function outputXml($data){
380412
$dataset = array ();
381413

382414
// Live dataset and distributions
383-
$liveDistribs = writeDistribution( $xml, $data, $data['ids']['liveDistribLD'], 'ld', null );
415+
$liveDistribs = writeDistribution( $xml, $data,
416+
$data['ids']['liveDistribLD'], 'ld', null );
384417
if ( $data['config']['api-enabled'] ) {
385418
$liveDistribs = array_merge( $liveDistribs,
386-
writeDistribution( $xml, $data, $data['ids']['liveDistribAPI'], 'api', null )
419+
writeDistribution( $xml, $data,
420+
$data['ids']['liveDistribAPI'], 'api', null )
387421
);
388422
}
389423
array_push( $dataset,
390-
writeDataset( $xml, $data, null, $data['ids']['liveDataset'], $data['ids']['publisher'], $data['ids']['contactPoint'], $liveDistribs )
424+
writeDataset( $xml, $data, null, $data['ids']['liveDataset'],
425+
$data['ids']['publisher'], $data['ids']['contactPoint'],
426+
$liveDistribs )
391427
);
392428

393429
// Dump dataset and distributions
394430
if ( $data['config']['dumps-enabled'] ) {
395431
foreach ( $data['dumps'] as $key => $value ) {
396-
$distIds = writeDistribution( $xml, $data, $data['ids']['dumpDistribPrefix'], 'dump', $key );
432+
$distIds = writeDistribution( $xml, $data,
433+
$data['ids']['dumpDistribPrefix'], 'dump', $key );
397434
array_push( $dataset,
398-
writeDataset( $xml, $data, $key, $data['ids']['dumpDatasetPrefix'], $data['ids']['publisher'], $data['ids']['contactPoint'], $distIds )
435+
writeDataset( $xml, $data, $key,
436+
$data['ids']['dumpDatasetPrefix'],
437+
$data['ids']['publisher'],
438+
$data['ids']['contactPoint'], $distIds )
399439
);
400440
}
401441
}

0 commit comments

Comments
 (0)