html
[
class tree: html
] [
index: html
] [
all elements
]
changelog
install
readme
Todo List
Packages:
core
communication
databases
data_structures
filesystem
forms
GilliGan
html
Services_JSON
Source for file HTMLList.class.php
Documentation is available at
HTMLList.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
html
*/
if
(
!
defined
(
"CLASSPATH"
) )
{
echo
"<h3>You have to define the constant CLASSPATH!</h3>\n"
;
echo
"Example: define( 'CLASSPATH', '../path/to/classes/' );\n"
;
exit
(
)
;
}
/**
* Including a class to format plain text.
*/
require_once
(
CLASSPATH
.
"html/ABSTHTMLTag.class.php"
)
;
/**
* Create HTML-Lists
*
*
@package
html
*
@version
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@license
http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
*
@copyright
Copyright (c) 2005 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
HTMLList
extends
ABSTHTMLTag
{
/**
*
@var
string
kind
*
@access
private
*/
var
$kind
=
"ul"
;
/**
*
@var
array
$list_arr
*
@access
public
*/
var
$list_arr
=
array
(
)
;
/**
*
@var
array
$style_class_arr
*
@access
public
*/
var
$style_class_arr
=
array
(
)
;
/**
*
@var
array
$freestyle_arr
*
@access
public
*/
var
$freestyle_arr
=
array
(
)
;
/**
*
@var
array
$mouseover_arr
*
@access
public
*/
var
$mouseover_arr
=
array
(
)
;
/**
*
@var
array
$mouseup_arr
*
@access
public
*/
var
$mouseup_arr
=
array
(
)
;
/**
*
@var
array
$mouseout_arr
*
@access
public
*/
var
$mouseout_arr
=
array
(
)
;
/**
* Constructor.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
array
$label_arr
*
@param
array
$style_class_arr
*
@return
HTMLList
*/
function
HTMLList
(
$label_arr
=
array
(
)
,
$style_class_arr
=
array
(
) )
{
$this
->
list_arr
=
&
$label_arr
;
$this
->
style_class_arr
=
&
$style_class_arr
;
}
/**
* Adds an element to the list.
*
*
@version
1.1
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$mixed_label
*
@param
string
$style_class
*
@param
string
$freestyle
*
@param
string
$str_mouseup
*
@param
string
$str_mouseover
*
@param
string
$str_mouseout
*
@return
integer
The insert position.
*/
function
addElement
(
$mixed_label
,
$str_style_class
=
""
,
$str_freestyle
=
""
,
$str_mouseup
=
""
,
$str_mouseover
=
""
,
$str_mouseout
=
""
)
{
$this
->
list_arr
[
]
=
$mixed_label
;
$this
->
style_class_arr
[
]
=
$str_style_class
;
$this
->
freestyle_arr
[
]
=
$str_freestyle
;
$this
->
mouseup_arr
[
]
=
$str_mouseup
;
$this
->
mouseover_arr
[
]
=
$str_mouseover
;
$this
->
mouseout_arr
[
]
=
$str_mouseout
;
return
count
(
$this
->
list_arr
)
-
1
;
}
/**
* Removes the element at $int-index. All elements behind the deleted element
* moving up by one position.
*
*
@version
1.1
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
integer
$int
Index of the element to remove.
*
@return
void
*/
function
deleteElementAt
(
&
$int
)
{
array_splice
(
$this
->
list_arr
,
$int
,
1
)
;
array_splice
(
$this
->
style_class_arr
,
$int
,
1
)
;
array_splice
(
$this
->
freestyle_arr
,
$int
,
1
)
;
array_splice
(
$this
->
mouseup_arr
,
$int
,
1
)
;
array_splice
(
$this
->
mouseover_arr
,
$int
,
1
)
;
array_splice
(
$this
->
mouseout_arr
,
$int
,
1
)
;
}
/**
* Sets the the kind of this list ("ul" or "ol").
*
*
@version
1.2
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$kind
*
@return
string
*/
function
setKind
(
$kind
)
{
if
(
preg_match
(
"!^(?:o|u)l$!i"
,
$kind
) )
$this
->
kind
=
strtolower
(
$kind
)
;
}
/**
* Returns a generated string based on the attributes of this HTML-Object.
*
*
@version
1.2
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
get
(
)
{
$this
->
idExists
(
$this
->
id
,
true
)
;
$out
=
"<!--\r\n\r\n LIST\r\n "
.
"* -----\r\n "
.
"* -----\r\n "
.
"* -----\r\n-->"
;
$out
.=
"<"
.
$this
->
kind
.
" "
.
(
!
empty
(
$this
->
id
)
?
"id=\""
.
$this
->
id
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
style_class
)
?
"class=\""
.
$this
->
style_class
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseup
)
?
"onMouseUp=\""
.
$this
->
mouseup
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseout
)
?
"onMouseOut=\""
.
$this
->
mouseout
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseover
)
?
"onMouseOver=\""
.
$this
->
mouseover
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
freestyle
)
?
"style=\""
.
$this
->
freestyle
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
other_attributes
)
?
$this
->
other_attributes
.
"\r\n"
:
""
)
.
" ><!--\r\n"
;
for
(
$i
=
0
;
$i
<
count
(
$this
->
list_arr
)
;
$i
++
)
$out
.=
" --><li "
.
(
!
empty
(
$this
->
style_class_arr
[
$i
]
)
?
"class=\""
.
$this
->
style_class_arr
[
$i
]
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseup_arr
[
$i
]
)
?
"onMouseup=\""
.
$this
->
mouseup_arr
[
$i
]
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseover_arr
[
$i
]
)
?
"onMouseover=\""
.
$this
->
mouseover_arr
[
$i
]
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
mouseout_arr
[
$i
]
)
?
"onMouseout=\""
.
$this
->
mouseout_arr
[
$i
]
.
"\""
.
"\r\n "
:
""
)
.
(
!
empty
(
$this
->
freestyle_arr
[
$i
]
)
?
"style=\""
.
$this
->
freestyle_arr
[
$i
]
.
"\""
.
"\r\n "
:
""
)
.
"\r\n >"
.
(
is_object
(
$this
->
list_arr
[
$i
]
)
?
$this
->
list_arr
[
$i
]
->
get
(
)
:
$this
->
list_arr
[
$i
]
)
.
"</li><!--\r\n"
;
$out
.=
"--></"
.
$this
->
kind
.
">"
;
$out
.=
"<!--\r\n * -----\r\n "
.
"* -----\r\n "
.
" LIST\r\n\r\n-->"
;
return
$out
;
}
}
// End of class HTMLList
?>
Documentation generated on Thu, 05 Jun 2008 19:12:42 +0200 by
phpDocumentor 1.4.1