Framework  3.9
URLFieldRenderer Class Reference
+ Inheritance diagram for URLFieldRenderer:
+ Collaboration diagram for URLFieldRenderer:

Public Member Functions

 URLFieldRenderer (&$parent)
 
 addValidatorsToForm ($field, $required=false)
 This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer. More...
 
 renderReadOnly ($field)
 
- Public Member Functions inherited from StringFieldRenderer
 StringFieldRenderer (&$parent)
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderField ($field, $readonly=false)
 
 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...
 
 format ($field)
 
- 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...
 
 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...
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. 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...
 
 renderOnSubmitHandler ($field)
 FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client. 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

 $checkSyntax = false
 Set to true to force users to only enter valid URLs. More...
 
 $target = "_blank"
 
 $displayLength = 0
 
- Public Attributes inherited from StringFieldRenderer
 $size = 50
 
 $limit = 0
 optional - restricts users from entering character count over limit More...
 
 $autocomplete = true
 default is true. Set to false to disable autocompletion More...
 
 $onChange = ""
 optional (javascript) callback on data input change More...
 
 $disable = false
 alternative to readonly; field can be reenabled thru javascript More...
 
 $password = false
 Render the field as a password field (masked characters) More...
 
 $template = ""
 StringTypeRenderer template for readonly format (e.g., "prettify") More...
 
 $confirm = false
 Render a second field for the user to confirm their entry (for email addresses, etc) More...
 
 $width = ""
 Optionally specify a CSS width for the field. More...
 
 $CSSclass = ""
 Optionally specify a CSS class for the field. More...
 
 $numeric = false
 Restrict to numeric input. More...
 
 $onKeyPress = null
 Optional key press javascript callback. Note that if $limit is set, it will override this. More...
 
 $placeholder = null
 Placeholder text to display when field is empty. More...
 
- 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 $urlExpression = "/^(ht|f)tp(s?)\\:\\/\\/[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\,\\'\\/\\\\\\+&%\$#_=]*)?$/"
 

Detailed Description

Definition at line 40 of file url_field_renderer.inc.

Member Function Documentation

◆ addValidatorsToForm()

URLFieldRenderer::addValidatorsToForm (   $field,
  $required = false 
)

This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer.

Fields that need custom validation or a custom required validator should override this function.

Parameters
string$fieldthe field name
boolean$required- whether the field is required

Reimplemented from StringFieldRenderer.

Definition at line 53 of file url_field_renderer.inc.

54  {
55  $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
56 
57  if ($this->checkSyntax)
58  {
59  $this->parent->regexp($field, URLFieldRenderer::$urlExpression, "Please supply a valid URL.");
60  }
61 
62  if($required)
63  {
64  $this->parent->validator->add(new RequiredValidator($field, $label));
65  }
66  }
RequiredField Validator.
Definition: validation.inc:76

◆ renderReadOnly()

URLFieldRenderer::renderReadOnly (   $field)

Reimplemented from StringFieldRenderer.

Definition at line 68 of file url_field_renderer.inc.

69  {
70  $this->_startField($field);
71 
72  $value = $this->parent->data->get($field);
73  $escaped = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
74  $safe = htmlSafe($value);
75 
76  if ($this->displayLength > 0)
77  {
78  $safe = ellipsis($safe, $this->displayLength);
79  }
80 
81  if (!$this->parent->readOnlyForm)
82  {
83  echo "<input id='{$this->parent->id}_{$field}' type='hidden' name='$field' value='".$escaped."'/>";
84  }
85 
86  if (preg_match(URLFieldRenderer::$urlExpression, $value))
87  {
88 
89  echo "<a target='{$this->target}' href='$value'>$safe</a>";
90  }
91  else
92  {
93  echo htmlSafe($value);
94  }
95 
96  $this->_endField($field);
97  }
_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.
ellipsis($txt, $max, $wholeWord=false)
Truncate the supplied text at the given maximum length.
Definition: functions.inc:779

◆ URLFieldRenderer()

URLFieldRenderer::URLFieldRenderer ( $parent)

Definition at line 48 of file url_field_renderer.inc.

49  {
51  }

Member Data Documentation

◆ $checkSyntax

URLFieldRenderer::$checkSyntax = false

Set to true to force users to only enter valid URLs.

Definition at line 44 of file url_field_renderer.inc.

◆ $displayLength

URLFieldRenderer::$displayLength = 0

Definition at line 46 of file url_field_renderer.inc.

◆ $target

URLFieldRenderer::$target = "_blank"

Definition at line 45 of file url_field_renderer.inc.

◆ $urlExpression

URLFieldRenderer::$urlExpression = "/^(ht|f)tp(s?)\\:\\/\\/[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\,\\'\\/\\\\\\+&amp;%\$#_=]*)?$/"
static

Definition at line 42 of file url_field_renderer.inc.


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