Renderer
[ class tree: Renderer ] [ index: Renderer ] [ all elements ]

Class: Formagic_Renderer_Html

Source Location: /Renderer/Html.php

Class Overview


Returns rendered HTML form. Tables are used to place form elements.


Author(s):

  • Florian Sonnenburg

Version:

  • $Id: Html.php 128 2011-05-22 19:39:37Z meweasle $

Copyright:

  • Copyright (c) 2007-2011 Florian Sonnenburg

Implements interfaces:

Variables

Methods


Child classes:

Formagic_Renderer_Xhtml
Formagic Renderer Xhtml

Class Details

[line 36]
Returns rendered HTML form. Tables are used to place form elements.



Tags:

author:  Florian Sonnenburg
version:  $Id: Html.php 128 2011-05-22 19:39:37Z meweasle $
copyright:  Copyright (c) 2007-2011 Florian Sonnenburg


[ Top ]


Class Variables

$_containerLabelTemplate = array('' => '')

[line 81]

Container label template array



Tags:

access:  protected

Type:   array


[ Top ]

$_containerRowTemplate = array('' => 
        '
        <tr>
            <td colspan="2">
                <!-- Container -->
                %CONTAINER%</td>
        </tr>'
    )

[line 68]

Template for rows containing containers



Tags:

access:  protected

Type:   array


[ Top ]

$_containerWrapperTemplate = array('' => 
    '<table border="0" cellpadding="0" cellspacing="0"%ATTRIBUTES%>
        <!-- form rows -->%ROWS%
    </table>'
    )

[line 58]

Container wrapping template array



Tags:

access:  protected

Type:   array


[ Top ]

$_errorClass =  'formagicError'

[line 120]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_formWrapperTemplate =  
'
<!-- formagic HTML renderer start
============================= -->
<form action="%ACTION%" method="%METHOD%"%ATTRIBUTES%>
    %HIDDENS%
    %CONTAINER%
</form>
<!-- formagic HTML renderer end
=========================== -->
'

[line 42]

Form wrapping template array



Tags:

access:  protected

Type:   array


[ Top ]

$_hiddenString =  ''

[line 134]

Hidden inputs string



Tags:

access:  protected

Type:   string


[ Top ]

$_itemErrorTemplate = array('' => 
        '<li>%ERRORMESSAGE%</li>'
    )

[line 116]

Array of templates for displaying the item error string (list elements)



Tags:

access:  protected

Type:   array


[ Top ]

$_itemErrorWrapperTemplate = array('' =>
        '<!-- Error --><ul%ERRORCLASS%>%ERRORS%</ul>'
    )

[line 108]

Array of templates for item's error wrapper (list open tag)



Tags:

access:  protected

Type:   array


[ Top ]

$_itemLabelTemplate = array('' => 
        '<!-- Label --><label for="%ID%"%ERRORCLASS%>%LABEL%%MANDATORYMARKER%</label>'
    )

[line 100]

Template for displaying the item label array



Tags:

access:  protected

Type:   array


[ Top ]

$_itemRowTemplate = array('' => 
        '
        <tr>
            <td>%LABEL%</td>
            <td>%ERROR%
                <!-- Input -->%INPUT%</td>
        </tr>'
    )

[line 87]

Template for rows containing normal items array



Tags:

access:  protected

Type:   array


[ Top ]

$_mandatoryMarkerTemplate = array('' => 
        ' <span class="mandatory">*</span>'
    )

[line 126]

HTML string for mandatory fields array



Tags:

access:  protected

Type:   array


[ Top ]

$_translator =

[line 140]

Translator object



Tags:

access:  protected



[ Top ]



Class Methods


constructor __construct [line 147]

Formagic_Renderer_Html __construct( [ $translator = null])

Sets the translator object for this renderer instance



Tags:

access:  public


Overridden in child classes as:

Formagic_Renderer_Xhtml::__construct()
Constructor

Parameters:

Formagic_Translator   $translator   Translator instance

[ Top ]

method getContainerLabelTemplate [line 270]

string getContainerLabelTemplate( [string|Formagic_Item_Container $container = ''])

Returns container label template (empty by default).



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Container   $container   Optional. Returns a template defined for one specific container.

[ Top ]

method getContainerRowTemplate [line 206]

string getContainerRowTemplate( [string|Foramgic_Item_Container $container = ''])

Returns the template for rows that hold sub-containers.



Tags:

return:  Template string
access:  public


Parameters:

string|Foramgic_Item_Container   $container   Optional. Returns a template defined for one specific container.

[ Top ]

method getContainerWrapperTemplate [line 239]

string getContainerWrapperTemplate( [string $container = ''])

Returns wrapper template for containers (HTML table tag by default)



Tags:

return:  Template string
access:  public


Parameters:

string   $container   Optional. Returns a template defined for one specific item with name $name.

[ Top ]

method getFormWrapperTemplate [line 299]

string getFormWrapperTemplate( )

Returns form wrapper tag.



Tags:

return:  Template string
access:  public


[ Top ]

method getItemErrorTemplate [line 393]

string getItemErrorTemplate( [string|Formagic_Item_Abstract $item = ''])

Returns single error message template



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Abstract   $item   Optional. Returns a template defined for one specific item.

[ Top ]

method getItemErrorWrapperTemplate [line 422]

string getItemErrorWrapperTemplate( [string|Formagic_Item_Abstract $item = ''])

Returns error wrapper template for item errors.



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Abstract   $item   Optional. Returns a template defined for one specific item.

[ Top ]

method getItemLabelTemplate [line 364]

string getItemLabelTemplate( [string|Formagic_Item_Abstract $item = ''])

Returns label template for an item.



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Abstract   $item   Optional. Returns a template defined for one specific item.

[ Top ]

method getItemRowTemplate [line 332]

string getItemRowTemplate( [string|Formagic_Item_Abstract $item = ''])

Returns item row template.



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Abstract   $item   Optional. Returns a template defined for one specific item.

[ Top ]

method getMandatoryMarkerTemplate [line 448]

string getMandatoryMarkerTemplate( [string|Formagic_Item_Abstract $item = ''])

Returns marker string for items marked as mandatory.



Tags:

return:  Template string
access:  public


Parameters:

string|Formagic_Item_Abstract   $item   Optional. Returns a template defined for one specific item.

[ Top ]

method getTranslator [line 160]

Formagic_Translator getTranslator( )

Returns current translator instance.



Tags:

return:  Translator object
access:  public


[ Top ]

method render [line 459]

string render( $form)

Returns form HTML string



Tags:

return:  The rendered HTML string
access:  public



Implementation of:
Formagic_Renderer_Interface::render()
Renders form item information into a specific data format.

Parameters:

Formagic   $form   Formagic object to be rendered.

[ Top ]

method setContainerLabelTemplate [line 257]

Formagic_Renderer_Html setContainerLabelTemplate( string $template, [string|Formagic_Item_Container $container = ''])

Sets container label template.

Available placeholders:

  • %LABEL%: Label string




Tags:



Parameters:

string   $template   Template string
string|Formagic_Item_Container   $container   Optional. Defines this template only for a specific container (name or container object).

[ Top ]

method setContainerRowTemplate [line 193]

Formagic_Renderer_Html setContainerRowTemplate( string $template, [string|Formagic_Item_Container $container = ''])

Sets new template for rows that hold sub-containers.

Supported placeholders:

  • %CONTAINER%: HTML for the subcontainer, including it's wrapper




Tags:



Parameters:

string   $template   Template string
string|Formagic_Item_Container   $container   Optional. Defines this template only for a specific container.

[ Top ]

method setContainerWrapperTemplate [line 226]

Formagic_Renderer_Html setContainerWrapperTemplate( type $template, [string|Formagic_Item_Container $container = ''])

Sets wrapper template for containers.

Available placeholders:

  • %ROWS%: Rendered rows as HTML, including row wrapper
  • %ATTRIBUTES%: Assembled attributes string as HTML
  • %LABEL%: Rendered container label as HTML




Tags:



Parameters:

type   $template   Template string
string|Formagic_Item_Container   $container   Optional. Defines this template only for a specific container.

[ Top ]

method setErrorClass [line 174]

Formagic_Renderer_Html setErrorClass( string $errorClass)

Sets error CSS class.

This css class is per default added to the label and error list tag of items that did not pass validation.




Tags:

return:  Fluent interface
access:  public


Parameters:

string   $errorClass   New error class

[ Top ]

method setFormWrapperTemplate [line 288]

Formagic_Renderer_Html setFormWrapperTemplate( string $template)

Sets form wrapper template (opening/closing form tag by default).

Available placeholders:

  • %ACTION%: Form action string
  • %METHOD%: Form method string
  • %ATTRIBUTES%: Assembled tag attributes string
  • %HIDDENS%: Rendered hidden inputs
  • %CONTAINER%: Rendered HTML of item holder container




Tags:

return:  Fluent interface
access:  public


Parameters:

string   $template   Template string

[ Top ]

method setItemErrorTemplate [line 380]

Formagic_Renderer_Html setItemErrorTemplate( string $template, [string|Formagic_Item_Abstract $item = ''])

Sets a new template for a single error message (HTML LI tag by default)

Supported placeholders:

  • %ERRORMESSAGE%: Message string returned by violated rule




Tags:

return:  Fluent interface
access:  public


Parameters:

string   $template   Template string
string|Formagic_Item_Abstract   $item   Optional. Defines this template only for a specific item (name or item object).

[ Top ]

method setItemErrorWrapperTemplate [line 409]

Formagic_Renderer_Html setItemErrorWrapperTemplate( string $template, [string|Formagic_Item_Abstract $item = ''])

Sets error wrapper template (opening and closing list tags by default).

Supported placeholders:

  • %ERRORS%: Rendered list of item errors




Tags:

return:  Fluent interface
access:  public


Parameters:

string   $template   Template string
string|Formagic_Item_Abstract   $item   Optional. Defines this template only for a specific item (name or item object).

[ Top ]

method setItemLabelTemplate [line 351]

Formagic_Renderer_Html setItemLabelTemplate( string $template, [string|Formagic_Item_Abstract $item = ''])

Sets label template for a single item (label tag by default).

Available placeholders:

  • %LABEL%: Label string defined for item
  • %ID%: Value of Item's HTML ID attribute
  • %MANDATORYMARKER%: Marker for items with mandatory rule




Tags:

return:  Fluent interface
see:  Formagic_Renderer_Html::setItemRowTemplate()
access:  public


Parameters:

string   $template   Template string
string|Formagic_Item_Abstract   $item   Optional. Defines this template only for a specific item (name or item object).

[ Top ]

method setItemRowTemplate [line 319]

Formagic_Renderer_Html setItemRowTemplate( string $template, [string|Formagic_Item_Abstract $item = ''])

Sets template for rows containing input items (tr/td tags by default).

  • %LABEL%: Item label string
  • %ERROR%: Assembled error list (HTML)
  • %ERRORCLASS%: CSS class attribute with error class (eg. ' class="formagicError"')
  • %INPUT%: Input HTML




Tags:

return:  Fluent interface
see:  Formagic_Renderer_Html::setItemLabelTemplate()
see:  Formagic_Renderer_Html::setItemErrorTemplate()
access:  public


Parameters:

string   $template   Template string
string|Formagic_Item_Abstract   $item   Optional. Defines this template only for a specific item (name or item object).

[ Top ]

method setMandatoryMarkerTemplate [line 435]

Formagic_Renderer_Html setMandatoryMarkerTemplate( type $template, [type $item = ''])

Sets marker string for items that are marked mandatory (asterisk by default).



Tags:

return:  Fluent interface
access:  public


Parameters:

type   $template   Template string
type   $item   Optional. Item this template is to be defined for.

[ Top ]

method _addHiddenItem [line 497]

void _addHiddenItem( $item)

Adds hidden fields to form HTML string.



Tags:

access:  protected


Parameters:

Formagic_Item_Hidden   $item   Hidden item to be rendered.

[ Top ]

method _getContainerLabel [line 693]

string _getContainerLabel( $container)

Renders a container label into the container label template.

Returns empty string if no container label is defined.




Tags:

return:  Container label and template string
access:  protected


Parameters:

Formagic_Item_Container   $container   Container item

[ Top ]

method _getErrorProperties [line 624]

array _getErrorProperties( $item)

Returns the rendered error list and HTML class attribute.

Returns empty array if item validated ok.




Tags:

return:  Error list and class attribute. Example:
  1.  array(
  2.       '<ul>
  3.           <li>Please enter a value.</li>
  4.        </ul>',
  5.       ' class="formagicError"')
access:  protected


Parameters:

Formagic_Item_Abstract   $item  

[ Top ]

method _getItemLabel [line 667]

string _getItemLabel( $item)

Returns rendered item label and template.

Returns a non-breakin-space HTML entity if no item label is provided.




Tags:

return:  Item label and template
access:  protected


Parameters:

Formagic_Item_Abstract   $item   Input item

[ Top ]

method _getTemplate [line 593]

string _getTemplate( type $templateArray, Formagic_Item_Abstract $item)

Returns a template for a specific item from a template array.



Tags:

return:  Template string
access:  private


Parameters:

type   $templateArray   Pool of templates to choose from.
Formagic_Item_Abstract   $item  

[ Top ]

method _renderContainer [line 513]

string _renderContainer( $container)

Returns HTML for all items of a container (recursively)



Tags:

return:  HTML string
access:  protected


Parameters:

object   $container   Container to be rendererd

[ Top ]

method _setTemplate [line 575]

void _setTemplate( &$templateArray, string $template, string|Formagic_Item_Abstract $item, array $templateArray)

Sets a template string for an item to a template pool.



Tags:

access:  protected


Parameters:

array   $templateArray   Template pool new template is to be added to
string   $template   New template string
string|Formagic_Item_Abstract   $item  
   &$templateArray  

[ Top ]


Documentation generated on Sun, 22 May 2011 22:40:13 +0200 by phpDocumentor 1.4.3