Commit 61dd30c6 authored by sylvieg's avatar sylvieg

[MOD]tracker export: can specifiy delimitors, separator, CR + default is...

[MOD]tracker export: can specifiy delimitors, separator, CR + default is ISO8859 no parsing tracker default sort + can sort on itemId
parent f8b817e0
......@@ -150,6 +150,8 @@ function wikiplugin_trackerlist($data, $params) {
$sort_mode = 'lastModif';
elseif ($tracker_info['defaultOrderKey'] == -2)
$sort_mode = 'created';
elseif ($tracker_info['defaultOrderKey'] == -3)
$sort_mode = 'itemId';
else
$sort_mode = 'f_'.$tracker_info['defaultOrderKey'];
if (isset($tracker_info['defaultOrderDir'])) {
......
......@@ -6,7 +6,11 @@
{icon _id='help'}</a>{/if}
{if $prefs.feature_view_tpl eq 'y'}
<a href="tiki-edit_templates.php?template=tiki-admin_trackers.tpl" target="tikihelp" class="tikihelp" title="{tr}View tpl{/tr}: {tr}Admin Trackers tpl{/tr}">
{icon _id='shape_square_edit'}</a>{/if}</h1>
{icon _id='shape_square_edit'}</a>{/if}
{if $tiki_p_admin eq 'y'}
<a href="tiki-admin.php?page=trackers">{icon _id='wrench' alt="{tr}Admin Feature{/tr}"}</a>
{/if}
</h1>
<div class="navbar">
<span class="button2"><a href="tiki-list_trackers.php" class="linkbut">{tr}List trackers{/tr}</a></span>
......@@ -170,8 +174,9 @@ for a tracker and they must be valid in SQL{/tr}</em>
{section name=x loop=$fields}
<option value="{$fields[x].fieldId}"{if $defaultOrderKey eq $fields[x].fieldId} selected="selected"{/if}>{$fields[x].name|truncate:42:" ..."}</option>
{/section}
<option value="-1"{if $defaultOrderKey eq -1} selected="selected"{/if}>{tr}lastModif{/tr}</option>
<option value="-1"{if $defaultOrderKey eq -1} selected="selected"{/if}>{tr}LastModif{/tr}</option>
<option value="-2"{if $defaultOrderKey eq -2} selected="selected"{/if}>{tr}Created{/tr}</option>
<option value="-3"{if $defaultOrderKey eq -3} selected="selected"{/if}>{tr}ItemId{/tr}</option>
</select>
</td></tr>
<tr class="formcolor"><td class="auto" colspan="2">{tr}What is default sort order in list?{/tr}</td><td>
......@@ -290,12 +295,15 @@ categories = {$catsdump}
<form action="tiki-export_tracker.php?trackerId={$trackerId}" method="post">
<table class="normal">
<tr class="formcolor"><td>{tr}File{/tr}</td><td>{tr}Tracker{/tr}_{$trackerId}.csv</td></tr>
<tr class="formcolor"><td>{tr}Charset encoding{/tr}</td><td><select name="encoding"><option value="UTF-8" selected="selected">{tr}UTF-8{/tr}</option><option value="ISO-8859-1">{tr}ISO-8859-1{/tr}</option></select></td></tr>
<tr class="formcolor"><td></td><td><input name="showItemId" type="checkbox" checked="checked" />itemId
<tr class="formcolor"><td>{tr}Charset encoding{/tr}</td><td><select name="encoding"><option value="UTF-8">{tr}UTF-8{/tr}</option><option value="ISO-8859-1" selected="selected">{tr}ISO-8859-1{/tr}</option></select></td></tr>
<tr class="formcolor"><td>{tr}Separator{/tr}</td><td><input type="text" name="separator" value="," /></td></tr>
<tr class="formcolor"><td>{tr}Delimitors{/tr}</td><td><input type="text" name="delimitorL" value='"' /><input type="text" name="delimitorR" value='"' /></td></tr>
<tr class="formcolor"><td>{tr}Carriage Return inside Field Value{/tr}</td><td><input type="text" name="CR" value='%%%' /></td></tr>
<tr class="formcolor"><td>{tr}Parse{/tr}</td><td><input type="checkbox" name="parse"></td></tr>
<tr class="formcolor"><td>{tr}Info{/tr}</td><td><input name="showItemId" type="checkbox" checked="checked" />itemId
<br /><input type="checkbox" name="showStatus"{if $info.showStatus eq 'y'} checked="checked"{/if}>{tr}status{/tr}
<br /><input type="checkbox" name="showCreated"{if $info.showCreated eq 'y'} checked="checked"{/if}>{tr}created{/tr}
<br /><input type="checkbox" name="showLastModif"{if $info.showLastModif eq 'y'} checked="checked"{/if}>{tr}lastModif{/tr}
<br /><input type="checkbox" name="parse" checked="checked">{tr}Parse{/tr}</td></tr>
<tr class="formcolor"><td>{tr}Fields{/tr}</td><td><input type="radio" name="which" value="list"/> {tr}Fields visible in items list{/tr}
<br /><input type="radio" name="which" value="ls"/> {tr}Fields searchable or visible in items list{/tr}
<br /><input type="radio" name="which" value="item"/> {tr}Fields visible in an item view{/tr}
......
......@@ -2,25 +2,25 @@
{if $heading ne 'n'}
{if $showItemId ne 'n'}
{assign var='comma' value='y'}
"itemId"
{$delimitorL}itemId{$delimitorR}
{/if}
{if $showStatus ne 'n'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"status"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}status{$delimitorR}
{/if}
{if $showCreated ne 'n'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"created"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}created{$delimitorR}
{/if}
{if $showLastModif ne 'n'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"lastModif"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}lastModif{$delimitorR}
{/if}
{if !empty($listfields)}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{foreach item=field key=fieldId from=$listfields name=list}
"{$field.name} -- {$fieldId}"
{if !$smarty.foreach.list.last},{/if}
{$delimitorL}{$field.name} -- {$fieldId}{$delimitorR}
{if !$smarty.foreach.list.last}{$separator}{/if}
{/foreach}
{/if}
{assign var='comma' value='n'}
......@@ -30,29 +30,29 @@
{foreach from=$items item=item}
{if $showItemId ne 'n'}
{assign var='comma' value='y'}
"{$item.itemId}"
{$delimitorL}{$item.itemId}{$delimitorR}
{/if}
{if $showStatus eq 'y'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"{$item.status}"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}{$item.status}{$delimitorR}
{/if}
{if $showCreated ne 'n'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"{$item.created|tiki_short_datetime}"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}{$item.created|tiki_short_datetime}{$delimitorR}
{/if}
{if $showLastModif ne 'n'}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
"{$item.lastModif|tiki_short_datetime}"
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{$delimitorL}{$item.lastModif|tiki_short_datetime}{$delimitorR}
{/if}
{if !empty($listfields)}
{if $comma eq 'y'},{else}{assign var='comma' value='y'}{/if}
{if $comma eq 'y'}{$separator}{else}{assign var='comma' value='y'}{/if}
{foreach item=field_value from=$item.field_values name=list}
{if $field_value.isHidden ne 'c' or $item.creator eq $user or $tiki_p_admin_trackers eq 'y'}
{capture name="line"}{include file="tracker_item_field_value.tpl" list_mode='csv' showlinks='n'}{/capture}"{$smarty.capture.line|replace:"\r\n":"%%%"|replace:"\n":"%%%"|replace:"<br />":"%%%"|replace:'"':'""'}"
{capture name="line"}{include file="tracker_item_field_value.tpl" list_mode='csv' showlinks='n'}{/capture}{$delimitorL}{$smarty.capture.line|replace:"\r\n":"`$CR`"|replace:"\n":"`$CR`"|replace:"<br />":"`$CR`"|replace:"`$delimitorL`":"`$delimitorL``$delimitorL`"|replace:"`$delimitorR`":"`$delimitorR``$delimitorR`"}{$delimitorR}
{else}
""
{$delimitorL}{$delimitorR}
{/if}
{if !$smarty.foreach.list.last},{/if}
{if !$smarty.foreach.list.last}{$separator}{/if}
{/foreach}
{/if}
{/strip}
......
......@@ -135,8 +135,8 @@
{else}
{if $parse ne 'n'} {* the field is not necessary parsed if you come from a itm list field *}
{if $field_value.pvalue}{$field_value.pvalue}{else}{wiki}{$field_value.value}{/wiki}{/if}
{elseif $list_mode eq 'cvs'}
{$field_value}
{elseif $list_mode eq 'csv'}
{$field_value.value}
{else}
{$field_value.value|escape}
{/if}
......
......@@ -125,8 +125,24 @@ if (isset($_REQUEST['parse'])) {
$smarty->assign_by_ref('parse', $parse);
if (empty($_REQUEST['encoding'])) {
$_REQUEST['encoding'] = 'UTF-8';
$_REQUEST['encoding'] = 'ISO-8859-1';
}
if (empty($_REQUEST['separator'])) {
$_REQUEST['separator'] = ',';
}
$smarty->assign_by_ref('separator', $_REQUEST['separator']);
if (empty($_REQUEST['delimitorL'])) {
$_REQUEST['delimitorL'] = '"';
}
$smarty->assign_by_ref('delimitorL', $_REQUEST['delimitorL']);
if (empty($_REQUEST['delimitorR'])) {
$_REQUEST['delimitorR'] = '"';
}
$smarty->assign_by_ref('delimitorR', $_REQUEST['delimitorR']);
if (empty($_REQUEST['CR'])) {
$_REQUEST['CR'] = '%%%';
}
$smarty->assign_by_ref('CR', $_REQUEST['CR']);
if (!empty($_REQUEST['file'])) {
$fp = fopen($prefs['tmpDir'].'/'.tra('tracker')."_".$_REQUEST['trackerId'].".csv", 'w');
......@@ -140,7 +156,22 @@ if (!empty($_REQUEST['file'])) {
$offset = 0;
$maxRecords = 100;
$sort_mode = 'itemId_asc';
if ($tracker_info['defaultOrderKey'] == -1)
$sort_mode = 'lastModif';
elseif ($tracker_info['defaultOrderKey'] == -2)
$sort_mode = 'created';
elseif ($tracker_info['defaultOrderKey'] == -3)
$sort_mode = 'itemId';
elseif (isset($tracker_info['defaultOrderKey'])) {
$sort_mode = $tracker_info['defaultOrderKey'];
} else {
$sort_mode = 'itemId';
}
if (isset($tracker_info['defaultOrderDir'])) {
$sort_mode.= "_".$tracker_info['defaultOrderDir'];
} else {
$sort_mode.= "_asc";
}
$smarty->assign_by_ref('heading', $heading);
while (($items = $trklib->list_items($_REQUEST['trackerId'], $offset, $maxRecords, $sort_mode, $listfields, $filterFields, $values, $_REQUEST['status'], $_REQUEST['initial'], $exactValues)) && !empty($items['data'])) {
// still need to filter the fields that are view only by the admin and the item creator
......@@ -151,7 +182,7 @@ while (($items = $trklib->list_items($_REQUEST['trackerId'], $offset, $maxRecord
$smarty->assign_by_ref('items', $items["data"]);
$data = $smarty->fetch('tiki-export_tracker.tpl');
if (!empty($_REQUEST['encoding']) && $_REQUEST['encoding'] == 'ISO-8859-1') {
if (empty($_REQUEST['encoding']) || $_REQUEST['encoding'] == 'ISO-8859-1') {
$data = utf8_decode($data);
}
......
......@@ -593,6 +593,8 @@ if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'lastModif';
elseif ($tracker_info['defaultOrderKey'] == -2)
$sort_mode = 'created';
elseif ($tracker_info['defaultOrderKey'] == -3)
$sort_mode = 'itemId';
elseif ($orderkey) {
$sort_mode = 'f_'.$tracker_info['defaultOrderKey'];
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment