html
[ class tree: html ] [ index: html ] [ all elements ]

Source for file SWFObject.class.php

Documentation is available at SWFObject.class.php

  1. <?php
  2. /**
  3.  * @package html
  4.  */
  5.  
  6. /**
  7.  *
  8.  */
  9. include_once CLASSPATH."html/JavaScript.class.php";
  10. /**
  11.  *
  12.  */
  13. include_once CLASSPATH."html/HTMLLayer.class.php";
  14.  
  15. /**
  16.  * @package html
  17.  *
  18.  * @version   0.1.12
  19.  * @since     0.9.0.8
  20.  * @author    Daniel Plücken <daniel@debakel.net>
  21.  * @license   http://www.gnu.org/copyleft/lesser.html
  22.  *             GNU Lesser General Public License
  23.  * @copyright Copyright (C) 2006 Daniel Plücken <daniel@debakel.net>
  24.  *
  25.  *  This library is free software; you can redistribute it and/or
  26.  *  modify it under the terms of the GNU Lesser General Public
  27.  *  License as published by the Free Software Foundation; either
  28.  *  version 2.1 of the License.
  29.  *
  30.  *  This library is distributed in the hope that it will be useful,
  31.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  32.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33.  *  GNU Lesser General Public License for more details.
  34.  *
  35.  *  You should have received a copy of the GNU Lesser General
  36.  *  Public License along with this library; if not, write to the
  37.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  38.  *  Boston, MA 02111-1307 USA
  39.  */
  40. class SWFObject extends HTMLLayer
  41. {
  42.     /**
  43.      * The path to the swf object.
  44.      *
  45.      * @var    string $path 
  46.      * @access public
  47.      */
  48.     var $path = "";
  49.     /**
  50.      * The path to the swf object.
  51.      *
  52.      * @var    string $flash_version 
  53.      * @access public
  54.      */
  55.     var $flash_version = "8";
  56.     /**
  57.      * Stores the parameters that should put into the swf.
  58.      *
  59.      * @var    array  $param_arr 
  60.      * @access private
  61.      */
  62.     var $param_arr = array();
  63.     /**
  64.      * Stores the variables that should put into the swf.
  65.      *
  66.      * @var    array  $variable_arr 
  67.      * @access private
  68.      */
  69.     var $variable_arr = array();
  70.     /**
  71.      * Stores the delay to write the object in the html-container.
  72.      *
  73.      * @var    array  $delay 
  74.      * @access private
  75.      */
  76.     var $delay = 0;
  77.  
  78.  
  79.  
  80.     /**
  81.      * Constructor.
  82.      *
  83.      * @version 1.0
  84.      * @since   0.1.0
  85.      * @author  Daniel Plücken <daniel@debakel.net>
  86.      * @access  public
  87.      * @param   $path 
  88.      * @param   $id    The value of the name- and id-attribute of this layer.
  89.      * @return  void 
  90.      */
  91.     function SWFObject$path$id "flashcontent" )
  92.     {
  93.       $this->path = $path;
  94.       $this->bgcolor = "#FFFFFF";
  95.  
  96.       parent::HTMLLayer$id );
  97.     }
  98.  
  99.  
  100.  
  101.     /**
  102.      * Sets a delay for writing the object into the html-container. This can be
  103.      * used if a browser have problems with the display on a site refresh.
  104.      *
  105.      * @version 1.0
  106.      * @since   0.1.12
  107.      * @author  Daniel Plücken <daniel@debakel.net>
  108.      * @access  public
  109.      * @param   integer $int 
  110.      * @return  void 
  111.      */
  112.     function setDelay$int )
  113.     $this->delay = $int}
  114.  
  115.  
  116.  
  117.     /**
  118.      * This function sets the required version of the flash player.
  119.      *
  120.      * @version 1.0
  121.      * @since   0.1.1
  122.      * @author  Daniel Plücken <daniel@debakel.net>
  123.      * @access  public
  124.      * @param   integer $int 
  125.      * @return  void 
  126.      */
  127.     function setVersion$int )
  128.     $this->flash_version = $int}
  129.  
  130.  
  131.  
  132.     /**
  133.      * This function sets the required version of the flash player. This
  134.      * method is an alias for setVersion( $int ).
  135.      *
  136.      * @version 1.0
  137.      * @since   0.1.1
  138.      * @author  Daniel Plücken <daniel@debakel.net>
  139.      * @access  public
  140.      * @param   integer $int 
  141.      * @return  void 
  142.      */
  143.     function setFlashVersion$int )
  144.     $this->setVersion$int )}
  145.  
  146.  
  147.  
  148.     /**
  149.      * This function is an alias for setBody.
  150.      *
  151.      * @version 1.0
  152.      * @since   0.1.0
  153.      * @author  Daniel Plücken <daniel@debakel.net>
  154.      * @access  public
  155.      * @param   string $string 
  156.      * @return  void 
  157.      */
  158.     function setAlternative$string )
  159.     $this->setBody$string )}
  160.  
  161.  
  162.  
  163.     /**
  164.      * Adds an parameter to this swf object.
  165.      *
  166.      * @version 1.0
  167.      * @since   0.1.0
  168.      * @author  Daniel Plücken <daniel@debakel.net>
  169.      * @access  public
  170.      * @param   string $name 
  171.      * @param   string $value 
  172.      * @return  void 
  173.      */
  174.     function addParam$name$value )
  175.     $this->param_arr[$name$value}
  176.  
  177.  
  178.  
  179.     /**
  180.      * Adds an variable to this swf object.
  181.      *
  182.      * @version 1.0
  183.      * @since   0.1.1
  184.      * @author  Daniel Plücken <daniel@debakel.net>
  185.      * @access  public
  186.      * @param   string $name 
  187.      * @param   string $value 
  188.      * @return  void 
  189.      */
  190.     function addVariable$name$value )
  191.     $this->variable_arr[$name$value}
  192.  
  193.  
  194.  
  195.     /**
  196.      * Returns a javascript to generate a swf object.
  197.      *
  198.      * @version 1.0
  199.      * @since   0.1.0
  200.      * @author  Daniel Plücken <daniel@debakel.net>
  201.      * @access  public
  202.      * @return  string 
  203.      */
  204.     function getJSIncludeForSWFObject()
  205.     {
  206.        static $alreadyReturned false;
  207.  
  208.        $out "";
  209.        if !$alreadyReturned )
  210.        {
  211.           $alreadyReturned true;
  212.  
  213.           $out "  <script type=\"text/javascript\" "
  214.                           ."src=\"".CLASSPATH."jslib/swfobject.js\">"
  215.                   ."</script>";
  216.        }
  217.  
  218.  
  219.  
  220.        return $out;
  221.     }
  222.  
  223.  
  224.  
  225.     /**
  226.      * Returns a generated string based on the attributes of this HTML-Object.
  227.      *
  228.      * @version 1.2
  229.      * @since   0.1.0
  230.      * @author  Daniel Plücken <daniel@debakel.net>
  231.      * @access  public
  232.      * @return  string 
  233.      */
  234.     function get()
  235.     {
  236.       $js =new JavaScript();
  237.       $str_parent parent::get();
  238.  
  239.       $str_tmp "";
  240.       foreach $this->param_arr as $key => $val )
  241.         $str_tmp .= "    ".$this->id.".addParam( '".$key."', '".$val."' );\r\n";
  242.  
  243.       foreach $this->variable_arr as $key => $val )
  244.         $str_tmp .= "    ".$this->id.".addVariable( '".$key."', '".$val."' );\r\n";
  245.  
  246.       $js->add(
  247.            "var ".$this->id." = new SWFObject( '".$this->path."', "
  248.                                              ."'".$this->id."_obj', "
  249.                                              ."'".$this->width."', "
  250.                                              ."'".$this->height."', "
  251.                                              ."'".$this->flash_version."', "
  252.                                              ."'".$this->bgcolor."' );\r\n"
  253.           .$str_tmp
  254.           ."    "
  255.           .(
  256.               empty$this->delay )
  257.               ? $this->id.".write( '".$this->id."' );\r\n"
  258.               : "window.setTimeout( \"".$this->id.".write( '".$this->id."' )\", ".$this->delay." );\r\n"
  259.            )
  260.               );
  261.  
  262.       return $this->getJSIncludeForSWFObject().$str_parent.$js->get();
  263.     }
  264. }
  265. ?>

Documentation generated on Thu, 05 Jun 2008 19:15:15 +0200 by phpDocumentor 1.4.1