Jump to:

10930 Posts in 2613 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar in 2.4 alpha

Discuss all other Modules here.

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

Page: 1 2 3
Go to End
Author Topic: 3591 Views
  • Miles
    Avatar
    Community Member
    14 Posts

    Event Calendar in 2.4 alpha Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    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.

  • Miles
    Avatar
    Community Member
    14 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    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.

  • Miles
    Avatar
    Community Member
    14 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    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.

  • Miles
    Avatar
    Community Member
    14 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    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!

  • Stuckinrealtime
    Avatar
    Community Member
    2 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    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);
          }
       }

  • Miles
    Avatar
    Community Member
    14 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

    Many thanks for your amazing help today!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar in 2.4 alpha Link to this post

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

    3591 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.