Framework  3.9
HTMLFieldRenderer Class Reference

Field renderer for HTML data fields. More...

+ Inheritance diagram for HTMLFieldRenderer:
+ Collaboration diagram for HTMLFieldRenderer:

Public Member Functions

 HTMLFieldRenderer (&$parent)
 
 setRTEParam ($key, $value)
 
 getRTEParam ($key)
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 addEditorButton ($editor, $button)
 
 overrideEditorButton ($editor, $button)
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. More...
 
 renderReadOnly ($field)
 
 renderSearchField ($field, $mode="equal")
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
 renderOnSubmitHandler ($field)
 FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client. More...
 
- Public Member Functions inherited from FieldRenderer
 FieldRenderer ($parent)
 Constructor. More...
 
 _printLabel ($field, $colspan=1, $styles="", $annotation="")
 Internal method to generate the HTML for the field label. More...
 
 _getLabel ($field, $addSuffix=true)
 
 _startField ($field, $styles="")
 Internal method to generate the starting HTML for the field (including the label) More...
 
 _endField ($field)
 Internal method to generate the closing HTML for the field. More...
 
 addValidatorsToForm ($field, $required=false)
 This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer. More...
 
 addSearchValidatorsToForm ($field, $mode, $required=false)
 For SearchForm, the validator field needs to match the name tag in the form which is in the format field:mode. More...
 
 formatName ($item, $name)
 Formats the given DataItem based on the supplied format string. More...
 
 renderSearchScript ($field, $mode)
 FieldRenderers can override this method to provide any Javascript that the control requires when being used in a search form. More...
 
 preProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database. More...
 
 postProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs after the parent form's target object has been saved to the database. More...
 

Public Attributes

 $colspan = 2
 
 $hideStyleBar = false
 
 $width = "540px"
 
 $height = "200px"
 
 $featureButtons
 
 $rootBlock = "p"
 
 $baseURL = null
 
 $convertURLs = false
 
 $rteParams = array()
 
- Public Attributes inherited from FieldRenderer
 $parent = null
 
 $labelSuffix = ""
 
 $colspan = 1
 
 $annotateBefore = false
 
 $annotateNextLine = true
 
 $hideLabel = false
 
 $onPreProcess = null
 callback hook for processing prior to saving the form's data object - individual renderers may override with custom processing More...
 
 $onPostProcess = null
 callback hook for processing after saving the form's data object - individual renderers may override with custom processing More...
 

Static Public Attributes

static $_includedRTEScript = false
 
static $actionFilter = null
 

Detailed Description

Field renderer for HTML data fields.

Renders with the Sonjara Rich Text Editor, which can be extended to provide custom toolbar buttons for application-specific features and enhancements.

Definition at line 46 of file html_field_renderer.inc.

Member Function Documentation

◆ addEditorButton()

HTMLFieldRenderer::addEditorButton (   $editor,
  $button 
)

Definition at line 222 of file html_field_renderer.inc.

223  {
224  if ($button['url'])
225  {
226  echo "theEditors.$editor.addToolbarButton('{$button['name']}', '{$button['image']}', '{$button['tooltip']}', '{$button['url']}', '{$button['width']}', '{$button['height']}');\n";
227  }
228  else
229  {
230  echo "theEditors.$editor.addToolbarButton('{$button['name']}', '{$button['image']}', '{$button['tooltip']}', {$button['handler']});\n";
231  }
232  }

◆ getRTEParam()

HTMLFieldRenderer::getRTEParam (   $key)

Definition at line 77 of file html_field_renderer.inc.

78  {
79  return $this->rteParams[$key];
80  }

◆ HTMLFieldRenderer()

HTMLFieldRenderer::HTMLFieldRenderer ( $parent)

Definition at line 63 of file html_field_renderer.inc.

64  {
65  $this->FieldRenderer($parent);
66  $this->hideStyleBar = $parent->HTMLEditorHideStyleBar;
67  $this->width = $parent->HTMLEditorDefaultWidth;
68  $this->height = $parent->HTMLEditorDefaultHeight;
69  $this->annotateBefore = true;
70  }
FieldRenderer($parent)
Constructor.

◆ overrideEditorButton()

HTMLFieldRenderer::overrideEditorButton (   $editor,
  $button 
)

Definition at line 234 of file html_field_renderer.inc.

235  {
236  echo "theEditors.$editor.overrideToolbarButton('{$button['name']}', {$button['handler']});\n";
237  }

◆ renderField()

HTMLFieldRenderer::renderField (   $field)

FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 239 of file html_field_renderer.inc.

240  {
241  if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field) || array_key_exists($field, $this->parent->hidden)) return "";
242  echo "<div id='{$field}_container'></div>";
243 
244  $this->_startField($field);
245 
246  echo "<textarea id='{$this->parent->id}_{$field}' name='{$field}' style='width: {$this->width}; height: {$this->height}' class='richtext'>".htmlSafe($this->parent->data->get($field))."</textarea>\n";
247 
248  $this->_endField($field);
249  }
_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.

◆ renderOnSubmitHandler()

HTMLFieldRenderer::renderOnSubmitHandler (   $field)

FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client.

See HTMLFieldRenderer for an example of how this is used.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 285 of file html_field_renderer.inc.

286  {
287  // JDG 3/2/2011., no js for readonly field
288  if ($this->parent->isReadOnly($field)) return "";
289 
290  $editor = $field."_editor";
291 
292  //echo "\ttheEditors.$editor.prepareForSubmit();\n";
293  }

◆ renderReadOnly()

HTMLFieldRenderer::renderReadOnly (   $field)

Definition at line 251 of file html_field_renderer.inc.

252  {
253  $this->_startField($field);
254 
255  echo $this->parent->data->get($field);
256 
257  $this->_endField($field);
258  }

◆ renderScript()

HTMLFieldRenderer::renderScript (   $field)

FieldRenderers can override this method to provide any Javascript that their control requires for an edit form.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 82 of file html_field_renderer.inc.

83  {
84  global $config;
85 
86  if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field)
87  || array_key_exists($field, $this->parent->hidden)) return "";
88 
89  global $tiny_mce_application_plugins;
90  global $tiny_mce_application_toolbar_section;
91  global $tiny_mce_application_context_menu_section;
92  global $tiny_mce_content_css;
93  global $tiny_mce_body_class;
94 
95  $plugins = "advlist,lists,code,visualblocks,table,charmap,paste,contextmenu,searchreplace,fullscreen";
96  if ($tiny_mce_application_plugins) $plugins .= ",".$tiny_mce_application_plugins;
97  $contextMenu = "cut copy paste pastetext searchreplace removeformat | {$tiny_mce_application_context_menu_section} inserttable cell row column deletetable";
98  $toolbar = "undo redo | cut copy paste pastetext searchreplace | styleselect | bold italic removeformat | bullist numlist outdent indent | table charmap | {$tiny_mce_application_toolbar_section} code visualblocks fullscreen";
99 
100  if (is_callable(HTMLFieldRenderer::$actionFilter))
101  {
102  $contextMenu = (HTMLFieldRenderer::$actionFilter)($contextMenu);
103  $toolbar = (HTMLFieldRenderer::$actionFilter)($toolbar);
104  }
105 
106  $https = Fakoli::checkSSL();
107 
108  $protocol = $https ? "https" : "http";
109 
110  $rootBlock = "";
111 
112  if ($this->rootBlock != "p")
113  {
114  if (!$this->rootBlock)
115  {
116  $this->setRTEParam("forced_root_block", false);
117  }
118  else
119  {
120  $this->setRTEParam("forced_root_block", $this->rootBlock);
121  }
122  }
123 
124  $baseURL = ($this->baseURL !== null) ? $this->baseURL : "{$protocol}://{$config['http_host']}";
125  if (isset($config["convertURLs"]))
126  {
127  $convertURLs = $config["convertURLs"] ? true : false;
128  }
129  else
130  {
131  $convertURLs = ($this->convertURLs) ? true : false;
132  }
133 
135  {
136 ?>
137 
138  <script type='text/javascript'>
139  tinymce.baseURL = "<?echo $protocol?>://<?echo $config['http_host']?>/fakoli/tinymce/";
140  </script>
141 <?
143  }
144 
145  $cssFiles = explode("\n", str_replace("\r", "", $tiny_mce_content_css));
146  if (count($cssFiles) > 0)
147  {
148  $this->setRTEParam("content_css", $cssFiles);
149  }
150  else
151  {
152  $this->setRTEParam("content_css", "");
153  }
154 
155  if (endsWith($this->width, "px"))
156  {
157  $w = substr($this->width, 0, -2);
158 
159  $this->setRTEParam("width", $w);
160  }
161 
162  if (endsWith($this->height, "px"))
163  {
164  $h = substr($this->height, 0, -2);
165  $this->setRTEParam("height", $h);
166  }
167 
168  $this->setRTEParam("valid_elements", '*[*]');
169  $this->setRTEParam("selector", "#{$this->parent->id}_{$field}");
170  $this->setRTEParam("plugins", $plugins);
171  $this->setRTEParam("contextmenu", $contextMenu);
172  $this->setRTEParam("skin", 'fakoli');
173  $this->setRTEParam("body_class", $tiny_mce_body_class);
174  $this->setRTEParam("relative_urls", false);
175  $this->setRTEParam("convert_urls", $convertURLs);
176  $this->setRTEParam("document_base_url", $baseURL);
177  $this->setRTEParam("menubar", false);
178  $this->setRTEParam("toolbar", $toolbar);
179  $this->setRTEParam("tools", 'inserttable');
180 
181  if ($this->customConfig) call_user_func($this->customConfig, $this);
182 ?>
183  <script type='text/javascript'>
184  tinymce.init(
185  {
186 <?
187  echo $this->renderParameters();
188 ?>
189  });
190  </script>
191 <?
192  }
setRTEParam($key, $value)
endsWith($text, $end)
Tests whether a string ends with the given sub-string.
Definition: functions.inc:1481

