Skip to content

Commit 6711399

Browse files
committed
mostly working now
1 parent 9221edf commit 6711399

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

code/Module.class.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function displayExportOptions($template_name, $params)
155155
$smarty->assign("is_admin", $is_admin);
156156
$smarty->assign("page_vars", $page_vars);
157157
$smarty->assign("L", $L);
158-
$smarty->assign("SESSION", Settings::get("export_manager"));
158+
$smarty->assign("SESSION", Sessions::get("export_manager"));
159159
$smarty->assign("LANG", $params["LANG"]);
160160
$smarty->assign("export_icon_folder", "$root_url/modules/export_manager/images/icons");
161161

@@ -389,10 +389,11 @@ private function addXmlExportGroup ()
389389
"visibility" => "hide",
390390
"icon" => "xml.jpg",
391391
"action_button_text" => $L["word_generate"],
392-
"smarty_template" => "<?xml version=\"1.0\" encoding=\"utf - 8\" ?>\r\n\r\n{\$export_type_smarty_template}"
392+
"smarty_template" => "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n\r\n{\$export_type_smarty_template}"
393393
), $L);
394394

395395
$xml_smarty_template =<<< END
396+
{strip}
396397
<export>
397398
<export_datetime>{\$datetime}</export_datetime>
398399
<export_unixtime>{\$U}</export_unixtime>
@@ -420,6 +421,7 @@ private function addXmlExportGroup ()
420421
{/foreach}
421422
</submissions>
422423
</export>
424+
{/strip}
423425
END;
424426

425427
ExportTypes::addExportType(array(
@@ -441,12 +443,38 @@ private function addCsvExportGroup()
441443
"visibility" => "hide",
442444
"icon" => "csv.gif",
443445
"action_button_text" => $L["word_generate"],
444-
"headers" => "Content-type: application/xml; charset=\"octet - stream\"\r\nContent-Disposition: attachment; filename={\$filename}",
445-
"smarty_template" => "<?xml version=\"1.0\" encoding=\"utf - 8\" ?>\r\n\r\n{\$export_type_smarty_template}"
446+
"headers" => "Content-type: text/csv; charset=\"octet-stream\"\r\nContent-Disposition: attachment; filename={\$filename}",
447+
"smarty_template" => "{\$export_type_smarty_template}"
446448
), $L);
447449

