media.lib.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // TODO: This file is deprecated, it will be removed. Ivan Tcholakov, 23-SEP-2003.
  3. // These constants specify multi-media related resource files (scripts, players, etc.).
  4. define('FLASH_PLAYER_AUDIO', 'FLASH_PLAYER_AUDIO');
  5. define('FLASH_PLAYER_VIDEO', 'FLASH_PLAYER_VIDEO');
  6. define('SCRIPT_SWFOBJECT', 'SCRIPT_SWFOBJECT');
  7. define('SCRIPT_ASCIIMATHML', 'SCRIPT_ASCIIMATHML');
  8. /**
  9. * A static class for serving the Dokeos system's multi-media features.
  10. * @author Ivan Tcholakov, July 2009.
  11. */
  12. class Media {
  13. /**
  14. * This method returns the path (location) of a specified multi-media resource file.
  15. * @param string $media_resource The identificator of the requested resource: FLASH_PLAYER_AUDIO, FLASH_PLAYER_VIDEO, SCRIPT_SWFOBJECT, SCRIPT_ASCIIMATHML
  16. * @param string $path_type (optional) Type (or base) of the returned path, it can be: WEB_PATH, SYS_PATH, REL_PATH (default)
  17. * @return string Path to access the requeted media-related file.
  18. * Note: At the moment returned paths are based on hard-coded data. Configuration data may be used in the future.
  19. */
  20. public function get_path($media_resource, $path_type = REL_PATH) {
  21. switch ($media_resource) {
  22. case FLASH_PLAYER_AUDIO:
  23. $relative_path = 'main/inc/lib/mediaplayer/player.swf';
  24. break ;
  25. case FLASH_PLAYER_VIDEO:
  26. $relative_path = 'main/inc/lib/mediaplayer/player.swf';
  27. break;
  28. case SCRIPT_SWFOBJECT:
  29. $relative_path = 'main/inc/lib/swfobject/swfobject.js';
  30. break;
  31. case SCRIPT_ASCIIMATHML:
  32. $relative_path = 'main/inc/lib/asciimath/ASCIIMathML.js';
  33. break;
  34. default:
  35. return '';
  36. }
  37. $base_path = api_get_path($path_type);
  38. if (empty($base_path)) {
  39. return '';
  40. }
  41. return $base_path.$relative_path;
  42. }
  43. }