Events Made Easy Forums Bug fixed or feature request implemented Locations Map Previous/Next Month Arrows

Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #42332
    Anonymous
    Inactive

    How much trouble would it be to add locations map support for previous/next month arrows (like the calendar)?

    #45748
    Franky
    Keymaster

    that’s quite a change … certainly not like the calendar, but like the newly added code for paging in the shortcode [events_list]. But I added it 🙂

    See trunk, but use paging only on a page with one shortcode (otherwise eg. the events_list shortcode might get confused as well)

    #45749
    Anonymous
    Inactive

    Terrific! Exactly what I need. Thanks.

    #45750
    Anonymous
    Inactive

    This shortcode works with new code from the trunk:

    [locations_map eventful=1 paging=1 scope=this_week]

    This shortcode displays a world map with no location markers:

    [locations_map eventful=1 paging=1 scope=this_month]

    The following Line 530 from eme_locations.php doesn’t look right to me:

    $scope = date('Y-m-d',strtotime("first day of this month $scope_offset months"))."--".date('Y-m-d',strtotime("last day of this month $scope_offset months"));

    #45751
    Franky
    Keymaster

    Seems to work just fine for me … but you need at least php 5.3 for this to work correctly.

    Do a “print $scope;” after this line, and see what it returns. In my case: “2010-12-01–2010-12-31” (without clicking the arrows that is)

    #45752
    Anonymous
    Inactive

    PHP backward incompatibility is the problem then.

    I like to stay current with the latest software, but PHP upgrades can create an enormous cascade of serious problems for hosting firms. In many cases hundreds of websites run on single boxes. PHP upgrades are nearly certain to cause some of those sites to fail, trigger a technical support and customer relations nightmare, and cause the firm to lose customers. WordPress developers looked at PHP usage statistics in July and found about 88 percent where using PHP 5.2. See: http://wpdevel.wordpress.com/2010/07/09/suggest-topics-for-the-july-15-2010-dev/ As of late September only about 3 percent of WordPress sites use PHP 5.3. In contrast, more than 7 percent still use PHP 4.

    If developers don’t use features of new versions of support software like PHP there is no incentive to upgrade and the world will forever be stuck with old technology, but the flip-side is the practical reality that requiring new versions excludes the vast majority (about 97 percent in this case) of users.

    #45753
    Franky
    Keymaster

    Yeah … php issues are here to stay 🙂 Can you try:

    $scope = date('Y-m-d',strtotime("first day of this month $scope_offset months"))."--".date('Y-m-d',strtotime("first day of next month $scope_offset months")-86400);

    ?

    And if that (first day of next month) doesn’t work:

    $next_offset=$scope_offset+1;
    $scope = date('Y-m-d',strtotime("first day of this month $scope_offset months"))."--".date('Y-m-d',strtotime("first day of this month $next_offset months")-86400);

    #45754
    Anonymous
    Inactive

    I have been outside shoveling snow and thinking about a fix.

    I just tried your two alternatives above. Neither one works using PHP 5.2.14. I will try some things and get back to you.

    #45755
    Anonymous
    Inactive

    With your original PHP 5.3 code and “this_month”:

    $scope == “”

    Using either the first or second alternative in your post above:

    $scope == “1970-01-01–1969-12-31”

    #45756
    Anonymous
    Inactive

    I just wrote the following which returns 2010-12-01–2010-12-31 under PHP 5.2.14:

    $scope=date("Y-m-d", strtotime(date('m').'/01/'.date('Y').' 00:00:00'))."--".date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));

    However, it needs to be modified to allow incrementing the month with forward and rearward year rollovers.

    #45757
    Anonymous
    Inactive

    There must be a simpler way to do this, but the following works except for January, which fails (I think) due to the -1 second trick:

    $scope=date("Y-m-d",strtotime((string)$scope_offset.' month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))."--".date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime((string)$scope_offset.' month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))));

    #45758
    Anonymous
    Inactive

    I changed -1 second to -1 day, which wasn’t actually causing the problem, but -1 day is more logical. The true problem was a couple missing “+” characters. The following code seems to work correctly with PHP 5.2.14, both forward and backward in time:

    $scope=date("Y-m-d",strtotime("+".(string)$scope_offset.' month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))."--".date("Y-m-d", strtotime('-1 day',strtotime('+1 month',strtotime("+".(string)$scope_offset.' month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))));

    #45759
    Franky
    Keymaster

    Ok, complicated but should probably work 🙂

    But then again, I already got this code to calculate next month’s scope, so this is more readable:

    $year=date('Y', strtotime("+$scope_offset month"));
    $month=date('m', strtotime("+$scope_offset month"));
    $number_of_days_month=eme_days_in_month($month,$year);
    $limit_start = "$year-$month-01";
    $limit_end = "$year-$month-$number_of_days_month";
    $scope = "$limit_start--$limit_end";

    Try this 🙂

    #45760
    Anonymous
    Inactive

    I just tried your code:

    eme_offset=-3 returns: 2010-09-01–2010-09-30

    eme_offset=-2 returns: 2010-10-01–2010-10-31

    eme_offset=-1 returns: 2010-11-01–2010-11-30

    eme_offset=0 returns: 2010-12-01–2010-12-31

    eme_offset=1 returns: 2011-01-01–2011-01-31

    eme_offset=2 returns: 2011-03-01–2011-03-31

    eme_offset=3 returns: 2011-03-01–2011-03-31

    eme_offset=4 returns: 2011-04-01–2011-04-30

    eme_offset=5 returns: 2011-05-01–2011-05-31

    eme_offset=6 returns: 2011-06-01–2011-06-30

    I didn’t test beyond that range, but note that eme_offset=2 strangely returns March.

    #45761
    Franky
    Keymaster

    No, it’s logical 🙂

    Working on a fix now (and need to fix other code as well, since this brought to light a new bug)

    #45762
    Franky
    Keymaster

    Fix (will be in trunk):

    // the year/month should be based on the first of the month, so if we are the 13th, we substract 12 days to get to day 1
    $day_offset=date('j')-1;
    $year=date('Y', strtotime("+$scope_offset month")-$day_offset*86400);
    $month=date('m', strtotime("+$scope_offset month")-$day_offset*86400);
    $number_of_days_month=eme_days_in_month($month,$year);
    $limit_start = "$year-$month-01";
    $limit_end = "$year-$month-$number_of_days_month";
    $scope = "$limit_start--$limit_end";

    #45763
    Franky
    Keymaster

    is now in trunk btw 🙂

    #45764
    Anonymous
    Inactive

    I haven’t downloaded from the trunk yet, but I just confirmed that your latest code works.

    #45765
    Anonymous
    Inactive

    I just installed from the trunk and that also works.

Viewing 19 posts - 1 through 19 (of 19 total)
  • The forum ‘Bug fixed or feature request implemented’ is closed to new topics and replies.
Scroll to Top