Framework  3.9
data_list_field_renderer.inc
Go to the documentation of this file.
1 <?php
6 /**************************************************************
7 
8  Copyright (c) 2007-2010 Sonjara, Inc
9 
10  Permission is hereby granted, free of charge, to any person
11  obtaining a copy of this software and associated documentation
12  files (the "Software"), to deal in the Software without
13  restriction, including without limitation the rights to use,
14  copy, modify, merge, publish, distribute, sublicense, and/or sell
15  copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following
17  conditions:
18 
19  The above copyright notice and this permission notice shall be
20  included in all copies or substantial portions of the Software.
21 
22  Except as contained in this notice, the name(s) of the above
23  copyright holders shall not be used in advertising or otherwise
24  to promote the sale, use or other dealings in this Software
25  without prior written authorization.
26 
27  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
29  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
32  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34  OTHER DEALINGS IN THE SOFTWARE.
35 
36 *****************************************************************/
37 
38 require_once realpath(dirname(__FILE__))."/../field_renderers.inc";
39 
58 {
59  var $field;
60  var $label;
61  var $table;
62 
64  {
65  $this->FieldRenderer($parent);
66 
67  $this->field = ($field) ? $field : $table->id;
68  $this->label = ($label) ? $label : prettify($this->field);
69 
70  $this->table = $table;
71  if ($parent->data->hasField($this->field))
72  {
73  $parent->override($this->field, $this->label, $this);
74  }
75  else
76  {
77  $parent->add($this, $this->field);
78  $parent->overrides[$this->field]['label'] = $this->label;
79  }
80  $this->colspan = 2;
81  }
82 
83  function renderScript($field)
84  {
85  return $this->table->writeScript();
86  }
87 
88  function renderSearchField($field, $mode = "")
89  {
90  $this->renderField();
91  }
92 
93  function renderField($field)
94  {
95  if (!$field) $field = $this->field;
96 
97  $this->_startField($field);
98  $this->table->drawView();
99  $this->_endField($field);
100  }
101 
102  function preProcess($field = "")
103  {
104  if ($this->onPreProcess != null)
105  {
106  $callback = $this->onPreProcess;
107  call_user_func($callback, $this, $field);
108  }
109  }
110 
111  function renderReadOnly()
112  {
113  $this->table->selectable = false;
114  $this->renderField();
115  }
116 
117  function postProcess($field = "")
118  {
119  if ($this->onPostProcess != null)
120  {
121  $callback = $this->onPostProcess;
122  call_user_func($callback, $this, $field);
123  }
124  }
125 }
126 ?>
Add a DataListView table to an AutoForm.
renderSearchField($field, $mode="")
FieldRenderers must override this method to provide the HTML implementation of the control displayed ...
DataListFieldRenderer(&$parent, $table, $field="", $label="")
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
postProcess($field="")
FieldRenderers can override this method to provide behavior that occurs after the parent form's targe...
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
preProcess($field="")
FieldRenderers can override this method to provide behavior that occurs prior to the saving of the pa...
FieldRenderer is the abstract base class for all FieldRenderers.
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
$onPreProcess
callback hook for processing prior to saving the form's data object - individual renderers may overri...
_endField($field)
Internal method to generate the closing HTML for the field.
$onPostProcess
callback hook for processing after saving the form's data object - individual renderers may override ...
FieldRenderer($parent)
Constructor.
prettify($name)
Takes a variable or field name and converts it into a human-readable version (assuming that the origi...
Definition: functions.inc:1413