pdf editor improved;
things working: - add/remove fields/sections - remove static text - move up/down fields inside a section things todo: - add static text - save pdf structure - move up/down section/static text - implement real getAvailablePDFFields functions
This commit is contained in:
parent
54b0177a0c
commit
f56f816f94
|
@ -39,7 +39,6 @@ if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// check if user has pressed submit or abort button
|
// check if user has pressed submit or abort button
|
||||||
if ($_POST['forward'] == "yes") {
|
if ($_POST['forward'] == "yes") {
|
||||||
// on abort go back to main page
|
// on abort go back to main page
|
||||||
|
|
|
@ -23,10 +23,10 @@ $Id$
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once("../../lib/pdfstruct.inc");
|
include_once('../../lib/pdfstruct.inc');
|
||||||
include_once("../../lib/ldap.inc");
|
include_once('../../lib/ldap.inc');
|
||||||
include_once("../../lib/config.inc");
|
include_once('../../lib/config.inc');
|
||||||
include_once("../../lib/modules.inc");
|
include_once('../../lib/modules.inc');
|
||||||
include_once('../../lib/xml_parser.inc');
|
include_once('../../lib/xml_parser.inc');
|
||||||
|
|
||||||
// start session
|
// start session
|
||||||
|
@ -41,14 +41,141 @@ if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['edit']) {
|
if(isset($_POST['type'])) {
|
||||||
$currentStructure = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']);
|
$_GET = $_POST;
|
||||||
}
|
|
||||||
else {
|
|
||||||
$currentStructure = loadPDFStructureDefinitions($_GET['type']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$availableFields = getAvailablePDFFields($_GET['type']);
|
if(isset($_GET['abort'])) {
|
||||||
|
unset($_SESSION['currentPDFStructure']);
|
||||||
|
unset($_SESSION['availablePDFFields']);
|
||||||
|
session_unregister('currentPDFStructure');
|
||||||
|
session_unregister('availablePDFFields');
|
||||||
|
metarefresh('pdfmain.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['submit'])) {
|
||||||
|
// TODO implement save of PDF structure
|
||||||
|
unset($_SESSION['currentPDFStructure']);
|
||||||
|
unset($_SESSION['availablePDFFields']);
|
||||||
|
session_unregister('currentPDFStructure');
|
||||||
|
session_unregister('availablePDFFields');
|
||||||
|
metarefresh('pdfmain.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['add_section'])) {
|
||||||
|
$attributes = array();
|
||||||
|
if($_GET['section_type'] == 'text') {
|
||||||
|
$attributes['NAME'] = $_GET['section_text'];
|
||||||
|
}
|
||||||
|
elseif($_GET['section_type'] == 'item') {
|
||||||
|
$attributes['NAME'] = '_' . $_GET['section_item'];
|
||||||
|
}
|
||||||
|
$newSectionStart = array('tag' => 'SECTION','type' => 'open','level' => '2','attributes' => $attributes);
|
||||||
|
$newSectionEnd = array('tag' => 'SECTION','type' => 'close','level' => '2');
|
||||||
|
$_SESSION['currentPDFStructure'][] = $newSectionStart;
|
||||||
|
$_SESSION['currentPDFStructure'][] = $newSectionEnd;
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['add_field'])) {
|
||||||
|
$modules = explode(',',$_GET['modules']);
|
||||||
|
$fields = array();
|
||||||
|
foreach($modules as $module) {
|
||||||
|
if(isset($_GET[$module])) {
|
||||||
|
foreach($_GET[$module] as $field) {
|
||||||
|
$fields[] = array('tag' => 'ENTRY','type' => 'complete','level' => '3','attributes' => array('NAME' => $module . '_' . $field));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count($fields) > 0) {
|
||||||
|
$pos = 0;
|
||||||
|
while($pos < $_GET['section']) {
|
||||||
|
next($_SESSION['currentPDFStructure']);
|
||||||
|
$pos++;
|
||||||
|
}
|
||||||
|
$current = next($_SESSION['currentPDFStructure']);
|
||||||
|
$pos++;
|
||||||
|
while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') {
|
||||||
|
$current = next($_SESSION['currentPDFStructure']);
|
||||||
|
$pos++;
|
||||||
|
}
|
||||||
|
array_splice($_SESSION['currentPDFStructure'],$pos,0,$fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['remove'])) {
|
||||||
|
$start = 0;
|
||||||
|
while($start < $_GET['remove']) {
|
||||||
|
next($_SESSION['currentPDFStructure']);
|
||||||
|
$start++;
|
||||||
|
}
|
||||||
|
$remove = current($_SESSION['currentPDFStructure']);
|
||||||
|
if($remove['tag'] == "SECTION") {
|
||||||
|
$end = $start;
|
||||||
|
$current = next($_SESSION['currentPDFStructure']);
|
||||||
|
$end++;
|
||||||
|
while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') {
|
||||||
|
$current = next($_SESSION['currentPDFStructure']);
|
||||||
|
$end++;
|
||||||
|
}
|
||||||
|
echo "start: $start\nend: $end\n";
|
||||||
|
array_splice($_SESSION['currentPDFStructure'],$start,$end - $start + 1);
|
||||||
|
}
|
||||||
|
elseif($remove['tag'] == "ENTRY") {
|
||||||
|
array_splice($_SESSION['currentPDFStructure'],$start,1);
|
||||||
|
}
|
||||||
|
elseif($remove['tag'] == "TEXT") {
|
||||||
|
array_splice($_SESSION['currentPDFStructure'],$start,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['up'])) {
|
||||||
|
$tmp = $_SESSION['currentPDFStructure'][$_GET['up']];
|
||||||
|
$prev = $_SESSION['currentPDFStructure'][$_GET['up'] - 1];
|
||||||
|
if($tmp['tag'] == 'SECTION') {
|
||||||
|
|
||||||
|
}
|
||||||
|
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') {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(isset($_GET['down'])) {
|
||||||
|
$tmp = $_SESSION['currentPDFStructure'][$_GET['down']];
|
||||||
|
$next = $_SESSION['currentPDFStructure'][$_GET['down'] + 1];
|
||||||
|
if($tmp['tag'] == 'SECTION') {
|
||||||
|
|
||||||
|
}
|
||||||
|
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(!isset($_SESSION['currentPDFStructure'])) {
|
||||||
|
if($_GET['edit']) {
|
||||||
|
$_SESSION['currentPDFStructure'] = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$_SESSION['currentPDFStructure'] = loadPDFStructureDefinitions($_GET['type']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($_SESSION['availablePDFFields'])) {
|
||||||
|
$_SESSION['availablePDFFields'] = getAvailablePDFFields($_GET['type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules = array();
|
||||||
|
$section_items = '';
|
||||||
|
foreach($_SESSION['availablePDFFields'] as $module => $values) {
|
||||||
|
$modules[] = $module;
|
||||||
|
foreach($values as $attribute) {
|
||||||
|
$section_items .= "\t\t\t\t\t\t\t\t\t\t\t\t<option>" . $module . '_' . $attribute . "</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$modules = join(',',$modules);
|
||||||
|
|
||||||
// print header
|
// print header
|
||||||
echo $_SESSION['header'];
|
echo $_SESSION['header'];
|
||||||
|
@ -65,13 +192,12 @@ echo $_SESSION['header'];
|
||||||
<td width="45%" align="center">
|
<td width="45%" align="center">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<b><?php echo _("Current PDF structure"); ?></b>
|
<b><?php echo (($_GET['edit']) ? substr($_GET['edit'],0,strlen($GET['edit']) - 4) : _('New') . ' ' . $_GET['type']) . ' ' . _("PDF structure"); ?></b>
|
||||||
</legend>
|
</legend>
|
||||||
<table>
|
<table>
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
foreach($_SESSION['currentPDFStructure'] as $key => $entry) {
|
||||||
foreach($currentStructure as $entry) {
|
$links = "\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&up=" . $key . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Up') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&down=" . $key . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Down') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&remove=" . $key . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Remove') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n";
|
||||||
$links = "\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&up=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Up') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&down=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Down') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td width=\"10\">\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href=\"pdfpage.php?type=" . $_GET['type'] . "&remove=" . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '') . "\">" . _('Remove') . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n";
|
|
||||||
$uplink = 'pdfpage.php?type=' . $_GET['type'] . '&up=' . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
|
$uplink = 'pdfpage.php?type=' . $_GET['type'] . '&up=' . $i . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
|
||||||
$downlink = 'pdfpage.php?type=' . $_GET['type'] . '&down=' . urlencode($entry['tag']) . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
|
$downlink = 'pdfpage.php?type=' . $_GET['type'] . '&down=' . urlencode($entry['tag']) . (($_GET['edit']) ? 'edit=' . $_GET['edit'] : '');
|
||||||
// We have a new section to start
|
// We have a new section to start
|
||||||
|
@ -86,21 +212,13 @@ foreach($currentStructure as $entry) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20" align="left">
|
<td width="20" align="left">
|
||||||
<input type="radio" name="section">
|
<input type="radio" name="section" value="<?php echo $key;?>">
|
||||||
</td>
|
</td>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<b><?php echo $section_headline;?></b>
|
<b><?php echo $section_headline;?></b>
|
||||||
</td>
|
</td>
|
||||||
<td width="20">
|
<td width="20">
|
||||||
</td>
|
</td>
|
||||||
<!-- <td>
|
|
||||||
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
|
|
||||||
</td>
|
|
||||||
<td width="10">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
|
|
||||||
</td> -->
|
|
||||||
<?php echo $links;?>
|
<?php echo $links;?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
@ -127,14 +245,6 @@ foreach($currentStructure as $entry) {
|
||||||
</td>
|
</td>
|
||||||
<td width="20">
|
<td width="20">
|
||||||
</td>
|
</td>
|
||||||
<!-- <td>
|
|
||||||
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
|
|
||||||
</td>
|
|
||||||
<td width="10">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
|
|
||||||
</td> -->
|
|
||||||
<?php echo $links;?>
|
<?php echo $links;?>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -158,14 +268,6 @@ foreach($currentStructure as $entry) {
|
||||||
</td>
|
</td>
|
||||||
<td width="20">
|
<td width="20">
|
||||||
</td>
|
</td>
|
||||||
<!-- <td>
|
|
||||||
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
|
|
||||||
</td>
|
|
||||||
<td width="10">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
|
|
||||||
</td> -->
|
|
||||||
<?php echo $links;?>
|
<?php echo $links;?>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -197,27 +299,83 @@ foreach($currentStructure as $entry) {
|
||||||
</td>
|
</td>
|
||||||
<td width="20">
|
<td width="20">
|
||||||
</td>
|
</td>
|
||||||
<!-- <td>
|
|
||||||
<a href="<?php echo $uplink;?>"><?php echo _('Up');?></a>
|
|
||||||
</td>
|
|
||||||
<td width="10">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo $downlink;?>"><?php echo _('Down');?></a>
|
|
||||||
</td> -->
|
|
||||||
<?php echo $links;?>
|
<?php echo $links;?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<b><?php echo _("Add new section"); ?></b>
|
||||||
|
</legend>
|
||||||
|
<table align="left">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="section_type" value="text" checked>
|
||||||
|
</td>
|
||||||
|
<td colspan="2">
|
||||||
|
<input type="text" name="section_text">
|
||||||
|
</td>
|
||||||
|
<td colspan="6" rowspan="2" align="left">
|
||||||
|
<input type="submit" name="add_section" value="<?php echo _('Add');?>">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="section_type" value="item">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name="section_item">
|
||||||
|
<?php echo $section_items;?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</fieldset>
|
||||||
|
<p> </p>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<b><?php echo _("Submit"); ?></b>
|
||||||
|
</legend>
|
||||||
|
<table border="0" align="left">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b><?php echo _("Structure name"); ?>:</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="pdfname" value="<?php echo substr($_GET['edit'],0,strlen($_GET['edit']) -4);?>">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="../help.php?HelpNumber=360" target="lamhelp"><?php echo _("Help");?></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
 
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="submit" name="submit" value="<?php echo _("Save");?>">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="submit" name="abort" value="<?php echo _("Abort");?>">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
 
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td width="10%" align="center">
|
<td width="10%" align="center">
|
||||||
<input type="button" name="add" value="<=">
|
<input type="submit" name="add_field" value="<=">
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- print available fields sorted by modul -->
|
<!-- print available fields sorted by modul -->
|
||||||
<td width="45%" align="center">
|
<td width="45%" align="center">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -226,7 +384,7 @@ foreach($currentStructure as $entry) {
|
||||||
</legend>
|
</legend>
|
||||||
<table>
|
<table>
|
||||||
<?php
|
<?php
|
||||||
foreach($availableFields as $module => $fields) {
|
foreach($_SESSION['availablePDFFields'] as $module => $fields) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
|
@ -261,38 +419,8 @@ foreach($availableFields as $module => $fields) {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p> </p>
|
<input type="hidden" name="modules" value="<?php echo $modules;?>">
|
||||||
<table border="0">
|
<input type="hidden" name="type" value="<?php echo $_GET['type'];?>">
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<b><?php echo _("Structure name"); ?>:</b>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="profname" value="<?php echo $_GET['edit'];?>">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="../help.php?HelpNumber=360" target="lamhelp"><?php echo _("Help");?></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=3>
|
|
||||||
 
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="submit" name="submit" value="<?php echo _("Save");?>">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="reset" name="reset" value="<?php echo _("Reset");?>">
|
|
||||||
<input type="submit" name="abort" value="<?php echo _("Abort");?>">
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
 
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<input type="hidden" name="accounttype" value="<?php echo $type;?>">
|
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue