Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Event Calendar in 2.4 alpha


Go to End


21 Posts   6590 Views

Avatar
Miles

Community Member, 14 Posts

21 November 2009 at 5:35am

Ok, I'm being brave and working on trying to get event_calendar to work with the new 2.4.0 branch. Is anyone else attempting to get this working yet?

So far I've done the following things?

In /event_calendar/code/RecurringDayOfMonth.php altered line 42 from:

Database::alteration_message("Recurring Days of Month added.","created"); 

to
DB::alteration_message("Recurring Days of Month added.","created"); 

In /event_calendar/code/RecurringDayOfWeek.php I altered line 45 from:

Database::alteration_message("Recurring Days of Week added.","created"); 

to
DB::alteration_message("Recurring Days of Week added.","created"); 

After those changes I could at least get the module to install without errors.
I can also create a calendar, but cannot create calendar events. Now the current error is:

Fatal error: Call to a member function FormName() on a non-object in /home/kiveo/subdomains/sstest/sapphire/forms/DateField.php on line 54

At this point, in dataobject_manager I switched out and used the nestedUrls version of the class and ran into a couple parse errors.

In the new DataObjectManager.php I had to make the following code additions:

protected static $allow_assets_override = true;
protected static $allow_css_override = false;

	public static function allow_assets_override($bool)
	{
	    if($bool) {
	      DataObject::add_extension("Folder","AssetManagerFolder");
	      SortableDataObject::add_sortable_class("File");
	    }
	    else
	      DataObject::remove_extension("Folder","AssetManagerFolder");
	}
	
	public static function allow_css_override($bool)
	{
	   self::$allow_css_override = $bool;
	}

I'm aware there are a few more changes made to the live DataObjectManager relating to paths for include files, and I'm about to find those and make those edits as well.

UncleCheese if you or anyone else is working on this in the community, I would love any feedback as you have it. I will also keep updating this thread for anyone else who will try to undertake this endeavor.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

21 November 2009 at 7:11am

Ugh. Not looking forward to this transition. Thanks for looking into it.

The NestedURLs version of DOM is bunk. It hasn't been updated in months, so I would recommend you do your edits to DataObjectManager.php.

Avatar
Miles

Community Member, 14 Posts

21 November 2009 at 7:26am

Ok, then I'll swap files back, and keep chipping away. I'll post updates here as I have them. Anyone else who feels ambitious, feel free to join the fun. :)

Avatar
Miles

Community Member, 14 Posts

21 November 2009 at 9:21am

Ok, so I can actually add an event to the calendar now, and get the public calendar view to show.

I bypassed the previous parse issue for the moment by putting in my own function jsValidation in CalendarDateField.php

function jsValidation() {
	return true;
}

Basically as it's trying to run the jsValidation method on the CalendarDateField, $this->form is evaluating to null. I've seen there are some posts on possible reasons for this to happen that I'll read through and see if I can get a resolution to that. If anyone has any ideas, or places for me to look it would be appreciated.

Now that I can get events in the system I can see them on a front end view of events just fine. Of course when I actually try to view an individual event, that's of course broken with a SS_HTTPResponse_Exception.

Avatar
Miles

Community Member, 14 Posts

30 December 2009 at 8:47am

Ok, we pretty much have a working system with the exception of two pretty large details. The page routing/handling isn't working.

Whenever we try to filter events, or view the details of a single event, it just 404's. It's not routing to the correct actions. UncleCheese, if you or anyone else could point us in the right direction on where to look at handling this, that would be wonderful!

Avatar
Stuckinrealtime

Community Member, 2 Posts

5 January 2010 at 10:59am

Methods to add so the calendar handles clicking on events

add this method to event_calendar/code/Calendar.php

	public function handleAction($request) {
		//Debug::show($this->urlParams);
		$patterns = array();
		$patterns[] = '/^(19|20)\d\d$/';
		$patterns[] = '/^(19|20)\d\d-(0[1-9]|1[012])$/';
		$patterns[] = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/';
		$theAction = $this->urlParams['Action'];
		$goodDate = false;
		if (!$this->hasMethod[$theAction]) { // only do this if we don't already match an existing action
			if((strlen($theAction) >=4) && (strlen($theAction) <= 10)) {
				// only one date specified
				foreach($patterns as $pattern) {
					//Debug::show($pattern);
					if (preg_match($pattern,$theAction) !== 0) {
						$goodDate = true;
						break;
					}
				}			
			} elseif (strlen($theAction) == 21) {
				$d1 = substr($theAction,0,10); 
				$d2 = substr($theAction,11,10);
				//Debug::show($d1);
				//Debug::show($d2);
				if ((preg_match($patterns[2],$d1) > 0) && (preg_match($patterns[2],$d2) > 0)) {
					$goodDate = true;
				}
			}
			if ($goodDate) {
				$this->action = 'index';
				return $this->getViewer($this->action)->process($this);	
			}
		}
		
		return parent::handleAction($request);
	}

add this method to event_calendar/code/CalendarEvent.php

	public function handleAction($request) {
		$theAction = $this->urlParams['Action'];
		if (!$this->hasMethod[$theAction]) {
			$this->action = 'index';
			return $this->getViewer($this->action)->process($this);
		} else {
			return parent::handleAction($request);
		}
	}

Avatar
Miles

Community Member, 14 Posts

5 January 2010 at 11:08am

Many thanks for your amazing help today!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

5 January 2010 at 2:54pm

Yes, thanks to both of you guys. One less thing for me to worry about with the 2.4 release. :)

Go to Top