author | ymh <ymh.work@gmail.com> |
Mon, 12 Jun 2017 14:53:59 +0200 | |
changeset 537 | d2e6ee099125 |
parent 503 | bd2701bd8142 |
permissions | -rw-r--r-- |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
namespace CorpusParole\Models; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
use Config; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
use CorpusParole\Libraries\Utils; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
use CorpusParole\Libraries\CocoonUtils; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
use CorpusParole\Libraries\RdfModel\RdfModelResource; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
use JsonSerializable; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
use Log; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
use EasyRdf\Literal; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
use EasyRdf\Resource; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
use EasyRdf\Graph; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
/** |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
*/ |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
class DocumentBase extends RdfModelResource implements JsonSerializable { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
public function __construct($uri, $graph = null) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
//print($graph->dump('html')); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
parent::__construct($uri, $graph); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
private $id = null; |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
25 |
private $cocoonId = null; |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
26 |
private $countryCode = false; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
// memoization |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
private $providedCHO = null; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
private $title = false; |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
31 |
private $langs = null; |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
32 |
private $langsResolved = null; |
325 | 33 |
private $issued = false; |
34 |
private $modified = false; |
|
35 |
private $created = false; |
|
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
public function getProvidedCHO() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
if(is_null($this->providedCHO)) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
$this->providedCHO = $this->get("<http://www.europeana.eu/schemas/edm/aggregatedCHO>"); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
return $this->providedCHO; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
protected function clearMemoizationCache() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
$this->providedCHO = null; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
$this->title = false; |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
47 |
$this->langs = null; |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
48 |
$this->langsResolved = null; |
325 | 49 |
$this->issued = false; |
50 |
$this->modified = false; |
|
51 |
$this->created = false; |
|
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
public function getId() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
if(is_null($this->id)) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
$ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>'); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
foreach ($ids as $id) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
if($id instanceof Literal && strpos($id->getValue(), config('corpusparole.corpus_id_scheme')) === 0) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
$this->id = $id->getValue(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
if(is_null($this->id)) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
$this->id = CocoonUtils::getIdFromCorpusUri($this->uri); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
return $this->id; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
|
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
69 |
public function getCocoonId() { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
70 |
if(is_null($this->cocoonId)) { |
503
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
71 |
$this->cocoonId = CocoonUtils::getCocoonIdFromCorpusUri($this->uri); |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
72 |
if(is_null($this->cocoonId)) { |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
73 |
$ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>'); |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
74 |
foreach ($ids as $id) { |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
75 |
if($id instanceof Literal && strpos($id->getValue(), config('corpusparole.cocoon_doc_id_base')) === 0) { |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
76 |
$this->cocoonId = substr($id->getValue(), strlen(config('corpusparole.cocoon_doc_id_base'))); |
bd2701bd8142
Do not get cocoonId from identifier but from graph url
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
77 |
} |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
78 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
79 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
80 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
81 |
return $this->cocoonId; |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
82 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
83 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
84 |
public function getLanguages() { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
85 |
if(is_null($this->langs)) { |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
try { |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
87 |
$this->langs = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/language>'); |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
} catch(\Exception $e) { |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
89 |
$this->langs = []; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
} |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
92 |
return $this->langs; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
95 |
public function getLanguagesValue() { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
96 |
return array_map(function($lang) { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
97 |
if($lang instanceof Resource) { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
98 |
return $lang->getUri(); |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
99 |
} else if($lang instanceof Literal) { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
100 |
return $lang->getValue(); |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
101 |
} |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
102 |
}, $this->getLanguages()); |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
105 |
public function getLanguagesResolved() { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
106 |
return $this->langsResolved; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
109 |
public function setLanguagesResolved($languagesResolved) { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
110 |
$this->langsResolved = $languagseResolved; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
public function getTitle() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
if($this->title === false) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
try { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
$this->title = $this->getProvidedCHO()->getLiteral('<http://purl.org/dc/elements/1.1/title>'); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
} catch(\Exception $e) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
$this->title = null; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
return $this->title; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
public function setTitle($value, $lang="fr") { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
$oldTitle = $this->getTitle(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
if($oldTitle && $oldTitle->getValue() != $value && $oldTitle->getLang() != $lang) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
$literalTitle = new Literal($value, $lang, null); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
$this->setSimpleProperty($this->getProvidedCHO(), 'http://purl.org/dc/elements/1.1/title', $oldTitle, $literalTitle); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
//clear cache |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
$this->title = false; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
public function getTitleValue() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
$title = $this->getTitle(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
return is_null($title)?null:$title->getValue(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
public function getIssued() { |
325 | 143 |
if($this->issued === false) { |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
try { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
$this->issued = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/issued>"); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
} catch(\Exception $e) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
$this->issued = null; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
return $this->issued; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
public function getIssuedValue() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
$issued = $this->getIssued(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
return is_null($issued)?null:$issued->getValue(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
|
325 | 158 |
public function getCreated() { |
159 |
if($this->created === false) { |
|
160 |
try { |
|
161 |
$this->created = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/created>"); |
|
162 |
} catch(\Exception $e) { |
|
163 |
$this->created = null; |
|
164 |
} |
|
165 |
} |
|
166 |
return $this->created; |
|
167 |
} |
|
168 |
||
445
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
169 |
public function getCreatedValue() { |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
170 |
$created = $this->getCreated(); |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
171 |
return is_null($created)?null:$created->getValue(); |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
172 |
} |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
173 |
|
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
174 |
|
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
public function getModified() { |
325 | 176 |
if($this->modified === false) { |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
try { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
$this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>"); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
if(is_null($this->modified)) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
$this->modified = $this->getIssued(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
} catch(\Exception $e) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
$this->modified = null; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
return $this->modified; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
public function setModified($value = null) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
if(is_null($value)) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
$value = gmdate(\DateTime::ATOM); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
} elseif ($value instanceof \DateTime) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
$value = $value->format(\DateTime::ATOM); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
$value = preg_replace('/[\+\-]00(\:?)00$/', 'Z', $value); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
$modified = $this->getModified(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
if($value && (!$modified || $modified->getValue() !== $value) ) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
$newModified = new Literal($value, null, "http://purl.org/dc/terms/W3CDTF"); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
$this->setSimpleProperty($this->getProvidedCHO(), 'http://purl.org/dc/terms/modified', $modified, $newModified); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
203 |
$this->modified = false; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
public function getModifiedValue() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
$modified = $this->getModified(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
return is_null($modified)?null:$modified->getValue(); |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
|
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
213 |
public function getCountryCode() { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
214 |
return $this->countryCode; |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
215 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
216 |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
217 |
public function setCountryCode($code) { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
218 |
$this->countryCode = $code; |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
219 |
} |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
220 |
|
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
221 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
222 |
public function jsonSerialize() { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
223 |
if(!$this->graph) { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
return [ |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
225 |
'id' => $this->getId(), |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
226 |
]; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
227 |
} else { |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
228 |
$res = [ |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
229 |
'id' => $this->getId(), |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
230 |
'cocoonId' => $this->getCocoonId(), |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
231 |
'uri' => $this->getUri(), |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
232 |
'title' => $this->getTitleValue(), |
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
233 |
'languages' => $this->getLanguagesValue(), |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
234 |
'modified' => $this->getModifiedValue(), |
445
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
235 |
'issued' => $this->getIssuedValue(), |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
236 |
'created' => $this->getCreatedValue() |
b1e5ad6b2a29
Display created date instead of issued
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
237 |
]; |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
238 |
|
326
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
239 |
if($this->languagesResolved) { |
226d5b17a119
- First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents:
325
diff
changeset
|
240 |
$res['languages_resolved'] = $this->getLanguagesResolved(); |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
241 |
} |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
242 |
if($this->getCountryCode() !== false) { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
243 |
$res['countryCode'] = $this->getCountryCode(); |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
244 |
} |
260
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
245 |
|
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
246 |
return $res; |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
247 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
248 |
} |
64caee7ce38d
Split document model in document and document results
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
249 |
} |