include/SugarFields/Parsers/MetaParser.php
\MetaParser
MetaParser.php
This is a utility base file to parse HTML
- Children
- \EditViewMetaParser
- \DetailViewMetaParser
- \QuickCreateMetaParser
- \SearchFormMetaParser
- Api
- Author
- Collin Lee
Properties
Methods
createFileContents(
$moduleDir, $panels, $templateMeta
=
array(), $htmlFilePath
)
:
void
Name | Type | Description |
---|---|---|
$moduleDir | ||
$panels | ||
$templateMeta | ||
$htmlFilePath |
dirList(
\$directory $directory
)
:
\$results
dirList Utility method to list all the files in a given directory.
Name | Type | Description |
---|---|---|
$directory | \$directory | The directory to scan |
Type | Description |
---|---|
\$results | The files in the directory that were found |
findAssignedVariableName(
\$name $name, \$filePath $filePath
)
:
\The
findAssignedVariableName This method provides additional support in attempting to parse the module's corresponding PHP file for either the EditView or DetailView. In the event that the subclasses cannot find a matching vardefs.php entry in the HTML file, this method can be called to parse the PHP file to see if the assignment was made using the bean's variable. If so, we return this variable name.
Name | Type | Description |
---|---|---|
$name | \$name | The tag name found in the HTML file for which we want to search |
$filePath | \$filePath | The full file path for the HTML file |
Type | Description |
---|---|
\The | variable name found in PHP file, original $name variable if not found |
findSingleVardefElement(
$formElements
=
array(), $vardefs
=
array()
)
:
void
findSingleVardefElement Scans array of form elements to see if just one is a vardef element and, if so, return that vardef name
Name | Type | Description |
---|---|---|
$formElements | ||
$vardefs |
fixDuplicateTrTags(
$tableContents
)
:
void
fixDuplicateTrTags This is a very crude function to fix instances where files have two consecutive
Name | Type | Description |
---|---|---|
$tableContents |
Name | Type | Description |
---|---|---|
$tableContents |
fixTablesWithMissingTr(
$tableContents
)
:
void
fixTablesWithMissingTr This is a very crude function to fix instances where files declared a table as
Name | Type | Description |
---|---|---|
$tableContents |
getCustomField(
\$elementNames $elementNames
)
:
String
isCustomField This method checks the mixed variable $elementNames to see if it is a custom field. A custom field is simply defined as a field that ends with "_c". If $elementNames is an Array any matching custom field value will result in a true evaluation
Name | Type | Description |
---|---|---|
$elementNames | \$elementNames | Array or String value of form element name(s). |
Type | Description |
---|---|
String | name of custom field; null if none found |
getElementValue(
$type, $contents, $filter
=
"(.*?)"
)
:
void
getElementValue
Name | Type | Description |
---|---|---|
$type | ||
$contents | ||
$filter |
getElementsByType(
\$type $type, $contents
)
:
\a
getElementsByType
Returns an Array of all elements matching type. It will match for the outermost tags. For example given contents: "
a |
a |
Name | Type | Description |
---|---|---|
$type | \$type | The type of element to parse out and return |
$contents |
Type | Description |
---|---|
\a | tag element format Array |
getFormContents(
$contents, $all
=
true
)
:
void
getFormContents Parses for contents enclosed within
tagsName | Type | Description |
---|---|---|
$contents | ||
$all |
getFormElements(
\$contents $contents
)
:
\$matches
getFormElements Parses for input, select, textarea types from string content
Name | Type | Description |
---|---|---|
$contents | \$contents | The String contents to parse |
Type | Description |
---|---|
\$matches | Array of matches of PREG_SET_ORDER |
getFormElementsNames(
\$contents $contents
)
:
\$matches
getFormElementsNames Parses for the name values of input, select, textarea types from string content
Name | Type | Description |
---|---|---|
$contents | \$contents | The String contents to parse |
Type | Description |
---|---|
\$matches | Array of name/value pairs |
getJavascript(
\$contents $contents, $addLiterals
=
true
)
:
\$javascript
getJavascript
This method parses the given $contents String and grabs all <script...>... blocks. The method also converts values enclosed within "{...}" blocks that may need to be converted to Smarty syntax.
Name | Type | Description |
---|---|---|
$contents | \$contents | The HTML String contents to parse |
$addLiterals |
Type | Description |
---|---|
\$javascript | The formatted script blocks or null if none found |
getMaxColumns(
\$contents $contents, \$filter $filter
)
:
\The
getMaxColumns Returns the highest number of
Name | Type | Description |
---|---|---|
$contents | \$contents | The table contents to parse |
$filter | \$filter | Optional filter to parse for an attribute within the td block. |
Type | Description |
---|---|
\The | maximum column count |
getTables(
\$tableClass $tableClass
=
null, $contents
)
:
Array
getTables Returns an Array of the tables found in the file. If $tableClass parameter is supplied, it'll return only those tables that have a matching class attribute equal to $tableClass
Name | Type | Description |
---|---|---|
$tableClass | \$tableClass | Optional table class parameter value |
$contents |
Type | Description |
---|---|
Array | of table elements found |
getTagAttribute(
\$name $name, \$contents $contents, \$filter $filter
=
''
)
:
Array
getTagAttribute Returns the name/value of a tag attribute where name is set to $name
Name | Type | Description |
---|---|---|
$name | \$name | The name of the attribute |
$contents | \$contents | The contents to parse |
$filter | \$filter | Option regular expression to filter value |
Type | Description |
---|---|
Array | of name/value for matching attribute |
mergePanels(
\$panels $panels, \$moduleDir $vardefs, \$masterCopy $moduleDir, $masterCopy
)
:
Array
mergePanels This function merges the $panels Array against the $masterCopy's meta data definition
Name | Type | Description |
---|---|---|
$panels | \$panels | meta data Array to merge |
$vardefs | \$moduleDir | Directory name of the module |
$moduleDir | \$masterCopy | file path to the meta data master copy |
$masterCopy |
Type | Description |
---|---|
Array | of merged $panel definition |
mergeTemplateMeta(
\$templateMeta $templateMeta, \$moduleDir $moduleDir, \$masterCopy $masterCopy
)
:
Array
mergeTemplateMeta This function merges the $templateMeta Array against the $masterCopy's meta data definition
Name | Type | Description |
---|---|---|
$templateMeta | \$templateMeta | meta data Array to merge |
$moduleDir | \$moduleDir | Directory name of the module |
$masterCopy | \$masterCopy | file path to the meta data master copy |
Type | Description |
---|---|
Array | of merged $templateMeta definition |
stripFlavorTags(
\$contents $contents
)
:
void
stripFlavorTags This method accepts the file contents and uses the $GLOBALS['sugar_flavor'] value to remove the flavor tags in the file contents if present. If $GLOBALS['sugar_flavor'] is not set, it defaults to PRO flavor
Name | Type | Description |
---|---|---|
$contents | \$contents | The file contents as a String value |