Author: jablko
Date: Thu Aug 27 14:00:17 2009
New Revision: 3098

Log:
Instantiate information objects in search action instead of template, 
incidentally using one SQL query. Drop no longer used un indexed fields from 
search index.

Modified:
   trunk/apps/qubit/lib/SearchIndex.class.php
   trunk/apps/qubit/modules/search/actions/searchAction.class.php
   trunk/apps/qubit/modules/search/templates/searchSuccess.php

Modified: trunk/apps/qubit/lib/SearchIndex.class.php
==============================================================================
--- trunk/apps/qubit/lib/SearchIndex.class.php  Thu Aug 27 13:45:18 2009        
(r3097)
+++ trunk/apps/qubit/lib/SearchIndex.class.php  Thu Aug 27 14:00:17 2009        
(r3098)
@@ -244,8 +244,6 @@
       //include an i18n fallback for proper search result display in case the 
title field was not translated
       $doc->addField(Zend_Search_Lucene_Field::UnIndexed('display_title', 
$informationObject->getTitle(array('sourceCulture' => true)), $encoding));
     }
-    // Store an unindexed, case-sensitive label for use in hit display
-    $doc->addField(Zend_Search_Lucene_Field::UnIndexed('display_label', 
QubitIsad::getLabel($informationObject, array('culture' => $language)), 
$encoding));
 
     // LEVEL OF DESCRIPTION
     $doc->addField(Zend_Search_Lucene_Field::Unstored('levelofdescription', 
strtolower($informationObject->getLevelOfDescription(array('culture' => 
$language))), $encoding));
@@ -267,8 +265,6 @@
 
     // SCOPE AND CONTENT
     $doc->addField(Zend_Search_Lucene_Field::Unstored('scopeandcontent', 
strtolower($informationObject->getScopeAndContent(array('culture' => 
$language))), $encoding));
-    //store an unindexed, case-sensitive copy of the scope & content field for 
use in hit display
-    
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('display_scopeandcontent', 
$informationObject->getScopeAndContent(array('culture' => $language)), 
$encoding));
 
     // REPOSITORY
     $repository = $informationObject->getRepository(array('inherit' => true));

Modified: trunk/apps/qubit/modules/search/actions/searchAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/searchAction.class.php      Thu Aug 
27 13:45:18 2009        (r3097)
+++ trunk/apps/qubit/modules/search/actions/searchAction.class.php      Thu Aug 
27 14:00:17 2009        (r3098)
@@ -37,5 +37,15 @@
     
$query->addSubquery(Zend_Search_Lucene_Search_QueryParser::parse($request->query,
 'UTF-8'), true);
 
     $this->pager = new 
QubitSearchPager($search->getEngine()->getIndex()->find($query), 
$request->page);
+
+    $ids = array();
+    foreach ($this->pager->getHits() as $hit)
+    {
+      $ids[] = $hit->informationObjectId;
+    }
+
+    $criteria = new Criteria;
+    $criteria->add(QubitInformationObject::ID, $ids, Criteria::IN);
+    $this->informationObjects = QubitInformationObject::get($criteria);
   }
 }

Modified: trunk/apps/qubit/modules/search/templates/searchSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/searchSuccess.php Thu Aug 27 
13:45:18 2009        (r3097)
+++ trunk/apps/qubit/modules/search/templates/searchSuccess.php Thu Aug 27 
14:00:17 2009        (r3098)
@@ -3,25 +3,20 @@
   <h1 class="search"><?php echo __("Search for '%1%' returned %2% results", 
array('%1%' => $sf_request->query, '%2%' => count($pager->allHits))); ?></h1>
 <?php endif; ?>
 
-<?php foreach ($pager->getHits() as $hit): ?>
+<?php foreach ($informationObjects as $informationObject): ?>
   <div class="search-results" style="padding-top: 5px;">
 
-    <h3><?php echo link_to($hit->display_label, array('module' => 
'informationobject', 'action' => 'show', 'id' => $hit->informationObjectId)) 
?></h3>
+    <h3><?php echo link_to(render_title($informationObject), array('module' => 
'informationobject', 'action' => 'show', 'id' => $informationObject->id)) 
?></h3>
 
     <div class="CRUD_summary">
-    <?php if (in_array('display_scopeandcontent', 
$hit->getDocument()->getFieldNames()) && 0 < 
strlen($hit->display_scopeandcontent)): ?>
-      <?php echo highlight_text(truncate_text($hit->display_scopeandcontent, 
250), $sf_request->query) ?><br />
-    <?php endif; ?>
+      <?php echo 
highlight_text(truncate_text($informationObject->scopeAndContent, 250), 
$sf_request->query) ?><br />
 
-    <?php $informationObject = 
QubitInformationObject::getById($hit->informationObjectId) ?>
     <?php if ($informationObject->getCollectionRoot()->id != 
$informationObject->id): ?>
       <?php echo __('Part of').': 
'.link_to(render_title($informationObject->getCollectionRoot()), array('module' 
=> 'informationobject', 'action' => 'show', 'id' => 
$informationObject->getCollectionRoot()->id)) ?><br />
     <?php endif; ?>
 
-    <?php if (sfConfig::get('app_multi_repository') && 
in_array('repositoryid', $hit->getDocument()->getFieldNames()) && 0 < 
intval($hit->repositoryid)): ?>
-      <?php $repository = QubitRepository::getById($hit->repositoryid) ?>
-      <?php echo __('Repository').': 
'.link_to($repository->getAuthorizedFormOfName(array('cultureFallback' => 
true)),
-        array('module' => 'repository', 'action' => 'show', 'id' => 
$repository->getId())) ?><br />
+    <?php if (sfConfig::get('app_multi_repository') && 
isset($informationObject->repository)): ?>
+      <?php echo __('Repository').': '.link_to(render_title($repository), 
array('module' => 'repository', 'action' => 'show', 'id' => $repository->id)) 
?><br />
     <?php endif; ?>
     </div>
 

--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to