From 74e64ea788fdc11d8bff4c435261d67457a783fb Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 5 Dec 2010 13:31:39 +0000 Subject: [PATCH] restyled upload fields --- lam/templates/masscreate.php | 280 ++++++++++++++++++----------------- 1 file changed, 143 insertions(+), 137 deletions(-) diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 80f63f67..f98726ef 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -68,7 +68,6 @@ if (isset($_GET['getCSV'])) { } include 'main_header.php'; -echo '
'; // get possible types and remove those which do not support file upload $types = $_SESSION['config']->get_ActiveTypes(); @@ -108,6 +107,11 @@ if (isset($_POST['type'])) { } // show start page +$divClass = 'user'; +if (isset($_REQUEST['type'])) { + $divClass = $_REQUEST['type']; +} +echo '
'; echo "
\n"; echo "

" . _("Account creation via file upload") . "

\n"; echo "
"; @@ -126,7 +130,7 @@ echo "' . _("Account type") . ':'; echo "\n"; echo "
\n"; - echo "\n"; $sortedTypes = array(); for ($i = 0; $i < sizeof($types); $i++) { $sortedTypes[$types[$i]] = getTypeAlias($types[$i]); @@ -214,77 +218,98 @@ include 'main_footer.php'; * @param array $selectedModules list of selected account modules */ function showMainPage($scope, $selectedModules) { - echo "

" . _("File upload") . "

"; - echo "

\n"; - echo _("Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row."); - echo "
"; - echo _("Check your input carefully. LAM will only do some basic checks on the upload data."); - echo "

"; - echo _("Hint: Format all cells as text in your spreadsheet program and turn off auto correction."); - echo "

\n"; - - echo "

 

\n"; - - echo "
\n"; - echo "

\n"; - echo "" . _("CSV file:") . "   "; - echo "\n"; - echo "\n"; - echo "\n"; - echo "    " . _("Download sample CSV file") . "\n"; - echo "

\n"; - echo "
\n"; - - ?> - -  

\n"; - - echo _("Here is a list of possible columns. The red columns must be included in the CSV file and filled with data for all accounts."); - - echo "

" . _("Columns:") . "

\n"; - - // DN options - echo "
\n" . _("DN settings") . "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "" . _("DN suffix") . "\n"; - // help link - echo " "; - printHelpLink(getHelp('', '361'), '361'); - echo "
\n"; - echo "
    \n"; - echo "
  • " . _("Identifier") . ": " . "dn_suffix
  • \n"; - echo "
  • " . _("Example value") . ": " . _("ou=accounts,dc=yourdomain,dc=org") . "
  • \n"; - echo "
  • " . _("Default value") . ": " . $_SESSION['config']->get_Suffix($scope) . "
  • \n"; - echo "
\n"; - echo "
\n"; - echo "" . _("RDN identifier") . "\n"; - // help link - echo " "; - printHelpLink(getHelp('', '301'), '301'); - echo "
\n"; - echo "
    \n"; - echo "
  • " . _("Identifier") . ": " . "dn_rdn
  • \n"; - echo "
  • " . _("Possible values") . ": " . implode(", ", getRDNAttributes($scope, $selectedModules)) . "
  • \n"; - echo "
\n"; - echo "
\n"; - echo "

