Skip to content

Commit

Permalink
Merge pull request #125 from albig/master
Browse files Browse the repository at this point in the history
Update documentation and fine tuning.
  • Loading branch information
Alexander Bigga authored Aug 9, 2019
2 parents cf807b2 + df14d3c commit 71566fa
Show file tree
Hide file tree
Showing 8 changed files with 4,222 additions and 4,079 deletions.
40 changes: 23 additions & 17 deletions Classes/Plugins/NewspaperCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

use \tx_dlf_plugin;
use \TYPO3\CMS\Core\Utility\MathUtility;
use \TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
use \TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Plugin 'DFG-Viewer: Newspaper Calendar' for the 'dfgviewer' extension.
Expand All @@ -42,6 +44,8 @@ class NewspaperCalendar extends tx_dlf_plugin {

public $scriptRelPath = 'Classes/Plugins/NewspaperCalendar.php';

protected $templateService;

const CHILDREN = 'children';
const LABEL = 'label';
const ORDERLABEL = 'orderlabel';
Expand Down Expand Up @@ -73,6 +77,8 @@ public function main($content, $conf) {

$toc = $this->doc->tableOfContents;

$this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);

$months = array();
$monthLabel = '';

Expand All @@ -87,11 +93,11 @@ public function main($content, $conf) {
// Load template file.
if (!empty($this->conf['templateFile'])) {

$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');

} else {

$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperCalendar.tmpl'), '###TEMPLATE###');
$this->template = $this->templateService->getSubpart($this->cObj->fileResource('EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperCalendar.tmpl'), '###TEMPLATE###');

}

Expand All @@ -118,7 +124,7 @@ public function main($content, $conf) {
}
}

return $this->cObj->substituteSubpart($this->template, '###CALYEARWRAPPER###', $subPartContent);
return $this->templateService->substituteSubpart($this->template, '###CALYEARWRAPPER###', $subPartContent);
}

/**
Expand All @@ -137,9 +143,9 @@ public function main($content, $conf) {
* @return string
*/
private function getTemplateForYear($subparts, $toc, $year, $months, $firstMonth, $lastMonth, $hasMoreYears = true) {
$subparts["year"] = $this->cObj->getSubpart($subparts['template'], '###CALYEARWRAPPER###');
$subparts['month'] = $this->cObj->getSubpart($subparts['year'], '###CALMONTH###');
$subparts['singleissue'] = $this->cObj->getSubpart($subparts['issuelist'], '###SINGLEISSUE###');
$subparts["year"] = $this->templateService->getSubpart($subparts['template'], '###CALYEARWRAPPER###');
$subparts['month'] = $this->templateService->getSubpart($subparts['year'], '###CALMONTH###');
$subparts['singleissue'] = $this->templateService->getSubpart($subparts['issuelist'], '###SINGLEISSUE###');

$allIssues[] = array();
$subPartContent = '';
Expand All @@ -158,7 +164,7 @@ private function getTemplateForYear($subparts, $toc, $year, $months, $firstMonth
);

// Get week subpart template
$subWeekTemplate = $this->cObj->getSubpart($subparts['month'], '###CALWEEK###');
$subWeekTemplate = $this->templateService->getSubpart($subparts['month'], '###CALWEEK###');
$subWeekPartContent = '';

$firstOfMonth = strtotime($year . '-' . $i . '-1');
Expand Down Expand Up @@ -251,14 +257,14 @@ private function getTemplateForYear($subparts, $toc, $year, $months, $firstMonth
}
}
// fill the weeks
$subWeekPartContent .= $this->cObj->substituteMarkerArray($subWeekTemplate, $weekArray);
$subWeekPartContent .= $this->templateService->substituteMarkerArray($subWeekTemplate, $weekArray);
}

// fill the month markers
$subPartContent .= $this->cObj->substituteMarkerArray($subparts['month'], $markerArray);
$subPartContent .= $this->templateService->substituteMarkerArray($subparts['month'], $markerArray);

// fill the week markers
$subPartContent = $this->cObj->substituteSubpart($subPartContent, '###CALWEEK###', $subWeekPartContent);
$subPartContent = $this->templateService->substituteSubpart($subPartContent, '###CALWEEK###', $subWeekPartContent);
}

