Ignore:
Timestamp:
01/09/07 12:38:54 (13 years ago)
Author:
rvelices
Message:

Plugins: new way of adding links and content to administration pages...

Location:
trunk/plugins/event_tracer
Files:
3 edited

Legend:

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

    r1590 r1705  
    1212  var $me_working; 
    1313  var $my_config; 
    14  
    15   function EventTracer() 
     14  var $my_id; 
     15   
     16  function EventTracer($id) 
    1617  { 
    1718    $this->me_working=0; 
     19    $this->my_id=$id; 
    1820  } 
    1921 
     
    7779  } 
    7880 
    79   function plugin_admin_menu() 
     81  function plugin_admin_menu($menu) 
    8082  { 
    81     add_plugin_admin_menu( "Event Tracer", array(&$this, 'do_admin') ); 
     83    array_push($menu, 
     84        array( 
     85          'NAME' => 'Event Tracer', 
     86          'URL' => get_admin_plugin_menu_link($this->my_id, 'tracer_admin') 
     87        ) 
     88      ); 
     89    return $menu; 
    8290  } 
    83  
    84   function do_admin($my_url) 
    85   { 
    86     include( dirname(__FILE__).'/tracer_admin.php' ); 
    87   } 
    88  
    8991} 
    9092 
    91 $eventTracer = new EventTracer(); 
    92 $eventTracer->load_config(); 
     93$obj = new EventTracer($plugin['id']); 
     94$obj->load_config(); 
    9395 
    94 add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') ); 
    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') ); 
     96add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') ); 
     97add_event_handler('pre_trigger_event', array(&$obj, 'on_pre_trigger_event') ); 
     98add_event_handler('post_trigger_event', array(&$obj, 'on_post_trigger_event') ); 
     99add_event_handler('trigger_action', array(&$obj, 'on_trigger_action') ); 
     100set_plugin_data($plugin['id'], $obj); 
    98101?> 
  • trunk/plugins/event_tracer/tracer_admin.php

    r1655 r1705  
    11<?php 
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     3 
     4$me = get_plugin_data($plugin_id); 
    35 
    46global $template; 
     
    1214  $v = stripslashes($v); 
    1315  if (!empty($v)) 
    14     $this->my_config['filters'] = explode("\n", $v); 
     16    $me->my_config['filters'] = explode("\n", $v); 
    1517  else 
    16     $this->my_config['filters'] = array(); 
    17   $this->my_config['show_args'] = isset($_POST['eventTracer_show_args']); 
    18   $this->save_config(); 
     18    $me->my_config['filters'] = array(); 
     19  $me->my_config['show_args'] = isset($_POST['eventTracer_show_args']); 
     20  $me->save_config(); 
    1921  global $page; 
    2022  array_push($page['infos'], 'event tracer options saved'); 
    2123} 
    22 $template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $this->my_config['filters'] ) ); 
    23 $template->assign_var('EVENT_TRACER_SHOW_ARGS', $this->my_config['show_args'] ? 'checked="checked"' : '' ); 
    24 $template->assign_var('EVENT_TRACER_F_ACTION', $my_url); 
     24$template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $me->my_config['filters'] ) ); 
     25$template->assign_var('EVENT_TRACER_SHOW_ARGS', $me->my_config['show_args'] ? 'checked="checked"' : '' ); 
     26//$template->assign_var('EVENT_TRACER_F_ACTION', $my_url); 
    2527 
    26 $template->assign_var_from_handle( 'PLUGIN_ADMIN_CONTENT', 'plugin_admin_content'); 
     28$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); 
    2729?> 
  • trunk/plugins/event_tracer/tracer_admin.tpl

    r1590 r1705  
     1<div class="titrePage"> 
     2  <h2>Event Tracer</h2> 
     3</div> 
     4 
    15<p> 
    26The event tracer is a developer tool that logs in the footer of the window all calls to trigger_event method. 
Note: See TracChangeset for help on using the changeset viewer.