responsive tools

This commit is contained in:
Roland Gruber 2018-05-10 09:06:19 +02:00
parent c30045b3ad
commit 35d580f217
1 changed files with 115 additions and 110 deletions

View File

@ -1,19 +1,18 @@
<?php <?php
namespace LAM\TOOLS\PDF_EDITOR; namespace LAM\TOOLS\PDF_EDITOR;
use \htmlTable; use \htmlResponsiveRow;
use \htmlResponsiveSelect;
use \htmlResponsiveInputField;
use \htmlTitle; use \htmlTitle;
use \htmlTableExtendedInputField;
use \htmlSpacer;
use \htmlTableExtendedSelect;
use \htmlButton; use \htmlButton;
use \htmlOutputText; use \htmlOutputText;
use \htmlGroup; use \htmlGroup;
use \htmlSelect; use \htmlSelect;
use \htmlInputField; use \htmlInputField;
use \htmlSubTitle; use \htmlSubTitle;
use \htmlFieldset; use \htmlResponsiveInputTextarea;
use \htmlInputTextarea;
use \htmlHiddenInput; use \htmlHiddenInput;
use \htmlSpacer;
use LAM\PDF\PDFStructureReader; use LAM\PDF\PDFStructureReader;
use LAM\PDF\PDFTextSection; use LAM\PDF\PDFTextSection;
use LAM\PDF\PDFEntrySection; use LAM\PDF\PDFEntrySection;
@ -21,11 +20,9 @@ use LAM\PDF\PDFStructure;
use LAM\PDF\PDFSectionEntry; use LAM\PDF\PDFSectionEntry;
use LAM\PDF\PDFStructureWriter; use LAM\PDF\PDFStructureWriter;
/* /*
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Michael Duergner Copyright (C) 2003 - 2006 Michael Duergner
2007 - 2017 Roland Gruber 2007 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -42,7 +39,6 @@ $Id$
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Manages creating/changing of pdf structures. Manages creating/changing of pdf structures.
*/ */
/** /**
@ -184,7 +180,10 @@ foreach($sortedModules as $module => $title) {
$modules = join(',',$modules); $modules = join(',',$modules);
// print header // print header
include '../main_header.php'; include '../../lib/adminHeader.inc';
?>
<div class="user-bright smallPaddingContent">
<?php
// print error messages if any // print error messages if any
if (sizeof($saveErrors) > 0) { if (sizeof($saveErrors) > 0) {
@ -233,31 +232,31 @@ if (isset($_SESSION['currentPDFStructure'])) {
$sectionElements = array(); $sectionElements = array();
$nonTextSectionElements = array(); $nonTextSectionElements = array();
$container = new htmlTable(); $container = new htmlResponsiveRow();
$container->addElement(new htmlTitle(_('PDF editor')), true); $container->add(new htmlTitle(_('PDF editor')), 12);
// main content // main content
$mainContent = new htmlTable(); $mainContent = new htmlResponsiveRow();
$structureNameInput = new htmlTableExtendedInputField(_("Structure name"), 'pdfname', $structureName, '360'); $structureNameInput = new htmlResponsiveInputField(_("Structure name"), 'pdfname', $structureName, '360');
$structureNameInput->setRequired(true); $structureNameInput->setRequired(true);
$mainContent->addElement($structureNameInput, true); $mainContent->add($structureNameInput, 12);
$mainContent->addElement(new htmlTableExtendedInputField(_('Headline'), 'headline', $headline), true); $mainContent->add(new htmlResponsiveInputField(_('Headline'), 'headline', $headline), 12);
$logoSelect = new htmlTableExtendedSelect('logoFile', $logos, $selectedLogo, _('Logo')); $logoSelect = new htmlResponsiveSelect('logoFile', $logos, $selectedLogo, _('Logo'));
$logoSelect->setHasDescriptiveElements(true); $logoSelect->setHasDescriptiveElements(true);
$mainContent->addElement($logoSelect, true); $mainContent->add($logoSelect, 12);
$foldingMarks = 'no'; $foldingMarks = 'no';
if (isset($_SESSION['currentPDFStructure'])) { if (isset($_SESSION['currentPDFStructure'])) {
$foldingMarks = $_SESSION['currentPDFStructure']->getFoldingMarks(); $foldingMarks = $_SESSION['currentPDFStructure']->getFoldingMarks();
} }
$possibleFoldingMarks = array(_('No') => 'no', _('Yes') => 'standard'); $possibleFoldingMarks = array(_('No') => 'no', _('Yes') => 'standard');
$foldingMarksSelect = new htmlTableExtendedSelect('foldingmarks', $possibleFoldingMarks, array($foldingMarks), _('Folding marks')); $foldingMarksSelect = new htmlResponsiveSelect('foldingmarks', $possibleFoldingMarks, array($foldingMarks), _('Folding marks'));
$foldingMarksSelect->setHasDescriptiveElements(true); $foldingMarksSelect->setHasDescriptiveElements(true);
$mainContent->addElement($foldingMarksSelect, true); $mainContent->add($foldingMarksSelect, 12);
$mainContent->addElement(new htmlSpacer(null, '30px'), true); $mainContent->addVerticalSpacer('3rem');
// PDF structure // PDF structure
$structure = $_SESSION['currentPDFStructure']; $structure = $_SESSION['currentPDFStructure'];
// print every entry in the current structure // print every entry in the current structure
$structureContent = new htmlTable(); $structureContent = new htmlResponsiveRow();
$sections = $structure->getSections(); $sections = $structure->getSections();
foreach ($sections as $key => $section) { foreach ($sections as $key => $section) {
// create the up/down/remove links // create the up/down/remove links
@ -267,7 +266,7 @@ foreach ($sections as $key => $section) {
$linkDown->setTitle(_("Down")); $linkDown->setTitle(_("Down"));
$linkRemove = new htmlButton('remove_section_' . $key, 'delete.gif', true); $linkRemove = new htmlButton('remove_section_' . $key, 'delete.gif', true);
$linkRemove->setTitle(_("Remove")); $linkRemove->setTitle(_("Remove"));
$emptyBox = new htmlOutputText(''); $emptyBox = new htmlSpacer('19px', null);
// We have a new section to start // We have a new section to start
if($section instanceof PDFEntrySection) { if($section instanceof PDFEntrySection) {
if($section->isAttributeTitle()) { if($section->isAttributeTitle()) {
@ -278,7 +277,7 @@ foreach ($sections as $key => $section) {
} }
$nonTextSectionElements[$section_headline] = $key; $nonTextSectionElements[$section_headline] = $key;
$sectionElements[$section_headline] = $key; $sectionElements[$section_headline] = $key;
$structureContent->addElement(new htmlSpacer(null, '15px'), true); $structureContent->addVerticalSpacer('2rem');
// Section headline is a value entry // Section headline is a value entry
if($section->isAttributeTitle()) { if($section->isAttributeTitle()) {
$headlineElements = array(); $headlineElements = array();
@ -287,58 +286,56 @@ foreach ($sections as $key => $section) {
} }
$sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, array('_' . $section->getPdfKey())); $sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, array('_' . $section->getPdfKey()));
$sectionHeadlineSelect->setHasDescriptiveElements(true); $sectionHeadlineSelect->setHasDescriptiveElements(true);
$sectionHeadlineGroup = new htmlGroup(); $structureContent->addLabel($sectionHeadlineSelect);
$sectionHeadlineGroup->addElement($sectionHeadlineSelect);
$sectionHeadlineGroup->colspan = 2;
$structureContent->addElement($sectionHeadlineGroup);
} }
// Section headline is a user text // Section headline is a user text
else { else {
$sectionHeadlineInput = new htmlInputField('section_' . $key, $section_headline); $sectionHeadlineInput = new htmlInputField('section_' . $key, $section_headline);
$sectionHeadlineGroup = new htmlGroup(); $structureContent->addLabel($sectionHeadlineInput);
$sectionHeadlineGroup->addElement($sectionHeadlineInput);
$sectionHeadlineGroup->colspan = 2;
$structureContent->addElement($sectionHeadlineGroup);
} }
$actionGroup = new htmlGroup();
if ($key != 0) { if ($key != 0) {
$structureContent->addElement($linkUp); $actionGroup->addElement($linkUp);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
$hasAdditionalSections = $key < (sizeof($sections) - 1); $hasAdditionalSections = $key < (sizeof($sections) - 1);
if ($hasAdditionalSections) { if ($hasAdditionalSections) {
$structureContent->addElement($linkDown); $actionGroup->addElement($linkDown);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
$structureContent->addElement($linkRemove, true); $actionGroup->addElement($linkRemove);
$structureContent->addField($actionGroup);
// add section entries // add section entries
$sectionEntries = $section->getEntries(); $sectionEntries = $section->getEntries();
foreach ($sectionEntries as $e => $sectionEntry) { foreach ($sectionEntries as $e => $sectionEntry) {
$structureContent->addElement(new htmlSpacer('10px', null)); $structureContent->addVerticalSpacer('1rem');
$fieldOutput = new htmlOutputText(translateFieldIDToName($sectionEntry->getKey(), $type->getScope(), $availablePDFFields)); $fieldOutput = new htmlOutputText(translateFieldIDToName($sectionEntry->getKey(), $type->getScope(), $availablePDFFields));
$structureContent->addElement($fieldOutput); $structureContent->addLabel($fieldOutput);
$actionGroup = new htmlGroup();
if ($e != 0) { if ($e != 0) {
$entryLinkUp = new htmlButton('up_entry_' . $key . '_' . $e, 'up.gif', true); $entryLinkUp = new htmlButton('up_entry_' . $key . '_' . $e, 'up.gif', true);
$entryLinkUp->setTitle(_("Up")); $entryLinkUp->setTitle(_("Up"));
$structureContent->addElement($entryLinkUp); $actionGroup->addElement($entryLinkUp);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
if ($e < (sizeof($sectionEntries) - 1)) { if ($e < (sizeof($sectionEntries) - 1)) {
$linkDown = new htmlButton('down_entry_' . $key . '_' . $e, 'down.gif', true); $linkDown = new htmlButton('down_entry_' . $key . '_' . $e, 'down.gif', true);
$linkDown->setTitle(_("Down")); $linkDown->setTitle(_("Down"));
$structureContent->addElement($linkDown); $actionGroup->addElement($linkDown);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
$entryLinkRemove = new htmlButton('remove_entry_' . $key . '_' . $e, 'delete.gif', true); $entryLinkRemove = new htmlButton('remove_entry_' . $key . '_' . $e, 'delete.gif', true);
$entryLinkRemove->setTitle(_("Remove")); $entryLinkRemove->setTitle(_("Remove"));
$structureContent->addElement($entryLinkRemove, true); $actionGroup->addElement($entryLinkRemove, true);
$structureContent->addField($actionGroup);
} }
} }
// We have to include a static text. // We have to include a static text.
@ -353,97 +350,105 @@ foreach ($sections as $key => $section) {
} }
$textSnippet = htmlspecialchars($textSnippet); $textSnippet = htmlspecialchars($textSnippet);
$sectionElements[_('Static text') . ': ' . $textSnippet] = $key; $sectionElements[_('Static text') . ': ' . $textSnippet] = $key;
$structureContent->addElement(new htmlSpacer(null, '15px'), true);
$sectionHeadlineOutput = new htmlOutputText(_('Static text')); $sectionHeadlineOutput = new htmlOutputText(_('Static text'));
$sectionHeadlineOutput->colspan = 2; $structureContent->addLabel($sectionHeadlineOutput);
$structureContent->addElement($sectionHeadlineOutput); $actionGroup = new htmlGroup();
if ($key != 0) { if ($key != 0) {
$structureContent->addElement($linkUp); $actionGroup->addElement($linkUp);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
if ($key != sizeof($sections) - 1) { if ($key != sizeof($sections) - 1) {
$structureContent->addElement($linkDown); $actionGroup->addElement($linkDown);
} }
else { else {
$structureContent->addElement($emptyBox); $actionGroup->addElement($emptyBox);
} }
$structureContent->addElement($linkRemove, true); $actionGroup->addElement($linkRemove, true);
$structureContent->addElement(new htmlSpacer('10px', null)); $structureContent->addField($actionGroup);
$structureContent->addVerticalSpacer('1rem');
$staticTextOutput = new htmlOutputText($section->getText()); $staticTextOutput = new htmlOutputText($section->getText());
$staticTextOutput->setPreformatted(); $staticTextOutput->setPreformatted();
$structureContent->addElement($staticTextOutput, true); $structureContent->add($staticTextOutput, 12);
} }
} }
$sectionElements[_('End')] = sizeof($structure->getSections()); $sectionElements[_('End')] = sizeof($structure->getSections());
$structureContent->colspan = 3; $mainContent->add($structureContent, 12);
$mainContent->addElement($structureContent); $container->add($mainContent, 12);
$container->addElement(new htmlFieldset($mainContent), true); $container->addVerticalSpacer('2rem');
$container->addElement(new htmlSpacer(null, '15px'), true);
// new section
$container->addElement(new htmlSubTitle(_('New section')), true);
$newSectionContent = new htmlTable();
// add new section with text title
$newSectionContent->addElement(new htmlTableExtendedInputField(_("Headline"), 'new_section_text'));
$newSectionPositionSelect1 = new htmlTableExtendedSelect('add_sectionText_position', $sectionElements, array(), _('Position'));
$newSectionPositionSelect1->setHasDescriptiveElements(true);
$newSectionPositionSelect1->setSortElements(false);
$newSectionContent->addElement($newSectionPositionSelect1);
$newSectionContent->addElement(new htmlButton('add_sectionText', _('Add')), true);
// add new section with field title
$newSectionFieldSelect = new htmlTableExtendedSelect('new_section_item', $newFieldFieldElements, array(), _("Headline"));
$newSectionFieldSelect->setHasDescriptiveElements(true);
$newSectionFieldSelect->setContainsOptgroups(true);
$newSectionContent->addElement($newSectionFieldSelect);
$newSectionPositionSelect2 = new htmlTableExtendedSelect('add_section_position', $sectionElements, array(), _('Position'));
$newSectionPositionSelect2->setHasDescriptiveElements(true);
$newSectionPositionSelect2->setSortElements(false);
$newSectionContent->addElement($newSectionPositionSelect2);
$newSectionContent->addElement(new htmlButton('add_section', _('Add')));
$container->addElement(new htmlFieldset($newSectionContent, _("Section")), true);
$container->addElement(new htmlSpacer(null, '10px'), true);
$newTextFieldContent = new htmlTable();
$newTextFieldContent->addElement(new htmlInputTextarea('text_text', '', 40, 3));
$newTextFieldPositionSelect = new htmlTableExtendedSelect('add_text_position', $sectionElements, array(), _('Position'));
$newTextFieldPositionSelect->setHasDescriptiveElements(true);
$newTextFieldPositionSelect->setSortElements(false);
$newTextFieldContent->addElement($newTextFieldPositionSelect);
$newTextFieldContent->addElement(new htmlButton('add_text', _('Add')));
$container->addElement(new htmlFieldset($newTextFieldContent, _("Text field")), true);
// new field // new field
if (!empty($nonTextSectionElements)) { if (!empty($nonTextSectionElements)) {
$container->addElement(new htmlSubTitle(_('New field')), true); $newFieldContainer = new htmlResponsiveRow();
$newFieldContainer = new htmlTable(); $newFieldContainer->add(new htmlSubTitle(_('New field')), 12);
$newFieldFieldSelect = new htmlSelect('new_field', $newFieldFieldElements); $newFieldFieldSelect = new htmlResponsiveSelect('new_field', $newFieldFieldElements, array(), _('Field'));
$newFieldFieldSelect->setHasDescriptiveElements(true); $newFieldFieldSelect->setHasDescriptiveElements(true);
$newFieldFieldSelect->setContainsOptgroups(true); $newFieldFieldSelect->setContainsOptgroups(true);
$newFieldContainer->addElement($newFieldFieldSelect); $newFieldContainer->add($newFieldFieldSelect, 12);
$newFieldContainer->addElement(new htmlSpacer('10px', null)); $newFieldSectionSelect = new htmlResponsiveSelect('add_field_position', $nonTextSectionElements, array(), _('Position'));
$newFieldSectionSelect = new htmlTableExtendedSelect('add_field_position', $nonTextSectionElements, array(), _('Position'));
$newFieldSectionSelect->setHasDescriptiveElements(true); $newFieldSectionSelect->setHasDescriptiveElements(true);
$newFieldContainer->addElement($newFieldSectionSelect); $newFieldContainer->add($newFieldSectionSelect, 12);
$newFieldContainer->addElement(new htmlButton('add_new_field', _('Add'))); $newFieldContainer->addLabel(new htmlOutputText('&nbsp;', false));
$container->addElement(new htmlFieldset($newFieldContainer), true); $newFieldContainer->addField(new htmlButton('add_new_field', _('Add')));
$container->addElement(new htmlSpacer(null, '20px'), true); $container->add($newFieldContainer, 12);
} }
// new section
$container->addVerticalSpacer('1rem');
$newSectionContent = new htmlResponsiveRow();
$newSectionContent->add(new htmlSubTitle(_('New section')), 12);
// add new section with text title
$newSectionContent->add(new htmlResponsiveInputField(_("Headline"), 'new_section_text'), 12);
$newSectionPositionSelect1 = new htmlResponsiveSelect('add_sectionText_position', $sectionElements, array(), _('Position'));
$newSectionPositionSelect1->setHasDescriptiveElements(true);
$newSectionPositionSelect1->setSortElements(false);
$newSectionContent->add($newSectionPositionSelect1, 12);
$newSectionContent->addLabel(new htmlOutputText('&nbsp;', false));
$newSectionContent->addField(new htmlButton('add_sectionText', _('Add')));
$newSectionContent->addVerticalSpacer('2rem');
// add new section with field title
$newSectionFieldSelect = new htmlResponsiveSelect('new_section_item', $newFieldFieldElements, array(), _("Headline"));
$newSectionFieldSelect->setHasDescriptiveElements(true);
$newSectionFieldSelect->setContainsOptgroups(true);
$newSectionContent->add($newSectionFieldSelect, 12);
$newSectionPositionSelect2 = new htmlResponsiveSelect('add_section_position', $sectionElements, array(), _('Position'));
$newSectionPositionSelect2->setHasDescriptiveElements(true);
$newSectionPositionSelect2->setSortElements(false);
$newSectionContent->add($newSectionPositionSelect2, 12);
$newSectionContent->addLabel(new htmlOutputText('&nbsp;', false));
$newSectionContent->addField(new htmlButton('add_section', _('Add')));
// new text area
$container->add($newSectionContent, 12);
$container->addVerticalSpacer('1rem');
$newTextFieldContent = new htmlResponsiveRow();
$newTextFieldContent->add(new htmlSubTitle(_('New text area')), 12);
$newTextFieldContent->add(new htmlResponsiveInputTextarea('text_text', '', 40, 3, _('Static text')), 12);
$newTextFieldPositionSelect = new htmlResponsiveSelect('add_text_position', $sectionElements, array(), _('Position'));
$newTextFieldPositionSelect->setHasDescriptiveElements(true);
$newTextFieldPositionSelect->setSortElements(false);
$newTextFieldContent->add($newTextFieldPositionSelect, 12);
$newTextFieldContent->addLabel(new htmlOutputText('&nbsp;', false));
$newTextFieldContent->addField(new htmlButton('add_text', _('Add')));
$newTextFieldContent->addVerticalSpacer('2rem');
$container->add($newTextFieldContent, 12);
// buttons // buttons
$buttonContainer = new htmlTable(); $buttonContainer = new htmlResponsiveRow();
$saveButton = new htmlButton('submit', _("Save")); $saveButton = new htmlButton('submit', _("Save"));
$saveButton->setIconClass('saveButton'); $saveButton->setIconClass('saveButton');
$cancelButton = new htmlButton('abort', _("Cancel")); $cancelButton = new htmlButton('abort', _("Cancel"));
$cancelButton->setIconClass('cancelButton'); $cancelButton->setIconClass('cancelButton');
$buttonContainer->addElement($saveButton); $buttonGroup = new htmlGroup();
$buttonContainer->addElement($cancelButton); $buttonGroup->addElement($saveButton);
$buttonContainer->addElement(new htmlHiddenInput('modules', $modules)); $buttonGroup->addElement($cancelButton);
$buttonContainer->addElement(new htmlHiddenInput('type', $type->getId())); $buttonContainer->add($buttonGroup, 12);
$buttonContainer->addElement(new htmlHiddenInput('form_submit', 'true')); $buttonContainer->add(new htmlHiddenInput('modules', $modules), 4);
$buttonContainer->add(new htmlHiddenInput('type', $type->getId()), 4);
$buttonContainer->add(new htmlHiddenInput('form_submit', 'true'), 4);
$container->addElement($buttonContainer, true); $container->add($buttonContainer, 12);
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
$tabindex = 1; $tabindex = 1;
@ -459,8 +464,8 @@ if ((sizeof($saveErrors) == 0) && isset($_POST['scrollPositionTop']) && isset($_
</script>'; </script>';
} }
echo '</form>'; echo '</form></div>';
include '../main_footer.php'; include '../../lib/adminFooter.inc';
/** /**