Alpha Framework 3.0.0 API Documentation
  • Namespace
  • Class

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
      • Service
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • ArticleCommentView
  • ArticleView
  • DEnumView
  • PersonView
  • SequenceView
  • View
  • ViewState

Class View

The master rendering view class for the Alpha Framework.

Direct known subclasses

Alpha\View\ArticleCommentView, Alpha\View\ArticleView, Alpha\View\DEnumView, Alpha\View\PersonView, Alpha\View\SequenceView

Namespace: Alpha\View
Copyright:

Copyright (c) 2018, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License: The BSD License
Author: John Collins dev@alphaframework.org
Since: 1.0
Located at View/View.php

Methods summary

protected
# __construct( Alpha\Model\ActiveRecord $record, string $acceptHeader = null )

Constructor for the View. As this is protected, use the View::getInstance method from a public scope.

Constructor for the View. As this is protected, use the View::getInstance method from a public scope.

Parameters

$record
The main business object that this view is going to render
$acceptHeader
Optionally pass the HTTP Accept header to select the correct renderer provider.

Throws

Alpha\Exception\IllegalArguementException

Since

1.0
public static Alpha\View\View
# getInstance( Alpha\Model\ActiveRecord $record, boolean $returnParent = false, string $acceptHeader = null )

Static method which returns a View object or a custom child view for the Record specified if one exists.

Static method which returns a View object or a custom child view for the Record specified if one exists.

Parameters

$record
The main business object that this view is going to render
$returnParent
Flag to enforce the return of this object instead of a child (defaults to false)
$acceptHeader
Optionally pass the HTTP Accept header to select the correct renderer provider.

Returns

Alpha\View\View
Returns a View object, or a child view object if one exists for this record

Since

1.0
public
# setRecord( Alpha\Model\ActiveRecord $record )

Simple setter for the view business object.

Simple setter for the view business object.

Parameters

$record

Throws

Alpha\Exception\IllegalArguementException

Since

1.0
public Alpha\Model\ActiveRecord
# getRecord( )

Gets the Record attached to this view (if any).

Gets the Record attached to this view (if any).

Returns

Alpha\Model\ActiveRecord

Since

1.0
public string
# createView( array $fields = array() )

Renders the default create view.

Renders the default create view.

Parameters

$fields
Hash array of fields to pass to the template

Returns

string

Since

1.0
public string
# editView( array $fields = array() )

Renders a form to enable object editing.

Renders a form to enable object editing.

Parameters

$fields
Hash array of fields to pass to the template

Returns

string

Since

1.0
public string
# listView( array $fields = array() )

Renders the list view.

Renders the list view.

Parameters

$fields
Hash array of fields to pass to the template

Returns

string

Since

1.0
public string
# detailedView( array $fields = array() )

Renders a detailed view of the object (read-only).

Renders a detailed view of the object (read-only).

Parameters

$fields
Hash array of fields to pass to the template

Returns

string

Since

1.0
public string
# adminView( array $fields = array() )

Renders the admin view for the business object screen.

Renders the admin view for the business object screen.

Parameters

$fields
Hash array of fields to pass to the template

Returns

string

Since

1.0
public static string
# displayPageHead( Alpha\Controller\Controller $controller )

Method to render the page header content.

Method to render the page header content.

Parameters

$controller

Returns

string

Throws

Alpha\Exception\IllegalArguementException

Since

1.0
public static string
# displayPageFoot( Alpha\Controller\Controller $controller )

Method to render the page footer content.

Method to render the page footer content.

Parameters

$controller

Returns

string

Since

1.0
public static string
# displayPageLinks( Alpha\Controller\Controller $controller )

Method for rendering the pagination links.

Method for rendering the pagination links.

Parameters

$controller

Returns

string

Since

3.0
public static string
# displayUpdateMessage( string $message )

Renders the content for an update (e.g. successful save) message.

Renders the content for an update (e.g. successful save) message.

Parameters

$message

Returns

string

Since

1.0
public static string
# displayErrorMessage( string $message )

Renders the content for an error (e.g. save failed) message.

Renders the content for an error (e.g. save failed) message.

Parameters

$message

Returns

string

Since

1.0
public static string
# renderErrorPage( string $code, string $message )

Renders an error page with the supplied error code (typlically a HTTP code) and a message.

Renders an error page with the supplied error code (typlically a HTTP code) and a message.

Parameters

$code
$message

Returns

string

Since

