Author: sevein
Date: Mon May 14 10:33:10 2012
New Revision: 11668

Log:
Use facet partial

Modified:
   branches/2.0/apps/qubit/modules/search/templates/_searchResults.php

Modified: branches/2.0/apps/qubit/modules/search/templates/_searchResults.php
==============================================================================
--- branches/2.0/apps/qubit/modules/search/templates/_searchResults.php Mon May 
14 10:32:17 2012        (r11667)
+++ branches/2.0/apps/qubit/modules/search/templates/_searchResults.php Mon May 
14 10:33:10 2012        (r11668)
@@ -5,7 +5,7 @@
     <div class="span12 hidden-phone">
       <h1>
         <?php echo __('%1% search results', array('%1%' => 
$pager->getNbResults())) ?>
-        <?php if (sfConfig::get('app_multi_repository')): ?>
+        <?php if (sfConfig::get('app_multi_repository') && 
isset($pager->facets['repository_id'])): ?>
           <?php echo __('in %1% institutions', array('%1%' => 
count($pager->facets['repository_id']['terms']))) ?>
         <?php endif; ?>
       </h1>
@@ -19,7 +19,7 @@
 
   </div>
 
-  <?php if (sfConfig::get('app_multi_repository')): ?>
+  <?php if (sfConfig::get('app_multi_repository') && 
isset($pager->facets['repository_id'])): ?>
 
     <div class="row">
 
@@ -68,102 +68,55 @@
 
   <div class="row">
 
-    <?php if (!isset($hideFacets)): ?>
+    <div class="span3" id="facets">
 
-      <div class="span3" id="facets">
+      <?php if (isset($pager->facets['subjects_id'])): ?>
 
-        <?php if (isset($pager->facets['subjects_id'])): ?>
-          <div class="section">
+        <?php echo get_partial('search/facet', array(
+          'target' => '#facet-subject',
+          'label' => __('Subject'),
+          'facet' => 'subjects_id',
+          'pager' => $pager,
+          'filters' => $filters)) ?>
 
