linker.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Sloodle Presenter linker.
  4. * Allows a Sloodle Presenter object in-world to request a list of entries for a presentation.
  5. *
  6. * @package sloodle
  7. * @copyright Copyright (c) 2007-8 Sloodle (various contributors)
  8. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9. *
  10. * @contributor Peter R. Bloomfield
  11. */
  12. // This script should be called with the following parameters:
  13. // sloodlecontrollerid = ID of a Sloodle Controller through which to access Moodle
  14. // sloodlepwd = the prim password or object-specific session key to authenticate the request
  15. // sloodlemoduleid = ID of a presenter
  16. //
  17. // Status code 1 will be returned on success.
  18. // Each data line specifies one entry in the presetnation, as follows:
  19. // type|url|name
  20. // The type may be "image", "video" or "web".
  21. // In future, scaling values may be applied.
  22. //
  23. /** Lets Sloodle know we are in a linker script. */
  24. define('SLOODLE_LINKER_SCRIPT', true);
  25. /** Grab the Sloodle/Moodle configuration. */
  26. require_once('../../init.php');
  27. /** Include the Sloodle PHP API. */
  28. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  29. // Authenticate the request, and load a slideshow module
  30. $sloodle = new SloodleSession();
  31. $sloodle->authenticate_request();
  32. $sloodle->load_module(SLOODLE_TYPE_PRESENTER, true);
  33. // Load the necessary Presenter plugins
  34. if (!$sloodle->plugins->load_plugins('presenter')) {
  35. $sloodle->response->quick_output(-131, 'PLUGIN', 'Failed to load any SLOODLE Presenter plugins. Please check your "sloodle/plugin" folder.', false);
  36. exit();
  37. }
  38. // Start preparing the response
  39. $sloodle->response->set_status_code(1);
  40. $sloodle->response->set_status_descriptor('OK');
  41. // Output each URL and entry type
  42. $slides = $sloodle->module->get_slides();
  43. if (is_array($slides)) {
  44. foreach ($slides as $slide) {
  45. // This will store the source URL for the slide
  46. $slidesource = '';
  47. // Convert the plugin class names back to the simpler slide type name.
  48. $slidetype = strtolower($slide->type);
  49. switch ($slidetype)
  50. {
  51. case 'presenterslideimage': case 'sloodlepluginpresenterslideimage': $slidetype = 'image'; break;
  52. case 'presenterslideweb': case 'sloodlepluginpresenterslideweb': $slidetype = 'web'; break;
  53. case 'presenterslidevideo': case 'sloodlepluginpresenterslidevideo': $slidetype = 'video'; break;
  54. }
  55. // Attempt to load the plugin for this type
  56. $slideplugin = $sloodle->plugins->get_plugin('presenter-slide', $slidetype);
  57. if ($slideplugin === false) {
  58. // Indicate the error as a side effect, and specify the type as an error
  59. sloodle_debug("Failed to load Presenter slide plugin.\n");
  60. $sloodle->response->add_side_effect(-132);
  61. $entrytype = 'ERROR';
  62. $entrysource = '';
  63. } else {
  64. list($mimetype, $slidesource) = $slideplugin->render_slide_for_sl($slide);
  65. }
  66. $sloodle->response->add_data_line(array($slidetype, $slidesource, $slide->name));
  67. }
  68. }
  69. // Output our response
  70. $sloodle->response->render_to_output();
  71. ?>