forms
[
class tree: forms
] [
index: forms
] [
all elements
]
changelog
install
readme
Todo List
Packages:
core
communication
databases
data_structures
filesystem
forms
GilliGan
html
Services_JSON
Source for file HTMLRadioButton.class.php
Documentation is available at
HTMLRadioButton.class.php
<?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
* framework GilliGan.
*
*
@package
forms
*
@subpackage
items
*/
if
(
!
defined
(
"CLASSPATH"
) )
{
echo
"<h3>You have to define the constant CLASSPATH!</h3>\n"
;
echo
"Example: define( 'CLASSPATH', '../path/to/classes/' );\n"
;
exit
(
)
;
}
/**
*
*/
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.
*
*
@package
forms
*
@subpackage
items
*
@version
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@license
http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
*
@copyright
Copyright (C) 2007 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
*/
class
HTMLRadioButton
extends
ABSTHTMLFormItem
{
/**
*
@var
integer
$value
*
@access
public
*/
var
$value
=
1
;
/**
*
@var
boolean
$checked
*
@access
public
*/
var
$checked
=
false
;
/**
* Constructor
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$name
*
@param
string
$checked
*
@param
string
$label
*
@return
HTMLCheckBox
*/
function
HTMLRadioButton
(
$name
,
$checked
=
false
,
$label
=
""
)
{
$this
->
name
=
$name
;
$this
->
id
=
$name
;
$this
->
checked
=
is_bool
(
$checked
)
?
$checked
:
!
empty
(
$checked
)
?
true
:
false
;
if
(
!
empty
(
$label
) )
{
$this
->
label_obj
=
new
HTMLLabel
(
$label
)
;
$this
->
label_obj
->
form_item_obj
=
&
$this
;
}
}
/**
* Sets this radio button checked.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
boolean
$boolean
*
@return
string
*/
function
setChecked
(
$boolean
=
true
)
{
$this
->
checked
=
!
empty
(
$boolean
)
?
true
:
false
;
}
/**
* Sets the label of this checkbox.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$mixed
*
@return
string
*/
function
setLabel
(
$mixed
)
{
if
(
is_object
(
$mixed
) )
$this
->
label_obj
=
$mixed
;
else
{
if
(
is_object
(
$this
->
label_obj
) )
$this
->
label_obj
->
setBody
(
$mixed
)
;
else
{
$this
->
label_obj
=
new
HTMLLabel
(
$mixed
)
;
$this
->
label_obj
->
form_item_obj
=
&
$this
;
}
}
}
/**
* Returns an if-order of a javascript to check whether this item is NOT
* filled
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
getChangeOrder
(
)
{
return
$this
->
mouseup
;
}
/**
* Returns an if-order of a javascript to check whether this item is NOT
* filled
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
getCheckOrder
(
)
{
$out
=
"document."
.
$this
->
parentform
->
name
.
"."
.
$this
->
name
.
".checked != true"
;
return
$out
;
}
/**
* Returns if the checkbox is declared is checked.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
boolean
*/
function
getChecked
(
)
{
return
$this
->
checked
;
}
/**
* Sets the mouseUp-Attribute of the radio button.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$formname
*
@return
string
*/
function
setChangeOrder
(
$string
)
{
$this
->
mouseup
=
$string
;
}
/**
* Returns a generated string based on the attributes of this object.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
get
(
$forminput
=
""
)
{
$this
->
idExists
(
$this
->
id
,
true
)
;
$out
=
"<!--\r\n"
.
"--><input type=\"radio\"\r\n"
.
" name=\""
.
$this
->
name
.
"\"\r\n"
.
" id=\""
.
$this
->
id
.
"\"\r\n"
.
" value=\""
.
$this
->
value
.
"\"\r\n"
;
$out
.=
!
empty
(
$this
->
style_class
)
?
" class=\""
.
$this
->
style_class
.
"\"\r\n"
:
""
;
$out
.=
!
empty
(
$this
->
freestyle
)
?
" style=\""
.
$this
->
freestyle
.
"\"\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"
:
""
;
$out
.=
!
empty
(
$this
->
mouseup
)
?
" onMouseup=\""
.
$this
->
mouseup
.
"\"\r\n"
:
""
;
$out
.=
!
empty
(
$this
->
mouseover
)
?
" onMouseover=\""
.
$this
->
mouseover
.
"\"\r\n"
:
""
;
$out
.=
!
empty
(
$this
->
mouseout
)
?
" onMouseout=\""
.
$this
->
mouseout
.
"\"\r\n"
:
""
;
$out
.=
!
empty
(
$this
->
mousemove
)
?
" onMousemove=\""
.
$this
->
mousemove
.
"\"\r\n"
:
""
;
if
(
$forminput
==
"POST"
||
$forminput
==
"GET"
||
$forminput
==
"REQUEST"
)
$out
.=
"<?php if ( \x24_"
.
$forminput
.
"['"
.
$this
->
name
.
"'] ) "
.
"echo ' checked'; ?>"
;
else
$out
.=
$this
->
checked
?
" checked=\"checked\"\r\n"
:
""
;
$out
.=
(
$this
->
enabled
&&
$this
->
manipulateable
)
?
""
:
" disabled=\"disabled\"\r\n"
;
$out
.=
" />"
.
(
is_object
(
$this
->
label_obj
)
?
$this
->
label_obj
->
get
(
)
:
""
)
;
return
$out
;
}
}
// End of class HTMLRadioButton
?>
Documentation generated on Thu, 05 Jun 2008 19:12:48 +0200 by
phpDocumentor 1.4.1