Framework  3.9
tree_select_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 
46 {
47  var $tree;
48  var $field;
51 
52  function TreeSelectFieldRenderer(&$form, $field, &$tree, $label = null)
53  {
54  $this->tree = $tree;
55  $this->onPreProcess = null;
56  $this->onPostProcess = null;
57  $this->FieldRenderer($form);
58  $this->field = $field;
59  if ($form->data->hasField($field))
60  {
61  $form->override($field, $label, $this);
62  }
63  else
64  {
65  $form->add($this, $field);
66  if ($label) $form->alias($field, $label);
67  }
68  }
69 
70  function renderScript($field)
71  {
72  //Not necessary - tree control writes script automatically
73  //$this->tree->writeScript();
74  }
75 
76  function renderSearchField($field, $mode = "")
77  {
78  $this->renderField($field);
79  }
80 
81  function renderField($field = "")
82  {
83  if (!$field) $field = $this->field;
84 
85  $this->_startField($field);
86  $this->tree->writeHTML();
87  $this->_endField($field);
88  }
89 
91  {
92  //TODO: Implement this
93  }
94 
95  function preProcess($field = "")
96  {
97  if ($this->onPreProcess != null)
98  {
99  $callback = $this->onPreProcess;
100  call_user_func($callback, $this, $field);
101  }
102  }
103 
104  function postProcess($field = "")
105  {
106  if ($this->onPostProcess != null)
107  {
108  $callback = $this->onPostProcess;
109  call_user_func($callback, $this, $field);
110  }
111  }
112 }
113 ?>
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)
_endField($field)
Internal method to generate the closing HTML for the field.
FieldRenderer($parent)
Constructor.
Field renderer for data fields that are selectable via a tree control.
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...
renderSearchField($field, $mode="")
FieldRenderers must override this method to provide the HTML implementation of the control displayed ...
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...
TreeSelectFieldRenderer(&$form, $field, &$tree, $label=null)