Merge lp:~henrik-lochmann/goobi-presentation/bug-802839 into lp:~slub.team/goobi-presentation/old-bzr-trunk

Proposed by Henrik Lochmann
Status: Merged
Approved by: Sebastian Meyer
Approved revision: 124
Merged at revision: 125
Proposed branch: lp:~henrik-lochmann/goobi-presentation/bug-802839
Merge into: lp:~slub.team/goobi-presentation/old-bzr-trunk
Diff against target: 463 lines (+388/-0)
8 files modified
dlf/ext_autoload.php (+1/-0)
dlf/ext_localconf.php (+2/-0)
dlf/ext_tables.php (+9/-0)
dlf/locallang.xml (+2/-0)
dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php (+252/-0)
dlf/plugins/pagegrid/flexform.xml (+72/-0)
dlf/plugins/pagegrid/locallang.xml (+33/-0)
dlf/plugins/pagegrid/template.tmpl (+17/-0)
To merge this branch: bzr merge lp:~henrik-lochmann/goobi-presentation/bug-802839
Reviewer Review Type Date Requested Status
Sebastian Meyer Approve
Review via email: mp+126250@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sebastian Meyer (sebastian-meyer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dlf/ext_autoload.php'
--- dlf/ext_autoload.php 2012-08-22 19:22:29 +0000
+++ dlf/ext_autoload.php 2012-09-25 14:14:21 +0000
@@ -47,6 +47,7 @@
47 'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php',47 'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php',
48 'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php',48 'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php',
49 'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',49 'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',
50 'tx_dlf_pagegrid' => $extensionPath.'plugins/pagegrid/class.tx_dlf_pagegrid.php',
50 'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php',51 'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php',
51 'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php',52 'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php',
52 'tx_dlf_search_suggest' => $extensionPath.'plugins/search/class.tx_dlf_search_suggest.php',53 'tx_dlf_search_suggest' => $extensionPath.'plugins/search/class.tx_dlf_search_suggest.php',
5354
=== modified file 'dlf/ext_localconf.php'
--- dlf/ext_localconf.php 2012-08-22 19:22:29 +0000
+++ dlf/ext_localconf.php 2012-09-25 14:14:21 +0000
@@ -37,6 +37,8 @@
3737
38t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/oai/class.tx_dlf_oai.php', '_oai', 'list_type', FALSE);38t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/oai/class.tx_dlf_oai.php', '_oai', 'list_type', FALSE);
3939
40t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pagegrid/class.tx_dlf_pagegrid.php', '_pagegrid', 'list_type', TRUE);
41
40t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php', '_pageview', 'list_type', TRUE);42t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php', '_pageview', 'list_type', TRUE);
4143
42t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE);44t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE);
4345
=== modified file 'dlf/ext_tables.php'
--- dlf/ext_tables.php 2012-09-15 16:05:08 +0000
+++ dlf/ext_tables.php 2012-09-25 14:14:21 +0000
@@ -276,6 +276,15 @@
276t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_oai', $_EXTKEY.'_oai'), 'list_type');276t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_oai', $_EXTKEY.'_oai'), 'list_type');
277277
278t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_oai', 'FILE:EXT:'.$_EXTKEY.'/plugins/oai/flexform.xml');278t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_oai', 'FILE:EXT:'.$_EXTKEY.'/plugins/oai/flexform.xml');
279
280// Plugin "pagegrid".
281$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pagegrid'] = 'layout,select_key,pages,recursive';
282
283$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pagegrid'] = 'pi_flexform';
284
285t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_pagegrid', $_EXTKEY.'_pagegrid'), 'list_type');
286
287t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pagegrid', 'FILE:EXT:'.$_EXTKEY.'/plugins/pagegrid/flexform.xml');
279288
280// Plugin "pageview".289// Plugin "pageview".
281$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pageview'] = 'layout,select_key,pages,recursive';290$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pageview'] = 'layout,select_key,pages,recursive';
282291
=== modified file 'dlf/locallang.xml'
--- dlf/locallang.xml 2012-09-17 08:23:30 +0000
+++ dlf/locallang.xml 2012-09-25 14:14:21 +0000
@@ -116,6 +116,7 @@
116 <label index="tt_content.dlf_metadata">DLF: Metadata</label>116 <label index="tt_content.dlf_metadata">DLF: Metadata</label>
117 <label index="tt_content.dlf_navigation">DLF: Navigation</label>117 <label index="tt_content.dlf_navigation">DLF: Navigation</label>
118 <label index="tt_content.dlf_oai">DLF: OAI-PMH Interface</label>118 <label index="tt_content.dlf_oai">DLF: OAI-PMH Interface</label>
119 <label index="tt_content.dlf_pagegrid">DLF: Page Grid</label>
119 <label index="tt_content.dlf_pageview">DLF: Page View</label>120 <label index="tt_content.dlf_pageview">DLF: Page View</label>
120 <label index="tt_content.dlf_search">DLF: Search</label>121 <label index="tt_content.dlf_search">DLF: Search</label>
121 <label index="tt_content.dlf_statistics">DLF: Statistics</label>122 <label index="tt_content.dlf_statistics">DLF: Statistics</label>
@@ -277,6 +278,7 @@
277 <label index="tt_content.dlf_metadata">DLF: Metadaten</label>278 <label index="tt_content.dlf_metadata">DLF: Metadaten</label>
278 <label index="tt_content.dlf_navigation">DLF: Navigation</label>279 <label index="tt_content.dlf_navigation">DLF: Navigation</label>
279 <label index="tt_content.dlf_oai">DLF: OAI-PMH-Schnittstelle</label>280 <label index="tt_content.dlf_oai">DLF: OAI-PMH-Schnittstelle</label>
281 <label index="tt_content.dlf_pagegrid">DLF: Seiten-Raster</label>
280 <label index="tt_content.dlf_pageview">DLF: Seitenansicht</label>282 <label index="tt_content.dlf_pageview">DLF: Seitenansicht</label>
281 <label index="tt_content.dlf_search">DLF: Suche</label>283 <label index="tt_content.dlf_search">DLF: Suche</label>
282 <label index="tt_content.dlf_statistics">DLF: Statistik</label>284 <label index="tt_content.dlf_statistics">DLF: Statistik</label>
283285
=== added directory 'dlf/plugins/pagegrid'
=== added file 'dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php'
--- dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php 1970-01-01 00:00:00 +0000
+++ dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php 2012-09-25 14:14:21 +0000
@@ -0,0 +1,252 @@
1<?php
2/***************************************************************
3* Copyright notice
4*
5* (c) 2012 Henrik Lochmann <dev@mentalmotive.com>
6* All rights reserved
7*
8* This script is part of the TYPO3 project. The TYPO3 project is
9* free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* The GNU General Public License can be found at
15* http://www.gnu.org/copyleft/gpl.html.
16*
17* This script is distributed in the hope that it will be useful,
18* but WITHOUT ANY WARRANTY; without even the implied warranty of
19* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20* GNU General Public License for more details.
21*
22* This copyright notice MUST APPEAR in all copies of the script!
23***************************************************************/
24
25/**
26 * [CLASS/FUNCTION INDEX of SCRIPT]
27 */
28
29/**
30 * Plugin 'DLF: Page Grid' for the 'dlf' extension.
31 *
32 * @author Henrik Lochmann <dev@mentalmotive.com>
33 * @copyright Copyright (c) 2012, Zeutschel GmbH
34 * @package TYPO3
35 * @subpackage tx_dlf
36 * @access public
37 */
38class tx_dlf_pagegrid extends tx_dlf_plugin {
39
40 public $scriptRelPath = 'plugins/pagegrid/class.tx_dlf_pagegrid.php';
41
42 /**
43 * Renders thumbnail and page number for one page of the currently shown document.
44 *
45 * @access protected
46 *
47 * @param integer $number: The page to render
48 * @param string $template: Parsed template subpart
49 *
50 * @return string The rendered entry ready for output
51 */
52 protected function getEntry($number, $template) {
53
54 $markerArray = array();
55
56 $thumbnailFile = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][strtolower($this->conf['fileGrpThumbs'])]);
57
58 $markerArray['###THUMBNAIL###'] = '<a href="'.$this->pi_linkTP_keepPIvars_url(array (
59 'page' => $number,
60 'pointer' => NULL // reset pointer: page has priority on page change
61 ), TRUE, FALSE, $this->conf['targetPid']).'"><img src="'.$thumbnailFile.'" /></a>';
62
63 $markerArray['###PAGE###'] = sprintf($this->pi_getLL('page'), $number);
64
65 return $this->cObj->substituteMarkerArray($template, $markerArray);
66
67 }
68
69 /**
70 * Renders the page browser, which shows itemCount pages beside the current page.
71 *
72 * @access protected
73 *
74 * @param integer $itemCount: The number of page links to be shown beside the currently selected page
75 *
76 * @return string The rendered page browser ready for output
77 */
78 protected function getPagebrowser($itemCount = 3) {
79
80 // Get overall number of pages.
81 $maxPages = intval(ceil($this->doc->numPages / $this->conf['limit']));
82
83 // Return empty pagebrowser if there is just one page.
84 if ($maxPages < 2) {
85
86 return '';
87
88 }
89
90 // Get separator.
91 $separator = $this->pi_getLL('separator');
92
93 // Add link to previous page.
94 if ($this->piVars['pointer'] > 0) {
95
96 $output = $this->pi_linkTP_keepPIvars($this->pi_getLL('firstPage'), array ('pointer' => 0), TRUE);
97
98 $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('prevPage'), array ('pointer' => $this->piVars['pointer'] - 1), TRUE).$separator;
99
100 } else {
101
102 $output = $this->pi_getLL('firstPage');
103
104 $output .= $this->pi_getLL('prevPage').$separator;
105
106 }
107
108 $lowerLimit = max($this->piVars['pointer'] - $itemCount, 0);
109
110 if ($this->piVars['pointer'] + $itemCount >= $maxPages) {
111
112 $lowerLimit -= max(($this->piVars['pointer'] + $itemCount) - ($maxPages - 1), 0);
113
114 }
115
116
117 for ($i = $lowerLimit; $i < ($lowerLimit + 2 * $itemCount + 1) && $i < $maxPages; $i++) {
118
119 if ($this->piVars['pointer'] != $i) {
120
121 $output .= $this->pi_linkTP_keepPIvars(sprintf('%d', $i + 1), array ('pointer' => $i), TRUE).$separator;
122
123 } else {
124
125 $output .= '<strong>'.sprintf('%d', $i + 1).'</strong>'.$separator;
126
127 }
128
129 }
130
131 // Add link to next page.
132 if ($this->piVars['pointer'] < $maxPages - 1) {
133
134 $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('nextPage'), array ('pointer' => $this->piVars['pointer'] + 1), TRUE);
135
136 $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('lastPage'), array ('pointer' => $maxPages - 1), TRUE);
137
138 } else {
139
140 $output .= $this->pi_getLL('nextPage');
141
142 $output .= $this->pi_getLL('lastPage');
143
144 }
145
146 return $output;
147
148 }
149
150 /**
151 * The main method of the PlugIn
152 *
153 * @access public
154 *
155 * @param string $content: The PlugIn content
156 * @param array $conf: The PlugIn configuration
157 *
158 * @return string The content that is displayed on the website
159 */
160 public function main($content, $conf) {
161
162 $this->init($conf);
163
164 // Don't cache the output.
165 $this->setCache(FALSE);
166
167 $this->loadDocument();
168
169 if ($this->doc === NULL || $this->doc->numPages < 1) {
170
171 // Quit without doing anything if required variables are not set.
172 return $content;
173
174 } else {
175
176 // Set default values for page if not set.
177 $this->piVars['pointer'] = t3lib_div::intInRange($this->piVars['pointer'], 0, $this->doc->numPages, 0);
178
179 }
180
181 // Load template file.
182 if (!empty($this->conf['templateFile'])) {
183
184 $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
185
186 } else {
187
188 $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/pagegrid/template.tmpl'), '###TEMPLATE###');
189
190 }
191
192 $entryTemplate = $this->cObj->getSubpart($this->template, '###ENTRY###');
193
194 if (empty($entryTemplate)) {
195
196 if (TYPO3_DLOG) {
197
198 t3lib_div::devLog('[tx_dlf_pagegrid->main('.$content.', [data])] Incomplete plugin configuration: entry template missing.', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf);
199
200 }
201
202 // Quit without doing anything if required variables are not set.
203 return $content;
204
205 }
206
207 $actEntryTemplate = $this->cObj->getSubpart($this->template, '###ACT_ENTRY###');
208
209 // Set some variable defaults.
210 if (!empty($this->piVars['pointer']) && (($this->piVars['pointer'] * $this->conf['limit']) + 1) <= $this->doc->numPages) {
211
212 $this->piVars['pointer'] = max(intval($this->piVars['pointer']), 0);
213
214 } else if (!empty($this->piVars['page'])) {
215
216 $page = max(intval($this->piVars['page']), 0);
217
218 $this->piVars['pointer'] = intval(floor($page / $this->conf['limit']));
219
220 } else {
221
222 $this->piVars['pointer'] = 0;
223
224 }
225
226 // Iterate through visible page set and display thumbnails.
227 for ($i = max($this->piVars['pointer'] * $this->conf['limit'], 1); $i < ($this->piVars['pointer'] + 1) * $this->conf['limit']; $i++) {
228
229 $content .= $this->getEntry($i, $i == intval($this->piVars['page']) && !empty($actEntryTemplate) ? $actEntryTemplate : $entryTemplate);
230
231 }
232
233 // Render page browser.
234 $markerArray['###PAGEBROWSER###'] = $this->getPageBrowser();
235
236 // Render entries into entry template.
237 $content = $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE), $markerArray);
238
239 // Remove act-entry template from result.
240 $content = $this->cObj->substituteSubpart($content, '###ACT_ENTRY###', '', TRUE);
241
242 return $this->pi_wrapInBaseClass($content);
243
244 }
245
246}
247
248if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php']) {
249 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php']);
250}
251
252?>
0\ No newline at end of file253\ No newline at end of file
1254
=== added file 'dlf/plugins/pagegrid/flexform.xml'
--- dlf/plugins/pagegrid/flexform.xml 1970-01-01 00:00:00 +0000
+++ dlf/plugins/pagegrid/flexform.xml 2012-09-25 14:14:21 +0000
@@ -0,0 +1,72 @@
1<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2<T3DataStructure>
3 <meta>
4 <langDisable>1</langDisable>
5 </meta>
6 <sheets>
7 <sDEF>
8 <ROOT>
9 <TCEforms>
10 <sheetTitle>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
11 </TCEforms>
12 <type>array</type>
13 <el>
14 <pages>
15 <TCEforms>
16 <exclude>1</exclude>
17 <label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
18 <config>
19 <type>group</type>
20 <internal_type>db</internal_type>
21 <allowed>pages</allowed>
22 <size>1</size>
23 <maxitems>1</maxitems>
24 <minitems>1</minitems>
25 </config>
26 </TCEforms>
27 </pages>
28 <limit>
29 <TCEforms>
30 <exclude>1</exclude>
31 <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.limit</label>
32 <config>
33 <type>input</type>
34 <eval>required,num,int</eval>
35 <default>24</default>
36 </config>
37 </TCEforms>
38 </limit>
39 <targetPid>
40 <TCEforms>
41 <exclude>1</exclude>
42 <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.targetPid</label>
43 <config>
44 <type>group</type>
45 <internal_type>db</internal_type>
46 <allowed>pages</allowed>
47 <size>1</size>
48 <maxitems>1</maxitems>
49 <minitems>1</minitems>
50 </config>
51 </TCEforms>
52 </targetPid>
53 <templateFile>
54 <TCEforms>
55 <exclude>1</exclude>
56 <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.templateFile</label>
57 <config>
58 <type>group</type>
59 <internal_type>file_reference</internal_type>
60 <allowed>tmpl,tpl,html,htm,txt</allowed>
61 <size>1</size>
62 <maxitems>1</maxitems>
63 <minitems>0</minitems>
64 <disable_controls>upload</disable_controls>
65 </config>
66 </TCEforms>
67 </templateFile>
68 </el>
69 </ROOT>
70 </sDEF>
71 </sheets>
72</T3DataStructure>
0\ No newline at end of file73\ No newline at end of file
174
=== added file 'dlf/plugins/pagegrid/locallang.xml'
--- dlf/plugins/pagegrid/locallang.xml 1970-01-01 00:00:00 +0000
+++ dlf/plugins/pagegrid/locallang.xml 2012-09-25 14:14:21 +0000
@@ -0,0 +1,33 @@
1<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2<T3locallang>
3 <meta type="array">
4 <type>module</type>
5 <description>Language labels for plugin tx_dlf_pagegrid</description>
6 </meta>
7 <data type="array">
8 <languageKey index="default" type="array">
9 <label index="tt_content.pi_flexform.sheet_general">Options</label>
10 <label index="tt_content.pi_flexform.limit">Previews per page</label>
11 <label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
12 <label index="tt_content.pi_flexform.templateFile">Template file</label>
13 <label index="firstPage">&#171;</label>
14 <label index="prevPage">&#8592;</label>
15 <label index="nextPage">&#8594;</label>
16 <label index="lastPage">&#187;</label>
17 <label index="page">Page %d</label>
18 <label index="separator"> - </label>
19 </languageKey>
20 <languageKey index="de" type="array">
21 <label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
22 <label index="tt_content.pi_flexform.limit">Vorschaubilder pro Seite</label>
23 <label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
24 <label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
25 <label index="firstPage">&#171;</label>
26 <label index="prevPage">&#8592;</label>
27 <label index="nextPage">&#8594;</label>
28 <label index="lastPage">&#187;</label>
29 <label index="page">Seite %d</label>
30 <label index="separator"> - </label>
31 </languageKey>
32 </data>
33</T3locallang>
0\ No newline at end of file34\ No newline at end of file
135
=== added file 'dlf/plugins/pagegrid/template.tmpl'
--- dlf/plugins/pagegrid/template.tmpl 1970-01-01 00:00:00 +0000
+++ dlf/plugins/pagegrid/template.tmpl 2012-09-25 14:14:21 +0000
@@ -0,0 +1,17 @@
1<!-- ###TEMPLATE### -->
2<div class="tx-dlf-pagegrid-pagebrowser">###PAGEBROWSER###</div>
3<div class="tx-dlf-pagegrid-grid">
4 <!-- ###ENTRY### -->
5 <div class="tx-dlf-pagegrid-item" style="float:left;">
6 <div>###THUMBNAIL###</div>
7 <div>###PAGE###</div>
8 </div>
9 <!-- ###ENTRY### -->
10 <!-- ###ACT_ENTRY### -->
11 <div class="tx-dlf-pagegrid-item-act" style="float:left;">
12 <div>###THUMBNAIL###</div>
13 <div>###PAGE###</div>
14 </div>
15 <!-- ###ACT_ENTRY### -->
16</div>
17<!-- ###TEMPLATE### -->
0\ No newline at end of file18\ No newline at end of file

Subscribers

People subscribed via source and target branches