Calendar_XH 1.4 released

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Re: Calendar_XH 1.4 released

Postby cmb » Sun Jul 01, 2012 12:08 pm

Hi Beate,

beate_r wrote:I would like to avoid the popup for the long description of the event and simply have it added into the list entry. How do i disable that popup?

I assume you're asking about Calendar 1.4. The description ("Additional Description") will be shown directly in the output. But I guess you mean the "Info Text": just uncheck the "Icon" checkbox to the left of the "Info Text" textarea.

If you want to have full control over the appearance of the eventlist, have a look at section 11 "Event-List Style" in the manual.

beate_r wrote:the format of the calendar database might lead to severe problems, if one of the entries contains a semicolon.

If the events are edited from the back-end, all semicolons will be replaced by commas, to avoid corruption of the database. But changing the delimiter might be a good idea anyway. ASCII 28-31 would be a logical choice, but I'm afraid not all editors have full support for displaying and inserting these characters. So perhaps a Tab character or even a multi-character combination might be considered.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5566
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: Calendar_XH 1.4 released

Postby beate_r » Mon Jul 02, 2012 11:14 pm

Hi Christoph,

cmb wrote: So perhaps a Tab character or even a multi-character combination might be considered.


Maybe CSV would be a good choice. Well supported, the neccessary quoting provided by convention, probably libraries available (i would be surprised if not).

Beate
beate_r
 
Posts: 125
Joined: Thu May 22, 2008 11:44 pm
Location: Hessen / Germany

Re: Calendar_XH 1.4 released

Postby cmb » Tue Jul 03, 2012 12:59 am

@admins: In the following I'm going quite OT, so feel free to move the post, if reasonable.

beate_r wrote:i would be surprised if not

Hmm, parsing of CSV files is supported since PHP 4 through fgetcsv() (unfortunately full support is not available: the $escape character was introduced in 5.3, so it's not possible to have fields containing $delimiter as well as the $enclosure characters in earlier versions). Writing of CSV files through fputcsv() was introduced only in PHP 5.1, and the even more flexible str_getcsv() was introduced not until PHP 5.3. So full CSV support is only available in quite recent PHP versions :(

Unfortunately there's no other flat file database format generally available in PHP (probably dBase is not supported on most shared hosting services; DBA is probably available everywhere, but only with rather suboptimal drivers; SQLite, which is nearly a full fledged SQL database, is probably available on most PHP 5 powered hosts, but it's been made a PECL extension since PHP 5.4, so availability might decrease). And as nowadays probably 90% of PHP scripts use mySQL :roll: (I'm not saying, that mySQL is something bad, but often it's like breaking a butterfly on a wheel), I doubt that there'll be any improvements in this area.

So, what's left:
  • some custom format:
    The details are hard to handle for the plugin writer, and users who want to edit the files manually have to learn the syntax (including all the gory details).
  • serialize()/unserialize():
    Fast (BTW: sessions are stored this way), powerful and easy to use for the plugin writer, but it's impractical to edit these files manually (particularly with UTF-8 encoding)
  • XML
    The XML Parser (based on expat) is probably available everywhere -- but it's usability is poor. Other XML parsers are available since PHP 5.x only, and they are lame.
  • JSON
    Quite nice, but natively supported not until PHP 5.2.
  • PHP
    Quite fast and easy to read, but editing manually is dangerous, as parse errors will cause PHP to exit.
  • YAML
    (do not mistake it for the "template engine" ported to CMSimple by Till)
    Very nice compromise (machine vs. human readability), but not natively supported by PHP, though PHP only implementations are available (probably lame too -- and it seems YAML hasn't made it against JSON)
If anybody has to add something, please report it -- I'm gladly willing to extend the list.

Christoph

PS:
beate_r wrote:Well supported, the neccessary quoting provided by convention, probably libraries available

see http://stackoverflow.com/questions/5341219/csv-library-for-php
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5566
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: Calendar_XH 1.4 released

Postby svasti » Tue Jul 03, 2012 7:24 pm

Hi calendar-friends,

just returning from holidays and seeing this thread.
cmb wrote:But what about other cultural spheres? E.g. in Russia (Orthodox Church) christmas is celebrated on January 6th; AFAIK the jews have totally different holidays; and I'm quite sure, that there are totally different holidays in other countries.
thought about that, however are any of these people using CMSimple? I just had a look at the list of public holidays in Russia, and it seems all of them can be put into Calendar, as Easter is not a public holiday in Russia. It should not be so difficult to enter new holidays in Calendar.

beate_r wrote:Secondly, and possibly more important: the format of the calendar database might lead to severe problems,
The format is quite strange in my view, but to keep compatibility with the older versions I kept it as it was designed by Michael Svarrer. Next version will most probably have a new format. Actually the presence of unwanted ";" is checked frequently by Calendar.

cmb wrote:parsing of CSV files is supported since PHP 4 through fgetcsv()
I found that the csv functions are language dependent and not really utf-8 save. That's why I removed all of them in memberpages after having put them in in the first place, only to discover that accented letters can pose problems.

I haven'd settled on a particular flat file version for next Calendar, but I would like something flexible, where the file contains also the information on the fields that are used etc., so that one can add fields without breaking the file structure.
It should be simple and powerful :lol:

svasti
svasti
 
Posts: 694
Joined: Wed Dec 17, 2008 5:08 pm
Location: Bielefeld, Germany

Re: Calendar_XH 1.4 released

Postby cmb » Tue Jul 03, 2012 8:09 pm

Hi svasti,

svasti wrote:just returning from holidays

Nice to have you back in the forum. I hope your holidays were recreative.

svasti wrote:are any of these people using CMSimple?

Have a look at the download stats on SF: 7. Russia, 17. Indonesia, 24. China. Only small numbers (compared to the german downloads), and only statistics, but OTOH: various religions have their own holidays (those are not necessarily restricted to certain countries). If feasible, it might be nice to be able to configure the holidays (maybe in the language settings?) -- particularly the movable ones.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5566
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: Calendar_XH 1.4 released

Postby Tata » Tue Jul 03, 2012 8:51 pm

I thought about this too. The language setting would be the right place to do so.
Basically, the countries have various number of holidays. But the principle may be simple:
1. Let have e.g. 10 fields:
Code: Select all
$plugin_tx['calendar']['holiday_01'] = "date_1,date_2,name"; //use date_2 if the holiday extends more days
$plugin_tx['calendar']['holiday_02'] = "date_1,date_2,name";
...
$plugin_tx['calendar']['holiday_10'] = "date_1,date_2,name";

2. If there is a need to have more holidays defined, extending these 10 fields is a simple task. Or (more coding required), it can be done by a function
"create_holiday_fields" with input field for the number of required holidays, finaly saved into the language file.

The plugin then should look for these fields and parse them into the calendar table.
Image
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
Tata
 
Posts: 1440
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia

Re: Calendar_XH 1.4 released

Postby cmb » Tue Jul 03, 2012 9:50 pm

Tata wrote:Basically, the countries have various number of holidays. But the principle may be simple:

The problem is not so much with the fixed holidays. Since Calendar_XH 1.4 (or 1.3?) it's possible to enter yearly events, which could be used for the holidays too. But what about the movable holidays (e.g. Easter, Thanksgiving, Chanukah, Chinese New Year)? These can't be specified by a certain date, but have to be somehow calculated. Thanksgiving can be calculated quite easily: it's the 4th Thursday in November (in the US). But Easter is more complicated, so such holidays probably need some special PHP calculation. But how could this be specified in the configuration?
Code: Select all
${EASTER}-2, Good Friday
${EASTER}, Easter Sunday
${EASTER}+1, Easter Monday
${EASTER}+49, Pentecost
:?:
And of course it would require to implement algorithms for other movable holidays...
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5566
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: Calendar_XH 1.4 released

Postby svasti » Thu Jul 05, 2012 7:42 pm

Hi Tata, hi Christoph,

what you are asking for is in large parts already there in Calendar 1.4. You can set holidays in the language file, even quite complicated ones;
Calendar Help file wrote:
  • Fixed holidays are entered as day.month,holiday-name. (Instead of the dot you have to use hyphen or slash if your date delimiter is set to this.)
  • Movable holidays depending on the Easter date are entered without day and month by entering: easter + x day (x = number of days after Easter) or easter - y day (y = number of days before Easter) as follows:

    Good Friday: easter - 2 day,Good Friday
    Whitsunday: easter + 49 day,Whitsunday
    Corpus Christi Day: easter + 60 day,Corpus Christi Day
  • Other movable holidays occuring on a fixed weekday following or preceding a certain fixed date are entered as follows:

    English May Day Bank Holiday: monday 1.5,May Day Bank Holiday (Monday starting counting from 1st of May, i.e. first Monday in May)
    English Spring Bank Holiday: -1 monday 1.6,Spring Bank Holiday (Monday before 1st of June, i.e. last Monday in May)
    English Summer Bank Holiday: -1 monday 1.9,Summer Bank Holiday (Monday before 1st of September, i.e. last Monday in August)
    German holiday "Buß- und Bettag": -11 days 1 sunday 26.11 (11 days before the 1st sunday after 26.11)
    1. Advent: 1 sunday 26.11 (1st sunday after 26.11)

languages/de.php has
Code: Select all
$plugin_tx['calendar']['holydays']="1.1,Neujahr;6.1,Hl. Drei Könige;1.5,Tag der Arbeit;easter - 48 day,Rosenmontag;easter -2 day,Karfreitag;easter,Ostern;easter + 1 day,Ostermontag;easter + 39 day,Himmelfahrt;easter + 49 day,Pfingsten;easter + 50 day,Pfingstmontag;easter + 60 day,Fronleichnam;15.8,Mariä Himmelfahrt;3.10,Tag der Deutschen Einheit;31.10,Reformationstag;1.11,Allerheiligen;-11 days 1 sunday 26.11,Buß- u. Bettag;1 sunday 26.11,1. Advent;2 sunday 26.11,2. Advent;3 sunday 26.11,3. Advent;4 sunday 26.11,4. Advent;24.12,Heiligabend;25.12,1. Weihnachtstag;26.12,2. Weihnachtstag;31.12,Silvester";

I thought it was easy to enter holidays for other languages??? May be I should add a "Holiday Wizard" in Calendar 1.5? What more Holidays would you propose? Orthodox? In the php-manual there is a function to calculate orthodox easter. Jewish? I found a rather big chunk of code to calculate jewish holidays. I'm afraid this may fatten Calendar.... better I offer Holiday add-ons.
Couldn't find any Hindu-Calendar code, this would be lunar based.

svasti
svasti
 
Posts: 694
Joined: Wed Dec 17, 2008 5:08 pm
Location: Bielefeld, Germany

Re: Calendar_XH 1.4 released

Postby Tata » Thu Jul 05, 2012 8:16 pm

svasti wrote:.... better I offer Holiday add-ons

This sounds as the best solution. If this plugin could tightlz communicate with the calendar plugin, then the calendar may take even some reductinal diete :-) and all hlidays then may be transfered into the holiday plugin.
The calendar self then would onlz serve as "linking service" to events.
Image
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
Tata
 
Posts: 1440
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia

Re: Calendar_XH 1.4 released

Postby cmb » Thu Jul 05, 2012 10:42 pm

svasti wrote:I thought it was easy to enter holidays for other languages???

Yes, it is the way you've done it! I better should have RTFM before suggesting, what's already there! :oops:

svasti wrote:What more Holidays would you propose?

That's hard to say, as it depends on the usage of CMSimple and the Calendar plugin. Perhaps it might be a good idea to add an appropriate thread to the "Translations" forum? Of course holidays are not translations, not even some form of localization, but it's somewhat related. This way users might express their wishes, and maybe give even some insights on holidays in their culture.

svasti wrote:this would be lunar based.

It seems to me that many movable holidays are lunar based (e.g. Easter and the Chinese New Year's day). A general calculation of the moon phases might be interesting. Qualifire's SMCal already does this. Unfortunately it's not allowed to modify the plugin, but perhaps some of it's functionality might be included to Calendar (of course newly written to avoid any copyright infringement).

svasti wrote:better I offer Holiday add-ons.

Perhaps a very good idea -- IMO the main goal should be simplicity for the user as well as for the developer. I consider performance secondary, but well, Calendar has already gone a long way to avoid putting a burden on the system when not necessary. :)

svasti wrote:Jewish? I found a rather big chunk of code to calculate jewish holidays.

I'd rather avoid being political when the topic is software development, but IMO that's something that should be seriously considered; see e.g. http://tro-hosting.de/stolpersteine/
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5566
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

PreviousNext

Return to Addons and Plugins

Who is online

Users browsing this forum: No registered users and 1 guest