source: extensions/event_tracer/event_list.php @ 27153

Last change on this file since 27153 was 3282, checked in by plg, 15 years ago

change: according to topic:15067, svn:keywords property was removed

  • Property svn:eol-style set to LF
File size: 2.3 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function get_php_files($path, $to_ignore=array(), $recursive=true )
5{
6  $files = array();
7  if (is_dir($path))
8  {
9    if ($contents = opendir($path))
10    {
11      while (($node = readdir($contents)) !== false)
12      {
13        if ($node != '.' and $node != '..' and $node != '.svn'
14            and !in_array($node, $to_ignore) )
15        {
16          if ( $recursive and is_dir($path.'/'.$node) )
17          {
18            $files = array_merge($files, get_php_files($path.'/'.$node, $to_ignore));
19
20          }
21          if ( is_file($path.'/'.$node) )
22          {
23            $files[] = $path.'/'.$node;
24          }
25        }
26      }
27      closedir($contents);
28    }
29  }
30  return $files;
31}
32
33$files = array();
34$files = array_merge( $files, get_php_files('.', array(), false) );
35$files = array_merge( $files, get_php_files('./include') );
36$files = array_merge( $files, get_php_files('./admin') );
37$files = array_unique($files);
38
39$events = array();
40foreach ($files as $file)
41{
42  $code = file_get_contents($file);
43  $code = preg_replace( '#\?'.'>.*<\?php#m', '', $code);
44  $code = preg_replace( '#\/\*.*\*\/#m', '', $code);
45  $code = preg_replace( '#\/\/.*#', '', $code);
46
47  $count = preg_match_all(
48    '#[^a-zA-Z_$-]trigger_(action|event)\s*\(\s*([^,)]+)#m',
49    $code, $matches
50    );
51
52  for ($i=0; $i<$count; $i++)
53  {
54    $type = $matches[1][$i];
55    $name = preg_replace( '#^[\'"]?([^\'"]*)[\'"]?$#', '$1', $matches[2][$i]);
56    array_push($events, array($type,$name,$file) );
57  }
58}
59
60$sort= isset($_GET['sort']) ? (int)$_GET['sort'] : 1;
61usort(
62  $events,
63  create_function( '$a,$b', 'return $a['.$sort.']>$b['.$sort.'];' )
64  );
65
66global $template;
67
68$url = get_admin_plugin_menu_link(__FILE__);
69
70$template->assign( array(
71  'NB_EVENTS' => count($events),
72  'U_SORT0' => add_url_params($url, array('sort'=>0) ),
73  'U_SORT1' => add_url_params($url, array('sort'=>1) ),
74  'U_SORT2' => add_url_params($url, array('sort'=>2) ),
75  ) );
76
77$template->assign('events', array());
78foreach ($events as $e)
79{
80  $template->append( 'events', array(
81    'TYPE' => $e[0],
82    'NAME' => $e[1],
83    'FILE' => $e[2],
84    )
85  );
86}
87
88$template->set_filenames( array('event_list' => dirname(__FILE__).'/event_list.tpl' ) );
89$template->assign_var_from_handle( 'ADMIN_CONTENT', 'event_list');
90?>
Note: See TracBrowser for help on using the repository browser.