class SVG in Forena Reports 8
Provides SVG file exports
Exports only the first SVG element in a report. This is useful for building dynamic SVG assets.
Plugin annotation
@FrxDocument(
id= "svg",
name="Scaler Vector Graphics",
ext="svg"
)
Hierarchy
- class \Drupal\forena\FrxPlugin\Document\DocumentBase implements DocumentInterface uses FrxAPI
- class \Drupal\forena\FrxPlugin\Document\SVG
Expanded class hierarchy of SVG
File
- src/
FrxPlugin/ Document/ SVG.php, line 21 - SVG Embedded SVG Graph as it's own document. @author davidmetzler
Namespace
Drupal\forena\FrxPlugin\DocumentView source
class SVG extends DocumentBase {
public function __construct() {
$this->content_type = 'image/svg+xml';
}
public function header() {
$this->write_buffer = '';
$this->headers = [];
$this->headers['Content-Type'] = $this->content_type;
$this->headers['Cache-Control'] = 'must-revalidate';
}
public function flush() {
$output = '';
$svg = NULL;
$doc = new \DomDocument();
$xml_body = '<html><body>' . $this->write_buffer . '</body></html>';
$doc->formatOutput = FALSE;
$doc->strictErrorChecking = FALSE;
libxml_use_internal_errors(true);
$doc
->loadXML($xml_body);
libxml_clear_errors();
$xml = simplexml_import_dom($doc);
// Extract first SVG from document.
$xml
->registerXPathNamespace('__empty_ns', 'http://www.w3.org/2000/svg');
if ($xml) {
$svg = $xml
->xpath('//__empty_ns:svg');
if (!$svg) {
$svg = $xml
->xpath('//svg');
}
}
if ($svg) {
$output .= $svg[0]
->asXML();
}
else {
$output = '<svg/>';
}
// Add in namespaces
if (!strpos($output, 'xmlns')) {
$output = str_replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"', $output);
}
return $output;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | function | ||
DocumentBase:: |
public | function | Wrapper function for check output to default the right type. | |
DocumentBase:: |
public | function |
Clear the buffer Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function | Perform character set conversion | |
DocumentBase:: |
public | function |
No default footer. Overrides DocumentInterface:: |
1 |
DocumentBase:: |
public | function | ||
DocumentBase:: |
public | function |
Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function |
Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function |
Write Overrides DocumentInterface:: |
|
FrxAPI:: |
public | function | Returns containing application service | |
FrxAPI:: |
public | function | Get the current data context. | |
FrxAPI:: |
public | function | ||
FrxAPI:: |
public | function | Returns the data manager service | |
FrxAPI:: |
public | function | Return Data Service | |
FrxAPI:: |
public | function | Returns the fornea document manager | |
FrxAPI:: |
public | function | Report an error | |
FrxAPI:: |
public | function | Get the context of a specific id. | |
FrxAPI:: |
public | function | Get the current document | |
FrxAPI:: |
public | function | Load the contents of a file in the report file system. | |
FrxAPI:: |
function | Enter description here... | 1 | |
FrxAPI:: |
public | function | Pop data off of the stack. | |
FrxAPI:: |
public | function | Push data onto the Stack | |
FrxAPI:: |
public | function | Run a report with a particular format. | 1 |
FrxAPI:: |
public | function | Get the current report file system. | |
FrxAPI:: |
public | function | Set Data context by id. | |
FrxAPI:: |
public | function | Change to a specific document type. | |
FrxAPI:: |
public | function | Get list of skins. | |
SVG:: |
public | function |
Write the output to disk. Overrides DocumentBase:: |
|
SVG:: |
public | function |
Default implementation to put in content type based headers. Overrides DocumentBase:: |
|
SVG:: |
public | function |