1.0
public static string
# renderDeleteForm( string $URI )

Method to render a hidden HTML form for posting the ID of an object to be deleted.

Method to render a hidden HTML form for posting the ID of an object to be deleted.

Parameters

$URI
The URI that the form will point to

Returns

string

Since

1.0
public static string
# renderSecurityFields( )

Method to render a HTML form with two hidden, hashed (MD5) form fields to be used as a check to ensure that a post to the controller is being sent from the same server as hosting it.

Method to render a HTML form with two hidden, hashed (MD5) form fields to be used as a check to ensure that a post to the controller is being sent from the same server as hosting it.

Returns

string

Since

1.0
public string
# renderIntegerField( string $name, string $label, string $mode, string $value = '' )

Method to render the default Integer HTML.

Method to render the default Integer HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderDoubleField( string $name, string $label, string $mode, string $value = '' )

Method to render the default Double HTML.

Method to render the default Double HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderBooleanField( string $name, string $label, string $mode, string $value = '' )

Method to render the default Boolean HTML.

Method to render the default Boolean HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderEnumField( string $name, string $label, string $mode, array $options, string $value = '' )

Method to render the default Enum HTML.

Method to render the default Enum HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$options
The Enum options
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderDEnumField( string $name, string $label, string $mode, array $options, string $value = '' )

Method to render the default DEnum HTML.

Method to render the default DEnum HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$options
The DEnum options
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderDefaultField( string $name, string $label, string $mode, string $value = '' )

Method to render the default field HTML when type is not known.

Method to render the default field HTML when type is not known.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderTextField( string $name, string $label, string $mode, string $value = '' )

render the default Text HTML.

render the default Text HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)

Returns

string

Since

1.0
public string
# renderRelationField( string $name, string $label, string $mode, string $value = '', boolean $expanded = false, boolean $buttons = true )

render the default Relation HTML.

render the default Relation HTML.

Parameters

$name
The field name
$label
The label to apply to the field
$mode
The field mode (create/edit/view)
$value
The field value (optional)
$expanded
Render the related fields in expanded format or not (optional)
$buttons
Render buttons for expanding/contacting the related fields (optional)

Returns

string

Since

1.0
public string
# renderAllFields( string $mode, array $filterFields = array(), array $readOnlyFields = array() )

Renders all fields for the current Record in edit/create/view mode.

Renders all fields for the current Record in edit/create/view mode.

Parameters

$mode
(view|edit|create)
$filterFields
Optional list of field names to exclude from rendering
$readOnlyFields
Optional list of fields to render in a readonly fashion when rendering in create or edit mode

Returns

string

Since

1.0
public static string
# loadTemplate( Alpha\Model\ActiveRecord $record, string $mode, array $fields = array() )

Loads a template for the Record specified if one exists. Lower level custom templates take precedence.

Loads a template for the Record specified if one exists. Lower level custom templates take precedence.

Parameters

$record
$mode
$fields

Returns

string

Throws

Alpha\Exception\IllegalArguementException

Since

1.0
public static string
# loadTemplateFragment( string $type, string $fileName, array $fields = array() )

Loads a template fragment from the Renderer/[type]/Fragments/[filename.ext] location.

Loads a template fragment from the Renderer/[type]/Fragments/[filename.ext] location.

Parameters

$type
Currently only html supported, later json and xml.
$fileName
The name of the fragment file
$fields
A hash array of field values to pass to the template fragment.

Returns

string

Throws

Alpha\Exception\IllegalArguementException

Since

1.2
public static
# setProvider( string $ProviderClassName, string $acceptHeader = null )

Enables you to set an explicit type of RendererProviderInterface implementation to use for rendering the records attached to this view.

Enables you to set an explicit type of RendererProviderInterface implementation to use for rendering the records attached to this view.

Parameters

$ProviderClassName
The name of the RendererProviderInterface implementation to use in this view object
$acceptHeader
Optional pass the HTTP Accept header to select the correct renderer provider.

Throws

Alpha\Exception\IllegalArguementException

Since

1.2
public static Alpha\View\Renderer\RendererProviderInterface
# getProvider( )

Get the current view renderer provider.

Get the current view renderer provider.

Returns

Alpha\View\Renderer\RendererProviderInterface

Since

2.0

Properties summary

protected Alpha\Model\ActiveRecord $record

The business object that will be rendered.

The business object that will be rendered.

Since

1.0
#
Alpha Framework 3.0.0 API Documentation API documentation generated by ApiGen