diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc index 7551a669..3f2ae610 100644 --- a/lam/lib/pdfstruct.inc +++ b/lam/lib/pdfstruct.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) - Copyright (C) 2003 Roland Gruber + Copyright (C) 2003 Michael Dürgner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,4 +55,38 @@ function loadPDFStructureDefinitions($scope='user', $definition='default.xml') { $structure = array_slice($xml[0],$border['start'] + 1,$border['end'] - ($border['start'] + 1)); return $structure; } + +function savePDFStructureDefinitions($scope,$definition) { + $handle = fopen($_SESSION['lampath'] . 'config/pdf/' . $scope . '/' . $definition,'w'); + $file = "\n"; + foreach($_SESSION['currentPDFStructure'] as $entry) { + $ident = ''; + for($i=0;$i<$entry['level'] -1;$i++) { + $ident .= "\t"; + } + $attributes = ''; + if(is_array($entry['attributes'])) { + foreach($entry['attributes'] as $key => $value) { + $attributes .= ' ' . strtolower($key) . '="' . $value . '"'; + } + } + if($entry['type'] == 'open') { + $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . ">\n"; + } + elseif($entry['type'] == 'close') { + $file .= $ident . '\n"; + } + elseif($entry['type'] == 'complete') { + if(isset($entry['value'])) { + $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . '>' . $entry['value'] . '\n"; + } + else { + $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . " />\n"; + } + } + } + $file .= ""; + fwrite($handle,$file); + fclose($handle); +} ?> \ No newline at end of file diff --git a/lam/templates/pdfedit/pdfmain.php b/lam/templates/pdfedit/pdfmain.php index 41268671..c1b6c060 100644 --- a/lam/templates/pdfedit/pdfmain.php +++ b/lam/templates/pdfedit/pdfmain.php @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) - Copyright (C) 2003 Roland Gruber + Copyright (C) 2003 Michael Dürgner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lam/templates/pdfedit/pdfpage.php b/lam/templates/pdfedit/pdfpage.php index f6306fac..10ce0b8f 100644 --- a/lam/templates/pdfedit/pdfpage.php +++ b/lam/templates/pdfedit/pdfpage.php @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) - Copyright (C) 2003 Roland Gruber + Copyright (C) 2003 Michael Dürgner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,7 +54,7 @@ if(isset($_GET['abort'])) { exit; } elseif(isset($_GET['submit'])) { - // TODO implement save of PDF structure + savePDFStructureDefinitions($_GET['type'],$_GET['pdfname'] . '.xml'); unset($_SESSION['currentPDFStructure']); unset($_SESSION['availablePDFFields']); session_unregister('currentPDFStructure'); @@ -129,28 +129,110 @@ elseif(isset($_GET['up'])) { $tmp = $_SESSION['currentPDFStructure'][$_GET['up']]; $prev = $_SESSION['currentPDFStructure'][$_GET['up'] - 1]; if($tmp['tag'] == 'SECTION') { - + $pos = 0; + $borders = array(); + $current = current($_SESSION['currentPDFStructure']); + if($current['tag'] == 'SECTION') { + $borders[$current['type']][] = $pos; + } + while($pos < $_GET['up']) { + $current = next($_SESSION['currentPDFStructure']); + $pos++; + if($current['tag'] == 'SECTION') { + $borders[$current['type']][] = $pos; + } + } + if(count($borders['close']) > 0) { + $current = next($_SESSION['currentPDFStructure']); + $pos++; + while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { + $current = next($_SESSION['currentPDFStructure']); + $pos++; + } + $borders['close'][] = $pos; + $cut_start = $borders['open'][count($borders['open']) - 1]; + $cut_count = $borders['close'][count($borders['close']) - 1] - $borders['open'][count($borders['open']) - 1] + 1; + $insert_pos = $borders['open'][count($borders['open']) - 2]; + $tomove = array_splice($_SESSION['currentPDFStructure'],$cut_start,$cut_count); + array_splice($_SESSION['currentPDFStructure'],$insert_pos,0,$tomove); + } } elseif($tmp['tag'] == 'ENTRY' && $prev['tag'] == 'ENTRY') { $_SESSION['currentPDFStructure'][$_GET['up']] = $_SESSION['currentPDFStructure'][$_GET['up'] - 1]; $_SESSION['currentPDFStructure'][$_GET['up'] - 1] = $tmp; } elseif($tmp['tag'] == 'TEXT') { - + if($_GET['up'] != 0) { + $tomove = array_splice($_SESSION['currentPDFStructure'],$_GET['up'],1); + array_splice($_SESSION['currentPDFStructure'],0,0,$tomove); + } } } elseif(isset($_GET['down'])) { $tmp = $_SESSION['currentPDFStructure'][$_GET['down']]; $next = $_SESSION['currentPDFStructure'][$_GET['down'] + 1]; if($tmp['tag'] == 'SECTION') { - + $pos = 0; + $current = current($_SESSION['currentPDFStructure']); + while($pos < $_GET['down']) { + $current = next($_SESSION['currentPDFStructure']); + $pos++; + } + $borders = array(); + $borders[$current['type']][] = $pos; + $current = next($_SESSION['currentPDFStructure']); + $pos++; + while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { + $current = next($_SESSION['currentPDFStructure']); + $pos++; + } + $borders['close'][] = $pos; + $current = next($_SESSION['currentPDFStructure']); + $pos++; + if($current) { + $borders[$current['type']][] = $pos; + $current = next($_SESSION['currentPDFStructure']); + $pos++; + while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { + if($current['tag'] == 'SECTION') { + $borders[$current['type']][] = $pos; + } + $current = next($_SESSION['currentPDFStructure']); + $pos++; + } + $borders['close'][] = $pos; + } + if(count($borders['open']) > 1) { + $cut_start = $borders['open'][count($borders['open']) - 1]; + $cut_count = $borders['close'][count($borders['close']) - 1] - $borders['open'][count($borders['open']) - 1] + 1; + $insert_pos = $borders['open'][count($borders['open']) - 2]; + $tomove = array_splice($_SESSION['currentPDFStructure'],$cut_start,$cut_count); + array_splice($_SESSION['currentPDFStructure'],$insert_pos,0,$tomove); + } } elseif($tmp['tag'] == 'ENTRY' && $next['tag'] == 'ENTRY') { $_SESSION['currentPDFStructure'][$_GET['down']] = $_SESSION['currentPDFStructure'][$_GET['down'] + 1]; $_SESSION['currentPDFStructure'][$_GET['down'] + 1] = $tmp; } elseif($tmp['tag'] == 'TEXT') { - + if($_GET['down'] != (count($_SESSION['currentPDFStructure']) -1)) { + $tomove = array_splice($_SESSION['currentPDFStructure'],$_GET['down'],1); + array_splice($_SESSION['currentPDFStructure'],count($_SESSION['currentPDFStructure']),0,$tomove); + } + } +} +elseif(isset($_GET['add_text'])) { + if($_GET['text_type'] == 'config') { + $entry = array('tag' => 'TEXT','type' => 'complete','level' => '2','attributes' => array('type' => $_GET['type'])); + } + else { + $entry = array('tag' => 'TEXT','type' => 'complete','level' => '2','value' => $_GET['text_text']); + } + if($_GET['text_position'] == 'top') { + array_splice($_SESSION['currentPDFStructure'],0,0,array($entry)); + } + else { + array_push($_SESSION['currentPDFStructure'],$entry); } } @@ -235,7 +317,7 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) { } // We have to include a static text. elseif($entry['tag'] == "TEXT") { - if($entry['type'] == "complete") { + if(!isset($entry['value'])) { ?> @@ -271,18 +353,23 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) { - + - + + + +
+ + + $entry) { - +
@@ -334,6 +421,76 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
+

 

+
+ + + + + + + + + + + +
+
+ + + + + + + + + + +
+ + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + +
+
+
+