md_mix.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php /* <!-- md_mix.php for Dokeos metadata/*.php -->
  2. <!-- 2005/09/20 -->
  3. <!-- Copyright (C) 2005 rene.haentjens@UGent.be - see metadata/md_funcs.php -->
  4. */
  5. /**
  6. ==============================================================================
  7. * Dokeos Metadata: reduced class mdobject for Search, for a Mix of objects
  8. *
  9. * @package dokeos.metadata
  10. ==============================================================================
  11. */
  12. class mdobject
  13. {
  14. var $mdo_course;
  15. var $mdo_type;
  16. var $mdo_id;
  17. var $mdo_eid;
  18. var $mdo_path;
  19. var $mdo_comment;
  20. var $mdo_filetype;
  21. var $mdo_url;
  22. var $mdo_base_url;
  23. function mdobject($_course, $eid)
  24. {
  25. if (!($dotpos = strpos($eid, '.'))) return;
  26. $this->mdo_course = $_course; $this->mdo_eid = $eid;
  27. $this->mdo_type = ($type = substr($eid, 0, $dotpos));
  28. $this->mdo_id = ($id = substr($eid, $dotpos + 1));
  29. if ($type == 'Document' || $type == 'Scorm')
  30. {
  31. $table = $type == 'Scorm' ?
  32. Database::get_course_table(TABLE_SCORMDOC) :
  33. Database::get_course_table(TABLE_DOCUMENT);
  34. if (($dotpos = strpos($id, '.')))
  35. {
  36. $urlp = '?sid=' . urlencode(substr($id, $dotpos+1));
  37. $id = substr($id, 0, $dotpos);
  38. }
  39. if (($docinfo = @mysql_fetch_array(Database::query(
  40. "SELECT path,comment,filetype FROM
  41. $table WHERE id='" .
  42. addslashes($id) . "'", __FILE__, __LINE__))))
  43. {
  44. $this->mdo_path = $docinfo['path'];
  45. $this->mdo_comment = $docinfo['comment'];
  46. $this->mdo_filetype = $docinfo['filetype'];
  47. if ($type == 'Scorm')
  48. {
  49. $this->mdo_base_url = get_course_web() .
  50. $this->mdo_course['path'] . '/scorm' . $this->mdo_path;
  51. $this->mdo_url = $this->mdo_base_url . '/index.php' . $urlp;
  52. }
  53. else
  54. {
  55. $this->mdo_url = api_get_path(WEB_PATH) . 'main/document/' .
  56. (($this->mdo_filetype == 'file') ? 'download' : 'document').'.php?'.
  57. (($this->mdo_filetype == 'file') ? 'doc_url=' : 'curdirpath=') .
  58. urlencode($this->mdo_path);
  59. }
  60. }
  61. }
  62. elseif ($type == 'Link')
  63. {
  64. $link_table = Database::get_course_table(TABLE_LINK);
  65. if (($linkinfo = @mysql_fetch_array(Database::query(
  66. "SELECT url,title,description,category_id FROM
  67. $link_table WHERE id='" . addslashes($id) .
  68. "'", __FILE__, __LINE__))))
  69. {
  70. $this->mdo_url = $linkinfo['url'];
  71. }
  72. }
  73. }
  74. }
  75. ?>