From d189752d0ee9d6a3d8b2e3c4de72d97cdc83cda6 Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Fri, 19 Dec 2014 16:27:10 +0100 Subject: [PATCH] handle years, months, and day ORDERLABEL --- .../class.tx_dfgviewer_newspaper-calendar.php | 22 ++++++++++++++----- .../class.tx_dfgviewer_newspaper-years.php | 20 +++++++++++++---- .../plugins/uri/class.tx_dfgviewer_uri.php | 4 ++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/dfgviewer/plugins/newspaper-calendar/class.tx_dfgviewer_newspaper-calendar.php b/dfgviewer/plugins/newspaper-calendar/class.tx_dfgviewer_newspaper-calendar.php index 4435af9a6..48a6aaca5 100644 --- a/dfgviewer/plugins/newspaper-calendar/class.tx_dfgviewer_newspaper-calendar.php +++ b/dfgviewer/plugins/newspaper-calendar/class.tx_dfgviewer_newspaper-calendar.php @@ -71,8 +71,14 @@ public function main($content, $conf) { //~ t3lib_utility_Debug::debug($toc, 'tx_dfgviewer_newspaperyear: conf... '); foreach($toc[0]['children'][0]['children'] as $id => $mo) { - $month[$mo['label']] = $id; + + // prefer oderlabel over label + $monthNum = isset($mo['orderlabel']) ? (int)$mo['orderlabel'] : $mo['label']; + + $month[$monthNum] = $id; + $allIssuesCount += count($mo['children']); + } // Load template file. @@ -90,7 +96,6 @@ public function main($content, $conf) { $subparts['template'] = $this->template; $subparts['month'] = $this->cObj->getSubpart($subparts['template'], '###CALMONTH###'); - //~ $subparts['issuelist'] = $this->cObj->getSubpart($subparts['template'], '###ISSUELIST###'); $subparts['singleissue'] = $this->cObj->getSubpart($subparts['issuelist'], '###SINGLEISSUE###'); $year = (int)$toc[0]['children'][0]['label']; @@ -145,18 +150,23 @@ public function main($content, $conf) { $dayLinks = ''; $dayLinksText = ''; - $currentMonth = strftime('%m', $currentDayTime); + $currentMonth = date('n', $currentDayTime); foreach($toc[0]['children'][0]['children'][$month[$currentMonth]]['children'] as $id => $day) { - if ((int)$day['label'] === (int)date('j', $currentDayTime) + // prefer oderlabel over label + $dayNum = isset($day['orderlabel']) ? (int)$day['orderlabel'] : $day['label']; + + if ($dayNum === (int)date('j', $currentDayTime) && $day['type'] === 'day') { - $dayLinks = $day['label']; + $dayLinks = $dayNum; foreach($day['children'] as $id => $issue) { + $dayPoints = $issue['points']; - $dayLinkLabel = $issue['label']; + + $dayLinkLabel = empty($issue['label']) ? strftime('%x', $currentDayTime) : $issue['label']; $linkConf = array ( 'useCacheHash' => 1, diff --git a/dfgviewer/plugins/newspaper-years/class.tx_dfgviewer_newspaper-years.php b/dfgviewer/plugins/newspaper-years/class.tx_dfgviewer_newspaper-years.php index e9359674f..9cb414fe7 100644 --- a/dfgviewer/plugins/newspaper-years/class.tx_dfgviewer_newspaper-years.php +++ b/dfgviewer/plugins/newspaper-years/class.tx_dfgviewer_newspaper-years.php @@ -92,17 +92,29 @@ public function main($content, $conf) { foreach($years as $id => $year) { + $yearLabel = empty($year['label']) ? $year['orderlabel'] : $year['label']; + + if (empty($yearLabel)) { + + // if neither order nor orderlabel is set, use the id... + $yearLabel = (string)$id; + + } if (strlen($year['points']) > 0) { $linkConf = array ( 'useCacheHash' => 1, 'parameter' => $this->conf['targetPid'], 'additionalParams' => '&' . $this->prefixId . '[id]=' . urlencode($year['points']), - 'title' => $year['label'] + 'title' => $yearLabel ); - $yearText = $this->cObj->typoLink($year['label'], $linkConf); - } else - $yearText = $year['label']; + $yearText = $this->cObj->typoLink($yearLabel, $linkConf); + + } else { + + $yearText = $yearLabel; + + } $yearArray = array( '###YEARNAME###' => $yearText, diff --git a/dfgviewer/plugins/uri/class.tx_dfgviewer_uri.php b/dfgviewer/plugins/uri/class.tx_dfgviewer_uri.php index 97168bc47..63a66662b 100644 --- a/dfgviewer/plugins/uri/class.tx_dfgviewer_uri.php +++ b/dfgviewer/plugins/uri/class.tx_dfgviewer_uri.php @@ -67,9 +67,9 @@ public function main($content, $conf) { // Set default values if not set. // page may be integer or string (pyhsical page attribute) - if (tx_dlf_helper::testInt($this->piVars['page']) || empty($this->piVars['page'])) { + if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { - $this->piVars['page'] = tx_dlf_helper::intInRange($this->piVars['page'], 1, $this->doc->numPages, 1); + $this->piVars['page'] = tx_dlf_helper::intInRange((int)$this->piVars['page'], 1, $this->doc->numPages, 1); } else {