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 HTMLTextInput.class.php
Documentation is available at
HTMLTextInput.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/ABSTHTMLTextInput.class.php"
)
;
/**
* A class to generate text input fields.
*
*
@package
forms
*
@subpackage
items
*
@version
0.1.25
*
@static
*
@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
*/
class
HTMLTextInput
extends
ABSTHTMLTextInput
{
/**
* Carries the text that should be shown if the textfields value is empty.
*
*
@var
string
*
@access
public
*/
var
$standard_text
=
""
;
/**
* Constructor
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$name
*
@param
string
$value
*
@param
integer
$size
*
@param
integer
$maxchar
*
@param
string
$style_class
*
@param
string
$other_attributes
*/
function
HTMLTextInput
(
$name
=
""
,
$value
=
""
,
$size
=
0
,
$maxchars
=
0
,
$style_class
=
""
,
$other_attributes
=
""
)
{
parent
::
__constructor
(
$name
,
$value
,
$size
,
$maxchars
,
$style_class
,
$other_attributes
)
;
}
/**
* Makes a clone of this object an returns a reference to this clone.
*
*
@version
1.1
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$newName
*
@param
integer
$maxchars
Zero means no limit.
*
@param
integer
$size
Zero means no preference.
*
@return
HTMLTextInput
*/
function
getClone
(
$newName
,
$maxchars
=
0
,
$size
=
0
,
$selectedValue
=
""
)
{
$maxchars
=
preg_match
(
"^\d*$"
,
$maxchars
)
?
$maxchars
:
$this
->
maxchars
;
$size
=
preg_match
(
"^\d*$"
,
$size
)
?
$size
:
$this
->
size
;
$selectedValue
=
!
empty
(
$selectedValue
)
?
$selectedValue
:
$this
->
value
;
$newInstance
=
new
HTMLTextInput
(
$newName
,
$selectedValue
,
$size
,
$maxchars
)
;
if
(
!
empty
(
$this
->
onBlur
) )
$newInstance
->
setOnBlur
(
$this
->
onBlur
)
;
if
(
!
empty
(
$this
->
style_class
) )
$newInstance
->
setStyle
(
$this
->
style_class
)
;
if
(
!
empty
(
$this
->
other_attributes
) )
$newInstance
->
setAttributes
(
$this
->
other_attributes
)
;
return
$newInstance
;
}
/**
* Sets the text that should be shown if the textfields value is empty.
*
*
@version
1.1
*
@since
0.1.25
*
@author
Daniel Plücken <daniel@debakel.net>
*
@param
string
$string
*
@access
public
*
@return
void
*/
function
setStandardText
(
$string
)
{
$this
->
standard_text
=
$string
;
}
/**
* Generates the sourcecode to build this object and returns it.
*
*
@version
1.1
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@param
string
$type
*
@access
public
*
@return
string
*/
function
getPHPSource
(
$type
=
""
)
{
if
(
empty
(
$type
) )
$type
=
"HTMLTextInput"
;
return
parent
::
getPHPSource
(
$type
)
;
}
/**
* Returns a generated string based on the attributes of this object.
*
*
@version
1.23
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@param
string
$type
*
@access
public
*
@return
string
*/
function
get
(
$type
=
""
)
{
if
(
!
empty
(
$this
->
standard_text
) )
{
if
(
!
preg_match
(
"!;$!"
,
$this
->
focus
) )
$this
->
focus
.=
";"
;
$this
->
focus
.=
"if(this.value=='"
.
addslashes
(
$this
->
standard_text
)
.
"')this.value=''"
;
if
(
!
preg_match
(
"!;$!"
,
$this
->
blur
) )
$this
->
blur
.=
";"
;
$this
->
blur
.=
"if(this.value=='')this.value='"
.
addslashes
(
$this
->
standard_text
)
.
"'"
;
if
(
empty
(
$this
->
value
) )
$this
->
value
=
$this
->
standard_text
;
}
if
(
empty
(
$type
) )
$type
=
"text"
;
return
parent
::
get
(
$type
)
;
}
}
// END of class HTMLTextInput
?>
Documentation generated on Thu, 05 Jun 2008 19:13:27 +0200 by
phpDocumentor 1.4.1