Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

Author: Nicola Asuni
Version: 1.0.008
File Size: 1176 lines (43 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Datamatrix  - X-Ref


__construct($code)   X-Ref
This is the class constructor.
Creates a datamatrix object

param: string $code Code to represent using Datamatrix.

getBarcodeArray()   X-Ref
Returns a barcode array which is readable by TCPDF

return: array barcode array readable by TCPDF;

getGFProduct($a, $b, $log, $alog, $gf)   X-Ref
Product of two numbers in a Power-of-Two Galois Field

param: int $a first number to multiply.
param: int $b second number to multiply.
param: array $log Log table.
param: array $alog Anti-Log table.
param: int $gf Number of Factors of the Reed-Solomon polynomial.
return: int product

getErrorCorrection($wd, $nb, $nd, $nc, $gf=256, $pp=301)   X-Ref
Add error correction codewords to data codewords array (ANNEX E).

param: array $wd Array of datacodewords.
param: int $nb Number of blocks.
param: int $nd Number of data codewords per block.
param: int $nc Number of correction codewords per block.
param: int $gf numner of fields on log/antilog table (power of 2).
param: int $pp The value of its prime modulus polynomial (301 for ECC200).
return: array data codewords + error codewords

get253StateCodeword($cwpad, $cwpos)   X-Ref
Return the 253-state codeword

param: int $cwpad Pad codeword.
param: int $cwpos Number of data codewords from the beginning of encoded data.
return: int pad codeword

get255StateCodeword($cwpad, $cwpos)   X-Ref
Return the 255-state codeword

param: int $cwpad Pad codeword.
param: int $cwpos Number of data codewords from the beginning of encoded data.
return: int pad codeword

isCharMode($chr, $mode)   X-Ref
Returns true if the char belongs to the selected mode

param: int $chr Character (byte) to check.
param: int $mode Current encoding mode.
return: boolean true if the char is of the selected mode.

lookAheadTest($data, $pos, $mode)   X-Ref
The look-ahead test scans the data to be encoded to find the best mode (Annex P - steps from J to S).

param: string $data data to encode
param: int $pos current position
param: int $mode current encoding mode
return: int encoding mode

getSwitchEncodingCodeword($mode)   X-Ref
Get the switching codeword to a new encoding mode (latch codeword)

param: int $mode New encoding mode.
return: int Switch codeword.

getMaxDataCodewords($numcw)   X-Ref
Choose the minimum matrix size and return the max number of data codewords.

param: int $numcw Number of current codewords.
return: int number of data codewords in matrix

getHighLevelEncoding($data)   X-Ref
Get high level encoding using the minimum symbol data characters for ECC 200

param: string $data data to encode
return: array of codewords

placeModule($marr, $nrow, $ncol, $row, $col, $chr, $bit)   X-Ref
Places "chr+bit" with appropriate wrapping within array[].
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $row Row number.
param: int $col Column number.
param: int $chr Char byte.
param: int $bit Bit.
return: array

placeUtah($marr, $nrow, $ncol, $row, $col, $chr)   X-Ref
Places the 8 bits of a utah-shaped symbol character.
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $row Row number.
param: int $col Column number.
param: int $chr Char byte.
return: array

placeCornerA($marr, $nrow, $ncol, $chr)   X-Ref
Places the 8 bits of the first special corner case.
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $chr Char byte.
return: array

placeCornerB($marr, $nrow, $ncol, $chr)   X-Ref
Places the 8 bits of the second special corner case.
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $chr Char byte.
return: array

placeCornerC($marr, $nrow, $ncol, $chr)   X-Ref
Places the 8 bits of the third special corner case.
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $chr Char byte.
return: array

placeCornerD($marr, $nrow, $ncol, $chr)   X-Ref
Places the 8 bits of the fourth special corner case.
(Annex F - ECC 200 symbol character placement)

param: array $marr Array of symbols.
param: int $nrow Number of rows.
param: int $ncol Number of columns.
param: int $chr Char byte.
return: array

getPlacementMap($nrow, $ncol)   X-Ref
Build a placement map.
(Annex F - ECC 200 symbol character placement)

param: int $nrow Number of rows.
param: int $ncol Number of columns.
return: array