ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

event_manager.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class event_manager_1_0_0{
27
28 var $LoadedBindings = array();
29
40 var $CachedMultyFS = false;
41 var $String = false;
42 var $Settings = false;
43
54 function __construct()
55 {
56 try
57 {
58 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
59 $this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
60
61 $this->register_events( dirname( __FILE__ ).'/conf/cf_event_manager_binded_events' );
62 }
63 catch( Exception $e )
64 {
65 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
66 }
67 }
68
99 function register_event( $Event , $PackageName , $PackageVersion , $Handler = false )
100 {
101 try
102 {
103 if( isset( $this->LoadedBindings[ $Event ] ) === false )
104 {
105 $this->LoadedBindings[ $Event ] = array();
106 }
107
108 if( isset( $this->LoadedBindings[ $Event ][ $PackageName ] ) === false )
109 {
110 $this->LoadedBindings[ $Event ][ $PackageName ] = array();
111 }
112
113 if( isset( $this->LoadedBindings[ $Event ][ $PackageName ][ $PackageVersion ] ) === false )
114 {
115 $this->LoadedBindings[ $Event ][ $PackageName ][ $PackageVersion ] = array();
116 }
117
118 $this->LoadedBindings[ $Event ][ $PackageName ][ $PackageVersion ] [] = $Handler;
119 }
120 catch( Exception $e )
121 {
122 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
123 }
124 }
125
144 function register_events( $ConfigPath )
145 {
146 try
147 {
148 $Bindings = $this->CachedMultyFS->file_get_contents( $ConfigPath , 'cleaned' );
149
150 if( $Bindings != '' )
151 {
152 $Bindings = explode( "\n" , $Bindings );
153
154 foreach( $Bindings as $k => $v )
155 {
156 $this->Settings->load_settings( $v );
157 $this->register_event( $this->Settings->get_setting( 'event' ) ,
158 $this->Settings->get_setting( 'package_name' ) ,
159 $this->Settings->get_setting( 'package_version' ) ,
160 $this->Settings->get_setting( 'handler' , false ) );
161 }
162 }
163 }
164 catch( Exception $e )
165 {
166 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
167 }
168 }
169
194 function trigger_event( $Event , $Parameters )
195 {
196 try
197 {
198 $Return = array();
199
200 if( isset( $this->LoadedBindings[ $Event ] ) )
201 {
202 foreach( $this->LoadedBindings[ $Event ] as $PackageName => $PackageVersions )
203 {
204 foreach( $PackageVersions as $PackageVersion => $FunctionNames )
205 {
206 foreach( $FunctionNames as $k => $FunctionName )
207 {
208 $Object = get_package( $PackageName , $PackageVersion , __FILE__ );
209 $Return [] = call_user_func( array( $Object , $FunctionName ) , $Parameters );
210 }
211 }
212 }
213 }
214
215 return( $Return );
216 }
217 catch( Exception $e )
218 {
219 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
220 }
221 }
222 }
223
224 ?>