PHP Класс htmlHelper, nodejs-autorestart

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
_tagBuilder ( string $tagType, array $args = [] ) : string Creates simple HTML wrappers, accessed via $this->__call()

Описание методов

__call() публичный Метод

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
Результат string

__construct() публичный Метод

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

_tagBuilder() защищенный Метод

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
Результат string

alternator() публичный Метод

..
'; //gray background echo '
...
'; //white background echo '
...
'; //gray background
public alternator ( ) : boolean
Результат boolean

anchor() публичный Метод

Creates an anchor or link container
public anchor ( array $args ) : string
$args array
Результат string

code() публичный Метод

Wrapper display computer-code samples
public code ( str $str ) : str
$str str
Результат str

formatProperties() публичный статический Метод

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
Результат string

getNotifications() публичный Метод

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
Результат string Returns null if there are no notifications to return

header() публичный Метод

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
Результат string

isEven() публичный Метод

Will return true if the number passed in is even, false if odd.
public isEven ( integer $number ) : boolean
$number integer
Результат boolean

jsLoad() публичный Метод

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
Результат str

jsTools() публичный Метод

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
Результат string

setDocType() публичный Метод

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

Описание свойств

$_cssSingleton защищенное свойство

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

$_docType защищенное свойство

Sets the default doctype to XHTML 1.1
protected string $_docType
Результат string

$_includedFiles защищенное свойство

Internal list of included CSS & JS files used by $this->_tagBuilder() to assure that files are not included twice
protected array $_includedFiles
Результат array

$_jsSingleton защищенное свойство

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

$_linkPrefix защищенное свойство

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

$_protocol защищенное свойство

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

$vorkHead публичное свойство

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
Результат array