Update ParserKrokiTag.php
This commit is contained in:
parent
7fa4213178
commit
e6b5ced343
@ -59,6 +59,12 @@ class ParserKrokiTag {
|
|||||||
'wireviz'
|
'wireviz'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** @var string[] Output format types */
|
||||||
|
public const OUTPUT_FORMAT_TYPES = [
|
||||||
|
'svg',
|
||||||
|
'png'
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor method for MyClass.
|
* Constructor method for MyClass.
|
||||||
*
|
*
|
||||||
@ -83,6 +89,16 @@ class ParserKrokiTag {
|
|||||||
return in_array( strtolower( $string ), array_map( 'strtolower', self::DIAGRAM_TYPES ), true );
|
return in_array( strtolower( $string ), array_map( 'strtolower', self::DIAGRAM_TYPES ), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if $string is one of avaliable output format extensions.
|
||||||
|
*
|
||||||
|
* @param string $string string to check
|
||||||
|
* @return bool {true} if output format compare to one of avaliable types, {false} if not compare
|
||||||
|
*/
|
||||||
|
private static function validOutputFormatType( string $string ): bool {
|
||||||
|
return in_array( strtolower( $string ), array_map( 'strtolower', self::OUTPUT_FORMAT_TYPES ), true );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - Add tracking categories
|
* - Add tracking categories
|
||||||
* - Split parser cache for preview, where Graph uses different HTML
|
* - Split parser cache for preview, where Graph uses different HTML
|
||||||
@ -186,10 +202,10 @@ class ParserKrokiTag {
|
|||||||
|
|
||||||
$output_format = $args['output_format'] ?? 'svg';
|
$output_format = $args['output_format'] ?? 'svg';
|
||||||
|
|
||||||
//TODO: add check for format onlt png or svg
|
// Check for format only png or svg
|
||||||
|
if ( !self::validOutputFormatType( $output_format ) ) {
|
||||||
//DEBUG
|
return $this->formatError( wfMessage( 'kroki-error-unknown-language' ) );
|
||||||
echo $output_format;
|
}
|
||||||
|
|
||||||
// set post fields
|
// set post fields
|
||||||
$requestParams = [
|
$requestParams = [
|
||||||
@ -247,10 +263,10 @@ class ParserKrokiTag {
|
|||||||
|
|
||||||
$output_format = $args['output_format'] ?? 'svg';
|
$output_format = $args['output_format'] ?? 'svg';
|
||||||
|
|
||||||
//TODO: add check for format onlt png or svg
|
// Check for format only png or svg
|
||||||
|
if ( !self::validOutputFormatType( $output_format ) ) {
|
||||||
//DEBUG
|
return $this->formatError( wfMessage( 'kroki-error-unknown-language' ) );
|
||||||
echo $output_format;
|
}
|
||||||
|
|
||||||
// set post fields
|
// set post fields
|
||||||
$requestParams = [
|
$requestParams = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user