1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 06:55:05 +01:00
openstamanager/view.php

60 lines
1.2 KiB
PHP
Raw Normal View History

2019-01-17 16:11:10 +01:00
<?php
include_once __DIR__.'/core.php';
$file_id = filter('file_id');
$file = Models\Upload::find($file_id);
if (empty($file)) {
return;
}
$link = ROOTDIR.'/'.$file->filepath;
if ($file->isFatturaElettronica()) {
$content = file_get_contents(DOCROOT.'/'.$file->filepath);
// XML
$xml = new DOMDocument();
$xml->loadXML($content);
// XSL
$xsl = new DOMDocument();
2019-02-12 11:42:48 +01:00
$xsl->load(DOCROOT.'/assets/src/xml/fe-stylesheet-1.2.1.xsl');
2019-01-17 16:11:10 +01:00
// XSLT
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl);
echo $xslt->transformToXML($xml);
} else {
echo '
<style>
body, iframe, img{
border: 0;
margin: 0;
max-width: 100%;
}
iframe{
width:100%;
height:100%;
min-height: 500px;
}
</style>';
if ($file->isImage()) {
echo '
<img src="'.$link.'"></img>';
} else {
if ($file->isPDF()) {
$src = \Prints::getPDFLink($file->filepath);
}
echo '
<iframe src="'.($link ?: $src).'">
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
</iframe>';
}
}