This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  a3fb030061c9d228c10f4a61588d27e74f9acb8b (commit)
       via  9e2a08b5ac562bc4b8f6900453cb74770cc43153 (commit)
       via  0c17b1ab9ffac4499d10c9f75b1c1fd3db1718ff (commit)
      from  22f64a7b60c7328af0f7852047e42b8d77952120 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=a3fb030061c9d228c10f4a61588d27e74f9acb8b

commit a3fb030061c9d228c10f4a61588d27e74f9acb8b
Merge: 22f64a7 9e2a08b
Author: Franck Villaume <[email protected]>
Date:   Tue Apr 13 19:23:07 2021 +0200

    Merge remote-tracking branch 'rhabacker/ticket-321'


https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=9e2a08b5ac562bc4b8f6900453cb74770cc43153

commit 9e2a08b5ac562bc4b8f6900453cb74770cc43153
Author: Ralf Habacker <[email protected]>
Date:   Tue Apr 13 13:34:39 2021 +0200

    [#321] Encoding for pm csv export

diff --git a/src/www/pm/csv.php b/src/www/pm/csv.php
index f25bdd1..fc981ee 100644
--- a/src/www/pm/csv.php
+++ b/src/www/pm/csv.php
@@ -60,6 +60,8 @@ if (session_loggedin()) {
        }
 }
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $headers = getIntFromRequest('headers', $default['headers']);
 $full = getIntFromRequest('full', $default['full']);
 $sep = getFilteredStringFromRequest('sep', '/^[,;]$/', $default['sep']);
@@ -78,8 +80,8 @@ $format .= " using '".htmlentities($sep)."' as separator.";
 echo html_e('p', array(), _('This page allows you to export or import all the 
tasks using a CSV (<a 
href="http://en.wikipedia.org/wiki/Comma-separated_values";>Comma Separated 
Values</a>) File. This format can be used to view tasks using Microsoft 
Excel.'));
 echo html_e('h2', array(), _('Export tasks as a CSV file'));
 
-echo html_e('strong', array(), _('Selected CSV Format')._(':')).' '.$format.' 
'.util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=format_csv&sep='.$sep.'&full='.$full.'&headers='.$headers,
 _('(Change)'));
-echo html_e('p', array(), 
util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=downloadcsv&sep='.$sep.'&full='.$full.'&headers='.$headers,
 _('Export CSV file')));
+echo html_e('strong', array(), _('Selected CSV Format')._(':')).' '.$format.' 
'.util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=format_csv&sep='.$sep.'&full='.$full.'&headers='.$headers.'&bom='.$bom.'&encoding='.$encoding,
 _('(Change)'));
+echo html_e('p', array(), 
util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=downloadcsv&sep='.$sep.'&full='.$full.'&headers='.$headers.'&bom='.$bom.'&encoding='.$encoding,
 _('Export CSV file')));
 
 echo html_e('h2', array(), _('Import tasks using a CSV file'));
 echo $HTML->openForm(array('enctype' => 'multipart/form-data', 'method' => 
'post', 'action' => 
'/pm/task.php?group_project_id='.$group_project_id.'&group_id='.$group_id.'&func=postuploadcsv'));
diff --git a/src/www/pm/downloadcsv.php b/src/www/pm/downloadcsv.php
index 42678ed..fc566a0 100644
--- a/src/www/pm/downloadcsv.php
+++ b/src/www/pm/downloadcsv.php
@@ -82,6 +82,8 @@ dependenton5_linktype
 require_once $gfcommon.'include/User.class.php';
 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $headers = getIntFromRequest('headers');
 $full = getIntFromRequest('full');
 $sep = getFilteredStringFromRequest('sep', '/^[,;]$/', ',');
