1: <?php
2:
3: /**
4: * Defines the renderer interface, which allows us to have various implementations (HTML,
5: * JSON, XML etc.) behind one unified interface. Use the
6: * AlphaRendererProviderFactory::getInstance() method to get instances of this.
7: *
8: * @package alpha::view::renderers
9: * @since 1.2
10: * @author John Collins <dev@alphaframework.org>
11: * @version $Id: AlphaRendererProviderInterface.inc 1745 2014-03-29 15:19:05Z alphadevx $
12: * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
13: * @copyright Copyright (c) 2014, John Collins (founder of Alpha Framework).
14: * All rights reserved.
15: *
16: * <pre>
17: * Redistribution and use in source and binary forms, with or
18: * without modification, are permitted provided that the
19: * following conditions are met:
20: *
21: * * Redistributions of source code must retain the above
22: * copyright notice, this list of conditions and the
23: * following disclaimer.
24: * * Redistributions in binary form must reproduce the above
25: * copyright notice, this list of conditions and the
26: * following disclaimer in the documentation and/or other
27: * materials provided with the distribution.
28: * * Neither the name of the Alpha Framework nor the names
29: * of its contributors may be used to endorse or promote
30: * products derived from this software without specific
31: * prior written permission.
32: *
33: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
34: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
35: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
38: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
40: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
44: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46: * </pre>
47: *
48: */
49: interface AlphaRendererProviderInterface {
50: /**
51: * Provide the BO that we are going render.
52: *
53: * @param AlphaDAO $BO
54: * @since 1.2
55: */
56: public function setBO($BO);
57:
58: /**
59: * Renders the create view for the BO using the selected renderer.
60: *
61: * @param array $fields Hash array of fields to pass to the template.
62: * @return string
63: * @since 1.2
64: */
65: public function createView($fields=array());
66:
67: /**
68: * Renders the edit view for the BO using the selected renderer.
69: *
70: * @param array $fields Hash array of fields to pass to the template.
71: * @return string
72: * @since 1.2
73: */
74: public function editView($fields=array());
75:
76: /**
77: * Renders the list view for the BO using the selected renderer.
78: *
79: * @param array $fields Hash array of fields to pass to the template.
80: * @return string
81: * @since 1.2
82: */
83: public function listView($fields=array());
84:
85: /**
86: * Renders the detailed read-only view for the BO using the selected renderer.
87: *
88: * @param array $fields Hash array of fields to pass to the template.
89: * @return string
90: * @since 1.2
91: */
92: public function detailedView($fields=array());
93:
94: /**
95: * Renders the admin view for the BO using the selected renderer.
96: *
97: * @param array $fields Hash array of fields to pass to the template.
98: * @return string
99: * @since 1.2
100: */
101: public function adminView($fields=array());
102:
103: /**
104: * Renders the header content using the given renderer.
105: *
106: * @param AlphaController $controller
107: * @return string
108: * @throws IllegalArguementException
109: * @since 1.2
110: */
111: public static function displayPageHead($controller);
112:
113: /**
114: * Renders the footer content using the given renderer.
115: *
116: * @param AlphaController $controller
117: * @return string
118: * @since 1.2
119: */
120: public static function displayPageFoot($controller);
121:
122: /**
123: * Renders an update (e.g. successful save) message.
124: *
125: * @param string $message
126: * @return string
127: * @since 1.2
128: */
129: public static function displayUpdateMessage($message);
130:
131: /**
132: * Renders an error (e.g. save failed) message.
133: *
134: * @param string $message
135: * @return string
136: * @since 1.2
137: */
138: public static function displayErrorMessage($message);
139:
140: /**
141: * Renders an error page with the supplied HTTP error code and a message.
142: *
143: * @param string $code
144: * @param string $message
145: * @return string
146: * @since 1.2
147: */
148: public static function renderErrorPage($code, $message);
149:
150: /**
151: * Method to render a hidden HTML form for posting the OID of an object to be deleted.
152: *
153: * @return string
154: * @since 1.2
155: */
156: public static function renderDeleteForm();
157:
158: /**
159: * Method to render a HTML form with two hidden, hashed (MD5) form fields to be used as
160: * a check to ensure that a post to the controller is being sent from the same server
161: * as hosting it.
162: *
163: * @return string
164: * @since 1.2
165: */
166: public static function renderSecurityFields();
167:
168: /**
169: * Renders an Integer field value.
170: *
171: * @param string $name The field name
172: * @param string $label The label to apply to the field
173: * @param string $mode The field mode (create/edit/view)
174: * @param string $value The field value (optional)
175: * @param bool $tableTags Include table tags and label (optional)
176: * @return string
177: * @since 1.2
178: */
179: public function renderIntegerField($name, $label, $mode, $value='', $tableTags=true);
180:
181: /**
182: * Renders an Double field value.
183: *
184: * @param string $name The field name
185: * @param string $label The label to apply to the field
186: * @param string $mode The field mode (create/edit/view)
187: * @param string $value The field value (optional)
188: * @param bool $tableTags Include table tags and label (optional)
189: * @return string
190: * @since 1.2
191: */
192: public function renderDoubleField($name, $label, $mode, $value='', $tableTags=true);
193:
194: /**
195: * Renders an Boolean field value.
196: *
197: * @param string $name The field name
198: * @param string $label The label to apply to the field
199: * @param string $mode The field mode (create/edit/view)
200: * @param string $value The field value (optional)
201: * @return string
202: * @since 1.2
203: */
204: public function renderBooleanField($name, $label, $mode, $value='');
205:
206: /**
207: * Renders an Enum field value.
208: *
209: * @param string $name The field name
210: * @param string $label The label to apply to the field
211: * @param string $mode The field mode (create/edit/view)
212: * @param array $options The Enum options
213: * @param string $value The field value (optional)
214: * @return string
215: * @since 1.0
216: */
217: public function renderEnumField($name, $label, $mode, $options, $value='');
218:
219: /**
220: * Renders an DEnum field value.
221: *
222: * @param string $name The field name
223: * @param string $label The label to apply to the field
224: * @param string $mode The field mode (create/edit/view)
225: * @param array $options The DEnum options
226: * @param string $value The field value (optional)
227: * @param bool $tableTags Include table tags and label (optional)
228: * @return string
229: * @since 1.2
230: */
231: public function renderDEnumField($name, $label, $mode, $options, $value='', $tableTags=true);
232:
233: /**
234: * Method to render a field when type is not known.
235: *
236: * @param string $name The field name
237: * @param string $label The label to apply to the field
238: * @param string $mode The field mode (create/edit/view)
239: * @param string $value The field value (optional)
240: * @return string
241: * @since 1.2
242: */
243: public function renderDefaultField($name, $label, $mode, $value='');
244:
245: /**
246: * Renders a Text field value.
247: *
248: * @param string $name The field name
249: * @param string $label The label to apply to the field
250: * @param string $mode The field mode (create/edit/view)
251: * @param string $value The field value (optional)
252: * @param bool $tableTags Include table tags and label (optional)
253: * @return string
254: * @since 1.0
255: */
256: public function renderTextField($name, $label, $mode, $value='', $tableTags=true);
257:
258: /**
259: * Renders a String field value.
260: *
261: * @param string $name The field name
262: * @param string $label The label to apply to the field
263: * @param string $mode The field mode (create/edit/view)
264: * @param string $value The field value (optional)
265: * @return string
266: * @since 1.2.2
267: */
268: public function renderStringField($name, $label, $mode, $value='');
269:
270: /**
271: * Renders a Relation field value.
272: *
273: * @param string $name The field name
274: * @param string $label The label to apply to the field
275: * @param string $mode The field mode (create/edit/view)
276: * @param string $value The field value (optional)
277: * @param bool $tableTags Include table tags and label (optional)
278: * @param bool $expanded Render the related fields in expanded format or not (optional)
279: * @param bool $buttons Render buttons for expanding/contacting the related fields (optional)
280: * @return string
281: * @since 1.2
282: */
283: public function renderRelationField($name, $label, $mode, $value='', $tableTags=true, $expanded=false, $buttons=true);
284:
285: /**
286: * Convenience method that renders all fields for the current BO in edit/create/view mode.
287: *
288: * @param string $mode (view|edit|create)
289: * @param array $filterFields Optional list of field names to exclude from rendering.
290: * @param array $readOnlyFields Optional list of fields to render in a readonly fashion when rendering in create or edit mode.
291: * @return string
292: * @since 1.2
293: */
294: public function renderAllFields($mode, $filterFields=array(), $readOnlyFields=array());
295: }
296:
297: ?>
298: