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
1=== modified file 'dlf/ext_autoload.php'
2--- dlf/ext_autoload.php 2012-08-22 19:22:29 +0000
3+++ dlf/ext_autoload.php 2012-09-25 14:14:21 +0000
4@@ -47,6 +47,7 @@
5 'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php',
6 'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php',
7 'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',
8+ 'tx_dlf_pagegrid' => $extensionPath.'plugins/pagegrid/class.tx_dlf_pagegrid.php',
9 'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php',
10 'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php',
11 'tx_dlf_search_suggest' => $extensionPath.'plugins/search/class.tx_dlf_search_suggest.php',
12
13=== modified file 'dlf/ext_localconf.php'
14--- dlf/ext_localconf.php 2012-08-22 19:22:29 +0000
15+++ dlf/ext_localconf.php 2012-09-25 14:14:21 +0000
16@@ -37,6 +37,8 @@
17
18 t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/oai/class.tx_dlf_oai.php', '_oai', 'list_type', FALSE);
19
20+t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pagegrid/class.tx_dlf_pagegrid.php', '_pagegrid', 'list_type', TRUE);
21+
22 t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php', '_pageview', 'list_type', TRUE);
23
24 t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE);
25
26=== modified file 'dlf/ext_tables.php'
27--- dlf/ext_tables.php 2012-09-15 16:05:08 +0000
28+++ dlf/ext_tables.php 2012-09-25 14:14:21 +0000
29@@ -276,6 +276,15 @@
30 t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_oai', $_EXTKEY.'_oai'), 'list_type');
31
32 t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_oai', 'FILE:EXT:'.$_EXTKEY.'/plugins/oai/flexform.xml');
33+
34+// Plugin "pagegrid".
35+$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pagegrid'] = 'layout,select_key,pages,recursive';
36+
37+$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pagegrid'] = 'pi_flexform';
38+
39+t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_pagegrid', $_EXTKEY.'_pagegrid'), 'list_type');
40+
41+t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pagegrid', 'FILE:EXT:'.$_EXTKEY.'/plugins/pagegrid/flexform.xml');
42
43 // Plugin "pageview".
44 $TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pageview'] = 'layout,select_key,pages,recursive';
45
46=== modified file 'dlf/locallang.xml'
47--- dlf/locallang.xml 2012-09-17 08:23:30 +0000
48+++ dlf/locallang.xml 2012-09-25 14:14:21 +0000
49@@ -116,6 +116,7 @@
50 <label index="tt_content.dlf_metadata">DLF: Metadata</label>
51 <label index="tt_content.dlf_navigation">DLF: Navigation</label>
52 <label index="tt_content.dlf_oai">DLF: OAI-PMH Interface</label>
53+ <label index="tt_content.dlf_pagegrid">DLF: Page Grid</label>
54 <label index="tt_content.dlf_pageview">DLF: Page View</label>
55 <label index="tt_content.dlf_search">DLF: Search</label>
56 <label index="tt_content.dlf_statistics">DLF: Statistics</label>
57@@ -277,6 +278,7 @@
58 <label index="tt_content.dlf_metadata">DLF: Metadaten</label>
59 <label index="tt_content.dlf_navigation">DLF: Navigation</label>
60 <label index="tt_content.dlf_oai">DLF: OAI-PMH-Schnittstelle</label>
61+ <label index="tt_content.dlf_pagegrid">DLF: Seiten-Raster</label>
62 <label index="tt_content.dlf_pageview">DLF: Seitenansicht</label>
63 <label index="tt_content.dlf_search">DLF: Suche</label>
64 <label index="tt_content.dlf_statistics">DLF: Statistik</label>
65
66=== added directory 'dlf/plugins/pagegrid'
67=== added file 'dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php'
68--- dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php 1970-01-01 00:00:00 +0000
69+++ dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php 2012-09-25 14:14:21 +0000
70@@ -0,0 +1,252 @@
71+<?php
72+/***************************************************************
73+* Copyright notice
74+*
75+* (c) 2012 Henrik Lochmann <dev@mentalmotive.com>
76+* All rights reserved
77+*
78+* This script is part of the TYPO3 project. The TYPO3 project is
79+* free software; you can redistribute it and/or modify
80+* it under the terms of the GNU General Public License as published by
81+* the Free Software Foundation; either version 2 of the License, or
82+* (at your option) any later version.
83+*
84+* The GNU General Public License can be found at
85+* http://www.gnu.org/copyleft/gpl.html.
86+*
87+* This script is distributed in the hope that it will be useful,
88+* but WITHOUT ANY WARRANTY; without even the implied warranty of
89+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90+* GNU General Public License for more details.
91+*
92+* This copyright notice MUST APPEAR in all copies of the script!
93+***************************************************************/
94+
95+/**
96+ * [CLASS/FUNCTION INDEX of SCRIPT]
97+ */
98+
99+/**
100+ * Plugin 'DLF: Page Grid' for the 'dlf' extension.
101+ *
102+ * @author Henrik Lochmann <dev@mentalmotive.com>
103+ * @copyright Copyright (c) 2012, Zeutschel GmbH
104+ * @package TYPO3
105+ * @subpackage tx_dlf
106+ * @access public
107+ */
108+class tx_dlf_pagegrid extends tx_dlf_plugin {
109+
110+ public $scriptRelPath = 'plugins/pagegrid/class.tx_dlf_pagegrid.php';
111+
112+ /**
113+ * Renders thumbnail and page number for one page of the currently shown document.
114+ *
115+ * @access protected
116+ *
117+ * @param integer $number: The page to render
118+ * @param string $template: Parsed template subpart
119+ *
120+ * @return string The rendered entry ready for output
121+ */
122+ protected function getEntry($number, $template) {
123+
124+ $markerArray = array();
125+
126+ $thumbnailFile = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][strtolower($this->conf['fileGrpThumbs'])]);
127+
128+ $markerArray['###THUMBNAIL###'] = '<a href="'.$this->pi_linkTP_keepPIvars_url(array (
129+ 'page' => $number,
130+ 'pointer' => NULL // reset pointer: page has priority on page change
131+ ), TRUE, FALSE, $this->conf['targetPid']).'"><img src="'.$thumbnailFile.'" /></a>';
132+
133+ $markerArray['###PAGE###'] = sprintf($this->pi_getLL('page'), $number);
134+
135+ return $this->cObj->substituteMarkerArray($template, $markerArray);
136+
137+ }
138+
139+ /**
140+ * Renders the page browser, which shows itemCount pages beside the current page.
141+ *
142+ * @access protected
143+ *
144+ * @param integer $itemCount: The number of page links to be shown beside the currently selected page
145+ *
146+ * @return string The rendered page browser ready for output
147+ */
148+ protected function getPagebrowser($itemCount = 3) {
149+
150+ // Get overall number of pages.
151+ $maxPages = intval(ceil($this->doc->numPages / $this->conf['limit']));
152+
153+ // Return empty pagebrowser if there is just one page.
154+ if ($maxPages < 2) {
155+
156+ return '';
157+
158+ }
159+
160+ // Get separator.
161+ $separator = $this->pi_getLL('separator');
162+
163+ // Add link to previous page.
164+ if ($this->piVars['pointer'] > 0) {
165+
166+ $output = $this->pi_linkTP_keepPIvars($this->pi_getLL('firstPage'), array ('pointer' => 0), TRUE);
167+
168+ $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('prevPage'), array ('pointer' => $this->piVars['pointer'] - 1), TRUE).$separator;
169+
170+ } else {
171+
172+ $output = $this->pi_getLL('firstPage');
173+
174+ $output .= $this->pi_getLL('prevPage').$separator;
175+
176+ }
177+
178+ $lowerLimit = max($this->piVars['pointer'] - $itemCount, 0);
179+
180+ if ($this->piVars['pointer'] + $itemCount >= $maxPages) {
181+
182+ $lowerLimit -= max(($this->piVars['pointer'] + $itemCount) - ($maxPages - 1), 0);
183+
184+ }
185+
186+
187+ for ($i = $lowerLimit; $i < ($lowerLimit + 2 * $itemCount + 1) && $i < $maxPages; $i++) {
188+
189+ if ($this->piVars['pointer'] != $i) {
190+
191+ $output .= $this->pi_linkTP_keepPIvars(sprintf('%d', $i + 1), array ('pointer' => $i), TRUE).$separator;
192+
193+ } else {
194+
195+ $output .= '<strong>'.sprintf('%d', $i + 1).'</strong>'.$separator;
196+
197+ }
198+
199+ }
200+
201+ // Add link to next page.
202+ if ($this->piVars['pointer'] < $maxPages - 1) {
203+
204+ $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('nextPage'), array ('pointer' => $this->piVars['pointer'] + 1), TRUE);
205+
206+ $output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('lastPage'), array ('pointer' => $maxPages - 1), TRUE);
207+
208+ } else {
209+
210+ $output .= $this->pi_getLL('nextPage');
211+
212+ $output .= $this->pi_getLL('lastPage');
213+
214+ }
215+
216+ return $output;
217+
218+ }
219+
220+ /**
221+ * The main method of the PlugIn
222+ *
223+ * @access public
224+ *
225+ * @param string $content: The PlugIn content
226+ * @param array $conf: The PlugIn configuration
227+ *
228+ * @return string The content that is displayed on the website
229+ */
230+ public function main($content, $conf) {
231+
232+ $this->init($conf);
233+
234+ // Don't cache the output.
235+ $this->setCache(FALSE);
236+
237+ $this->loadDocument();
238+
239+ if ($this->doc === NULL || $this->doc->numPages < 1) {
240+
241+ // Quit without doing anything if required variables are not set.
242+ return $content;
243+
244+ } else {
245+
246+ // Set default values for page if not set.
247+ $this->piVars['pointer'] = t3lib_div::intInRange($this->piVars['pointer'], 0, $this->doc->numPages, 0);
248+
249+ }
250+
251+ // Load template file.
252+ if (!empty($this->conf['templateFile'])) {
253+
254+ $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
255+
256+ } else {
257+
258+ $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/pagegrid/template.tmpl'), '###TEMPLATE###');
259+
260+ }
261+
262+ $entryTemplate = $this->cObj->getSubpart($this->template, '###ENTRY###');
263+
264+ if (empty($entryTemplate)) {
265+
266+ if (TYPO3_DLOG) {
267+
268+ t3lib_div::devLog('[tx_dlf_pagegrid->main('.$content.', [data])] Incomplete plugin configuration: entry template missing.', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf);
269+
270+ }
271+
272+ // Quit without doing anything if required variables are not set.
273+ return $content;
274+
275+ }
276+
277+ $actEntryTemplate = $this->cObj->getSubpart($this->template, '###ACT_ENTRY###');
278+
279+ // Set some variable defaults.
280+ if (!empty($this->piVars['pointer']) && (($this->piVars['pointer'] * $this->conf['limit']) + 1) <= $this->doc->numPages) {
281+
282+ $this->piVars['pointer'] = max(intval($this->piVars['pointer']), 0);
283+
284+ } else if (!empty($this->piVars['page'])) {
285+
286+ $page = max(intval($this->piVars['page']), 0);
287+
288+ $this->piVars['pointer'] = intval(floor($page / $this->conf['limit']));
289+
290+ } else {
291+
292+ $this->piVars['pointer'] = 0;
293+
294+ }
295+
296+ // Iterate through visible page set and display thumbnails.
297+ for ($i = max($this->piVars['pointer'] * $this->conf['limit'], 1); $i < ($this->piVars['pointer'] + 1) * $this->conf['limit']; $i++) {
298+
299+ $content .= $this->getEntry($i, $i == intval($this->piVars['page']) && !empty($actEntryTemplate) ? $actEntryTemplate : $entryTemplate);
300+
301+ }
302+
303+ // Render page browser.
304+ $markerArray['###PAGEBROWSER###'] = $this->getPageBrowser();
305+
306+ // Render entries into entry template.
307+ $content = $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE), $markerArray);
308+
309+ // Remove act-entry template from result.
310+ $content = $this->cObj->substituteSubpart($content, '###ACT_ENTRY###', '', TRUE);
311+
312+ return $this->pi_wrapInBaseClass($content);
313+
314+ }
315+
316+}
317+
318+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php']) {
319+ include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pagegrid/class.tx_dlf_pagegrid.php']);
320+}
321+
322+?>
323\ No newline at end of file
324
325=== added file 'dlf/plugins/pagegrid/flexform.xml'
326--- dlf/plugins/pagegrid/flexform.xml 1970-01-01 00:00:00 +0000
327+++ dlf/plugins/pagegrid/flexform.xml 2012-09-25 14:14:21 +0000
328@@ -0,0 +1,72 @@
329+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
330+<T3DataStructure>
331+ <meta>
332+ <langDisable>1</langDisable>
333+ </meta>
334+ <sheets>
335+ <sDEF>
336+ <ROOT>
337+ <TCEforms>
338+ <sheetTitle>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
339+ </TCEforms>
340+ <type>array</type>
341+ <el>
342+ <pages>
343+ <TCEforms>
344+ <exclude>1</exclude>
345+ <label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
346+ <config>
347+ <type>group</type>
348+ <internal_type>db</internal_type>
349+ <allowed>pages</allowed>
350+ <size>1</size>
351+ <maxitems>1</maxitems>
352+ <minitems>1</minitems>
353+ </config>
354+ </TCEforms>
355+ </pages>
356+ <limit>
357+ <TCEforms>
358+ <exclude>1</exclude>
359+ <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.limit</label>
360+ <config>
361+ <type>input</type>
362+ <eval>required,num,int</eval>
363+ <default>24</default>
364+ </config>
365+ </TCEforms>
366+ </limit>
367+ <targetPid>
368+ <TCEforms>
369+ <exclude>1</exclude>
370+ <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.targetPid</label>
371+ <config>
372+ <type>group</type>
373+ <internal_type>db</internal_type>
374+ <allowed>pages</allowed>
375+ <size>1</size>
376+ <maxitems>1</maxitems>
377+ <minitems>1</minitems>
378+ </config>
379+ </TCEforms>
380+ </targetPid>
381+ <templateFile>
382+ <TCEforms>
383+ <exclude>1</exclude>
384+ <label>LLL:EXT:dlf/plugins/pagegrid/locallang.xml:tt_content.pi_flexform.templateFile</label>
385+ <config>
386+ <type>group</type>
387+ <internal_type>file_reference</internal_type>
388+ <allowed>tmpl,tpl,html,htm,txt</allowed>
389+ <size>1</size>
390+ <maxitems>1</maxitems>
391+ <minitems>0</minitems>
392+ <disable_controls>upload</disable_controls>
393+ </config>
394+ </TCEforms>
395+ </templateFile>
396+ </el>
397+ </ROOT>
398+ </sDEF>
399+ </sheets>
400+</T3DataStructure>
401\ No newline at end of file
402
403=== added file 'dlf/plugins/pagegrid/locallang.xml'
404--- dlf/plugins/pagegrid/locallang.xml 1970-01-01 00:00:00 +0000
405+++ dlf/plugins/pagegrid/locallang.xml 2012-09-25 14:14:21 +0000
406@@ -0,0 +1,33 @@
407+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
408+<T3locallang>
409+ <meta type="array">
410+ <type>module</type>
411+ <description>Language labels for plugin tx_dlf_pagegrid</description>
412+ </meta>
413+ <data type="array">
414+ <languageKey index="default" type="array">
415+ <label index="tt_content.pi_flexform.sheet_general">Options</label>
416+ <label index="tt_content.pi_flexform.limit">Previews per page</label>
417+ <label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
418+ <label index="tt_content.pi_flexform.templateFile">Template file</label>
419+ <label index="firstPage">&#171;</label>
420+ <label index="prevPage">&#8592;</label>
421+ <label index="nextPage">&#8594;</label>
422+ <label index="lastPage">&#187;</label>
423+ <label index="page">Page %d</label>
424+ <label index="separator"> - </label>
425+ </languageKey>
426+ <languageKey index="de" type="array">
427+ <label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
428+ <label index="tt_content.pi_flexform.limit">Vorschaubilder pro Seite</label>
429+ <label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
430+ <label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
431+ <label index="firstPage">&#171;</label>
432+ <label index="prevPage">&#8592;</label>
433+ <label index="nextPage">&#8594;</label>
434+ <label index="lastPage">&#187;</label>
435+ <label index="page">Seite %d</label>
436+ <label index="separator"> - </label>
437+ </languageKey>
438+ </data>
439+</T3locallang>
440\ No newline at end of file
441
442=== added file 'dlf/plugins/pagegrid/template.tmpl'
443--- dlf/plugins/pagegrid/template.tmpl 1970-01-01 00:00:00 +0000
444+++ dlf/plugins/pagegrid/template.tmpl 2012-09-25 14:14:21 +0000
445@@ -0,0 +1,17 @@
446+<!-- ###TEMPLATE### -->
447+<div class="tx-dlf-pagegrid-pagebrowser">###PAGEBROWSER###</div>
448+<div class="tx-dlf-pagegrid-grid">
449+ <!-- ###ENTRY### -->
450+ <div class="tx-dlf-pagegrid-item" style="float:left;">
451+ <div>###THUMBNAIL###</div>
452+ <div>###PAGE###</div>
453+ </div>
454+ <!-- ###ENTRY### -->
455+ <!-- ###ACT_ENTRY### -->
456+ <div class="tx-dlf-pagegrid-item-act" style="float:left;">
457+ <div>###THUMBNAIL###</div>
458+ <div>###PAGE###</div>
459+ </div>
460+ <!-- ###ACT_ENTRY### -->
461+</div>
462+<!-- ###TEMPLATE### -->
463\ No newline at end of file

Subscribers

People subscribed via source and target branches