@@ -181,20 +183,20 @@ $header = array(
 }
 
 if ($headers) {
-       echo join($sep, $header)."\n";
+       $s = join($sep, $header)."\n";
 }
 
 for ($i=0; $i<count($pt_arr); $i++) {
 
-       echo $pt_arr[$i]->getID().$sep.
+       $s .= $pt_arr[$i]->getID().$sep.
                $pt_arr[$i]->getExternalID().$sep.
                $pt_arr[$i]->getParentID().$sep.
                $sep.
                str_replace($arrRemove, ' ', $pt_arr[$i]->getSummary()).$sep;
        if ($full) {
-               echo $pt_arr[$i]->getCategoryName().$sep;
+               $s .= $pt_arr[$i]->getCategoryName().$sep;
        }
-       echo $pt_arr[$i]->getDuration().$sep.
+       $s .= $pt_arr[$i]->getDuration().$sep.
                $pt_arr[$i]->getHours().$sep.
                date('Y-m-d H:i:s',$pt_arr[$i]->getStartDate()).$sep.
                date('Y-m-d H:i:s',$pt_arr[$i]->getEndDate()).$sep.
@@ -206,23 +208,35 @@ for ($i=0; $i<count($pt_arr); $i++) {
                for ($j=0; $j<5; $j++) {
                        if ($j < count($users)) {
                                if ($users[$j]->getUnixName() != 'none') {
-                                       echo $users[$j]->getUnixName();
+                                       $s .= $users[$j]->getUnixName();
                                }
                        }
-                       echo $sep;
+                       $s .= $sep;
                }
 
                $dependentOn = $pt_arr[$i]->getDependentOn();
                $keys=array_keys($dependentOn);
                for ($j=0; $j<5; $j++) {
                        if ($j < count($keys)) {
-                               echo 
$keys[$j].$sep.$sep.$dependentOn[$keys[$j]];
+                               $s .= 
$keys[$j].$sep.$sep.$dependentOn[$keys[$j]];
                        } else {
-                               echo $sep.$sep;
+                               $s .= $sep.$sep;
                        }
                        if ($j<4) {
-                               echo $sep;
+                               $s .= $sep;
                        }
                }
-       echo "\n";
+       $s .= "\n";
 }
+
+if ($bom) {
+       if ($encoding == 'UTF-16LE') {
+               echo "\xFF\xFE";
+       } elseif ($encoding == 'UTF-16BE') {
+               echo "\xFE\xFF";
+       } elseif ($encoding == 'UTF-8') {
+               echo "\xEF\xBB\xBF";
+       }
+}
+
+echo mb_convert_encoding($s, $encoding, "UTF-8");
diff --git a/src/www/pm/format_csv.php b/src/www/pm/format_csv.php
index 46b29ed..35843e3 100644
--- a/src/www/pm/format_csv.php
+++ b/src/www/pm/format_csv.php
@@ -51,6 +51,8 @@ global $HTML;
 
 pm_header(array('title'=>_('Update CSV Format'), 'modal'=>1, 
'group_project_id'=>$group_project_id));
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $headers = getIntFromRequest('headers', 1);
 $full = getIntFromRequest('full', 1);
 $sep = getStringFromRequest('sep', ',');
@@ -110,6 +112,39 @@ $sep = getStringFromRequest('sep', ',');
                                        </label>
                                </td>
                        </tr>
+                       <tr>
+                               <td>
+                                       <?php echo _('Encoding')._(':'); ?>
+                               </td>
+                               <td>
+                                       <input type="radio" id="utf8" 
name="encoding" value="UTF-8"<?php if ($encoding == 'UTF-8') echo ' 
checked="checked"' ?> />
+                                       <label for="utf8">
+                                               <?php echo _('UTF-8'); ?><br />
+                                       </label>
+                                       <input type="radio" id="utf16be" 
name="encoding" value="UTF-16BE"<?php if ($encoding == 'UTF-16BE') echo ' 
checked="checked"' ?> />
+                                       <label for="utf16be">
+                                               <?php echo _('UTF-16BE'); ?><br 
/>
+                                       </label>
+                                       <input type="radio" id="utf16le" 
name="encoding" value="UTF-16LE"<?php if ($encoding == 'UTF-16LE') echo ' 
checked="checked"' ?> />
+                                       <label for="utf16le">
+                                               <?php echo _('UTF-16LE'); ?><br 
/>
+                                       </label>
+                                       <input type="radio" id="1252" 
name="encoding" value="Windows-1252"<?php if ($encoding == 'Windows-1252') echo 
' checked="checked"' ?> />
+                                       <label for="1252">
+                                               <?php echo _('Windows-1252'); 
?><br />
+                                       </label>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td>
+                               </td>
+                               <td>
+                                       <input type="checkbox" id="bom" 
name="bom" value="1"<?php if ($bom) echo ' checked="checked"' ?> />
+                                       <label for="bom">
+                                               <?php echo _('Byte order 
mark'); ?><br />
+                                       </label>
+                               </td>
+                       </tr>
                </table>
                <input type="submit" name="Submit" /><?php echo 
$HTML->closeForm(); ?>
                </fieldset>

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=0c17b1ab9ffac4499d10c9f75b1c1fd3db1718ff

commit 0c17b1ab9ffac4499d10c9f75b1c1fd3db1718ff
Author: Ralf Habacker <[email protected]>
Date:   Tue Apr 13 13:12:49 2021 +0200

    [#321] Encoding for tracker csv export

diff --git a/src/common/tracker/actions/csv.php 
b/src/common/tracker/actions/csv.php
index c6434c9..c34aab3 100644
--- a/src/common/tracker/actions/csv.php
+++ b/src/common/tracker/actions/csv.php
@@ -57,6 +57,8 @@ if (session_loggedin()) {
        }
 }
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $headers = getIntFromRequest('headers', $default['headers']);
 $sep = getFilteredStringFromRequest('sep', '/^[,;]$/', $default['sep']);
 
@@ -121,8 +123,10 @@ $format .= _(' using ')."'".htmlentities($sep)."'"._(' as 
separator.');
 <?php
 echo $HTML->information(_('By default, export uses filter as setup in the 
browse page. To overwrite, please use Advanced Options'));
 echo html_e('h2', array(), _('Export as a CSV file'));
-echo html_e('strong', array(), _('Selected CSV Format')._(': 
')).'CSV'.$format.' '.util_make_link($url.'&func=format_csv', 
$HTML->getConfigurePic(_('Modify this CSV format.')));
+echo html_e('strong', array(), _('Selected CSV Format')._(': 
')).'CSV'.$format.' 
'.util_make_link($url.'&func=format_csv&encoding='.$encoding.'&bom='.$bom, 
$HTML->getConfigurePic(_('Modify this CSV format.')));
 echo $HTML->openForm(array('action' => $url.'&func=downloadcsv', 'method' => 
'post'));
+echo html_e('input', array('type' => 'hidden', 'name' => 'bom', 'value' => 
$bom));
+echo html_e('input', array('type' => 'hidden', 'name' => 'encoding', 'value' 
=> $encoding));
 echo html_ao('fieldset', array('id' => 'fieldset1_closed', 'class' => 
'coolfieldset'));
 echo html_e('legend', array(), _('Advanced Options'));
 echo html_ao('div');
diff --git a/src/common/tracker/actions/downloadcsv.php 
b/src/common/tracker/actions/downloadcsv.php
index 98af501..72b4ecc 100644
--- a/src/common/tracker/actions/downloadcsv.php
+++ b/src/common/tracker/actions/downloadcsv.php
@@ -42,6 +42,8 @@ sysdebug_off();
 header('Content-type: text/csv');
 header('Content-disposition: filename="trackers-'.date('Y-m-d-His').'.csv"');
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $offset = getStringFromRequest('offset');
 $_sort_col = getStringFromRequest('_sort_col');
 $_sort_ord = getStringFromRequest('_sort_ord');
@@ -66,7 +68,7 @@ $af->setup($offset, $_sort_col, $_sort_ord, $max_rows, $set, 
$_assigned_to, $_st
 $at_arr = $af->getArtifacts();
 
 if ($headers) {
-       echo 'artifact_id'.$sep.
+       $s = 'artifact_id'.$sep.
                'status_id'.$sep.
                'status_name'.$sep.
                'priority'.$sep.
@@ -91,12 +93,12 @@ if ($headers) {
        $keys = array_keys($ef);
        for ($i = 0; $i < count($keys); $i++) {
                if ($ef[$keys[$i]]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
-                       echo $sep.'"'.'effort_unit for 
'.$ef[$keys[$i]]['field_name'].'"';
+                       $s .= $sep.'"'.'effort_unit for 
'.$ef[$keys[$i]]['field_name'].'"';
                }
-               echo $sep.'"'.$ef[$keys[$i]]['field_name'].'"';
+               $s .= $sep.'"'.$ef[$keys[$i]]['field_name'].'"';
        }
-       echo $sep.'comments';
-       echo "\n";
+       $s .= $sep.'comments';
+       $s .= "\n";
 }
 
 for ($i = 0; $i < count($at_arr); $i++) {
@@ -106,7 +108,7 @@ for ($i = 0; $i < count($at_arr); $i++) {
        $close_date  = $at_arr[$i]->getCloseDate()? date(_('Y-m-d 
H:i'),$at_arr[$i]->getCloseDate()): '';
 
        $votes = $at_arr[$i]->getVotes();
-       echo $at_arr[$i]->getID().$sep.
+       $s .= $at_arr[$i]->getID().$sep.
                $at_arr[$i]->getStatusID().$sep.
                '"'.$at_arr[$i]->getStatusName().'"'.$sep.
                $at_arr[$i]->getPriority().$sep.
@@ -140,12 +142,12 @@ for ($i = 0; $i < count($at_arr); $i++) {
                                        $unittexts = $unit->getName();
                                }
                        }
-                       echo $sep.'"'.fix4csv($unittexts).'"';
+                       $s .= $sep.'"'.fix4csv($unittexts).'"';
                        $value = 
$effortUnitFactory->encodedToValue($efd_pair['value']);
                } else {
                        $value = $efd_pair["value"];
                }
-               echo $sep.'"'.fix4csv($value).'"';
+               $s .= $sep.'"'.fix4csv($value).'"';
        }
 
        // Include comments
@@ -159,10 +161,22 @@ for ($i = 0; $i < count($at_arr); $i++) {
                $body = str_replace(array("\r\n", "\r", "\n", PHP_EOL, chr(10), 
chr(13), chr(10).chr(13)), " ~ ", $body);
                $comments .= ' *** '.$date.' --- '.$realname.' --- '.$body;
        }
-       echo $sep.'"'.fix4csv($comments).'"';
-       echo "\n";
+       $s .= $sep.'"'.fix4csv($comments).'"';
+       $s .= "\n";
 }
 
+if ($bom) {
+       if ($encoding == 'UTF-16LE') {
+               echo "\xFF\xFE";
+       } elseif ($encoding == 'UTF-16BE') {
+               echo "\xFE\xFF";
+       } elseif ($encoding == 'UTF-8') {
+               echo "\xEF\xBB\xBF";
+       }
+}
+
+echo mb_convert_encoding($s, $encoding, "UTF-8");
+
 function fix4csv($value) {
        $value = util_unconvert_htmlspecialchars($value);
        $value = str_replace("\r\n", "\n", $value);
diff --git a/src/common/tracker/actions/format_csv.php 
b/src/common/tracker/actions/format_csv.php
index 65ce34d..e45e146 100644
--- a/src/common/tracker/actions/format_csv.php
+++ b/src/common/tracker/actions/format_csv.php
@@ -53,6 +53,8 @@ global $HTML;
 
 $ath->header(array('atid'=>$ath->getID(), 'modal'=>1, 'title'=>_('Update CSV 
Format')));
 
+$bom = getIntFromRequest('bom', 0);
+$encoding = getStringFromRequest('encoding', 'UTF-8');
 $headers = getIntFromRequest('headers', 1);
 $sep = getStringFromRequest('sep', ',');
 
@@ -96,6 +98,39 @@ $sep = getStringFromRequest('sep', ',');
                                        </label>
                                </td>
                        </tr>
+                       <tr>
+                               <td>
+                                       <?php echo _('Encoding')._(':'); ?>
+                               </td>
+                               <td>
+                                       <input type="radio" id="utf8" 
name="encoding" value="UTF-8"<?php if ($encoding == 'UTF-8') echo ' 
checked="checked"' ?> />
+                                       <label for="utf8">
+                                               <?php echo _('UTF-8'); ?><br />
+                                       </label>
+                                       <input type="radio" id="utf16be" 
name="encoding" value="UTF-16BE"<?php if ($encoding == 'UTF-16BE') echo ' 
checked="checked"' ?> />
+                                       <label for="utf16be">
+                                               <?php echo _('UTF-16BE'); ?><br 
/>
+                                       </label>
+                                       <input type="radio" id="utf16le" 
name="encoding" value="UTF-16LE"<?php if ($encoding == 'UTF-16LE') echo ' 
checked="checked"' ?> />
+                                       <label for="utf16le">
+                                               <?php echo _('UTF-16LE'); ?><br 
/>
+                                       </label>
+                                       <input type="radio" id="1252" 
name="encoding" value="Windows-1252"<?php if ($encoding == 'Windows-1252') echo 
' checked="checked"' ?> />
+                                       <label for="1252">
+                                               <?php echo _('Windows-1252'); 
?><br />
+                                       </label>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td>
+                               </td>
+                               <td>
+                                       <input type="checkbox" id="bom" 
name="bom" value="1"<?php if ($bom) echo ' checked="checked"' ?> />
+                                       <label for="bom">
+                                               <?php echo _('Byte order 
mark'); ?><br />
+                                       </label>
+                               </td>
+                       </tr>
                </table>
                <input type="submit" name="Submit" /><?php
                echo $HTML->closeForm();

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/actions/csv.php         |  6 ++++-
 src/common/tracker/actions/downloadcsv.php | 34 ++++++++++++++++++++---------
 src/common/tracker/actions/format_csv.php  | 35 ++++++++++++++++++++++++++++++
 src/www/pm/csv.php                         |  6 +++--
 src/www/pm/downloadcsv.php                 | 34 ++++++++++++++++++++---------
 src/www/pm/format_csv.php                  | 35 ++++++++++++++++++++++++++++++
 6 files changed, 127 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to