Source for file DescriptionSearch.class.php

Documentation is available at DescriptionSearch.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: DescriptionSearch.class.php,v 1.10 2007/09/04 20:25:47 adamfranco Exp $
  9. */
  10.  
  11. require_once(dirname(__FILE__)."/RegexSearch.abstract.php");
  12.  
  13. /**
  14. * Return assets of the specified type
  15. *
  16. *
  17. * @package harmoni.osid_v2.repository.search
  18. *
  19. * @copyright Copyright &copy; 2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: DescriptionSearch.class.php,v 1.10 2007/09/04 20:25:47 adamfranco Exp $
  23. */
  24.  
  25. class DescriptionSearch
  26. extends RegexSearch
  27. {
  28. /**
  29. * Constructor
  30. *
  31. * @param object $dr
  32. * @return object
  33. * @access public
  34. * @since 11/2/04
  35. */
  36. function DescriptionSearch ( $dr ) {
  37. $this->_dr =$dr;
  38. }
  39. /**
  40. * Get the ids of the assets that match the search criteria
  41. *
  42. * @param mixed $searchCriteria
  43. * @return array
  44. * @access public
  45. * @since 11/2/04
  46. */
  47. function searchAssets ( $searchCriteria ) {
  48. $searchCriteria = $this->translateToRegex($searchCriteria);
  49. $matchingIds = array();
  50. // Get All the assets
  51. $assets =$this->_dr->getAssets();
  52. // Add their id to the array if the displayName matches
  53. while ($assets->hasNext()) {
  54. $asset =$assets->next();
  55. if (preg_match($searchCriteria, $asset->getDescription()))
  56. $matchingIds[] =$asset->getId();
  57. }
  58. // Return the array
  59. return $matchingIds;
  60. }
  61. }
  62.  
  63. ?>

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