news-bundle/src/Resources/contao/modules/ModuleNewsMenu.php
protected function compileDailyMenu()
	{
		$arrData = array();
		$time = Date::floorToMinute();

		// Get the dates
		$objDates = $this->Database->query("SELECT FROM_UNIXTIME(date, '%Y%m%d') AS day, COUNT(*) AS count FROM tl_news WHERE pid IN(" . implode(',', array_map('\intval', $this->news_archives)) . ")" . ((!BE_USER_LOGGED_IN || TL_MODE == 'BE') ? " AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1'" : "") . " GROUP BY day ORDER BY day DESC");

		while ($objDates->next())
		{
			$arrData[$objDates->day] = $objDates->count;
		}

		// Sort the data
		krsort($arrData);

		// Create the date object
		try
		{
			$this->Date = Input::get('day') ? new Date(Input::get('day'), 'Ymd') : new Date();
		}
		catch (\OutOfBoundsException $e)
		{
			throw new PageNotFoundException('Page not found: ' . Environment::get('uri'));
		}

		$intYear = date('Y', $this->Date->tstamp);
		$intMonth = date('m', $this->Date->tstamp);

		$this->Template->intYear = $intYear;
		$this->Template->intMonth = $intMonth;

		// Previous month
		$prevMonth = ($intMonth == 1) ? 12 : ($intMonth - 1);
		$prevYear = ($intMonth == 1) ? ($intYear - 1) : $intYear;
		$lblPrevious = $GLOBALS['TL_LANG']['MONTHS'][($prevMonth - 1)] . ' ' . $prevYear;

		$this->Template->prevHref = $this->strUrl . '?day=' . $prevYear . ((\strlen($prevMonth) < 2) ? '0' : '') . $prevMonth . '01';
		$this->Template->prevTitle = StringUtil::specialchars($lblPrevious);
		$this->Template->prevLink = $GLOBALS['TL_LANG']['MSC']['news_previous'] . ' ' . $lblPrevious;
		$this->Template->prevLabel = $GLOBALS['TL_LANG']['MSC']['news_previous'];

		// Current month
		$this->Template->current = $GLOBALS['TL_LANG']['MONTHS'][(date('m', $this->Date->tstamp) - 1)] .  ' ' . date('Y', $this->Date->tstamp);

		// Next month
		$nextMonth = ($intMonth == 12) ? 1 : ($intMonth + 1);
		$nextYear = ($intMonth == 12) ? ($intYear + 1) : $intYear;
		$lblNext = $GLOBALS['TL_LANG']['MONTHS'][($nextMonth - 1)] . ' ' . $nextYear;

		$this->Template->nextHref = $this->strUrl . '?day=' . $nextYear . ((\strlen($nextMonth) < 2) ? '0' : '') . $nextMonth . '01';
		$this->Template->nextTitle = StringUtil::specialchars($lblNext);
		$this->Template->nextLink = $lblNext . ' ' . $GLOBALS['TL_LANG']['MSC']['news_next'];
		$this->Template->nextLabel = $GLOBALS['TL_LANG']['MSC']['news_next'];

		// Set week start day
		if (!$this->news_startDay)
		{
			$this->news_startDay = 0;
		}

		$this->Template->daily = true;
		$this->Template->days = $this->compileDays();
		$this->Template->weeks = $this->compileWeeks($arrData);
		$this->Template->showQuantity = ($this->news_showQuantity != '') ? true : false;
	}
protected function compileDailyMenu()
	{
		$arrData = array();
		$time = Date::floorToMinute();

		// Get the dates
		$objDates = $this->Database->query("SELECT FROM_UNIXTIME(date, '%Y%m%d') AS day, COUNT(*) AS count FROM tl_news WHERE pid IN(" . implode(',', array_map('\intval', $this->news_archives)) . ")" . ((!BE_USER_LOGGED_IN || TL_MODE == 'BE') ? " AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1'" : "") . " GROUP BY day ORDER BY day DESC");

		while ($objDates->next())
		{
			$arrData[$objDates->day] = $objDates->count;
		}

		// Sort the data
		krsort($arrData);

		// Create the date object
		try
		{
			$this->Date = Input::get('day') ? new Date(Input::get('day'), 'Ymd') : new Date();
		}
		catch (\OutOfBoundsException $e)
		{
			throw new PageNotFoundException('Page not found: ' . Environment::get('uri'));
		}

		$intYear = date('Y', $this->Date->tstamp);
		$intMonth = date('m', $this->Date->tstamp);

		$this->Template->intYear = $intYear;
		$this->Template->intMonth = $intMonth;

		// Previous month
		$prevMonth = ($intMonth == 1) ? 12 : ($intMonth - 1);
		$prevYear = ($intMonth == 1) ? ($intYear - 1) : $intYear;
		$lblPrevious = $GLOBALS['TL_LANG']['MONTHS'][($prevMonth - 1)] . ' ' . $prevYear;

		$this->Template->prevHref = $this->strUrl . '?day=' . $prevYear . ((\strlen($prevMonth) < 2) ? '0' : '') . $prevMonth . '01';
		$this->Template->prevTitle = StringUtil::specialchars($lblPrevious);
		$this->Template->prevLink = $GLOBALS['TL_LANG']['MSC']['news_previous'] . ' ' . $lblPrevious;
		$this->Template->prevLabel = $GLOBALS['TL_LANG']['MSC']['news_previous'];

		// Current month
		$this->Template->current = $GLOBALS['TL_LANG']['MONTHS'][(date('m', $this->Date->tstamp) - 1)] .  ' ' . date('Y', $this->Date->tstamp);

		// Next month
		$nextMonth = ($intMonth == 12) ? 1 : ($intMonth + 1);
		$nextYear = ($intMonth == 12) ? ($intYear + 1) : $intYear;
		$lblNext = $GLOBALS['TL_LANG']['MONTHS'][($nextMonth - 1)] . ' ' . $nextYear;

		$this->Template->nextHref = $this->strUrl . '?day=' . $nextYear . ((\strlen($nextMonth) < 2) ? '0' : '') . $nextMonth . '01';
		$this->Template->nextTitle = StringUtil::specialchars($lblNext);
		$this->Template->nextLink = $lblNext . ' ' . $GLOBALS['TL_LANG']['MSC']['news_next'];
		$this->Template->nextLabel = $GLOBALS['TL_LANG']['MSC']['news_next'];

		// Set week start day
		if (!$this->news_startDay)
		{
			$this->news_startDay = 0;
		}

		$this->Template->daily = true;
		$this->Template->days = $this->compileDays();
		$this->Template->weeks = $this->compileWeeks($arrData);
		$this->Template->showQuantity = ($this->news_showQuantity != '') ? true : false;
	}
