Source for file linker.php

Documentation is available at linker.php

  1. <?php
  2.  
  3.     /**
  4.     * Sloodle Presenter linker.
  5.     * Allows a Sloodle Presenter object in-world to request a list of entries for a presentation.
  6.     *
  7.     * @package sloodle
  8.     * @copyright Copyright (c) 2007-8 Sloodle (various contributors)
  9.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10.     *
  11.     * @contributor Peter R. Bloomfield
  12.     */
  13.     
  14.     // This script should be called with the following parameters:
  15.     //  sloodlecontrollerid = ID of a Sloodle Controller through which to access Moodle
  16.     //  sloodlepwd = the prim password or object-specific session key to authenticate the request
  17.     //  sloodlemoduleid = ID of a presenter
  18.     //
  19.     // The following parameter is optional:
  20.     //  sloodleslidenum = the number of a slide within a presentation (this is a 1 based number, so 1 is the first slide, 2 is the second, and so on)
  21.     //
  22.     // Status code 1 will be returned on success of any request.
  23.     // The first line will always contain the following data:
  24.     //
  25.     //  num_slides|name
  26.     //
  27.     // "name" is the name of the presentation, and "num_slides" is the total number of slides currently in the presentation.
  28.     // The second data line will contain data about a particular slide in the presentation, as follows:
  29.     //
  30.     //  num|type|source|name
  31.     //
  32.     // num = the number of slide within the presentation, starting at 1
  33.     // type = the mimetype of the slide, such as "video/*"
  34.     // source = the source of the slide, which will usually be a URL (although we might use it for other things later)
  35.     // name = the name of the slide
  36.     //
  37.     // By default, the first slide's data will always be returned.
  38.     // However, by including the "sloodleslidenum" parameter in the request, a specific slide can be requested.i
  39.     //
  40.     // In the event that the Presenter plugins fail to load at all, the response will be status code -131.
  41.     // If the presentation is empty (no slides at all) then the response will be status code -10501.
  42.     // If a particular slide's plugin cannot be loaded, then the main status code will still be 1 and the basic presenter data will be given. But there will be side effect code -132, and the 'type' field for the slide will say 'ERROR'. (This allows the presentation to continue to work -- the specific slide can simply be skipped.)
  43.     //
  44.     // Future modifications may include:
  45.     //  - text-based display in SL
  46.     //  - UUID-based texture or object loading in SL
  47.     //  - aspect ratio specified for each slide
  48.     //
  49.     
  50.  
  51.     /** Lets Sloodle know we are in a linker script. */
  52.     define('SLOODLE_LINKER_SCRIPT'true);
  53.     
  54.     /** Grab the Sloodle/Moodle configuration. */
  55.     require_once('../../sl_config.php');
  56.     /** Include the Sloodle PHP API. */
  57.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  58.     
  59.     // Authenticate the request, and load a slideshow module
  60.     $sloodle new SloodleSession();
  61.     $sloodle->authenticate_request();
  62.     $sloodle->load_module(SLOODLE_TYPE_PRESENTERtrue);
  63.  
  64.     // Load the necessary Presenter plugins
  65.     sloodle_debug("Loading Presenter plugins\n");
  66.     if (!$sloodle->plugins->load_plugins('presenter')) {
  67.         $sloodle->response->quick_output(-131'PLUGIN''Failed to load any SLOODLE Presenter plugins. Please check your "sloodle/plugin" folder.'false);
  68.         exit();
  69.     }
  70.  
  71.     // Get all the slides in this presentation
  72.     $slides $sloodle->module->get_slides();
  73.     if (!is_array($slides|| count($slides== 0{
  74.         $sloodle->response->quick_output(-10501'PRESENTER''There are no slides in this presentation'false);
  75.         exit();
  76.     }
  77.     $numslides count($slides);
  78.   
  79.     // Has a particular slide been requested?
  80.     $sloodleslidenum = (int)$sloodle->request->optional_param('sloodleslidenum'0);
  81.     if ($sloodleslidenum || $sloodleslidenum $numslides$sloodleslidenum 1;
  82.     
  83.     // Figure out which slide we are going to output
  84.     $outputslide null;
  85.     $curslidenum 1;
  86.     foreach ($slides as $curslide{
  87.         // If this is the current slide we are after, then output it
  88.         if ($curslidenum == $sloodleslidenum{
  89.             $outputslide $curslide;
  90.             break;
  91.         }
  92.         $curslidenum++;
  93.     }
  94.  
  95.  
  96.     // Output the basic presenter information
  97.     $sloodle->response->set_status_code(1);
  98.     $sloodle->response->set_status_descriptor('OK');
  99.     $sloodle->response->add_data_line(array($numslidessloodle_clean_for_output($sloodle->module->get_name())));
  100.     
  101.     // Our plugin data will be store in these variables
  102.     $slidetype ''$slidesource '';
  103.     // Attempt to load the plugin required by our current slide
  104.     sloodle_debug("Attempting to load plugin \"{$outputslide->type}\"...");
  105.     $slideplugin $sloodle->plugins->get_plugin($outputslide->type);
  106.     if ($slideplugin === false{
  107.         // Indicate the error as a side effect, and specify the type as an error
  108.         sloodle_debug("Failed to load plugin\n");
  109.         $sloodle->response->add_side_effect(-132);
  110.         $slidetype 'ERROR';
  111.         $slidesource '';
  112.     else {
  113.         // Load the slide data from the plugin
  114.         sloodle_debug("Loaded plugin OK\n");
  115.         list($slidetype$slidesource$slideplugin->render_slide_for_sl($outputslide);
  116.     }
  117.  
  118.     // Output the slide data
  119.     $sloodle->response->add_data_line(array($sloodleslidenumsloodle_clean_for_output($slidetype)sloodle_clean_for_output($slidesource)sloodle_clean_for_output($outputslide->name)));
  120.     $sloodle->response->render_to_output();
  121.     exit();
  122.  
  123. ?>

Documentation generated on Fri, 17 Jul 2009 11:01:45 +0100 by phpDocumentor 1.4.0