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

Source for file HTMLLayer.class.php

Documentation is available at HTMLLayer.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package html
  9.  */
  10. if!defined"CLASSPATH" ) )
  11. {
  12.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  13.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  14.   exit();
  15. }
  16.  
  17. /**
  18.  * Including the basic class of all HTML-tags.
  19.  */
  20. require_onceCLASSPATH."html/ABSTHTMLTag.class.php" );
  21. /**
  22.  * A pool of regular expressions.
  23.  */
  24. include_onceCLASSPATH."RegExpConstants.inc.php" );
  25.  
  26. /**
  27.  * A class to generate "<div>"-Layer.
  28.  *
  29.  * @package   html
  30.  * @version   0.2.33
  31.  * @author    Daniel Plücken <daniel@debakel.net>
  32.  * @license   http://www.gnu.org/copyleft/lesser.html
  33.  *             GNU Lesser General Public License
  34.  * @copyright Copyright (c) 2004 Daniel Plücken <daniel@debakel.net>
  35.  *
  36.  *  This library is free software; you can redistribute it and/or
  37.  *  modify it under the terms of the GNU Lesser General Public
  38.  *  License as published by the Free Software Foundation; either
  39.  *  version 2.1 of the License.
  40.  *
  41.  *  This library is distributed in the hope that it will be useful,
  42.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  43.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44.  *  GNU Lesser General Public License for more details.
  45.  *
  46.  *  You should have received a copy of the GNU Lesser General
  47.  *  Public License along with this library; if not, write to the
  48.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  49.  *  Boston, MA 02111-1307 USA
  50.  */
  51. class HTMLLayer extends ABSTHTMLTag
  52. {
  53.    /**
  54.     * @var    integer 
  55.     * @access public
  56.     */
  57.    var $position;
  58.    /**
  59.     * @var    integer 
  60.     * @access public
  61.     */
  62.    var $top;
  63.    /**
  64.     * @var    integer 
  65.     * @access public
  66.     */
  67.    var $left;
  68.    /**
  69.     * @var    integer 
  70.     * @access public
  71.     */
  72.    var $width;
  73.    /**
  74.     * @var    integer 
  75.     * @access public
  76.     */
  77.    var $height;
  78.    /**
  79.     * @var    string 
  80.     * @access public
  81.     */
  82.    var $visible = "visible"// hidden
  83.    /**
  84.     * @var    string 
  85.     * @access public
  86.     */
  87.    var $z_index = 10;
  88.    /**
  89.     * @var    string 
  90.     * @access public
  91.     */
  92.    var $body;
  93.    /**
  94.     * var     string
  95.     * @access public
  96.     */
  97.    var $bgcolor;
  98.    /**
  99.     * @var    boolean 
  100.     * @access public
  101.     */
  102.    var $noformat = false;
  103.  
  104.  
  105.  
  106.    /**
  107.     * Constructor.
  108.     *
  109.     * @version 1.2
  110.     * @since   0.1.0
  111.     * @author  Daniel Plücken <daniel@debakel.net>
  112.     * @access  public
  113.     * @param   $name The value of the name- and id-attribute of this layer.
  114.     * @return  void 
  115.     */
  116.    function HTMLLayer$name "" )
  117.    {
  118.      $this->name = $name;
  119.      $this->setId$name );
  120.    }
  121.  
  122.  
  123.  
  124.    /**
  125.     * Sets the background color of this layer.
  126.     *
  127.     * @version 1.0
  128.     * @since   0.1.0
  129.     * @author  Daniel Plücken <daniel@debakel.net>
  130.     * @access  public
  131.     * @param   string $string 
  132.     * @return  void 
  133.     */
  134.    function setBGColor$string )
  135.    $this->bgcolor = $string}
  136.  
  137.  
  138.  
  139.    /**
  140.     * Sets the content of this layer.
  141.     *
  142.     * @version 1.0
  143.     * @since   0.1.0
  144.     * @author  Daniel Plücken <daniel@debakel.net>
  145.     * @access  public
  146.     * @param   string $string 
  147.     * @return  void 
  148.     */
  149.    function setBody$string )
  150.    $this->body = $string}
  151.  
  152.  
  153.  
  154.    /**
  155.     * Sets the depth of this layer.
  156.     *
  157.     * @version 1.1
  158.     * @since   0.1.0
  159.     * @author  Daniel Plücken <daniel@debakel.net>
  160.     * @access  public
  161.     * @param   integer $int 
  162.     * @return  void 
  163.     */
  164.    function setZIndex$int )
  165.    {
  166.      if(  preg_match"!^-?".INTEGER."$!"$int ) )
  167.        $this->z_index = $int;
  168.      else
  169.      if!empty$int ) )
  170.        die(
  171.             "The value \"".$int."\" is not valid for the z-index of a Layer."
  172.            ."<br>The value has to be a number!"
  173.           );
  174.    }
  175.  
  176.  
  177.  
  178.    /**
  179.     * Sets the visibility of this layer to visible.
  180.     *
  181.     * @version 1.0
  182.     * @since   0.1.0
  183.     * @author  Daniel Plücken <daniel@debakel.net>
  184.     * @access  public
  185.     * @return  void 
  186.     */
  187.    function setVisible()
  188.    $this->visible = "visible"}
  189.  
  190.  
  191.  
  192.    /**
  193.     * Sets the visibility of this layer to visible.
  194.     *
  195.     * @version 1.0
  196.     * @since   0.2.1
  197.     * @author  Daniel Plücken <daniel@debakel.net>
  198.     * @access  public
  199.     * @return  void 
  200.     */
  201.    function setInvisible()
  202.    $this->visible = "hidden"}
  203.  
  204.  
  205.  
  206.    /**
  207.     * Sets the behaviour of the position of this layer.
  208.     *
  209.     * @version 1.1
  210.     * @since   0.1.0
  211.     * @author  Daniel Plücken <daniel@debakel.net>
  212.     * @access  public
  213.     * @param   string $string 
  214.     * @return  void 
  215.     */
  216.    function setPosition$string )
  217.    {
  218.      if(
  219.          $string == "absolute"
  220.       || $string == "fixed"
  221.       || $string == "relative"
  222.       || $string == "static"
  223.        )
  224.        $this->position = $string;
  225.      else
  226.        die(
  227.             "<pre>\r\n"
  228.            ."You can only set the following values to the position:\r\n\r\n"
  229.            ."       absolute\r\n"
  230.            ."       fixed\r\n"
  231.            ."       relative\r\n"
  232.            ."       static\r\n"
  233.            ."</pre>\r\n"
  234.           );
  235.    }
  236.  
  237.  
  238.  
  239.    /**
  240.     * Sets the left-position of this layer.
  241.     *
  242.     * @version 1.0
  243.     * @since   0.1.8
  244.     * @author  Daniel Plücken <daniel@debakel.net>
  245.     * @access  public
  246.     * @param   integer $int 
  247.     * @return  void 
  248.     */
  249.    function setLeft$int )
  250.    {
  251.      ifpreg_match"!^".INTEGER."%?$!"$int ) )
  252.        $this->left = $int;
  253.      else
  254.      if!empty$int ) )
  255.        die(
  256.             "The value \"".$int."\" is not valid for the top-position of a "
  257.            ."Layer.<br>"
  258.            ."The value has to be a number!"
  259.           );
  260.    }
  261.  
  262.  
  263.  
  264.    /**
  265.     * Sets the top-position of this layer.
  266.     *
  267.     * @version 1.0
  268.     * @since   0.1.8
  269.     * @author  Daniel Plücken <daniel@debakel.net>
  270.     * @access  public
  271.     * @param   integer $int 
  272.     * @return  void 
  273.     */
  274.    function setTop$int )
  275.    {
  276.      ifpreg_match"!^".INTEGER."%?$!"$int ) )
  277.        $this->top = $int;
  278.      else
  279.        die(
  280.             "The value \"".$int."\" is not valid for the top-position of a "
  281.            ."Layer.<br>"
  282.            ."The value has to be a number!"
  283.           );
  284.    }
  285.  
  286.  
  287.  
  288.    /**
  289.     * Sets the width of this layer.
  290.     *
  291.     * @version 1.0
  292.     * @since   0.1.8
  293.     * @author  Daniel Plücken <daniel@debakel.net>
  294.     * @access  public
  295.     * @param   integer $int 
  296.     * @return  void 
  297.     */
  298.    function setWidth$int )
  299.    {
  300.      ifpreg_match"!^".INTEGER."%?$!"$int ) )
  301.        $this->width = $int;
  302.      else
  303.      if!empty$int ) )
  304.        die(
  305.             "The value \"".$int."\" is not valid for the width of a Layer.<br>"
  306.            ."The value has to be a number!"
  307.           );
  308.    }
  309.  
  310.  
  311.  
  312.    /**
  313.     * Sets the height of this layer.
  314.     *
  315.     * @version 1.0
  316.     * @since   0.1.8
  317.     * @author  Daniel Plücken <daniel@debakel.net>
  318.     * @access  public
  319.     * @param   integer $int 
  320.     * @return  void 
  321.     */
  322.    function setHeight$int )
  323.    {
  324.      ifpreg_match"!^".INTEGER."%?$!"$int ) )
  325.        $this->height = $int;
  326.      else
  327.        die(
  328.             "The value \"".$int."\" is not valid for the height of a Layer.<br>"
  329.            ."The value has to be a number!"
  330.           );
  331.    }
  332.  
  333.  
  334.  
  335.    /**
  336.     * Returns a generated string based on the attributes of this HTML-Object.
  337.     *
  338.     * @version 1.94
  339.     * @since   0.1.0
  340.     * @author  Daniel Plücken <daniel@debakel.net>
  341.     * @access  public
  342.     * @return  string 
  343.     */
  344.    function get()
  345.    {
  346.      $this->idExists$this->idtrue );
  347.  
  348.      $newline $this->no_format
  349.                 ? ""
  350.                 : "\r\n";
  351.  
  352.      $outputstr  "<!--\r\n"
  353.                   ."--><div id=\"".$this->id."\"\r\n"
  354.                   ."        style=\"z-index:".$this->z_index.";"
  355.                                   ."visibility:".$this->visible.";"
  356.                                   .(
  357.                                        !empty$this->bgcolor )
  358.                                        ? "background-color:".$this->bgcolor.";"
  359.                                        : ""
  360.                                    )
  361.                                   .(
  362.                                        !empty$this->position )
  363.                                        ? "position:".$this->position.";"
  364.                                        : ""
  365.                                    )
  366.                                   .(
  367.                                        preg_match"!\d+!"$this->top )
  368.                                        ? "top:".$this->top.(
  369.                                             strpos$this->top"%" )
  370.                                             ? ";"
  371.                                             : "px;"
  372.                                                            )
  373.                                        : ""
  374.                                    )
  375.                                   .(
  376.                                        preg_match"!\d+!"$this->left )
  377.                                        ? "left:".$this->left.(
  378.                                             strpos$this->left"%" )
  379.                                             ? ";"
  380.                                             : "px;"
  381.                                                              )
  382.                                        : ""
  383.                                    )
  384.                                   .(
  385.                                        preg_match"!\d+!"$this->width )
  386.                                        ? "width:".$this->width.(
  387.                                             strpos$this->width"%" )
  388.                                             ? ";"
  389.                                             : "px;"
  390.                                                                )
  391.                                        : ""
  392.                                    )
  393.                                   .(
  394.                                        preg_match"!\d+!"$this->height )
  395.                                        ? "height:".$this->height.(
  396.                                             strpos$this->height"%" )
  397.                                             ? ";"
  398.                                             : "px;"
  399.                                                                  )
  400.                                        : ""
  401.                                    )
  402.                                   .(
  403.                                        !empty$this->freestyle )
  404.                                        ? $this->freestyle
  405.                                        : ""
  406.                                    )
  407.                                   ."\"\r\n"
  408.                   .(
  409.                      !empty$this->name )
  410.                      ? "        name=\"".$this->name."\"\r\n"
  411.                      : ""
  412.                    )
  413.                   .(
  414.                      !empty$this->style_class )
  415.                      ? "        class=\"".$this->style_class."\"\r\n"
  416.                      : ""
  417.                    )
  418.                   .(
  419.                      !empty$this->click )
  420.                      ? "        onClick=\"".$this->click."\"\r\n"
  421.                      : ""
  422.                    )
  423.                   .(
  424.                      !empty$this->mouseup )
  425.                      ? "        onMouseup=\"".$this->mouseup."\"\r\n"
  426.                      : ""
  427.                    )
  428.                   .(
  429.                      !empty$this->mouseout )
  430.                      ? "        onMouseout=\"".$this->mouseout."\"\r\n"
  431.                      : ""
  432.                    )
  433.                   .(
  434.                      !empty$this->mouseover )
  435.                      ? "        onMouseover=\"".$this->mouseover."\"\r\n"
  436.                      : ""
  437.                    )
  438.                   .(
  439.                      !empty$this->mousemove )
  440.                      ? "        onMousemove=\"".$this->mousemove."\"\r\n"
  441.                      : ""
  442.                    )
  443.                   .(
  444.                      !empty$this->other_attributes )
  445.                      ? "        ".$this->other_attributes."\r\n"
  446.                      : ""
  447.                    )
  448.                   ."   >";
  449.      $outputstr .= $this->body;
  450.      $outputstr .= "<!--\r\n"
  451.                   ."--></div>";
  452.  
  453.      return $outputstr;
  454.    }
  455. // END of class HTMLLayer
  456. ?>

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