Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Metadata_Manager Class Reference
Inheritance diagram for Metadata_Manager:
MySource_Object

Public Member Functions

 Metadata_Manager ()
 
 requiredFieldsComplete ($assetid)
 
 allowsMetadata ($assetid)
 
 getSchemas ($assetid, $granted=NULL, $cascades=NULL)
 
 getAssetSchemaInfo ($assetid, $schemaid=NULL, $cascades=NULL, $include_cascades=TRUE)
 
 setSchema ($assetid, $schemaid, $granted, $cascades=TRUE, $force_set=FALSE)
 
 deleteSchema ($assetid, $schemaid)
 
 getSchemaAssets ($schemaid, $granted=NULL)
 
 getMetadataFields ($schemaids)
 
 getMetadata ($assetid, $schemaid=0, $contextid=NULL)
 
 _cleanupMetadataValues ($assetid)
 
 getSchemaDefaultValues ($schemaid, $contextid=NULL)
 
 loadMetadataFile ($assetid, $metadata_filename)
 
 getMetadataFieldValues ($assetid, $field_names=Array(), $contextid=NULL)
 
 setMetadata ($assetid, $metadata, $contextid=NULL, $update_asset=TRUE, $broadcast_all_fields=FALSE, $ignore_editable=FALSE)
 
 generateContentFile ($assetid, $regenerate=FALSE, $contextid=NULL, $update_asset=TRUE)
 
 generateKeywordReplacements (&$metadata_asset, $keywords, $generating=TRUE)
 
 regenerateMetadata ($assetid, $contextid=NULL, $update_asset=TRUE)
 
 purgeMetadata ($assetid)
 
 getMetadataInterfaceValueByAssetid ($assetid, $field_assetid, $mute_errors=FALSE, &$has_errors=FALSE, $contextid=NULL)
 
 getMetadataValueByAssetid ($assetid, $field_assetid, $mute_errors=FALSE, $replace_nested_keyword=FALSE, $contextid=NULL)
 
 isMetadataFieldAssetid ($field_assetid)
 
 getMetadataFieldDefaultValue ($field_assetid, $contextid=NULL)
 
 setMetadataFieldDefaultValue ($field_assetid, $value, $contextid=NULL)
 
 escapeMetadata ($value, $escape_single=FALSE)
 
 getFieldAssetIdFromName ($assetid, $target_field_name)
 
 getMetadataFieldTypeValues ($assetid, $metadata_field_type, $contextid=NULL)
 
- Public Member Functions inherited from MySource_Object
 MySource_Object ()
 
 __sleep ()
 
 __wakeup ()
 

Additional Inherited Members

- Data Fields inherited from MySource_Object
 $_tmp
 

Detailed Description

Definition at line 29 of file metadata_manager.inc.

Member Function Documentation

_cleanupMetadataValues (   $assetid)

Remove entries from the mdata_val table that don't correspond to an applied schema or a currently available context

Parameters
int$assetidThe ID of the asset whose values we want to clean up
Returns
void private

Definition at line 613 of file metadata_manager.inc.

allowsMetadata (   $assetid)

Check if metadata can be set on an asset

Parameters
string$assetidthe ID of the asset to check
Returns
boolean public

Definition at line 91 of file metadata_manager.inc.

deleteSchema (   $assetid,
  $schemaid 
)

Remove a set schema from an asset

Parameters
string$assetidthe ID of the asset to delete the schema from
string$schemaidthe ID of the schema to delete
Returns
boolean public

Definition at line 367 of file metadata_manager.inc.

escapeMetadata (   $value,
  $escape_single = FALSE 
)

Escapes the passed value to be used inside quotes in a block of PHP (eg. when the field names and values are cached out to each asset's metadata.php)

Parameters
string$valuethe value to escape
boolean$escape_singlewhether or not the apostrophes are escaped with backslashes; defaults to FALSE
Returns
string public

Definition at line 2328 of file metadata_manager.inc.

generateContentFile (   $assetid,
  $regenerate = FALSE,
  $contextid = NULL,
  $update_asset = TRUE 
)

Generate a PHP file that can be included to print all metadata fields for an asset

The generated file contains PHP code to do any keyword replacing based on current values instead of the ones at the time of caching.

Parameters
string$assetidthe ID of the asset to generate the file for
boolean$regenerateregenerate the DB information as well
int$contextidContext to generate the content file for
boolean$update_assetUpdate the asset?
Returns
boolean public

Definition at line 1113 of file metadata_manager.inc.

generateKeywordReplacements ( $metadata_asset,
  $keywords,
  $generating = TRUE 
)

Generate an array of keyword replacements, or the PHP code to generate it

This function outputs the PHP required to generate all the keywords that it is passed. All PHP generated places values in an array called $metadata_replacements (which happens in the outputted PHP code). An array of replacements is returned that can be used to replace all the keywords with a PHP string to output the correct value from the $metadata_replacements array. Return format is (keyword => replacement) This function can also return the values of the replacement values instead of the PHP code.

Parameters
object&$metadata_assetthe asset to use for replacment values
array$keywordsan array of keywords in
boolean$generatinggenerate the PHP code or not (which generates the value)
Returns
array public

Definition at line 1451 of file metadata_manager.inc.

getAssetSchemaInfo (   $assetid,
  $schemaid = NULL,
  $cascades = NULL,
  $include_cascades = TRUE 
)

Get list of schemas for a certain asset, optionally filtered by cascading setting

This is primarily used for showing settings on the Metadata Schemas screen.

Definition at line 163 of file metadata_manager.inc.

getFieldAssetIdFromName (   $assetid,
  $target_field_name 
)

Given the ID of an asset that has metadata applied and the name of a field that is applied to that asset, get the asset ID of that metadata field

Returns FALSE if the asset ID does not exist, or if the asset doesn't have a field matching the field name

Throws an assertion exception if the asset ID is completely invalid, or if the field name is not a string.

Parameters
string$assetidThe ID of the asset we wish to check
string$target_field_nameThe name of the field we wish to find
Returns
mixed string|boolean

Definition at line 2379 of file metadata_manager.inc.

getMetadata (   $assetid,
  $schemaid = 0,
  $contextid = NULL 
)

Get the metadata values set for an asset on a particular schema

The array returned may have some fields missing. If there is no field value it means that the field is using the default value (whatever that happens to be at the time). This cuts down on storage and allows defaults to change over time without updating metadata values.

Parameters
string$assetidthe ID of the asset to get metadata for
string$schemaidoptional ID of the schema to only the get metadata for
int$contextidThe context which we should get values from
Returns
array public

Definition at line 528 of file metadata_manager.inc.

getMetadataFieldDefaultValue (   $field_assetid,
  $contextid = NULL 
)

Returns whether the asset ID being passed into this function is some kind of metadata field asset

Parameters
string$field_assetidthe ID of the metadata field asset
string$contextidthe context that this applies to
Returns
boolean public

Definition at line 2141 of file metadata_manager.inc.

getMetadataFields (   $schemaids)

Get an array of metatata fields IDs for a metadata schema

Parameters
string | array$schemaidssingle schemaid or an array of schema ids whose fields we are getting
Returns
array public
See Also
Asset_Manager::getChildren()

Definition at line 492 of file metadata_manager.inc.

getMetadataFieldTypeValues (   $assetid,
  $metadata_field_type,
  $contextid = NULL 
)

For given asset with metadata schema(s) applied, this function returns the value for all metadata fields of given type in following format:

Array( 
'<fieldname>' => '<metadata_value>'
)
Parameters
string$assetidThe ID of the asset we wish to get metadata value of
string$metadata_field_typeThe asset type of the field we wish to get
boolean$contextid
Returns
array public

Definition at line 2418 of file metadata_manager.inc.

getMetadataFieldValues (   $assetid,
  $field_names = Array(),
  $contextid = NULL 
)

Generate an array of current values for the passed metadata field names

If the passed fields array is empty, all field values will be returned

Parameters
string$assetidthe ID of the asset to get field values for
array$field_namesan array of field names
int$contextidThe context to get these values from
Returns
array public

Definition at line 755 of file metadata_manager.inc.

getMetadataInterfaceValueByAssetid (   $assetid,
  $field_assetid,
  $mute_errors = FALSE,
$has_errors = FALSE,
  $contextid = NULL 
)

Get the value of an asset's metadata field based on that field's asset ID to populate its interface

Parameters
string$assetidThe ID of the asset that we want the metadata value of
string$field_assetidThe field that we wish to check
boolean$mute_errorsSet TRUE to mute errors that occur when the asset (specified in $assetid) does not have a schema applied to it
boolean$has_errorsThis parameter is set to TRUE when an error occurs so that errors are acknowledged even they are mute ($mute_errors = TRUE)
int$contextidThe context to get the value of metadata for
Returns
array public

Definition at line 1956 of file metadata_manager.inc.

getMetadataValueByAssetid (   $assetid,
  $field_assetid,
  $mute_errors = FALSE,
  $replace_nested_keyword = FALSE,
  $contextid = NULL 
)

Get the value of an asset's metadata field based on that field's asset ID

Because this value is for displaying on the front end, use the default value if required

Parameters
string$assetidThe ID of the asset that we want the metadata value of
string$field_assetidThe field that we wish to check
boolean$mute_errorsSet TRUE to mute errors that occur when the asset (specified in $assetid) does not have a schema applied to it
boolean$replace_nested_keywordSet TRUE to replace nested keywords. If FALSE the function may return the value of the metadata field that contains keywords
int$contextidThe context to get the value of metadata for
Returns
array public

Definition at line 2038 of file metadata_manager.inc.

getSchemaAssets (   $schemaid,
  $granted = NULL 
)

Get an array of assetIDs that have the passed schemaID applied or denied on them

Parameters
string$schemaidthe ID of the schema to get assets for
boolean$grantedtype of access : null = all, TRUE = applied, FALSE = denied
Returns
array public

Definition at line 445 of file metadata_manager.inc.

getSchemaDefaultValues (   $schemaid,
  $contextid = NULL 
)

Get the default metadata values for a particular schema

Parameters
string$schemaidthe ID of the schema to get default metadata for
int$contextidContext to get the values for (omit for current)
Returns
array public

Definition at line 664 of file metadata_manager.inc.

getSchemas (   $assetid,
  $granted = NULL,
  $cascades = NULL 
)

Get an array of schemaIDs for all schemas applied and denied on an asset

if $granted is null returns Array(schemaid) otherwise returns Array(schemaid => granted[1|0])

Parameters
string$assetidthe ID of the asset to get schemas for
boolean$grantedtype of access : null = all, TRUE = applied, FALSE = denied
Returns
array public

Definition at line 116 of file metadata_manager.inc.

isMetadataFieldAssetid (   $field_assetid)

Returns whether the asset ID being passed into this function is some kind of metadata field asset

Parameters
string$field_assetidthe ID of the metadata field asset
Returns
boolean public

Definition at line 2100 of file metadata_manager.inc.

loadMetadataFile (   $assetid,
  $metadata_filename 
)

Load metadata values, principally from $metadata_filename

Parameters
string$assetid
string$metadata_filename
Returns
Array public

Definition at line 723 of file metadata_manager.inc.

Constructor

Definition at line 37 of file metadata_manager.inc.

purgeMetadata (   $assetid)

Removes the metadata entries for the specified asset

Parameters
string$assetidthe assetid of the asset to purge
Returns
boolean public

Definition at line 1911 of file metadata_manager.inc.

regenerateMetadata (   $assetid,
  $contextid = NULL,
  $update_asset = TRUE 
)

Regenerate both the cached tag metadata and the serialised DB values

If $contextid is NULL, the current context will be used, like usual. However, if $contextid is "all", ALL content files will be generated. This is intended for regenerate metadata HIPOs, or first creation.

Parameters
string$assetidthe ID of the asset to regenerate metadata for
mixed$contextidthe context to regenerate
boolean$update_assetupdate the asset?
Returns
boolean public

Definition at line 1857 of file metadata_manager.inc.

requiredFieldsComplete (   $assetid)

Check if all required fields have been completed for an asset

If no values have been entered, the default schema values are checked

Parameters
string$assetidthe ID of the asset to check
Returns
boolean public

Definition at line 54 of file metadata_manager.inc.

setMetadata (   $assetid,
  $metadata,
  $contextid = NULL,
  $update_asset = TRUE,
  $broadcast_all_fields = FALSE,
  $ignore_editable = FALSE 
)

Set metadata values for an asset

Parameters
string$assetidthe ID of the asset to set the values for
array$metadatathe values to set
int$contextidThe context ID that this metadata setting applies for
boolean$broadcast_all_fieldsIf true, the event "metadata updated" will be broadcasted for all metadata fields
Returns
boolean public

Definition at line 842 of file metadata_manager.inc.

setMetadataFieldDefaultValue (   $field_assetid,
  $value,
  $contextid = NULL 
)

Sets the default value of a certain metadata field asset (as identified by assetid)

Parameters
string$field_assetidthe ID of the metadata field asset
string$valuethe value to be stored
string$contextidthe context that this applies to
Returns
boolean public

Definition at line 2223 of file metadata_manager.inc.

setSchema (   $assetid,
  $schemaid,
  $granted,
  $cascades = TRUE,
  $force_set = FALSE 
)

Apply a schema to or Deny from, an asset

Parameters
string$assetidthe ID of the asset to set the schema on
string$schemaidthe ID of the schema to set
boolean$grantedis this schema applied (TRUE) or denied (FALSE)?
boolean$cascadesdoes this schema cascade to newly created assets?
boolean$force_setif true, existing metadata schemas will be updated regardless of whether or not the new metadata schemas are found to conflict with them
Returns
boolean public

Definition at line 228 of file metadata_manager.inc.


The documentation for this class was generated from the following file: