-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi again,

besides the "xofmonth" hack, I created another extension a while ago that 
modifies how multi-day
events are handled.

Usually (and without any better knowledge) if you have an event that starts on 
April 8th and ends on
April 10th, you only have two [[Has date::]] properties, i.e. the starting and 
ending dates.

The Timeline Result Format displays these events as continuous, but the 
Calendar does not.

Is there already a way to have the Calendar display the event on all days?

If not, this is what I did:  (Again, a very quick and dirty hack and not even 
using any SMW classes.
Example: https://www.hackerspace.lu/wiki/Hackito_Ergo_Sum! -->
https://www.hackerspace.lu/w/index.php?title=Calendar&month=4&year=2010 (8-10 
April))

function efDateDiff(){
    global $wgParser;
    $wgParser->setFunctionHook('dates', 'calcdates');
}

/**
 * Adds the magic words for the parser functions
 */
function efDatesFunctionMagic( &$magicWords, $langCode ) {
        $magicWords['dates'] = array( 0, 'dates' );
        return true;
}

function calcdates(&$parser){
        $params = func_get_args();
        array_shift( $params ); // We already know the $parser ...
        while(empty($params[0])) array_shift($params);  // quite common

        $dates = array();
        foreach($params as $pair)
                $dates[] = substr($pair,strpos($pair,'=')+1);   // we currently 
ignore the label of the date

        $time1 = strtotime($dates[0]);
        $time2 = strtotime($dates[1]);

        $a = ($time2 > $time1) ? $time2 : $time1;       // higher
        $b = ($a == $time1) ? $time2 : $time1;          // lower
        $datediff = $a - $b;

        $oneday = 86400;
        $days = array();
        for($i=0;$i <= $datediff; $i+=$oneday){
                $days[] = date('c',strtotime($dates[0])+$i);
        }
        return implode(',',$days);

}

cheers,
David

- --
HaxoGreen 2010 - the Hackers' Summercamp in Luxembourg
July 22nd till July 25th 2010, in Dudelange, Luxembourg
Register Now: http://events.hackerspace.lu/camp/2010/
- ----
mailto:da...@hackerspace.lu
xmpp:kwis...@jabber.hackerspaces.org
mobile: +43 650 73 63 834 | +352 691 44 23 24
++++++++++++++++++++++++++++++++++++++++++++
Wear your geek: http://syn2cat.spreadshirt.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuP65EACgkQYTtdUdP5zDf6HwCdH4liGAysizQPjOaSk2lR2G5k
OKEAnRu2WfYj8hAuC3DLtL5VqvxboaqZ
=s+N0
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to