protected function runBeforeTemplateParsing($objTemplate, $arrItem)
 {
     $objTemplate->ago = DateUtil::getTimeElapsed($arrItem['raw']['date']);
     $objTemplate->commentCount = \CommentsModel::countPublishedBySourceAndParent('tl_news', $arrItem['fields']['id']);
     $objTemplate->isAuthor = $arrItem['raw']['memberAuthor'] == \FrontendUser::getInstance()->id;
     $this->imgSize = deserialize($this->imgSize, true);
     if ($objTemplate->isAuthor && !$arrItem['raw']['published']) {
         $objTemplate->unpublished = true;
     }
     // media
     $strMedia = '';
     if ($arrItem['raw']['mediaType'] == 'video') {
         $arrItem['fields']['addYouTube'] = true;
         $arrItem['fields']['youtube'] = preg_replace('@.*watch\\?v=([^&]+).*@i', '$1', $arrItem['fields']['pinBoardYouTube']);
         $objYouTube = YouTubeVideo::getInstance()->setData($arrItem['fields']);
         $strMedia = $objYouTube->getCachedYouTubePreviewImage();
     } elseif ($arrItem['fields']['pinBoardImage']) {
         $strMedia = $arrItem['fields']['pinBoardImage'];
     }
     if ($strMedia) {
         $objTemplate->media = \Image::get($strMedia, $this->imgSize[0], $this->imgSize[1], $this->imgSize[2]);
         $arrSize = getimagesize(urldecode(TL_ROOT . '/' . $objTemplate->media));
         if (count($arrSize) > 1) {
             $objTemplate->imgSizeParsed = 'width="' . $arrSize[0] . '" height="' . $arrSize[1] . '"';
         }
     }
 }
 public static function shareTokenExpiredOrEmpty($objEntity, $intNow)
 {
     $strShareToken = $objEntity->shareToken;
     $arrExpirationInterval = deserialize(\Config::get('shareExpirationInterval'), true);
     $intInterval = 604800;
     // default: 7 days
     if (isset($arrExpirationInterval['unit']) && isset($arrExpirationInterval['value']) && $arrExpirationInterval['value'] > 0) {
         $intInterval = DateUtil::getTimePeriodInSeconds($arrExpirationInterval);
     }
     return !$strShareToken || !$objEntity->shareTokenTime || $objEntity->shareTokenTime > $intNow + $intInterval;
 }
 /**
  * Returns the event title concatenated with its date/time
  * @param $varEvent object|int The event id or the event object itself
  */
 public static function getDateTimeFormattedEvent($varEvent, $blnSeparatedDateTime = true, $strFormat = '%s (%s)')
 {
     $objEvent = $varEvent;
     if (is_numeric($varEvent)) {
         if (($objEvent = \CalendarEventsModel::findByPk($varEvent)) === null) {
             return '';
         }
     }
     $strDateTime = DateUtil::getFormattedDateTime($objEvent, $blnSeparatedDateTime);
     return sprintf($strFormat, $objEvent->title, $strDateTime);
 }
 public function addEventTokens($objItem, $arrTokens, $arrRelation, $objNotification, $strLanguage, $objGatewayModel)
 {
     // date and time
     $arrTokens['event_date'] = DateUtil::getNumericDateInterval($objItem->startDate, $objItem->endDate);
     if ($objItem->addTime) {
         $arrTokens['event_datime'] = DateUtil::getNumericDateTimeInterval($objItem->startTime, $objItem->endTime);
     } else {
         $arrTokens['event_datime'] = $arrTokens['event_date'];
     }
     return $arrTokens;
 }
 /**
  * @param              $strTable
  * @param \Module|null $objModule
  *
  * @return null|int Returns the lock interval in seconds or false if no interval is set
  */
 public static function getLockIntervalInSeconds($strTable, \Module $objModule = null)
 {
     $arrLocks = array();
     if ($objModule !== null && $objModule->addEntityLock && $objModule->overrideLockIntervals) {
         $arrLocks = deserialize($objModule->lockIntervals, true);
     } else {
         if (\Config::get('addLockIntervals')) {
             $arrLocks = deserialize(\Config::get('lockIntervals'), true);
         }
     }
     if (!empty($arrLocks)) {
         foreach ($arrLocks as $arrLock) {
             if ($arrLock['table'] == $strTable) {
                 return DateUtil::getTimePeriodInSeconds($arrLock['interval']);
             }
         }
     }
     return null;
 }
 /**
  * @dataProvider getSeparatedNumericDateTimeIntervalProvider
  * @test
  */
 public function testGetSeparatedNumericDateTimeInterval($intStartDate = null, $intEndDate = null, $intStartTime = null, $intEndTime = null, $strIntervalDelimiter = ' – ', $strDelimiter = ' , ', $varExpectedResult)
 {
     $this->assertSame($varExpectedResult, DateUtil::getSeparatedNumericDateTimeInterval($intStartDate, $intEndDate, $intStartTime, $intEndTime, $strIntervalDelimiter, $strDelimiter));
 }