Author: david
Date: Fri Feb 10 14:14:36 2012
New Revision: 10856
Log:
Add level of description
Modified:
trunk/lib/QubitSearchPdo.class.php
Modified: trunk/lib/QubitSearchPdo.class.php
==============================================================================
--- trunk/lib/QubitSearchPdo.class.php Fri Feb 10 13:46:27 2012 (r10855)
+++ trunk/lib/QubitSearchPdo.class.php Fri Feb 10 14:14:36 2012 (r10856)
@@ -21,6 +21,7 @@
{
protected static
$collectionRoot,
+ $levelsOfDescription = array(),
$repository;
public function qubitPopulate($options)
@@ -243,7 +244,7 @@
self::$repository = QubitRepository::getById($resource->repository_id);
}
- // Repository
+ // Add repository
if (isset(self::$repository))
{
$doc->addField(Zend_Search_Lucene_Field::Keyword('repositoryId',
self::$repository->id));
@@ -257,6 +258,17 @@
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('repositoryName',
null));
}
+ // Level of description
+ if (null !== $resource->level_of_description_id)
+ {
+ $lod = self::getLevelOfDescription($resource->level_of_description_id,
$language);
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('levelOfDescription',
$lod));
+ }
+ else
+ {
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('levelOfDescription',
null));
+ }
+
self::getInstance()->getEngine()->getIndex()->addDocument($doc);
return;
@@ -309,16 +321,6 @@
$doc->addField($creatorField);
$doc->addField(Zend_Search_Lucene_Field::Unstored('creatorhistory',
$resource->getCreatorsHistoryString(array('culture' => $language))));
- // Level of Description
- if (null !== $resource->getLevelOfDescription())
- {
- $doc->addField(Zend_Search_Lucene_Field::Text('levelOfDescription',
$resource->getLevelOfDescription()->getName(array('culture' => $language))));
- }
- else
- {
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('levelOfDescription',
null));
- }
-
// Identifier
$identifierField = Zend_Search_Lucene_Field::Text('identifier',
$resource->getIdentifier());
$identifierField->boost = 5;
@@ -434,5 +436,23 @@
return self::getFallbackTitle($id, $options);
}
}
+
+ protected static function getLevelOfDescription($id, $culture)
+ {
+ if (0 == count(self::$levelsOfDescription))
+ {
+ $criteria = new Criteria;
+ $criteria->add(QubitTerm::TAXONOMY_ID,
QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID);
+ foreach (QubitTerm::get($criteria) as $item)
+ {
+ self::$levelsOfDescription[$item->id] = $item;
+ }
+ }
+
+ if (isset(self::$levelsOfDescription[$id]))
+ {
+ return self::$levelsOfDescription[$id]->getName(array('culture' =>
$culture));
+ }
+ }
}
--
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.