Documentation/Index/CustomMPKStyle: CustomAsyncTreeDialog.inc

Plik CustomAsyncTreeDialog.inc, 3.7 KB (dodany przez TS, 8 years temu)
xx
Line 
1<?php
2require_once(LIB_PATH.'widgets/WDialogForm.inc');
3
4/**
5 * CustomAsyncTreeDialog
6 *
7 * @final
8 * @author Tomasz Świenty
9 * @version 0.1
10 * @copyright Copyright (c) BetaSoft
11 */
12final class CustomAsyncTreeDialog extends WDialogForm {
13
14
15
16    /**
17     * __construct
18     *
19     * @param string $name
20     * @param string $caption
21     * @param string $dstyle
22     * @return void
23     */
24    public function __construct($name, $caption = NULL, $dstyle = BS_DIALOG) {
25
26        parent::__construct($name, Translator::translate('Wybór z async drzewka'), BS_DIALOG);
27        $this->path = Application::makeRelativePath(__FILE__);
28
29        $this->HWND = $this->name;
30
31        $this->width = '400px';
32        $this->height = '276px';
33
34        if (($this->isOpened()) AND (!$this->noNeedForCreate())) {
35            $this->create();
36        }
37
38    }
39
40
41
42    public function save() {
43
44        $sData = $this->getSData();
45        $wData = $this->getWData();
46       
47        // tutaj musi nastąpić zapisanie do relacji places_of_vcosts i zapisanie zmiennej $povcid
48
49        if (isset($sData['js_after'])) {
50            JScript::add($sData['js_after']);
51        }
52
53        if (isset($sData['onAdd']) AND $sData['onAdd']) {
54            JScript::add($sData['onAdd'].'('.$povcid.')');   
55        }
56       
57        $this->jsClose(TRUE, TRUE);
58
59        return TRUE;
60
61    }
62
63
64
65    /**
66     * open
67     *
68     * @param string $params
69     * @return void
70     */
71    public function open($params = array()) {
72
73        parent::open($params, $data);
74        $this->setSData($data);
75        $this->create();
76
77    }
78
79
80
81    /**
82     * create
83     *
84     * @return void
85     */
86    protected function create() {
87
88        if (!$this->isOpened()) {
89            return FALSE;
90        }
91
92        require_once(LIB_PATH.'widgets/Panel.inc');
93        require_once(LIB_PATH.'forms/TextInput.inc');       
94        require_once('./scripts/MyCustomTree.inc');
95
96        $this->setHeaderIcon('PageToolBar/settings.png');
97        $this->setHeaderTitle(Translator::translate('Wybierz z async drzewka :D.'));
98
99        $top = 14;
100        $int = 27;
101       
102        $leftPanel = new Panel($this->name.'leftPanel');
103        $leftPanel->top = '';
104        $leftPanel->left = '';
105        $leftPanel->width = '100%';
106        $leftPanel->height = '100%';
107        $leftPanel->overflow = 'hidden';
108        $leftPanel->class = 'b-s-b SPEX_';
109        $leftPanel->style = 'float:left;';
110        $leftPanel->position = 'relative';
111        $leftPanel->display = '';
112       
113        $tree__ = new MyCustomTree($this->name.'tree__');
114        $tree__->withoutUnnecessaryDIV = TRUE;
115        $tree__->class = 'b-s-b sbg';
116        $tree__->mainCSS = 'height:calc(100% - 30px)';
117        $tree__->setStyle('overflow:auto; height:calc(100% - 32px); width:100%;');
118        $tree__->onSelect = '$(\''.$this->name.'trekey'.'\').value = this.clsnam;';
119
120        $trekey = new TextInput($this->name.'trekey');
121        $trekey->setCSSFormatting(NULL, 'display: none;');
122       
123        $this->height = '400px';
124
125        parent::create();
126
127        $this->add($leftPanel);
128        $leftPanel->add($tree__);
129        $this->add($trekey, 'trekey');       
130
131        $this->addButtonsPanel(array('bSave', 'bCancel'));
132
133    }
134
135}
136
137final class CustomAsyncTreeDialogInitializer {
138
139
140
141    public static function init($args) {
142
143        $dHWND = Application::registerDialog(Application::getShortName('CustomAsyncTreeDialogD'), 'CustomAsyncTreeDialog', './scripts/CustomAsyncTreeDialog.inc');
144        $args = JSON::encode($args);
145        if (get_magic_quotes_gpc() == 1) {
146            $args = addSlashes($args);
147        }
148
149        JScript::add('App.openDialogEx(\''.$dHWND.'\', null, ('.$args.').toJSONString())');
150
151    }
152
153}
154
155if (isset($args)) {
156    CustomAsyncTreeDialogInitializer::init($args);
157}
158
159?>