-            <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse" 
data-target="#subjects"><?php echo __('Subject') ?></h2>
-            <h2 class="hidden-phone"><?php echo __('Subject') ?></h2>
-
-            <div class="scrollable" id="subjects">
-              <ul>
-                <li <?php if ('' == $sf_request->getParameter('subjects_id')) 
echo 'class="active"'; ?>><?php echo link_to(__('All'), array('subjects_id' => 
null, 'page' => null) + $sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php foreach($pager->facets['subjects_id']['terms'] as $id => 
$term): ?>
-                  <li <?php if (in_array($id, @$filters['subjects_id'])) echo 
'class="active"'; ?>><?php echo 
link_to(__($term['term']).'<span>'.$term['count'].'</span>', 
array('subjects_id' => (@$filters['subjects_id'] ? implode(',', 
array_diff(array_merge(@$filters['subjects_id'], array($id)), 
array_intersect(@$filters['subjects_id'], array($id)))) : $id), 'page' => null) 
+ $sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php endforeach; ?>
-              </ul>
-            </div>
-
-          </div>
-        <?php endif; ?>
-
-        <?php if (isset($pager->facets['digitalObject_mediaTypeId'])): ?>
-          <div class="section">
-
-            <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse" 
data-target="#mediatypes"><?php echo __('Media Type') ?></h2>
-            <h2 class="hidden-phone"><?php echo __('Media Type') ?></h2>
-
-            <div class="scrollable" id="mediatypes">
-              <ul>
-                <li <?php if ('' == 
$sf_request->getParameter('digitalObject_mediaTypeId')) echo 'class="active"' 
?>><?php echo link_to(__('All'), array('digitalObject_mediaTypeId' => null, 
'page' => null) + $sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php 
foreach($pager->facets['digitalObject_mediaTypeId']['terms'] as $id => $term): 
?>
-                  <li <?php if (in_array($id, 
@$filters['digitalObject_mediaTypeId'])) echo 'class="active"' ?>><?php echo 
link_to(__($term['term']).'<span>'.$term['count'].'</span>', 
array('digitalObject_mediaTypeId' => (@$filters['digitalObject_mediaTypeId'] ? 
implode(',', array_diff(array_merge(@$filters['digitalObject_mediaTypeId'], 
array($id)), array_intersect(@$filters['digitalObject_mediaTypeId'], 
array($id)))) : $id), 'page' => null) + 
$sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php endforeach; ?>
-              </ul>
-            </div>
-
-          </div>
-        <?php endif; ?>
-
-        <div class="section">
-
-          <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse" 
data-target="#dates"><?php echo __('Creation date') ?></h2>
-          <h2 class="hidden-phone"><?php echo __('Creation date') ?></h2>
+      <?php endif; ?>
 
-          <div class="scrollable dates" id="dates">
-            <input type="text" value="<?php echo 
$pager->facets['dates_startDate']['min'] ?>" name="from" /> - <input 
type="text" value="<?php echo $pager->facets['dates_startDate']['max'] ?>" 
name="to" />
-          </div>
-
-        </div>
+      <?php if (isset($pager->facets['digitalObject_mediaTypeId'])): ?>
 
-        <?php if (isset($pager->facets['places_id'])): ?>
-          <div class="section">
+        <?php echo get_partial('search/facet', array(
+          'target' => '#facet-mediatype',
+          'label' => __('Media type'),
+          'facet' => 'digitalObject_mediaTypeId',
+          'pager' => $pager,
+          'filters' => $filters)) ?>
 
-            <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse" 
data-target="#places"><?php echo __('Place') ?></h2>
-            <h2 class="hidden-phone"><?php echo __('Place') ?></h2>
+      <?php endif; ?>
 
-            <div class="scrollable" id="places">
-              <ul>
-                <li <?php if ('' == $sf_request->getParameter('places_id')) 
echo 'class="active"' ?>><?php echo link_to(__('All'), array('places_id' => 
null, 'page' => null) + $sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php foreach($pager->facets['places_id']['terms'] as $id => 
$term): ?>
-                  <li <?php if (in_array($id, @$filters['places_id'])) echo 
'class="active"' ?>><?php echo 
link_to(__($term['term']).'<span>'.$term['count'].'</span>', array('places_id' 
=> (@$filters['places_id'] ? implode(',', 
array_diff(array_merge(@$filters['places_id'], array($id)), 
array_intersect(@$filters['places_id'], array($id)))) : $id), 'page' => null) + 
$sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php endforeach; ?>
-              </ul>
-            </div>
-
-          </div>
-        <?php endif; ?>
+      <?php if (isset($pager->facets['places_id'])): ?>
 
-        <?php if (isset($pager->facets['names_id'])): ?>
-          <div class="section">
+        <?php echo get_partial('search/facet', array(
+          'target' => '#facet-place',
+          'label' => __('Place'),
+          'facet' => 'places_id',
+          'pager' => $pager,
+          'filters' => $filters)) ?>
 
-            <h2 class="visible-phone widebtn btn-huge" data-toggle="collapse" 
data-target="#names"><?php echo __('Name') ?></h2>
-            <h2 class="hidden-phone"><?php echo __('Name') ?></h2>
+      <?php endif; ?>
 
-            <div class="scrollable" id="names">
-              <ul>
-                <li <?php if ('' == $sf_request->getParameter('names_id')) 
echo 'class="active"' ?>><?php echo link_to(__('All'), array('names_id' => 
null, 'page' => null) + $sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php foreach($pager->facets['names_id']['terms'] as $id => 
$term): ?>
-                  <li <?php if (in_array($id, @$filters['names_id'])) echo 
'class="active"' ?>><?php echo 
link_to(__($term['term']).'<span>'.$term['count'].'</span>', array('names_id' 
=> (@$filters['names_id'] ? implode(',', 
array_diff(array_merge(@$filters['names_id'], array($id)), 
array_intersect(@$filters['names_id'], array($id)))) : $id), 'page' => null) + 
$sf_request->getParameterHolder()->getAll()) ?></li>
-                <?php endforeach; ?>
-              </ul>
-            </div>
+      <?php if (isset($pager->facets['names_id'])): ?>
 
-          </div>
-        <?php endif; ?>
+        <?php echo get_partial('search/facet', array(
+          'target' => '#facet-name',
+          'label' => __('Name'),
+          'facet' => 'names_id',
+          'pager' => $pager,
+          'filters' => $filters)) ?>
 
-      </div>
+      <?php endif; ?>
 
-    <?php endif; ?>
+    </div>
 
-    <?php if (isset($hideFacets)): ?>
-      <div class="span12" id="content">
-    <?php else: ?>
-      <div class="span9" id="content">
-    <?php endif; ?>
+    <div class="span9" id="content">
 
       <div class="listings">
 
@@ -183,10 +136,8 @@
         <?php endif; ?>
 
         <?php foreach ($pager->getResults() as $hit): ?>
-
           <?php $doc = build_i18n_doc($hit, array('creators')) ?>
           <?php echo include_partial('search/searchResult', array('doc' => 
$doc, 'pager' => $pager)) ?>
-
         <?php endforeach; ?>
 
         <?php echo get_partial('default/pager', array('pager' => $pager)) ?>

-- 
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