]> git.proxmox.com Git - extjs.git/blob - extjs/build/examples/kitchensink/data/direct/classes/TestAction.php
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / data / direct / classes / TestAction.php
1 <?php
2
3 class TestAction {
4 function doEcho($data){
5 return $data;
6 }
7
8 function multiply($num){
9 if(!is_numeric($num)){
10 throw new Exception('Call to multiply with a value that is not a number');
11 }
12 return $num*8;
13 }
14
15 function getTree($id){
16 $out = array();
17 if($id == "root"){
18 for($i = 1; $i <= 5; ++$i){
19 array_push($out, array(
20 'id'=>'n' . $i,
21 'text'=>'Node ' . $i,
22 'leaf'=>false
23 ));
24 }
25 }else if(strlen($id) == 2){
26 $num = substr($id, 1);
27 for($i = 1; $i <= 5; ++$i){
28 array_push($out, array(
29 'id'=>$id . $i,
30 'text'=>'Node ' . $num . '.' . $i,
31 'leaf'=>true
32 ));
33 }
34 }
35 return $out;
36 }
37
38 function getGrid($params, $metadata){
39 $sort = $params->sort[0];
40 $field = $sort->property;
41 $direction = $sort->direction;
42
43 $table = $metadata->table;
44
45 if ($table == 'customers') {
46 $data = array(
47 array(
48 'name'=>'ABC Accounting',
49 'revenue'=>50000
50 ), array(
51 'name'=>'Ezy Video Rental',
52 'revenue'=>106300
53 ), array(
54 'name'=>'Greens Fruit Grocery',
55 'revenue'=>120000
56 ), array(
57 'name'=>'Icecream Express',
58 'revenue'=>73000
59 ), array(
60 'name'=>'Ripped Gym',
61 'revenue'=>88400
62 ), array(
63 'name'=>'Smith Auto Mechanic',
64 'revenue'=>222980
65 )
66 );
67 }
68 elseif ($table == 'leads') {
69 $data = array(
70 array(
71 'name' => 'AT&T Inc.',
72 'revenue' => 10000000
73 ), array(
74 'name' => 'General Electric',
75 'revenue' => 5000000
76 ), array(
77 'name' => 'Intel Corporation',
78 'revenue' => 150000000
79 ), array(
80 'name' => 'Verizon Communications',
81 'revenue' => 3000000
82 )
83 );
84 }
85 else {
86 throw new Exception("Wrong table: $table");
87 }
88
89 function sort_fn($property) {
90 $fn_text = "return strnatcmp(\$a['$property'], \$b['$property']);";
91
92 return create_function('$a, $b', $fn_text);
93 }
94
95 usort($data, sort_fn($field));
96
97 if ($direction == 'DESC') {
98 $data = array_reverse($data);
99 }
100
101 return $data;
102 }
103
104 function showDetails($data){
105 $first = $data->firstName;
106 $last = $data->lastName;
107 $age = $data->age;
108 return "Hi $first $last, you are $age years old.";
109 }
110 }
111
112 ?>