Item8367: Problem to export and import topics that have fields with defining topics

pencil
Priority: Normal
Current State: Waiting for Feedback
Released In:
Target Release:
Applies To: Extension
Component: ExcelImportExportPlugin
Branches:
Reported By: Foswiki:Main.JuanPabloGaviria
Waiting For: Main.ThomasWeigert
Last Change By: ThomasWeigert
Hi,

There are 3 problems with the 3043 (2009-03-12) version of this plugin.

the firstone:

In the line 680 the "_SEARCH" doesn't work, it has to be only "SEARCH".

the second:

This code used the Foswiki::Attrs lib and it doesn't import it at the beging, so add the

diff -pu Export.pm.org Export.pm
--- Export.pm.org   2009-05-29 06:37:18.000000000 -0500
+++ Export.pm   2009-12-18 00:18:59.000000000 -0500
@@ -19,6 +19,7 @@ package Foswiki::Plugins::ExcelImportExp
 use strict;
 use Foswiki::Func;
 use Foswiki::Form;
+use Foswiki::Attrs;
 use Spreadsheet::WriteExcel;
 use Date::Manip;

The third:

when the form field is defind with the sintax:
[[<DefinignTopic>][<field title>]]

And you try to Export all topic with that form to a excel sheet, none of those fields are going to be export, only appear with blank cells in the excel sheet.

So, i try this solutions and works for me:

diff -pu Export.pm.org Export.pm
--- Export.pm.org   2009-05-29 06:37:18.000000000 -0500
+++ Export.pm   2009-12-18 00:18:59.000000000 -0500
@@ -19,6 +19,7 @@ package Foswiki::Plugins::ExcelImportExp
 use strict;
 use Foswiki::Func;
 use Foswiki::Form;
+use Foswiki::Attrs;
 use Spreadsheet::WriteExcel;
 use Date::Manip;
 
@@ -153,7 +154,15 @@ sub topics2excel {
     foreach my $field ( @{$fieldDefs} ) {
 
         # NAME
-        my $name = $field->{title};
+   my $name = "";
+        my $definitiontopic = $field->{definingTopic};
+        if ( $definitiontopic ){
+       $name = "[[" . $field->{definingTopic} . "][" . $field->{title} . "]]";
+   }
+        else
+   {
+            $name = $field->{title};
+   }
         $name =~ s/^\s*//go;
         $name =~ s/\s*$//go;
         push( @sortorder, $name ) if $name;
@@ -673,12 +682,12 @@ sub table2excel {
     # read the table and write them in the Excel sheet
     my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $basetopic );
 
+
     # Need to expand searches to handle tables generated from search.
     ## SMELL: Need to expand FormQueryPlugin based searches also...
     ## SMELL: What if there are tags in the search?
-    $text =~
-s/%SEARCH{(.*)}%/$session->_SEARCH( new Foswiki::Attrs($1), $basetopic, $web )/geo;
-
+    $text =~ s/%SEARCH{(.*?)}%/$session->SEARCH( new Foswiki::Attrs($1), $basetopic, $web )/geo;
+    
     my $insideTable = 0;
     my $beforeTable = 0;
     my @labels;

So, if someone knows a better way to do it plaese comment this topic.

PDD: Sorry for my English.

-- JuanPabloGaviria - 18 Dec 2009

Thanks for the tip with the _SEARCH -> SEARCH correction. This fixed a bug I encountered in connection with a EditRowPlugin table header with an embedded SEARCH.

If this patch doesn´t break other things, it should be included into the next release, if my vote counts.

-- PhilippLeufke - 25 Feb 2010

setting to this as "Waiting for Feedback" from ThomasWeigert, as ExcelImportExportPlugin is marked "Coordinate with author".

-- WillNorris - 27 Feb 2010

Sorry for the late feedback. No problem if you want to fix this. I am not able to maintain the Foswiki specific changes as it is too complicated to maintain two different version. So Sorry.

-- ThomasWeigert - 04 Sep 2010
 

ItemTemplate edit

Summary Problem to export and import topics that have fields with defining topics
ReportedBy Foswiki:Main.JuanPabloGaviria
Codebase 1.0.7
SVN Range
AppliesTo Extension
Component ExcelImportExportPlugin
Priority Normal
CurrentState Waiting for Feedback
WaitingFor ThomasWeigert
Checkins
ReleasedIn
Topic revision: r5 - 04 Sep 2010, ThomasWeigert
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy