Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(no description)

Author: Nicola Asuni
Version: 1.1.2
File Size: 2650 lines (110 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: TCPDF_STATIC  - X-Ref


getTCPDFVersion()   X-Ref
Return the current TCPDF version.

return: TCPDF version string

getTCPDFProducer()   X-Ref
Return the current TCPDF producer.

return: TCPDF producer string

set_mqr($mqr)   X-Ref
Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtime function exist)

param: $mqr (boolean) FALSE for off, TRUE for on.

get_mqr()   X-Ref
Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtime function exist)

return: Returns 0 if magic quotes runtime is off or get_magic_quotes_runtime doesn't exist, 1 otherwise.

isValidURL($url)   X-Ref
Check if the URL exist.

return: Boolean true if the URl exist, false otherwise.
param: $url (string) URL to check.

removeSHY($txt='', $unicode=true)   X-Ref
Removes SHY characters from text.
Unicode Data:<ul>
<li>Name : SOFT HYPHEN, commonly abbreviated as SHY</li>
<li>HTML Entity (decimal): "&amp;#173;"</li>
<li>HTML Entity (hex): "&amp;#xad;"</li>
<li>HTML Entity (named): "&amp;shy;"</li>
<li>How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173]</li>
<li>UTF-8 (hex): 0xC2 0xAD (c2ad)</li>
<li>UTF-8 character: chr(194).chr(173)</li>
</ul>

return: string without SHY characters.
param: $txt (string) input string
param: $unicode (boolean) True if we are in unicode mode, false otherwise.

getBorderMode($brd, $position='start', $opencell=true)   X-Ref
Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages)

return: border mode array
param: $brd (mixed) Indicates if borders must be drawn around the cell block. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
param: $position (string) multicell position: 'start', 'middle', 'end'
param: $opencell (boolean) True when the cell is left open at the page bottom, false otherwise.

empty_string($str)   X-Ref
Determine whether a string is empty.

return: bool true if string is empty
param: $str (string) string to be checked

getObjFilename($type='tmp', $file_id='')   X-Ref
Returns a temporary filename for caching object on filesystem.

return: string filename.
param: $type (string) Type of file (name of the subdir on the tcpdf cache folder).
param: $file_id (string) TCPDF file_id.

_escape($s)   X-Ref
Add "\" before "\", "(" and ")"

return: string escaped string.
param: $s (string) string to escape.

_escapeXML($str)   X-Ref
Escape some special characters (&lt; &gt; &amp;) for XML output.

return: converted string
param: $str (string) Input string to convert.

objclone($object)   X-Ref
Creates a copy of a class object

return: cloned object
param: $object (object) class object to be cloned

sendOutputData($data, $length)   X-Ref
Output input data and compress it if possible.

param: $data (string) Data to output.
param: $length (int) Data length in bytes.

replacePageNumAliases($page, $replace, $diff=0)   X-Ref
Replace page number aliases with number.

return: replaced page content and updated $diff parameter as array.
param: $page (string) Page content.
param: $replace (array) Array of replacements (array keys are replacement strings, values are alias arrays).
param: $diff (int) If passed, this will be set to the total char number difference between alias and replacements.

getTimestamp($date)   X-Ref
Returns timestamp in seconds from formatted date-time.

return: int seconds.
param: $date (string) Formatted date-time.

getFormattedDate($time)   X-Ref
Returns a formatted date-time.

return: string escaped date string.
param: $time (int) Time in seconds.

getRandomSeed($seed='')   X-Ref
Returns a string containing random data to be used as a seed for encryption methods.

author: Nicola Asuni
return: string containing random data
param: $seed (string) starting seed value

_md5_16($str)   X-Ref
Encrypts a string using MD5 and returns it's value as a binary string.

return: String MD5 encrypted binary string
param: $str (string) input string

_AES($key, $text)   X-Ref
Returns the input text exrypted using AES algorithm and the specified key.
This method requires openssl or mcrypt. Text is padded to 16bytes blocks

author: Nicola Asuni
return: String encrypted text
param: $key (string) encryption key
param: $text (String) input text to be encrypted

_AESnopad($key, $text)   X-Ref
Returns the input text exrypted using AES algorithm and the specified key.
This method requires openssl or mcrypt. Text is not padded

author: Nicola Asuni
return: String encrypted text
param: $key (string) encryption key
param: $text (String) input text to be encrypted

_RC4($key, $text, &$last_enc_key, &$last_enc_key_c)   X-Ref
Returns the input text encrypted using RC4 algorithm and the specified key.
RC4 is the standard encryption algorithm used in PDF format

author: Klemen Vodopivec, Nicola Asuni
return: String encrypted text
param: $key (string) Encryption key.
param: $text (String) Input text to be encrypted.
param: $last_enc_key (String) Reference to last RC4 key encrypted.
param: $last_enc_key_c (String) Reference to last RC4 computed key.

