1 | <?php |
||
14 | abstract class OrderStepController extends Controller |
||
15 | { |
||
16 | private static $allowed_actions = array( |
||
|
|||
17 | 'error' => true, |
||
18 | ); |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $alternativeContent = ""; |
||
24 | |||
25 | /** |
||
26 | * when no action is selected |
||
27 | * this action runs... |
||
28 | */ |
||
29 | public function index($request) |
||
30 | { |
||
31 | $this->alternativeContent = '<p class="message bad">Sorry, we can not find the page you are looking for.</p>'; |
||
32 | |||
33 | return $this->renderWith('Page'); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * there is an error ... |
||
38 | */ |
||
39 | public function error($request) |
||
40 | { |
||
41 | $this->alternativeContent = '<p class="message bad">Sorry, an error occurred, please contact us for more information....</p>'; |
||
42 | |||
43 | return $this->renderWith('Page'); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | protected static function name_of_controller_class() |
||
50 | { |
||
51 | return get_called_class(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param Order $order |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | protected static function secure_hash($order) |
||
60 | { |
||
61 | $obj = Injector::inst()->get(self::name_of_controller_class()); |
||
62 | |||
63 | return $obj->secureHash($order); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function nameOfControllerClass() |
||
70 | { |
||
71 | return self::name_of_controller_class(); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * related OrderStatusLog class. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | abstract protected function nameOfLogClass(); |
||
80 | |||
81 | /** |
||
82 | * main content ... |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function Content($order = null) |
||
87 | { |
||
88 | if ($this->alternativeContent) { |
||
89 | return $this->alternativeContent; |
||
90 | } |
||
91 | return $this->standardContent($order); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return string ($html) |
||
96 | */ |
||
97 | protected function standardContent($order = null) |
||
98 | { |
||
99 | user_error("Make sure to put some content here in classes that extend ".$this->class); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * the form on the field. |
||
104 | * |
||
105 | * @return Form |
||
106 | */ |
||
107 | protected function Form() |
||
108 | { |
||
109 | return $this->Form; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * code of related order step. |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | abstract protected function codeOfRelevantOrderStep(); |
||
118 | |||
119 | /** |
||
120 | * used to secure page. |
||
121 | * |
||
122 | * @param Order $order |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | abstract protected function secureHash($order); |
||
127 | |||
128 | /** |
||
129 | * @oaram string $action |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function Link($action = null) |
||
134 | { |
||
135 | $link = '/'.Config::inst()->get($this->nameOfControllerClass(), 'url_segment').'/'; |
||
142 | |||
143 | public function errorLink() |
||
147 | |||
148 | /** |
||
149 | * is the order valid? |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | protected function checkOrder($dataOrRequest = null) |
||
162 | |||
163 | /** |
||
164 | * @var Order |
||
165 | */ |
||
166 | private static $_order = null; |
||
167 | |||
168 | /** |
||
169 | * finds the order ... |
||
170 | * |
||
171 | * @param mixed |
||
172 | * |
||
173 | * @return Order |
||
174 | */ |
||
175 | protected function Order($dataOrRequest = null) |
||
208 | |||
209 | /** |
||
210 | * @return string |
||
211 | */ |
||
212 | protected function getOrderGetParams() |
||
218 | |||
219 | /** |
||
220 | * @return OrderStep |
||
221 | */ |
||
222 | protected function orderStep() |
||
229 | } |
||
230 |