server()) { metaRefresh("../login.php"); exit; } // Write $_POST variables to $_GET when form was submitted via post if(isset($_POST['type'])) { $_GET = $_POST; if($_POST['pdfname'] == '') { unset($_GET['pdfname']); } } // Abort and go back to main pdf structure page if(isset($_GET['abort'])) { metarefresh('pdfmain.php'); exit; } // set new logo and headline if ((isset($_GET['headline'])) && ($_GET['logoFile'] != $_SESSION['currentPageDefinitions']['filename'])) { $_SESSION['currentPageDefinitions']['filename'] = $_GET['logoFile']; } if ((isset($_GET['headline'])) && ($_GET['headline'] != $_SESSION['currentPageDefinitions']['headline'])) { $_SESSION['currentPageDefinitions']['headline'] = str_replace('<','',str_replace('>','',$_GET['headline'])); } // Check if pdfname is valid, then save current structure to file and go to // main pdf structure page if(isset($_GET['submit'])) { include '../main_header.php'; if(!isset($_GET['pdfname']) || !preg_match('/[a-zA-Z0-9\-\_]+/',$_GET['pdfname'])) { StatusMessage('ERROR', _('PDF-structure name not valid'), _('The name for that PDF-structure you submitted is not valid. A valid name must constist at least of one of the following characters \'a-z\',\'A-Z\',\'0-9\',\'_\',\'-\',\'.\'.')); } else { $return = savePDFStructureDefinitions($_GET['type'],$_GET['pdfname']); if($return == 'ok') { StatusMessage('INFO', _("PDF structure was successfully saved."), $_GET['pdfname']); } elseif($return == 'no perms'){ StatusMessage('ERROR', _("Could not save PDF profile, access denied."), $_GET['pdfname']); } } echo ("
" . _("Back to PDF Editor") . ""); echo ""; exit; } // add a new text field elseif(isset($_GET['add_text'])) { // Check if text for static text field is specified if(!isset($_GET['text_text']) || ($_GET['text_text'] == '')) { StatusMessage('ERROR',_('No static text specified'),_('The static text must contain at least one character.')); } else { $entry = array(array('tag' => 'TEXT','type' => 'complete','level' => '2','value' => $_GET['text_text'])); // Insert new field in structure array_splice($_SESSION['currentPDFStructure'],$_GET['add_text_position'],0,$entry); } } // add a new section with text headline elseif(isset($_GET['add_sectionText'])) { // Check if name for new section is specified when needed if(!isset($_GET['section_text']) || ($_GET['section_text'] == '')) { StatusMessage('ERROR',_('No section text specified'),_('The headline for a new section must contain at least one character.')); } else { $attributes = array(); $attributes['NAME'] = $_GET['section_text']; $entry = array(array('tag' => 'SECTION','type' => 'open','level' => '2','attributes' => $attributes),array('tag' => 'SECTION','type' => 'close','level' => '2')); // Insert new field in structure array_splice($_SESSION['currentPDFStructure'],$_GET['add_sectionText_position'],0,$entry); } } // Add a new section with item as headline elseif(isset($_GET['add_section'])) { $attributes = array(); $attributes['NAME'] = '_' . $_GET['section_item']; $entry = array(array('tag' => 'SECTION','type' => 'open','level' => '2','attributes' => $attributes),array('tag' => 'SECTION','type' => 'close','level' => '2')); // Insert new field in structure array_splice($_SESSION['currentPDFStructure'],$_GET['add_section_position'],0,$entry); } // Add a new value field elseif(isset($_GET['add_new_field'])) { $field = array('tag' => 'ENTRY','type' => 'complete','level' => '3','attributes' => array('NAME' => $_GET['new_field'])); $pos = 0; // Find begin section to insert into while($pos < $_GET['add_field_position']) { next($_SESSION['currentPDFStructure']); $pos++; } $current = next($_SESSION['currentPDFStructure']); $pos++; // End of section to insert into while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { $current = next($_SESSION['currentPDFStructure']); $pos++; } // Insert new entry before closing section tag array_splice($_SESSION['currentPDFStructure'],$pos,0,array($field)); } // Change section headline elseif(isset($_GET['change'])) { $alter = explode('_',$_GET['change']); $newvalue = $_GET['section_' . $alter[0]]; if (isset($alter[1]) && ($alter[1] == 'item') && ($newvalue[0] != '_')) { $newvalue = '_' . $newvalue; } $_SESSION['currentPDFStructure'][$alter[0]]['attributes']['NAME'] = $newvalue; } // Remove section, static text or value entry from structure elseif(isset($_GET['remove'])) { $start = 0; // Find element to remove while($start < $_GET['remove']) { next($_SESSION['currentPDFStructure']); $start++; } $remove = current($_SESSION['currentPDFStructure']); // We have a section to remove if($remove['tag'] == "SECTION") { $end = $start; $current = next($_SESSION['currentPDFStructure']); $end++; // Find end of section to remove while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { $current = next($_SESSION['currentPDFStructure']); $end++; } // Remove complete section with all value entries in it from structure array_splice($_SESSION['currentPDFStructure'],$start,$end - $start + 1); } // We have a value entry to remove elseif($remove['tag'] == "ENTRY") { array_splice($_SESSION['currentPDFStructure'],$start,1); } // We hava a static text to remove elseif($remove['tag'] == "TEXT") { array_splice($_SESSION['currentPDFStructure'],$start,1); } } // Move a section, static text or value entry upwards elseif(isset($_GET['up'])) { $tmp = $_SESSION['currentPDFStructure'][$_GET['up']]; $prev = $_SESSION['currentPDFStructure'][$_GET['up'] - 1]; // We have a section or static text to move if($tmp['tag'] == 'SECTION' || $tmp['tag'] == 'TEXT') { $pos = 0; $borders = array(); $current = current($_SESSION['currentPDFStructure']); // Add borders of sections and static text entry to array if($current['tag'] == 'SECTION') { $borders[$current['type']][] = $pos; } elseif($current['tag'] == 'TEXT') { $borders['open'][] = $pos; $borders['close'][] = $pos; } // Find all sections and statci text fields before the section or static // text entry to move upwards while($pos < $_GET['up']) { $current = next($_SESSION['currentPDFStructure']); $pos++; if($current['tag'] == 'SECTION') { $borders[$current['type']][] = $pos; } elseif($current['tag'] == 'TEXT') { $borders['open'][] = $pos; $borders['close'][] = $pos; } } // Move only when not topmost element if(count($borders['close']) > 0) { // We have a section to move up if($current['tag'] == 'SECTION') { $current = next($_SESSION['currentPDFStructure']); $pos++; // Find end of section to move while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { $current = next($_SESSION['currentPDFStructure']); $pos++; } $borders['close'][] = $pos; } // Calculate the entries to move and move them $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); } } // We have a value entry to move; move it only if its not the topmost // entry in this section elseif($tmp['tag'] == 'ENTRY' && $prev['tag'] == 'ENTRY') { $_SESSION['currentPDFStructure'][$_GET['up']] = $prev; $_SESSION['currentPDFStructure'][$_GET['up'] - 1] = $tmp; } } // Move a section, static text field or value entry downwards elseif(isset($_GET['down'])) { $tmp = $_SESSION['currentPDFStructure'][$_GET['down']]; $next = $_SESSION['currentPDFStructure'][$_GET['down'] + 1]; // We have a section or static text to move if($tmp['tag'] == 'SECTION' || $tmp['tag'] == 'TEXT') { $pos = 0; $current = current($_SESSION['currentPDFStructure']); // Find section or static text entry to move while($pos < $_GET['down']) { $current = next($_SESSION['currentPDFStructure']); $pos++; } $borders = array(); // We have a section to move if($current['tag'] == 'SECTION'){ $borders[$current['type']][] = $pos; $current = next($_SESSION['currentPDFStructure']); $pos++; // Find end of section to move while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { $current = next($_SESSION['currentPDFStructure']); $pos++; } $borders['close'][] = $pos; } // We have a static text entry to move elseif($current['tag'] == 'TEXT') { $borders['open'][] = $pos; $borders['close'][] = $pos; } $current = next($_SESSION['currentPDFStructure']); $pos++; // Find next section or static text entry in structure if($current) { // Next is a section if($current['tag'] == 'SECTION') { $borders[$current['type']][] = $pos; $current = next($_SESSION['currentPDFStructure']); $pos++; // Find end of this section while($current && $current['tag'] != 'SECTION' && $current['type'] != 'close') { if($current['tag'] == 'SECTION') { $borders[$current['type']][] = $pos; } $current = next($_SESSION['currentPDFStructure']); $pos++; } } // Next is static text entry elseif($current['tag'] == 'TEXT') { $borders['open'][] = $pos; } $borders['close'][] = $pos; } // Move only downwars if not bottenmost element of this structure if(count($borders['open']) > 1) { // Calculate entries to move and move them $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); } } // We have a value entry to move; move it only if it is not the bottmmost // element of this section. elseif($tmp['tag'] == 'ENTRY' && $next['tag'] == 'ENTRY') { $_SESSION['currentPDFStructure'][$_GET['down']] = $_SESSION['currentPDFStructure'][$_GET['down'] + 1]; $_SESSION['currentPDFStructure'][$_GET['down'] + 1] = $tmp; } } // Load PDF structure from file if it is not defined in session if(!isset($_SESSION['currentPDFStructure'])) { // Load structure file to be edit if(isset($_GET['edit'])) { $load = loadPDFStructureDefinitions($_GET['type'],$_GET['edit']); $_SESSION['currentPDFStructure'] = $load['structure']; $_SESSION['currentPageDefinitions'] = $load['page_definitions']; $_GET['pdfname'] = $_GET['edit']; } // Load default structure file when creating a new one else { $load = loadPDFStructureDefinitions($_GET['type']); $_SESSION['currentPDFStructure'] = $load['structure']; $_SESSION['currentPageDefinitions'] = $load['page_definitions']; } } // Load available fields from modules when not set in session if(!isset($_SESSION['availablePDFFields'])) { $_SESSION['availablePDFFields'] = getAvailablePDFFields($_GET['type']); } // Create the values for the dropdown boxes for section headline defined by // value entries and fetch all available modules $modules = array(); $section_items_array = array(); $section_items = ''; $sortedModules = array(); foreach($_SESSION['availablePDFFields'] as $module => $fields) { if ($module != 'main') { $title = getModuleAlias($module, $_GET['type']); } else { $title = _('Main'); } $sortedModules[$module] = $title; } natcasesort($sortedModules); foreach($sortedModules as $module => $title) { $values = $_SESSION['availablePDFFields'][$module]; if (!is_array($values) || (sizeof($values) < 1)) { continue; } $modules[] = $module; $section_items .= ""; natcasesort($values); foreach($values as $attribute => $attributeLabel) { $section_items_array[] = $module . '_' . $attribute; $section_items .= "\n"; } $section_items .= "\n"; } $modules = join(',',$modules); $logoFiles = getAvailableLogos(); $logos = '\n"; foreach($logoFiles as $logoFile) { $logos .= "\n"; } // print header include '../main_header.php'; // TODO Change enctype of form ?>

:      :


' . _('Beginning') . "\n"; $nonTextSections = ''; // Print every entry in the current structure foreach($_SESSION['currentPDFStructure'] as $key => $entry) { // Create the up/down/remove links $links = "\n" . "\n" . "\n" . ""; // We have a new section to start if($entry['tag'] == "SECTION" && $entry['type'] == "open") { $name = $entry['attributes']['NAME']; if(preg_match("/^_[a-zA-Z_]+/",$name)) { $section_headline = substr($name,1); } else { $section_headline = $name; } $nonTextSections .= '\n"; ?> ' . $section_headline . "\n"; ?> ' . _('Static text') . "\n"; ?>
\n" . "\""\n\n" . "\""\n\n" . "\""\n 
    



 


:     :
:     :
 
    :

:

 


:
 
"> ">  



$fields) { if (!(strpos($id, $module . '_') === 0)) { continue; } foreach ($fields as $name => $label) { if ($id == $module . '_' . $name) { if ($module == 'main') { return _('Main') . ': ' . $label; } else { return getModuleAlias($module, $scope) . ': ' . $label; } } } } return $id; } ?>