\midcom_services_metadata

Metadata service.

This service utilizes MidCOM's metadata system to provide meaningful, auto-generated meta and link tags into documents. It is also entry point site builders can use to retrieve metadata about current page.

Summary

Methods
Properties
Constants
get_node_metadata()
get_view_metadata()
set_page_class()
get_page_class()
get_object_classes()
bind_to()
bind_metadata_to_object()
populate_meta_head()
get_opengraph_types()
get_opengraph_type_default()
set_request_metadata()
get_request_metadata()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
_create_metadata()
_add_opengraph_metadata()
$_metadata
$_page_classes
N/A

Properties

$_metadata

$_metadata : Array

The metadata currently available. This array is indexed by context id; each value consists of a flat array of two metadata objects, the first object being the Node metadata, the second View metadata. The metadata objects are created on-demand.

Type

Array

$_page_classes

$_page_classes : Array

Class of the current page per each context.

Typically these are the same as the schema name of the current object's Datamanager schema. This can be used for changing site styling based on body class="" etc.

Type

Array

Methods

get_node_metadata()

get_node_metadata(integer  $context_id = null) 

Returns the node metadata of the specified context. The metadata will be created if this is the first request.

Parameters

integer $context_id

The context to retrieve the node metadata for, this defaults to the current context.

get_view_metadata()

get_view_metadata(integer  $context_id = null) : \midcom_helper_metadata

Returns the view metadata of the specified context. The metadata will be created if this is the first request.

Parameters

integer $context_id

The context to retrieve the view metadata for, this defaults to the current context.

Returns

\midcom_helper_metadata

set_page_class()

set_page_class(string  $page_class, integer  $context_id = null) 

Sets the class of the current page for a context

Parameters

string $page_class

The class that should be used for the page

integer $context_id

The context ID for which the page class should be set.

get_page_class()

get_page_class(integer  $context_id = null) : string

Gets the CSS class of the current page of a context

Parameters

integer $context_id

The context ID for the page class.

Returns

string —

The page class

get_object_classes()

get_object_classes(\midcom_core_dbaobject  $object, string  $existing_classes = null) : string

Get CSS classes for an object. This will include two new CSS classes for the object's class string if appropriate:

  • unapproved: approvals are enabled for the site but the object is not translated
  • hidden: object is hidden via metadata settings or scheduling

Parameters

\midcom_core_dbaobject $object

The DBA class instance to get CSS classes for

string $existing_classes

Existing CSS classes to append to

Returns

string —

CSS classes for that object

bind_to()

bind_to(\midcom_core_dbaobject  $object) 

Binds view metadata to a DBA content object

Parameters

\midcom_core_dbaobject $object

The DBA class instance to bind to.

bind_metadata_to_object()

bind_metadata_to_object(  $metadata_type,   $object,   $context_id = null) 

Binds object to given metadata type.

Parameters

$metadata_type
$object
$context_id

populate_meta_head()

populate_meta_head() 

Populates appropriate metadata into HTML documents based on metadata information available to MidCOM for the request.

get_opengraph_types()

get_opengraph_types() : Array

Return a list of Open Graph Protocol types

Returns

Array

get_opengraph_type_default()

get_opengraph_type_default(  $object = null) : string

Get the default Open Graph Protocol type for an object

Parameters

$object

Returns

string —

Open Graph Protocol type

set_request_metadata()

set_request_metadata(integer  $lastmodified, string  $permalinkguid) 

Set the currently known and required Request Metadata: The last modified timestamp and the permalink GUID.

You may set either of the arguments to null to enforce default usage (based on NAP).

Parameters

integer $lastmodified

The date of last modification of this request.

string $permalinkguid

The GUID used to create a permalink for this request.

get_request_metadata()

get_request_metadata(\midcom_core_context  $context = null) : Array

Get the currently known and required Request Metadata: The last modified timestamp and the permalink GUID.

Parameters

\midcom_core_context $context

The context from which the request metadata should be retrieved. Omit to use the current context.

Returns

Array —

An array with the two keys 'lastmodified' and 'permalinkguid' containing the values set with the setter pendant. For ease of use, there is also a key 'permalink' which contains a ready-made permalink.

_create_metadata()

_create_metadata(integer  $context_id) 

Creates the node and view metadata for a given context ID.

Parameters

integer $context_id

The context ID for which the metadata should be created.

_add_opengraph_metadata()

_add_opengraph_metadata(  $view_metadata) 

Parameters

$view_metadata