getUserPermissionCode($permissions, $mode=0)   X-Ref
Return the permission code used on encryption (P value).

author: Nicola Asuni
param: $permissions (Array) the set of permissions (specify the ones you want to block).
param: $mode (int) encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.

convertHexStringToString($bs)   X-Ref
Convert hexadecimal string to string

author: Nicola Asuni
return: String
param: $bs (string) byte-string to convert

convertStringToHexString($s)   X-Ref
Convert string to hexadecimal string (byte string)

author: Nicola Asuni
return: byte string
param: $s (string) string to convert

getEncPermissionsString($protection)   X-Ref
Convert encryption P value to a string of bytes, low-order byte first.

author: Nicola Asuni
return: String
param: $protection (string) 32bit encryption permission value (P value)

encodeNameObject($name)   X-Ref
Encode a name object.

author: Nicola Asuni
return: (string) Encoded name object.
param: $name (string) Name object to encode.

getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false)   X-Ref
Convert JavaScript form fields properties array to Annotation Properties array.

author: Nicola Asuni
return: array of annotation properties
param: $prop (array) javascript field properties. Possible values are described on official Javascript for Acrobat API reference.
param: $spot_colors (array) Reference to spot colors array.
param: $rtl (boolean) True if in Right-To-Left text direction mode, false otherwise.

formatPageNumber($num)   X-Ref
Format the page numbers.
This method can be overriden for custom formats.

param: $num (int) page number

formatTOCPageNumber($num)   X-Ref
Format the page numbers on the Table Of Content.
This method can be overriden for custom formats.

param: $num (int) page number

extractCSSproperties($cssdata)   X-Ref
Extracts the CSS properties from a CSS string.

author: Nicola Asuni
return: An array where the keys are the CSS selectors and the values are the CSS properties.
param: $cssdata (string) string containing CSS definitions.

fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces)   X-Ref
Cleanup HTML code (requires HTML Tidy library).

author: Nicola Asuni
return: string XHTML code cleaned up
param: $html (string) htmlcode to fix
param: $default_css (string) CSS commands to add
param: $tagvs (array) parameters for setHtmlVSpace method
param: $tidy_options (array) options for tidy_parse_string function
param: $tagvspaces (array) Array of vertical spaces for tags.

isValidCSSSelectorForTag($dom, $key, $selector)   X-Ref
Returns true if the CSS selector is valid for the selected HTML tag

return: true if the selector is valid, false otherwise
param: $dom (array) array of HTML tags and properties
param: $key (int) key of the current HTML tag
param: $selector (string) CSS selector string

getCSSdataArray($dom, $key, $css)   X-Ref
Returns the styles array that apply for the selected HTML tag.

return: array containing CSS properties
param: $dom (array) array of HTML tags and properties
param: $key (int) key of the current HTML tag
param: $css (array) array of CSS properties

getTagStyleFromCSSarray($css)   X-Ref
Compact CSS data array into single string.

return: string containing merged CSS properties
param: $css (array) array of CSS properties

intToRoman($number)   X-Ref
Returns the Roman representation of an integer number

return: string roman representation of the specified number
param: $number (int) number to convert

revstrpos($haystack, $needle, $offset = 0)   X-Ref
Find position of last occurrence of a substring in a string

return: Returns the position where the needle exists. Returns FALSE if the needle was not found.
param: $haystack (string) The string to search in.
param: $needle (string) substring to search.
param: $offset (int) May be specified to begin searching an arbitrary number of characters into the string.

getHyphenPatternsFromTEX($file)   X-Ref
Returns an array of hyphenation patterns.

author: Nicola Asuni
return: array of hyphenation patterns
param: $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/

getPathPaintOperator($style, $default='S')   X-Ref
Get the Path-Painting Operators.

author: Nicola Asuni
param: $style (string) Style of rendering. Possible values are:
param: $default (string) default style

getTransformationMatrixProduct($ta, $tb)   X-Ref
Get the product of two SVG tranformation matrices

author: Nicola Asuni
return: transformation array
param: $ta (array) first SVG tranformation matrix
param: $tb (array) second SVG tranformation matrix

getSVGTransformMatrix($attribute)   X-Ref
Get the tranformation matrix from SVG transform attribute

author: Nicola Asuni
return: array of transformations
param: $attribute (string) transformation

getVectorsAngle($x1, $y1, $x2, $y2)   X-Ref
Returns the angle in radiants between two vectors

author: Nicola Asuni
param: $x1 (int) X coordinate of first vector point
param: $y1 (int) Y coordinate of first vector point
param: $x2 (int) X coordinate of second vector point
param: $y2 (int) Y coordinate of second vector point

pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL)   X-Ref
Split string by a regular expression.
This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850

author: Nicola Asuni
return: Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
param: $pattern (string) The regular expression pattern to search for without the modifiers, as a string.
param: $modifiers (string) The modifiers part of the pattern,
param: $subject (string) The input string.
param: $limit (int) If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter.
param: $flags (int) The flags as specified on the preg_split PHP function.

fopenLocal($filename, $mode)   X-Ref
Wrapper to use fopen only with local files

return: Returns a file pointer resource on success, or FALSE on error.
param: filename (string) Name of the file to open
param: $mode (string)

url_exists($url)   X-Ref
Check if the URL exist.

return: Returns TRUE if the URL exists; FALSE otherwise.
param: url (string) URL to check.

encodeUrlQuery($url)   X-Ref
Encode query params in URL

return: string
param: string $url

file_exists($filename)   X-Ref
Wrapper for file_exists.
Checks whether a file or directory exists.
Only allows some protocols and local files.

return: Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
param: filename (string) Path to the file or directory.

fileGetContents($file)   X-Ref
Reads entire file into a string.
The file can be also an URL.

author: Nicola Asuni
return: The function returns the read data or FALSE on failure.
param: $file (string) Name of the file or URL to read.

_getULONG($str, $offset)   X-Ref
Get ULONG from string (Big Endian 32-bit unsigned integer).

author: Nicola Asuni
return: int 32 bit value
param: $str (string) string from where to extract value
param: $offset (int) point from where to read the data

_getUSHORT($str, $offset)   X-Ref
Get USHORT from string (Big Endian 16-bit unsigned integer).

author: Nicola Asuni
return: int 16 bit value
param: $str (string) string from where to extract value
param: $offset (int) point from where to read the data

_getSHORT($str, $offset)   X-Ref
Get SHORT from string (Big Endian 16-bit signed integer).

author: Nicola Asuni
return: int 16 bit value
param: $str (string) String from where to extract value.
param: $offset (int) Point from where to read the data.

_getFWORD($str, $offset)   X-Ref
Get FWORD from string (Big Endian 16-bit signed integer).

author: Nicola Asuni
return: int 16 bit value
param: $str (string) String from where to extract value.
param: $offset (int) Point from where to read the data.

_getUFWORD($str, $offset)   X-Ref
Get UFWORD from string (Big Endian 16-bit unsigned integer).

author: Nicola Asuni
return: int 16 bit value
param: $str (string) string from where to extract value
param: $offset (int) point from where to read the data

_getFIXED($str, $offset)   X-Ref
Get FIXED from string (32-bit signed fixed-point number (16.16).

author: Nicola Asuni
return: int 16 bit value
param: $str (string) string from where to extract value
param: $offset (int) point from where to read the data

_getBYTE($str, $offset)   X-Ref
Get BYTE from string (8-bit unsigned integer).

author: Nicola Asuni
return: int 8 bit value
param: $str (string) String from where to extract value.
param: $offset (int) Point from where to read the data.

rfread($handle, $length)   X-Ref
Binary-safe and URL-safe file read.
Reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read; EOF (end of file) is reached.

author: Nicola Asuni
return: Returns the read string or FALSE in case of error.
param: $handle (resource)
param: $length (int)

_freadint($f)   X-Ref
Read a 4-byte (32 bit) integer from file.

return: 4-byte integer
param: $f (string) file name.

getPageSizeFromFormat($format)   X-Ref
Get page dimensions from format name.

return: array containing page width and height in points
param: $format (mixed) The format name @see self::$page_format<ul>

setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points, $k, $pagedim=array()   X-Ref
Set page boundaries.

return: pagedim array of page dimensions.
param: $page (int) page number
param: $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
param: $llx (float) lower-left x coordinate in user units.
param: $lly (float) lower-left y coordinate in user units.
param: $urx (float) upper-right x coordinate in user units.
param: $ury (float) upper-right y coordinate in user units.
param: $points (boolean) If true uses user units as unit of measure, otherwise uses PDF points.
param: $k (float) Scale factor (number of points in user unit).
param: $pagedim (array) Array of page dimensions.

swapPageBoxCoordinates($page, $pagedim)   X-Ref
Swap X and Y coordinates of page boxes (change page boxes orientation).

return: pagedim array of page dimensions.
param: $page (int) page number
param: $pagedim (array) Array of page dimensions.

getPageLayoutMode($layout='SinglePage')   X-Ref
Get the canonical page layout mode.

return: (string) Canonical page layout name.
param: $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>

getPageMode($mode='UseNone')   X-Ref
Get the canonical page layout mode.

return: (string) Canonical page mode name.
param: $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>