// link to years overview
Expand All @@ -279,9 +285,9 @@ private function getTemplateForYear($subparts, $toc, $year, $months, $firstMonth


// prepare list as alternative of the calendar view
$issueListTemplate = $this->cObj->getSubpart($subparts['year'], '###ISSUELIST###');
$issueListTemplate = $this->templateService->getSubpart($subparts['year'], '###ISSUELIST###');

$subparts['singleissue'] = $this->cObj->getSubpart($issueListTemplate, '###SINGLEISSUE###');
$subparts['singleissue'] = $this->templateService->getSubpart($issueListTemplate, '###SINGLEISSUE###');

$allDaysList = array();
$subPartContentList = '';
Expand All @@ -294,21 +300,21 @@ private function getTemplateForYear($subparts, $toc, $year, $months, $firstMonth
$subPartContentList .= $issue[0];
}

$subPartContentList .= $this->cObj->substituteMarker($subparts['singleissue'], '###ITEM###', $issue[1]);
$subPartContentList .= $this->templateService->substituteMarker($subparts['singleissue'], '###ITEM###', $issue[1]);
}

$issueListTemplate = $this->cObj->substituteSubpart($issueListTemplate, '###SINGLEISSUE###', $subPartContentList);
$issueListTemplate = $this->templateService->substituteSubpart($issueListTemplate, '###SINGLEISSUE###', $subPartContentList);

$subparts['year'] = $this->cObj->substituteSubpart($subparts['year'], '###ISSUELIST###', $issueListTemplate);
$subparts['year'] = $this->templateService->substituteSubpart($subparts['year'], '###ISSUELIST###', $issueListTemplate);

$markerArray = array (
'###CALYEAR###' => $yearLink,
'###CALALLYEARS###' => $allYearsLink
);

$subparts['year'] = $this->cObj->substituteMarkerArray($subparts['year'], $markerArray);
$subparts['year'] = $this->templateService->substituteMarkerArray($subparts['year'], $markerArray);

return $this->cObj->substituteSubpart($subparts['year'], '###CALMONTH###', $subPartContent);
return $this->templateService->substituteSubpart($subparts['year'], '###CALMONTH###', $subPartContent);
}

/**
Expand Down
120 changes: 60 additions & 60 deletions Classes/Plugins/NewspaperYears.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,95 +40,95 @@
*/
class NewspaperYears extends tx_dlf_plugin {

public $extKey = 'dfgviewer';
public $extKey = 'dfgviewer';

public $scriptRelPath = 'Classes/Plugins/NewspaperYears.php';
public $scriptRelPath = 'Classes/Plugins/NewspaperYears.php';

/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf) {
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf) {

$this->init($conf);
$this->init($conf);

// Load current document.
$this->loadDocument();
// Load current document.
$this->loadDocument();

if ($this->doc === NULL) {
if ($this->doc === NULL) {

// Quit without doing anything if required variables are not set.
return $content;
// Quit without doing anything if required variables are not set.
return $content;

} else {
} else {

// Set default values if not set.
$this->piVars['page'] = MathUtility::forceIntegerInRange($this->piVars['page'], 1, $this->doc->numPages, 1);
// Set default values if not set.
$this->piVars['page'] = MathUtility::forceIntegerInRange($this->piVars['page'], 1, $this->doc->numPages, 1);

}
}

$toc = $this->doc->tableOfContents;
$toc = $this->doc->tableOfContents;

$templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);

// Load template file.
if (!empty($this->conf['templateFile'])) {
$this->template = $templateService->getSubpart($GLOBALS['TSFE']->tmpl->getFileName($this->conf['templateFile']), '###TEMPLATE###');
} else {
$this->template = $templateService->getSubpart($GLOBALS['TSFE']->tmpl->getFileName('EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperYears.tmpl'), '###TEMPLATE###');
}
// Load template file.
if (!empty($this->conf['templateFile'])) {
$this->template = $templateService->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
} else {
$this->template = $templateService->getSubpart($this->cObj->fileResource('EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperYears.tmpl'), '###TEMPLATE###');
}

// Get subpart templates
$subparts['template'] = $this->template;
$subparts['year'] = $templateService->getSubpart($subparts['template'], '###LISTYEAR###');
// Get subpart templates
$subparts['template'] = $this->template;
$subparts['year'] = $templateService->getSubpart($subparts['template'], '###LISTYEAR###');

$years = $toc[0]['children'];
$years = $toc[0]['children'];

$subYearPartContent = '';
$subYearPartContent = '';

foreach($years as $id => $year) {
foreach($years as $id => $year) {

$yearLabel = empty($year['label']) ? $year['orderlabel'] : $year['label'];
$yearLabel = empty($year['label']) ? $year['orderlabel'] : $year['label'];

if (empty($yearLabel)) {
if (empty($yearLabel)) {

// if neither order nor orderlabel is set, use the id...
$yearLabel = (string)$id;
// if neither order nor orderlabel is set, use the id...
$yearLabel = (string)$id;

}
if (strlen($year['points']) > 0) {
}
if (strlen($year['points']) > 0) {

$linkConf = array (
'useCacheHash' => 1,
'parameter' => $this->conf['targetPid'],
'additionalParams' => '&' . $this->prefixId . '[id]=' . urlencode($year['points']),
'title' => $yearLabel
);
$yearText = $this->cObj->typoLink($yearLabel, $linkConf);
$linkConf = array (
'useCacheHash' => 1,
'parameter' => $this->conf['targetPid'],
'additionalParams' => '&' . $this->prefixId . '[id]=' . urlencode($year['points']),
'title' => $yearLabel
);
$yearText = $this->cObj->typoLink($yearLabel, $linkConf);

} else {
} else {

$yearText = $yearLabel;
$yearText = $yearLabel;

}
}

$yearArray = array(
'###YEARNAME###' => $yearText,
);
$yearArray = array(
'###YEARNAME###' => $yearText,
);

$subYearPartContent .= $templateService->substituteMarkerArray($subparts['year'], $yearArray);
$subYearPartContent .= $templateService->substituteMarkerArray($subparts['year'], $yearArray);

}
}

// fill the week markers
return $templateService->substituteSubpart($subparts['template'], '###LISTYEAR###', $subYearPartContent);
// fill the week markers
return $templateService->substituteSubpart($subparts['template'], '###LISTYEAR###', $subYearPartContent);

}
}

}
12 changes: 12 additions & 0 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}

if (TYPO3_MODE === 'BE') {

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile (
'dfgviewer',
'Configuration/TsConfig/Page.ts',
'EXT:dfgviewer: Page TS');
}
2 changes: 1 addition & 1 deletion Configuration/TypoScript/Page/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ page {
# will work as of TYPO3 7.6
integrity = sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=
excludeFromConcatenation = 1
allWrap = |<script type="text/javascript">if (typeof jQuery == 'undefined') { document.write(unescape("%3Cscript src='/typo3conf/ext/dfgviewer/Resources/Public/Javascript/jquery-2.2.4.min.js' type='text/javascript'%3E%3C/script%3E"));}</script>
allWrap = |<script type="text/javascript">if (typeof jQuery == 'undefined') { document.write(unescape("%3Cscript src='/typo3conf/ext/dfgviewer/Resources/Public/Js/jquery-2.2.4.min.js' type='text/javascript'%3E%3C/script%3E"));}</script>
}
}
includeJSFooterlibs {
Expand Down
28 changes: 14 additions & 14 deletions Configuration/TypoScript/constants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,46 @@ config {
# cat=plugin.tx_dfgviewer/piwik/030; type=string; label=Piwik Domains
piwik_domains =

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Main template file newspaper
# cat=plugin.tx_dfgviewer/file; type=string; label=Main template file newspaper
templateFileNewspaper = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/template_newspaper.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Metadata template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Metadata template file
templateFileMeta = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/metadata.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Grid Pager template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Grid Pager template file
templateFilePager = EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/GridPager.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Pers. Identifier template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Pers. Identifier template file
templateFileUri = EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/Uri.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Page View template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Page View template file
templateFilePage = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/pageview.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Page Grid template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Page Grid template file
templateFileGrid = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/pagegrid.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Table of Contents template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Table of Contents template file
templateFileToc = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/toc.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Toolbox template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Toolbox template file
templateFileToolbox = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/toolbox.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Download Tool template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Download Tool template file
templateFileToolPdf = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/downloads.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Fulltext Tool template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Fulltext Tool template file
templateFileToolFulltext = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/fulltext.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Image manipulation template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Image manipulation template file
templateFileToolImageManipulation = EXT:dfgviewer/Resources/Private/Templates/Plugins/Kitodo/imagemanipulation.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Newspaper Calendar template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Newspaper Calendar template file
templateFileNewspaperCalendar = EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperCalendar.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=Newspaper Year List template file
# cat=plugin.tx_dfgviewer/file; type=string; label=Newspaper Year List template file
templateFileNewspaperYears = EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/NewspaperYears.tmpl

# cat=plugin.tx_dfgviewer/file; type=file[html,htm,tmpl]; label=SRU searchform template file
# cat=plugin.tx_dfgviewer/file; type=string; label=SRU searchform template file
templateFileSru = EXT:dfgviewer/Resources/Private/Templates/Plugins/Dfgviewer/Sru.tmpl

}
Loading

0 comments on commit 71566fa

Please sign in to comment.