Documentation/Index/CustomTreeForCRegisters: MyCustomTree.inc

Plik MyCustomTree.inc, 1.9 KB (dodany przez TS, 7 years temu)
xx
Line 
1<?php
2require_once(LIB_PATH.'tree/CustomAsyncTree.inc');
3
4/**
5 * MyCustomTree
6 *
7 * @uses CustomAsyncTree
8 * @final
9 * @author Tomasz Świenty
10 * @version 0.3
11 * @copyright Copyright (c) BetaSoft
12 */
13final class MyCustomTree extends CustomAsyncTree {
14
15
16   
17    /**
18     *
19     * @param string $name                 nazwa
20     * @param boolean [$doCreate = FALSE]  zawsze dać FALSE
21     * @param array [$params = NULL]       dodatkowe parametry jako array
22     */
23    public function __construct($name, $doCreate = FALSE, $params = NULL) {
24
25        $this->rootItem = array();
26        $this->rootItem['dscrpt'] = 1;
27        $this->rootItem['clsnam'] = 1;
28        $this->rootItem['keyval'] = 1;
29
30        $this->path = './scripts/MyCustomTree.inc';
31
32        parent::__construct($name, $doCreate, $params);
33       
34    }
35
36
37   
38    /**
39     * getCustomItems
40     *
41     * @param  array $data dane ładowanego węzła drzewka jako array(clsnam => '', keyval => '')
42     * @return array lista węzłów w zależności od podanego elementu nadrzędnego ($data)
43     */
44    public function getCustomItems($data) {
45
46        $items = array();
47        if (isset($data['keyval']) AND isset($data['clsnam'])) {
48            // root ustawiony w __construct
49            //if ($data['clsnam'] == 1) {
50            $items[] = array(
51                'dscrpt'    => 'A - '.time(),
52                'clsnam'    => $data['clsnam'].'-NOWE_CLSNAM',
53                'keyval'    => $data['keyval'].'-NOWE_KEYVAL',
54                'hasChilds' => TRUE
55            );
56
57            $items[] = array(
58                'dscrpt'    => '<span style="color:red;">BC - '.htmlspecialchars(time(), ENT_QUOTES, 'UTF-8').'</span>',
59                'clsnam'    => $data['clsnam'].'-NOWE_CLSNAM',
60                'keyval'    => $data['keyval'].'-NOWE_KEYVAL',
61                'hasChilds' => TRUE,
62                'doHSC'     => FALSE
63            );
64            //}
65        }
66
67        return $items;
68
69    }
70
71} // class MyCustomTree
72
73?>