_base.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // This file is part of the Sloodle project (www.sloodle.org) and is released under the GNU GPL v3.
  3. /**
  4. * Defines base classes for SLOODLE Presenter plugins.
  5. *
  6. * @package sloodle
  7. * @copyright Copyright (c) 2009 Sloodle (various contributors)
  8. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9. * @since Sloodle 0.4.1
  10. *
  11. * @contributor Peter R. Bloomfield
  12. *
  13. */
  14. /**
  15. * Base class for plugins which provide slide types for the SLOODLE Presenter.
  16. * Sub-classes should override the essential functions, in addition to those in the SloodlePluginBase class.
  17. * The purpose of the plugin is to render slides for output to a browser or to SL.
  18. *
  19. * @package sloodle
  20. */
  21. class SloodlePluginBasePresenterSlide extends SloodlePluginBase
  22. {
  23. // DATA //
  24. // OVERRIDABLE FUNCTIONS //
  25. // These are functions which can be overridden by sub-classes.
  26. /**
  27. * Render the given slide for browser output -- NOTE: render to a string, and return the string.
  28. * The title of the slide need not be included -- simply the basic iFrame or embedded player etc.
  29. * @param SloodlePresenterSlide $slide An object containing the raw slide data.
  30. * @return string
  31. */
  32. function render_slide_for_browser($slide)
  33. {
  34. // In case this function isn't overridden, just output a basic link.
  35. $output = "<a href=\"{$slide->source}\" title=\"\">".get_string('directlink', 'sloodle')."</a>";
  36. return $output;
  37. }
  38. /**
  39. * Render the given slide for virtual-world output.
  40. * This returns two items of data in a numeric array.
  41. * The first is the virtual world compatible type identifier: web, image, video, or audio (or a mime type).
  42. * The second is the absolute URL to give it.
  43. * @param SloodlePresenterSlide $slide An object containing the raw slide data.
  44. * @return array Numeric array containg (type, url)
  45. */
  46. function render_slide_for_sl($slide)
  47. {
  48. // In case this function isn't overridden, just output a basic web URL
  49. return array('web', $slide->source);
  50. }
  51. /**
  52. * Gets the category to which this plugin belongs.
  53. * For example, Presenters have two plugin categories: slides, and importers.
  54. * This function must be overriden.
  55. * A useful approach would be to have a derived plugin base class for a particular category of plugins.
  56. * Each derived base class would report the appropriate category by overriding this function.
  57. * The actual plugin classes would simply have to inherit that derived base, without needing to specify their own category.
  58. * @access public
  59. * @return string The name of this category of plugin.
  60. */
  61. function get_category()
  62. {
  63. return 'presenter-slide';
  64. }
  65. }
  66. /**
  67. * Base class for plugins which provide slide importers for the SLOODLE Presenter.
  68. * Sub-classes should override the essential functions, in addition to those in the SloodlePluginBase class.
  69. * The purpose of the plugin is to take a specified file (locally), process it, and add slides to the Presentation at the given point.
  70. */
  71. class SloodlePluginBasePresenterImporter extends SloodlePluginBase
  72. {
  73. // DATA //
  74. // OVERRIDABLE FUNCTIONS //
  75. // These are functions which can be overridden by sub-classes.
  76. /**
  77. * Import the given file, and insert the new slides at the specified position in the Presentation.
  78. * The best approach to inserting slides is to insert the first one at the specified position,
  79. * and then increment the position on each insertion.
  80. * Inserting at the same point repeatedly will cause the slides to appear in reverse order! :-)
  81. * @param string $file The path of the file to import.
  82. * @param int $position Position at which the first new slide should be imported. (If negative, then insert at end)
  83. * @return bool True if successful, or false otherwise.
  84. */
  85. function import($file, $position = -1)
  86. {
  87. return false;
  88. }
  89. /**
  90. * Gets the category to which this plugin belongs.
  91. * For example, Presenters have two plugin categories: slides, and importers.
  92. * This function must be overriden.
  93. * A useful approach would be to have a derived plugin base class for a particular category of plugins.
  94. * Each derived base class would report the appropriate category by overriding this function.
  95. * The actual plugin classes would simply have to inherit that derived base, without needing to specify their own category.
  96. * @access public
  97. * @return string The name of this category of plugin.
  98. */
  99. function get_category()
  100. {
  101. return 'presenter-importer';
  102. }
  103. }
  104. ?>