You are here: Foswiki>Tasks Web>Item1652 (24 Nov 2009, IngoKappler)Edit Attach

Item1652: HolidaylistPlugin does not show results if an INCLUDE or SEARCH uses additional macros in the value

pencil
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
Applies To: Extension
Component: HolidaylistPlugin
Branches:
Reported By: IngoKappler
Waiting For: Main.DanielRohde
Last Change By: IngoKappler
Hi,

I have to include holiday data while at the same time basing the included topic and section on a formfield value. Any approach I tried failed not because the include or search was not working but because although the data were found, the HolidaylistPlugin didn't show it anymore.

Therefore it looks to me as if the HolidaylistPlugin is not able to fully resolve an include if it contains another macro as part of the value.

Please find here code examples which work but are not fully understood by the HolidaylistPlugin.

Trial1 (Simple INCLUDE, using formfield only for section):
%INCLUDE{ "%USERSWEB%.VacationPublicHolidaysOverview" section="Vacation%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" }%

Trial2 (Same as 1 but using formfield also for topic name):
%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" section="Vacation%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" }%

Trial3 (SEARCH instead of INCLUDE using formfield for topic name and section):
%SEARCH{search="FixedSearchCode_vac01" topic="VacationPublicHolidays%FORMFIELD{"Country" topic="%WIKINAME%" format="$value"}%" nonoise="on" format="$pattern(.*?(\%STARTSECTION\{\"Vacation%FORMFIELD{"Country" topic="%WIKINAME%" format="$value"}%\"\}\%.*?\%ENDSECTION\{\"Vacation%FORMFIELD{"Country" topic="%WIKINAME%" format="$value"}%\"\}\%).*)"}%

Trial4 (SEARCH instead of INCLUDE using formfield only for section):
%SEARCH{search="FixedSearchCode_vac02" topic="VacPublicHolidaysOverview" nonoise="on" format="$pattern(.*?(\%STARTSECTION\{\"Vacation%FORMFIELD{"Country" topic="%WIKINAME%" format="$value"}%\"\}\%.*?\%ENDSECTION\{\"Vacation%FORMFIELD{"Country" topic="%WIKINAME%" format="$value"}%\"\}\%).*)"}%

Trial5 (SEARCH also instead of using formfield; used for topic name and section):
%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%SEARCH{"name='%WIKINAME%' AND WorkStatus= 'Current' " web="%USERSWEB%" type="query"  nonoise="on" format="$formfield(Country)"}%" section="Vacation%SEARCH{"name='%WIKINAME%' AND WorkStatus= 'Current' " web="%USERSWEB%" type="query"  nonoise="on" format="$formfield(Country)"}%" }%

On my system all of the above examples worked by displaying the included or searched part. But the HolidaylistPlugin didn't use the displayed data. It only started using it when simplifying it to this:
%INCLUDE{ "%USERSWEB%.VacationPublicHolidaysGermany" section="VacationGermany"}%

As said, it looks like the plugin isn't able to handle additional macros as part of the value in a SEARCH or INCLUDE or maybe even generally. This makes it difficult or limits the ability to build automatic applications on top of the HolidaylistPlugin.

It is a very nice plugin. smile

-- IngoKappler - 22 May 2009

A construct like this is not correctly resolved:

   * 10 Jun 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%" format="$value"}% - *Corpus Christi* Frohnleichnam - :-)

The retrieval of FirstName works and in the topic it is displayed as expected:

HolidaylistPlugin correct definition.png
Definition is correct

But the name, although correctly resolved, is not correctly used by the HolidaylistPlugin:

HolidaylistPlugin name not correctly used if inserted via macro.png
Name from the definition is not correctly used

-- IngoKappler - 9 Jun 2009

Hi Daniel,

I see you are waiting for feedback from me after checking in the fixes/enhancements. How can I get a new version of the plugin now?

-- IngoKappler - 11 Jun 2009

Hi Ingo,

you can checkout the latest BETA from SVN:
svn co http://svn.foswiki.org/trunk/HolidaylistPlugin

