Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Compatibility with Vanilla 2.8

Hi,

I have modified the plugin to make it compatible with vanilla 2.8.

There is one issue with the test of the category ID :

if (!in_array($categoryID, c('EventCalendar.CategoryIDs'))) {

should now be

if (!in_array($categoryID, unserialize(c('EventCalendar.CategoryIDs')))) {

and also :

       $sender->addDefinition(
           'EventCalendarCategoryIDs',
           json_encode(unserialize(c('EventCalendar.CategoryIDs')))
       );


Comments

  • Another correction, line 209

    $categoryID = $sender->Data['Category']['CategoryID'];
    
  • And lastly i think, a question..

    the date inputs are rendered like this :

           echo $sender->Form->date('EventCalendarDate', [
               'YearRange' => $yearRange,
               'Fields' => $fields
           ]);
    

    I'm looking for a way to customize the order of the fields (day, month, year instead of month, day, year).

    And i'll like to have the months in french.. I have french names when showing in the calendar, but i can't figure how to do this in the case of the month select..

    I did not found documentation about the $sender->Form->date options.. ?

    Thanks if anyone does have information

  • R_JR_J Admin

    If you like to, you can make pull requests to the repo

    For translations, you need to create a file "fr.php" in the /locale subfolder of the plugin. Easiest approach would be to copy the german language file (it has more entries) and translate it.

    If you look at this line $fields = explode(',', t('EventCalendar.DateOrder', 'month,day,year')); you can find a hint on how to change the order of the months: you need a translation for "EventCalendar.DateOrder" like it is done in the German locale file

    You can find great documentation in the Vanilla source code directly. Here is the date method of the form class

  • Thanks ! I managed to change the fields order, i saw the line in the plugin code, but i missed the translation (i should have search for the meaning of the 't' function !)

    For the translation, i've tried the fr.php file in the /plugins/EventCalendar/locale directory, but it was not loaded.. When i put the translations in the /locales (root) it's OK !

    And yes, for github i should learn to use it, but i'm not familiar with it, so it was quickier to just post the hints to make it work with 2.8

    I have posted a quite long message earlier (not validated yet it seems) which explains how to add an end date to the event and replace the month view with fullcalendar.. I should do a pull request for this too.. as it's big changes to your code.

    Thanks for your help

  • ok, i've put it on github and made a pull request

  • Oh also, in case you would like to use fullCalendar to view the events instead of the actual view..

    In views/month.php

    after

    $events = $this->data('Events');
    if (count($events) < 1) {
       echo '<p>'.t('No events yet').'</p>';
       return;
    }
    

    I construct the array i'll use (i've also used the profile extender to assign a color to each user) :

    $jsEvents = array();
    $i = 0;
    foreach($events as $event) {
       $user = Gdn::userModel()->getID($event['UserID']);
       $color = "#".Gdn::UserMetaModel()->GetUserMeta($event['UserID'], 'Profile.CouleurAgenda')['Profile.CouleurAgenda'];
       $jsEvents[$i]['user'] = $user->Name;
       $jsEvents[$i]['userID'] = $event['UserID'];
       $jsEvents[$i]['DiscussionID'] = $event['DiscussionID'];
       $jsEvents[$i]['title'] = $event['Name'];
       $jsEvents[$i]['start'] = $event['EventCalendarDate'];
       $jsEvents[$i]['startDate'] = strftime(t('EventCalendar.DateFormat', '%A, %e %B %Y'), strtotime($event['EventCalendarDate']));
       $jsEvents[$i]['link'] = anchor(t('Voir la discussion'), '/discussion/'.$event['DiscussionID'], 'Button');
       $jsEvents[$i]['body'] = Gdn_Format::to($event['Body'], $event['Format']);
       if( !is_null($color) ) {
          $jsEvents[$i]['color'] = $color;
       }
       if( !is_null($event['EventCalendarDateEnd']) ) { 
          $jsEvents[$i]['end'] = $event['EventCalendarDateEnd']."T23:59:00";
          $jsEvents[$i]['endDate'] = strftime(t('EventCalendar.DateFormat', '%A, %e %B %Y'), strtotime($event['EventCalendarDateEnd']));
       }
       $i++;
    }
    $jsEvents = json_encode($jsEvents);
    

    And for the calendar itself (with bootstrap 4, for the popover) :


        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    
       <link href='/js/fullcalendar/packages/core/main.css' rel='stylesheet' />
       <link href='/js/fullcalendar/packages/daygrid/main.css' rel='stylesheet' />
       <link href='/js/fullcalendar/packages/bootstrap/main.css' rel='stylesheet' />
       <link href='/js/fullcalendar/bootstrap.min.css' rel='stylesheet' />
    
       <script src='/js/fullcalendar/packages/core/main.js'></script>
       <script src='/js/fullcalendar/packages/core/locales/fr.js'></script>
       <script src='/js/fullcalendar/packages/daygrid/main.js'></script>
       <script src='/js/fullcalendar/packages/bootstrap/main.js'></script>
    
       <script>
    
         document.addEventListener('DOMContentLoaded', function() {
           var calendarEl = document.getElementById('calendar');
          var el;
           var calendar = new FullCalendar.Calendar(calendarEl, {
             plugins: [ 'dayGrid', 'bootstrap' ],
             locale: 'fr',
             editable: false,
             height: 'auto',
             handleWindowResize: true,
             displayEventTime: false,
             defaultView: 'dayGridMonth',
             eventClick: function(info) {
                //console.log(info.event);
                //console.log(info.event.extendedProps.endDate);
                $(".fc-day-grid-event").popover('hide');
                if( typeof(info.event.extendedProps.endDate) !== 'undefined' ) {
                   var dateFormate = " du " + info.event.extendedProps.startDate + " au " + info.event.extendedProps.endDate;
                } else {
                   var dateFormate = " le " + info.event.extendedProps.startDate
                }
    
                $(info.el).popover({
                      title: info.event.title + " -- " + dateFormate,
                      content: 'Evénement crée par <a href="/profile/'+info.event.extendedProps.user+'">'+info.event.extendedProps.user+'</a><br />' + info.event.extendedProps.body + '<br />' + info.event.extendedProps.link,
                      html: true
                }).popover('show');
                ; 
             },
             events: <?php echo $jsEvents; ?>
           });
    
           calendar.render();
    
          $("#closeAll").on('click', function(e) {
             e.preventDefault();
             $(".fc-day-grid-event").popover('hide');
          });
         });
    
       </script>
    
       <div id='calendar'></div>
    


    If it can help someone ;)

  • R_JR_J Admin

    Thanks for that! Adding the locale file to your "personal" locales is the better approach anyway. It might have worked if you have deleted the /cache/addon.php file, I guess...

  • K17K17 ✭✭✭
    edited April 2019

    Bonjour :D

    Si tu as besoin d'aide pour la traduction je peux t'aider @levince ^^

    <?php
    $Definition['Jan']='Janvier';
    $Definition['Feb']='Février';
    $Definition['Mar']='Mars';
    $Definition['Apr']='Avril';
    $Definition['May']='Mai';
    $Definition['Jun']='Juin';
    $Definition['Jul']='Juillet';
    $Definition['Aug']='Août';
    $Definition['Sep']='Septembre';
    $Definition['Oct']='Octobre';
    $Definition['Nov']='Novembre';
    $Definition['Dec']='Décembre';
    $Definition['EventCalendar.DateOrder']='day,month,year';
    $Definition['EventCalendar.DateFormat']='%A,%e%B%Y';
    $Definition['Calendarfor%B%Y']='%B%Y';
    $Definition['EventCalendar.SettingsTitle']='Paramètresdel\'agenda';
    $Definition['EventCalendar.SettingsDescription']='Lacréationd\'évènementspeutêtrecontrôléeparcatégorie<strong>et</strong>lespermissions.Vouspouvezchoisirunecatégorieici,maisn\'oubliezpasdeparamétrerlespermissionsdansles<ahref="/index.php?p=dashboard/role">permissionsstandard</a>dutableaudebord,sansquoilesutilisateursnepourrontutiliserlemodule.';
    


Sign In or Register to comment.