IHMPlotContextFileClass.php
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class IHMPlotContextFileClass {
public static function parse($filePath) {
if (!file_exists($filePath))
return array("success" => false, "message" => "Cannot load plot context file");
$doc = new DOMDocument("1.0", "UTF-8");
$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
if (!$doc->load($filePath))
return array("success" => false, "message" => "Cannot load plot context file");
//<page>
$pageNodes = $doc->getElementsByTagName('page');
if ($pageNodes->length <= 0)
return array("success" => false, "message" => "Cannot load context page node");
$pageNode = $pageNodes->item(0);
$pageContext = array(
'startTime' => $pageNode->getAttribute('startTime'),
'stopTime' => $pageNode->getAttribute('stopTime'),
'portrait' => ($pageNode->getAttribute('portrait') == "true"),
//An image rotation of 90 deg. is done after request execution if a page is in "portrait" mode
'width' => ($pageNode->getAttribute('portrait') == "true" ? $pageNode->getAttribute('height') : $pageNode->getAttribute('width')),
'height' => ($pageNode->getAttribute('portrait') == "true" ? $pageNode->getAttribute('width') : $pageNode->getAttribute('height')),
'panels' => array()
);
return array("success" => true, "page" => $pageContext);
}
}
?>