server/src/app/Models/Document.php
changeset 500 4f507ba2bb4c
parent 498 265992e5b379
child 501 7b2dcd2b31c1
--- a/server/src/app/Models/Document.php	Mon Feb 06 14:36:25 2017 +0100
+++ b/server/src/app/Models/Document.php	Mon Feb 06 15:22:39 2017 +0100
@@ -32,6 +32,7 @@
     private $types = null;
     private $descriptions = null;
     private $geoInfo = false;
+    private $alternativeTitle = false;
 
     protected function clearMemoizationCache() {
         parent::clearMemoizationCache();
@@ -313,7 +314,7 @@
 
 
     /**
-     * Get subjects list
+     * Get descriptions
      */
     public function getDescriptions() {
         if(is_null($this->descriptions)) {
@@ -325,6 +326,24 @@
         return $this->descriptions;
     }
 
+    /**
+     * Get Alternative Title
+     */
+    public function getAlternativeTitle() {
+        if($this->alternativeTitle === false) {
+            try {
+                $this->alternativeTitle = $this->getProvidedCHO()->getLiteral('<http://purl.org/dc/terms/alternative>');
+            } catch(\Exception $e) {
+                $this->alternativeTitle = null;
+            }
+        }
+        return $this->alternativeTitle;
+    }
+
+    public function getAlternativeTitleValue() {
+        $alternativeTitle = $this->getAlternativeTitle();
+        return is_null($alternativeTitle)?null:$alternativeTitle->getValue();
+    }
 
     public function isIsomorphic($doc) {
         return Isomorphic::isomorphic($this->graph, $doc->graph);
@@ -387,7 +406,8 @@
                 'transcript' => $transcript,
                 'mediaArray'=> $mediaArray,
                 'geoInfo' => $geoInfo,
-                'descriptions' => $descriptions
+                'descriptions' => $descriptions,
+                'alternativeTitle' => $this->getAlternativeTitleValue(),
             ]);
 
         }