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

Source for file ABSTHTMLTextInput.class.php

Documentation is available at ABSTHTMLTextInput.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>\n";
  14.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  15.   exit();
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. require_onceCLASSPATH."forms/items/ABSTHTMLFormItem.class.php" );
  22.  
  23. /**
  24.  * A class to generate text input fields.
  25.  *
  26.  * @package    forms
  27.  * @subpackage items
  28.  * @version    0.2.91
  29.  * @static
  30.  * @author     Daniel Plücken <daniel@debakel.net>
  31.  * @license    http://www.gnu.org/copyleft/lesser.html
  32.  *              GNU Lesser General Public License
  33.  * @copyright  Copyright (c) 2003 Daniel Plücken <daniel@debakel.net>
  34.  *
  35.  *  This library is free software; you can redistribute it and/or
  36.  *  modify it under the terms of the GNU Lesser General Public
  37.  *  License as published by the Free Software Foundation; either
  38.  *  version 2.1 of the License.
  39.  *
  40.  *  This library is distributed in the hope that it will be useful,
  41.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  43.  *  GNU Lesser General Public License for more details.
  44.  *
  45.  *  You should have received a copy of the GNU Lesser General
  46.  *  Public License along with this library; if not, write to the
  47.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  48.  *  Boston, MA 02111-1307 USA
  49.  */
  50. {
  51.    /**
  52.     * @var integer   The value of the "size"-attribute of this text-input.
  53.     * @access private
  54.     */
  55.    var $size;
  56.    /**
  57.     * @var integer   The value of the "maxLength"-attribute of this text-input.
  58.     * @access private
  59.     */
  60.    var $maxchars;
  61.  
  62.  
  63.  
  64.    /**
  65.     * Constructor
  66.     *
  67.     * @version 1.0
  68.     * @since   0.1.1
  69.     * @author  Daniel Plücken <daniel@debakel.net>
  70.     * @access  public
  71.     * @return  void 
  72.     */
  73.    function ABSTHTMLTextInput()
  74.    {
  75.      die(
  76.           "ABSTHTMLTextInput is an abstract class. "
  77.          ."You cannot get an instance of it."
  78.         );
  79.    }
  80.  
  81.  
  82.  
  83.    /**
  84.     * Constructor
  85.     *
  86.     * @version 1.3
  87.     * @since   0.1.0
  88.     * @author  Daniel Plücken <daniel@debakel.net>
  89.     * @access  public
  90.     * @param   string  $name 
  91.     * @param   string  $value 
  92.     * @param   integer $size 
  93.     * @param   integer $maxchar 
  94.     * @param   string  $style_class 
  95.     * @param   string  $other_attributes 
  96.     * @return  void 
  97.     */
  98.    function __constructor(
  99.                            $name             "",
  100.                            $value            "",
  101.                            $size             0,
  102.                            $maxchars         0,
  103.                            $style_class      "",
  104.                            $other_attributes ""
  105.                          )
  106.    {
  107.       $this->name             = $name;
  108.       $this->value            = $value;
  109.  
  110.       ifpreg_match"!^\d+$!"$size ) )
  111.         $this->size = $size;
  112.  
  113.       ifpreg_match"!^\d+$!"$maxchars ) )
  114.         $this->maxchars = $maxchars;
  115.  
  116.       $this->style_class      = $style_class;
  117.       $this->other_attributes = $other_attributes;
  118.    }
  119.  
  120.  
  121.  
  122.    /**
  123.     * Returns the value of this item's "size"-attribute.
  124.     *
  125.     * @version 1.0
  126.     * @since   0.1.0
  127.     * @author  Daniel Plücken <daniel@debakel.net>
  128.     * @access  public
  129.     * @return  string 
  130.     */
  131.    function getSize()
  132.    return $this->size}
  133.  
  134.  
  135.  
  136.    /**
  137.     * Returns the value of this item's "maxLength"-attribute.
  138.     *
  139.     * @version 1.0
  140.     * @since   0.1.0
  141.     * @author  Daniel Plücken <daniel@debakel.net>
  142.     * @access  public
  143.     * @return  string 
  144.     */
  145.    function getMaxChars()
  146.    return $this->maxchars}
  147.  
  148.  
  149.  
  150.    /**
  151.     * Stores the value of this item's "size"-attribute.
  152.     *
  153.     * @version 1.1
  154.     * @since   0.1.0
  155.     * @author  Daniel Plücken <daniel@debakel.net>
  156.     * @access  public
  157.     * @return  void 
  158.     */
  159.    function setSize$int )
  160.    {
  161.      ifpreg_match"!^\d+$!"$int ) )
  162.        $this->size = $int;
  163.    }
  164.  
  165.  
  166.  
  167.    /**
  168.     * Stores the value of this item's "maxLength"-attribute.
  169.     *
  170.     * @version 1.1
  171.     * @since   0.1.0
  172.     * @author  Daniel Plücken <daniel@debakel.net>
  173.     * @access  public
  174.     * @param   void 
  175.     */
  176.    function setMaxChars$int )
  177.    {
  178.      ifpreg_match"!^\d+$!"$int ) )
  179.        $this->maxchars = $int;
  180.    }
  181.  
  182.  
  183.  
  184.    /**
  185.     * Returns an if-order of a javascript to check whether this item is NOT
  186.     * filled
  187.     *
  188.     * @version 1.1
  189.     * @since   0.1.7
  190.     * @author  Daniel Plücken <daniel@debakel.net>
  191.     * @access  public
  192.     * @return  string 
  193.     */
  194.    function getCheckOrder()
  195.    {
  196.       $out "document.".$this->parentform->name."."
  197.                         .$this->name.".value == \"\"";
  198.  
  199.       return $out;
  200.    }
  201.  
  202.  
  203.  
  204.    /**
  205.     * Generates the sourcecode to build this object and returns it.
  206.     *
  207.     * @version 1.1
  208.     * @since   0.1.8
  209.     * @author  Daniel Plücken <daniel@debakel.net>
  210.     * @access  public
  211.     * @return  string 
  212.     */
  213.    function getPHPSource$type )
  214.    {
  215.       $out  "unset( \x24value );\r\n";
  216.       $out .= "\x24value = \x24_REQUEST[\"".$this->name."\"]\r\n";
  217.       $out .= "\x24input[] = new ".$type."(\r\n"
  218.              ."                               \"".$this->name."\",\r\n"
  219.              .(
  220.                 $type != "HTMLPasswordInput"
  221.                 ? "                               \x24value,\r\n"
  222.                 : ""
  223.               )
  224.              .(
  225.                 $type != "HTMLFileInput"
  226.                 ? "                               \"".$this->size."\",\r\n"
  227.                  ."                               \"".$this->maxchars."\"\r\n"
  228.                 : ""
  229.               )
  230.              ."                            );\n";
  231.  
  232.       $out .= !empty$this->value )
  233.               ? "if( \x24value === \"\" )\r\n"
  234.                ."  \x24input[count(\x24input)-1] "
  235.                  ."-> setValue( \"".$this->value."\" );\r\n\r\n"
  236.               : "\r\n";
  237.  
  238.       return $out;
  239.    }
  240.  
  241.  
  242.  
  243.    /**
  244.     * Returns a generated string based on the attributes of this object.
  245.     *
  246.     * @version 1.82
  247.     * @since   0.1.0
  248.     * @author  Daniel Plücken <daniel@debakel.net>
  249.     * @access  public
  250.     * @param   string type Possible values are "text" or "password"
  251.     * @return  string 
  252.     */
  253.    function get$type )
  254.    {
  255.       if empty$this->id ) )
  256.          $this->id = $this->name;
  257.  
  258.       $this->idExists$this->idtrue );
  259.  
  260.  
  261.       $out  $this->getLabel();
  262.  
  263.       $out .= "<!--\r\n"
  264.              ."--><input type=\"".$type."\"\r\n"
  265.              ."          name=\"".$this->name."\"\r\n";
  266.       $out .= "          id=\"".$this->id."\"\r\n";
  267.  
  268.       if $type != "password" )
  269.          $out .= "          value=\"".str_replace(
  270.                                         "\"""&quot;"$this->value
  271.                                                  )."\"\r\n";
  272.  
  273.       $out .= !empty$this->style_class )
  274.               ? "          class=\"".$this->style_class."\"\r\n"
  275.               : "";
  276.       $out .= !empty$this->freestyle )
  277.               ? "          style=\"".$this->freestyle."\"\r\n"
  278.               : "";
  279.       $out .= !empty$this->blur )
  280.               ? "          onBlur=\"".$this->blur."\"\r\n"
  281.               : "";
  282.       $out .= !empty$this->focus )
  283.               ? "          onFocus=\"".$this->focus."\"\r\n"
  284.               : "";
  285.       $out .= !empty$this->click )
  286.               ? "          onClick=\"".$this->click."\"\r\n"
  287.               : "";
  288.       $out .= !empty$this->mouseup )
  289.               ? "          onMouseup=\"".$this->mouseup."\"\r\n"
  290.               : "";
  291.       $out .= !empty$this->mouseover )
  292.               ? "          onMouseover=\"".$this->mouseover."\"\r\n"
  293.               : "";
  294.       $out .= !empty$this->mouseout )
  295.               ? "          onMouseout=\"".$this->mouseout."\"\r\n"
  296.               : "";
  297.       $out .= !empty$this->mousemove )
  298.               ? "          onMousemove=\"".$this->mousemove."\"\r\n"
  299.               : "";
  300.       $out .= !empty$this->size )
  301.               ? "          size=\"".$this->size."\"\r\n"
  302.               : "";
  303.       $out .= !empty$this->maxchars )
  304.               ? "          maxLength=\"".$this->maxchars."\"\r\n"
  305.               : "";
  306.       $out .= !empty$this->other_attributes )
  307.               ? "          ".$this->other_attributes
  308.               : "";
  309.       $out .= $this->enabled
  310.               ? ""
  311.               : "          disabled=\"disabled\"\r\n";
  312.       $out .= $this->manipulateable
  313.               ? ""
  314.               : "          readonly=\"readonly\"\r\n";
  315.       $out .= "  />";
  316.  
  317.       return $out;
  318.    }
  319. // END of class ABSTHTMLTextInput
  320. ?>

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