new type API for PDF
This commit is contained in:
parent
22cfb56f60
commit
a9234c1537
|
@ -690,7 +690,7 @@ class lamList {
|
||||||
$selAccounts[] = $id;
|
$selAccounts[] = $id;
|
||||||
}
|
}
|
||||||
// get possible PDF structures
|
// get possible PDF structures
|
||||||
$pdf_structures = getPDFStructureDefinitions($this->type->getId());
|
$pdf_structures = \LAM\PDF\getPDFStructureDefinitions($this->type->getId());
|
||||||
|
|
||||||
$this->listPrintHeader();
|
$this->listPrintHeader();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
use LAM\TYPES\ConfiguredType;
|
use LAM\TYPES\ConfiguredType;
|
||||||
|
use function LAM\TYPES\getScopeFromTypeId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id$
|
$Id$
|
||||||
|
@ -401,14 +402,14 @@ function getHelp($module,$helpID,$scope='') {
|
||||||
/**
|
/**
|
||||||
* Returns a list of available PDF entries.
|
* Returns a list of available PDF entries.
|
||||||
*
|
*
|
||||||
* @param string $scope account type (user, group, host)
|
* @param string $typeId account type (user, group, host)
|
||||||
* @return array PDF entries (field ID => field label)
|
* @return array PDF entries (field ID => field label)
|
||||||
*/
|
*/
|
||||||
function getAvailablePDFFields($scope) {
|
function getAvailablePDFFields($typeId) {
|
||||||
$mods = $_SESSION['config']->get_AccountModules($scope);
|
$mods = $_SESSION['config']->get_AccountModules($typeId);
|
||||||
$return = array();
|
$return = array();
|
||||||
for ($i = 0; $i < sizeof($mods); $i++) {
|
for ($i = 0; $i < sizeof($mods); $i++) {
|
||||||
$module = moduleCache::getModule($mods[$i], $scope);
|
$module = moduleCache::getModule($mods[$i], getScopeFromTypeId($typeId));
|
||||||
$fields = $module->get_pdfFields();
|
$fields = $module->get_pdfFields();
|
||||||
$return[$mods[$i]] = array();
|
$return[$mods[$i]] = array();
|
||||||
if (is_array($fields)) {
|
if (is_array($fields)) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ function createModulePDF($accounts, $pdf_structure="default", $returnAsString =
|
||||||
|
|
||||||
$account_type = $accounts[0]->get_type();
|
$account_type = $accounts[0]->get_type();
|
||||||
// Get PDF structure from xml file
|
// Get PDF structure from xml file
|
||||||
$load = loadPDFStructureDefinitions($account_type->getId(), $pdf_structure);
|
$load = \LAM\PDF\loadPDFStructureDefinitions($account_type->getId(), $pdf_structure);
|
||||||
$structure = $load['structure'];
|
$structure = $load['structure'];
|
||||||
// get list of PDF keys
|
// get list of PDF keys
|
||||||
$pdfKeys = array();
|
$pdfKeys = array();
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace LAM\PDF;
|
||||||
|
|
||||||
|
use \htmlStatusMessage;
|
||||||
/*
|
/*
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
@ -75,14 +78,14 @@ function getPDFStructureDefinitions($scope = "user", $profile = null) {
|
||||||
*
|
*
|
||||||
* @return array PDF structure
|
* @return array PDF structure
|
||||||
*/
|
*/
|
||||||
function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') {
|
function loadPDFStructureDefinitions($scope='user', $pdf_structure='default') {
|
||||||
$parser = new xmlParser();
|
$parser = new xmlParser();
|
||||||
$file = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/' . $pdf_structure . '.' . $scope . '.xml';
|
$file = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/' . $pdf_structure . '.' . $scope . '.xml';
|
||||||
$xml = $parser->parse($file);
|
$xml = $parser->parse($file);
|
||||||
$border = array();
|
$border = array();
|
||||||
$structure = array();
|
$structure = array();
|
||||||
$complete_page_definitions = array('filename' => 'printLogo.jpg', 'headline' => 'LDAP Account Manager');
|
$complete_page_definitions = array('filename' => 'printLogo.jpg', 'headline' => 'LDAP Account Manager');
|
||||||
if($xml[0][$xml[1]['PDF'][0]]['attributes']['TYPE'] == $scope) {
|
if (!empty($xml)) {
|
||||||
$border['start'] = $xml[1]['PDF'][0];
|
$border['start'] = $xml[1]['PDF'][0];
|
||||||
$page_definitions = $xml[0][$xml[1]['PDF'][0]]['attributes'];
|
$page_definitions = $xml[0][$xml[1]['PDF'][0]]['attributes'];
|
||||||
foreach($page_definitions as $key => $value) {
|
foreach($page_definitions as $key => $value) {
|
||||||
|
@ -90,8 +93,8 @@ function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') {
|
||||||
unset($page_definitions[$key]);
|
unset($page_definitions[$key]);
|
||||||
}
|
}
|
||||||
$border['end'] = $xml[1]['PDF'][1];
|
$border['end'] = $xml[1]['PDF'][1];
|
||||||
|
$structure = array_slice($xml[0],$border['start'] + 1,$border['end'] - ($border['start'] + 1));
|
||||||
}
|
}
|
||||||
$structure = array_slice($xml[0],$border['start'] + 1,$border['end'] - ($border['start'] + 1));
|
|
||||||
return array('structure' => $structure, 'page_definitions' => $complete_page_definitions);
|
return array('structure' => $structure, 'page_definitions' => $complete_page_definitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +106,7 @@ function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') {
|
||||||
* @param string $definition Name of definition
|
* @param string $definition Name of definition
|
||||||
* @return string "no perms" if access denied or "ok".
|
* @return string "no perms" if access denied or "ok".
|
||||||
*/
|
*/
|
||||||
function savePDFStructureDefinitions($scope,$definition) {
|
function savePDFStructureDefinitions($scope, $definition) {
|
||||||
if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return 'no perms';
|
if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return 'no perms';
|
||||||
if (!preg_match('/[a-zA-Z]+/',$scope)) return 'no perms';
|
if (!preg_match('/[a-zA-Z]+/',$scope)) return 'no perms';
|
||||||
$struct_file = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/' . $definition . '.' . $scope . '.xml';
|
$struct_file = dirname(__FILE__) . '/../config/pdf/' . $_SESSION['config']->getName() . '/' . $definition . '.' . $scope . '.xml';
|
||||||
|
@ -115,11 +118,9 @@ function savePDFStructureDefinitions($scope,$definition) {
|
||||||
if (!$handle) return 'no perms';
|
if (!$handle) return 'no perms';
|
||||||
$pdf_attributes = '';
|
$pdf_attributes = '';
|
||||||
foreach($_SESSION['currentPageDefinitions'] as $key => $value) {
|
foreach($_SESSION['currentPageDefinitions'] as $key => $value) {
|
||||||
if($key != 'type') {
|
$pdf_attributes .= ' ' . $key . '="' . $value . '"';
|
||||||
$pdf_attributes .= ' ' . $key . '="' . $value . '"';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$file = '<pdf type="' . $scope . "\"" . $pdf_attributes . ">\n";
|
$file = '<pdf' . $pdf_attributes . ">\n";
|
||||||
foreach($_SESSION['currentPDFStructure'] as $entry) {
|
foreach($_SESSION['currentPDFStructure'] as $entry) {
|
||||||
$ident = '';
|
$ident = '';
|
||||||
for($i=0;$i<$entry['level'] -1;$i++) {
|
for($i=0;$i<$entry['level'] -1;$i++) {
|
||||||
|
@ -289,7 +290,7 @@ function deletePDFLogo($name) {
|
||||||
$data = loadPDFStructureDefinitions($type, $structure);
|
$data = loadPDFStructureDefinitions($type, $structure);
|
||||||
if ($data['page_definitions']['filename'] == $name) {
|
if ($data['page_definitions']['filename'] == $name) {
|
||||||
return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'),
|
return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'),
|
||||||
sprintf(_('Logo is still in use by PDF structure "%s" in account type "%s".'), $structure, LAM\TYPES\getTypeAlias($type)));
|
sprintf(_('Logo is still in use by PDF structure "%s" in account type "%s".'), $structure, \LAM\TYPES\getTypeAlias($type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace LAM\PDF;
|
||||||
/*
|
/*
|
||||||
$Id$
|
$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
|
||||||
|
2017 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
|
||||||
|
@ -22,44 +24,44 @@ $Id$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple XML parser.
|
* Simple XML parser.
|
||||||
*
|
*
|
||||||
* @author Michael Duergner
|
* @author Michael Duergner
|
||||||
* @package PDF
|
* @package PDF
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple XML parser.
|
* Simple XML parser.
|
||||||
*
|
*
|
||||||
* @author Michael Duergner
|
* @author Michael Duergner
|
||||||
* @package PDF
|
* @package PDF
|
||||||
*/
|
*/
|
||||||
class xmlParser {
|
class xmlParser {
|
||||||
|
|
||||||
/** XML parser */
|
/** XML parser */
|
||||||
private $xmlParser;
|
private $xmlParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$this->xmlParser = xml_parser_create();
|
$this->xmlParser = xml_parser_create();
|
||||||
xml_set_object($this->xmlParser,$this);
|
xml_set_object($this->xmlParser, $this);
|
||||||
xml_parser_set_option($this->xmlParser, XML_OPTION_CASE_FOLDING, 1);
|
xml_parser_set_option($this->xmlParser, XML_OPTION_CASE_FOLDING, 1);
|
||||||
xml_parser_set_option($this->xmlParser, XML_OPTION_SKIP_WHITE, 1);
|
xml_parser_set_option($this->xmlParser, XML_OPTION_SKIP_WHITE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the parsing.
|
* Starts the parsing.
|
||||||
*
|
*
|
||||||
* @param String $filename file name
|
* @param String $filename file name
|
||||||
* @return array XML structure
|
* @return array XML structure
|
||||||
*/
|
*/
|
||||||
function parse($filename) {
|
function parse($filename) {
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
$xmlStructure = array();
|
$xmlStructure = array();
|
||||||
$xmlIndex = array();
|
$xmlIndex = array();
|
||||||
xml_parse_into_struct($this->xmlParser,implode("\n",file($filename)),$xmlStructure,$xmlIndex);
|
xml_parse_into_struct($this->xmlParser, implode("\n", file($filename)), $xmlStructure, $xmlIndex);
|
||||||
return array($xmlStructure,$xmlIndex);
|
return array($xmlStructure, $xmlIndex);
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ setlanguage();
|
||||||
// Unset pdf structure definitions in session if set
|
// Unset pdf structure definitions in session if set
|
||||||
if(isset($_SESSION['currentPDFStructure'])) {
|
if(isset($_SESSION['currentPDFStructure'])) {
|
||||||
unset($_SESSION['currentPDFStructure']);
|
unset($_SESSION['currentPDFStructure']);
|
||||||
unset($_SESSION['availablePDFFields']);
|
|
||||||
unset($_SESSION['currentPageDefinitions']);
|
unset($_SESSION['currentPageDefinitions']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ $container->addElement(new htmlTitle(_('PDF editor')), true);
|
||||||
|
|
||||||
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
||||||
// delete structure
|
// delete structure
|
||||||
if (deletePDFStructureDefinition($_POST['profileDeleteType'], $_POST['profileDeleteName'])) {
|
if (\LAM\PDF\deletePDFStructureDefinition($_POST['profileDeleteType'], $_POST['profileDeleteName'])) {
|
||||||
$message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), \LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
$message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), \LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
||||||
$message->colspan = 10;
|
$message->colspan = 10;
|
||||||
$container->addElement($message, true);
|
$container->addElement($message, true);
|
||||||
|
@ -127,7 +126,7 @@ if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
if (!$cfg->checkPassword($_POST['passwd_' . $_POST['typeId']])) {
|
if (!$cfg->checkPassword($_POST['passwd_' . $_POST['typeId']])) {
|
||||||
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
||||||
}
|
}
|
||||||
elseif (copyPdfProfiles($_POST['importProfiles_' . $_POST['typeId']], $_POST['typeId'])) {
|
elseif (\LAM\PDF\copyPdfProfiles($_POST['importProfiles_' . $_POST['typeId']], $_POST['typeId'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('INFO', _('Import successful'));
|
$impExpMessage = new htmlStatusMessage('INFO', _('Import successful'));
|
||||||
}
|
}
|
||||||
} else if (isset($_POST['exportProfiles'])) {
|
} else if (isset($_POST['exportProfiles'])) {
|
||||||
|
@ -135,7 +134,7 @@ if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
if (!$cfg->checkPassword($_POST['passwd'])) {
|
if (!$cfg->checkPassword($_POST['passwd'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
||||||
}
|
}
|
||||||
elseif (copyPdfProfiles($_POST['exportProfiles'], $_POST['typeId'], $_POST['destServerProfiles'])) {
|
elseif (\LAM\PDF\copyPdfProfiles($_POST['exportProfiles'], $_POST['typeId'], $_POST['destServerProfiles'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('INFO', _('Export successful'));
|
$impExpMessage = new htmlStatusMessage('INFO', _('Export successful'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,13 +148,13 @@ if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) {
|
if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) {
|
||||||
$file = $_FILES['logoUpload']['tmp_name'];
|
$file = $_FILES['logoUpload']['tmp_name'];
|
||||||
$filename = $_FILES['logoUpload']['name'];
|
$filename = $_FILES['logoUpload']['name'];
|
||||||
$container->addElement(uploadPDFLogo($file, $filename), true);
|
$container->addElement(\LAM\PDF\uploadPDFLogo($file, $filename), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete logo file
|
// delete logo file
|
||||||
if (isset($_POST['delLogo'])) {
|
if (isset($_POST['delLogo'])) {
|
||||||
$toDel = $_POST['logo'];
|
$toDel = $_POST['logo'];
|
||||||
$container->addElement(deletePDFLogo($toDel), true);
|
$container->addElement(\LAM\PDF\deletePDFLogo($toDel), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get list of account types
|
// get list of account types
|
||||||
|
@ -172,7 +171,7 @@ foreach ($sortedTypes as $typeId => $title) {
|
||||||
}
|
}
|
||||||
// get list of templates for each account type
|
// get list of templates for each account type
|
||||||
for ($i = 0; $i < sizeof($templateClasses); $i++) {
|
for ($i = 0; $i < sizeof($templateClasses); $i++) {
|
||||||
$templateClasses[$i]['templates'] = getPDFStructureDefinitions($templateClasses[$i]['typeId']);
|
$templateClasses[$i]['templates'] = \LAM\PDF\getPDFStructureDefinitions($templateClasses[$i]['typeId']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if a template should be edited
|
// check if a template should be edited
|
||||||
|
@ -255,7 +254,7 @@ include '../main_header.php';
|
||||||
$logoContainer = new htmlTable();
|
$logoContainer = new htmlTable();
|
||||||
$logoContainer->addElement(new htmlSpacer(null, '30px'), true);
|
$logoContainer->addElement(new htmlSpacer(null, '30px'), true);
|
||||||
$logoContainer->addElement(new htmlSubTitle(_('Manage logos')), true);
|
$logoContainer->addElement(new htmlSubTitle(_('Manage logos')), true);
|
||||||
$logos = getAvailableLogos();
|
$logos = \LAM\PDF\getAvailableLogos();
|
||||||
$logoOptions = array();
|
$logoOptions = array();
|
||||||
foreach ($logos as $logo) {
|
foreach ($logos as $logo) {
|
||||||
$file = $logo['filename'];
|
$file = $logo['filename'];
|
||||||
|
@ -287,7 +286,7 @@ include '../main_header.php';
|
||||||
$tmpArr = array();
|
$tmpArr = array();
|
||||||
foreach ($configProfiles as $profile) {
|
foreach ($configProfiles as $profile) {
|
||||||
if ($profile != $_SESSION['config']->getName()) {
|
if ($profile != $_SESSION['config']->getName()) {
|
||||||
$accountProfiles = getPDFStructureDefinitions($typeId, $profile);
|
$accountProfiles = \LAM\PDF\getPDFStructureDefinitions($typeId, $profile);
|
||||||
for ($p = 0; $p < sizeof($accountProfiles); $p++) {
|
for ($p = 0; $p < sizeof($accountProfiles); $p++) {
|
||||||
$tmpArr[$profile][$accountProfiles[$p]] = $profile . '##' . $accountProfiles[$p];
|
$tmpArr[$profile][$accountProfiles[$p]] = $profile . '##' . $accountProfiles[$p];
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ if(isset($_GET['submit'])) {
|
||||||
$saveErrors[] = array('ERROR', _('PDF structure name not valid'), _('The name for that PDF-structure you submitted is not valid. A valid name must consist of the following characters: \'a-z\',\'A-Z\',\'0-9\',\'_\',\'-\'.'));
|
$saveErrors[] = array('ERROR', _('PDF structure name not valid'), _('The name for that PDF-structure you submitted is not valid. A valid name must consist of the following characters: \'a-z\',\'A-Z\',\'0-9\',\'_\',\'-\'.'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return = savePDFStructureDefinitions($type->getId(), $_GET['pdfname']);
|
$return = \LAM\PDF\savePDFStructureDefinitions($type->getId(), $_GET['pdfname']);
|
||||||
if($return == 'ok') {
|
if($return == 'ok') {
|
||||||
metaRefresh('pdfmain.php?savedSuccessfully=' . $_GET['pdfname']);
|
metaRefresh('pdfmain.php?savedSuccessfully=' . $_GET['pdfname']);
|
||||||
exit;
|
exit;
|
||||||
|
@ -356,23 +356,20 @@ foreach ($_GET as $key => $value) {
|
||||||
if(!isset($_SESSION['currentPDFStructure'])) {
|
if(!isset($_SESSION['currentPDFStructure'])) {
|
||||||
// Load structure file to be edit
|
// Load structure file to be edit
|
||||||
if(isset($_GET['edit'])) {
|
if(isset($_GET['edit'])) {
|
||||||
$load = loadPDFStructureDefinitions($type->getId(), $_GET['edit']);
|
$load = \LAM\PDF\loadPDFStructureDefinitions($type->getId(), $_GET['edit']);
|
||||||
$_SESSION['currentPDFStructure'] = $load['structure'];
|
$_SESSION['currentPDFStructure'] = $load['structure'];
|
||||||
$_SESSION['currentPageDefinitions'] = $load['page_definitions'];
|
$_SESSION['currentPageDefinitions'] = $load['page_definitions'];
|
||||||
$_GET['pdfname'] = $_GET['edit'];
|
$_GET['pdfname'] = $_GET['edit'];
|
||||||
}
|
}
|
||||||
// Load default structure file when creating a new one
|
// Load default structure file when creating a new one
|
||||||
else {
|
else {
|
||||||
$load = loadPDFStructureDefinitions($type->getId());
|
$load = \LAM\PDF\loadPDFStructureDefinitions($type->getId());
|
||||||
$_SESSION['currentPDFStructure'] = $load['structure'];
|
$_SESSION['currentPDFStructure'] = $load['structure'];
|
||||||
$_SESSION['currentPageDefinitions'] = $load['page_definitions'];
|
$_SESSION['currentPageDefinitions'] = $load['page_definitions'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load available fields from modules when not set in session
|
$availablePDFFields = getAvailablePDFFields($type->getId());
|
||||||
if(!isset($_SESSION['availablePDFFields'])) {
|
|
||||||
$_SESSION['availablePDFFields'] = getAvailablePDFFields($type->getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the values for the dropdown boxes for section headline defined by
|
// Create the values for the dropdown boxes for section headline defined by
|
||||||
// value entries and fetch all available modules
|
// value entries and fetch all available modules
|
||||||
|
@ -380,7 +377,7 @@ $modules = array();
|
||||||
$section_items_array = array();
|
$section_items_array = array();
|
||||||
$section_items = '';
|
$section_items = '';
|
||||||
$sortedModules = array();
|
$sortedModules = array();
|
||||||
foreach($_SESSION['availablePDFFields'] as $module => $fields) {
|
foreach($availablePDFFields as $module => $fields) {
|
||||||
if ($module != 'main') {
|
if ($module != 'main') {
|
||||||
$title = getModuleAlias($module, $type->getScope());
|
$title = getModuleAlias($module, $type->getScope());
|
||||||
}
|
}
|
||||||
|
@ -391,7 +388,7 @@ foreach($_SESSION['availablePDFFields'] as $module => $fields) {
|
||||||
}
|
}
|
||||||
natcasesort($sortedModules);
|
natcasesort($sortedModules);
|
||||||
foreach($sortedModules as $module => $title) {
|
foreach($sortedModules as $module => $title) {
|
||||||
$values = $_SESSION['availablePDFFields'][$module];
|
$values = $availablePDFFields[$module];
|
||||||
if (!is_array($values) || (sizeof($values) < 1)) {
|
if (!is_array($values) || (sizeof($values) < 1)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +416,7 @@ if (sizeof($saveErrors) > 0) {
|
||||||
|
|
||||||
$newFieldFieldElements = array();
|
$newFieldFieldElements = array();
|
||||||
foreach($sortedModules as $module => $title) {
|
foreach($sortedModules as $module => $title) {
|
||||||
$fields = $_SESSION['availablePDFFields'][$module];
|
$fields = $availablePDFFields[$module];
|
||||||
if (isset($fields) && is_array($fields) && (sizeof($fields) > 0)) {
|
if (isset($fields) && is_array($fields) && (sizeof($fields) > 0)) {
|
||||||
$moduleFields = array();
|
$moduleFields = array();
|
||||||
foreach ($fields as $field => $fieldLabel) {
|
foreach ($fields as $field => $fieldLabel) {
|
||||||
|
@ -446,7 +443,7 @@ if (isset($_SESSION['currentPageDefinitions']['headline'])) {
|
||||||
$headline = $_SESSION['currentPageDefinitions']['headline'];
|
$headline = $_SESSION['currentPageDefinitions']['headline'];
|
||||||
}
|
}
|
||||||
// logo
|
// logo
|
||||||
$logoFiles = getAvailableLogos();
|
$logoFiles = \LAM\PDF\getAvailableLogos();
|
||||||
$logos = array(_('No logo') => 'none');
|
$logos = array(_('No logo') => 'none');
|
||||||
foreach($logoFiles as $logoFile) {
|
foreach($logoFiles as $logoFile) {
|
||||||
$logos[$logoFile['filename'] . ' (' . $logoFile['infos'][0] . ' x ' . $logoFile['infos'][1] . ")"] = $logoFile['filename'];
|
$logos[$logoFile['filename'] . ' (' . $logoFile['infos'][0] . ' x ' . $logoFile['infos'][1] . ")"] = $logoFile['filename'];
|
||||||
|
@ -459,7 +456,7 @@ if (isset($_SESSION['currentPageDefinitions']['filename'])) {
|
||||||
?>
|
?>
|
||||||
<form id="inputForm" action="pdfpage.php" method="post" onSubmit="saveScrollPosition('inputForm')">
|
<form id="inputForm" action="pdfpage.php" method="post" onSubmit="saveScrollPosition('inputForm')">
|
||||||
<?php
|
<?php
|
||||||
$sectionElements = array(_('Beginning') => 0);
|
$sectionElements = array();
|
||||||
$nonTextSectionElements = array();
|
$nonTextSectionElements = array();
|
||||||
|
|
||||||
$container = new htmlTable();
|
$container = new htmlTable();
|
||||||
|
@ -498,10 +495,10 @@ for ($key = 0; $key < sizeof($_SESSION['currentPDFStructure']); $key++) {
|
||||||
$linkRemove->setTitle(_("Remove"));
|
$linkRemove->setTitle(_("Remove"));
|
||||||
$emptyBox = new htmlOutputText('');
|
$emptyBox = new htmlOutputText('');
|
||||||
// We have a new section to start
|
// We have a new section to start
|
||||||
if($entry['tag'] == "SECTION" && $entry['type'] == "open") {
|
if(($entry['tag'] == "SECTION") && ($entry['type'] == 'open')) {
|
||||||
$name = $entry['attributes']['NAME'];
|
$name = $entry['attributes']['NAME'];
|
||||||
if(preg_match("/^_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+/",$name)) {
|
if(preg_match("/^_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+/",$name)) {
|
||||||
$section_headline = translateFieldIDToName(substr($name,1), $type->getScope());
|
$section_headline = translateFieldIDToName(substr($name,1), $type->getScope(), $availablePDFFields);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$section_headline = $name;
|
$section_headline = $name;
|
||||||
|
@ -513,7 +510,7 @@ for ($key = 0; $key < sizeof($_SESSION['currentPDFStructure']); $key++) {
|
||||||
if(preg_match("/^_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+/",$name)) {
|
if(preg_match("/^_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+/",$name)) {
|
||||||
$headlineElements = array();
|
$headlineElements = array();
|
||||||
foreach($section_items_array as $item) {
|
foreach($section_items_array as $item) {
|
||||||
$headlineElements[translateFieldIDToName($item, $type->getScope())] = '_' . $item;
|
$headlineElements[translateFieldIDToName($item, $type->getScope(), $availablePDFFields)] = '_' . $item;
|
||||||
}
|
}
|
||||||
$sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, array($name));
|
$sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, array($name));
|
||||||
$sectionHeadlineSelect->setHasDescriptiveElements(true);
|
$sectionHeadlineSelect->setHasDescriptiveElements(true);
|
||||||
|
@ -583,7 +580,7 @@ for ($key = 0; $key < sizeof($_SESSION['currentPDFStructure']); $key++) {
|
||||||
// Get name of current entry
|
// Get name of current entry
|
||||||
$name = $entry['attributes']['NAME'];
|
$name = $entry['attributes']['NAME'];
|
||||||
$structureContent->addElement(new htmlSpacer('10px', null));
|
$structureContent->addElement(new htmlSpacer('10px', null));
|
||||||
$fieldOutput = new htmlOutputText(translateFieldIDToName($name, $type->getScope()));
|
$fieldOutput = new htmlOutputText(translateFieldIDToName($name, $type->getScope(), $availablePDFFields));
|
||||||
$structureContent->addElement($fieldOutput);
|
$structureContent->addElement($fieldOutput);
|
||||||
if ($_SESSION['currentPDFStructure'][$key - 1]['tag'] != 'SECTION') {
|
if ($_SESSION['currentPDFStructure'][$key - 1]['tag'] != 'SECTION') {
|
||||||
$structureContent->addElement($linkUp);
|
$structureContent->addElement($linkUp);
|
||||||
|
@ -600,6 +597,7 @@ for ($key = 0; $key < sizeof($_SESSION['currentPDFStructure']); $key++) {
|
||||||
$structureContent->addElement($linkRemove, true);
|
$structureContent->addElement($linkRemove, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$sectionElements[_('End')] = sizeof($_SESSION['currentPDFStructure']);
|
||||||
$structureContent->colspan = 3;
|
$structureContent->colspan = 3;
|
||||||
$mainContent->addElement($structureContent);
|
$mainContent->addElement($structureContent);
|
||||||
$container->addElement(new htmlFieldset($mainContent), true);
|
$container->addElement(new htmlFieldset($mainContent), true);
|
||||||
|
@ -638,19 +636,21 @@ $newTextFieldContent->addElement(new htmlButton('add_text', _('Add')));
|
||||||
$container->addElement(new htmlFieldset($newTextFieldContent, _("Text field")), true);
|
$container->addElement(new htmlFieldset($newTextFieldContent, _("Text field")), true);
|
||||||
|
|
||||||
// new field
|
// new field
|
||||||
$container->addElement(new htmlSubTitle(_('New field')), true);
|
if (!empty($nonTextSectionElements)) {
|
||||||
$newFieldContainer = new htmlTable();
|
$container->addElement(new htmlSubTitle(_('New field')), true);
|
||||||
$newFieldFieldSelect = new htmlSelect('new_field', $newFieldFieldElements);
|
$newFieldContainer = new htmlTable();
|
||||||
$newFieldFieldSelect->setHasDescriptiveElements(true);
|
$newFieldFieldSelect = new htmlSelect('new_field', $newFieldFieldElements);
|
||||||
$newFieldFieldSelect->setContainsOptgroups(true);
|
$newFieldFieldSelect->setHasDescriptiveElements(true);
|
||||||
$newFieldContainer->addElement($newFieldFieldSelect);
|
$newFieldFieldSelect->setContainsOptgroups(true);
|
||||||
$newFieldContainer->addElement(new htmlSpacer('10px', null));
|
$newFieldContainer->addElement($newFieldFieldSelect);
|
||||||
$newFieldSectionSelect = new htmlTableExtendedSelect('add_field_position', $nonTextSectionElements, array(), _('Position'));
|
$newFieldContainer->addElement(new htmlSpacer('10px', null));
|
||||||
$newFieldSectionSelect->setHasDescriptiveElements(true);
|
$newFieldSectionSelect = new htmlTableExtendedSelect('add_field_position', $nonTextSectionElements, array(), _('Position'));
|
||||||
$newFieldContainer->addElement($newFieldSectionSelect);
|
$newFieldSectionSelect->setHasDescriptiveElements(true);
|
||||||
$newFieldContainer->addElement(new htmlButton('add_new_field', _('Add')));
|
$newFieldContainer->addElement($newFieldSectionSelect);
|
||||||
$container->addElement(new htmlFieldset($newFieldContainer), true);
|
$newFieldContainer->addElement(new htmlButton('add_new_field', _('Add')));
|
||||||
$container->addElement(new htmlSpacer(null, '20px'), true);
|
$container->addElement(new htmlFieldset($newFieldContainer), true);
|
||||||
|
$container->addElement(new htmlSpacer(null, '20px'), true);
|
||||||
|
}
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
$buttonContainer = new htmlTable();
|
$buttonContainer = new htmlTable();
|
||||||
|
@ -688,9 +688,10 @@ include '../main_footer.php';
|
||||||
*
|
*
|
||||||
* @param String $id field ID
|
* @param String $id field ID
|
||||||
* @param String $scope account type
|
* @param String $scope account type
|
||||||
|
* @param array $availablePDFFields available PDF fields
|
||||||
*/
|
*/
|
||||||
function translateFieldIDToName($id, $scope) {
|
function translateFieldIDToName($id, $scope, $availablePDFFields) {
|
||||||
foreach ($_SESSION['availablePDFFields'] as $module => $fields) {
|
foreach ($availablePDFFields as $module => $fields) {
|
||||||
if (!(strpos($id, $module . '_') === 0)) {
|
if (!(strpos($id, $module . '_') === 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ function showMainPage($scope, $selectedModules) {
|
||||||
$pdfCheckbox = new htmlTableExtendedInputCheckbox('createPDF', $createPDF, _('Create PDF files'));
|
$pdfCheckbox = new htmlTableExtendedInputCheckbox('createPDF', $createPDF, _('Create PDF files'));
|
||||||
$pdfCheckbox->setTableRowsToShow(array('pdfStructure'));
|
$pdfCheckbox->setTableRowsToShow(array('pdfStructure'));
|
||||||
$inputContainer->addElement($pdfCheckbox, true);
|
$inputContainer->addElement($pdfCheckbox, true);
|
||||||
$pdfStructures = getPDFStructureDefinitions($scope);
|
$pdfStructures = \LAM\PDF\getPDFStructureDefinitions($scope);
|
||||||
$pdfSelected = array();
|
$pdfSelected = array();
|
||||||
if (isset($_POST['pdfStructure'])) {
|
if (isset($_POST['pdfStructure'])) {
|
||||||
$pdfSelected = array($_POST['pdfStructure']);
|
$pdfSelected = array($_POST['pdfStructure']);
|
||||||
|
|
Loading…
Reference in New Issue