◆ renderSearchField()

HTMLFieldRenderer::renderSearchField (   $field,
  $mode = "equal" 
)

FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 260 of file html_field_renderer.inc.

261  {
262  // AJG - Override default colspan when rendering in a search form
263  $this->colspan = 1;
264 
265  if ($mode == "range")
266  {
267  $from = $this->parent->params->get($field, "from");
268  $to = $this->parent->params->get($field, "to");
269 
270  echo "<tr>\n";
271  $this->_printLabel($field);
272  echo "<td>From <input type='text' name='$field:from' value='{$from}' size='25'> to <input type='text' name='$field:to' value='{$to}' size='25'></td>\n";
273  echo "</tr>\n";
274  }
275  else
276  {
277  $value = $this->parent->params->get($field, $mode);
278  echo "<tr>\n";
279  $this->_printLabel($field);
280  echo "<td><input type='text' name='$field:$mode' value='{$value}' size='50'></td>\n";
281  echo "</tr>\n";
282  }
283  }
_printLabel($field, $colspan=1, $styles="", $annotation="")
Internal method to generate the HTML for the field label.

◆ setRTEParam()

HTMLFieldRenderer::setRTEParam (   $key,
  $value 
)

Definition at line 72 of file html_field_renderer.inc.

73  {
74  $this->rteParams[$key] = $value;
75  }

Member Data Documentation

◆ $_includedRTEScript

HTMLFieldRenderer::$_includedRTEScript = false
static

Definition at line 57 of file html_field_renderer.inc.

◆ $actionFilter

HTMLFieldRenderer::$actionFilter = null
static

Definition at line 59 of file html_field_renderer.inc.

◆ $baseURL

HTMLFieldRenderer::$baseURL = null

Definition at line 54 of file html_field_renderer.inc.

◆ $colspan

HTMLFieldRenderer::$colspan = 2

Definition at line 48 of file html_field_renderer.inc.

◆ $convertURLs

HTMLFieldRenderer::$convertURLs = false

Definition at line 55 of file html_field_renderer.inc.

◆ $featureButtons

HTMLFieldRenderer::$featureButtons

Definition at line 52 of file html_field_renderer.inc.

◆ $height

HTMLFieldRenderer::$height = "200px"

Definition at line 51 of file html_field_renderer.inc.

◆ $hideStyleBar

HTMLFieldRenderer::$hideStyleBar = false

Definition at line 49 of file html_field_renderer.inc.

◆ $rootBlock

HTMLFieldRenderer::$rootBlock = "p"

Definition at line 53 of file html_field_renderer.inc.

◆ $rteParams

HTMLFieldRenderer::$rteParams = array()

Definition at line 61 of file html_field_renderer.inc.

◆ $width

HTMLFieldRenderer::$width = "540px"

Definition at line 50 of file html_field_renderer.inc.


The documentation for this class was generated from the following file: