[
class tree: tangra_lib
] [
index: tangra_lib
] [
all elements
]
tangra_lib
Packages:
tangra_lib
Source for file web_event_composite.class.php
Documentation is available at
web_event_composite.class.php
<?php
// *** Tangra (Application Framework and Tools for PHP)
// $Id$
//
/**
* Contains class Web_Event_Composite
*
*
@package
tangra_lib
*
@subpackage
web_site
*/
/**
*
*/
require_once
(
TANGRA_MAIN_DIR
.
'web_site/web_event_simple.class.php'
)
;
/**
*
*/
require_once
(
TANGRA_MAIN_DIR
.
'web_site/web_event_simple_int.class.php'
)
;
/**
*
*/
require_once
(
TANGRA_MAIN_DIR
.
'exceptions/te_key_already_exists.class.php'
)
;
/**
* Web_Event_Composite is intended to contain 2 or more Web_Event_Simple
* It's contition is met if conditions of all Web_Events_Simple are met
*
*
*
@package
tangra_lib
*
@subpackage
web_site
*/
class
Web_Event_Composite
extends
Web_Event
{
/**
* Array that holds Web_Event_Simple
*
*
@var
array
*/
private
$web_events_simple
=
array
(
)
;
/**
* Adds new Web_Event_Simple
*
*
@param
Web_Event_Simple
$wes
*/
public
function
add_web_event_simple
(
Web_Event_Simple
$wes
)
{
if
(
!
array_key_exists
(
$wes
->
get_name
(
)
,
$this
->
web_events_simple
))
{
$this
->
web_events_simple
[
$wes
->
get_name
(
)
]
=
$wes
;
}
else
{
throw
new
TE_Key_Already_Exists
(
$wes
->
get_name
(
))
;
}
}
/**
* Alias of add_web_event_simple
*
*
@param
Web_Event_Simple
$wes
*/
public
function
add_wes
(
Web_Event_Simple
$wes
)
{
if
(
!
array_key_exists
(
$wes
->
get_name
(
)
,
$this
->
web_events_simple
))
{
$this
->
web_events_simple
[
$wes
->
get_name
(
)
]
=
$wes
;
}
else
{
throw
new
TE_Key_Already_Exists
(
$wes
->
get_name
(
))
;
}
}
/**
* Checks if event condition is met
*
* Returns array that contain $key => $value pairs for all Web_Event_Simple.
* $key is the name of Web_Event_Simple, $value is the value of the capture
*
*
@param
Web_Context
$context
*
@return
array
R
*/
public
function
is_it_me
(
Web_Context
$context
)
{
$flag
=
true
;
$ret
=
array
(
)
;
foreach
(
$this
->
web_events_simple
as
$wes
)
{
$tmp_ret
=
$wes
->
is_it_me
(
$context
)
;
if
(
$tmp_ret
!==
false
)
{
$ret
[
$wes
->
get_name
(
)
]
=
$tmp_ret
;
}
else
{
$flag
=
false
;
break
;
}
}
if
(
!
$flag
)
{
$ret
=
false
;
}
return
$ret
;
}
/**
* Returns array that contains capture labels of all Web_Event_Simple
*
*
@return
unknown
*/
public
function
get_capture
(
)
{
$ret
=
array
(
)
;
foreach
(
$this
->
web_events_simple
as
$wes
)
{
array_push
(
$ret
,
$wes
->
get_capture
(
))
;
}
return
$ret
;
}
}