Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
core_badges\png_metadata_handler Class Reference

Baking badges - PNG metadata handler. More...

Public Member Functions

 __construct (string $contents)
 Prepares file for handling metadata.
 
 add_chunks (string $type, string $key, string $value)
 Adds a chunk with keyword and data to the file content.
 
 check_chunks (string $type, string $check)
 Checks if a key already exists in the chunk of said type.
 

Detailed Description

Baking badges - PNG metadata handler.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Author
Yuliya Bozhko yuliy.nosp@m.a.bo.nosp@m.zhko@.nosp@m.tota.nosp@m.ralms.nosp@m..com

Constructor & Destructor Documentation

◆ __construct()

core_badges\png_metadata_handler::__construct ( string $contents)

Prepares file for handling metadata.

Verifies that this file is a valid PNG file. Unpacks file chunks and reads them into an array.

Parameters
string$contentsFile content as a string

Member Function Documentation

◆ add_chunks()

core_badges\png_metadata_handler::add_chunks ( string $type,
string $key,
string $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.

Parameters
string$typeChunk type, like iTXt, tEXt, etc.
string$keyKeyword that needs to be added.
string$valueCurrently an assertion URL that is added to an image metadata.
Return values
string#$resultFile content with a new chunk as a string. Can be used in file_put_contents() to write to a file.
Exceptions
moodle_exceptionwhen unsupported chunk type is defined.

◆ check_chunks()

core_badges\png_metadata_handler::check_chunks ( string $type,
string $check )

Checks if a key already exists in the chunk of said type.

We need to avoid writing same keyword into file chunks.

Parameters
string$typeChunk type, like iTXt, tEXt, etc.
string$checkKeyword that needs to be checked.
Return values
boolean(true|false) True if file is safe to write this keyword, false otherwise.

The documentation for this class was generated from the following file: