From 948699c8556c61c38732b0f61855ce8d52cdb867 Mon Sep 17 00:00:00 2001 From: Karl Burkhart Date: Thu, 11 Oct 2012 12:15:26 +0000 Subject: [PATCH] =?UTF-8?q?Projektbeschreibung=20wir=20dynamisch=20erstell?= =?UTF-8?q?t=20und=20per=20odt=20file=20zur=C3=BCckgegeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/projekt/projekt.overlay.js.php | 23 ++++ content/projekt/projekt.overlay.xul.php | 1 + content/projektbeschreibung.php | 168 ++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100755 content/projektbeschreibung.php diff --git a/content/projekt/projekt.overlay.js.php b/content/projekt/projekt.overlay.js.php index cf6f2d352..84ece1016 100755 --- a/content/projekt/projekt.overlay.js.php +++ b/content/projekt/projekt.overlay.js.php @@ -391,4 +391,27 @@ function ProjektPrintStatusbericht() return false; } window.open('content/pdfExport.php?xsl=statusbericht&xml=statusbericht.rdf.php&projekt_kurzbz='+id); +} + +function ProjektPrintProjektbeschreibung() +{ + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var tree = document.getElementById('tree-projekt'); + + if (tree.currentIndex==-1) + { + alert('Kein Projekt ausgewählt!'); + return; + } + try + { + //Ausgewaehltes Projekt holen + id = getTreeCellText(tree, "treecol-projekt-projekt_kurzbz", tree.currentIndex); + } + catch(e) + { + alert(e); + return false; + } + window.open('content/projektbeschreibung.php?xsl=Projektbeschr&xml=projektbeschreibung.rdf.php&projekt_kurzbz='+id); } \ No newline at end of file diff --git a/content/projekt/projekt.overlay.xul.php b/content/projekt/projekt.overlay.xul.php index f21781dd8..2690064f8 100755 --- a/content/projekt/projekt.overlay.xul.php +++ b/content/projekt/projekt.overlay.xul.php @@ -54,6 +54,7 @@ echo ' + diff --git a/content/projektbeschreibung.php b/content/projektbeschreibung.php new file mode 100755 index 000000000..7e11cd87c --- /dev/null +++ b/content/projektbeschreibung.php @@ -0,0 +1,168 @@ + + * + */ + +session_cache_limiter('none'); //muss gesetzt werden sonst funktioniert der Download mit IE8 nicht +session_start(); +require_once('../config/vilesci.config.inc.php'); +require_once('../include/functions.inc.php'); +require_once('../include/vorlage.class.php'); +require_once('../include/gantt.class.php'); +require_once('../include/benutzerberechtigung.class.php'); + +$user = get_uid(); + +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($user); +if(!$rechte->isBerechtigt('planner')) +{ + die('Sie haben keine Berechtigung fuer diese Seite'); +} + +// Parameter holen +if(isset($_GET['xml'])) + $xml=$_GET['xml']; +else + die('Fehlerhafte Parameteruebergabe'); + +if(isset($_GET['xsl'])) + $xsl=$_GET['xsl']; +else + die('Fehlerhafte Parameteruebergabe'); + +if(isset($_GET['xsl_oe_kurzbz'])) + $xsl_oe_kurzbz=$_GET['xsl_oe_kurzbz']; +else + $xsl_oe_kurzbz='0'; + +if(isset($_GET['version']) && is_numeric($_GET['version'])) + $version = $_GET['version']; +else + $version =''; + +$output = (isset($_GET['output'])?$_GET['output']:'odt'); + +//Parameter setzen +$params='?xmlformat=xml'; +if(isset($_GET['uid'])) + $params.='&uid='.$_GET['uid']; +if(isset($_GET['projekt_kurzbz'])) + $params.='&projekt_kurzbz='.$_GET['projekt_kurzbz']; + + +$xml_url=XML_ROOT.$xml.$params; + +// Load the XML source +$xml_doc = new DOMDocument; + +if(!$xml_doc->load($xml_url)) + die('unable to load xml: '.$xml_url); + +//XSL aus der DB holen +$vorlage = new vorlage(); +$vorlage->getAktuelleVorlage($xsl_oe_kurzbz, $xsl); + +$xsl_content = $vorlage->text; + +if(mb_strstr($vorlage->mimetype, 'application/vnd.oasis.opendocument')) +{ + switch($vorlage->mimetype) + { + case 'application/vnd.oasis.opendocument.text': + $endung = 'odt'; + break; + case 'application/vnd.oasis.opendocument.spreadsheet': + $endung = 'ods'; + break; + default: + $endung = 'pdf'; + } + + // Load the XSL source + $xsl_doc = new DOMDocument; + if(!$xsl_doc->loadXML($xsl_content)) + die('unable to load xsl'); + + // Configure the transformer + $proc = new XSLTProcessor; + $proc->importStyleSheet($xsl_doc); // attach the xsl rules + + $buffer = $proc->transformToXml($xml_doc); + + $tempfolder = '/tmp/'.uniqid(); + mkdir($tempfolder); + chdir($tempfolder); + mkdir('Pictures'); + + file_put_contents('content.xml', $buffer); + + // aktuelles Jahr + $timestamp = time(); + $year = date('Y',$timestamp); + + $gantt = new gantt(); + $gantSvg = $gantt->getBeschreibungGantt($_GET['projekt_kurzbz'], $year, 'studienjahr'); + + // Bild im Temp Ordner zwischenspeichern + file_put_contents($tempfolder.'/Pictures/20000001000071B00000242C6CF7933F.svg',$gantSvg); + + $zipfile = DOC_ROOT.'system/vorlage_zip/'.$vorlage->vorlage_kurzbz.'.'.$endung; + $tempname_zip = 'out.zip'; + if(copy($zipfile, $tempname_zip)) + { + exec("zip $tempname_zip content.xml"); + // Bilder zum ZIP-File hinzufuegen + exec("zip $tempname_zip Pictures/*"); + + clearstatcache(); + if($output == 'pdf') + { + $tempPdfName = $vorlage->vorlage_kurzbz.'_'.$_GET['projekt_kurzbz'].'.pdf'; + exec("unoconv -e IsSkipEmptyPages=false --stdout -f pdf $tempname_zip > $tempPdfName"); + + $fsize = filesize($tempPdfName); + $handle = fopen($tempPdfName,'r'); + header('Content-type: application/pdf'); + header('Content-Disposition: attachment; filename="'.$tempPdfName.'"'); + header('Content-Length: '.$fsize); + } + else if($output =='odt') + { + $fsize = filesize($tempname_zip); + $handle = fopen($tempname_zip,'r'); + header('Content-type: '.$vorlage->mimetype); + header('Content-Disposition: attachment; filename="'.$vorlage->vorlage_kurzbz.'_'.$_GET['projekt_kurzbz'].'.'.$endung.'"'); + header('Content-Length: '.$fsize); + } + + while (!feof($handle)) + { + echo fread($handle, 8192); + } + fclose($handle); + + unlink('content.xml'); + unlink($tempname_zip); + if($output=='pdf') + unlink($tempPdfName); + rmdir($tempfolder); + } +} +?>