protected function compileDailyMenu ( ) { $ arrData = array ( ) ; $ time = Date :: floorToMinute ( ) ; // Get the dates $ objDates = $ this -> Database -> query ( "SELECT FROM_UNIXTIME(date, '%Y%m%d') AS day, COUNT(*) AS count FROM tl_news WHERE pid IN(" . implode ( ',' , array_map ( '\intval' , $ this -> news_archives ) ) . ")" . ( ( ! BE_USER_LOGGED_IN || TL_MODE == 'BE' ) ? " AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ( $ time + 60 ) . "') AND published='1'" : "" ) . " GROUP BY day ORDER BY day DESC" ) ; while ( $ objDates -> next ( ) ) { $ arrData [ $ objDates -> day ] = $ objDates -> count ; } // Sort the data krsort ( $ arrData ) ; // Create the date object try { $ this -> Date = Input :: get ( 'day' ) ? new Date ( Input :: get ( 'day' ) , 'Ymd' ) : new Date ( ) ; } catch ( \ OutOfBoundsException $ e ) { throw new PageNotFoundException ( 'Page not found: ' . Environment :: get ( 'uri' ) ) ; } $ intYear = date ( 'Y' , $ this -> Date -> tstamp ) ; $ intMonth = date ( 'm' , $ this -> Date -> tstamp ) ; $ this -> Template -> intYear = $ intYear ; $ this -> Template -> intMonth = $ intMonth ; // Previous month $ prevMonth = ( $ intMonth == 1 ) ? 12 : ( $ intMonth - 1 ) ; $ prevYear = ( $ intMonth == 1 ) ? ( $ intYear - 1 ) : $ intYear ; $ lblPrevious = $ GLOBALS [ 'TL_LANG' ] [ 'MONTHS' ] [ ( $ prevMonth - 1 ) ] . ' ' . $ prevYear ; $ this -> Template -> prevHref = $ this -> strUrl . '?day=' . $ prevYear . ( ( \ strlen ( $ prevMonth ) < 2 ) ? '0' : '' ) . $ prevMonth . '01' ; $ this -> Template -> prevTitle = StringUtil :: specialchars ( $ lblPrevious ) ; $ this -> Template -> prevLink = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'news_previous' ] . ' ' . $ lblPrevious ; $ this -> Template -> prevLabel = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'news_previous' ] ; // Current month $ this -> Template -> current = $ GLOBALS [ 'TL_LANG' ] [ 'MONTHS' ] [ ( date ( 'm' , $ this -> Date -> tstamp ) - 1 ) ] . ' ' . date ( 'Y' , $ this -> Date -> tstamp ) ; // Next month $ nextMonth = ( $ intMonth == 12 ) ? 1 : ( $ intMonth + 1 ) ; $ nextYear = ( $ intMonth == 12 ) ? ( $ intYear + 1 ) : $ intYear ; $ lblNext = $ GLOBALS [ 'TL_LANG' ] [ 'MONTHS' ] [ ( $ nextMonth - 1 ) ] . ' ' . $ nextYear ; $ this -> Template -> nextHref = $ this -> strUrl . '?day=' . $ nextYear . ( ( \ strlen ( $ nextMonth ) < 2 ) ? '0' : '' ) . $ nextMonth . '01' ; $ this -> Template -> nextTitle = StringUtil :: specialchars ( $ lblNext ) ; $ this -> Template -> nextLink = $ lblNext . ' ' . $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'news_next' ] ; $ this -> Template -> nextLabel = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'news_next' ] ; // Set week start day if ( ! $ this -> news_startDay ) { $ this -> news_startDay = 0 ; } $ this -> Template -> daily = true ; $ this -> Template -> days = $ this -> compileDays ( ) ; $ this -> Template -> weeks = $ this -> compileWeeks ( $ arrData ) ; $ this -> Template -> showQuantity = ( $ this -> news_showQuantity != '' ) ? true : false ; }
Generate the dayil menu
Generate the dayil menu