Source for file ContentSearch.class.php

Documentation is available at ContentSearch.class.php

  1. <?php
  2. /**
  3. * @package harmoni.osid_v2.repository.search
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: ContentSearch.class.php,v 1.8 2007/09/04 20:25:47 adamfranco Exp $
  9. */
  10.  
  11. require_once(dirname(__FILE__)."/SearchModule.interface.php");
  12.  
  13. /**
  14. * Return assets of the specified type
  15. *
  16. * @package harmoni.osid_v2.repository.search
  17. *
  18. * @copyright Copyright &copy; 2005, Middlebury College
  19. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  20. *
  21. * @version $Id: ContentSearch.class.php,v 1.8 2007/09/04 20:25:47 adamfranco Exp $
  22. */
  23.  
  24. class ContentSearch
  25. extends SearchModuleInterface {
  26. /**
  27. * Constructor
  28. *
  29. * @param object $dr
  30. * @return object
  31. * @access public
  32. * @since 11/2/04
  33. */
  34. function ContentSearch ( $dr ) {
  35. $this->_dr =$dr;
  36. }
  37. /**
  38. * Get the ids of the assets that match the search criteria
  39. *
  40. * @param mixed $searchCriteria
  41. * @return array
  42. * @access public
  43. * @since 11/2/04
  44. */
  45. function searchAssets ( $searchCriteria ) {
  46. $matchingIds = array();
  47. // Get All the assets
  48. $criteria = new FieldValueSearch("edu.middlebury.harmoni.repository.asset_content","Content", new Blob($searchCriteria), SEARCH_TYPE_CONTAINS);
  49. $recordMgr = Services::getService("RecordManager");
  50. $recordIDs = $recordMgr->getRecordIDsBySearch($criteria);
  51.  
  52. $groupIds = array();
  53. foreach ($recordIDs as $id) {
  54. $recordSetIds =$recordMgr->getRecordSetIDsContainingID($id);
  55. $groupIds = array_merge($groupIds, $recordSetIds);
  56. }
  57. $groupIds = array_unique($groupIds);
  58. $idManager = Services::getService("Id");
  59. foreach ($groupIds as $id) {
  60. $matchingIds[] =$idManager->getId($id);
  61. }
  62. // Return the array
  63. return $matchingIds;
  64. }
  65. }
  66.  
  67. ?>

Documentation generated on Wed, 19 Sep 2007 10:22:11 -0400 by phpDocumentor 1.3.0RC3