Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

cb_newscal & eventnews - End of Year and End of Month #14

Open
bechtlepri opened this issue Feb 14, 2017 · 0 comments
Open

cb_newscal & eventnews - End of Year and End of Month #14

bechtlepri opened this issue Feb 14, 2017 · 0 comments

Comments

@bechtlepri
Copy link

bechtlepri commented Feb 14, 2017

Hey, thanks for the extension.

We are using EXT:eventnews v1.1.1
cb_newscal won't show the end of the event if its exceeding a month/year.

For example:
Create an event (news-entry with isEvent==TRUE) from 23th February 2017 until 5th March 2017 - now the event will stop (not end) on February 28, even though the calendar shows the day.
Don't know if that's wanted to happen - but since you see the day in February...
Also you can't see the event from March 1 to March 5 because the actual entry is in February.

Attached is a sample how I fixed it manually to at least show entrys beginning in the last month and the last year when jumping DEC->JAN.

File: /cb_newscal/Classes/Controller/NewsController.php
Class: NewsController
Function: getEventsOfDay

Edit: 18. September 2017: I updated the example code because after a recent update to TYPO3 LTS 7 with PHP 7 the code failed. Only change: I added a if(!empty(...)) check in front of the foreach loops. Still works with PHP 7, LTS 7

protected function getEventsOfDay($demand, &$day)
   {
        if (!isset($this->events[$day['year']]))
            $this->events[$day['year']] = array();
        if (!isset($this->events[$day['year']][$day['month']]))
        {
            // # BEGIN CHANGES 4. JANUARY 2017 - Problem with DEC/JAN
            // # BEGIN CHANGES 14. FEBRUARY 2017 - Problem with MONTH-End
            `
            // January - We check last Month, too (Year-1 and Month = 12)
            if ($day['month'] == 1) 
            {
                $demand->setYear($day['year']-1);
                $demand->setMonth(12); 
                $eventsPlus1 = $this->newsRepository->findDemanded($demand);
            }
            
            // Next Month - We check the last Month, too (Month-1 and Day = 1-31)
            $demand->setMonth($day['month']-1); 
            $eventsPlus2 = $this->newsRepository->findDemanded($demand);

            
            // Current Year + Month - These 3 lines were before the changes, rest is new!
            $demand->setYear($day['year']);
            $demand->setMonth($day['month']);
            $this->events[$day['year']][$day['month']] = $this->newsRepository->findDemanded($demand);
            
            
            // Merging - Adding the Plusevents1 to the array:
            if (!empty($eventsPlus1))
            {
                foreach ($eventsPlus1 as $k => $event)
                {
                    $this->events[$day['year']][$day['month']][] = $event;
                }
            }
            
            // Merging - Adding the Plusevents2 to the array:
            if (!empty($eventsPlus2))
            {
                foreach ($eventsPlus2 as $k => $event)
                {
                    $this->events[$day['year']][$day['month']][] = $event;
                }
            }

            // Debugging:
            //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($eventsPlus, 'January - We check last Month also(Year-1,Month = 12)');
            //\TYPO3\CMS\Core\Utility\DebugUtility::debug($day['cd']);
            //$debug = [ "EVENT->TITLE" => $event->getTitle(),
            //           "DAY" => $day['cd'],
            //           "DEMAND->DATEFIELD" => $demand->getDateField(),
            //           "EVENT->DATETIME" => $event->getDatetime(),
            //           "EVENT->EVENTEND" => $event->getEventEnd(),
            //         ];
            //\TYPO3\CMS\Core\Utility\DebugUtility::debug("++");

            //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($debug, 'DEBUG');
            
            // # END CHANGES 14. FEBRUARY 2017 - Problem with MONTH-End
            // # END CHANGES 4. JANUARY 2017 - Problem with DEC/JAN            
        }

        $day['startev'] = True;
        $day['endev'] = True;
        $day['news'] = array();
        
        ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant