Events Made Easy › Forums › Bug fixed or feature request implemented › Locations Map Previous/Next Month Arrows
- This topic has 18 replies, 2 voices, and was last updated 13 years, 11 months ago by Anonymous.
-
AuthorPosts
-
Wed 29 Dec 2010 at 19:05 #42332AnonymousInactive
How much trouble would it be to add locations map support for previous/next month arrows (like the calendar)?
Wed 29 Dec 2010 at 20:42 #45748FrankyKeymasterthat’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)
Wed 29 Dec 2010 at 21:09 #45749AnonymousInactiveTerrific! Exactly what I need. Thanks.
Thu 30 Dec 2010 at 01:00 #45750AnonymousInactiveThis 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"));
Thu 30 Dec 2010 at 09:32 #45751FrankyKeymasterSeems 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)
Thu 30 Dec 2010 at 15:09 #45752AnonymousInactivePHP 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.
Thu 30 Dec 2010 at 18:22 #45753FrankyKeymasterYeah … 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);Thu 30 Dec 2010 at 20:36 #45754AnonymousInactiveI 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.
Thu 30 Dec 2010 at 20:43 #45755AnonymousInactiveWith 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”
Thu 30 Dec 2010 at 21:18 #45756AnonymousInactiveI 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.
Thu 30 Dec 2010 at 21:56 #45757AnonymousInactiveThere 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')))));
Thu 30 Dec 2010 at 22:17 #45758AnonymousInactiveI 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')))));
Thu 30 Dec 2010 at 23:12 #45759FrankyKeymasterOk, 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 🙂
Thu 30 Dec 2010 at 23:27 #45760AnonymousInactiveI 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.
Thu 30 Dec 2010 at 23:41 #45761FrankyKeymasterNo, it’s logical 🙂
Working on a fix now (and need to fix other code as well, since this brought to light a new bug)
Thu 30 Dec 2010 at 23:51 #45762FrankyKeymasterFix (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";Fri 31 Dec 2010 at 00:00 #45763FrankyKeymasteris now in trunk btw 🙂
Fri 31 Dec 2010 at 00:24 #45764AnonymousInactiveI haven’t downloaded from the trunk yet, but I just confirmed that your latest code works.
Fri 31 Dec 2010 at 00:41 #45765AnonymousInactiveI just installed from the trunk and that also works.
-
AuthorPosts
- The forum ‘Bug fixed or feature request implemented’ is closed to new topics and replies.