PVHtml

Extends \PVStaticObject

PVHTML is a class designed for generating HTML elements to display to the user.

The class takes in basic HTML forms with options. The functionality can be used with dynamic form generation tools.

Example:

//Create array of links
$links = array('Google', 'http://www.google.com', 'Facebook', 'http://www.facebook.com');

$html = '';
$li = '';

foreach($links as $key => $value):
     $li .= PVHtml::li(PVHtml::ahref($key, $value));
endforeach;

$html = PVHtml::ul($li);

$html = PVHtml::div($html, array('class' => 'container'));
echo $html;

//The following will be printed
<div class="container">
     <ul>
        <li><a href="http://www.google.com">Google</a><li>
        <li><a href="http://www.facebook.com">Facebook</a><li>
     </ul>
</div>
package

template

todo

Add more HTML5 form elements

Methods

Uses the magic method __call and executes a closure/anonymous function that has been added to the classes $_methods using the addMethod() method.

__callStatic(string $method, mixed $args = array()) : mixed
inherited static
access

public

Arguments

$method

string

The key/name assigned to the method when added

$args

mixed

Arguements to pass to the annoymous function. The function is called using call_user_func_array.

Response

mixed

$value The value returned is the value the stored function returns

Apply a fitler if filter is set.

_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the filter is in

$method

string

The method the filter is in

$data

mixed

The data that is being passed to the filter

$options

array

options to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null

Response

mixed

$data The data the function returns

Calls an adapter for this class. The easiest way of implementing an adapter is by placing the adapter at the top of the function that it is being called in. An infinite amout of parameters can be passed to the adapter BUT the parameters should be the same as the parents.

_callAdapter(string $class, string $method) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the adapter is in

$method

string

THe name of the method the class is being called from.

Response

mixed

$value A value that the adapter returns

Checks if an adapter is set for the function.

_hasAdapter( $class, string $method) : \boolea
inherited static
access

protected

Arguments

$class

$method

string

The associated method

Response

\boolea

$hasAdapter Returns true if it has an adapter or false if it doesn not

Checks if a filter has been set.

_hasFilter(string $class, string $method) 
inherited static

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Calls a methods that is an instance of an class. This method is generally faster than using user_call_func_array.

_invokeMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Calls a methods that is a static method of a class. This method is generally faster than using user_call_func_array.

_invokeStaticMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Write out the contents of adapters used to a log

_logAdapter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the adapter

Write out the contents of a filter used to a log

_logFilter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the filter

Write out the contents of an observer to a log.

