Source for file image.php

Documentation is available at image.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 image 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 image 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.         $output "<img src=\"{$url}\" alt=\"{$slide->name}\" />";
  52.         return $output;
  53.     }
  54.  
  55.     /**
  56.     * Render the given slide for virtual-world output.
  57.     * This returns two items of data in a numeric array.
  58.     * The first is the virtual world compatible type identifier: web, image, video, or audio (or a mime type).
  59.     * The second is the absolute URL to give it.
  60.     * @param SloodlePresenterSlide $slide An object containing the raw slide data.
  61.     * @return array Numeric array containg (type, url)
  62.     */
  63.     function render_slide_for_sl($slide)
  64.     {
  65.         return array('image/*'$this->get_absolute_url($slide->source));
  66.     }
  67.  
  68.     /**
  69.     * Gets the human-readable name of this plugin.
  70.     * This MUST be overridden by base classes. If not, it will just return the name of the class.
  71.     * @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.
  72.     * @access public
  73.     * @return string The human-readable name of this plugin
  74.     */
  75.     function get_plugin_name($lang null)
  76.     {
  77.         return 'Image';
  78.     }
  79.  
  80.     /**
  81.     * Gets the internal version number of this plugin.
  82.     * This MUST be overridden.
  83.     * This should be a number like the internal version number for Moodle modules, containing the date and release number.
  84.     * Format is: YYYYMMDD##.
  85.     * For example, "2009012302" would be the 3rd release on the 23rd January 2009.
  86.     * @return int The version number of this module.
  87.     */
  88.     function get_version()
  89.     {
  90.         return 2009050600;
  91.     }
  92.  
  93.  
  94. }
  95.  
  96.  
  97. ?>

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