3 require_once(dirname(__FILE__
) . "/../interface/globals.php");
6 $document_id = $_GET['doc_id'];
7 $d = new Document($document_id);
9 $storagemethod = $d->get_storagemethod();
10 $couch_docid = $d->get_couch_docid();
11 $couch_revid = $d->get_couch_revid();
13 if ($couch_docid && $couch_revid) {
14 $couch = new CouchDB();
15 $resp = $couch->retrieve_doc($couch_docid);
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"));
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;
44 $f = fopen($url, "r");
45 $xml = fread($f, filesize($url));
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);
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);