Author: jablko
Date: Mon Aug 24 15:38:11 2009
New Revision: 3066
Log:
Use search index for information object list
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
trunk/apps/qubit/modules/informationobject/templates/listSuccess.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Mon Aug 24 13:57:08 2009 (r3065)
+++ trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Mon Aug 24 15:38:11 2009 (r3066)
@@ -69,40 +69,21 @@
$this->forward404();
}
- $options = array();
- $this->repositoryId = 0;
-
$request->setAttribute('informationObject', $this->informationObject);
- $options['parentId'] = $request->id;
-
- // Set culture and cultural fallback flag
- $this->culture = $this->getUser()->getCulture();
- $options['cultureFallback'] = true; // Do cultural fallback
-
- // Set sort
- $this->sort = $this->getRequestParameter('sort', 'titleUp');
- $options['sort'] = $this->sort;
+ $search = new QubitSearch;
+ $query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term($request->id, 'parentId'));
- // Set current page
- $this->page = $this->getRequestParameter('page', 1);
- $options['page'] = $this->page;
-
- // Filter by repository
- if ($this->getRequestParameter('repository'))
- {
- $this->repositoryId = $this->getRequestParameter('repository');
- $options['repositoryId'] = $this->repositoryId;
- }
+ $this->pager = new
QubitSearchPager($search->getEngine()->getIndex()->find($query),
$request->page);
- // Filter by collection type
- if ($this->getRequestParameter('collectionType'))
+ $ids = array();
+ foreach ($this->pager->getHits() as $hit)
{
- $this->collectionType = $this->getRequestParameter('collectionType');
- $options['collectionType'] = $this->collectionType;
+ $ids[] = $hit->informationObjectId;
}
- // Get QubitQuery collection of information objects (with pagination,
fallback and sorting)
- $this->informationObjects = QubitInformationObject::getList($options);
+ $criteria = new Criteria;
+ $criteria->add(QubitInformationObject::ID, $ids, Criteria::IN);
+ $this->informationObjects = QubitInformationObject::get($criteria);
}
}
Modified: trunk/apps/qubit/modules/informationobject/templates/listSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/listSuccess.php
Mon Aug 24 13:57:08 2009 (r3065)
+++ trunk/apps/qubit/modules/informationobject/templates/listSuccess.php
Mon Aug 24 15:38:11 2009 (r3066)
@@ -40,7 +40,7 @@
</tr>
</thead>
<tbody>
-<?php foreach ($informationObjects->getResults() as $informationObject): ?>
+<?php foreach ($informationObjects as $informationObject): ?>
<tr>
<td>
<?php echo link_to(render_title($informationObject), array('module' =>
'informationobject', 'action' => 'show', 'id' => $informationObject->id)) ?>
@@ -64,22 +64,20 @@
</tbody>
</table>
-<?php if ($informationObjects->haveToPaginate()): ?>
+<?php if ($pager->haveToPaginate()): ?>
<div class="pager">
- <?php $links = $informationObjects->getLinks() ?>
- <?php if ($informationObjects->getPage() !=
$informationObjects->getFirstPage()): ?>
- <?php echo link_to('< '.__('previous'), array('page' =>
$informationObjects->getPage() - 1) +
$sf_request->getParameterHolder()->getAll()) ?>
+ <?php if (1 != $pager->getCurrentPage()): ?>
+ <?php echo link_to('< '.__('previous'), array('page' =>
$pager->getCurrentPage() - 1) + $sf_request->getParameterHolder()->getAll()) ?>
<?php endif; ?>
- <?php foreach ($links as $page): ?>
- <?php echo ($page == $informationObjects->getPage()) ?
'<strong>'.$page.'</strong>' : link_to($page, array('page' => $page) +
$sf_request->getParameterHolder()->getAll()) ?>
- <?php if ($page != $informationObjects->getCurrentMaxLink()): ?> <?php
endif; ?>
+ <?php foreach ($pager->getPages() as $page): ?>
+ <?php echo ($pager->getCurrentPage() == $page) ?
'<strong>'.$page.'</strong>' : link_to($page, array('page' => $page) +
$sf_request->getParameterHolder()->getAll()) ?>
<?php endforeach ?>
- <?php if ($informationObjects->getPage() !=
$informationObjects->getLastPage()): ?>
- <?php echo link_to(__('next').' >', array('page' =>
$informationObjects->getPage() + 1) +
$sf_request->getParameterHolder()->getAll()) ?>
+ <?php if (count($pager->getPages()) > $pager->getCurrentPage()): ?>
+ <?php echo link_to(__('next').' >', array('page' => $pager->getCurrentPage()
+ 1) + $sf_request->getParameterHolder()->getAll()) ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="result-count">
-<?php echo __('displaying %1% to %2% of %3% results', array('%1%' =>
$informationObjects->getFirstIndice(), '%2%' =>
$informationObjects->getLastIndice(), '%3%' =>
$informationObjects->getNbResults())) ?>
+<?php echo __('displaying %1% to %2% of %3% results', array('%1%' =>
$pager->getFirstHit(), '%2%' => $pager->getLastHit(), '%3%' =>
count($pager->getHits()))) ?>
</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
-~----------~----~----~----~------~----~------~--~---