Alpha Framework 4.0.0 API Documentation

ArticleView extends View
in package

The rendering class for the Article class.

Tags
since
1.0
author

John Collins dev@alphaframework.org

license

http://www.opensource.org/licenses/bsd-license.php The BSD License

copyright

Copyright (c) 2021, 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.

Table of Contents

Properties

$record  : ActiveRecord
The business object that will be rendered.
$logger  : Logger
Trace logger.
$provider  : RendererProviderInterface
The rendering provider that will be used to render the active record.

Methods

adminView()  : string
Renders the admin view for the Article, with create button pointed to the ArticleController.
createView()  : string
Renders the default create view.
detailedView()  : string
Renders the detail view for the Article, with edit button pointed to the ArticleController.
displayErrorMessage()  : string
Renders the content for an error (e.g. save failed) message.
displayPageFoot()  : string
Method to render the page footer content.
displayPageHead()  : string
Method to render the page header content.
displayPageLinks()  : string
Method for rendering the pagination links.
displayUpdateMessage()  : string
Renders the content for an update (e.g. successful save) message.
editView()  : string
Renders a form to enable article editing with attachments options.
getInstance()  : mixed
Static method which returns a View object or a custom child view for the Record specified if one exists.
getProvider()  : RendererProviderInterface
Get the current view renderer provider.
getRecord()  : ActiveRecord
Gets the Record attached to this view (if any).
listView()  : string
Renders the list view (adds the dateAdded field for the list template).
loadTemplate()  : string
Loads a template for the Record specified if one exists. Lower level custom templates take precedence.
loadTemplateFragment()  : string
Loads a template fragment from the Renderer/[type]/Fragments/[filename.ext] location.
markdownView()  : string
Method to generate the markdown HTML render of the article content.
renderAllFields()  : string
Renders all fields for the current Record in edit/create/view mode.
renderBooleanField()  : string
Method to render the default Boolean HTML.
renderDefaultField()  : string
Method to render the default field HTML when type is not known.
renderDeleteForm()  : string
Method to render a hidden HTML form for posting the ID of an object to be deleted.
renderDEnumField()  : string
Method to render the default DEnum HTML.
renderDoubleField()  : string
Method to render the default Double HTML.
renderEnumField()  : string
Method to render the default Enum HTML.
renderErrorPage()  : string
Renders an error page with the supplied error code (typlically a HTTP code) and a message.
renderIntegerField()  : string
Method to render the default Integer HTML.
renderRelationField()  : string
render the default Relation HTML.
renderSecurityFields()  : string
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.
renderTextField()  : string
render the default Text HTML.
setProvider()  : void
Enables you to set an explicit type of RendererProviderInterface implementation to use for rendering the records attached to this view.
setRecord()  : void
Simple setter for the view business object.
__construct()  : mixed
Constructor for the View. As this is protected, use the View::getInstance method from a public scope.
afterCreateView()  : string
Adds a note to the create article screen.
renderFileUploadSection()  : string
Renders the HTML for the file upload section.

Properties

$record

The business object that will be rendered.

protected ActiveRecord $record
Tags
since
1.0

$logger

Trace logger.

private static Logger $logger = null
Tags
since
1.0

Methods

adminView()

Renders the admin view for the Article, with create button pointed to the ArticleController.

public adminView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

Hash array of fields to pass to the template

Tags
since
2.0.1
Return values
string

createView()

Renders the default create view.

public createView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

Hash array of fields to pass to the template

Tags
since
1.0
Return values
string

detailedView()

Renders the detail view for the Article, with edit button pointed to the ArticleController.

public detailedView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

Hash array of fields to pass to the template

Tags
since
2.0.1
Return values
string

displayErrorMessage()

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

public static displayErrorMessage(string $message) : string
Parameters
$message : string
Tags
since
1.0
Return values
string

displayPageFoot()

Method to render the page footer content.

public static displayPageFoot(Controller $controller) : string
Parameters
$controller : Controller
Tags
since
1.0
Return values
string

Method for rendering the pagination links.

public static displayPageLinks(Controller $controller) : string
Parameters
$controller : Controller
Tags
since
3.0
Return values
string

displayUpdateMessage()

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

public static displayUpdateMessage(string $message) : string
Parameters
$message : string
Tags
since
1.0
Return values
string

editView()

Renders a form to enable article editing with attachments options.

public editView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

hash array of HTML fields to pass to the template

Tags
since
1.0
Return values
string

getInstance()

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

public static getInstance(ActiveRecord $record[, bool $returnParent = false ][, string $acceptHeader = null ]) : mixed
Parameters
$record : ActiveRecord

The main business object that this view is going to render

$returnParent : bool = false

Flag to enforce the return of this object instead of a child (defaults to false)

$acceptHeader : string = null

Optionally pass the HTTP Accept header to select the correct renderer provider.

Tags
since
1.0

listView()

Renders the list view (adds the dateAdded field for the list template).

public listView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

hash array of HTML fields to pass to the template

Tags
since
1.0
Return values
string

loadTemplate()

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

public static loadTemplate(ActiveRecord $record, string $mode[, array<string|int, mixed> $fields = array() ]) : string
Parameters
$record : ActiveRecord
$mode : string
$fields : array<string|int, mixed> = array()
Tags
since
1.0
throws
IllegalArguementException
Return values
string

loadTemplateFragment()

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

public static loadTemplateFragment(string $type, string $fileName[, array<string|int, mixed> $fields = array() ]) : string
Parameters
$type : string

Currently only html supported, later json and xml.

$fileName : string

The name of the fragment file

$fields : array<string|int, mixed> = array()

A hash array of field values to pass to the template fragment.

Tags
since
1.2
throws
IllegalArguementException
Return values
string

markdownView()

Method to generate the markdown HTML render of the article content.

public markdownView([array<string|int, mixed> $fields = array() ]) : string
Parameters
$fields : array<string|int, mixed> = array()

Hash array of HTML fields to pass to the template.

Tags
since
1.0
Return values
string

renderAllFields()

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

public renderAllFields(string $mode[, array<string|int, mixed> $filterFields = array() ][, array<string|int, mixed> $readOnlyFields = array() ]) : string
Parameters
$mode : string

(view|edit|create)

$filterFields : array<string|int, mixed> = array()

Optional list of field names to exclude from rendering

$readOnlyFields : array<string|int, mixed> = array()

Optional list of fields to render in a readonly fashion when rendering in create or edit mode

Tags
since
1.0
Return values
string

renderBooleanField()

Method to render the default Boolean HTML.

public renderBooleanField(string $name, string $label, string $mode[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderDefaultField()

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

public renderDefaultField(string $name, string $label, string $mode[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderDeleteForm()

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

public static renderDeleteForm(string $URI) : string
Parameters
$URI : string

The URI that the form will point to

Tags
since
1.0
Return values
string

renderDEnumField()

Method to render the default DEnum HTML.

public renderDEnumField(string $name, string $label, string $mode, array<string|int, mixed> $options[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$options : array<string|int, mixed>

The DEnum options

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderDoubleField()

Method to render the default Double HTML.

public renderDoubleField(string $name, string $label, string $mode[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderEnumField()

Method to render the default Enum HTML.

public renderEnumField(string $name, string $label, string $mode, array<string|int, mixed> $options[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$options : array<string|int, mixed>

The Enum options

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderErrorPage()

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

public static renderErrorPage(string $code, string $message) : string
Parameters
$code : string
$message : string
Tags
since
1.0
Return values
string

renderIntegerField()

Method to render the default Integer HTML.

public renderIntegerField(string $name, string $label, string $mode[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

renderRelationField()

render the default Relation HTML.

public renderRelationField(string $name, string $label, string $mode[, string $value = '' ][, bool $expanded = false ][, bool $buttons = true ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

$expanded : bool = false

Render the related fields in expanded format or not (optional)

$buttons : bool = true

Render buttons for expanding/contacting the related fields (optional)

Tags
since
1.0
Return values
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.

public static renderSecurityFields() : string
Tags
since
1.0
Return values
string

renderTextField()

render the default Text HTML.

public renderTextField(string $name, string $label, string $mode[, string $value = '' ]) : string
Parameters
$name : string

The field name

$label : string

The label to apply to the field

$mode : string

The field mode (create/edit/view)

$value : string = ''

The field value (optional)

Tags
since
1.0
Return values
string

setProvider()

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

public static setProvider(string $ProviderClassName[, string $acceptHeader = null ]) : void
Parameters
$ProviderClassName : string

The name of the RendererProviderInterface implementation to use in this view object

$acceptHeader : string = null

Optional pass the HTTP Accept header to select the correct renderer provider.

Tags
since
1.2
throws
IllegalArguementException

__construct()

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

protected __construct(ActiveRecord $record[, string $acceptHeader = null ]) : mixed
Parameters
$record : ActiveRecord

The main business object that this view is going to render

$acceptHeader : string = null

Optionally pass the HTTP Accept header to select the correct renderer provider.

Tags
throws
IllegalArguementException
since
1.0

afterCreateView()

Adds a note to the create article screen.

protected afterCreateView() : string
Tags
since
1.0
Return values
string

renderFileUploadSection()

Renders the HTML for the file upload section.

protected renderFileUploadSection() : string
Tags
since
1.0
Return values
string

        
On this page

Search results