diff --git a/content/lvplanung/lehrauftrag.php b/content/lvplanung/lehrauftrag.php index 02dc6e9bd..e1a29db39 100644 --- a/content/lvplanung/lehrauftrag.php +++ b/content/lvplanung/lehrauftrag.php @@ -19,6 +19,12 @@ * Andreas Oesterreicher and * Rudolf Hangl . */ +/* Erstellt einen Lehrauftrag im PDF Format + * + * Erstellt ein XML File Transformiert dieses mit + * Hilfe der XSL-FO Vorlage aus der DB und generiert + * daraus ein PDF (xslfo2pdf) + */ require_once('../../vilesci/config.inc.php'); require_once('../../include/functions.inc.php'); require_once('../../include/benutzerberechtigung.class.php'); @@ -27,20 +33,15 @@ require_once('../../include/studiengang.class.php'); require_once('../../include/lehreinheit.class.php'); require_once('../../include/fachbereich.class.php'); +//String der laenger als limit ist wird +//abgeschnitten und '...' angehaengt function CutString($strVal, $limit) { if(strlen($strVal) > $limit+3) - { return substr($strVal, 0, $limit) . "..."; - } else - { return $strVal; - } } - -ini_set('display_errors','0'); -//error_reporting(E_ALL); // Datenbank Verbindung if (!$conn = @pg_pconnect(CONN_STRING)) @@ -57,11 +58,6 @@ if(isset($_GET['stg_kz'])) $studiengang_kz = $_GET['stg_kz']; else die('Fehlerhafte Parameteruebergabe'); - -if(isset($_GET['output'])) - $output = $_GET['output']; -else - $output = 'pdf'; //Berechtigung pruefen $rechte = new benutzerberechtigung($conn); @@ -125,7 +121,7 @@ foreach ($fachbereich_obj->result as $fb) $fb_arr[$fb->fachbereich_kurzbz] = $fb->bezeichnung; $lehreinheit = new lehreinheit($conn); -$qry = "SELECT * FROM campus.vw_lehreinheit WHERE lv_studiengang_kz='".addslashes($studiengang_kz)."' AND mitarbeiter_uid='".addslashes($uid)."' AND studiensemester_kurzbz='$semester_aktuell'"; +$qry = "SELECT * FROM campus.vw_lehreinheit WHERE lv_studiengang_kz='".addslashes($studiengang_kz)."' AND mitarbeiter_uid='".addslashes($uid)."' AND studiensemester_kurzbz='$semester_aktuell' ORDER BY lehreinheit_id"; if($result = pg_query($conn, $qry)) { @@ -261,7 +257,7 @@ $buffer = html_entity_decode($buffer); $fo2pdf = new XslFo2Pdf(); if (!$fo2pdf->generatePdf($buffer, 'filename', "D")) { - echo "Failed parsing file:".'filename'."
"; + echo('Failed to generate PDF'); } ?> \ No newline at end of file diff --git a/include/xslfo2pdf/fo_block.php b/include/xslfo2pdf/fo_block.php index ddd88edc0..d9a2335ac 100644 --- a/include/xslfo2pdf/fo_block.php +++ b/include/xslfo2pdf/fo_block.php @@ -25,20 +25,20 @@ class FO_Block extends FO_LayoutObject{ private static $CHILDNODES = array( //FO_BidiOverride, //FO_Character, - FO_ExternalGraphic, /*oesi - uncomment for ExternalGraphic Support*/ - FO_InstreamForeignObject, - FO_Inline, + 'FO_ExternalGraphic', /*oesi - uncomment for ExternalGraphic Support*/ + 'FO_InstreamForeignObject', + 'FO_Inline', //FO_InlineContainer, //FO_Leader, //FO_PageNumber, //FO_PageNumberCitation, - FO_BasicLink, + 'FO_BasicLink', //FO_MultiToggle, - FO_Block, - FO_BlockContainer, - FO_TableAndCaption, - FO_Table, - FO_ListBlock + 'FO_Block', + 'FO_BlockContainer', + 'FO_TableAndCaption', + 'FO_Table', + 'FO_ListBlock' ); protected function getChildNodes() { @@ -64,6 +64,7 @@ class FO_Block extends FO_LayoutObject{ case "left": $align = "L"; default: + $align = ''; } $text = $this->escape($text); diff --git a/include/xslfo2pdf/fo_core.php b/include/xslfo2pdf/fo_core.php index b4a07c6a7..26671bfb5 100644 --- a/include/xslfo2pdf/fo_core.php +++ b/include/xslfo2pdf/fo_core.php @@ -29,7 +29,7 @@ class FO_Container { } public function resolveReference($category, $name) { - return $_refs[$category][$name]; + return (isset($_refs)?$_refs[$category][$name]:''); } } @@ -41,7 +41,10 @@ class FO_Context { } public function get($key) { - return $this->_context[$key]; + if(isset($this->_context[$key])) + return $this->_context[$key]; + else + return false; } public function set($key, $val) { @@ -189,12 +192,18 @@ abstract class FO_Object { } protected function getAttribute(DOMNode $node, $key) { - return $node->attributes->getNamedItem($key)->nodeValue; + if($node->attributes->getNamedItem($key)!=null) + return $node->attributes->getNamedItem($key)->nodeValue; + else + return false; } protected function getSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") { - $val = $node->attributes->getNamedItem($key)->nodeValue; - return $this->calcInternalValue($val, $to, $from); + if($node->attributes->getNamedItem($key)!=null) + $val = $node->attributes->getNamedItem($key)->nodeValue; + else + $val=false; + return $this->calcInternalValue($val, $to, $from); } protected function initSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") { @@ -346,8 +355,8 @@ class FO_Root extends FO_Object{ } private static $CHILDNODES = array ( - FO_LayoutMasterSet, - FO_PageSequence + 'FO_LayoutMasterSet', + 'FO_PageSequence' ); public function parse(DOMNode $node) { diff --git a/include/xslfo2pdf/fo_instream.php b/include/xslfo2pdf/fo_instream.php index ba7923a02..e4fc2167a 100644 --- a/include/xslfo2pdf/fo_instream.php +++ b/include/xslfo2pdf/fo_instream.php @@ -25,7 +25,7 @@ require_once("fo_svg.php"); class FO_InstreamForeignObject extends FO_Object { private static $CHILDNODES = array( - FO_SVG + 'FO_SVG' ); public function parse(DOMNode $node) { diff --git a/include/xslfo2pdf/fo_layout.php b/include/xslfo2pdf/fo_layout.php index d17e0a12b..7b94533c5 100644 --- a/include/xslfo2pdf/fo_layout.php +++ b/include/xslfo2pdf/fo_layout.php @@ -65,6 +65,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer { //$this->initLocalSizeAttribute($node, "padding-right"); } + //oesi - convertiert die daten von utf8 nach latin1 und ersetzt 'EURO' durch das eurosymbol public function convert($str) { //echo str_replace('EURO',chr(128),utf8_decode($str)); @@ -116,7 +117,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer { //oesi - hack for ExternalGraphic Tag to show without content if($this instanceof FO_ExternalGraphic) - $this->processContent($child->textContent); + $this->processContent(''); //endhack $contentBuffer = $this->endCapture(); @@ -498,13 +499,13 @@ class FO_LayoutMasterSet extends FO_Object { class FO_PageSequence extends FO_Object { private static $CHILDNODES = array( - FO_Flow + 'FO_Flow' ); public function parse(DOMNode $node) { $masterRef = $node->attributes->getNamedItem("master-reference"); if ($masterRef) { - $master = $this->resolveReference(FO_LayoutMasterSet, $masterRef); + $master = $this->resolveReference('FO_LayoutMasterSet', $masterRef); //TODO: do something with this master } $pdf = $this->getPdf(); @@ -541,11 +542,11 @@ abstract class FO_FlowContainer extends FO_Object { class FO_Flow extends FO_FlowContainer { private static $CHILDNODES = array( - FO_Block, - FO_Table, - FO_BlockContainer, - FO_TableAndCaption, - FO_ListBlock + 'FO_Block', + 'FO_Table', + 'FO_BlockContainer', + 'FO_TableAndCaption', + 'FO_ListBlock' ); public function parse(DOMNode $node) { @@ -556,11 +557,11 @@ class FO_Flow extends FO_FlowContainer { class FO_BlockContainer extends FO_LayoutObject { private static $CHILDNODES = array( - FO_Block, - FO_BlockContainer, - FO_TableAndCaption, - FO_Table, - FO_ListBlock); + 'FO_Block', + 'FO_BlockContainer', + 'FO_TableAndCaption', + 'FO_Table', + 'FO_ListBlock'); protected function initAttributes(DOMNode $node) { $this->initLocalSizeAttribute($node, "position"); diff --git a/include/xslfo2pdf/fo_table.php b/include/xslfo2pdf/fo_table.php index 8dd5eb5f8..16034ae6b 100644 --- a/include/xslfo2pdf/fo_table.php +++ b/include/xslfo2pdf/fo_table.php @@ -67,8 +67,8 @@ http://xslf2pdf.tegonal.com class FO_TableAndCaption extends FO_Object { private static $CHILDNODES = array( - FO_Table, - FO_TableCaption + 'FO_Table', + 'FO_TableCaption' ); public function parse(DOMNode $node) { @@ -80,10 +80,10 @@ class FO_Table extends FO_LayoutObject { private $colCount = 0; private static $CHILDNODES = array( - FO_TableColumn, - FO_TableHeader, - FO_TableFooter, - FO_TableBody + 'FO_TableColumn', + 'FO_TableHeader', + 'FO_TableFooter', + 'FO_TableBody' ); protected function getChildNodes() { @@ -122,9 +122,9 @@ class FO_Table extends FO_LayoutObject { class FO_TableCaption extends FO_Object { private static $CHILDNODES = array( - FO_Block, - FO_BlockContainer, - FO_ListBlock + 'FO_Block', + 'FO_BlockContainer', + 'FO_ListBlock' ); public function parse(DOMNode $node) { @@ -149,7 +149,7 @@ class FO_TableRow extends FO_LayoutObject { private $colIndex = 0; private static $CHILDNODES = array( - FO_TableCell + 'FO_TableCell' ); protected function getChildNodes() { @@ -186,8 +186,8 @@ class FO_TableRow extends FO_LayoutObject { class FO_TableHeader extends FO_TableRow { private static $CHILDNODES = array( - FO_TableCell, - FO_TableRow + 'FO_TableCell', + 'FO_TableRow' ); protected function getChildNodes() { @@ -198,8 +198,8 @@ class FO_TableHeader extends FO_TableRow { class FO_TableFooter extends FO_LayoutObject { private static $CHILDNODES = array( - FO_TableCell, - FO_TableRow + 'FO_TableCell', + 'FO_TableRow' ); protected function getChildNodes() { @@ -210,8 +210,8 @@ class FO_TableFooter extends FO_LayoutObject { class FO_TableBody extends FO_LayoutObject { private static $CHILDNODES = array( - FO_TableCell, - FO_TableRow + 'FO_TableCell', + 'FO_TableRow' ); protected function getChildNodes() { @@ -232,11 +232,11 @@ class FO_TableBody extends FO_LayoutObject { class FO_TableCell extends FO_LayoutObject { private static $CHILDNODES = array( - FO_Block, - FO_BlockContainer, - FO_ListBlock, - FO_Table, - FO_TableAndCaption + 'FO_Block', + 'FO_BlockContainer', + 'FO_ListBlock', + 'FO_Table', + 'FO_TableAndCaption' ); diff --git a/include/xslfo2pdf/xslfo2pdf.php b/include/xslfo2pdf/xslfo2pdf.php index 11901a309..d5f92a9de 100644 --- a/include/xslfo2pdf/xslfo2pdf.php +++ b/include/xslfo2pdf/xslfo2pdf.php @@ -68,6 +68,7 @@ class XslFo2PDF { $name = $name.".pdf"; } $pdf->Output($name, $dest); + return true; } private function initDefaults(FPDF $pdf, FO_Root $root) { @@ -114,12 +115,16 @@ class FO_Factory { public static function createFOObject(DOMNode $node, FO_Container $container, FPDF $pdf, FO_Context &$context, - $filter) { - $obj = self::$factory[$node->nodeName]; - if (!$obj) { + $filter) + { + if(isset(self::$factory[$node->nodeName])) + $obj = self::$factory[$node->nodeName]; + if (!isset($obj) || !$obj) + { return NULL; } - if (!$filter || !in_array($obj, $filter)) { + if (!$filter || !in_array($obj, $filter)) + { echo "ignore due to filter:$obj
"; return NULL; }