From 695f94e3227ccfd0469f98232b3cbf5e85606f0e Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 6 Jan 2017 10:11:47 +0100 Subject: [PATCH] new type API for PDF --- lam/templates/pdfedit/pdfmain.php | 125 +++++++++++++++++------------- 1 file changed, 73 insertions(+), 52 deletions(-) diff --git a/lam/templates/pdfedit/pdfmain.php b/lam/templates/pdfedit/pdfmain.php index 43470fc8..acec5114 100644 --- a/lam/templates/pdfedit/pdfmain.php +++ b/lam/templates/pdfedit/pdfmain.php @@ -40,7 +40,7 @@ $Id$ */ /** -* This is the main window of the pdf structure editor. +* This is the main window of the PDF structure editor. * * @author Michael Duergner * @author Roland Gruber @@ -72,7 +72,7 @@ if (!empty($_POST)) { setlanguage(); -// Unset pdf structure definitions in session if set +// Unset PDF structure definitions in session if set if(isset($_SESSION['currentPDFStructure'])) { unset($_SESSION['currentPDFStructure']); unset($_SESSION['currentPageDefinitions']); @@ -124,7 +124,7 @@ foreach ($configProfiles as $profileName) { $serverProfiles[$profileName] = new \LAMConfig($profileName); } -// import profiles +// import structures if (!empty($_POST['import'])) { $cfg = new LAMCfgMain(); $typeId = $_POST['typeId']; @@ -147,7 +147,30 @@ if (!empty($_POST['import'])) { } } - +// export structures +if (!empty($_POST['export'])) { + $cfg = new LAMCfgMain(); + $typeId = $_POST['typeId']; + // check master password + $errMessage = null; + if (!$cfg->checkPassword($_POST['passwd_e_' . $_POST['typeId']])) { + $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); + } + elseif (!empty($_POST['exportProfiles_' . $typeId])) { + $options = array(); + foreach ($_POST['exportProfiles_' . $typeId] as $importProfiles) { + $parts = explode('##', $importProfiles); + $options[] = array('conf' => $parts[0], 'typeId' => $parts[1]); + } + $typeId = $_POST['typeId']; + $name = $_POST['name_' . $typeId]; + $errMessage = exportStructures($typeId, $name, $options, $serverProfiles, $typeManager); + } + if ($errMessage != null) { + $errMessage->colspan = 10; + $container->addElement($errMessage, true); + } +} // upload logo file if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) { @@ -334,54 +357,52 @@ include '../main_header.php'; echo ''; echo "\n"; + + //export dialog + echo "
\n"; + echo "
\n"; + + $container = new htmlTable(); + + $container->addElement(new htmlOutputText(_("Target server profile")), true); + $exportOptions = array(); + foreach ($configProfiles as $profile) { + $typeManagerExport = new \LAM\TYPES\TypeManager($serverProfiles[$profile]); + $typesExport = $typeManagerExport->getConfiguredTypesForScope($scope); + foreach ($typesExport as $typeExport) { + if (($profile != $_SESSION['config']->getName()) || ($typeExport->getId() != $typeId)) { + $exportOptions[$typeManagerExport->getConfig()->getName()][$typeExport->getAlias()] = $profile . '##' . $typeExport->getId(); + } + } + } + $exportOptions['*' . _('Global templates')][_('Global templates')] = 'templates*##'; + + $select = new htmlSelect('exportProfiles_' . $typeId, $exportOptions, array(), count($exportOptions) < 10 ? count($exportOptions, 1) : 10); + $select->setHasDescriptiveElements(true); + $select->setContainsOptgroups(true); + $select->setMultiSelect(true); + + $container->addElement($select); + $container->addElement(new htmlHelpLink('363'), true); + + $container->addElement(new htmlSpacer(null, '10px'), true); + + $container->addElement(new htmlOutputText(_("Master password")), true); + $exportPasswd = new htmlInputField('passwd_e_' . $typeId); + $exportPasswd->setIsPassword(true); + $container->addElement($exportPasswd); + $container->addElement(new htmlHelpLink('236')); + $container->addElement(new htmlHiddenInput('export', '1'), true); + $container->addElement(new htmlHiddenInput('typeId', $typeId), true); + $container->addElement(new htmlHiddenInput('name_' . $typeId, '_'), true); + addSecurityTokenToMetaHTML($container); + + parseHtml(null, $container, array(), false, $tabindex, 'user'); + + echo '
'; + echo "
\n"; } - //export dialog - echo "
\n"; - echo "
\n"; - - $container = new htmlTable(); - - $container->addElement(new htmlOutputText(_('PDF structure')), true); - $expStructGroup = new htmlTable(); - $expStructGroup->addElement(new htmlSpacer('10px', null)); - $expStructGroup->addElement(new htmlDiv('exportName', '')); - $container->addElement($expStructGroup, true); - $container->addElement(new htmlSpacer(null, '10px'), true); - - $container->addElement(new htmlOutputText(_("Target server profile")), true); - foreach ($configProfiles as $key => $value) { - $tmpProfiles[$value] = $value; - } - natcasesort($tmpProfiles); - $tmpProfiles['*' . _('Global templates')] = 'templates*'; - - $findProfile = array_search($_SESSION['config']->getName(), $tmpProfiles); - if ($findProfile !== false) { - unset($tmpProfiles[$findProfile]); - } - $select = new htmlSelect('destServerProfiles', $tmpProfiles, array(), count($tmpProfiles) < 10 ? count($tmpProfiles) : 10); - $select->setHasDescriptiveElements(true); - $select->setSortElements(false); - $select->setMultiSelect(true); - - $container->addElement($select); - $container->addElement(new htmlHelpLink('409'), true); - $container->addElement(new htmlSpacer(null, '10px'), true); - - $container->addElement(new htmlOutputText(_("Master password")), true); - $exportPasswd = new htmlInputField('passwd'); - $exportPasswd->setIsPassword(true); - $container->addElement($exportPasswd); - $container->addElement(new htmlHelpLink('236')); - $container->addElement(new htmlHiddenInput('importexport', '1'), true); - addSecurityTokenToMetaHTML($container); - - parseHtml(null, $container, array(), false, $tabindex, 'user'); - - echo '
'; - echo "
\n"; - // form for delete action echo '