include/SugarHtml/SugarHtml.php

Show: inherited
Table of Contents

\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

Constant  SINGLE_QUOTE = "'"
Constant  DOUBLE_QUOTE = '"'
Constant  ASSIGN_SIGN = "="
Constant  HTML_TAG_BEGIN = "<"
Constant  HTML_TAG_END = ">"
Constant  SMARTY_TAG_BEGIN = "{"
Constant  SMARTY_TAG_END = "}"
Constant  CLAUSE_TAG_BEGIN = "("
Constant  CLAUSE_TAG_END = ")"

Properties

Propertypublicinteger  $count= '0'
static

the counter for generating automatic input field names.
Default value0Details
Type
integer

Methods

methodpubliccreateAttributes( Array $params ) : string
static

Parameters
Name Type Description
$params Array
  • Attributes (key-value pair)
Returns
Type Description
string - Generated html attribute string
Details
Static
Creates HTML attribute elements corresponding key-value pair.  
methodpubliccreateCloseTag( String $tagName ) : string
static

Parameters
Name Type Description
$tagName String
  • the tag name
Returns
Type Description
string - generated html string
Details
Static
Create a close html element  
methodpubliccreateHtml( array $dom_tree = array() ) : string
static

Parameters
Name Type Description
$dom_tree array
  • Cascade array form
 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(...) ), ) ) 
Returns
Type Description
string - generated html string
Details
See
\SugarHtml::parseHtmlTag  
Static
Create a html block given a cascade array tree. Resemble the array form generated by parseHtmlTag  
methodpubliccreateOpenTag( String $tagName, array $params = array(), bool $self_closing = false ) : string
static

Parameters
Name Type Description
$tagName String
  • the tag name
$params array
  • the element attributes
$self_closing bool
  • whether the element is self-closing or not
Returns
Type Description
string - generated html string
Details
Static
Create an open html element  
methodpublicextractAttributes( String $code, Array $output ) : string
static

Parameters
Name Type Description
$code String
  • attribute string (i.e. - id='form_id' name='button' value='View Detail' ...)
$output Array
  • Parsed the attribute into key-value form
Returns
Type Description
string - Remainder string by spliting with ">"
Details
Static
Disassemble an html attributes into a key-value array form  
methodpublicparseHtmlTag( String $code, array $appendTo = array() ) : array
static

Parameters
Name Type Description
$code String
  • html string (support the mixed html string with smarty blocks)
$appendTo array
  • Precedent siblings
Returns
Type Description
array - structual array form, can be restored in a html code by createHtml
Details
See
\SugarHtml::createHtml  
Static
Disassemble an html string into a cascaded array form elements  
methodpublicparseSmartyTag( String $code, Array $output, int $offset = 0, bool $is_attr = false ) : void
static

Parameters
Name Type Description
$code String
  • smarty encoded string
$output Array
  • parsed attribute
$offset int
$is_attr bool
  • whether current smarty block is inside html attributes or not
Details
Static
Disassemble a smarty string into a cascaded array form elements  
methodpublicparseSugarHtml(  $sugar_html = array() ) : void
static

Parameters
Name Type Description
$sugar_html
Documentation was generated by DocBlox 0.18.1.