Source for file web.php

Documentation is available at web.php

  1. <?php
  2. // This file is part of the Sloodle project (www.sloodle.org) and is released under the GNU GPL v3.
  3.  
  4. /**
  5. * Defines the SLOODLE Presenter plugin for showing web slides.
  6. *
  7. @package sloodle
  8. @copyright Copyright (c) 2009 Sloodle (various contributors)
  9. @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10. @since Sloodle 0.4.1
  11. *
  12. @contributor Peter R. Bloomfield
  13. *
  14. */
  15.  
  16.  
  17. /**
  18. * Presenter plugin for showing web slides.
  19. *
  20. @package sloodle
  21. */
  22. {
  23.  
  24.     /**
  25.     * Construct an absolute URL, based on the given source data.
  26.     * Leaves existing absolute URLs alone, but converts relative URLs as necessary.
  27.     * (This allows the site to be moved without disrupting these slides.)
  28.     * @param string $source The source data from the slide.
  29.     * @return string An absolute URL.
  30.     */
  31.     function get_absolute_url($source)
  32.     {
  33.         global $CFG;
  34.         // If we have a protocol specifier, then assume this is already an absolute URL
  35.         if (strpos($source'://'!== falsereturn $source;
  36.         // Assume the source URL is relative to the Moodle WWW root.
  37.         // Make sure we don't duplicate a forward slash.
  38.         if (strpos($source'/'=== 0return $CFG->wwwroot.$source;
  39.         return $CFG->wwwroot.'/'.$source;
  40.     }
  41.  
  42.     /**
  43.     * Render the given slide for browser output -- NOTE: render to a string, and return the string.
  44.     * The title of the slide need not be included -- simply the basic iFrame or embedded player etc.
  45.     * @param SloodlePresenterSlide $slide An object containing the raw slide data.
  46.     * @return string 
  47.     */
  48.     function render_slide_for_browser($slide)
  49.     {
  50.         $url $this->get_absolute_url($slide->source);
  51.         $framewidth 500;
  52.         $frameheight 500;
  53.         if (isset($this->presenter)) {
  54.             $framewidth $this->presenter->get_frame_width();
  55.             $frameheight $this->presenter->get_frame_height();
  56.         }        
  57.  
  58.         $output "<iframe src=\"{$url}\" style=\"width:{$framewidth}px; height:{$frameheight}px;\"></iframe>";
  59.         return $output;
  60.     }
  61.  
  62.     /**
  63.     * Render the given slide for virtual-world output.
  64.     * This returns two items of data in a numeric array.
  65.     * The first is the virtual world compatible type identifier: web, image, video, or audio (or a mime type).
  66.     * The second is the absolute URL to give it.
  67.     * @param SloodlePresenterSlide $slide An object containing the raw slide data.
  68.     * @return array Numeric array containg (type, url)
  69.     */
  70.     function render_slide_for_sl($slide)
  71.     {
  72.         return array('text/html'$this->get_absolute_url($slide->source));
  73.     }
  74.  
  75.     /**
  76.     * Gets the human-readable name of this plugin.
  77.     * This MUST be overridden by base classes. If not, it will just return the name of the class.
  78.     * @param string $lang Optional -- can specify the language we want the plugin name in, as an identifier like "en_utf8". If unspecified, then the current Moodle language should be used.
  79.     * @access public
  80.     * @return string The human-readable name of this plugin
  81.     */
  82.     function get_plugin_name($lang null)
  83.     {
  84.         return 'Web';
  85.     }
  86.  
  87.     /**
  88.     * Gets the internal version number of this plugin.
  89.     * This MUST be overridden.
  90.     * This should be a number like the internal version number for Moodle modules, containing the date and release number.
  91.     * Format is: YYYYMMDD##.
  92.     * For example, "2009012302" would be the 3rd release on the 23rd January 2009.
  93.     * @return int The version number of this module.
  94.     */
  95.     function get_version()
  96.     {
  97.         return 2009050600;
  98.     }
  99.  
  100.  
  101. }
  102.  
  103.  
  104. ?>

Documentation generated on Fri, 17 Jul 2009 11:02:49 +0100 by phpDocumentor 1.4.0