Class TranscodingAction

Description

TranscodingAction is an abstract class for all the transcoding actions that may be managed by a Transcoder.

A transcoding action is defined within the transcoding library as an action that converts content to match the capabilities of the device that requests the content. The capabilities of the device are retrieved from a DDR Service based on an Evidence. See apply().

The class features a generic pair/value option mechanism that may be used in concrete implementations to fine-tune the behavior of the transcoding action.

The apply() method must be implemented in concrete subclasses.

Located in /common/transcoding/transcodingaction.php (line 41)


	
			
Direct descendents
Class Description
TranscodingActionSwitchTemplate Transcoding action that switches the template to a mobile-friendly template whenever the requesting device is a "mobile" device.
TranscodingActionReplaceEntities Transcoding action that translates HTML entities such as " " by their code equivalent (i.e. " ") when the requesting device supports application/xhtml+xml.
TranscodingActionCSSAdaptation Transcoding action that adapts CSS content to improve content layout on mobile devices.
TranscodingActionPagination Transcoding action that paginates lenghty XHTML content to speed up content delivery on mobile devices with limited bandwidth, and possibly limited memory.
TranscodingActionDeletePopup Transcoding action that updates links to separate windows (i.e. popup windows) so that they open in the same window when the requesting device is a mobile device.
TranscodingActionResizeIMG Transcoding action that resizes images that appear in the given HTML content to match the requesting device's list of supported image formats and screen size.
TranscodingActionDeleteEmbeds Transcoding action that removes embedded elements within the content that are not allowed in XHTML Basic 1.1 when the requesting device is identified as mobile: applet, embed and iframe are removed.
TranscodingActionLineartables Transcoding action that linearizes tables found in XHTML content when the requesting device does not support tables.
TranscodingActionDeleteScript Transcoding action that removes scripts from the given HTML content when the requesting device does not support them.
TranscodingActionDeleteWordpressScripts Transcoding action that removes registered scripts in Wordpress.
Variable Summary
static string $CORE_VOCABULARY
static mixed $WURFL_DEFAULT_ASPECT
static mixed $WURFL_MOBILE_DEVICE
static string $WURFL_VOCABULARY
Method Summary
A __construct (Service $service)
string apply (string $content, Evidence $evidence)
array getNextBlock (string $blocks, string $string, int $offset)
mixed getOption (string $optionName)
PropertyValue getPropertyValue (string $name, string $namespace, string $aspectName)
string getRelativeUri ($base $base, $url $absoluteUri)
void initOption (string $name, mixed $type, mixed $default)
void initProperty (string $name,  $defaultName,  $defaultNamespace,  $defaultAspect)
void initPropertyValues (Evidence $evidence)
string mapAbsoluteUriToFile ($uri $uri, $mappings $mappings)
string mapFileToAbsoluteUri ($fileName $fileName, $mappings $mappings)
string mapFileToUri ($fileName $fileName, $baseUri $baseUri, $mappings $mappings)
string mapUriToFile ($uri $uri, $baseUri $baseUri, $mappings $mappings)
string resolveUri ($base $base, $url $uri)
void setOption (string $optionName, mixed $optionValue)
string unparse_url (array(string) $parsed)
Variables
static string $CORE_VOCABULARY = 'http://www.w3.org/2008/01/ddr-core-vocabulary' (line 45)
  • var: The DDR Core Vocabulary namespace
  • access: public
static mixed $WURFL_DEFAULT_ASPECT = '__NULL' (line 55)
  • access: public
static mixed $WURFL_MOBILE_DEVICE = 'is_wireless_device' (line 54)

Default DDR property reference used to identify mobile devices.

  • access: public
static string $WURFL_VOCABULARY = 'http://wurfl.sourceforge.net' (line 49)
  • var: The Vocabulary that defines the "tableSupport" property.
  • access: public
Methods
Constructor __construct (line 86)

Creates an instance of the transcoding action associated with the given DDR service.

  • return: new transcoding action.
  • exception: SystemException The given service is invalid.
  • access: public
A __construct (Service $service)
  • Service $service: The DDR service to use to retrieve the capabilities of the requesting device.
apply (line 114)

Applies the transcoding action to the given content, using the capabilities of the device identified by the given evidence.

The method must be implemented in concrete subclasses.

  • return: The transcoded content.
  • abstract:
  • exception: SystemException The evidence is not valid.
  • access: public
string apply (string $content, Evidence $evidence)
  • string $content: The content to be modified.
  • Evidence $evidence: The evidence that identifies the requesting device.

Redefined in descendants as:
getNextBlock (line 601)

Retrieves the first block found in the string that matches the given list.

The method requires the blocks being looked upon to be properly nested.

  • return: An array that contains information about the first matched block, NULL when no block was found. Array structure: 0: The extracted block 1: The matched tag name 2: The block's starting offset in the string 3: The block's starting tag 4: The block's ending offset in the string 5: The block's ending tag (may be an empty string if empty tag or if ending tag was not found)
  • access: protected
array getNextBlock (string $blocks, string $string, int $offset)
  • string $blocks: The list of tag names to look for defined in a "RegExp way", e.g.: 'p|div|table'
  • string $string: The string to search
  • int $offset: Position where search should begin in the string
getOption (line 142)

Retrieves a transcoding option.

Options are just a generic pair/value settings mechanisms that may be used in concrete subclasses. In particular, options are not used within this class.

  • return: The option value.
  • exception: SystemException The option does not exist.
  • access: public
mixed getOption (string $optionName)
  • string $optionName: The name of the option.
getPropertyValue (line 194)

Returns the property value of the device identified by a prior call to initPropertyValues() that matches the given local property name, vocabulary IRI and aspect name.

Please note that the underlying DDR Simple API implementation may throw exceptions if the arguments are not valid.

  • return: The property value for the device identified through a prior call to initPropertyValues().
  • exception: SystemException The capabilities have not been properly initialized.
  • access: protected
PropertyValue getPropertyValue (string $name, string $namespace, string $aspectName)
  • string $name: The local property name
  • string $namespace: The vocabulary IRI the property belongs to
  • string $aspectName: The property aspect name
getPropertyValuePr (line 219)

Returns the property value of the device identified by a prior call to initPropertyValues() that matches the given local property name, vocabulary IRI and aspect name.

Please note that the underlying DDR Simple API implementation may throw exceptions if the arguments are not valid.

  • return: The property value for the device identified through a prior call to initPropertyValues().
  • exception: SystemException The capabilities have not been properly initialized.
  • access: protected
PropertyValue getPropertyValuePr (PropertyRef $propRef)
  • PropertyRef $propRef: The reference of the property value to retrieve
getRelativeUri (line 521)

Converts an absolute URI to a URI relative to the given base URI, when possible.

  • return: The relative URI when possible, the original absolute URI otherwise.
  • access: protected
string getRelativeUri ($base $base, $url $absoluteUri)
  • $base $base: The base URI. Must be an absolute URI.
  • $url $absoluteUri: The absolute URI to convert.
initOption (line 279)

Ensures that the given option is defined in the list of options, and is of the appropriate type. Sets the option to the given default value if the option is not in the list of options yet.

  • exception: SystemException Option value found with an invalid type.
  • access: protected
void initOption (string $name, mixed $type, mixed $default)
  • string $name: The option's name.
  • mixed $type: The expected type of the option value.
  • mixed $default: The option's default value if not already set.
initProperty (line 236)

Checks the Check if default values (name, namespace and aspect) are set for a property. If not, then use the default value.

  • access: protected
void initProperty (string $name,  $defaultName,  $defaultNamespace,  $defaultAspect)
  • string $name: The name of the property to initialize
  • $defaultName
  • $defaultNamespace
  • $defaultAspect
initPropertyValues (line 164)

Initializes the list of capabilities of the device identified by the given Evidence.

This method must be called prior to calling getProperty().

Please note that concrete subclasses may choose to interact with the DDR service directly instead of relying on these two methods. In particular, the method is not used within this class.

  • exception: SystemException The evidence is not valid.
  • access: protected
void initPropertyValues (Evidence $evidence)
  • Evidence $evidence: The evidence that identifies the requesting device.
mapAbsoluteUriToFile (line 373)

Converts the given absolute URI to a local file URI, when possible.

  • return: the mapped filename, in absolute form.
  • access: protected
string mapAbsoluteUriToFile ($uri $uri, $mappings $mappings)
  • $uri $uri: string The URI to map. May be absolute or relative.
  • $mappings $mappings: array(string=>string) List of mappings between a root URI and a root folder. The list is tried in the order in which it appears. First possible replacement gets used.
mapFileToAbsoluteUri (line 395)

Converts the given absolute file name to an absolute URI, when possible.

  • return: the mapped URI, in absolute form.
  • access: protected
string mapFileToAbsoluteUri ($fileName $fileName, $mappings $mappings)
  • $fileName $fileName: string The absolute filename to map.
  • $mappings $mappings: array(string=>string) List of mappings between a root URI and a root folder. The list is tried in the order in which it appears. First possible replacement gets used.
mapFileToUri (line 352)

Converts the given filename to a relative or absolute URI when possible.

The relative form, where relative is to the provided base URI, is returned whenever possible. An absolute URI is returned if not.

  • return: The relative/absolute mapped URI if possible, NULL otherwise.
  • access: protected
string mapFileToUri ($fileName $fileName, $baseUri $baseUri, $mappings $mappings)
  • $fileName $fileName: string The absolute full path to the file to map.
  • $baseUri $baseUri: string The base URI to use to compute the returned relative form. An absolute URI is returned when NULL or empty.
  • $mappings $mappings: array(string=>string) List of mappings between a root URI and a root folder. The list is tried in the order in which it appears. First possible replacement gets used.
mapUriToFile (line 326)

Converts the given URI to a local file URI, when possible.

  • return: The file URI is mapping can be done, NULL otherwise.
  • access: protected
string mapUriToFile ($uri $uri, $baseUri $baseUri, $mappings $mappings)
  • $uri $uri: string The URI to map. May be absolute or relative.
  • $baseUri $baseUri: string The base URI to use to resolve the URI to map.
  • $mappings $mappings: array(string=>string) List of mappings between a root URI and a root folder. The list is tried in the order in which it appears. First possible replacement gets used.
resolveUri (line 427)

Resolves a URI against a base URI

The code is based on code provided by: alistair at 21degrees dot com dot au in the comments of http://fr2.php.net/manual/fr/function.parse-url.php and patched by: adrian-php at sixfingeredman dot net

This implementation more or less follows the "5.2 Resolving Relative References to Absolute Form" section of RFC 2395.

  • return: The resolved absolute URI
  • access: protected
string resolveUri ($base $base, $url $uri)
  • $base $base: The base URI. Must be an absolute URI.
  • $url $uri: The URI to resolve. The URI may be an absolute or a relative URI.
setOption (line 127)

Sets a transcoding option.

Options are just a generic pair/value settings mechanisms that may be used in concrete subclasses. In particular, options are not used within this class.

  • access: public
void setOption (string $optionName, mixed $optionValue)
  • string $optionName: The name of the option.
  • mixed $optionValue: The value of the option.
unparse_url (line 559)

Converts a URI previously splitted through a call to parse_url back to an absolute form.

  • return: The URI represented by the parsed entity
  • access: protected
string unparse_url (array(string) $parsed)
  • array(string) $parsed: The parsed URI

Documentation generated on Tue, 17 Nov 2009 19:00:40 +0100 by phpDocumentor 1.4.2