eZPublish  4.7
eZCodeMapper Class Reference

Handles mapping of character codes. More...

Public Member Functions

 decodeCommand ($name, $parameters)
 
 error ($text, $position=false)
 
 executeCommandCode (&$text, $command, $charsetName)
 
 eZCodeMapper ()
 
 generateCharsetMappingTable ($unicodeTable, $charset)
 
 generateCommandCode ($command, $charsetName)
 
 generateMappingCode ($identifier)
 
 generateSimpleMappingTable ($table, $allowedRanges)
 
 isTranformationLoaded ($name)
 
 loadTransformationFiles ($currentCharset, $transformationGroup)
 
 mapOrdinals ($table, $ordinals)
 
 mappingTable ($identifier)
 
 nonCJKCharsets ()
 
 ordinalValues ($table, $list)
 
 parseTransformationFile ($filename, $name)
 
 ruleNames ()
 
 warning ($text, $position=false)
 

Public Attributes

 $ISOUnicodeCodec
 
 $TransformationFiles
 
 $TransformationTables
 
const TYPE_DIRECT = 1
 
const TYPE_RANGE = 2
 
const TYPE_REPLACE = 3
 

Protected Member Functions

 mapExistingCodes ($unicodeMap, $fromCode, $toCode)
 

Private Member Functions

 appendDirectMapping (&$block, $identifier, $sourceValue, $destinationValues)
 
 appendReplaceMapping (&$block, $identifier, $sourceValue, $sourceEndValue, $destinationValues)
 
 appendTransposeMapping (&$block, $identifier, $sourceValue, $sourceEndValue, $transposeValue, $addValue, $moduloValue)
 
 expandInheritance ($table)
 
 extractUnicodeValue ($data)
 
 extractUnicodeValues ($data)
 

Detailed Description

Handles mapping of character codes.

Member Function Documentation

eZCodeMapper::appendDirectMapping ( $block,
  $identifier,
  $sourceValue,
  $destinationValues 
)
private

Appends a mapping from one value to another.

Parameters
$blockCurrent block it is working on
$identifierThe current identifier it is working on
$sourceValueThe original value
$destinationValuesThe value it should be mapped to

Referenced by parseTransformationFile().

eZCodeMapper::appendReplaceMapping ( $block,
  $identifier,
  $sourceValue,
  $sourceEndValue,
  $destinationValues 
)
private

Appends a mapping for a range of values into a specific value

Parameters
$blockCurrent block it is working on
$identifierThe current identifier it is working on
$sourceValueThe start of the original value
$sourceEndValueThe ned of the original value
$destinationValuesThe value it should be mapped to

Referenced by parseTransformationFile().

eZCodeMapper::appendTransposeMapping ( $block,
  $identifier,
  $sourceValue,
  $sourceEndValue,
  $transposeValue,
  $addValue,
  $moduloValue 
)
private

Appends a mapping for characters by transposing them up or down.

Parameters
$blockCurrent block it is working on
$identifierThe current identifier it is working on
$sourceValueThe start of the original value
$sourceEndValueThe ned of the original value
$transposeValueHow much to transpose the values
$addValueIf true the $transposeValue is added to the range if not it is subtracted.

Referenced by parseTransformationFile().

eZCodeMapper::decodeCommand (   $name,
  $parameters 
)

Decodes a command into transformation rules.

Parameters
$nameName of the command
$parametersArray of parameters for the command
Returns
An array with transformation rules.
eZCodeMapper::error (   $text,
  $position = false 
)

Outputs error $text found in parsed file at position $position.

Referenced by parseTransformationFile().

eZCodeMapper::executeCommandCode ( $text,
  $command,
  $charsetName 
)

Executes custom PHP code for the command $command.

Parameters
$charsetNameThe name of the charset the text will be in, this can be used to execute different code for different charsets.
Returns
true if the command is supported, false otherwise.
eZCodeMapper::expandInheritance (   $table)
private

Goes trough all entries in $table and if it finds identifier references it will fetch the table for that identifier and merge in the current one.

Returns
The expanded table.

Referenced by generateMappingCode().

eZCodeMapper::extractUnicodeValue (   $data)
private
Returns
The first unicod value for the data entry $data.

Referenced by parseTransformationFile().

eZCodeMapper::extractUnicodeValues (   $data)
private
Returns
The unicode values for the data entry $data.

Referenced by parseTransformationFile().

eZCodeMapper::eZCodeMapper ( )

Constructor

eZCodeMapper::generateCharsetMappingTable (   $unicodeTable,
  $charset 
)

Generates a mapping table for the character set $charset. This will mapping table will only work for that character set but will be much faster and be fed directly to the strtr() PHP function.

Returns
the table or false if something failed.
eZCodeMapper::generateCommandCode (   $command,
  $charsetName 
)

Generates PHP code for the command $command.

Parameters
$charsetNameThe name of the charset the text will be in, this can be used to generate different code for different charsets.
Returns
A string containing PHP code or false if not supported.
eZCodeMapper::generateMappingCode (   $identifier)

Generates a unicode mapping table for idenfier $idenfier.

Parameters
$identifierIs either a single identifier string or a an array with identifiers.
Returns
The unicode mapping table for all defined identifiers
eZCodeMapper::generateSimpleMappingTable (   $table,
  $allowedRanges 
)

Goes trough the mapping rules in the table $table and generates a simple mapping table which maps from one Unicode value to another (or array of values).

The generation uses backward and forward propagation of the defined mappings to get the proper end result of a given value.

Note
This method can take a while if lots of rules are used

Referenced by generateMappingCode().

eZCodeMapper::isTranformationLoaded (   $name)
Returns
true if the transformation file is already loaded.

Referenced by loadTransformationFiles().

eZCodeMapper::loadTransformationFiles (   $currentCharset,
  $transformationGroup 
)

Loads all transformation files defined in transform.ini to the current mapper. It will also load any transformations found in extensions.

Parameters
$currentCharsetThe name of the current charset in use. The caller must make sure this is not an alias by using eZCharsetInfo::realCharsetCode()
$transformationGroupThe transformation group which is currently used or false for none.
eZCodeMapper::mapExistingCodes (   $unicodeMap,
  $fromCode,
  $toCode 
)
protected

Goes trough all to codes in the mapping table $unicodeMap and maps those that match $fromCode into $toCode.

Returns
$unicodeMap

Referenced by generateSimpleMappingTable().

eZCodeMapper::mapOrdinals (   $table,
  $ordinals 
)

Goes trough each ordinal in $ordinals and sees if there is mapping for it. If it is the mapping is applied and used as the new ordinal, if the mapping refers to an array it will be mapped recursively.

Referenced by ordinalValues().

eZCodeMapper::mappingTable (   $identifier)
Returns
The mapping table for identifier $identifier or false if it is not found.

Referenced by expandInheritance().

eZCodeMapper::nonCJKCharsets ( )
Returns
An array with charsets that are certain to not contain CJK characters.

Referenced by executeCommandCode(), and generateCommandCode().

eZCodeMapper::ordinalValues (   $table,
  $list 
)

Turns the character list $list into an array with ordinal values

Parameters
$listCan be on of these types:
  • String - each character is turned into an ordinal value
  • Numeric - the numeric is used as ordinal value
  • Boolean - means no character
  • Array - each element is turned into an ordinal value by recursion

Referenced by generateSimpleMappingTable().

eZCodeMapper::parseTransformationFile (   $filename,
  $name 
)

Parses the transformation file $filename and appends any rules it finds to the current rule list.

Parameters
$nameThe name of transformation file as it was requested, ie. without a path

Referenced by loadTransformationFiles().

eZCodeMapper::ruleNames ( )
Returns
An array with the names of rules which are currently available.

Referenced by decodeCommand().

eZCodeMapper::warning (   $text,
  $position = false 
)

Outputs warning $text found in parsed file at position $position.

Referenced by parseTransformationFile().

Member Data Documentation

eZCodeMapper::$ISOUnicodeCodec
eZCodeMapper::$TransformationFiles
eZCodeMapper::$TransformationTables
const eZCodeMapper::TYPE_DIRECT = 1
const eZCodeMapper::TYPE_RANGE = 2
const eZCodeMapper::TYPE_REPLACE = 3

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