Author: sevein
Date: Tue May 1 14:51:03 2012
New Revision: 11586
Log:
Remove culture facet, use new search/searchResult partial, access to directly
because it is passed as an argument, cosmetic changes...
Modified:
branches/2.0/apps/qubit/modules/search/actions/indexAction.class.php
branches/2.0/apps/qubit/modules/search/templates/_searchResults.php
Modified: branches/2.0/apps/qubit/modules/search/actions/indexAction.class.php
==============================================================================
--- branches/2.0/apps/qubit/modules/search/actions/indexAction.class.php
Tue May 1 14:48:58 2012 (r11585)
+++ branches/2.0/apps/qubit/modules/search/actions/indexAction.class.php
Tue May 1 14:51:03 2012 (r11586)
@@ -24,8 +24,7 @@
'subjects.id',
'digitalObject.mediaTypeId',
'places.id',
- 'names.id',
- 'i18n.culture');
+ 'names.id');
public function execute($request)
{
@@ -60,18 +59,16 @@
// tie-break sort on slug (ie. alphanumeric sort), eg. for match_all
$query->setSort(array('_score' => 'desc', 'slug' => 'asc'));
+ $query->setLimit($request->limit);
- // set paging for request
- $query->setLimit($this->request->limit);
-
- if (!empty($this->request->page))
+ if (!empty($request->page))
{
- $query->setFrom(($this->request->page - 1) * $this->request->limit);
+ $query->setFrom(($request->page - 1) * $request->limit);
}
- if (isset($this->request->realm) && is_int($this->request->realm))
+ if (isset($request->realm) && is_int($request->realm))
{
- $query->setQuery(new Elastica_Query_Term(array('repository._id' =>
$this->request->realm)));
+ $query->setQuery(new Elastica_Query_Term(array('repository._id' =>
$request->realm)));
}
try
@@ -225,48 +222,40 @@
break;
- case 'i18n.culture':
- foreach ($facet['terms'] as $term)
- {
- $facets[strtr($name, '.', '_')]['terms'][$term['term']] =
array('count' => $term['count'],
- 'term' =>
sfCultureInfo::getInstance($this->context->user->getCulture())->getLanguage($term['term']));
- }
-
- break;
}
}
- $ancestorsIds = array();
- foreach ($this->pager->getResults() as $hit)
+ $this->pager->facets = $facets;
+ }
+
+ $ancestorsIds = array();
+ foreach ($this->pager->getResults() as $hit)
+ {
+ $doc = $hit->getData();
+ foreach ($doc['ancestors'] as $item)
{
- $doc = $hit->getData();
- foreach ($doc['ancestors'] as $item)
+ if (in_array($item, $ancestorsIds))
{
- if (in_array($item, $ancestorsIds))
- {
- continue;
- }
-
- $ancestorsIds[] = $item;
+ continue;
}
- }
- $sql = 'SELECT
- io.id,
- o.slug,
- io.title
- FROM '.QubitInformationObjectI18n::TABLE_NAME.' AS io
- LEFT JOIN '.QubitSlug::TABLE_NAME.' AS o ON (o.object_id = io.id AND
io.culture = ?)
- WHERE o.object_id IN ('.implode(',', $ancestorsIds).')';
- $this->pager->ancestors = array();
- foreach (QubitPdo::fetchAll($sql,
array($this->context->user->getCulture())) as $ancestor)
- {
- $this->pager->ancestors[$ancestor->id] = array(
- 'slug' => $ancestor->slug,
- 'title' => $ancestor->title);
+ $ancestorsIds[] = $item;
}
+ }
- $this->pager->facets = $facets;
+ $sql = 'SELECT
+ io.id,
+ o.slug,
+ io.title
+ FROM '.QubitInformationObjectI18n::TABLE_NAME.' AS io
+ LEFT JOIN '.QubitSlug::TABLE_NAME.' AS o ON (o.object_id = io.id AND
io.culture = ?)
+ WHERE o.object_id IN ('.implode(',', $ancestorsIds).')';
+ $this->pager->ancestors = array();
+ foreach (QubitPdo::fetchAll($sql,
array($this->context->user->getCulture())) as $ancestor)
+ {
+ $this->pager->ancestors[$ancestor->id] = array(
+ 'slug' => $ancestor->slug,
+ 'title' => $ancestor->title);
}
}
else if (empty($this->error))
Modified: branches/2.0/apps/qubit/modules/search/templates/_searchResults.php
==============================================================================
--- branches/2.0/apps/qubit/modules/search/templates/_searchResults.php Tue May
1 14:48:58 2012 (r11585)
+++ branches/2.0/apps/qubit/modules/search/templates/_searchResults.php Tue May
1 14:51:03 2012 (r11586)
@@ -12,8 +12,9 @@
</div>
<div id="phone-filter" class="span12 visible-phone">
- <h2 class="widebtn btn-huge" data-toggle="collapse"
data-target="#facets, #top-facet"><?php echo __('Filter %1% Results', array(
- '%1%' => $pager->getNbResults())) ?></h2>
+ <h2 class="widebtn btn-huge" data-toggle="collapse"
data-target="#facets, #top-facet">
+ <?php echo __('Filter %1% Results', array('%1%' =>
$pager->getNbResults())) ?>
+ </h2>
</div>
</div>
@@ -154,24 +155,6 @@
</div>
<?php endif; ?>
- <?php if (isset($pager->facets['i18n_culture'])): ?>
- <div class="section">
-
- <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse"
data-target="#language"><?php echo __('Language') ?></h2>
- <h2 class="hidden-phone"><?php echo __('Language') ?></h2>
-
- <div class="scrollable" id="languages">
- <ul>
- <li <?php if ('' == $sf_request->getParameter('i18n_culture'))
echo 'class="active"' ?>><?php echo link_to(__('All'), array('i18n_culture' =>
null, 'page' => null) + $sf_request->getParameterHolder()->getAll()) ?></li>
- <?php foreach($pager->facets['i18n_culture']['terms'] as $id
=> $term): ?>
- <li <?php if (in_array($id, @$filters['i18n_culture'])) echo
'class="active"' ?>><?php echo
link_to(__($term['term']).'<span>'.$term['count'].'</span>',
array('i18n_culture' => (@$filters['i18n_culture'] ? implode(',',
array_diff(array_merge(@$filters['i18n_culture'], array($id)),
array_intersect(@$filters['i18n_culture'], array($id)))) : $id), 'page' =>
null) + $sf_request->getParameterHolder()->getAll()) ?></li>
- <?php endforeach; ?>
- </ul>
- </div>
-
- </div>
- <?php endif; ?>
-
</div>
<?php endif; ?>
@@ -201,37 +184,8 @@
<?php foreach ($pager->getResults() as $hit): ?>
- <?php $doc = build_i18n_doc($hit) ?>
-
- <div class="result">
-
- <?php if (isset($doc['digitalObject']['thumbnail_FullPath'])): ?>
- <?php echo
link_to(image_tag($doc['digitalObject']['thumbnail_FullPath'], array('alt' =>
'image-thumb', 'width' => '150', 'height' => '150')), array('module' =>
'informationobject', 'slug' => $doc['slug']), array('title' =>
$doc[$sf_user->getCulture()]['title'] ?: $doc[$doc['sourceCulture']]['title']))
?>
- <?php endif; ?>
-
- <h3><?php echo link_to(($doc[$sf_user->getCulture()]['title'] ?:
$doc[$doc['sourceCulture']]['title']) . ' <strong> ' .
$pager->levelsOfDescription[$doc['levelOfDescriptionId']] . ' </strong> <em> '
. (($doc['publicationStatusId'] == QubitTerm::PUBLICATION_STATUS_DRAFT_ID) ?
'Draft' : '') . ' </em>', array('module' => 'informationobject', 'slug' =>
$doc['slug'])) ?></h3>
-
- <ul class="breadcrumb">
- <?php foreach($doc['ancestors'] as $id): ?>
- <?php if ($id == QubitInformationObject::ROOT_ID) continue ?>
- <li><?php echo link_to($pager->ancestors[$id]['title'],
array('module' => 'informationobject', 'slug' =>
$pager->ancestors[$id]['slug']), array('title' =>
$pager->ancestors[$id]['title'])) ?></li>
- <?php endforeach; ?>
- </ul>
-
- <?php if (isset($doc[$sf_user->getCulture()]['scopeAndContent'])):
?>
- <p><?php echo $doc[$sf_user->getCulture()]['scopeAndContent']
?></p>
- <?php endif; ?>
-
- <p>
- <?php if (isset($doc['dates'])): ?>
- <?php echo Qubit::renderDateStartEnd(null,
$doc['dates'][0]['startDate'], $doc['dates'][0]['endDate']) ?>
- <?php endif; ?>
- <?php if
(!empty($doc[$doc['sourceCulture']]['creator'][0]['name'])): ?>
- <?php echo __('by %1%', array('%1%' =>
$doc[$sf_user->getCulture()]['creator'][0]['name'] ?:
$doc[$doc['sourceCulture']]['creator'][0]['name'])) ?>
- <?php endif; ?>
- </p>
-
- </div>
+ <?php $doc = build_i18n_doc($hit, array('creators')) ?>
+ <?php echo include_partial('search/searchResult', array('doc' =>
$doc, 'pager' => $pager)) ?>
<?php endforeach; ?>
--
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.