-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.php
45 lines (39 loc) · 1.12 KB
/
utils.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
<?php
class Paper {
private static $constants = array();
private static $settings = array();
static function constant($name, $value = null)
{
if ( $value === null ) {
if ( array_key_exists($name, self::$constants) ) {
return self::tag('span', self::$constants[$name], array( "class" => 'paper-constant' ));
} else {
return self::tag('span', $name, array( "class" => 'paper-constant paper-constant-error' ));
}
} else {
self::$constants[$name] = $value;
}
}
static function setting($name, $default = null)
{
if ( array_key_exists($name, self::$settings) ) {
return self::$settings[$name];
} else {
return $default;
}
}
static function add_setting($name, $value)
{
self::$settings[$name] = $value;
}
static function tag($tag, $content, Array $attributes = array() )
{
$attr = "";
foreach ($attributes as $key => $value) {
$attr .= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
}
$tag = strip_tags($tag);
$content = strip_tags($content);
return '<'.$tag.$attr.'>'.$content.'</'.$tag.'>';
}
}