diff --git a/dlf/common/class.tx_dlf_document.php b/dlf/common/class.tx_dlf_document.php index 0953d2eba..2767b376a 100644 --- a/dlf/common/class.tx_dlf_document.php +++ b/dlf/common/class.tx_dlf_document.php @@ -115,6 +115,14 @@ final class tx_dlf_document { */ protected $hasFulltext = FALSE; + /** + * Last searched logical and physical page + * + * @var array + * @access protected + */ + protected $lastSearchedPhysicalPage = array ('logicalPage' => NULL, 'physicalPage' => NULL); + /** * This holds the documents location * @@ -898,6 +906,46 @@ public function getMetadata($id, $cPid = 0) { } + /** + * This returns the first corresponding physical page number of a given logical page label + * + * @access public + * + * @param string $logicalPage: The label (or a part of the label) of the logical page + * + * @return integer The physical page number + */ + public function getPhysicalPage($logicalPage) { + + if(!empty( $this->lastSearchedPhysicalPage['logicalPage']) && $this->lastPhysicalPageSearch['logicalPage'] == $logicalPage) { + + return $this->lastSearchedPhysicalPage['physicalPage']; + + } else { + + $physicalPage = 0; + + foreach($this->physicalStructureInfo as $page) { + + if(strpos($page['orderlabel'], $logicalPage) !== false){ + + $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; + $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; + + return $physicalPage; + + } + + $physicalPage++; + + } + + } + + return 1; + + } + /** * This determines a title for the given document * diff --git a/dlf/plugins/listview/class.tx_dlf_listview.php b/dlf/plugins/listview/class.tx_dlf_listview.php index e633d5648..27a37b3c9 100644 --- a/dlf/plugins/listview/class.tx_dlf_listview.php +++ b/dlf/plugins/listview/class.tx_dlf_listview.php @@ -193,6 +193,12 @@ protected function getEntry($number, $template) { 'page' => $this->list[$number]['page'] ); + if(!empty($this->piVars['logicalPage'])) { + + $additionalParams['logicalPage'] = $this->piVars['logicalPage']; + + } + $conf = array ( 'useCacheHash' => 1, 'parameter' => $this->conf['targetPid'], @@ -312,6 +318,12 @@ protected function getSortingForm() { 'forceAbsoluteUrl' => 1 ); + if(!empty($this->piVars['logicalPage'])) { + + $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId,array('logicalPage' => $this->piVars['logicalPage']), '', TRUE, FALSE); + + } + // Build HTML form. $sorting = '
'; @@ -425,6 +437,12 @@ protected function getSubEntries($number, $template) { 'highlight_word' => preg_replace('/\s\s+/', ';', $this->list->metadata['searchString']) ); + if(!empty($this->piVars['logicalPage'])) { + + $additionalParams['logicalPage'] = $this->piVars['logicalPage']; + + } + $conf = array ( // we don't want cHash in case of search parameters 'useCacheHash' => empty($this->list->metadata['searchString']) ? 1 : 0, diff --git a/dlf/plugins/navigation/class.tx_dlf_navigation.php b/dlf/plugins/navigation/class.tx_dlf_navigation.php index 8b77c2442..455aafff1 100644 --- a/dlf/plugins/navigation/class.tx_dlf_navigation.php +++ b/dlf/plugins/navigation/class.tx_dlf_navigation.php @@ -129,6 +129,14 @@ public function main($content, $conf) { // Set default values if not set. if ($this->doc->numPages > 0) { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear + unset($this->piVars['logicalPage']); + + } + // Set default values if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php b/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php index cf07bf0c3..960659716 100644 --- a/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php +++ b/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php @@ -223,6 +223,14 @@ public function main($content, $conf) { } + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear + unset($this->piVars['logicalPage']); + + } + // Set some variable defaults. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/pageview/class.tx_dlf_pageview.php b/dlf/plugins/pageview/class.tx_dlf_pageview.php index a744b28cd..f6147a2d6 100644 --- a/dlf/plugins/pageview/class.tx_dlf_pageview.php +++ b/dlf/plugins/pageview/class.tx_dlf_pageview.php @@ -342,6 +342,14 @@ public function main($content, $conf) { } else { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear again + unset($this->piVars['logicalPage']); + + } + // Set default values if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/search/class.tx_dlf_search.php b/dlf/plugins/search/class.tx_dlf_search.php index 445621687..e4b0de6ba 100644 --- a/dlf/plugins/search/class.tx_dlf_search.php +++ b/dlf/plugins/search/class.tx_dlf_search.php @@ -316,6 +316,30 @@ protected function addFulltextSwitch($isFulltextSearch = 0) { } + /** + * Adds the logical page field to the search form + * + * @access protected + * + * @return string HTML output of logical page field + */ + protected function addLogicalPage() { + + $output = ''; + + // Check for plugin configuration. + if (!empty($this->conf['showLogicalPageField'])) { + + $output .= ' '; + + $output .= ' '; + + } + + return $output; + + } + /** * Creates an array for a HMENU entry of a facet value. * @@ -482,7 +506,8 @@ public function main($content, $conf) { '###FIELD_DOC###' => ($this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all' ? $this->addCurrentDocument() : ''), '###FIELD_COLL###' => ($this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all' ? $this->addCurrentCollection() : ''), '###ADDITIONAL_INPUTS###' => $this->addEncryptedCoreName(), - '###FACETS_MENU###' => $this->addFacetsMenu() + '###FACETS_MENU###' => $this->addFacetsMenu(), + '###LOGICAL_PAGE###' => $this->addLogicalPage() ); // Get additional fields for extended search. @@ -654,17 +679,22 @@ public function main($content, $conf) { // Clean output buffer. \TYPO3\CMS\Core\Utility\GeneralUtility::cleanOutputBuffers(); + $additionalParams = array(); + + if(!empty($this->piVars['logicalPage'])) { + + $additionalParams['logicalPage'] = $this->piVars['logicalPage']; + + } + // Jump directly to the page view, if there is only one result and it is configured if($results->count() == 1 && !empty($this->conf['showSingleResult'])) { $linkConf['parameter'] = $this->conf['targetPidPageView']; - $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, - array ( - 'id' => $results->current()['uid'], - 'highlight_word' => preg_replace('/\s\s+/', ';', $results->metadata['searchString']), - 'page' => count($results[0]['subparts']) == 1?$results[0]['subparts'][0]['page']:1 - ), '', TRUE, FALSE); + $additionalParams['id'] = $results->current()['uid']; + $additionalParams['highlight_word'] = preg_replace('/\s\s+/', ';', $results->metadata['searchString']); + $additionalParams['page'] = count($results[0]['subparts']) == 1?$results[0]['subparts'][0]['page']:1; } else { @@ -673,16 +703,15 @@ public function main($content, $conf) { if (!empty($this->piVars['order'])) { - $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, - array ( - 'order' => $this->piVars['order'], - 'asc' => (!empty($this->piVars['asc']) ? '1' : '0') - ), '', TRUE, FALSE); + $additionalParams['order'] = $this->piVars['order']; + $additionalParams['asc'] = !empty($this->piVars['asc']) ? '1' : '0'; } } + $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE); + // Send headers. header('Location: '.\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->cObj->typoLink_URL($linkConf))); diff --git a/dlf/plugins/search/flexform.xml b/dlf/plugins/search/flexform.xml index 900165015..8bc2ac13f 100644 --- a/dlf/plugins/search/flexform.xml +++ b/dlf/plugins/search/flexform.xml @@ -220,6 +220,16 @@ + + + 1 + + + check + 0 + + + reload diff --git a/dlf/plugins/search/locallang.xml b/dlf/plugins/search/locallang.xml index fa9af507b..b720384d0 100644 --- a/dlf/plugins/search/locallang.xml +++ b/dlf/plugins/search/locallang.xml @@ -37,11 +37,13 @@ + + @@ -74,11 +76,13 @@ + + diff --git a/dlf/plugins/search/template.tmpl b/dlf/plugins/search/template.tmpl index 19c03f51e..7ac449ceb 100644 --- a/dlf/plugins/search/template.tmpl +++ b/dlf/plugins/search/template.tmpl @@ -12,6 +12,7 @@ + ###LOGICAL_PAGE###
diff --git a/dlf/plugins/toc/class.tx_dlf_toc.php b/dlf/plugins/toc/class.tx_dlf_toc.php index 012add2f7..d1f1ff5b9 100644 --- a/dlf/plugins/toc/class.tx_dlf_toc.php +++ b/dlf/plugins/toc/class.tx_dlf_toc.php @@ -220,6 +220,14 @@ public function makeMenuArray($content, $conf) { } else { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear again + unset($this->piVars['logicalPage']); + + } + // Set default values for page if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php b/dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php index 1d05b209a..7d71bd15f 100644 --- a/dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php +++ b/dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php @@ -49,6 +49,14 @@ public function main($content, $conf) { } else { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear again + unset($this->piVars['logicalPage']); + + } + // Set default values if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php b/dlf/plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php index fd26a7d33..a1827143b 100644 --- a/dlf/plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php +++ b/dlf/plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php @@ -48,6 +48,14 @@ public function main($content, $conf) { } else { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear again + unset($this->piVars['logicalPage']); + + } + // Set default values if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { diff --git a/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php b/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php index 4f9b50b4f..7920935a6 100644 --- a/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php +++ b/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php @@ -49,6 +49,14 @@ public function main($content, $conf) { } else { + if (!empty($this->piVars['logicalPage'])) { + + $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); + // The logical page parameter should not appear again + unset($this->piVars['logicalPage']); + + } + // Set default values if not set. // $this->piVars['page'] may be integer or string (physical structure @ID) if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) {