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