Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 150 lines (108 sloc) 5.417 kb
b5dfdcd @CloCkWeRX Added source to svn
CloCkWeRX authored
1 <?php
2
3 /**
4 * Components example.
5 *
6 * @package XML_MXML
7 * @author Markus Nix <mnix@docuverse.de>
8 */
9
10 require_once 'XML/MXML.php';
11
12
13 try
14 {
15 $doc = XML_MXML::createDocument();
16 $doc->enableValidation(true);
17 $app = $doc->createElement('application', array('width' => 600, 'height' => 400));
18 $doc->addRoot($app);
19
20 $xml = $doc->createElement('xml', array('id' => 'treeModel', 'source' => '../assets/tree.xml'));
21 $app->appendChild($xml);
22
23 $tnv = $doc->createElement('tabnavigator', array('widthFlex' => 1, 'heightFlex' => 1));
24
25 // DataInput
26 $vbox = $doc->createElement('vbox', array('label' => 'DataInput', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
27
28 $txi = $doc->createElement('textinput');
29 $text = $txi->addText();
30 $text->setCData('This is a TextInput');
31 $vbox->appendChild($txi);
32
33 $txa = $doc->createElement('textarea', array('width' => 150, 'height' => 100));
34 $text = $txa->addText();
35 $text->setCData('This is a TextArea');
36 $vbox->appendChild($txa);
37
38 $nst = $doc->createElement('numericstepper', array('minimum' => 2003, 'maximum' => 2010, 'stepSize' => 1, 'value' => 2003, 'width' => 60));
39 $vbox->appendChild($nst);
40
41 $chb = $doc->createElement('checkbox', array('label' => 'HTML'));
42 $vbox->appendChild($chb);
43
44 $lbl = $doc->createElement('label', array('text' => 'What year were women first allowed to compete in the Boston Marathon?'));
45 $vbox->appendChild($lbl);
46
47 $rdb = $doc->createElement('radiobutton', array('groupName' => 'year', 'id' => 'option1', 'label' => 1952));
48 $vbox->appendChild($rdb);
49
50 $rdb = $doc->createElement('radiobutton', array('groupName' => 'year', 'id' => 'option1', 'label' => 1962));
51 $vbox->appendChild($rdb);
52
53 $rdb = $doc->createElement('radiobutton', array('groupName' => 'year', 'id' => 'option1', 'label' => 1972));
54 $vbox->appendChild($rdb);
55
56 $btn = $doc->createElement('button', array('label' => 'Check Answer', 'click' => 'alert(option3.selected? \'Correct Answer\' : \'Wrong Answer\', \'Result\')'));
57 $vbox->appendChild($btn);
58
59 $tnv->appendChild($vbox);
60
61 // Lists
62 $vbox = $doc->createElement('vbox', array('label' => 'Lists', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
63
64 $script = $doc->createElement('script');
65 $script->setCData('var cards = [ {label:"Visa", data:1}, {label:"American Express", data:2}, {label:"Master Card", data:3} ];');
66 $vbox->appendChild($script);
67
68 $cmbx = $doc->createElement('combobox', array('dataProvider' => '{cards}', 'width' => 200));
69 $vbox->appendChild($cmbx);
70
71 $mdl = $doc->createElement('model', array('id' => 'statesModel', 'source' => '../assets/states.xml'));
72 $vbox->appendChild($mdl);
73
74 $list = $doc->createElement('list', array('id' => 'source', 'dataProvider' => '{statesModel.state}', 'multipleSelection' => true));
75 $vbox->appendChild($list);
76
77 $tnv->appendChild($vbox);
78
79 // Dates
80 $vbox = $doc->createElement('vbox', array('label' => 'Dates', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
81
82 $dtf = $doc->createElement('datefield', array('width' => 100));
83 $vbox->appendChild($dtf);
84
85 $dtc = $doc->createElement('datechooser');
86 $vbox->appendChild($dtc);
87
88 $tnv->appendChild($vbox);
89
90 // Tree
91 $vbox = $doc->createElement('vbox', array('label' => 'Tree', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
92
93 $tree = $doc->createElement('tree', array('dataProvider' => '{treeModel}', 'widthFlex' => 1, 'heightFlex' => 1));
94 $vbox->appendChild($tree);
95
96 $tnv->appendChild($vbox);
97
98 // Data Grid
99 $vbox = $doc->createElement('vbox', array('label' => 'Data Grid', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
100
101 $mdl = $doc->createElement('model', array('id' => 'employeeModel', 'source' => '../assets/employees.xml') );
102 $vbox->appendChild($mdl);
103
104 $dgd = $doc->createElement('datagrid', array('height' => 300, 'widthFlex' => 1, 'heightFlex' => 1, 'dataProvider' => '{employeeModel.employee}'));
105 $vbox->appendChild($dgd);
106
107 $tnv->appendChild($vbox);
108
109 // Navigators
110 $vbox = $doc->createElement('vbox', array('label' => 'Navigators', 'marginLeft' => 8, 'widthFlex' => 1, 'heightFlex' => 1));
111
112 $lbl = $doc->createElement('link', array('label' => 'About Macromedia', 'click' => 'getUrl("http://www.macromedia.com", "_blank")'));
113 $vbox->appendChild($lbl);
114
115 $acrd = $doc->createElement('accordion', array('heightFlex' => 1));
116 $acrd->appendStructure(array(
117 array(
118 'name' => 'canvas',
119 'attributes' => array('label' => 'Address')
120 ),
121 array(
122 'name' => 'canvas',
123 'attributes' => array('label' => 'Shipping Method')
124 ),
125 array(
126 'name' => 'canvas',
127 'attributes' => array('label' => 'Payment Method')
128 )
129 ));
130
131 $vbox->appendChild($acrd);
132 $tnv->appendChild($vbox);
133 $app->appendChild($tnv);
134 } catch (Exception $e) {
135 die($e->getMessage());
136 }
137
138
139 if ($_GET['mode'] == 'source') {
140 highlight_file( __FILE__ );
141 } else if ($_GET['mode'] == 'dump') {
142 echo "<pre>";
143 echo $doc->dump();
144 echo "</pre>";
145 } else {
146 $doc->send();
147 }
148
149 ?>
Something went wrong with that request. Please try again.