This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kategoriagaci.class.php
62 lines (60 loc) · 2.67 KB
/
kategoriagaci.class.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 KategoriAgaci
* @author Mahmut İŞÇİ
* @blog http://mahmutisci.com
* @mail [email protected]
* @date 03.10.2016
*/
class KategoriAgaci{
/**
* @param $array
* @param string $inputName
* @param int $ust_ktg
* @param array $selected
* @return string
*/
static function tree($array, $ust_ktg = 0, $selected = array(), $inputName = "category"){
$dataArray = $array;
$data = "";
$data .= "<ul class='tree'>";
foreach($dataArray["ktg_id"] as $index => $item){
if($dataArray["ktg_ust"][$index] == $ust_ktg){
if(count($selected) != 0){
if(in_array($item, $selected)){
$data .= "<li class='tree-folder'>";
$data .= "<span class='tree-folder-name checked'>";
$data .= "<input checked type='checkbox' name='".$inputName."[]' value='".$dataArray["ktg_id"][$index]."'>";
$data .= "<i class='fa fa-folder-open'></i> ";
$data .= "<label class='tree-toggle'>".$dataArray['ktg_adi'][$index]."</label>";
$data .= "</span>";
$data .= self::tree($dataArray, $dataArray["ktg_id"][$index], $selected);
$data .= "</li>";
}
else{
$data .= "<li class='tree-folder'>";
$data .= "<span class='tree-folder-name'>";
$data .= "<input type='checkbox' name='".$inputName."[]' value='".$dataArray["ktg_id"][$index]."'>";
$data .= "<i class='fa fa-folder-open'></i> ";
$data .= "<label class='tree-toggle'>".$dataArray['ktg_adi'][$index]."</label>";
$data .= "</span>";
$data .= self::tree($dataArray, $dataArray["ktg_id"][$index], $selected);
$data .= "</li>";
}
}
else{
$data .= "<li class='tree-folder'>";
$data .= "<span class='tree-folder-name'>";
$data .= "<input type='checkbox' name='".$inputName."[]' value='".$dataArray["ktg_id"][$index]."'>";
$data .= "<i class='fa fa-folder-open'></i> ";
$data .= "<label class='tree-toggle'>".$dataArray['ktg_adi'][$index]."</label>";
$data .= "</span>";
$data .= self::tree($dataArray, $dataArray["ktg_id"][$index]);
$data .= "</li>";
}
}
}
$data .= "</ul>";
return $data;
}
}