glossary.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class GlossaryManager {
  3. function __construct() {
  4. }
  5. /**
  6. * Get all glossary terms
  7. * @author Isaac Flores <isaac.flores@dokeos.com>
  8. * @return Array Contain glossary terms
  9. */
  10. public static function get_glossary_terms () {
  11. global $course;
  12. $glossary_id=array();
  13. $glossary_name=array();
  14. $glossary_desc=array();
  15. $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
  16. $sql='SELECT glossary_id as id,name,description FROM '.$glossary_table;
  17. $rs=Database::query($sql,__FILE__,__LINE__);
  18. while ($row=Database::fetch_array($rs)) {
  19. $glossary_data[]=$row;
  20. }
  21. return $glossary_data;
  22. }
  23. /**
  24. * Get glossary term by glossary id
  25. * @author Isaac Flores <florespaz@bidsoftperu.com>
  26. * @param Integer The glossary id
  27. * @return String The glossary description
  28. */
  29. public static function get_glossary_term_by_glossary_id ($glossary_id) {
  30. global $course;
  31. $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
  32. $sql='SELECT description FROM '.$glossary_table.' WHERE glossary_id="'.Database::escape_string($glossary_id).'"';
  33. $rs=Database::query($sql,__FILE__,__LINE__);
  34. $row=Database::fetch_array($rs);
  35. return $row['description'];
  36. }
  37. /**
  38. * Get glossary term by glossary id
  39. * @author Isaac Flores <florespaz_isaac@hotmail.com>
  40. * @param String The glossary term name
  41. * @return String The glossary description
  42. */
  43. public static function get_glossary_term_by_glossary_name ($glossary_name) {
  44. global $course;
  45. $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
  46. $sql='SELECT description FROM '.$glossary_table.' WHERE name like trim("'.Database::escape_string($glossary_name).'") ';
  47. $rs=Database::query($sql,__FILE__,__LINE__);
  48. $row=Database::fetch_array($rs);
  49. return $row['description'];
  50. }
  51. }
  52. ?>