Changeset 1590 for trunk/plugins
- Timestamp:
- Nov 1, 2006, 6:54:35 AM (18 years ago)
- Location:
- trunk/plugins
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/event_tracer/main.inc.php
r1586 r1590 20 20 function load_config() 21 21 { 22 $x = @file_get_contents( dirname(__FILE__).'/ tracer.dat' );22 $x = @file_get_contents( dirname(__FILE__).'/data.dat' ); 23 23 if ($x!==false) 24 24 { … … 38 38 function save_config() 39 39 { 40 $file = fopen( dirname(__FILE__).'/ tracer.dat', 'w' );40 $file = fopen( dirname(__FILE__).'/data.dat', 'w' ); 41 41 fwrite($file, serialize($this->my_config) ); 42 42 fclose( $file ); 43 43 } 44 44 45 function pre_trigger_event($event_info)45 function on_pre_trigger_event($event_info) 46 46 { 47 if (!$this->me_working) 47 $this->dump('pre_trigger_event', $event_info); 48 } 49 function on_post_trigger_event($event_info) 50 { 51 $this->dump('post_trigger_event', $event_info); 52 } 53 54 function on_trigger_action($event_info) 55 { 56 $this->dump('trigger_action', $event_info); 57 } 58 59 function dump($event, $event_info) 60 { 61 foreach( $this->my_config['filters'] as $filter) 48 62 { 49 foreach( $this->my_config['filters'] as $filter)63 if ( preg_match( '/'.$filter.'/', $event_info['event'] ) ) 50 64 { 51 if ( preg_match( '/'.$filter.'/', $event_info['event'] ))65 if ($this->my_config['show_args']) 52 66 { 53 if ($this->my_config['show_args']) 54 $s = var_export( $event_info['data'], true ); 55 else 56 $s = ''; 57 pwg_debug('begin trigger_event "'.$event_info['event'].'" '.htmlspecialchars($s) ); 58 break; 67 $s = '<pre>'; 68 $s .= htmlspecialchars( var_export( $event_info['data'], true ) ); 69 $s .= '</pre>'; 59 70 } 71 else 72 $s = ''; 73 pwg_debug($event.' "'.$event_info['event'].'" '.($s) ); 74 break; 60 75 } 61 76 } 62 77 } 63 64 /*function post_trigger_event($filter_info)65 {66 if (!$this->me_working)67 {68 $s = var_export( $filter_info['data'], true );69 pwg_debug('end trigger_event '.$filter_info['event'].' '.$s );70 }71 }*/72 78 73 79 function plugin_admin_menu() … … 87 93 88 94 add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') ); 89 add_event_handler('pre_trigger_event', array(&$eventTracer, 'pre_trigger_event') ); 95 add_event_handler('pre_trigger_event', array(&$eventTracer, 'on_pre_trigger_event') ); 96 add_event_handler('post_trigger_event', array(&$eventTracer, 'on_post_trigger_event') ); 97 add_event_handler('trigger_action', array(&$eventTracer, 'on_trigger_action') ); 90 98 ?> -
trunk/plugins/event_tracer/tracer_admin.tpl
r1580 r1590 9 9 10 10 <label>Show event argument 11 <input type="checkbox" name="eventTracer_show_args" value="{EVENT_TRACER_SHOW_ARGS}"/>11 <input type="checkbox" name="eventTracer_show_args" {EVENT_TRACER_SHOW_ARGS} /> 12 12 </label> 13 13 <br/> -
trunk/plugins/hello_world/main.inc.php
r1586 r1590 2 2 Plugin Name: Hello World ! 3 3 Author: PhpWebGallery team 4 Description: This example plugin changes the page banner for the administration page 4 Description: This example plugin changes the page banner for the administration page. 5 5 */ 6 6 7 add_event_handler(' page_banner', 'hello_world_banner' );7 add_event_handler('loc_begin_page_header', 'hello_world_begin_header' ); 8 8 9 function hello_world_b anner($banner)9 function hello_world_begin_header() 10 10 { 11 11 global $page; 12 12 if ( isset($page['body_id']) and $page['body_id']=='theAdminPage') 13 13 { 14 return '<h1>Hello world from PhpWebGallery plugin!</h1>'; 14 $hellos = array( 'Aloha', 'Ahoy', 'Guten tag', 'Hello', 'Hoi', 'Hola', 'Salut', 'Yo' ); 15 shuffle($hellos); 16 $page['page_banner'] = $hellos[0]; 17 // just as an example we modify it a little bit later 18 add_event_handler('loc_end_page_header', 'hello_world_end_header'); 15 19 } 16 return $banner;17 20 } 21 22 23 function hello_world_end_header() 24 { 25 global $template, $page; 26 $template->assign_var( 'PAGE_BANNER', 27 '<h1>"'.$page['page_banner'].'" from PhpWebGallery plugin!</h1>'); 28 } 29 18 30 ?>
Note: See TracChangeset
for help on using the changeset viewer.