Microdata

Joomla Platform class for interacting with Microdata semantics.

since

3.2

Methods

__construct

Initialize the class and setup the default $Type

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

3.2

Arguments

$type

stringOptional, fallback to 'Thing' Type

$flag

booleanEnable or disable the library output

content

Setup a Human content or content for the Machines

content(string $content, string $machineContent = null) : \Joomla\CMS\Microdata\Microdata
since

3.2

Arguments

$content

stringThe human content or machine content to be used

$machineContent

stringThe machine content

Response

\Joomla\CMS\Microdata\MicrodataInstance of $this

display

This function handles the display logic.

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

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.

since

3.2

Arguments

$displayType

stringOptional, 'inline', available options ['inline'|'span'|'div'|meta]

$emptyOutput

booleanReturn an empty string if the library output is disabled and there is a $content value

Response

string

displayScope

Return the HTML of the current Scope

displayScope() : string
since

3.2

Response

string

enable

Enable or Disable the library output

enable(boolean $flag = true) : \Joomla\CMS\Microdata\Microdata
since

3.2

Arguments

$flag

booleanEnable or disable the library output

Response

\Joomla\CMS\Microdata\MicrodataInstance of $this

fallback

Setup a Fallback Type and Property

fallback(string $type, string $property) : \Joomla\CMS\Microdata\Microdata
since

3.2

Arguments

$type

stringThe Fallback Type

$property

stringThe Fallback Property

Response

\Joomla\CMS\Microdata\MicrodataInstance of $this

getAvailableTypes

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

getAvailableTypes() : array
static
since

3.2

Response

array

getContent

Return the current $content

getContent() : string
since

3.2

Response

string

getExpectedDisplayType

Return the expected display type: [normal|nested|meta] In which way to display the Property: normal -> itemprop="name" nested -> itemprop="director" itemscope itemtype="https://schema.org/Person" meta -> <meta itemprop="datePublished" content="1991-05-01">

getExpectedDisplayType(string $type, string $property) : string
static
since

3.2

Arguments

$type

stringThe Type where to find the Property

$property

stringThe Property to process

Response

string

getExpectedTypes

Return the expected Types of the given Property

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

3.2

Arguments

$type

stringThe Type to process

$property

stringThe Property to process

Response

array

getFallbackProperty

Return the current $fallbackProperty

getFallbackProperty() : string
since

3.2

Response

string

getFallbackType

Return the current $fallbackType

getFallbackType() : string
since

3.2

Response

string

getMachineContent

Return the current $machineContent

getMachineContent() : string
since

3.3

Response

string

getProperty

Return the current $Property name

getProperty() : string
since

3.2

Response

string

getType

Return the current $Type name

getType() : string
since

3.2

Response

string

getTypes

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

getTypes() : array
static
since

3.2

Response

array

htmlDiv

Return Microdata semantics in a <div> tag.

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

3.2

Arguments

$content

stringThe human content

$property

stringOptional, the human content to display

$scope

stringOptional, the Type scope to display

$invert

booleanOptional, default = false, invert the $scope with the $property

Response

string

htmlMeta

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

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

3.2

Arguments

$content

stringThe machine content to display

$property

stringThe Property

$scope

stringOptional, the Type scope to display

$invert

booleanOptional, default = false, invert the $scope with the $property

Response

string

htmlProperty

Return the HTML Property

htmlProperty(string $property) : string
static
since

3.2

Arguments

$property

stringThe Property to process

Response

string

htmlScope

Return the HTML Scope

htmlScope(string $scope) : string
static
since

3.2

Arguments

$scope

stringThe Scope to process

Response

string

htmlSpan

Return Microdata semantics in a <span> tag.

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

3.2

Arguments

$content

stringThe human content

$property

stringOptional, the human content to display

$scope

stringOptional, the Type scope to display

$invert

booleanOptional, default = false, invert the $scope with the $property

Response

string

htmlTag

Return Microdata semantics in a specified tag.

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

3.3

Arguments

$tag

stringThe HTML tag

$content

stringThe human content

$property

stringOptional, the human content to display

$scope

stringOptional, the Type scope to display

$invert

booleanOptional, default = false, invert the $scope with the $property

Response

string

isEnabled

Return 'true' if the library output is enabled

isEnabled() : boolean
since

3.2

Response

boolean

isPropertyInType

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

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

3.2

Arguments

$type

stringThe Type where to check

$property

stringThe Property to check

Response

boolean

isTypeAvailable

Control if the given Type class is available

isTypeAvailable(string $type) : boolean
static
since

3.2

Arguments

$type

stringThe Type to check

Response

boolean

loadTypes

Load all available Types and Properties from the http://schema.org vocabulary contained in the types.json file

loadTypes() : void
static
since

3.2

property

Setup a $Property

property(string $property) : \Joomla\CMS\Microdata\Microdata
since

3.2

Arguments

$property

stringThe Property

Response

\Joomla\CMS\Microdata\MicrodataInstance of $this

resetParams

Reset all params

resetParams() : void
since

3.2

sanitizeProperty

Return the sanitized $Property

sanitizeProperty(string $property) : string
static
since

3.2

Arguments

$property

stringThe Property to sanitize

Response

string

sanitizeType

Return the sanitized $Type

sanitizeType(string $type) : string
static
since

3.2

Arguments

$type

stringThe Type to sanitize

Response

string

setType

Set a new http://schema.org Type

setType(string $type) : \Joomla\CMS\Microdata\Microdata
since

3.2

Arguments

$type

stringThe $Type to be setup

Response

\Joomla\CMS\Microdata\MicrodataInstance of $this

Properties

types

Array with all available Types and Properties from the http://schema.org vocabulary

static
since

3.2

Type(s)

array

type

The Type

since

3.2

Type(s)

string

property

The Property

since

3.2

Type(s)

string

content

The Human content

since

3.2

Type(s)

string

machineContent

The Machine content

since

3.2

Type(s)

string

fallbackType

The Fallback Type

since

3.2

Type(s)

string

fallbackProperty

The Fallback Property

since

3.2

Type(s)

string

enabled

Used for checking if the library output is enabled or disabled

since

3.2

Type(s)

boolean