448450
$csv_smarty_template =<<< END
449-
{strip}\r\n {foreach from=\$display_fields item=column name=row}\r\n {* workaround for an absurd Microsoft Excel problem, in which the first\r\n two characters of a file cannot be ID; see:\r\n http://support.microsoft.com /kb/323626 *}\r\n {if \$smarty.foreach.row.first && \$column.field_title == \"ID\"}\r\n .ID\r\n {else}\r\n {\$column.field_title|escape:''csv''}\r\n {/if}\r\n {if !\$smarty.foreach.row.last},{/if}\r\n {/foreach}\r\n{/strip}\r\n{foreach from=\$submissions item=submission name=row}{strip}\r\n {foreach from=\$display_fields item=field_info name=col_row}\r\n {assign var=col_name value=\$field_info.col_name}\r\n {assign var=value value=\$submission.\$col_name}\r\n {smart_display_field form_id=\$form_id view_id=\$view_id\r\n submission_id=\$submission.submission_id field_info=\$field_info\r\n field_types=\$field_types settings=\$settings value=\$value\r\n escape=\"csv\"}\r\n {* if this wasn''t the last row, output a comma *}\r\n {if !\$smarty.foreach.col_row.last},{/if}\r\n {/foreach}\r\n{/strip}\r\n{if !\$smarty.foreach.row.last}\r\n{/if}\r\n{/foreach}
451+
{strip}
452+
{foreach from=\$display_fields item=column name=row}
453+
{* workaround for an absurd Microsoft Excel problem, in which the first
454+
two characters of a file cannot be ID; see:
455+
http://support.microsoft.com/kb/323626 *}
456+
{if \$smarty.foreach.row.first && \$column.field_title == "ID"}
457+
'ID
458+
{else}
459+
{\$column.field_title|escape:'csv'}
460+
{/if}
461+
{if !\$smarty.foreach.row.last},{/if}
462+
{/foreach}
463+
{/strip}
464+
{foreach from=\$submissions item=submission name=row}{strip}
465+
{foreach from=\$display_fields item=field_info name=col_row}
466+
{assign var=col_name value=\$field_info.col_name}
467+
{assign var=value value=\$submission.\$col_name}
468+
{smart_display_field form_id=\$form_id view_id=\$view_id
469+
submission_id=\$submission.submission_id field_info=\$field_info
470+
field_types=\$field_types settings=\$settings value=\$value
471+
escape="csv"}
472+
{* if this wasn't the last row, output a comma *}
473+
{if !\$smarty.foreach.col_row.last},{/if}
474+
{/foreach}{/strip}
475+
{if !\$smarty.foreach.row.last}
476+
{/if}
477+
{/foreach}
450478
END;
451479

452480
ExportTypes::addExportType(array(

export.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
$placeholders["settings"] = Settings::get();
104104

105105
$export_group_info = ExportGroups::getExportGroup($export_group_id);
106-
$export_types = ExportTypes::getExportType($export_group_id);
106+
$export_types = ExportTypes::getExportTypes($export_group_id);
107+
107108

108109
// if the export type ID isn't available, the export group only contains a single (visible) export type
109110
$export_type_info = array();
@@ -126,7 +127,7 @@
126127
$template = $export_type_info["export_type_smarty_template"];
127128
$placeholders["export_type_name"] = $export_type_info["export_type_name"];
128129

129-
$plugin_dirs = array("$root_dir/modules/export_manager/smarty");
130+
$plugin_dirs = array("$root_dir/modules/export_manager/smarty_plugins");
130131
$export_type_smarty_template = CoreGeneral::evalSmartyString($template, $placeholders, "", $plugin_dirs);
131132

132133

@@ -135,10 +136,15 @@
135136
$placeholders["export_group_name"] = CoreGeneral::evalSmartyString($export_group_info["group_name"]);
136137
$placeholders["export_types"] = $export_types;
137138
$placeholders["export_type_smarty_template"] = $export_type_smarty_template;
139+
140+
//print_r($placeholders);
141+
//exit;
142+
138143
$page = CoreGeneral::evalSmartyString($template, $placeholders);
139144

140145

141146
if ($export_group_info["action"] == "new_window" || $export_group_info["action"] == "popup") {
147+
142148
// if required, send the HTTP headers
143149
if (!empty($export_group_info["headers"])) {
144150
$headers = preg_replace("/\r\n|\r/", "\n", $export_group_info["headers"]);

smarty_plugins/function.smart_display_field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function smarty_function_smart_display_field($params, &$smarty)
2121
if (isset($params["escape"])) {
2222
if ($params["escape"] == "csv") {
2323
$value = preg_replace("/\"/", "\"\"", $value);
24-
if (strstr($value, ",")) {
24+
if (strstr($value, ",") || strstr($value, "\n")) {
2525
$value = "\"$value\"";
2626
}
2727
}

templates/export_options_html.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
<td class="target_content">
3434
{assign var=var_name value="export_group_`$export_group_id`_results"}
3535
<input type="radio" name="export_group_{$export_group_id}_results" id="export_group_{$export_group_id}_results_1" value="all"
36-
{if $SESSION.$var_name == "all" || !isset($SESSION.$var_name)}checked{/if} />
36+
{if !isset($SESSION.$var_name) || $SESSION.$var_name == "all"}checked{/if} />
3737
<label for="export_group_{$export_group_id}_results_1"">{$LANG.word_all}</label>
3838
<input type="radio" name="export_group_{$export_group_id}_results" id="export_group_{$export_group_id}_results_2" value="selected"
39-
{if $SESSION.$var_name == "selected"}checked{/if} />
39+
{if isset($SESSION.$var_name) && $SESSION.$var_name == "selected"}checked{/if} />
4040
<label for="export_group_{$export_group_id}_results_2"">{$LANG.word_selected}</label>
4141
</td>
4242
<td>

0 commit comments

Comments
 (0)