Author: david
Date: Mon Oct 5 12:05:24 2009
New Revision: 3663
Log:
Display and use preferred term for subject access point autocomplete.
Modified:
trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php
Modified: trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php Mon Oct
5 00:02:32 2009 (r3662)
+++ trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php Mon Oct
5 12:05:24 2009 (r3663)
@@ -21,6 +21,8 @@
{
public function execute($request)
{
+
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag','Url'));
+
$this->taxonomy = QubitTaxonomy::getById($request->taxonomyId);
if (!isset($this->taxonomy))
{
@@ -35,13 +37,58 @@
$criteria->addAscendingOrderByColumn(QubitTermI18n::NAME);
$criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
- $this->hitlist = new QubitPager('QubitTerm');
- $this->hitlist->setCriteria($criteria);
- $this->hitlist->setPage($request->page);
- $this->hitlist->init();
+ $this->pager = new QubitPager('QubitTerm');
+ $this->pager->setCriteria($criteria);
+ $this->pager->setPage($request->page);
+ $this->pager->init();
+
+ $this->terms = $this->pager->getResults();
+
+ $tableHtml = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Taxonomy List</title>
+</head>
+<body>
+<table>
+<thead>
+<th>term</th>
+</thead>
+<tbody>
+
+EOL;
+
+ foreach ($this->pager->getResults() as $term)
+ {
+ // Search for preferred term
+ $c = new Criteria;
+ $c->add(QubitRelation::OBJECT_ID, $term->id);
+ $c->add(QubitRelation::TYPE_ID, QubitTerm::TERM_RELATION_EQUIVALENCE_ID);
+ $c->addJoin(QubitRelation::SUBJECT_ID, QubitTerm::ID,
Criteria::INNER_JOIN);
+
+ if (null !== ($prefTerm = QubitTerm::getOne($c)))
+ {
+ $termId = $prefTerm->id;
+ $label = $this->getContext()->getI18N()->__('%1% (use: %2%)',
array('%1%' => $term->name, '%2%' => $prefTerm->name));
+ }
+ else
+ {
+ $termId = $term->id;
+ $label = $term->name;
+ }
+
+ $tableHtml .= '<tr><td>'.link_to($label, array('module' => 'term',
'action' => 'show', 'id' => $termId)).'</td></tr>';
+ $tableHtml .= "\n";
+ }
- $this->terms = $this->hitlist->getResults();
+ $tableHtml .= <<<EOL
+</tbody>
+</table>
+</body>
+</html>
+EOL;
- $this->setTemplate('listTaxonomy');
+ return $this->renderText($tableHtml);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---