diff -r 31a4987f6017 -r 226d5b17a119 server/src/app/Models/DocumentBase.php --- a/server/src/app/Models/DocumentBase.php Sun Oct 09 11:44:18 2016 +0200 +++ b/server/src/app/Models/DocumentBase.php Tue Oct 11 02:49:59 2016 +0200 @@ -26,8 +26,8 @@ // memoization private $providedCHO = null; private $title = false; - private $lang = null; - private $langResolved = null; + private $langs = null; + private $langsResolved = null; private $issued = false; private $modified = false; private $created = false; @@ -43,8 +43,8 @@ protected function clearMemoizationCache() { $this->providedCHO = null; $this->title = false; - $this->lang = null; - $this->langResolved = null; + $this->langs = null; + $this->langsResolved = null; $this->issued = false; $this->modified = false; $this->created = false; @@ -65,36 +65,33 @@ return $this->id; } - public function getLanguage() { - if(is_null($this->lang)) { + public function getLanguages() { + if(is_null($this->langs)) { try { - $langs = $this->getProvidedCHO()->all(''); - if(count($langs) > 0) { - $this->lang = $langs[0]; - } + $this->langs = $this->getProvidedCHO()->all(''); } catch(\Exception $e) { - $this->lang = null; + $this->langs = []; } } - return $this->lang; + return $this->langs; } - public function getLanguageValue() { - $lang = $this->getLanguage(); - if($lang instanceof Resource) { - return $lang->getUri(); - } else if($lang instanceof Literal) { - return $lang->getValue(); - } - return null; + public function getLanguagesValue() { + return array_map(function($lang) { + if($lang instanceof Resource) { + return $lang->getUri(); + } else if($lang instanceof Literal) { + return $lang->getValue(); + } + }, $this->getLanguages()); } - public function getLanguageResolved() { - return $this->langResolved; + public function getLanguagesResolved() { + return $this->langsResolved; } - public function setLanguageResolved($languageResolved) { - $this->langResolved = $languageResolved; + public function setLanguagesResolved($languagesResolved) { + $this->langsResolved = $languagseResolved; } @@ -181,7 +178,7 @@ $newModified = new Literal($value, null, "http://purl.org/dc/terms/W3CDTF"); $this->setSimpleProperty($this->getProvidedCHO(), 'http://purl.org/dc/terms/modified', $modified, $newModified); - $this->modified = null; + $this->modified = false; } } @@ -202,12 +199,12 @@ 'id' => $this->getId(), 'uri' => $this->getUri(), 'title' => $this->getTitleValue(), - 'language' => $this->getLanguageValue(), + 'languages' => $this->getLanguagesValue(), 'modified' => $this->getModifiedValue(), 'issued' => $this->getIssuedValue() ]; - if($this->language_resolved) { - $res['language_resolved'] = $this->getLanguageResolved(); + if($this->languagesResolved) { + $res['languages_resolved'] = $this->getLanguagesResolved(); } return $res;