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

Source for file HTMLTextArea.class.php

Documentation is available at HTMLTextArea.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 forms
  9.  * @subpackage items
  10.  */
  11. if!defined"CLASSPATH" ) )
  12. {
  13.   echo "<h3>You have to define the constant CLASSPATH!</h3>\r\n";
  14.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n";
  15.   exit();
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. require_onceCLASSPATH."forms/items/ABSTHTMLFormItem.class.php" );
  22.  
  23. /**
  24.  * @package    forms
  25.  * @subpackage items
  26.  * @version    0.1.6
  27.  * @author     Daniel Plücken <daniel@debakel.net>
  28.  * @license    http://www.gnu.org/copyleft/lesser.html
  29.  *              GNU Lesser General Public License
  30.  * @copyright  Copyright (c) 2004 Daniel Plücken <daniel@debakel.net>
  31.  *
  32.  *  This library is free software; you can redistribute it and/or
  33.  *  modify it under the terms of the GNU Lesser General Public
  34.  *  License as published by the Free Software Foundation; either
  35.  *  version 2.1 of the License.
  36.  *
  37.  *  This library is distributed in the hope that it will be useful,
  38.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  39.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40.  *  GNU Lesser General Public License for more details.
  41.  *
  42.  *  You should have received a copy of the GNU Lesser General
  43.  *  Public License along with this library; if not, write to the
  44.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  45.  *  Boston, MA 02111-1307 USA
  46.  */
  47. {
  48.    /**
  49.     * Stores the width of this text area in text cols (letter count per row).
  50.     *
  51.     * @var    $cols 
  52.     * @access public
  53.     */
  54.    var $cols;
  55.    /**
  56.     * Stores the height of this text area in text rows.
  57.     *
  58.     * @var    $rows 
  59.     * @access public
  60.     */
  61.    var $rows;
  62.  
  63.  
  64.  
  65.    /**
  66.     * Constructor
  67.     *
  68.     * @version 1.3
  69.     * @since   0.1.0
  70.     * @author  Daniel Plücken <daniel@debakel.net>
  71.     * @access  public
  72.     * @param   string  $name 
  73.     * @param   string  $value 
  74.     * @param   integer $cols  Width of textarea in chars.
  75.     * @param   integer $rows  Height of textarea in chars.
  76.     */
  77.    function HTMLTextArea(
  78.                           $name  "",
  79.                           $value "",
  80.                           $cols  "",
  81.                           $rows  ""
  82.                         )
  83.    {
  84.      $this->name  = $name;
  85.      $this->value = stripslashes$value );
  86.      $this->cols  = !empty$cols $cols 25;
  87.      $this->rows  = !empty$rows $rows 5;
  88.    }
  89.  
  90.  
  91.  
  92.    /**
  93.     * Returns the the width of this text area in text cols (letter count per
  94.     * row).
  95.     *
  96.     * @version 1.0
  97.     * @since   0.1.0
  98.     * @author  Daniel Plücken <daniel@debakel.net>
  99.     * @access  public
  100.     * @return  integer 
  101.     */
  102.    function getCols()
  103.    return $this->cols}
  104.  
  105.  
  106.  
  107.    /**
  108.     * Returns the the height of this text area in text rows.
  109.     *
  110.     * @version 1.0
  111.     * @since   0.1.0
  112.     * @author  Daniel Plücken <daniel@debakel.net>
  113.     * @access  public
  114.     * @return  integer 
  115.     */
  116.    function getRows()
  117.    return $this->rows}
  118.  
  119.  
  120.  
  121.    /**
  122.     * Sets the the width of this text area in text cols (letter count per
  123.     * row).
  124.     *
  125.     * @version 1.0
  126.     * @since   0.1.0
  127.     * @author  Daniel Plücken <daniel@debakel.net>
  128.     * @access  public
  129.     * @param   integer $int 
  130.     * @return  void 
  131.     */
  132.    function setCols$int )
  133.    $this->cols = $int}
  134.  
  135.  
  136.  
  137.    /**
  138.     * Sets the the height of this text area in text rows.
  139.     *
  140.     * @version 1.0
  141.     * @since   0.1.0
  142.     * @author  Daniel Plücken <daniel@debakel.net>
  143.     * @access  public
  144.     * @param   integer $int 
  145.     * @return  void 
  146.     */
  147.    function setRows$int )
  148.    $this->rows = $int}
  149.  
  150.  
  151.  
  152.    /**
  153.     * Returns an if-order of a javascript to check whether this item is NOT
  154.     * filled
  155.     *
  156.     * @version 1.1
  157.     * @since   0.1.5
  158.     * @author  Daniel Plücken <daniel@debakel.net>
  159.     * @access  public
  160.     * @return  string 
  161.     */
  162.    function getCheckOrder()
  163.    {
  164.       $out_str "document.".$this->parentform->name."."
  165.                             .$this->name.".value == \"\"";
  166.  
  167.       return $out_str;
  168.    }
  169.  
  170.  
  171.  
  172.    /**
  173.     * Generates the sourcecode to build this object and returns it.
  174.     *
  175.     * @version 1.0
  176.     * @since   0.1.2
  177.     * @author  Daniel Plücken <daniel@debakel.net>
  178.     * @access  public
  179.     * @return  string 
  180.     */
  181.    function getPHPSource()
  182.    {
  183.       $out  "unset( \x24value );\r\n";
  184.       $out .= "\x24value = \x24_POST[\"".$this -> getName()."\"]\r\n"
  185.              ."        .\x24_GET[\"".$this -> getName()."\"];\r\n";
  186.       $out .= "\x24input[] = new HTMLTextArea(\r\n"
  187.              ."                              \"".$this -> getName()."\",\r\n"
  188.              ."                              \x24value,\r\n"
  189.              ."                              \"".$this -> getCols()."\",\r\n"
  190.              ."                              \"".$this -> getRows()."\"\r\n"
  191.              ."                           );\r\n";
  192.  
  193.       $tmp $this -> getValue();
  194.       $out .= !empty$tmp )
  195.                     ? "if( \x24value === \"\" )\r\n"
  196.                      ."  \x24input[count(\x24input)-1]"
  197.                        ."->setValue( \"".$tmp."\" );\r\n\r\n"
  198.                     : "\r\n";
  199.  
  200.       return $out;
  201.    }
  202.  
  203.  
  204.  
  205.    /**
  206.     * Returns a generated string based on the attributes of this object.
  207.     *
  208.     * @version 1.5
  209.     * @since   0.1.0
  210.     * @author  Daniel Plücken <daniel@debakel.net>
  211.     * @access  public
  212.     * @param   string $forminput The possible values are "POST" and "GET".
  213.     *                             If one of this value is set, the source of
  214.     *                             this textarea will be output with php-source
  215.     *                             in the body to put the value from the form in
  216.     *                             it.
  217.     * @return  string 
  218.     */
  219.    function get$forminput "" )
  220.    {
  221.       $forminput strtoupper$forminput );
  222.       if$forminput == "POST" || $forminput == "GET" )
  223.         $tmp "<?php echo \x24_".$forminput."['".$this->name."']; ?>";
  224.       else
  225.         $tmp $this->value;
  226.  
  227.       $out  $this->getLabel();
  228.       $out .= "<!--\r\n-->"
  229.              ."<textarea\r\n"
  230.              ."             name=\"".$this->name."\"\r\n";
  231.  
  232.       if !empty$this->style_class ) )
  233.          $out .= "             class=\"".$this->style_class."\"\r\n";
  234.       if !empty$this->freestyle ) )
  235.          $out .= "             style=\"".$this->freestyle."\"\r\n";
  236.       if !empty$this->click ) )
  237.          $out .= "             onClick=\"".$this->click."\"\r\n";
  238.       if !empty$this->blur ) )
  239.          $out .= "             onBlur=\"".$this->blur."\"\r\n";
  240.       if !empty$this->focus ) )
  241.          $out .= "             onFocus=\"".$this->focus."\"\r\n";
  242.       if !empty$this->mouseup ) )
  243.          $out .= "             onMouseup=\"".$this->mouseup."\"\r\n";
  244.       if !empty$this->mouseover ) )
  245.          $out .= "             onMouseover=\"".$this->mouseover."\"\r\n";
  246.       if !empty$this->mousemove ) )
  247.          $out .= "             onMousemove=\"".$this->mousemove."\"\r\n";
  248.       if !empty$this->mouseout ) )
  249.          $out .= "             onMouseout=\"".$this->mouseout."\"\r\n";
  250.  
  251.       $out .= "             cols=\"".$this->cols."\"\r\n";
  252.       $out .= "             rows=\"".$this->rows."\"\r\n";
  253.       $out .= !$this->enabled "             readonly\r\n" "";
  254.       $out .= "    >".$tmp."</textarea>";
  255.  
  256.       return $out;
  257.    }
  258. // ENDE class HTMLTextArea
  259. ?>

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