OSDN Git Service

- added Validator Required and Filter Test.
[ethna/ethna.git] / skel / app.plugin.filter.default.php
1 <?php
2 /**
3  *  {$project_id}_Plugin_Filter_ExecutionTime.php
4  *
5  *  @author     {$author}
6  *  @package    {$project_id}
7  *  @version    $Id$
8  */
9
10 /**
11  *  filter plugin implementation for measuring execution time.
12  *
13  *  @author     {$author}
14  *  @access     public
15  *  @package    {$project_id}
16  */
17 class {$project_id}_Plugin_Filter_ExecutionTime extends Ethna_Plugin_Filter
18 {
19     /**#@+
20      *  @access private
21      */
22
23     /**
24      *  @var    int     Start time.
25      */
26     var $stime;
27
28     /**#@-*/
29
30
31     /**
32      *  filter before first processing.
33      *
34      *  @access public
35      */
36     function preFilter()
37     {
38         $stime = explode(' ', microtime());
39         $stime = $stime[1] + $stime[0];
40         $this->stime = $stime;
41     }
42
43     /**
44      *  filter BEFORE executing action.
45      *
46      *  @access public
47      *  @param  string  $action_name  Action name.
48      *  @return string  null: normal.
49      *                string: if you return string, it will be interpreted
50      *                        as Action name which will be executed immediately.
51      */
52     function preActionFilter($action_name)
53     {
54         return null;
55     }
56
57     /**
58      *  filter AFTER executing action.
59      *
60      *  @access public
61      *  @param  string  $action_name    executed Action name.
62      *  @param  string  $forward_name   return value from executed Action.
63      *  @return string  null: normal.
64      *                string: if you return string, it will be interpreted
65      *                        as Forward name.
66      */
67     function postActionFilter($action_name, $forward_name)
68     {
69         return null;
70     }
71
72     /**
73      *  filter which will be executed at the end.
74      *
75      *  @access public
76      */
77     function postFilter()
78     {
79         $etime = explode(' ', microtime());
80         $etime = $etime[1] + $etime[0];
81         $time   = round(($etime - $this->stime), 4);
82
83         print "\n<!-- page was processed in $time seconds -->\n";
84     }
85 }
86 ?>