Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/* ***** BEGIN LICENSE BLOCK *****
4
 *
5
 * This file is part of FirePHP (http://www.firephp.org/).
6
 *
7
 * Software License Agreement (New BSD License)
8
 *
9
 * Copyright (c) 2006-2009, Christoph Dorn
10
 * All rights reserved.
11
 *
12
 * Redistribution and use in source and binary forms, with or without modification,
13
 * are permitted provided that the following conditions are met:
14
 *
15
 *     * Redistributions of source code must retain the above copyright notice,
16
 *       this list of conditions and the following disclaimer.
17
 *
18
 *     * Redistributions in binary form must reproduce the above copyright notice,
19
 *       this list of conditions and the following disclaimer in the documentation
20
 *       and/or other materials provided with the distribution.
21
 *
22
 *     * Neither the name of Christoph Dorn nor the names of its
23
 *       contributors may be used to endorse or promote products derived from this
24
 *       software without specific prior written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
30
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
33
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
 *
37
 * ***** END LICENSE BLOCK *****
38
 *
39
 * @copyright   Copyright (C) 2007-2009 Christoph Dorn
40
 * @author      Christoph Dorn <christoph@christophdorn.com>
41
 * @license     http://www.opensource.org/licenses/bsd-license.php
42
 * @package     FirePHP
43
 */
44
 
45
require_once dirname(__FILE__).'/FirePHP.class.php';
46
 
47
/**
48
 * Sends the given data to the FirePHP Firefox Extension.
49
 * The data can be displayed in the Firebug Console or in the
50
 * "Server" request tab.
51
 *
52
 * @see http://www.firephp.org/Wiki/Reference/Fb
53
 * @param mixed $Object
54
 * @return true
55
 * @throws Exception
56
 */
57
function fb()
58
{
59
  $instance = FirePHP::getInstance(true);
60
 
61
  $args = func_get_args();
62
  return call_user_func_array(array($instance,'fb'),$args);
63
}
64
 
65
 
66
class FB
67
{
68
  /**
69
   * Enable and disable logging to Firebug
70
   *
71
   * @see FirePHP->setEnabled()
72
   * @param boolean $Enabled TRUE to enable, FALSE to disable
73
   * @return void
74
   */
75
  public static function setEnabled($Enabled) {
76
    $instance = FirePHP::getInstance(true);
77
    $instance->setEnabled($Enabled);
78
  }
79
 
80
  /**
81
   * Check if logging is enabled
82
   *
83
   * @see FirePHP->getEnabled()
84
   * @return boolean TRUE if enabled
85
   */
86
  public static function getEnabled() {
87
    $instance = FirePHP::getInstance(true);
88
    return $instance->getEnabled();
89
  }
90
 
91
  /**
92
   * Specify a filter to be used when encoding an object
93
   *
94
   * Filters are used to exclude object members.
95
   *
96
   * @see FirePHP->setObjectFilter()
97
   * @param string $Class The class name of the object
98
   * @param array $Filter An array or members to exclude
99
   * @return void
100
   */
101
  public static function setObjectFilter($Class, $Filter) {
102
    $instance = FirePHP::getInstance(true);
103
    $instance->setObjectFilter($Class, $Filter);
104
  }
105
 
106
  /**
107
   * Set some options for the library
108
   *
109
   * @see FirePHP->setOptions()
110
   * @param array $Options The options to be set
111
   * @return void
112
   */
113
  public static function setOptions($Options) {
114
    $instance = FirePHP::getInstance(true);
115
    $instance->setOptions($Options);
116
  }
117
 
118
  /**
119
   * Get options for the library
120
   *
121
   * @see FirePHP->getOptions()
122
   * @return array The options
123
   */
124
  public static function getOptions() {
125
    $instance = FirePHP::getInstance(true);
126
    return $instance->getOptions();
127
  }
128
 
129
  /**
130
   * Log object to firebug
131
   *
132
   * @see http://www.firephp.org/Wiki/Reference/Fb
133
   * @param mixed $Object
134
   * @return true
135
   * @throws Exception
136
   */
137
  public static function send()
138
  {
139
    $instance = FirePHP::getInstance(true);
140
    $args = func_get_args();
141
    return call_user_func_array(array($instance,'fb'),$args);
142
  }
143
 
144
  /**
145
   * Start a group for following messages
146
   *
147
   * Options:
148
   *   Collapsed: [true|false]
149
   *   Color:     [#RRGGBB|ColorName]
150
   *
151
   * @param string $Name
152
   * @param array $Options OPTIONAL Instructions on how to log the group
153
   * @return true
154
   */
155
  public static function group($Name, $Options=null) {
156
    $instance = FirePHP::getInstance(true);
157
    return $instance->group($Name, $Options);
158
  }
159
 
160
  /**
161
   * Ends a group you have started before
162
   *
163
   * @return true
164
   * @throws Exception
165
   */
166
  public static function groupEnd() {
167
    return self::send(null, null, FirePHP::GROUP_END);
168
  }
169
 
170
  /**
171
   * Log object with label to firebug console
172
   *
173
   * @see FirePHP::LOG
174
   * @param mixes $Object
175
   * @param string $Label
176
   * @return true
177
   * @throws Exception
178
   */
179
  public static function log($Object, $Label=null) {
180
    return self::send($Object, $Label, FirePHP::LOG);
181
  }
182
 
183
  /**
184
   * Log object with label to firebug console
185
   *
186
   * @see FirePHP::INFO
187
   * @param mixes $Object
188
   * @param string $Label
189
   * @return true
190
   * @throws Exception
191
   */
192
  public static function info($Object, $Label=null) {
193
    return self::send($Object, $Label, FirePHP::INFO);
194
  }
195
 
196
  /**
197
   * Log object with label to firebug console
198
   *
199
   * @see FirePHP::WARN
200
   * @param mixes $Object
201
   * @param string $Label
202
   * @return true
203
   * @throws Exception
204
   */
205
  public static function warn($Object, $Label=null) {
206
    return self::send($Object, $Label, FirePHP::WARN);
207
  }
208
 
209
  /**
210
   * Log object with label to firebug console
211
   *
212
   * @see FirePHP::ERROR
213
   * @param mixes $Object
214
   * @param string $Label
215
   * @return true
216
   * @throws Exception
217
   */
218
  public static function error($Object, $Label=null) {
219
    return self::send($Object, $Label, FirePHP::ERROR);
220
  }
221
 
222
  /**
223
   * Dumps key and variable to firebug server panel
224
   *
225
   * @see FirePHP::DUMP
226
   * @param string $Key
227
   * @param mixed $Variable
228
   * @return true
229
   * @throws Exception
230
   */
231
  public static function dump($Key, $Variable) {
232
    return self::send($Variable, $Key, FirePHP::DUMP);
233
  }
234
 
235
  /**
236
   * Log a trace in the firebug console
237
   *
238
   * @see FirePHP::TRACE
239
   * @param string $Label
240
   * @return true
241
   * @throws Exception
242
   */
243
  public static function trace($Label) {
244
    return self::send($Label, FirePHP::TRACE);
245
  }
246
 
247
  /**
248
   * Log a table in the firebug console
249
   *
250
   * @see FirePHP::TABLE
251
   * @param string $Label
252
   * @param string $Table
253
   * @return true
254
   * @throws Exception
255
   */
256
  public static function table($Label, $Table) {
257
    return self::send($Table, $Label, FirePHP::TABLE);
258
  }
259
 
260
}
261