From 7389c976d69bfe61ba8de1bdc6a315991c34971c Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 12 Oct 2004 13:12:16 +0000 Subject: [PATCH] added "possible values" option and sample CSV --- lam/templates/masscreate.php | 53 +++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 3af9f656..ef7bfdb8 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -49,6 +49,20 @@ if (!isset($_SESSION['loggedIn'])) { // Set correct language, codepages, .... setlanguage(); +// show CSV if requested +if (isset($_GET['getCSV'])) { + //download file + if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE')) { + Header('Content-Type: application/force-download'); + } + else { + Header('Content-Type: text/plain'); + } + Header('Content-disposition: attachment; filename=lam.csv'); + echo $_SESSION['mass_csv']; + exit; +} + echo $_SESSION['header']; echo "account upload\n"; echo "\n"; @@ -122,9 +136,9 @@ function showMainPage($scope) { // DN options echo "
\n" . _("DN settings") . "\n"; - echo "\n"; + echo "
\n"; echo "\n"; - echo "\n"; - echo "
\n"; + echo "\n"; echo "" . _("DN suffix") . "\n"; echo "
\n"; echo "
    \n"; @@ -135,7 +149,7 @@ function showMainPage($scope) { echo "\n"; echo "
\n"; echo "
\n"; + echo "\n"; echo "" . _("RDN identifier") . "\n"; echo "
\n"; echo "
    \n"; @@ -159,26 +173,26 @@ function showMainPage($scope) { for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; echo "
    \n" . getModuleAlias($modules[$m], $scope) . "\n"; - echo "\n"; + echo "
    \n"; 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 } - else echo ""; // empty cell if no more fields + else echo ""; // empty cell if no more fields echo "\n"; } echo "
    \n"; + echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "\n"; + echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "\n"; + echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "
    \n"; @@ -187,7 +201,10 @@ function showMainPage($scope) { echo "

     

    \n"; - // print table example + // print table example and build sample CSV + $sampleCSV = ""; + $sampleCSV_head = array(); + $sampleCSV_row = array(); echo "" . _("This is an example how it would look in your spreadsheet program before you convert to CSV:") . "\n"; echo "\n"; @@ -195,6 +212,7 @@ function showMainPage($scope) { for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { + $sampleCSV_head[] = "\"" . $columns[$modules[$m]][$i]['name'] . "\""; echo "\n"; @@ -205,6 +223,7 @@ function showMainPage($scope) { for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { + $sampleCSV_row[] = "\"" . $columns[$modules[$m]][$i]['example'] . "\""; echo "\n"; @@ -212,6 +231,15 @@ function showMainPage($scope) { } echo "\n"; echo "
    \n"; echo $columns[$modules[$m]][$i]['name']; echo "\n"; echo $columns[$modules[$m]][$i]['example']; echo "
    \n"; + $sampleCSV = implode(",", $sampleCSV_head) . "\n" . implode(",", $sampleCSV_row) . "\n"; + $_SESSION['mass_csv'] = $sampleCSV; + + // link to CSV sample + echo "

    \n"; + echo "

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

    \n"; + echo "

    \n"; echo "\n"; echo "\n"; @@ -240,6 +268,11 @@ function showColumnData($module, $data) { 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";