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

Source for file ColorInput.class.php

Documentation is available at ColorInput.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.  */
  22. require_onceCLASSPATH."forms/items/ABSTHTMLFormItem.class.php" );
  23. /**
  24.  *
  25.  */
  26. require_onceCLASSPATH."forms/items/HTMLTextInput.class.php" );
  27. /**
  28.  *
  29.  */
  30. require_onceCLASSPATH."forms/items/HTMLButton.class.php" );
  31.  
  32. /**
  33.  * @package    forms
  34.  * @subpackage items
  35.  * @version    0.1.5
  36.  * @author     Daniel Plücken <daniel@debakel.net>
  37.  * @license    http://www.gnu.org/copyleft/lesser.html
  38.  *              GNU Lesser General Public License
  39.  * @copyright  Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
  40.  *
  41.  *  This library is free software; you can redistribute it and/or
  42.  *  modify it under the terms of the GNU Lesser General Public
  43.  *  License as published by the Free Software Foundation; either
  44.  *  version 2.1 of the License.
  45.  *
  46.  *  This library is distributed in the hope that it will be useful,
  47.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  48.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  49.  *  GNU Lesser General Public License for more details.
  50.  *
  51.  *  You should have received a copy of the GNU Lesser General
  52.  *  Public License along with this library; if not, write to the
  53.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  54.  *  Boston, MA 02111-1307 USA
  55.  */
  56. class ColorInput extends ABSTHTMLFormItem
  57. {
  58.   /**
  59.    * @access private
  60.    * @var HTMLTextInput 
  61.    */
  62.   var $textinput;
  63.   /**
  64.    * @access private
  65.    * @var HTMLButton 
  66.    */
  67.   var $button;
  68.  
  69.  
  70.  
  71.   /**
  72.    * Constructor
  73.    *
  74.    * @version 1.1
  75.    * @since   0.1.0
  76.    * @author  Daniel Plücken <daniel@debakel.net>
  77.    * @access  public
  78.    * @param   string   $name  The name of the textfield.
  79.    * @param   string   $value The value of the Textfield.
  80.    * @param   interger $size  The Size of the Textfield.
  81.    * @param   string   $buttonlabel 
  82.    */
  83.   function ColorInput(
  84.                        $name "",
  85.                        $value "",
  86.                        $size null,
  87.                        $buttonlabel ""
  88.                      )
  89.   {
  90.      $this->textinput = new HTMLTextInput$name$value$size);
  91.      $this->button = new HTMLButton(
  92.                               "backbone",
  93.                               (
  94.                                 empty$buttonlabel )
  95.                                 ? "zur Farbauswahl"
  96.                                 : $buttonlabel
  97.                               )
  98.                                    );
  99.   }
  100.  
  101.  
  102.  
  103.   /**
  104.    * Returns the value of textfield tag's "name"-attribute.
  105.    *
  106.    * @version 1.0
  107.    * @since   0.1.0
  108.    * @author  Daniel Plücken <daniel@debakel.net>
  109.    * @access  public
  110.    * @return  string 
  111.    */
  112.   function getName()
  113.   return $this->textinput->getName()}
  114.  
  115.  
  116.  
  117.   /**
  118.    * Returns the value of textfield tag's "value"-attribute.
  119.    *
  120.    * @version 1.0
  121.    * @since   0.1.0
  122.    * @author  Daniel Plücken <daniel@debakel.net>
  123.    * @access  public
  124.    * @return  string 
  125.    */
  126.   function getValue()
  127.   return $this->textinput->getValue()}
  128.  
  129.  
  130.  
  131.   /**
  132.    * Returns the size of textfield in text columns.
  133.    *
  134.    * @version 1.0
  135.    * @since   0.1.0
  136.    * @author  Daniel Plücken <daniel@debakel.net>
  137.    * @access  public
  138.    * @return  integer 
  139.    */
  140.   function getSize()
  141.   return $this->textinput->getSize()}
  142.  
  143.  
  144.  
  145.   /**
  146.    * Returns the value of button tag's "value"-attribute.
  147.    *
  148.    * @version 1.0
  149.    * @since   0.1.0
  150.    * @author  Daniel Plücken <daniel@debakel.net>
  151.    * @access  public
  152.    * @return  string 
  153.    */
  154.   function getButtonLabel()
  155.   return $this->button->getValue()}
  156.  
  157.  
  158.  
  159.   /**
  160.    * Returns the value of textfield tag's "name"-attribute.
  161.    *
  162.    * @version 1.0
  163.    * @since   0.1.0
  164.    * @author  Daniel Plücken <daniel@debakel.net>
  165.    * @access  public
  166.    * @param   string $string 
  167.    */
  168.   function setName$string )
  169.   return $this->textinput->setName$string )}
  170.  
  171.  
  172.  
  173.   /**
  174.    * Sets the value of textfield tag's "value"-attribute.
  175.    *
  176.    * @version 1.0
  177.    * @since   0.1.0
  178.    * @author  Daniel Plücken <daniel@debakel.net>
  179.    * @access  public
  180.    * @param   string $string 
  181.    */
  182.   function setValue$string )
  183.   $this->textinput->setValue$string )}
  184.  
  185.  
  186.  
  187.   /**
  188.    * Returns an if-order of a javascript to check whether this item is NOT
  189.    * filled
  190.    *
  191.    * @version 1.1
  192.    * @since   0.1.7
  193.    * @author  Daniel Plücken <daniel@debakel.net>
  194.    * @access  public
  195.    * @return  string 
  196.    */
  197.   function getCheckOrder$formName )
  198.   {
  199.      $out $this->textinput->getCheckOrder();
  200.      
  201.      return $out;
  202.   }
  203.  
  204.  
  205.  
  206.   /**
  207.    * Stores a reference to the form-object that contains this item-object.
  208.    *
  209.    * @version 1.1
  210.    * @since   0.1.5
  211.    * @author  Daniel Plücken <daniel@debakel.net>
  212.    * @access  public
  213.    * @param   object 
  214.    * @return  void 
  215.    */
  216.   function setParentForm&$formobj )
  217.   {
  218.     parent::setParentForm$formobj );
  219.     $this->textinput->setParentForm$formobj );
  220.   }
  221.  
  222.  
  223.  
  224.   /**
  225.    * Generates the sourcecode to build this object and returns it.
  226.    *
  227.    * @version 1.1
  228.    * @since   0.1.0
  229.    * @author  Daniel Plücken <daniel@debakel.net>
  230.    * @param   string $type* 
  231.    * @access  public
  232.    * @return  string 
  233.    */
  234.   function getPHPSource()
  235.   {
  236.      $out  "unset( \x24value );\r\n";
  237.      $out .= "\x24value = \x24_POST[\"".$this->getName()."\"]\r\n"
  238.             ."        .\x24_GET[\"".$this->getName()."\"];\r\n";
  239.      $out .= "\x24input[] = new ColorInput(\r\n"
  240.             ."                            \"".$this->getName()."\",\r\n"
  241.             ."                            \x24value,\r\n"
  242.             ."                            \"".$this->getSize()."\",\r\n"
  243.             ."                            \"".$this->getButtonLabel()."\"\r\n"
  244.             ."                         );\r\n";
  245.      
  246.      $tmp $this->getValue();
  247.      $out .= !empty$tmp )
  248.              ? "if( \x24value === \"\" )\r\n"
  249.               ."  \x24input[count(\x24input)-1]->setValue( \"".$tmp."\" );"
  250.               ."\r\n\r\n"
  251.              : "\r\n";
  252.      
  253.      return $out;
  254.   }
  255.  
  256.  
  257.  
  258.   /**
  259.    * Returns a generated string based on the attributes of this object.
  260.    *
  261.    * @version 1.2
  262.    * @since   0.1.0
  263.    * @author  Daniel Plücken <daniel@debakel.net>
  264.    * @access  public
  265.    * @return  string 
  266.    */
  267.   function get()
  268.   {
  269.      if!empty$this->parentform ) )
  270.        $this->button->setonMouseup(
  271.                    "open( './".CLASSPATH."dialogs/"
  272.                              ."colorchooser.php"
  273.                              ."?callerForm=".$this 
  274.                             ->parentform->getName()
  275.                              ."&callerItem=".$this 
  276.                             ->getName()."', "
  277.                          ."'colorchooser', "
  278.                          ."'width=600,height=300' );"
  279.                                   );
  280.      
  281.      $out  $this->textinput->get()."\r\n";
  282.      $out .= $this->button->get();
  283.      
  284.      return $out;
  285.   }
  286. // END of class ColorInput
  287. ?>

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