class Microdata

Joomla Platform class for interacting with Microdata semantics.

Methods

__construct( string $type = '', boolean $flag = true)

Initialize the class and setup the default $Type

enable( boolean $flag = true)

Enable or Disable the library output

boolean
isEnabled()

Return 'true' if the library output is enabled

setType( string $type)

Set a new http://schema.org Type

string
getType()

Return the current $Type name

property( string $property)

Setup a $Property

string
getProperty()

Return the current $Property name

content( string $content, string $machineContent = null)

Setup a Human content or content for the Machines

string
getContent()

Return the current $content

string
getMachineContent()

Return the current $machineContent

fallback( string $type, string $property)

Setup a Fallback Type and Property

string
getFallbackType()

Return the current $fallbackType

string
getFallbackProperty()

Return the current $fallbackProperty

string
display( string $displayType = '', boolean $emptyOutput = false)

This function handles the display logic.

string
displayScope()

Return the HTML of the current Scope

static  string
sanitizeType( string $type)

Return the sanitized $Type

static  string
sanitizeProperty( string $property)

Return the sanitized $Property

static  array
getTypes()

Return an array with all available Types and Properties from the http://schema.org vocabulary

static  array
getAvailableTypes()

Return an array with all available Types from the http://schema.org vocabulary

static  array
getExpectedTypes( string $type, string $property)

Return the expected Types of the given Property

static  boolean
isPropertyInType( string $type, string $property)

Recursive function, control if the given Type has the given Property

static  boolean
isTypeAvailable( string $type)

Control if the given Type class is available

static  string
htmlMeta( string $content, string $property, string $scope = '', boolean $invert = false)

Return Microdata semantics in a <meta> tag with content for machines.

static  string
htmlSpan( string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a <span> tag.

static  string
htmlDiv( string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a <div> tag.

static  string
htmlTag( string $tag, string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a specified tag.

static  string
htmlScope( string $scope)

Return the HTML Scope

static  string
htmlProperty( string $property)

Return the HTML Property

Details

__construct( string $type = '', boolean $flag = true)

Initialize the class and setup the default $Type

Parameters

string $type Optional, fallback to 'Thing' Type
boolean $flag Enable or disable the library output

Microdata enable( boolean $flag = true)

Enable or Disable the library output

Parameters

boolean $flag Enable or disable the library output

Return Value

Microdata Instance of $this

boolean isEnabled()

Return 'true' if the library output is enabled

Return Value

boolean

Microdata setType( string $type)

Set a new http://schema.org Type

Parameters

string $type The $Type to be setup

Return Value

Microdata Instance of $this

string getType()

Return the current $Type name

Return Value

string

Microdata property( string $property)

Setup a $Property

Parameters

string $property The Property

Return Value

Microdata Instance of $this

string getProperty()

Return the current $Property name

Return Value

string

Microdata content( string $content, string $machineContent = null)

Setup a Human content or content for the Machines

Parameters

string $content The human content or machine content to be used
string $machineContent The machine content

Return Value

Microdata Instance of $this

string getContent()

Return the current $content

Return Value

string

string getMachineContent()

Return the current $machineContent

Return Value

string

Microdata fallback( string $type, string $property)

Setup a Fallback Type and Property

Parameters

string $type The Fallback Type
string $property The Fallback Property

Return Value

Microdata Instance of $this

string getFallbackType()

Return the current $fallbackType

Return Value

string

string getFallbackProperty()

Return the current $fallbackProperty

Return Value

string

string display( string $displayType = '', boolean $emptyOutput = false)

This function handles the display logic.

It checks if the Type, Property are available, if not check for a Fallback, then reset all params for the next use and return the HTML.

Parameters

string $displayType Optional, 'inline', available options ['inline'|'span'|'div'|meta]
boolean $emptyOutput Return an empty string if the library output is disabled and there is a $content value

Return Value

string

string displayScope()

Return the HTML of the current Scope

Return Value

string

static string sanitizeType( string $type)

Return the sanitized $Type

Parameters

string $type The Type to sanitize

Return Value

string

static string sanitizeProperty( string $property)

Return the sanitized $Property

Parameters

string $property The Property to sanitize

Return Value

string

static array getTypes()

Return an array with all available Types and Properties from the http://schema.org vocabulary

Return Value

array

static array getAvailableTypes()

Return an array with all available Types from the http://schema.org vocabulary

Return Value

array

static array getExpectedTypes( string $type, string $property)

Return the expected Types of the given Property

Parameters

string $type The Type to process
string $property The Property to process

Return Value

array

static boolean isPropertyInType( string $type, string $property)

Recursive function, control if the given Type has the given Property

Parameters

string $type The Type where to check
string $property The Property to check

Return Value

boolean

static boolean isTypeAvailable( string $type)

Control if the given Type class is available

Parameters

string $type The Type to check

Return Value

boolean

static string htmlMeta( string $content, string $property, string $scope = '', boolean $invert = false)

Return Microdata semantics in a <meta> tag with content for machines.

Parameters

string $content The machine content to display
string $property The Property
string $scope Optional, the Type scope to display
boolean $invert Optional, default = false, invert the $scope with the $property

Return Value

string

static string htmlSpan( string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a <span> tag.

Parameters

string $content The human content
string $property Optional, the human content to display
string $scope Optional, the Type scope to display
boolean $invert Optional, default = false, invert the $scope with the $property

Return Value

string

static string htmlDiv( string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a <div> tag.

Parameters

string $content The human content
string $property Optional, the human content to display
string $scope Optional, the Type scope to display
boolean $invert Optional, default = false, invert the $scope with the $property

Return Value

string

static string htmlTag( string $tag, string $content, string $property = '', string $scope = '', boolean $invert = false)

Return Microdata semantics in a specified tag.

Parameters

string $tag The HTML tag
string $content The human content
string $property Optional, the human content to display
string $scope Optional, the Type scope to display
boolean $invert Optional, default = false, invert the $scope with the $property

Return Value

string

static string htmlScope( string $scope)

Return the HTML Scope

Parameters

string $scope The Scope to process

Return Value

string

static string htmlProperty( string $property)

Return the HTML Property

Parameters

string $property The Property to process

Return Value

string