MediaWiki  1.34.0
SVGReader Class Reference

Public Member Functions

 __construct ( $source)
 Creates an SVGReader drawing from the source provided. More...
 
 getMetadata ()
 

Static Public Member Functions

static scaleSVGUnit ( $length, $viewportSize=512)
 Return a rounded pixel equivalent for a labeled CSS/SVG length. More...
 

Public Attributes

const DEFAULT_HEIGHT = 512
 
const DEFAULT_WIDTH = 512
 
const LANG_FULL_MATCH = 2
 
const LANG_PREFIX_MATCH = 1
 
const NS_SVG = 'http://www.w3.org/2000/svg'
 

Protected Member Functions

 read ()
 Read the SVG. More...
 

Private Member Functions

 animateFilterAndLang ( $name)
 Filter all children, looking for animated elements. More...
 
 debug ( $data)
 
 handleSVGAttribs ()
 Parse the attributes of an SVG element. More...
 
 readField ( $name, $metafield=null)
 Read a textelement from an element. More...
 
 readXml ( $metafield=null)
 Read an XML snippet from an element. More...
 

Private Attributes

 $languagePrefixes = []
 
 $languages = []
 
bool $mDebug = false
 
array $metadata = []
 
null XMLReader $reader = null
 

Detailed Description

Definition at line 31 of file SVGReader.php.

Constructor & Destructor Documentation

◆ __construct()

SVGReader::__construct (   $source)

Creates an SVGReader drawing from the source provided.

Parameters
string$sourceURI from which to read
Exceptions
MWException|Exception

Definition at line 54 of file SVGReader.php.

References $source, $wgSVGMetadataCutoff, debug(), DEFAULT_HEIGHT, DEFAULT_WIDTH, and read().

Member Function Documentation

◆ animateFilterAndLang()

SVGReader::animateFilterAndLang (   $name)
private

Filter all children, looking for animated elements.

Also get a list of languages that can be targeted.

Parameters
string$nameName of the element that we are reading from

Definition at line 229 of file SVGReader.php.

References debug(), Language\isWellFormedLanguageTag(), LANG_FULL_MATCH, and LANG_PREFIX_MATCH.

Referenced by read().

◆ debug()

SVGReader::debug (   $data)
private

Definition at line 292 of file SVGReader.php.

References wfDebug().

Referenced by __construct(), animateFilterAndLang(), read(), readField(), and readXml().

◆ getMetadata()

SVGReader::getMetadata ( )
Returns
array Array with the known metadata

Definition at line 115 of file SVGReader.php.

References $metadata.

◆ handleSVGAttribs()

SVGReader::handleSVGAttribs ( )
private

Parse the attributes of an SVG element.

The parser has to be in the start element of "<svg>"

Definition at line 303 of file SVGReader.php.

References DEFAULT_HEIGHT, DEFAULT_WIDTH, and scaleSVGUnit().

Referenced by read().

◆ read()

SVGReader::read ( )
protected

Read the SVG.

Exceptions
MWException
Returns
bool

Definition at line 124 of file SVGReader.php.

References $languagePrefixes, $type, animateFilterAndLang(), debug(), handleSVGAttribs(), NS_SVG, readField(), and readXml().

Referenced by __construct().

◆ readField()

SVGReader::readField (   $name,
  $metafield = null 
)
private

Read a textelement from an element.

Parameters
string$nameName of the element that we are reading from
string$metafieldField that we will fill with the result

Definition at line 187 of file SVGReader.php.

References debug().

Referenced by read().

◆ readXml()

SVGReader::readXml (   $metafield = null)
private

Read an XML snippet from an element.

Parameters
string$metafieldField that we will fill with the result
Exceptions
MWException

Definition at line 212 of file SVGReader.php.

References debug().

Referenced by read().

◆ scaleSVGUnit()

static SVGReader::scaleSVGUnit (   $length,
  $viewportSize = 512 
)
static

Return a rounded pixel equivalent for a labeled CSS/SVG length.

https://www.w3.org/TR/SVG11/coords.html#Units

Parameters
string$lengthCSS/SVG length.
float | int$viewportSizeOptional scale for percentage units...
Returns
float Length in pixels

Definition at line 354 of file SVGReader.php.

References $matches.

Referenced by handleSVGAttribs().

Member Data Documentation

◆ $languagePrefixes

SVGReader::$languagePrefixes = []
private

Definition at line 47 of file SVGReader.php.

Referenced by read().

◆ $languages

SVGReader::$languages = []
private

Definition at line 46 of file SVGReader.php.

◆ $mDebug

bool SVGReader::$mDebug = false
private

Definition at line 42 of file SVGReader.php.

◆ $metadata

array SVGReader::$metadata = []
private

Definition at line 45 of file SVGReader.php.

Referenced by getMetadata().

◆ $reader

null XMLReader SVGReader::$reader = null
private

Definition at line 39 of file SVGReader.php.

◆ DEFAULT_HEIGHT

const SVGReader::DEFAULT_HEIGHT = 512

Definition at line 33 of file SVGReader.php.

Referenced by __construct(), and handleSVGAttribs().

◆ DEFAULT_WIDTH

const SVGReader::DEFAULT_WIDTH = 512

Definition at line 32 of file SVGReader.php.

Referenced by __construct(), and handleSVGAttribs().

◆ LANG_FULL_MATCH

const SVGReader::LANG_FULL_MATCH = 2

Definition at line 36 of file SVGReader.php.

Referenced by animateFilterAndLang(), and SvgHandler\getAvailableLanguages().

◆ LANG_PREFIX_MATCH

const SVGReader::LANG_PREFIX_MATCH = 1

Definition at line 35 of file SVGReader.php.

Referenced by animateFilterAndLang().

◆ NS_SVG

const SVGReader::NS_SVG = 'http://www.w3.org/2000/svg'

Definition at line 34 of file SVGReader.php.

Referenced by read().


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