_logObserver(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the observer

Calls any functions that have been added to the observer if the event is present in the observers array.

_notify(string $event) : void
inherited static
access

protected

Arguments

$event

string

The name of the even that occured that will trigger notifies

Breaks down the data to be logged from an adapter, filter or observer.

_prepareLogData(array $data) : string
inherited static
access

private

Arguments

$data

array

Response

string

$message JSON encode message of information about the data

Adapters allows a method to be completely overwritten by calling a different class with the same method name. Adapters can also be used with closures. The adapter uses a strategy/adapter design pattern.

addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
inherited static
access

public

todo

add ability to adapt singleton class

Arguments

$trigger_class

string

The class that contains the function the adapter will respond too

$trigger_method

string

The method called that will have the adapter to be called.

$call_class

string

The new class to be called that has the same method name

$options

array

An array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure

Will add an adapter for every method in the trigger_class to another class. The method will only be adapted to another class if the method in the trigger class has an adapter. This functionality can be very similiar to DI.

addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
inherited static
access

public

todo

Add ability to use singleton classes

Arguments

$trigger_class

mixed

This can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.

$call_class

string

The call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.

$options

array

Options that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class

Adds a filter to the class. Filters are for modifying a value within a class and should not interpet the normal flow within the method.

addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
inherited static
access

public

Arguments

$class

string

The name of the class the filter is going in

$method

string

The name of the method the filter is in

$filter_class

string

The class that the filter resides in.

$filter_method

string

The method in the class that the parameters will be passed too.

$options

array

Options that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure

Adds a closure/anonymous function to the object that can be called.

addMethod(string $method, \function $closure) : void
inherited static
access

public

Arguments

$method

string

The key/value that will be used to call the function

$closure

\function

The anonymous function/closure to be added

Adds an observer to the class. Observer events can fired in any method to trigger a response.

addObserver(string $event, string $class, string $method, array $options = array()) : void
inherited static
access

public

Arguments

$event

string

The name of the event that will cause a certain class and method to fire

$class

string

The name of the class that contains the function that will be fired for this event

$method

string

The name of the method that will be fired when the event occurs

$options

array

Options to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure

Creates a address tag ,<address></address>, to display.

address(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the address tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$address The address element that was generated

Adds a data to the public collection, index will be assigned automatically. Primarily used for adding launch quanties of data to the collection

addToCollection(mixed $data) : void
inherited static
access

public

Arguments

$data

mixed

Any data type( Object, Array, int, etc) to add to the public data collection

Adds data to the public collection. The data is assigned a key/index. If the key/index is already set, new information will override the old one.

addToCollectionWithName(string $name, mixed $data) : void
inherited static
access

public

todo

check the relevance of get and set

Arguments

$name

string

The key/index to assign the value to

$data

mixed

Data to be stored in the collection

Creates a article tag ,<article></article>, to display.

article(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the article tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$article The article element that was generated

Creates a aside tag ,<aside></aside>, to display.

aside(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the aside tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$aside The aside element that was generated

Displays an audio clip using the HTML5 audio component. For best usage, pass through a wav, mp3 and oga file.

audio(string $src = '', array $options = array()) : string
static
access

public

Arguments

$src

string

The location of the audio file to be played. Will be rendered by self::audioContentURL() function

$options

array

Options that can be used to define attributes in the elements tag -'controls' string: The controls attributes. -'audio' 'string: THe audio attribute -'autoplay' string: Automatically play the video -'loop' string : Loop to play automatically -'poster' string : Poster attribute -'preload' string: Preload attribute -'wav_file' string: Location of the wav file -'mp3_file' string: The location of the mp3 file -'oga_file' string: Location of the oga file

Response

string

$audio Returns the audio tag

Not sure if the function is needed or still make sense

audioContentURL(string $url, boolean $append_location = false) : string
static
todo

check if function is still valid

Arguments

$url

string

url of the file

$append_location

boolean

Appends the PV_AUDIo tage

Response

string

Creates a canvas tag ,<canvas></canvas>, to display.

canvas(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the canvas tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$aside The canvas element that was generated

Remove all the filters from a class.

clearFilters(string $class, string $method) : void
inherited static
access

public

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Removes all the observers assoicated with an event.

clearObservers(string $event) : void
inherited static
access

public

Arguments

$event

string

The event to remove all the observers from

Creates a details tag ,<details></details>, to display.

details(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the details tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$details The details element that was generated

Creates a div to display.

div(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information thatwill be displayed inside the div

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$div The div element that was generated

Creates an html tag.

generateHtmlTag(string $tag, string $data, array $options = array()) 
static

Arguments

$tag

string

The name of the tag, such as div, main, etc.

$data

string

The content that will go instead the element

$options

array

Options than can be used to further distinguish the element. The options are the same values that will be passed through PVHTML::getStandardAttributes, PVHTML::getEventAttributes and get the self::getFormAttributes funtions

Retrieves a value that is in the public data collection or was pass through by the set method.

get(string $index) : mixed
inherited static
access

public

Arguments

$index

string

The index to retrieve a value from

Response

mixed

$data The data that was stored at that index

Matches options pased with javascript event actions such as onabort, onclick, etc.

getEventAttributes(array $attributes = array()) : string
static

Arguments

$attributes

array

An array of attributes check if its an event

Response

string

Html attributes if any matched

Returns the instance of a class. Used for implementing the singleton design pattern. Class will only be instantiated once.

getInstance() : object
inherited static
access

public

Response

object

$instance Returns the instance of a class.

Returns the iterator for iterating through the values stored in the classes collection.

getIterator() : \PVIterator
inherited static

Response

\PVIterator

$iterator The classes collection in an iteratable form

access public

Searches for media attributes that go with media tags like video/audio.

getMediaEventAttributes(array $attributes = array()) : string
static

Arguments

$attributes

array

An array of attributes to assign

Response

string

Html attributes if any matched

Standard attributes that are present in many html tags. This functionisused for assigning those attribute by passing them in as an array and returning them as a string. Contains both html and html5 elements

getStandardAttributes(array $attributes = array()) : string
static
access

public

Arguments

$attributes

array

Attribues that will be assigned if they match -'class' string: The class attribute -'id' string: The class attribute -'dir' string: The class attribute -'lang' string: The class attribute -'style' string: The class attribute -'title' string: The class attribute -'title' string: The class attribute -'xml:lang' string: The class attribute -'accesskey' string: The class attribute -'contenteditable' string: The class attribute -'contextmenu' string: The class attribute -'draggable' string: The class attribute -'dropzone' string: The class attribute -'hidden' string: The class attribute -'spellcheck' string: The class attribute -'title' string: The class attribute

Response

string

$attributes Returns the matched attributes as a string

Searches for media attributes that go with window javascript events.

getWindowAttributes(array $attributes = array()) : string
static

Arguments

$attributes

array

An array of attributes to assign

Response

string

Html attributes if any matched

Creates a <h1></h1> to display.

h1(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Creates a <h2></h2> to display.

h2(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Creates a <h3></h3> to display.

h3(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Creates a <h4></h4> to display.

h4(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Creates a <h5></h5> to display.

h5(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Creates a <h6></h6> to display.

h6(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the heaader tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The header element that was generated

Generate an html element for displaying an iframe.

iframe(string $src, string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$src

string

The source of the iframe

$data

string

The data to inside the iframe take

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes -'frameborder' string: Tags to go in the frameborder -'marginheight' string: Tags to go in the marginheight -'marginwidth' string: Tags to go in the marginweidth -'scrolling' string: Tags to go in the scrolling -'longdesc' string: Tags to go in the longdesc

Response

string

$iframe The iframe taged returned a time

Displays an image in the <img /> tags. By default the location can be either an image in an url or the image location referenced will be from the PV_IMAGE define set.

image(string $location, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$location

string

Either a url of the image or the path to the image in the PV_IMAGE define location

$options

array

Attributes that can be added to the image. includes self::getStandardAttributes and self::getEventAttributes -'image_width' double: The width of the image -'image_height' double: The height of the image -'width' double: The width of the image -'height' double: The height of the image -'alt' string: Value to go in the alt tag of the image -'longdesc' string: Value to go in the longdesc tag of the image -'usemap' string: Value to go in the usemap tag of an image

Response

string

$image The image tag returned as a string

Creates a strong li ,<li></li>, to display.

li(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the li tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$strong The strong element that was generated

Generate a meta tag.

meta(string $name = '', array $options = array()) : string
static
see \PVHtml::getStandardAttributes()
access

public

Arguments

$name

string

The name of the meta tag being generated

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes -'charset' string: Value to go in the charset tag. -'content' string: Value to go in the content attribute. -'name' string: Value tog go in the name attribute -'http-equiv' string: Value to go in the http-equiv attribute

Response

string

$meta The meta tag returned as a string

Creates a strong ol ,<ol></ol>, to display.

ol(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the ol tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$strong The strong element that was generated

Creates a paragraph tag ,<p></p>, to display.

p(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the paragraph tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The paragraph element that was generated

Creates a progress input element with options passed too it.

progress(string $value, string $max, array $options = array()) : string
static
see \PVHTML::getStandardAttributes() \PVHTML::getEventAttributes() \PVHTML::getStandardAttributes() self::getFormAttributes()
access

public

Arguments

$value

string

The current value for the progress bar

$max

string

The max value for the progress bar

$options

array

Options than can be used to further distinguish the element. The options are the same values that will be passed through PVHTML::getStandardAttributes, PVHTML::getEventAttributes and get the self::getFormAttributes funtions

Response

string

$element The string that creates the element

Removes an adapter.

removeAdapter( $class, string $method) : void
inherited static
access

public

Arguments

$class

$method

string

The associated method

Removes an adapter for an entire class.

removeClassAdapter( $class) : void
inherited static
access

public

Arguments

$class

Adds a value to the classes Collection. By default the collection is stored in the public collection. The stored instance can be retrieved later by called in it's key value.

set(string $index, mixed $value) : void
inherited static
access

public

Arguments

$index

string

The key or index to store the value at

$value

mixed

A mixed value that can be anytype

Turn on/off the ability to trace an adapter.Turning on will log an adapter using PVLog when adapter is executed.

setAdapterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace adatper.

Turn on/off the ability to trace an filter.Turning on will log a filter using PVLog when filter is executed.

setFilterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace filter.

Turn on/off the ability to trace an observer.Turning on will log an observer using PVLog when the observer is executed.

setObserverTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace observer.

Creates a span tag ,<span></span>, to display.

span(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the span tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$header The span element that was generated

Creates a strong tag ,<strong></strong>, to display.

strong(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the strong tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$strong The strong element that was generated

Creates a summary tag ,<summary></ssummary>, to display.

summary(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the strong tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$summary The summary element that was generated

Display a time passed in the HTML5 time field.

time(string $time, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$time

string

A time value

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes -'datetime' string: Tags to go in the datetime tags -'pubdate' string: Tags to go in the pubdate

Response

string

$time The time taged returned a time

Creates a strong ul ,<ul></ul>, to display.

ul(string $data, array $options = array()) : string
static
see \PVHtml::getEventAttributes() \PVHtml::getStandardAttributes()
access

public

Arguments

$data

string

The information that will be displayed inside the ul tag

$options

array

Attributes that can be added to the element. includes self::getStandardAttributes and self::getEventAttributes

Response

string

$strong The strong element that was generated

Displays a video using the HTML5 video component. For best usage, pass through a mp4, ogv and webm file.

video(string $src = '', array $options = array()) : string
static
access

public

Arguments

$src

string

The location of the video file to be played. Will be rendered by self::videoContentURL() function

$options

array

Options that can be used to define attributes in the elements tag -'height' double: The height of the video -'width' width: The width of the video -'controls' string: The controls attributes. -'audio' 'string: THe audio attribute -'autoplay' string: Automatically play the video -'loop' string : Loop to play automatically -'poster' string : Poster attribute -'preload' string: Preload attribute -'mp4_file' string: Location of the mp4 file -'webm_file' string: The location of the webm file -'ogv_file' string: Location of the ogv file

Response

string

$video Returns the video tag

Not sure if the function is needed or still make sense

videoContentURL(string $url, boolean $append_location = false) : string
static
todo

check if function is still valid

Arguments

$url

string

url of the file

$append_location

boolean

Appends the PV_AUDIo tage

Response

string

Properties

A collection of items that belong to this class

_collection : 
inherited static

Type(s)

A collection of dynamically added methods that below to this class

_methods : 
inherited static

Type(s)

The adapters that have been added

_adapters : 
inherited static

Type(s)

Observers that have been added

_observers : 
inherited static

Type(s)

Instances for singleton that have added

_instances : 
inherited static

Type(s)

Intercepting filters that have been added

_filters : 
inherited static

Type(s)

Boolean for following and logging adapters that have been added

_traceAdapters : 
inherited static

Type(s)

Boolean for following and logging filters that have been added

_traceFilters : 
inherited static

Type(s)

Boolean for following and logging observers that have been added.

_traceObservers : 
inherited static

Type(s)