md_mix.php 2.4 KB

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