forked from hugoh/Offlickr2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dialog.php
62 lines (48 loc) · 1.11 KB
/
Dialog.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class Dialog {
private $debug_level = 2;
const DIALOG_SHOW_PROGRESS_LEVEL = 2;
function __construct($level = 0) {
$this->set_debug_level($level);
}
function set_debug_level($level) {
$this->debug_level = $level;
}
function show_progress() {
return self::DIALOG_SHOW_PROGRESS_LEVEL <= $this->debug_level;
}
function progress($string) {
if ($this->show_progress()) {
print("\r" . $string);
}
}
function progress_done($string = '') {
if ($this->show_progress()) {
print($string . " ... done\n");
}
}
private function dialog($debug, $string) {
if ($this->debug_level >= $debug) {
if ($debug > 0) {
print("- ");
}
print($string);
}
}
function dprint($string) {
$this->dialog(-1, $string);
}
function info($debug, $string) {
$this->dialog($debug, $string . "\n");
}
function error($string) {
$this->dialog(0, 'ERROR: ' . $string . "\n");
}
function dump_var($debug, $name, $var) {
if ($this->debug_level >= $debug) {
print('DEBUG: ' . $name . ': ');
print_r($var);
}
}
}
?>