Apply limit to names shown in document helper (#1679)
[openemr.git] / ccr / display.php
blob51b9c2c4865845fd99873299739295423b6d402a
1 <?php
2 require_once(dirname(__FILE__) . "/../interface/globals.php");
4 $type = $_GET['type'];
5 $document_id = $_GET['doc_id'];
6 $d = new Document($document_id);
7 $url = $d->get_url();
8 $storagemethod = $d->get_storagemethod();
9 $couch_docid = $d->get_couch_docid();
10 $couch_revid = $d->get_couch_revid();
12 if ($couch_docid && $couch_revid) {
13 $couch = new CouchDB();
14 $data = array($GLOBALS['couchdb_dbase'],$couch_docid);
15 $resp = $couch->retrieve_doc($data);
16 $xml = base64_decode($resp->data);
17 if ($content=='' && $GLOBALS['couchdb_log']==1) {
18 $log_content = date('Y-m-d H:i:s')." ==> Retrieving document\r\n";
19 $log_content = date('Y-m-d H:i:s')." ==> URL: ".$url."\r\n";
20 $log_content .= date('Y-m-d H:i:s')." ==> CouchDB Document Id: ".$couch_docid."\r\n";
21 $log_content .= date('Y-m-d H:i:s')." ==> CouchDB Revision Id: ".$couch_revid."\r\n";
22 $log_content .= date('Y-m-d H:i:s')." ==> Failed to fetch document content from CouchDB.\r\n";
23 //$log_content .= date('Y-m-d H:i:s')." ==> Will try to download file from HardDisk if exists.\r\n\r\n";
24 $this->document_upload_download_log($d->get_foreign_id(), $log_content);
25 die(xlt("File retrieval from CouchDB failed"));
27 } else {
28 $url = preg_replace("|^(.*)://|", "", $url);
29 // Collect filename and path
30 $from_all = explode("/", $url);
31 $from_filename = array_pop($from_all);
32 $from_pathname_array = array();
33 for ($i=0; $i<$d->get_path_depth(); $i++) {
34 $from_pathname_array[] = array_pop($from_all);
37 $from_pathname_array = array_reverse($from_pathname_array);
38 $from_pathname = implode("/", $from_pathname_array);
39 $temp_url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_pathname . '/' . $from_filename;
40 if (!file_exists($temp_url)) {
41 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;
42 } else {
43 $url = $temp_url;
44 $f = fopen($url, "r");
45 $xml = fread($f, filesize($url));
46 fclose($f);
50 if ($type == "CCR") {
51 $xmlDom = new DOMDocument();
52 $xmlDom->loadXML($xml);
53 $ss = new DOMDocument();
54 $ss->load(dirname(__FILE__).'/stylesheet/ccr.xsl');
55 $proc = new XSLTProcessor();
56 $proc->importStylesheet($ss);
57 $s_html = $proc->transformToXML($xmlDom);
58 echo $s_html;
59 } else {
60 $xmlDom = new DOMDocument();
61 $xmlDom->loadXML($xml);
62 $ss = new DOMDocument();
63 $ss->load(dirname(__FILE__).'/stylesheet/cda.xsl');
64 $xslt = new XSLTProcessor();
65 $xslt->importStyleSheet($ss);
66 $html = $xslt->transformToXML($xmlDom);
67 echo $html;