Author: sevein Date: Mon Apr 30 14:02:48 2012 New Revision: 11567 Log: Stop using ES for the taxonomy browser, restore and style table
Modified: branches/2.0/apps/qubit/modules/taxonomy/actions/browseAction.class.php branches/2.0/apps/qubit/modules/taxonomy/templates/browseSuccess.php branches/2.0/plugins/qtDominionPlugin/css/less/archivalDescription.less Modified: branches/2.0/apps/qubit/modules/taxonomy/actions/browseAction.class.php ============================================================================== --- branches/2.0/apps/qubit/modules/taxonomy/actions/browseAction.class.php Mon Apr 30 14:00:39 2012 (r11566) +++ branches/2.0/apps/qubit/modules/taxonomy/actions/browseAction.class.php Mon Apr 30 14:02:48 2012 (r11567) @@ -17,81 +17,76 @@ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>. */ -class TaxonomyBrowseAction extends DefaultBrowseAction +class TaxonomyBrowseAction extends sfAction { - public static - $FACETS = array(); - - protected function buildFacetTable($name, $facet) + public function execute($request) { - $ids = array(); - foreach ($facet['terms'] as $term) + if (!isset($request->limit)) { - $ids[$term['term']] = $term['count']; + $request->limit = sfConfig::get('app_hits_per_page'); } - switch ($name) + // HACK Use id deliberately, vs. slug, because "Subjects" and "Places" + // menus still use id + $this->resource = QubitTaxonomy::getById($request->id); + if (!isset($this->resource)) { - default: - - break; + $this->forward404(); } - } - protected function earlyExecute() - { - // Determine what kind of term we are browsing - switch ($this->request->id) + switch ($this->resource->id) { - case QubitTaxonomy::SUBJECT_ID: - $this->field = 'subjects'; + case QubitTaxonomy::PLACE_ID: + $this->icon = 'places'; break; - case QubitTaxonomy::PLACE_ID: - $this->field = 'places'; + case QubitTaxonomy::SUBJECT_ID: + $this->icon = 'subjects'; + + } + + $criteria = new Criteria; + $criteria->add(QubitTerm::TAXONOMY_ID, $this->resource->id); + $criteria->addJoin(QubitTerm::ID, QubitObjectTermRelation::TERM_ID); + $criteria->addJoin(QubitObjectTermRelation::OBJECT_ID, QubitInformationObject::ID); + $criteria = QubitAcl::addFilterDraftsCriteria($criteria); + + // Do culture fallback + $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm'); + + $criteria->addGroupByColumn(QubitTerm::ID); + $criteria->addAsColumn('hits', 'COUNT('.QubitTerm::ID.')'); + + switch ($request->sort) + { + case 'hitsDown': + $criteria->addDescendingOrderByColumn('hits'); break; - case '': - // TODO: no ID specified, handle error condition (redirect?) + case 'hitsUp': + $criteria->addAscendingOrderByColumn('hits'); break; - } - $this->query = new Elastica_Query(new Elastica_Query_Term(array('taxonomyId' => $request->id))); - $this->query->setSort(array('_score' => 'desc', 'slug' => 'asc')); - } + case 'termNameDown': + $criteria->addDescendingOrderByColumn('name'); - public function execute($request) - { - parent::execute($request); + break; - try - { - $resultSet = QubitSearch::getInstance()->index->getType('QubitTerm')->search($query); - } - catch (Exception $e) - { - $this->error = $e->getMessage(); + case 'termNameUp': + default: + $criteria->addAscendingOrderByColumn('name'); - return; + break; } - $this->pager = new QubitSearchPager($resultSet); - $this->pager->setPage($request->page); + $this->pager = new QubitPager('QubitTerm'); + $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($request->limit); + $this->pager->setPage($request->page); - if ($this->pager->hasResults()) - { - if ($resultSet->hasFacets()) - { - $this->buildFacetTable($name, $facet); - } - } - else if (empty($this->error)) - { - // $this->error = $this->context->i18n->__('No %1% found.', array('%1%' => __($this->field))); - } + $this->terms = $this->pager->getResults(); } } Modified: branches/2.0/apps/qubit/modules/taxonomy/templates/browseSuccess.php ============================================================================== --- branches/2.0/apps/qubit/modules/taxonomy/templates/browseSuccess.php Mon Apr 30 14:00:39 2012 (r11566) +++ branches/2.0/apps/qubit/modules/taxonomy/templates/browseSuccess.php Mon Apr 30 14:02:48 2012 (r11567) @@ -1,39 +1,81 @@ -<div id="search-results"> +<div class="row"> - <div class="row"> + <div class="span12 hidden-phone"> + <h1> + <?php if (isset($icon)): ?> + <?php echo image_tag('/plugins/qtDominionPlugin/images/icons-large/icon-'.$icon.'.png', array('width' => '42', 'height' => '42')) ?> + <?php endif; ?> + <?php echo __('Browse %1% %2%', array( + '%1%' => $pager->getNbResults(), + '%2%' => strtolower(render_title($resource)))); ?> + </h1> + </div> - <div class="span12 hidden-phone"> - <h1> - <?php echo image_tag('/plugins/qtDominionPlugin/images/icons-large/icon-'.$field.'.png', array('width' => '42', 'height' => '42')) ?> - <?php echo __('%1% %2%', array('%1%' => $pager->getNbResults(), '%2%' => ucfirst($field))); ?> - </h1> - </div> +</div> - <div id="filter" class="span12 visible-phone"> - <h2 class="widebtn gray btn-huge" data-toggle="collapse" data-target="#facets"><?php echo __('Filter %1% %2%', array('%1%' => $pager->getNbResults(), '%2%' => ucfirst($field))); ?></h2> - </div> +<div class="row"> - </div> + <div class="span12" id="main-column"> - <div class="row"> + <ul class="nav nav-tabs"> + <li<?php if ('hitsUp' == $sf_request->sort || 'hitsDown' == $sf_request->sort): ?> class="active"<?php endif; ?>><?php echo link_to(__('Results'), array('sort' => 'hitsUp') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?></li> + <li<?php if ('hitsUp' != $sf_request->sort && 'hitsDown' != $sf_request->sort): ?> class="active"<?php endif; ?>><?php echo link_to(__('Alphabetic'), array('sort' => 'termNameUp') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?></li> + </ul> + + <div id="content"> + + <div class="c"> + <table class="table table-bordered sticky-enabled"> + <thead> + <tr> + <th> + <?php echo render_title($resource) ?> + <?php if ('termNameDown' == $sf_request->sort): ?> + <?php echo link_to(image_tag('up.gif'), array('sort' => 'termNameUp') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?> + <?php elseif ('termNameUp' == $sf_request->sort || !in_array($sf_request->sort, array('hitsDown', 'hitsUp'))): ?> + <?php echo link_to(image_tag('down.gif'), array('sort' => 'termNameDown') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?> + <?php endif; ?> + </th><th> + <?php echo __('Results') ?> + <?php if ('hitsDown' == $sf_request->sort): ?> + <?php echo link_to(image_tag('up.gif'), array('sort' => 'hitsUp') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?> + <?php elseif ('hitsUp' == $sf_request->sort): ?> + <?php echo link_to(image_tag('down.gif'), array('sort' => 'hitsDown') + $sf_request->getParameterHolder()->getAll(), array('title' => __('Sort'))) ?> + <?php endif; ?> + </th> + </tr> + </thead><tbody> + <?php foreach ($terms as $item): ?> + <tr class="<?php echo 0 == @++$row % 2 ? 'even' : 'odd' ?>"> + <td> + <?php echo link_to(render_title($item), array($item, 'module' => 'term', 'action' => 'browseTerm')) ?> + </td><td> + <?php echo $item->countRelatedInformationObjects() ?> + </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + </div> + + <?php echo get_partial('default/pager', array('pager' => $pager)) ?> - <div class="span3" id="facets"> - </div> - <div class="span9"> + </div> - <?php foreach ($pager->getResults() as $hit): ?> - <?php $doc = build_i18n_doc($hit) ?> - <div class="institution maxi"> - <h2 class="filltext"><?php echo link_to($doc[$sf_user->getCulture()]['name'] ?: $doc[$doc['sourceCulture']]['name'], array('module' => 'search', $field .'_id' => $hit->getId())) ?></h2> - </div> - <?php endforeach; ?> +</div> - <?php echo get_partial('default/pager', array('pager' => $pager)) ?> +<div class="actions section"> - </div> + <h2 class="element-invisible"><?php echo __('Actions') ?></h2> + <div class="content"> + <ul class="clearfix links"> + <?php if (QubitAcl::check($resource, array('edit', 'createTerm'))): ?> + <li><?php echo link_to(__('Add new'), array('module' => 'term', 'action' => 'add', 'taxonomy' => url_for(array($resource, 'module' => 'taxonomy')))) ?></li> + <?php endif; ?> + </ul> </div> </div> Modified: branches/2.0/plugins/qtDominionPlugin/css/less/archivalDescription.less ============================================================================== --- branches/2.0/plugins/qtDominionPlugin/css/less/archivalDescription.less Mon Apr 30 14:00:39 2012 (r11566) +++ branches/2.0/plugins/qtDominionPlugin/css/less/archivalDescription.less Mon Apr 30 14:02:48 2012 (r11567) @@ -240,9 +240,28 @@ } } +#main-column { + + > .nav.nav-tabs { + + margin-bottom: 0; + border-bottom: 4px solid @grayDark; + + > li { + + margin-bottom: 0; + + } + + } + +} + #main-column #content { - h2, p, li { + overflow: auto; + + h2, p { margin: 0 10px; } @@ -255,6 +274,12 @@ margin-bottom:5px; } + > .c { + + margin: 20px; + + } + .editlink { float:right; margin-top:2px; -- 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.
