-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.php
executable file
·112 lines (103 loc) · 2.58 KB
/
basic.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/*
* The inclusion of DangerFrame! This initiates the framework.
*/
require_once('includes/inc.php');
/*
* A very basic Model.
* This would normally be stored elsewhere.
* It is here for simplifying the example.
*/
class Item
{
protected $limes;
protected $grapefruits;
protected $oranges;
public function __construct($limes, $grapefruits, $oranges)
{
$this->limes = $limes;
$this->grapefruits = $grapefruits;
$this->oranges = $oranges;
}
public function limes()
{
return $this->limes;
}
public function grapefruits()
{
return $this->grapefruits;
}
public function oranges()
{
return $this->oranges;
}
}
/*
* An extension of DangerFrame_Loop to populate items
*/
class extendedLoop extends DangerFrame_Loop
{
protected $i = 0;
public function populateItem(DangerFrame_LoopItem $item)
{
$item->add(
new DangerFrame_Label('sub','Grapes '.($this->i++).' successful'));
}
}
/*
* An extension of DangerFrame_ListView to populate items
*/
class extendedListView extends DangerFrame_ListView
{
public function populateItem(DangerFrame_ListItem $item)
{
$item->add(
new DangerFrame_Label('limes', $item->getModelObject()->limes()),
new DangerFrame_Label('grapefruits', $item->getModelObject()->grapefruits()),
new DangerFrame_Label('oranges', $item->getModelObject()->oranges()));
}
}
/*
* The page controller. Notice the class name matches the filename
*/
class basic extends DangerFrame_Page
{
public function __construct()
{
parent::__construct();
/*
* All the page components are added to the page.
* Admire the beauty...
*/
$this->add(
new DangerFrame_Label('apples','Apple test successful'));
$this->add(
new DangerFrame_MultiLineLabel('oranges','Orange test successful!
Orange test successful (line 2)'));
$pears = $this->add(
new DangerFrame_WebMarkupContainer('pears'));
$pears->add(
new DangerFrame_Label('pineapples','Pears & Pinapples test successful'));
$bananas = $this->add(
new DangerFrame_RepeatingView('bananas'));
$bananas->add(
new DangerFrame_Label('1','Bananas 1 successful'));
$bananas->add(
new DangerFrame_Label('2','Bananas 2 successful'),
new DangerFrame_Label('3','Bananas 3 successful'));
$grapes = $this->add(
new extendedLoop('grapes', 5));
$lemons = $this->add(
new extendedListView('lemons',
new DangerFrame_List(
array(
new Item('A','B','C'),
new Item('D','E','F'),
new Item('G','H','I'),
)
)
)
);
}
}
?>