include/SugarFields/Parsers/MetaParser.php

Show: inherited
Table of Contents

\MetaParser

Package: SugarCRM

MetaParser.php

This is a utility base file to parse HTML

Children
\EditViewMetaParser
\DetailViewMetaParser
\QuickCreateMetaParser
\SearchFormMetaParser
Api
 
Author
Collin Lee  

Properties

Propertypublic  $mCustomPanels= ''
Details
Type
n/a
Propertypublic  $mModule= ''
Details
Type
n/a
Propertypublic  $mPHPFile= ''
Details
Type
n/a
Propertypublic  $mView= ''
Details
Type
n/a

Methods

methodpublicMetaParser( ) : void

methodpublicapplyPostRules(  $moduleDir,  $panels ) : void

Parameters
Name Type Description
$moduleDir
$panels
methodpublicapplyPreRules(  $moduleDir,  $panels ) : void

Parameters
Name Type Description
$moduleDir
$panels
methodpublicapplyRules(  $moduleDir,  $panels ) : void

Parameters
Name Type Description
$moduleDir
$panels
methodpublicconvertToTagElement(  $matches ) : void

Parameters
Name Type Description
$matches
methodpubliccreateFileContents(  $moduleDir,  $panels,  $templateMeta = array(),  $htmlFilePath ) : void

Parameters
Name Type Description
$moduleDir
$panels
$templateMeta
$htmlFilePath
methodpublicdirList( \$directory $directory ) : \$results

dirList Utility method to list all the files in a given directory.

Parameters
Name Type Description
$directory \$directory

The directory to scan

Returns
Type Description
\$results The files in the directory that were found
methodpublicfindAssignedVariableName( \$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.

Parameters
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

Returns
Type Description
\The variable name found in PHP file, original $name variable if not found
methodpublicfindSingleVardefElement(  $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

Parameters
Name Type Description
$formElements
$vardefs
methodpublicfixDuplicateTrTags(  $tableContents ) : void

fixDuplicateTrTags This is a very crude function to fix instances where files have two consecutive tags

Parameters
Name Type Description
$tableContents
methodpublicfixRowsWithMissingTr(  $tableContents ) : void

fixRowsWithMissingTr This is a very crude function to fix instances where files have an tag immediately followed by a tag

Parameters
Name Type Description
$tableContents
methodpublicfixTablesWithMissingTr(  $tableContents ) : void

fixTablesWithMissingTr This is a very crude function to fix instances where files declared a table as instead of . Without this helper function, the parsing could messed up.

Parameters
Name Type Description
$tableContents
methodpublicgetCustomField( \$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

Parameters
Name Type Description
$elementNames \$elementNames

Array or String value of form element name(s).

Returns
Type Description
String name of custom field; null if none found
methodpublicgetCustomPanels( ) : void

methodpublicgetElementValue(  $type,  $contents,  $filter = "(.*?)" ) : void

getElementValue

Parameters
Name Type Description
$type
$contents
$filter
methodpublicgetElementsByType( \$type $type,  $contents ) : \a

getElementsByType

Returns an Array of all elements matching type. It will match for the outermost tags. For example given contents: "Text

a

" and method call getElementsByType("", $contents) returns "Text

a

"

Parameters
Name Type Description
$type \$type

The type of element to parse out and return

$contents
Returns
Type Description
\a tag element format Array
methodpublicgetFormContents(  $contents,  $all = true ) : void

getFormContents Parses for contents enclosed within

...
tags

Parameters
Name Type Description
$contents
$all
methodpublicgetFormElements( \$contents $contents ) : \$matches

getFormElements Parses for input, select, textarea types from string content

Parameters
Name Type Description
$contents \$contents

The String contents to parse

Returns
Type Description
\$matches Array of matches of PREG_SET_ORDER
methodpublicgetFormElementsNames( \$contents $contents ) : \$matches

getFormElementsNames Parses for the name values of input, select, textarea types from string content

Parameters
Name Type Description
$contents \$contents

The String contents to parse

Returns
Type Description
\$matches Array of name/value pairs
methodpublicgetJavascript( \$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.

Parameters
Name Type Description
$contents \$contents

The HTML String contents to parse

$addLiterals
Returns
Type Description
\$javascript The formatted script blocks or null if none found
methodpublicgetMaxColumns( \$contents $contents, \$filter $filter ) : \The

getMaxColumns Returns the highest number of ... blocks within a ... block.

Parameters
Name Type Description
$contents \$contents

The table contents to parse

$filter \$filter

Optional filter to parse for an attribute within the td block.

Returns
Type Description
\The maximum column count
methodpublicgetRelateFieldName(  $mixed = '' ) : void

Parameters
Name Type Description
$mixed
methodpublicgetTables( \$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

Parameters
Name Type Description
$tableClass \$tableClass

Optional table class parameter value

$contents
Returns
Type Description
Array of table elements found
methodpublicgetTagAttribute( \$name $name, \$contents $contents, \$filter $filter = '' ) : Array

getTagAttribute Returns the name/value of a tag attribute where name is set to $name

Parameters
Name Type Description
$name \$name

The name of the attribute

$contents \$contents

The contents to parse

$filter \$filter

Option regular expression to filter value

Returns
Type Description
Array of name/value for matching attribute
methodpublichasMultiplePanels(  $panels ) : void

Parameters
Name Type Description
$panels
methodpublichasRequiredSpanLabel(  $html ) : void

Parameters
Name Type Description
$html
methodpublicmergePanels( \$panels $panels, \$moduleDir $vardefs, \$masterCopy $moduleDir,  $masterCopy ) : Array

mergePanels This function merges the $panels Array against the $masterCopy's meta data definition

Parameters
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
Returns
Type Description
Array of merged $panel definition
methodpublicmergeTemplateMeta( \$templateMeta $templateMeta, \$moduleDir $moduleDir, \$masterCopy $masterCopy ) : Array

mergeTemplateMeta This function merges the $templateMeta Array against the $masterCopy's meta data definition

Parameters
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

Returns
Type Description
Array of merged $templateMeta definition
methodpublicparse( ) : void

methodpublicparseDelimiters(  $javascript ) : void

Parameters
Name Type Description
$javascript
methodpublicstripComments(  $contents ) : void

Parameters
Name Type Description
$contents
methodpublicstripFlavorTags( \$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

Parameters
Name Type Description
$contents \$contents

The file contents as a String value

methodpublictrimHTML(  $contents ) : void

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