Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Class to create QR-code arrays for TCPDF class. More...
Public Member Functions | |
__construct ($code, $eclevel='L') | |
This is the class constructor. | |
getBarcodeArray () | |
Returns a barcode array which is readable by TCPDF. | |
Protected Member Functions | |
allocate ($setLength) | |
Return an array with zeros. | |
appendBitstream ($bitstream, $append) | |
Append one bitstream to another. | |
appendBytes ($bitstream, $size, $data) | |
Append one bitstream created from bytes to another. | |
appendNewInputItem ($items, $mode, $size, $data) | |
Append data to an input object. | |
appendNum ($bitstream, $bits, $num) | |
Append one bitstream created from number to another. | |
appendPaddingBit ($bstream) | |
Append Padding Bit to bitstream. | |
binarize ($frame) | |
Convert the frame in binary form. | |
bitstreamToByte ($bstream) | |
Convert bitstream to bytes. | |
calcN1N3 ($length) | |
calcN1N3 | |
calcParity ($items) | |
calcParity | |
check ($mode, $size, $data) | |
Validate the input data. | |
checkModeAn ($size, $data) | |
checkModeAn | |
checkModeKanji ($size, $data) | |
checkModeKanji | |
checkModeNum ($size, $data) | |
checkModeNum | |
convertData ($items) | |
convertData | |
createBitStream ($items) | |
createBitStream | |
createFrame ($version) | |
Return a copy of initialized frame. | |
eat8 () | |
eat8 | |
eatAn () | |
eatAn | |
eatKanji () | |
eatKanji | |
eatNum () | |
eatNum | |
encode_rs_char ($rs, $data, $parity) | |
Encode a Reed-Solomon codec and returns the parity array. | |
encodeBitStream ($inputitem, $version) | |
encodeBitStream | |
encodeMask ($mask) | |
Encode mask. | |
encodeMode8 ($inputitem, $version) | |
encodeMode8 | |
encodeModeAn ($inputitem, $version) | |
encodeModeAn | |
encodeModeKanji ($inputitem, $version) | |
encodeModeKanji | |
encodeModeNum ($inputitem, $version) | |
encodeModeNum | |
encodeModeStructure ($inputitem) | |
encodeModeStructure | |
encodeString ($string) | |
Encode the input string to QR code. | |
estimateBitsMode8 ($size) | |
estimateBitsMode8 | |
estimateBitsModeAn ($size) | |
estimateBitsModeAn | |
estimateBitsModeKanji ($size) | |
estimateBitsModeKanji | |
estimateBitsModeNum ($size) | |
estimateBitsModeNum | |
estimateBitStreamSize ($items, $version) | |
estimateBitStreamSize | |
estimateVersion ($items) | |
estimateVersion | |
evaluateSymbol ($width, $frame) | |
evaluateSymbol | |
generateMaskNo ($maskNo, $width, $frame) | |
Return bitmask. | |
getBitStream ($items) | |
Returns a stream of bits. | |
getByteStream ($items) | |
Pack all bit streams padding bits into a byte array. | |
getCode () | |
Return Reed-Solomon block code. | |
getDataLength ($version, $level) | |
Return maximum data code length (bytes) for the version. | |
getECCLength ($version, $level) | |
Return maximum error correction code length (bytes) for the version. | |
getEccSpec ($version, $level, $spec) | |
Return an array of ECC specification. | |
getFormatInfo ($mask, $level) | |
Return BCH encoded format information pattern. | |
getFrameAt ($at) | |
Get frame value at specified position. | |
getMinimumVersion ($size, $level) | |
Return a version number that satisfies the input code length. | |
getNextPosition () | |
Return the next frame position. | |
getRemainder ($version) | |
Return the numer of remainder bits. | |
getVersionPattern ($version) | |
Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. | |
getWidth ($version) | |
Return the width of the symbol for the version. | |
identifyMode ($pos) | |
identifyMode | |
init ($spec) | |
Initialize code. | |
init_rs ($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) | |
Initialize a Reed-Solomon codec and add it to existing rsitems. | |
init_rs_char ($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) | |
Initialize a Reed-Solomon codec and returns an array of values. | |
insertStructuredAppendHeader ($items, $size, $index, $parity) | |
insertStructuredAppendHeader | |
isalnumat ($str, $pos) | |
Return true if the character at specified position is an alphanumeric character. | |
isdigitat ($str, $pos) | |
Return true if the character at specified position is a number. | |
lengthIndicator ($mode, $version) | |
Return the size of length indicator for the mode and version. | |
lengthOfCode ($mode, $version, $bits) | |
lengthOfCode | |
lookAnTable ($c) | |
Look up the alphabet-numeric conversion table (see JIS X0510:2004, pp.19). | |
makeMask ($width, $frame, $maskNo, $level) | |
makeMask | |
makeMaskNo ($maskNo, $width, $s, &$d, $maskGenOnly=false) | |
makeMaskNo | |
mask ($width, $frame, $level) | |
mask | |
mask0 ($x, $y) | |
mask0 | |
mask1 ($x, $y) | |
mask1 | |
mask2 ($x, $y) | |
mask2 | |
mask3 ($x, $y) | |
mask3 | |
mask4 ($x, $y) | |
mask4 | |
mask5 ($x, $y) | |
mask5 | |
mask6 ($x, $y) | |
mask6 | |
mask7 ($x, $y) | |
mask7 | |
maximumWords ($mode, $version) | |
Return the maximum length for the mode and version. | |
mergeBitStream ($items) | |
mergeBitStream | |
modnn ($rs, $x) | |
modnn | |
newFrame ($version) | |
Set new frame for the specified version. | |
newFromBytes ($size, $data) | |
Return new bitstream from bytes. | |
newFromNum ($bits, $num) | |
Return new bitstream from number. | |
newInputItem ($mode, $size, $data, $bstream=null) | |
newInputItem | |
putAlignmentMarker ($frame, $ox, $oy) | |
Put an alignment marker. | |
putAlignmentPattern ($version, $frame, $width) | |
Put an alignment pattern. | |
putFinderPattern ($frame, $ox, $oy) | |
Put a finder pattern. | |
qrstrset ($srctab, $x, $y, $repl, $replLen=false) | |
Replace a value on the array at the specified position. | |
rsBlockNum ($spec) | |
Return block number 0. | |
rsBlockNum1 ($spec) | |
Return block number 1. | |
rsBlockNum2 ($spec) | |
Return block number 2. | |
rsDataCodes1 ($spec) | |
Return data codes 1. | |
rsDataCodes2 ($spec) | |
Return data codes 2. | |
rsDataLength ($spec) | |
Return data length. | |
rsEccCodes1 ($spec) | |
Return ecc codes 1. | |
rsEccCodes2 ($spec) | |
Return ecc codes 2. | |
rsEccLength ($spec) | |
Return ecc length. | |
setFrameAt ($at, $val) | |
Set frame value at specified position. | |
splitString () | |
splitString | |
toUpper () | |
toUpper | |
writeFormatInformation ($width, &$frame, $mask, $level) | |
Write Format Information on frame and returns the number of black bits. | |
Protected Attributes | |
$alignmentPattern | |
Array Positions of alignment patterns. | |
$anTable | |
Alphabet-numeric convesion table. | |
$b1 | |
Value b1. | |
$barcode_array = array() | |
Barcode array to be returned which is readable by TCPDF. | |
$bit | |
Single bit value. | |
$blocks | |
Blocks. | |
$capacity | |
Array Table of the capacity of symbols. | |
$casesensitive = true | |
Boolean flag, if true the input string will be converted to uppercase. | |
$count | |
Counter. | |
$data | |
Mask data. | |
$datacode = array() | |
Data code. | |
$dataLength | |
Data length. | |
$dataStr = '' | |
Input data string. | |
$dir | |
Direction. | |
$ecccode = array() | |
Error correction code. | |
$eccLength | |
Error correction length. | |
$eccTable | |
Array Table of the error correction code (Reed-Solomon block). | |
$formatInfo | |
Array Format information. | |
$frame | |
Frame. | |
$frames = array() | |
Array of frames. | |
$hint = QR_MODE_8B | |
Encoding mode. | |
$items | |
Input items. | |
$lengthTableBits | |
Array Length indicator. | |
$level = QR_ECLEVEL_L | |
Levels of error correction. | |
$rsblocks = array() | |
Reed-Solomon blocks. | |
$rsitems = array() | |
Reed-Solomon items. | |
$runLength = array() | |
Run length. | |
$structured = 0 | |
Structured QR code (not supported yet). | |
$version = 0 | |
QR code version. | |
$versionPattern | |
Array Version information pattern (BCH coded). | |
$width | |
Width. | |
$x | |
X position of bit. | |
$y | |
Y position of bit. | |
Class to create QR-code arrays for TCPDF class.
QR Code symbol is a 2D barcode that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness. This class supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1, Structured mode.
This class is derived from "PHP QR Code encoder" by Dominik Dzienia (http://phpqrcode.sourceforge.net/) based on "libqrencode C library 3.1.1." by Kentaro Fukuchi (http://megaui.net/fukuchi/works/qrencode/index.en.html), contains Reed-Solomon code written by Phil Karn, KA9Q. QR Code is registered trademark of DENSO WAVE INCORPORATED (http://www.denso-wave.com/qrcode/index-e.html). Please read comments on this class source file for full copyright and license information.
..
QRcode::__construct | ( | $code, | |
$eclevel = 'L' ) |
This is the class constructor.
Creates a QRcode object
string | $code | code to represent using QRcode |
string | $eclevel | error level:
|
|
protected |
Return an array with zeros.
int | $setLength | array size |
array |
|
protected |
Append one bitstream to another.
array | $bitstream | original bitstream |
array | $append | bitstream to append |
array | bitstream |
|
protected |
Append one bitstream created from bytes to another.
array | $bitstream | original bitstream |
int | $size | size |
array | $data | bytes |
array | bitstream |
|
protected |
Append data to an input object.
The data is copied and appended to the input object.
array | $items | input items |
int | $mode | encoding mode. |
int | $size | size of data (byte). |
array | $data | array of input data. |
array | items |
|
protected |
Append one bitstream created from number to another.
array | $bitstream | original bitstream |
int | $bits | number of bits |
int | $num | number |
array | bitstream |
|
protected |
Append Padding Bit to bitstream.
array | $bstream |
array | bitstream |
|
protected |
Convert the frame in binary form.
array | $frame | array to binarize |
array | frame in binary form |
|
protected |
Convert bitstream to bytes.
array | $bstream | original bitstream |
array | of bytes |
|
protected |
calcN1N3
int | $length |
int | demerit |
|
protected |
calcParity
array | $items |
int | parity |
|
protected |
Validate the input data.
int | $mode | encoding mode. |
int | $size | size of data (byte). |
array | $data | data to validate |
boolean | true in case of valid data, false otherwise |
|
protected |
checkModeAn
int | $size | |
array | $data |
boolean | true or false |
|
protected |
checkModeKanji
int | $size | |
array | $data |
boolean | true or false |
|
protected |
checkModeNum
int | $size | |
array | $data |
boolean | true or false |
|
protected |
convertData
array | $items |
array | items |
|
protected |
createBitStream
array | $items |
array | of items and total bits |
|
protected |
Return a copy of initialized frame.
int | $version | version |
array | array of unsigned char. |
|
protected |
eat8
int | run |
|
protected |
eatAn
int | run |
|
protected |
eatKanji
int | run |
|
protected |
eatNum
int | run |
|
protected |
Encode a Reed-Solomon codec and returns the parity array.
array | $rs | RS values |
array | $data | data |
array | $parity | parity |
parity | array |
|
protected |
encodeBitStream
array | $inputitem | |
int | $version |
array | input item |
|
protected |
Encode mask.
int | $mask | masking mode |
|
protected |
encodeMode8
array | $inputitem | |
int | $version |
array | input item |
|
protected |
encodeModeAn
array | $inputitem | |
int | $version |
array | input item |
|
protected |
encodeModeKanji
array | $inputitem | |
int | $version |
array | input item |
|
protected |
encodeModeNum
array | $inputitem | |
int | $version |
array | input item |
|
protected |
encodeModeStructure
array | $inputitem |
array | input item |
|
protected |
Encode the input string to QR code.
string | $string | input string to encode |
|
protected |
estimateBitsMode8
int | $size |
int | number of bits |
|
protected |
estimateBitsModeAn
int | $size |
int | number of bits |
|
protected |
estimateBitsModeKanji
int | $size |
int | number of bits |
|
protected |
estimateBitsModeNum
int | $size |
int | number of bits |
|
protected |
estimateBitStreamSize
array | $items | |
int | $version |
int | bits |
|
protected |
estimateVersion
array | $items |
int | version |
|
protected |
evaluateSymbol
int | $width | |
array | $frame |
int | demerit |
|
protected |
Return bitmask.
int | $maskNo | mask number |
int | $width | width |
array | $frame | frame |
array | bitmask |
QRcode::getBarcodeArray | ( | ) |
Returns a barcode array which is readable by TCPDF.
array | barcode array readable by TCPDF; |
|
protected |
Returns a stream of bits.
int | $items |
array | padded merged byte stream |
|
protected |
Pack all bit streams padding bits into a byte array.
int | $items |
array | padded merged byte stream |
|
protected |
Return Reed-Solomon block code.
array | rsblocks |
|
protected |
Return maximum data code length (bytes) for the version.
int | $version | version |
int | $level | error correction level |
int | maximum size (bytes) |
|
protected |
Return maximum error correction code length (bytes) for the version.
int | $version | version |
int | $level | error correction level |
int | ECC size (bytes) |
|
protected |
Return an array of ECC specification.
int | $version | version |
int | $level | error correction level |
array | $spec | an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} |
array | spec |
|
protected |
Return BCH encoded format information pattern.
array | $mask | |
int | $level | error correction level |
string | BCH encoded format information pattern |
|
protected |
Get frame value at specified position.
array | $at | x,y position |
value | at specified position |
|
protected |
Return a version number that satisfies the input code length.
int | $size | input code length (bytes) |
int | $level | error correction level |
int | version number |
|
protected |
Return the next frame position.
array | of x,y coordinates |
|
protected |
Return the numer of remainder bits.
int | $version | version |
int | number of remainder bits |
|
protected |
Return BCH encoded version information pattern that is used for the symbol of version 7 or greater.
Use lower 18 bits.
int | $version | version |
string | BCH encoded version information pattern |
|
protected |
Return the width of the symbol for the version.
int | $version | version |
int | width |
|
protected |
identifyMode
int | $pos |
int | mode |
|
protected |
Initialize code.
array | $spec | array of ECC specification |
int | 0 in case of success, -1 in case of error |
|
protected |
Initialize a Reed-Solomon codec and add it to existing rsitems.
int | $symsize | symbol size, bits |
int | $gfpoly | Field generator polynomial coefficients |
int | $fcr | first root of RS code generator polynomial, index form |
int | $prim | primitive element to generate polynomial roots |
int | $nroots | RS code generator polynomial degree (number of roots) |
int | $pad | padding bytes at front of shortened block |
array | Array of RS values:
|
|
protected |
Initialize a Reed-Solomon codec and returns an array of values.
int | $symsize | symbol size, bits |
int | $gfpoly | Field generator polynomial coefficients |
int | $fcr | first root of RS code generator polynomial, index form |
int | $prim | primitive element to generate polynomial roots |
int | $nroots | RS code generator polynomial degree (number of roots) |
int | $pad | padding bytes at front of shortened block |
array | Array of RS values:
|
|
protected |
insertStructuredAppendHeader
array | $items | |
int | $size | |
int | $index | |
int | $parity |
array | items |
|
protected |
Return true if the character at specified position is an alphanumeric character.
string | $str | string |
int | $pos | characted position |
boolean | true of false |
|
protected |
Return true if the character at specified position is a number.
string | $str | string |
int | $pos | characted position |
boolean | true of false |
|
protected |
Return the size of length indicator for the mode and version.
int | $mode | encoding mode |
int | $version | version |
int | the size of the appropriate length indicator (bits). |
|
protected |
lengthOfCode
int | $mode | |
int | $version | |
int | $bits |
int | size |
|
protected |
Look up the alphabet-numeric conversion table (see JIS X0510:2004, pp.19).
int | $c | character value |
int | value |
|
protected |
makeMask
int | $width | |
array | $frame | |
int | $maskNo | |
int | $level |
array | mask |
|
protected |
makeMaskNo
int | $maskNo | |
int | $width | |
int | $s | |
int | $d | |
boolean | $maskGenOnly |
int | b |
|
protected |
mask
int | $width | |
array | $frame | |
int | $level |
array | best mask |
|
protected |
mask0
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask1
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask2
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask3
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask4
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask5
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask6
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
mask7
int | $x | X position |
int | $y | Y position |
int | mask |
|
protected |
Return the maximum length for the mode and version.
int | $mode | encoding mode |
int | $version | version |
int | the maximum length (bytes) |
|
protected |
mergeBitStream
array | $items | items |
array | bitstream |
|
protected |
modnn
array | $rs | RS values |
int | $x | X position |
int | X osition |
|
protected |
Set new frame for the specified version.
int | $version | version |
array | array of unsigned char. |
|
protected |
Return new bitstream from bytes.
int | $size | size |
array | $data | bytes |
array | bitstream |
|
protected |
Return new bitstream from number.
int | $bits | number of bits |
int | $num | number |
array | bitstream |
|
protected |
newInputItem
int | $mode | |
int | $size | |
array | $data | |
array | $bstream |
array | input item |
|
protected |
Put an alignment marker.
array | $frame | frame |
int | $ox | X center coordinate of the pattern |
int | $oy | Y center coordinate of the pattern |
array | frame |
|
protected |
Put an alignment pattern.
int | $version | version |
array | $frame | frame |
int | $width | width |
array | frame |
|
protected |
Put a finder pattern.
array | $frame | frame |
int | $ox | X center coordinate of the pattern |
int | $oy | Y center coordinate of the pattern |
array | frame |
|
protected |
Replace a value on the array at the specified position.
array | $srctab | |
int | $x | X position |
int | $y | Y position |
string | $repl | value to replace |
int | $replLen | length of the repl string |
array | srctab |
|
protected |
Return block number 0.
array | $spec |
int | value |
|
protected |
Return block number 1.
array | $spec |
int | value |
|
protected |
Return block number 2.
array | $spec |
int | value |
|
protected |
Return data codes 1.
array | $spec |
int | value |
|
protected |
Return data codes 2.
array | $spec |
int | value |
|
protected |
Return data length.
array | $spec |
int | value |
|
protected |
Return ecc codes 1.
array | $spec |
int | value |
|
protected |
Return ecc codes 2.
array | $spec |
int | value |
|
protected |
Return ecc length.
array | $spec |
int | value |
|
protected |
Set frame value at specified position.
array | $at | x,y position |
int | $val | value of the character to set |
|
protected |
splitString
int |
|
protected |
Write Format Information on frame and returns the number of black bits.
int | $width | frame width |
array | $frame | frame |
array | $mask | masking mode |
int | $level | error correction level |
int | blacks |
|
protected |
Array Positions of alignment patterns.
This array includes only the second and the third position of the alignment patterns. Rest of them can be calculated from the distance between them. See Table 1 in Appendix E (pp.71) of JIS X0510:2004.
|
protected |
Alphabet-numeric convesion table.
|
protected |
Array Table of the capacity of symbols.
See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004.
|
protected |
Array Table of the error correction code (Reed-Solomon block).
See Table 12-16 (pp.30-36), JIS X0510:2004.
|
protected |
Array Format information.
|
protected |
Array Length indicator.
|
protected |
Levels of error correction.
See definitions for possible values.
|
protected |
QR code version.
Size of QRcode is defined as version. Version is from 1 to 40. Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. So version 40 is 177*177 matrix.
|
protected |
Array Version information pattern (BCH coded).
See Table 1 in Appendix D (pp.68) of JIS X0510:2004. size: [QRSPEC_VERSION_MAX - 6]