-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass.badge.php
62 lines (50 loc) · 1.52 KB
/
class.badge.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 badge {
private $strbadge = NULL;
private $arData = array();
public function badge($strBadge = NULL) {
if (!is_null($strBadge)) $this->load($strBadge);
//$this->user( (is_null($iUser)) ? me() : $iUser );
}
public function load($strBadge = NULL) {
if (!is_null($strBadge)) $this->strBadge = $strBadge;
if (!is_null($this->strBadge)) {
$oDB = new database();
$oDB->execute("select * from tblBadges where mkey = '" . $oDB->escape($this->strBadge) . "'; ");
if ($oDB->length() == 1) {
$this->arData = array(
"img" => $oDB->get("img"),
"title" => $oDB->get("title"),
"info" => $oDB->get("info"),
);
}
}
}
private function HTMLvalue($strTag) {
switch($strTag) {
case "key":
return $this->strBadge;
case "img":
return fixPath("img/badges/" . $this->arData["img"]);
case "title":
case "info":
return html($this->arData[$strTag]);
default:
$arTag = explode(":", $strTag, 2);
switch($arTag[0]) {
case "badge":
return $this->htmlValue($arTag[1]);
break;
}
return NULL;
}
}
public function HTML($strTemplate = "") { // vraagt pad van template (of HTML if bFile==FALSE) en returns de html met replaced [tags]
$oHTML = template($strTemplate);
foreach ($oHTML->tags() as $strTag) {
$strResult = $this->HTMLvalue($strTag);
if (!is_null($strResult)) $oHTML->tag($strTag, $strResult);
}
return $oHTML;
}
}