PHP Class htmlHelper, nodejs-autorestart

Mostrar archivo Open project: shimondoodkin/nodejs-autorestart Class Usage Examples

Public Properties

Property Type Description
$vorkHead array Array used internally by Vork to cache JavaScript and CSS snippets and place them in the head section Changing the contents of this property may cause Vork components to be rendered incorrectly.

Protected Properties

Property Type Description
$_cssSingleton Flag array to avoid defining singleton JavaScript & CSS snippets more than once
$_docType string Sets the default doctype to XHTML 1.1
$_includedFiles array Internal list of included CSS & JS files used by $this->_tagBuilder() to assure that files are not included twice
$_jsSingleton Flag array to avoid defining singleton JavaScript & CSS snippets more than once
$_linkPrefix Internal storage of the link-prefix and hypertext protocol values
$_protocol Internal storage of the link-prefix and hypertext protocol values

Public Methods

Method Description
__call ( string $method, $args ) : string Creates virtual wrapper methods via $this->_tagBuilder() for the simple wrapper functions including: $html->css, js, cssInline, jsInline, div, li, p and h1-h4
__construct ( ) Sets the protocol (http/https)
alternator ( ) : boolean Returns an alternating Boolean, useful to generate alternating background colors Eg.: $colors = array(true => 'gray', false => 'white'); echo '
.
anchor ( array $args ) : string Creates an anchor or link container
code ( str $str ) : str Wrapper display computer-code samples
footer ( array $args = [] ) : string Returns an HTML footer and optional Google Analytics This method will trigger an error if executed without first calling the header() method This is meant to be utilized within layouts, not views (but will work in either)
formatProperties ( array $properties ) : string Takes an array of key-value pairs and formats them in the syntax of HTML-container properties
getNotifications ( mixed $messages, string $class = 'errormessage' ) : string Returns a list of notifications if there are any - similar to the Flash feature of Ruby on Rails
header ( array $args ) : string Returns an HTML header and opens the body container This method will trigger an error if executed more than once without first calling the footer() method on the prior usage This is meant to be utilized within layouts, not views (but will work in either)
isEven ( integer $number ) : boolean Will return true if the number passed in is even, false if odd.
jsLoad ( mixed $library, mixed $version = null, array $options = [] ) : str Load a JavaScript library via Google's AJAX API http://code.google.com/apis/ajaxlibs/documentation/
jsTools ( boolean $noJsWrapper = false ) : string Establishes a basic set of JavaScript tools, just echo $html->jsTools() before any JavaScript code that will use the tools.
link ( str $href, str $text = null, array $args = [] ) : str Shortcut to access the anchor method
setDocType ( string $docType ) Allows modification of the docType

Protected Methods

Method Description
_tagBuilder ( string $tagType, array $args = [] ) : string Creates simple HTML wrappers, accessed via $this->__call()

Method Details

__call() public method

Creates virtual wrapper methods via $this->_tagBuilder() for the simple wrapper functions including: $html->css, js, cssInline, jsInline, div, li, p and h1-h4
public __call ( string $method, $args ) : string
$method string
return string

__construct() public method

Sets the protocol (http/https)
public __construct ( )

_tagBuilder() protected method

JS and CSS files are never included more than once even if requested twice. If DEBUG mode is enabled than the second request will be added to the debug log as a duplicate. The jsSingleton and cssSingleton methods operate the same as the js & css methods except that they will silently skip duplicate requests instead of logging them. jsInlineSingleton and cssInlineSingleton makes sure a JavaScript or CSS snippet will only be output once, even if echoed out multiple times and this method will attempt to place the JS code into the head section, if has already been echoed out then it will return the JS code inline the same as jsInline. Eg.: $helloJs = "function helloWorld() {alert('Hello World');}"; echo $html->jsInlineSingleton($helloJs); Adding an optional extra argument to jsInlineSingleton/cssInlineSingleton will return the inline code bare (plus a trailing linebreak) if it cannot place it into the head section, this is used for joint JS/CSS statements: echo $html->jsInline($html->jsInlineSingleton($helloJs, true) . 'helloWorld();');
protected _tagBuilder ( string $tagType, array $args = [] ) : string
$tagType string
$args array
return string

alternator() public method

..
'; //gray background echo '
...
'; //white background echo '
...
'; //gray background
public alternator ( ) : boolean
return boolean

anchor() public method

Creates an anchor or link container
public anchor ( array $args ) : string
$args array
return string

code() public method

Wrapper display computer-code samples
public code ( str $str ) : str
$str str
return str

formatProperties() public static method

Takes an array of key-value pairs and formats them in the syntax of HTML-container properties
public static formatProperties ( array $properties ) : string
$properties array
return string

getNotifications() public method

Returns a list of notifications if there are any - similar to the Flash feature of Ruby on Rails
public getNotifications ( mixed $messages, string $class = 'errormessage' ) : string
$messages mixed String or an array of strings
$class string
return string Returns null if there are no notifications to return

header() public method

Returns an HTML header and opens the body container This method will trigger an error if executed more than once without first calling the footer() method on the prior usage This is meant to be utilized within layouts, not views (but will work in either)
public header ( array $args ) : string
$args array
return string

isEven() public method

Will return true if the number passed in is even, false if odd.
public isEven ( integer $number ) : boolean
$number integer
return boolean

jsLoad() public method

Version is optional and can be exact (1.8.2) or just version-major (1 or 1.8) Usage: echo $html->jsLoad('jquery'); echo $html->jsLoad(array('yui', 'mootools')); echo $html->jsLoad(array('yui' => 2.7, 'jquery', 'dojo' => '1.3.1', 'scriptaculous')); You can also use the Google API format JSON-decoded in which case version is required & name must be lowercase $jsLibs = array(array('name' => 'mootools', 'version' => 1.2, 'base_domain' => 'ditu.google.cn'), array(...)); echo $html->jsLoad($jsLibs);
public jsLoad ( mixed $library, mixed $version = null, array $options = [] ) : str
$library mixed Can be a string, array(str1, str2...) or , array(name1 => version1, name2 => version2...) or JSON-decoded Google API syntax array(array('name' => 'yui', 'version' => 2), array(...))
$version mixed Optional, int or str, this is only used if $library is a string
$options array Optional, passed to Google "optionalSettings" argument, only used if $library == str
return str

jsTools() public method

This method will only operate from the first occurrence in your code, subsequent calls will not output anything but you should add it anyway as it will make sure that your code continues to work if you later remove a previous call to jsTools. Tools provided: dom() method is a direct replacement for document.getElementById() that works in all JS-capable browsers Y2k and newer. vork object - defines a global vork storage space; use by appending your own properties, eg.: vork.widgetCount
public jsTools ( boolean $noJsWrapper = false ) : string
$noJsWrapper boolean set to True if calling from within a $html->jsInline() wrapper
return string

setDocType() public method

Can either set to an actual doctype definition or to one of the presets (case-insensitive): XHTML Mobile 1.2 XHTML Mobile 1.1 XHTML Mobile 1.0 Mobile 1.2 (alias for XHTML Mobile 1.2) Mobile 1.1 (alias for XHTML Mobile 1.1) Mobile 1.0 (alias for XHTML Mobile 1.0) Mobile (alias for the most-strict Mobile DTD, currently 1.2) XHTML 1.1 (this is the default DTD, there is no need to apply this method for an XHTML 1.1 doctype) XHTML (Alias for XHTML 1.1) XHTML 1.0 Strict XHTML 1.0 Transitional XHTML 1.0 Frameset XHTML 1.0 (Alias for XHTML 1.0 Strict) HTML 5 HTML 4.01 HTML (Alias for HTML 4.01)
public setDocType ( string $docType )
$docType string

Property Details

$_cssSingleton protected_oe property

Flag array to avoid defining singleton JavaScript & CSS snippets more than once
protected $_cssSingleton

$_docType protected_oe property

Sets the default doctype to XHTML 1.1
protected string $_docType
return string

$_includedFiles protected_oe property

Internal list of included CSS & JS files used by $this->_tagBuilder() to assure that files are not included twice
protected array $_includedFiles
return array

$_jsSingleton protected_oe property

Flag array to avoid defining singleton JavaScript & CSS snippets more than once
protected $_jsSingleton

$_linkPrefix protected_oe property

Internal storage of the link-prefix and hypertext protocol values
protected $_linkPrefix

$_protocol protected_oe property

Internal storage of the link-prefix and hypertext protocol values
protected $_protocol

$vorkHead public_oe property

Array used internally by Vork to cache JavaScript and CSS snippets and place them in the head section Changing the contents of this property may cause Vork components to be rendered incorrectly.
public array $vorkHead
return array