From adc661eb65a1357b2d7bef7c6d31bd9f9f4fabe9 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 21 Dec 2010 14:30:42 +0000 Subject: [PATCH] migrated to new meta HTML classes --- lam/templates/pdfedit/pdfpage.php | 473 ++++++++++++------------------ 1 file changed, 181 insertions(+), 292 deletions(-) diff --git a/lam/templates/pdfedit/pdfpage.php b/lam/templates/pdfedit/pdfpage.php index dd040f42..53d51d27 100644 --- a/lam/templates/pdfedit/pdfpage.php +++ b/lam/templates/pdfedit/pdfpage.php @@ -153,15 +153,6 @@ elseif(isset($_GET['add_new_field'])) { // 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; @@ -324,6 +315,15 @@ elseif(isset($_GET['down'])) { } } +// Change section headline +foreach ($_GET as $key => $value) { + if(strpos($key, 'change_') === 0) { + $alter = explode('_', $key); + $newvalue = $_GET['section_' . $alter[1]]; + $_SESSION['currentPDFStructure'][$alter[1]]['attributes']['NAME'] = $newvalue; + } +} + // Load PDF structure from file if it is not defined in session if(!isset($_SESSION['currentPDFStructure'])) { // Load structure file to be edit @@ -378,12 +378,6 @@ foreach($sortedModules as $module => $title) { } $modules = join(',',$modules); -$logoFiles = getAvailableLogos(); -$logos = '\n"; -foreach($logoFiles as $logoFile) { - $logos .= "\n"; -} - // print header include '../main_header.php'; @@ -395,89 +389,77 @@ if (sizeof($saveErrors) > 0) { echo "
\n"; } +$newFieldFieldElements = array(); +foreach($sortedModules as $module => $title) { + $fields = $_SESSION['availablePDFFields'][$module]; + if (isset($fields) && is_array($fields) && (sizeof($fields) > 0)) { + $moduleFields = array(); + foreach ($fields as $field => $fieldLabel) { + $moduleFields[$fieldLabel] = $module . "_" . $field; + } + $newFieldFieldElements[$title] = $moduleFields; + } +} + +// structure name +$structureName = ''; +if (isset($_GET['edit'])) { + $structureName = $_GET['edit']; +} +elseif (isset($_GET['pdfname'])) { + $structureName = $_GET['pdfname']; +} +else if (isset($_POST['pdfname'])) { + $structureName = $_POST['pdfname']; +} +// headline +$headline = 'LDAP Account Manager'; +if (isset($_SESSION['currentPageDefinitions']['headline'])) { + $headline = $_SESSION['currentPageDefinitions']['headline']; +} +// logo +$logoFiles = getAvailableLogos(); +$logos = array(_('No logo') => 'none'); +foreach($logoFiles as $logoFile) { + $logos[$logoFile['filename'] . ' (' . $logoFile['infos'][0] . ' x ' . $logoFile['infos'][1] . ")"] = $logoFile['filename']; +} +$selectedLogo = array('printLogo.jpg'); +if (isset($_SESSION['currentPageDefinitions']['filename'])) { + $selectedLogo = array($_SESSION['currentPageDefinitions']['filename']); +} + ?>
- - - - - - - - - - - - -
- - -
- : - - - - - -   - - -
-
-
- - - -
- : - -      - : - -


