Changeset 1590 for trunk/plugins


Ignore:
Timestamp:
Nov 1, 2006, 6:54:35 AM (18 years ago)
Author:
rvelices
Message:

plugins last modifications + events are triggered now from picture.php

Location:
trunk/plugins
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/plugins/event_tracer/main.inc.php

    r1586 r1590  
    2020  function load_config()
    2121  {
    22     $x = @file_get_contents( dirname(__FILE__).'/tracer.dat' );
     22    $x = @file_get_contents( dirname(__FILE__).'/data.dat' );
    2323    if ($x!==false)
    2424    {
     
    3838  function save_config()
    3939  {
    40     $file = fopen( dirname(__FILE__).'/tracer.dat', 'w' );
     40    $file = fopen( dirname(__FILE__).'/data.dat', 'w' );
    4141    fwrite($file, serialize($this->my_config) );
    4242    fclose( $file );
    4343  }
    4444
    45   function pre_trigger_event($event_info)
     45  function on_pre_trigger_event($event_info)
    4646  {
    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)
    4862    {
    49       foreach( $this->my_config['filters'] as $filter)
     63      if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
    5064      {
    51         if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
     65        if ($this->my_config['show_args'])
    5266        {
    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>';
    5970        }
     71        else
     72          $s = '';
     73        pwg_debug($event.' "'.$event_info['event'].'" '.($s) );
     74        break;
    6075      }
    6176    }
    6277  }
    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   }*/
    7278
    7379  function plugin_admin_menu()
     
    8793
    8894add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') );
    89 add_event_handler('pre_trigger_event', array(&$eventTracer, 'pre_trigger_event') );
     95add_event_handler('pre_trigger_event', array(&$eventTracer, 'on_pre_trigger_event') );
     96add_event_handler('post_trigger_event', array(&$eventTracer, 'on_post_trigger_event') );
     97add_event_handler('trigger_action', array(&$eventTracer, 'on_trigger_action') );
    9098?>
  • trunk/plugins/event_tracer/tracer_admin.tpl

    r1580 r1590  
    99
    1010<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} />
    1212</label>
    1313<br/>
  • trunk/plugins/hello_world/main.inc.php

    r1586 r1590  
    22Plugin Name: Hello World !
    33Author: PhpWebGallery team
    4 Description: This example plugin changes the page banner for the administration page
     4Description: This example plugin changes the page banner for the administration page.
    55*/
    66
    7 add_event_handler('page_banner', 'hello_world_banner' );
     7add_event_handler('loc_begin_page_header', 'hello_world_begin_header' );
    88
    9 function hello_world_banner($banner)
     9function hello_world_begin_header()
    1010{
    1111  global $page;
    1212  if ( isset($page['body_id']) and $page['body_id']=='theAdminPage')
    1313  {
    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');
    1519  }
    16   return $banner;
    1720}
     21
     22
     23function 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
    1830?>
Note: See TracChangeset for help on using the changeset viewer.