Source for file HTMLCheckBox.class.php
Documentation is available at HTMLCheckBox.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
require_once( CLASSPATH. "forms/items/ABSTHTMLFormItem.class.php" );
* Loading the javascript class for form features.
include_once CLASSPATH. "html/JavaScript.class.php";
* Loading the javascript class for form features.
include_once CLASSPATH. "forms/HTMLLabel.class.php";
* A class to generate checkboxes.
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2003 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* @var boolean $label_position_right
* @author Daniel Plücken <daniel@debakel.net>
$tmp_obj->addToFormItem( $this );
* Returns if the checkbox is declared is checked.
* @author Daniel Plücken <daniel@debakel.net>
* Returns an if-order of a javascript to check whether this item is NOT
* @author Daniel Plücken <daniel@debakel.net>
* Returns an if-order of a javascript to check whether this item is NOT
* @author Daniel Plücken <daniel@debakel.net>
. ".". $this->name. ".checked != true";
* Returns a javascript to check all checkboxes in a given form. You have to
* give the name of the form and the element which should not checked in the
* @author Daniel Plücken <daniel@debakel.net>
$out = Javascript::getIsAncestorOf();
$out .= " function checkAllWithAncestor( id_of_ancestor, exception )\r\n"
. " el_arr = document.getElementsByTagName( 'input' );\r\n\r\n"
. " for( i = 0; i < el_arr.length; i++ )\r\n"
. "el_arr[i].type == 'checkbox' "
. "&& isAncestorOf( id_of_ancestor, el_arr[i] ) "
. "&& el_arr[i] != exception "
. " el_arr[i].checked = true;\r\n"
* Returns a javascript to uncheck all checkboxes in a given form. You have
* to give the name of the form and the element which should not checked in
* the javascript function.
* @author Daniel Plücken <daniel@debakel.net>
$out = Javascript::getIsAncestorOf();
$out .= " function uncheckAllWithAncestor( id_of_ancestor, exception )\r\n"
. " el_arr = document.getElementsByTagName( 'input' );\r\n\r\n"
. " for( i = 0; i < el_arr.length; i++ )\r\n"
. "el_arr[i].type == 'checkbox' "
. "&& isAncestorOf( id_of_ancestor, el_arr[i] ) "
. "&& el_arr[i] != exception "
. " el_arr[i].checked = false;\r\n"
* Returns a javascript to check and uncheck all checkboxes in a given form
* @author Daniel Plücken <daniel@debakel.net>
$out .= " function manageAllCheckboxesWithAnchestorByOne( "
. "id_of_anchestor, which "
. " if( !which.checked )\r\n"
. " checkAllWithAncestor( id_of_anchestor, which );\r\n"
. " uncheckAllWithAncestor( id_of_anchestor, which );\r\n"
* Returns a javascript to check all checkboxes in a given form. You have to
* give the name of the form and the element which should not checked in the
* @author Daniel Plücken <daniel@debakel.net>
$out = " function checkAllInForm( formname, exception )\r\n"
. " for( i = 0; i < eval( 'document.' + formname ).length; i++ )\r\n"
. " eval( 'document.' + formname ).elements[i].type == 'checkbox'\r\n"
. " && eval( 'document.' + formname ).elements[i] != exception\r\n"
. " eval( 'document.' + formname ).elements[i]"
* Returns a javascript to check all checkboxes in a given form. You have to
* give the name of the form and the element which should not unchecked in
* the javascript function.
* @author Daniel Plücken <daniel@debakel.net>
$out = " function uncheckAllInForm( formname, exception )\r\n"
. " for( i = 0; i < eval( 'document.' + formname ).length; i++ )\r\n"
. " eval( 'document.' + formname ).elements[i].type == 'checkbox'\r\n"
. " && eval( 'document.' + formname ).elements[i] != exception\r\n"
. " eval( 'document.' + formname ).elements[i]"
* Returns a javascript to check and uncheck all checkboxes in a given form
* @author Daniel Plücken <daniel@debakel.net>
$out .= " function manageAllCheckboxesByOne( which )\r\n"
. " if( !which.checked )\r\n"
. " checkAllInForm( which.form.name, which );\r\n"
. " uncheckAllInForm( which.form.name, which );\r\n"
* Sets this checkbox checked.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $boolean
{ $this->checked = !empty( $boolean ) ? true : false; }
* Sets the label of this checkbox.
* @author Daniel Plücken <daniel@debakel.net>
$mixed->addToFormItem( $this );
$tmp_obj->addToFormItem( $this );
* Sets the position of the label to the right side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the position of the label to the left side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the onChange-Attribute of the checkbox.
* @author Daniel Plücken <daniel@debakel.net>
* @param string $formname
* Generates the sourcecode to build this object and returns it.
* @author Daniel Plücken <daniel@debakel.net>
$outputstr = "unset( \x24checked );\n";
$outputstr .= "\x24checked = \x24_POST[\"". $this->getName(). "\"]\n"
. " .\x24_GET[\"". $this->getName(). "\"];\n";
$outputstr .= "\x24input[] = new HTMLCheckBox(\n"
. " !isset( \x24_POST[\"formsent\"] )\n"
. " && !isset( \x24_GET[\"formsent\"] )\n"
. " \x24input[count(\x24input)-1]->setChecked( true );\n\n";
* Returns a generated string based on the attributes of this object.
* @author Daniel Plücken <daniel@debakel.net>
function get( $forminput = "" )
. "--><input type=\"checkbox\"\r\n"
. " name=\"". $this->name. "\"\r\n"
. " id=\"". $this->id. "\"\r\n"
. " value=\"". $this->value. "\"\r\n";
$out .= !empty( $this->blur )
? " onBlur=\"". $this->blur. "\"\r\n"
$out .= !empty( $this->focus )
? " onFocus=\"". $this->focus. "\"\r\n"
$out .= !empty( $this->click )
? " onClick=\"". $this->click. "\"\r\n"
? " onMouseup=\"". $this->mouseup. "\"\r\n"
? " onMouseover=\"". $this->mouseover. "\"\r\n"
? " onMouseout=\"". $this->mouseout. "\"\r\n"
? " onMousemove=\"". $this->mousemove. "\"\r\n"
|| $forminput == "REQUEST"
$out .= "<?php if ( \x24_". $forminput. "['". $this->name. "'] ) "
? " checked=\"checked\"\r\n"
: " disabled=\"disabled\"\r\n";
} // END of class HTMLCheckBox
|