- ' . _('Beginning') . "\n"; -$nonTextSections = ''; -// Print every entry in the current structure +$sectionElements = array(_('Beginning') => 0); +$nonTextSectionElements = array(); + +$container = new htmlTable(); +$container->addElement(new htmlTitle(_('PDF editor')), true); + +// main content +$mainContent = new htmlTable(); +$structureNameInput = new htmlTableExtendedInputField(_("Structure name"), 'pdfname', $structureName, '360'); +$structureNameInput->setRequired(true); +$mainContent->addElement($structureNameInput, true); +$mainContent->addElement(new htmlTableExtendedInputField(_('Headline'), 'headline', $headline), true); +$logoSelect = new htmlTableExtendedSelect('logoFile', $logos, $selectedLogo, _('Logo')); +$logoSelect->setHasDescriptiveElements(true); +$mainContent->addElement($logoSelect, true); +$mainContent->addElement(new htmlSpacer(null, '30px'), true); +// PDF structure +// print every entry in the current structure +$structureContent = new htmlTable(); foreach($_SESSION['currentPDFStructure'] as $key => $entry) { - // Create the up/down/remove links - $links = "\n" . - "\n" . - "\n" . - ""; + // create the up/down/remove links + $linkBase = 'pdfpage.php?type=' . $_GET['type'] . '&pdfname=' . $structureName . '&headline=' . $headline . '&logoFile=' . $selectedLogo[0]; + $linkUp = new htmlLink(null, $linkBase . '&up=' . $key, '../../graphics/up.gif'); + $linkUp->setTitle(_("Up")); + $linkDown = new htmlLink(null, $linkBase . '&down=' . $key, '../../graphics/down.gif'); + $linkDown->setTitle(_("Down")); + $linkRemove = new htmlLink(null, $linkBase . '&remove=' . $key, '../../graphics/delete.gif'); + $linkRemove->setTitle(_("Remove")); // We have a new section to start if($entry['tag'] == "SECTION" && $entry['type'] == "open") { $name = $entry['attributes']['NAME']; @@ -487,226 +469,133 @@ foreach($_SESSION['currentPDFStructure'] as $key => $entry) { else { $section_headline = $name; } - $nonTextSections .= '\n"; - $sections .= '\n"; - ?> - - - - - - - - - - addElement($linkUp); + $structureContent->addElement($linkDown); + $structureContent->addElement($linkRemove, true); } // We have to include a static text. elseif($entry['tag'] == "TEXT") { // Add current satic text for dropdown box needed for the position when inserting a new // section or static text entry - $sections .= '\n"; - ?> - - - - - - - - - - - - - - - - addElement(new htmlSpacer(null, '15px'), true); + $sectionHeadlineOutput = new htmlOutputText(_('Static text')); + $sectionHeadlineOutput->colspan = 2; + $structureContent->addElement($sectionHeadlineOutput); + $structureContent->addElement($linkUp); + $structureContent->addElement($linkDown); + $structureContent->addElement($linkRemove, true); + $structureContent->addElement(new htmlSpacer('10px', null)); + $staticTextOutput = new htmlOutputText($entry['value']); + $structureContent->addElement($staticTextOutput, true); } // We have to include an entry from the account elseif($entry['tag'] == "ENTRY") { // Get name of current entry $name = $entry['attributes']['NAME']; - ?> - - - - - - - addElement(new htmlSpacer('10px', null)); + $fieldOutput = new htmlOutputText(translateFieldIDToName($name, $_GET['type'])); + $structureContent->addElement($fieldOutput); + $structureContent->addElement($linkUp); + $structureContent->addElement($linkDown); + $structureContent->addElement($linkRemove, true); } } -// Print the boxes for adding new sections and static text entries -// Print save and abort buttons -?> -
\n" . - "\""\n\n" . - "\""\n\n" . - "\""\n 
- addElement(new htmlSpacer(null, '15px'), true); // Section headline is a value entry if(preg_match("/^_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+/",$name)) { - ?> - - - setHasDescriptiveElements(true); + $sectionHeadlineGroup = new htmlGroup(); + $sectionHeadlineGroup->addElement($sectionHeadlineSelect); + $sectionHeadlineGroup->addElement(new htmlButton('change_' . $key, _('Change'))); + $sectionHeadlineGroup->colspan = 2; + $structureContent->addElement($sectionHeadlineGroup); } // Section headline is a user text else { - ?> -    - addElement($sectionHeadlineInput); + $sectionHeadlineGroup->addElement(new htmlButton('change_' . $key, _('Change'))); + $sectionHeadlineGroup->colspan = 2; + $structureContent->addElement($sectionHeadlineGroup); } - ?> -  
-
-
- - -
-
-
- - -
-
-
- - - -
-
-

 

-
-
- - -
- - - - - - - - - - -
-
- - - - - - - - - - - - - - -
- :     - - : - - - -
- : -     - - : - - - -
-
-
 
-
- - - - - - - - - -
-     - - : - - - -
-
-
-
-
-
- - -
- - : - - -
-
- - -
+$structureContent->colspan = 3; +$mainContent->addElement($structureContent); +$container->addElement(new htmlFieldset($mainContent), true); +$container->addElement(new htmlSpacer(null, '15px'), true); -addElement(new htmlSubTitle(_('New section')), true); +$newSectionContent = new htmlTable(); +// add new section with text title +$newSectionContent->addElement(new htmlTableExtendedInputField(_("Headline"), '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('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 +$container->addElement(new htmlSubTitle(_('New field')), true); +$newFieldContainer = new htmlTable(); +$newFieldFieldSelect = new htmlSelect('new_field', $newFieldFieldElements); +$newFieldFieldSelect->setHasDescriptiveElements(true); +$newFieldFieldSelect->setContainsOptgroups(true); +$newFieldContainer->addElement($newFieldFieldSelect); +$newFieldContainer->addElement(new htmlSpacer('10px', null)); +$newFieldSectionSelect = new htmlTableExtendedSelect('add_field_position', $nonTextSectionElements, array(), _('Position')); +$newFieldSectionSelect->setHasDescriptiveElements(true); +$newFieldContainer->addElement($newFieldSectionSelect); +$newFieldContainer->addElement(new htmlButton('add_new_field', _('Add'))); +$container->addElement(new htmlFieldset($newFieldContainer), true); +$container->addElement(new htmlSpacer(null, '20px'), true); + +// buttons +$buttonContainer = new htmlTable(); +$saveButton = new htmlButton('submit', _("Save")); +$saveButton->setIconClass('saveButton'); +$cancelButton = new htmlButton('abort', _("Cancel")); +$cancelButton->setIconClass('cancelButton'); +$buttonContainer->addElement($saveButton); +$buttonContainer->addElement($cancelButton); +$buttonContainer->addElement(new htmlHiddenInput('modules', $modules)); +$buttonContainer->addElement(new htmlHiddenInput('type', $_GET['type'])); + +$container->addElement($buttonContainer, true); + +$tabindex = 1; +parseHtml(null, $container, array(), false, $tabindex, $_GET['type']); + +echo ''; include '../main_footer.php';