-- DanielRohde - 11 Jun 2009

Hi Daniel,

since I am new to SVN I may need some time getting familiar with this way of checkouts. I started already reading about it but my time is limited. Anyhow, if I make it I let you know otherwise I might be silent.

10x
-- IngoKappler - 12 Jun 2009

I checked out the beta from SVN.

1. Using
%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" section="TimePlanning%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" }%
leads to this result:

HolidaylistPlugin correct definition 2.png
Correct definition is not picked up by the HolidaylistPlugin.

Please also note, that now there is also the Sunday of one weekend rendered in white instead of using the related background color.

2.

Using
   * 11 Jun 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%" format="$value"}% - *Corpus Christi* Frohnleichnam - :-) 
leads to this result:

HolidaylistPlugin name issue 2.png
Name is not correctly picked up by the HolidaylistPlugin.

-- IngoKappler - 14 Jun 2009

Hi Ingo,

I don't understand your examples. The HolidaylistPlugin supports "public holidays". Just write something like that to a topic (e.g. MyPublicHolidays):
   *  10 Jun 2009 - Corpus Christi* Frohnleichnam <!-- @all --> - :-)
( @all is required for public holidays and the HTML comment makes that invisible)
and to another topic:
%HOLIDAYLIST{month="Jun" topic="%TOPIC%,MyPublicHolidays" compatmode="on" enablepubholidays="on"}%

    * 3 Jun 2009 - Ingo
and you will see, that Ingo gets some additional free days.

Please send me an archive (.zip/.tgz/...) with your sample topics and forms. It's not really easy for me to create a test setup for your problem because I cannot see how do you use the HolidaylistPlugin attributes.

-- DanielRohde - 15 Jun 2009

Hi again,

I've submitted the next BETA release to SVN. The new test release fixes BASETOPIC/BASEWEB substitions. Please try the new version and test it before you send me your sample topic/form archive.

-- DanielRohde - 15 Jun 2009

Hi,

I've attached the file TimePlanning.tar.gz holding required files (hope I didn't miss something). Please have a look, thanks. You could simply extract the content into your Foswiki installation directory but it will overwrite data/System/UserForm, so be careful regarding that.

I retested your next BETA (SVN revision 4140) but the issue(s) remained, except of the white Sunday wink

-- IngoKappler - 15 Jun 2009

Hi Ingo,

the new SVN revision supports a special INCLUDE parameter handling. To use the new feature you must add allowvarsininclude="on" to your %HOLIDAYLIST% parameters.

A little improvement for your application: replace 'Dummy' by %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%

Thanx for testing ...

-- DanielRohde - 17 Jun 2009

... and multi-language support is also integrated now (see lang attribute).

-- DanielRohde - 17 Jun 2009

Hi Daniel,

thanks. I just enabled the following 2 lines on my topic and both now work (second line only with allowvarsininclude="on" ). So looks good from that point of view. Since I am going to slightly re-structure my setup I will give you another confirmation later on (today).

   * 11 Jun 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%" format="$value"}%%FORMFIELD{"LastName" topic="%BASETOPIC%" format="$value"}% - *Corpus Christi* Frohnleichnam - :-)

%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" section="TimePlanning%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" }%

Thank you very much. smile

-- IngoKappler - 18 Jun 2009

Ok, I found 1 "small" issue. When including public holidays using:

%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" section="TimePlanning%FORMFIELD{"Country" topic="%BASETOPIC%" format="$value"}%" }%

while the holidays are defined like:

---+!! %TOPIC%
 <!-- Do not change or remove this comment. FixedSearchCode_vac01
Do not add any other data to this topic except of the dates inside the section. -->

%STARTSECTION{"TimePlanningGermany"}%
   * 01 Jan 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *New Year's Day* Neujahr - :-)
   * 02 Apr 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Good Friday* Karfreitag - :-)
   * 05 Apr 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Easter Monday* Ostermontag - :-)
   * 01 May 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Labour Day* Tag der Arbeit / Maifeiertag - :-)
   * 13 May 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Ascension* Christi Himmelfahrt - :-)
   * 24 May 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Whit Monday* Pfingstmontag - :-)
   * 03 Jun 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Corpus Christi* Frohnleichnam - :-)
   * 03 Oct 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Day of German Unity* Tag der deutschen Einheit - :-)
   * 01 Nov 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *All Saints' Day* Allerheiligen - :-)
   * 25 Dec 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Christmas* 1. Weihnachtstag - :-)
   * 26 Dec 2010 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Christmas* 2. Weihnachtstag - :-)

   * 01 Jan 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *New Year's Day* Neujahr - :-)
   * 10 Apr 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Good Friday* Karfreitag  - :-)
   * 13 Apr 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Easter Monday* Ostermontag  - :-)
   * 01 May 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Labour Day* Tag der Arbeit  - :-)
   * 21 May 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Ascension* Christi Himmelfahrt  - :-)
   * 01 Jun 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Whit Monday* Pfingstmontag  - :-)
   * 11 Jun 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Corpus Christi* Frohnleichnam  - :-)
   * 03 Oct 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Day of German Unity* Tag der deutschen Einheit  - :-)
   * 01 Nov 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *All Saints' Day* Allerheiligen  - :-)
   * 25 Dec 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Christmas* 1. Weihnachtstag  - :-)
   * 26 Dec 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - *Christmas* 2. Weihnachtstag  - :-)

   * 01 Jan 2009 - %FORMFIELD{"FirstName" topic="%BASETOPIC%"}%%FORMFIELD{"LastName" topic="%BASETOPIC%"}% - Dummy entry which allows to display Holidays before any user entered data. Relevant if holidays are defined using &lt;!--@all--&gt;. In our current personalized holiday system this is not required anymore but kept as reference only.
%ENDSECTION{"TimePlanningGermany"}%

then when using the next button to go to e.g. the next 60 or 120 days the future holidays are not part of the table. This is not an issue when using the previous 60 or 120 days.

-- IngoKappler - 18 Jun 2009

Another thing, it looks like the HolidaylistPlugin now can handle BASETOPIC but when using TOPIC instead it still fails to display the result correctly. So I guess you'll have to allow TOPIC, BASETOPIC and INCLUDINGTOPIC for flexible handling of what might be needed. Please find here an example line:

%STARTSECTION{"MyPublicHolidays"}%
%INCLUDE{ "%USERSWEB%.VacationPublicHolidays%FORMFIELD{"Country" topic="%TOPIC%" format="$value"}%" section="TimePlanning%FORMFIELD{"Country" topic="%TOPIC%" format="$value"}%" }%
%ENDSECTION{"MyPublicHolidays"}%

Some more explanations about the latest issue I run into. Although now the BASETOPIC and the FORMFIELD stuff works, I've got an issue when building together the definitions from the different users as given on their homepages but only regarding the public holidays because those are already included. Since users are located in different countries the public holidays are not the same. Using <!--@all--> is not possible in an overview which holds people from different countries. So I am trying to bind the public holidays to the user by now using the above INCLUDE line. However, when trying to generate an overview with many users this needs to be included or searched for again. And at that point the name is not correctly resolved per user but left empty. Here is some code for building together (theoretically here I could use <!--@all--> but in others I won't be able to do so, the commented line is what I used earlier):

%STARTSECTION{"VacationSearchOfficeDüsseldorf"}%
%INCLUDE{ "%USERSWEB%.WikiCodeTimePlanning" section="TimePlanningLegend" }%
%HOLIDAYLIST{ startdate="-30" days="120" allowvarsininclude="on" showoptions="on" showweekends="0" enablepubholidays="1" showpubholidays="0" pubholidayicon=":-)" adayofficon=":ok:" holidayicon="8-)" notatworkicon="w1" tablecaption="Düsseldorf Office Vacations" namepos="both" todaybgcolor="#fff6a8" tableheadercolor="#8fadff" weekendbgcolor="#8fadff" showstatrow="off" showstatcol="on" showstatsum="on" statheader=" :-) | :ok: 8-) " statformat="%{pp} | %{hh}" }%
---+++ Projects
%SEARCH{ "WorkStatus='Current' AND Country='Germany' AND Office='Düsseldorf' AND text ~ '*MyProjects*' " type="query" web="%USERSWEB%" nonoise="on" format="$pattern(.*?(\%STARTSECTION\{\"MyProjects\"\}\%.*?\%ENDSECTION\{\"MyProjects\"\}\%).*)" }%
---+++ Public Holidays

%SEARCH{ "WorkStatus='Current' AND Country='Germany' AND Office='Düsseldorf' AND text ~ '*MyPublicHolidays*' " type="query" web="%USERSWEB%" nonoise="on" format="$pattern(.*?(\%STARTSECTION\{\"MyPublicHolidays\"\}\%.*?\%ENDSECTION\{\"MyPublicHolidays\"\}\%).*)" }%

<!-- % INCLUDE{ "%USERSWEB%.VacationPublicHolidaysGermany" section="TimePlanningGermany" }% -->

---+++ Vacations
%SEARCH{ "WorkStatus='Current' AND Country='Germany' AND Office='Düsseldorf' AND text ~ '*MyVacation*' " type="query" web="%USERSWEB%" nonoise="on" format="$pattern(.*?(\%STARTSECTION\{\"MyVacation\"\}\%.*?\%ENDSECTION\{\"MyVacation\"\}\%).*)" }%
%ENDSECTION{"VacationSearchOfficeDüsseldorf"}%

The searches for projects and vacations are ok, because the data is directly in the found topic. But for public holidays the data comes from the include and the name of the related person is not resolved and so far remained empty.

-- IngoKappler - 18 Jun 2009

It might have to do with the issue I noticed in Item1491: with Foswiki::Func::expandCommonVariables web and topic are passed in the wrong order.

-- ArthurClemens - 18 Jun 2009

Daniel, sorry but you can ignore the issue from above that is talking about not showing public holidays in the future when using next. I searched for the German holidays on 3rd of October and 1st of November but both fall on weekends, so this is what I didn't realize.

-- IngoKappler - 18 Jun 2009

Hi Daniel,

I have your latest beta now running on production since you released it and it solved definitely 2 issues I had. The 3rd one is still discussed above but I am not sure if it still applies to the HolidaylistPlugin. Generally it looks to me like you could release the beta as official version.

Also, if there are no objections we (I) may move the 3rd issue out of this topic into a new task, so it get's clearer what it is about.

I am looking forward to your official version.

-- IngoKappler - 26 Jun 2009

Hi Daniel,

for all your effort with this I put a virtual beer! Thanks so much. smile

-- IngoKappler - 24 Nov 2009
 
I Attachment Action Size Date Who Comment
HolidaylistPlugin_correct_definition.pngpng HolidaylistPlugin_correct_definition.png manage 11 K 09 Jun 2009 - 22:50 IngoKappler Definition is correctly resolved in the topic area
HolidaylistPlugin_correct_definition_2.pngpng HolidaylistPlugin_correct_definition_2.png manage 16 K 14 Jun 2009 - 07:02 IngoKappler HolidaylistPlugin_correct_definition_2
HolidaylistPlugin_name_issue_2.pngpng HolidaylistPlugin_name_issue_2.png manage 7 K 14 Jun 2009 - 07:05 IngoKappler HolidaylistPlugin_name_issue_2
HolidaylistPlugin_name_not_correctly_used_if_inserted_via_macro.pngpng HolidaylistPlugin_name_not_correctly_used_if_inserted_via_macro.png manage 8 K 09 Jun 2009 - 22:40 IngoKappler The name is not correctly used by the HolidaylistPlugin if it is resolved with the help of a macro
TimePlanning.tar.gzgz TimePlanning.tar.gz manage 6 K 15 Jun 2009 - 10:22 IngoKappler TimePlanning.tar.gz
Topic revision: r28 - 24 Nov 2009, IngoKappler
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