/** * generates the News archive menu * * @return string html code of the archive menu */ function displayArchiveMenu() { if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__ . ' start'); } $this->arcExclusive = 1; $selectConf = $this->getSelectConf('', 1); $selectConf['where'] .= $this->enableFields; // Finding maximum and minimum values: $row = $this->getArchiveMenuRange($selectConf); if ($row['minval'] || $row['maxval']) { // if ($row['minval']) { $dateArr = array(); $arcMode = $this->config['archiveMode']; $c = 0; $theDate = 0; while ($theDate < $row['maxval']) { switch ($arcMode) { case 'month': $theDate = mktime(0, 0, 0, date('m', $row['minval']) + $c, 1, date('Y', $row['minval'])); break; case 'quarter': $theDate = mktime(0, 0, 0, floor(date('m', $row['minval']) / 3) + 1 + 3 * $c, 1, date('Y', $row['minval'])); break; case 'year': $theDate = mktime(0, 0, 0, 1, 1, date('Y', $row['minval']) + $c); break; } $dateArr[] = $theDate; $c++; if ($c > 1000) { break; } } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__ . ' $dateArr'); } // $selectConf['where'] .= $this->enableFields; if ($selectConf['pidInList']) { $selectConf['where'] .= ' AND tt_news.pid IN (' . $selectConf['pidInList'] . ')'; } $tmpWhere = $selectConf['where']; $cachedPeriodAccum = FALSE; $storeKey = FALSE; if ($this->cache_amenuPeriods) { $storeKey = md5(serialize(array($this->catExclusive, $this->config['catSelection'], $this->tsfe->sys_language_content, $selectConf['pidInList'], $arcMode))); // $cachedPeriodAccum = $this->tsfe->sys_page->getHash($storeKey); $cachedPeriodAccum = $this->cache->get($storeKey); } if ($cachedPeriodAccum != '') { if ($this->writeCachingInfoToDevlog > 1) { t3lib_div::devLog('CACHE HIT (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', -1, array()); } $periodAccum = unserialize($cachedPeriodAccum); } else { $periodAccum = array(); foreach ($dateArr as $k => $v) { $periodInfo = array(); $periodInfo['start'] = $v; $periodInfo['active'] = $this->piVars['pS'] == $v ? 1 : 0; $periodInfo['stop'] = $dateArr[$k + 1] - 1; $periodInfo['HRstart'] = date('d-m-Y', $periodInfo['start']); $periodInfo['HRstop'] = date('d-m-Y', $periodInfo['stop']); $periodInfo['quarter'] = floor(date('m', $v) / 3) + 1; $select_fields = 'COUNT(DISTINCT tt_news.uid)'; $from_table = 'tt_news'; $join = $selectConf['leftjoin'] ? ' LEFT JOIN ' . $selectConf['leftjoin'] : ''; $where_clause = $tmpWhere . ' AND tt_news.datetime>=' . $periodInfo['start'] . ' AND tt_news.datetime<' . $periodInfo['stop']; $res = $this->db->exec_SELECTquery($select_fields, $from_table . $join, $where_clause); $row = $this->db->sql_fetch_row($res); $this->db->sql_free_result($res); $periodInfo['count'] = $row[0]; if (!$this->conf['archiveMenuNoEmpty'] || $periodInfo['count']) { $periodAccum[] = $periodInfo; } } if ($this->cache_amenuPeriods && count($periodAccum)) { if ($this->writeCachingInfoToDevlog) { t3lib_div::devLog('CACHE MISS (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', 2, array()); } // $this->tsfe->sys_page->storeHash($storeKey, serialize($periodAccum), 'news_amenuPeriodsCache'); $this->cache->set($storeKey, serialize($periodAccum), __FUNCTION__); } } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__ . ' periodAccum'); } // get template subpart $t['total'] = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_ARCHIVE###')); $t['item'] = $this->getLayouts($t['total'], $this->alternatingLayouts, 'MENUITEM'); $renderMarkers = $this->getMarkers($t['total']); $this->renderMarkers = array_unique($renderMarkers); $tCount = count($t['item']); $cc = 0; $veryLocal_cObj = t3lib_div::makeInstance('tslib_cObj'); // reverse amenu order if 'reverseAMenu' is given if ($this->conf['reverseAMenu']) { arsort($periodAccum); } $archiveLink = $this->conf['archiveTypoLink.']['parameter']; $archiveLink = $archiveLink ? $archiveLink : $this->tsfe->id; $this->conf['parent.']['addParams'] = $this->conf['archiveTypoLink.']['addParams']; $amenuLinkCat = null; if (!$this->conf['disableCategoriesInAmenuLinks']) { if ($this->piVars_catSelection && $this->config['amenuWithCatSelector']) { // use the catSelection from piVars only if 'amenuWithCatSelector' is given. $amenuLinkCat = $this->piVars_catSelection; } else { $amenuLinkCat = $this->actuallySelectedCategories; } } $itemsOutArr = array(); $oldyear = 0; $itemsOut = ''; foreach ($periodAccum as $pArr) { $wrappedSubpartArray = array(); $markerArray = array(); $year = date('Y', $pArr['start']); if ($this->conf['useHRDates']) { $month = date('m', $pArr['start']); if ($arcMode == 'year') { $archLinkArr = $this->pi_linkTP_keepPIvars('|', array('cat' => $amenuLinkCat, 'year' => $year), $this->allowCaching, 1, $archiveLink); } else { $archLinkArr = $this->pi_linkTP_keepPIvars('|', array('cat' => $amenuLinkCat, 'year' => $year, 'month' => $month), $this->allowCaching, 1, $archiveLink); } $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $archLinkArr); } else { $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array('cat' => $amenuLinkCat, 'pS' => $pArr['start'], 'pL' => $pArr['stop'] - $pArr['start'], 'arc' => 1), $this->allowCaching, 1, $archiveLink)); } $yearTitle = ''; if ($this->conf['showYearHeadersInAmenu'] && $arcMode != 'year') { if ($year != $oldyear) { if ($pArr['start'] < 20000) { $yearTitle = 'no date'; } else { $yearTitle = $year; } $oldyear = $year; } } $veryLocal_cObj->start($pArr, 'tt_news'); $markerArray['###ARCHIVE_YEAR###'] = ''; if ($yearTitle) { $markerArray['###ARCHIVE_YEAR###'] = $veryLocal_cObj->stdWrap($yearTitle, $this->conf['archiveYear_stdWrap.']); } $markerArray['###ARCHIVE_TITLE###'] = $veryLocal_cObj->cObjGetSingle($this->conf['archiveTitleCObject'], $this->conf['archiveTitleCObject.'], 'archiveTitleCObject'); $markerArray['###ARCHIVE_COUNT###'] = $pArr['count']; $markerArray['###ARCHIVE_ITEMS###'] = $pArr['count'] == 1 ? $this->pi_getLL('archiveItem') : $this->pi_getLL('archiveItems'); $markerArray['###ARCHIVE_ACTIVE###'] = $this->piVars['pS'] == $pArr['start'] ? $this->conf['archiveActiveMarkerContent'] : ''; $layoutNum = $tCount == 0 ? 0 : $cc % $tCount; $amenuitem = $this->cObj->substituteMarkerArrayCached($t['item'][$layoutNum], $markerArray, array(), $wrappedSubpartArray); if ($this->conf['newsAmenuUserFunc']) { // fill the generated data to an array to pass it to a userfuction as a single variable $itemsOutArr[] = array('html' => $amenuitem, 'data' => $pArr); } else { $itemsOut .= $amenuitem; } $cc++; } // Pass to user defined function if ($this->conf['newsAmenuUserFunc']) { $tmpItemsArr = FALSE; $itemsOutArr = $this->userProcess('newsAmenuUserFunc', $itemsOutArr); foreach ($itemsOutArr as $itemHtml) { $tmpItemsArr[] = $itemHtml['html']; } if (is_array($tmpItemsArr)) { $itemsOut = implode('', $tmpItemsArr); } } // Reset: $subpartArray = array(); $wrappedSubpartArray = array(); $markerArray = array(); $markerArray['###ARCHIVE_HEADER###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveHeader'), $this->conf['archiveHeader_stdWrap.']); // Set content $subpartArray['###CONTENT###'] = $itemsOut; $content = $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray, $wrappedSubpartArray); } else { // if nothing is found in the archive display the TEMPLATE_ARCHIVE_NOITEMS message $markerArray['###ARCHIVE_HEADER###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveHeader'), $this->conf['archiveHeader_stdWrap.']); $markerArray['###ARCHIVE_EMPTY_MSG###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveEmptyMsg'), $this->conf['archiveEmptyMsg_stdWrap.']); $noItemsMsg = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_ARCHIVE_NOITEMS###')); $content = $this->cObj->substituteMarkerArrayCached($noItemsMsg, $markerArray); } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__); } return $content; }