\n"; - + echo '
'; // get input fields from modules $columns = getUploadColumns($scope, $selectedModules); - - // print input fields $modules = array_keys($columns); + + echo "
\n"; + $container = new htmlTable(); + // title + $container->addElement(new htmlTitle(_("File upload")), true); + $container->addElement(new htmlSpacer(null, '10px'), true); + // instructions + $container->addElement(new htmlOutputText(_("Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row.")), true); + $container->addElement(new htmlOutputText(_("Check your input carefully. LAM will only do some basic checks on the upload data.")), true); + $container->addElement(new htmlSpacer(null, '10px'), true); + $container->addElement(new htmlOutputText(_("Hint: Format all cells as text in your spreadsheet program and turn off auto correction.")), true); + $container->addElement(new htmlSpacer(null, '10px'), true); + // upload elements + $inputContainer = new htmlTable(); + $inputContainer->addElement(new htmlOutputText(_("CSV file"))); + $inputContainer->addElement(new htmlInputFileUpload('inputfile')); + $inputContainer->addElement(new htmlButton('submitfile', _('Upload file and create accounts'))); + $inputContainer->addElement(new htmlSpacer('10px', null)); + $inputContainer->addElement(new htmlLink(_("Download sample CSV file"), 'masscreate.php?getCSV=1')); + $inputContainer->addElement(new htmlHiddenInput('scope', $scope)); + $inputContainer->addElement(new htmlHiddenInput('selectedModules', implode(',', $selectedModules)), true); + $container->addElement($inputContainer, true); + $container->addElement(new htmlSpacer(null, '10px'), true); + // column list + $columnSpacer = new htmlSpacer('10px', null); + $container->addElement(new htmlTitle(_("Columns")), true); + $columnContainer = new htmlTable(); + $columnContainer->setCSSClasses($scope . 'list'); + $columnContainer->addElement($columnSpacer); + $columnContainer->addElement(new htmlOutputText('')); + $columnContainer->addElement($columnSpacer); + $columnContainer->addElement(new htmlOutputText('')); + $columnContainer->addElement($columnSpacer); + $header1 = new htmlOutputText(_("Identifier")); + $header1->alignment = htmlElement::ALIGN_LEFT; + $columnContainer->addElement($header1, false, true); + $columnContainer->addElement($columnSpacer); + $header2 = new htmlOutputText(_("Example value")); + $header2->alignment = htmlElement::ALIGN_LEFT; + $columnContainer->addElement($header2, false, true); + $columnContainer->addElement($columnSpacer); + $header3 = new htmlOutputText(_("Default value")); + $header3->alignment = htmlElement::ALIGN_LEFT; + $columnContainer->addElement($header3, false, true); + $columnContainer->addElement($columnSpacer); + $header4 = new htmlOutputText(_("Possible values")); + $header4->alignment = htmlElement::ALIGN_LEFT; + $columnContainer->addElement($header4, true, true); + // DN options + $dnTitle = new htmlSubTitle(_("DN settings"), '../graphics/logo32.png'); + $dnTitle->colspan = 20; + $columnContainer->addElement($dnTitle); + $dnSuffixRowCells = array(); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlHelpLink('361'); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlOutputText(_("DN suffix")); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlOutputText('dn_suffix'); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); + $dnSuffixRowCells[] = $columnSpacer; + $dnSuffixRowCells[] = new htmlOutputText(''); + $dnSuffixRowCells[] = new htmlSpacer(null, '25px'); + $dnSuffixRow = new htmlTableRow($dnSuffixRowCells); + $dnSuffixRow->setCSSClasses($scope . 'list-dark'); + $columnContainer->addElement($dnSuffixRow); + $dnRDNRowCells = array(); + $dnRDNRowCells[] = $columnSpacer; + $dnRDNRowCells[] = new htmlHelpLink('301'); + $dnRDNRowCells[] = $columnSpacer; + $dnRDNRowCells[] = new htmlOutputText(_("RDN identifier") . '*'); + $dnRDNRowCells[] = $columnSpacer; + $dnRDNRowCells[] = new htmlOutputText('dn_rdn'); + $dnRDNRowCells[] = $columnSpacer; + $rdnAttributes = getRDNAttributes($scope, $selectedModules); + $dnRDNRowCells[] = new htmlOutputText($rdnAttributes[0]); + $dnRDNRowCells[] = $columnSpacer; + $dnRDNRowCells[] = new htmlOutputText(''); + $dnRDNRowCells[] = $columnSpacer; + $dnRDNRowCells[] = new htmlOutputText(implode(", ", $rdnAttributes)); + $dnRDNRowCells[] = new htmlSpacer(null, '25px'); + $dnRDNRow = new htmlTableRow($dnRDNRowCells); + $dnRDNRow->setCSSClasses($scope . 'list-bright'); + $columnContainer->addElement($dnRDNRow); + // module options for ($m = 0; $m < sizeof($modules); $m++) { // skip modules without upload columns if (sizeof($columns[$modules[$m]]) < 1) { @@ -294,34 +319,58 @@ function showMainPage($scope, $selectedModules) { $module = new $modules[$m]($scope); $iconImage = $module->getIcon(); if ($iconImage != null) { - $icon = '' . $iconImage . ' '; + $icon = '../graphics/' . $iconImage; } - echo "
\n$icon" . getModuleAlias($modules[$m], $scope) . "
\n"; - echo "\n"; + $moduleTitle = new htmlSubTitle(getModuleAlias($modules[$m], $scope), $icon); + $moduleTitle->colspan = 20; + $columnContainer->addElement($moduleTitle); + $odd = true; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { - echo "\n"; - echo "\n"; - $i++; - if ($i < sizeof($columns[$modules[$m]])) { - echo "\n"; - $i++; - if ($i < sizeof($columns[$modules[$m]])) { - echo "\n"; - } - else echo ""; // empty cell if no more fields - } - else echo ""; // empty cell if no more fields - echo "\n"; + $required = ''; + if (isset($columns[$modules[$m]][$i]['required']) && ($columns[$modules[$m]][$i]['required'] == true)) { + $required = '*'; + } + $rowCells = array(); + $rowCells[] = $columnSpacer; + $rowCells[] = new htmlHelpLink($columns[$modules[$m]][$i]['help'], $modules[$m], $scope); + $rowCells[] = $columnSpacer; + $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['description'] . $required); + $rowCells[] = $columnSpacer; + $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['name']); + $rowCells[] = $columnSpacer; + $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['example']); + $rowCells[] = $columnSpacer; + if (isset($columns[$modules[$m]][$i]['default'])) { + $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['default']); + } + else { + $rowCells[] = new htmlOutputText(''); + } + $rowCells[] = $columnSpacer; + if (isset($columns[$modules[$m]][$i]['values'])) { + $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['values']); + } + else { + $rowCells[] = new htmlOutputText(''); + } + $rowCells[] = new htmlSpacer(null, '25px'); + $row = new htmlTableRow($rowCells); + if ($odd) { + $row->setCSSClasses($scope . 'list-dark'); + } + else { + $row->setCSSClasses($scope . 'list-bright'); + } + $odd = !$odd; + $columnContainer->addElement($row); } - echo "
\n"; - showColumnData($modules[$m], $columns[$modules[$m]][$i], $scope); - echo "\n"; - showColumnData($modules[$m], $columns[$modules[$m]][$i], $scope); - echo "\n"; - showColumnData($modules[$m], $columns[$modules[$m]][$i], $scope); - echo "
\n"; - echo "

