Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Information on PNG file chunks can be found at http://www.w3.org/TR/PNG/#11Chunks Some other info on PNG that I used http://garethrees.org/2007/11/14/pngcrush/. More...
Public Member Functions | |
__construct ($contents) | |
Prepares file for handling metadata. | |
add_chunks ($type, $key, $value) | |
Adds a chunk with keyword and data to the file content. | |
check_chunks ($type, $check) | |
Checks if a key already exists in the chunk of said type. | |
Information on PNG file chunks can be found at http://www.w3.org/TR/PNG/#11Chunks Some other info on PNG that I used http://garethrees.org/2007/11/14/pngcrush/.
Example of use: $png = new PNG_MetaDataHandler('file.png');
if ($png->check_chunks("tEXt", "openbadge")) { $newcontents = $png->add_chunks("tEXt", "openbadge", 'http://some.public.url/to.your.assertion.file'); }
file_put_contents('file.png', $newcontents);
PNG_MetaDataHandler::__construct | ( | $contents | ) |
Prepares file for handling metadata.
Verifies that this file is a valid PNG file. Unpacks file chunks and reads them into an array.
string | $contents | File content as a string |
PNG_MetaDataHandler::add_chunks | ( | $type, | |
$key, | |||
$value ) |
Adds a chunk with keyword and data to the file content.
Chunk is added to the end of the file, before IEND image trailer.
string | $type | Chunk type, like iTXt, tEXt, etc. |
string | $key | Keyword that needs to be added. |
string | $value | Currently an assertion URL that is added to an image metadata. |
string\$result | File content with a new chunk as a string. Can be used in file_put_contents() to write to a file. |
moodle_exception | when unsupported chunk type is defined. |
PNG_MetaDataHandler::check_chunks | ( | $type, | |
$check ) |
Checks if a key already exists in the chunk of said type.
We need to avoid writing same keyword into file chunks.
string | $type | Chunk type, like iTXt, tEXt, etc. |
string | $check | Keyword that needs to be checked. |
boolean | (true|false) True if file is safe to write this keyword, false otherwise. |