Document module improvements, take 3.
[openemr.git] / ccr / display.php
blobd66827f0ad7f9849c9fa8f14dcb5f5186fb004a4
1 <?php
2 require_once(dirname(__FILE__) . "/../interface/globals.php");
3 require_once(dirname(__FILE__) . "/../library/classes/Document.class.php");
5 $type = $_GET['type'];
6 $document_id = $_GET['doc_id'];
7 $d = new Document($document_id);
8 $url = $d->get_url();
9 $url = preg_replace("|^(.*)://|","",$url);
11 // Collect filename and path
12 $from_all = explode("/",$url);
13 $from_filename = array_pop($from_all);
14 $from_pathname_array = array();
15 for ($i=0;$i<$d->get_path_depth();$i++) {
16 $from_pathname_array[] = array_pop($from_all);
18 $from_pathname_array = array_reverse($from_pathname_array);
19 $from_pathname = implode("/",$from_pathname_array);
20 $temp_url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_pathname . '/' . $from_filename;
21 if (!file_exists($temp_url)) {
22 echo xl('The requested document is not present at the expected location on the filesystem or there are not sufficient permissions to access it.','','',' ') . $temp_url;
23 }else{
24 $url = $temp_url;
25 $f = fopen($url,"r");
26 $xml = fread($f,filesize($url));
27 fclose($f);
28 if($type == "CCR"){
29 $xmlDom = new DOMDocument();
30 $xmlDom->loadXML($xml);
31 $ss = new DOMDocument();
32 $ss->load(dirname(__FILE__).'/stylesheet/ccr.xsl');
33 $proc = new XSLTProcessor();
34 $proc->importStylesheet($ss);
35 $s_html = $proc->transformToXML($xmlDom);
36 echo $s_html;
37 }else{
38 $xmlDom = new DOMDocument();
39 $xmlDom->loadXML($xml);
40 $ss = new DOMDocument();
41 $ss->load(dirname(__FILE__).'/stylesheet/cda.xsl');
42 $xslt = new XSLTProcessor();
43 $xslt->importStyleSheet($ss);
44 $html = $xslt->transformToXML($xmlDom);
45 echo $html;