"; } + $container->addElement($columnContainer, true); + + $tabindex = 1; + parseHtml(null, $container, array(), false, $tabindex, $scope); + + echo "
\n"; // build sample CSV $sampleCSV_head = array(); @@ -355,47 +404,4 @@ function showMainPage($scope, $selectedModules) { die; } -/** -* Prints the properties of one input field. -* -* @param string $module account module name -* @param array $data field data from modules -* @param string $scope account type -*/ -function showColumnData($module, $data, $scope) { - if (isset($data['required']) && ($data['required'] == true)) { - echo "\n"; - echo $data['description']; - echo "\n"; - } - else { - echo "\n"; - echo $data['description']; - echo "\n"; - } - // help link - echo " "; - printHelpLink(getHelp($module, $data['help'], $scope), $data['help'], $module, $scope); - echo "
\n"; - echo "
    \n"; - echo "
  • \n"; - echo "" . _("Identifier") . ": " . $data['name'] . "\n"; - echo "
  • \n"; - if (isset($data['values'])) { - echo "
  • \n"; - echo "" . _("Possible values") . ": " . $data['values'] . "\n"; - echo "
  • \n"; - } - echo "
  • \n"; - echo "" . _("Example value") . ": " . $data['example'] . "\n"; - echo "
  • \n"; - if (isset($data['default'])) { - echo "
  • \n"; - echo "" . _("Default value") . ": " . $data['default'] . "\n"; - echo "
  • \n"; - } - - echo "
\n"; -} - ?>