Author: david
Date: Fri Feb 10 12:15:25 2012
New Revision: 10849

Log:
Add title field

Modified:
   trunk/lib/QubitSearchPdo.class.php

Modified: trunk/lib/QubitSearchPdo.class.php
==============================================================================
--- trunk/lib/QubitSearchPdo.class.php  Fri Feb 10 12:04:05 2012        (r10848)
+++ trunk/lib/QubitSearchPdo.class.php  Fri Feb 10 12:15:25 2012        (r10849)
@@ -167,6 +167,19 @@
     $doc->addField(Zend_Search_Lucene_Field::UnIndexed('parent_id', 
$resource->parent_id));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('parent', 
$resource->parent->slug));
 
+    // Title
+    // include an i18n fallback for proper search result display in case the
+    // title field was not translated
+    if (0 < strlen($resource->title))))
+    {
+      $resource->title = getFallbackTitle($resource->id);
+    }
+
+    // Boost the hit relevance for the title field
+    $titleField = Zend_Search_Lucene_Field::Text('title', $resource->title);
+    $titleField->boost = 10;
+    $doc->addField($titleField);
+
     // Scope and content (stored for retrival in search results)
     $doc->addField(Zend_Search_Lucene_Field::Text('scopeAndContent', 
$resource->scope_and_content));
 
@@ -251,21 +264,6 @@
       $doc->addField(Zend_Search_Lucene_Field::Keyword('hasDigitalObject', 
'false'));
     }
 
-    // Title
-    // include an i18n fallback for proper search result display in case the 
title field was not translated
-    if (0 < strlen($resource->getTitle(array('culture' => $language))))
-    {
-      $titleField = Zend_Search_Lucene_Field::Text('title', 
$resource->getTitle(array('culture' => $language)));
-    }
-    else
-    {
-      $titleField = Zend_Search_Lucene_Field::Text('title', 
$resource->getTitle(array('sourceCulture' => true)));
-    }
-
-    // Boost the hit relevance for the title field
-    $titleField->boost = 10;
-    $doc->addField($titleField);
-
     // Publication status
     $doc->addField(Zend_Search_Lucene_Field::Text('publicationStatusId', 
$resource->getPublicationStatus()->status->id));
 
@@ -382,4 +380,24 @@
     // To come:
     // Add all dynamic metadata fields to index
   }
+
+  protected static function getFallbackTitle($id)
+  {
+    // Get info objects (with offset)
+    $sql  = 'SELECT i18n.title';
+    $sql .= ' FROM '.QubitInformationObject::TABLE_NAME.' node';
+    $sql .= ' JOIN '.QubitInformationObjectI18n::TABLE_NAME.' i18n';
+    $sql .= '   ON node.id = i18n.id';
+    $sql .= ' WHERE id = ?';
+
+    $statement = $conn->prepare($sql);
+    $statement->execute(array($id)))
+    $result = $statement->fetch(PDO::FETCH_OBJ);
+
+    if (null != $result)
+    {
+      return $result->title;
+    }
+  }
 }
+

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to