include/SugarHtml/SugarHtml.php
\SugarHtml
Package: SugarCRM
SugarHtml is a static class that provides a collection of helper methods for creating HTML DOM elements.
- Auther
- Justin Park(jpark@sugarcrm.com)
Constants
Properties
Methods
createAttributes(
Array $params
)
:
string
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$params | Array |
|
Type | Description |
---|---|
string | - Generated html attribute string |
- Static
- Creates HTML attribute elements corresponding key-value pair.
createCloseTag(
String $tagName
)
:
string
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$tagName | String |
|
Type | Description |
---|---|
string | - generated html string |
- Static
- Create a close html element
createHtml(
array $dom_tree
=
array()
)
:
string
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$dom_tree | array |
1. Simple html format array( 'tag' => 'div', // all attributes are assigned in key-value form 'id' => 'div_id', 'class' => 'wrapper', ... ) 2. Cascade html format array( 'tag' => 'div', //all subitems are assigned in container 'container' => array( array( 'tag' => 'input', 'type' => 'hidden', ) ) ) 3. Siblings array( //all siblings are assigned in a parallel array form array('tag' => 'input', 'type' => 'button', ... ), array('tag' => 'input', 'type' => 'submit', ... ) ) 4. Smarty array( 'smarty' => array( array( //smarty must contain 'template'. Container will replace with the same key value 'template' => '{if}[CONTENT1]{else}[CONTENT2]{/if}', //content1 will be assign on the lefthand side, and content2 will be on righthand side '[CONTENT1]' => array( //cascade valid array form ) '[CONTENT2]' => array(...) ), ) ) |
Type | Description |
---|---|
string | - generated html string |
- See
- \SugarHtml::parseHtmlTag
- Static
- Create a html block given a cascade array tree. Resemble the array form generated by parseHtmlTag
createOpenTag(
String $tagName, array $params
=
array(), bool $self_closing
=
false
)
:
string
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$tagName | String |
|
$params | array |
|
$self_closing | bool |
|
Type | Description |
---|---|
string | - generated html string |
- Static
- Create an open html element
extractAttributes(
String $code, Array $output
)
:
string
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$code | String |
|
$output | Array |
|
Type | Description |
---|---|
string | - Remainder string by spliting with ">" |
- Static
- Disassemble an html attributes into a key-value array form
parseHtmlTag(
String $code, array $appendTo
=
array()
)
:
array
static
Parameters
Returns
Details
Name | Type | Description |
---|---|---|
$code | String |
|
$appendTo | array |
|
Type | Description |
---|---|
array | - structual array form, can be restored in a html code by createHtml |
- See
- \SugarHtml::createHtml
- Static
- Disassemble an html string into a cascaded array form elements
parseSmartyTag(
String $code, Array $output, int $offset
=
0, bool $is_attr
=
false
)
:
void
static
Parameters
Details
Name | Type | Description |
---|---|---|
$code | String |
|
$output | Array |
|
$offset | int | |
$is_attr | bool |
|
- Static
- Disassemble a smarty string into a cascaded array form elements