Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

(no description)

Author: Nicola Asuni
Version: 1.1.2
File Size: 2616 lines (109 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.

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

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>

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

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

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.
return: border mode array

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

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

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

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

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

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

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

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

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

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

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.

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.
return: replaced page content and updated $diff parameter as array.

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

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

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

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

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

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

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

param: $str (string) input string
return: String MD5 encrypted binary 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

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

_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

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

_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

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.
author: Klemen Vodopivec, Nicola Asuni
return: String encrypted text

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

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.
author: Nicola Asuni

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

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

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

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

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

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

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

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

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

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.
author: Nicola Asuni
return: array of annotation properties

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.

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

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

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.
author: Nicola Asuni
return: string XHTML code cleaned up

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

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

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

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
return: array containing CSS properties

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

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

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

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

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

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.
return: Returns the position where the needle exists. Returns FALSE if the needle was not found.

getHyphenPatternsFromTEX($file)   X-Ref
Returns an 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/
author: Nicola Asuni
return: array of hyphenation patterns

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

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

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

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

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

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

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

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
author: Nicola Asuni

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

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.
author: Nicola Asuni
return: Returns an array containing substrings of subject split along boundaries matched by pattern.modifier

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

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

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

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.
return: pagedim array of page dimensions.

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

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

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

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>
return: (string) Canonical page layout name.

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

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>
return: (string) Canonical page mode name.