Skip to content

Commit

Permalink
Merge pull request #76 from slub/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dikastes authored Oct 15, 2024
2 parents 1dab731 + 630951a commit 1242101
Show file tree
Hide file tree
Showing 16 changed files with 338 additions and 30 deletions.
62 changes: 62 additions & 0 deletions Classes/Controller/WelcomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Slub\MpdbPresentation\Controller;

use \Illuminate\Support\Collection;
use \Illuminate\Support\Str;
use \Psr\Http\Message\ResponseInterface;
use \TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use \Slub\MpdbPresentation\Domain\Model\Publisher;

/***
*
* This file is part of the "Publisher Database" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Matthias Richter <[email protected]>, SLUB Dresden
*
***/
/**
* PublishedItemController
*/
class WelcomeController extends AbstractController
{

/**
* action welcome
*
* @return void
*/
public function welcomeAction(): ResponseInterface
{
$bodyText = $this->configurationManager->getContentObject()->getFieldVal('bodytext');
$and = LocalizationUtility::translate('LLL:EXT:mpdb_presentation/Resources/Private/Language/locallang:and');

$entityCount = $this->searchService->
setIndex(PublishedItemController::TABLE_INDEX_NAME)->
count();

$publishers = $this->searchService->
reset()->
setIndex(Publisher::INDEX_NAME)->
search()->
pluck('_source')->
map(function ($publisher) { return self::getPublisherName($publisher); })->
join(', ', ' ' . $and . ' ');

$processedText = Str::of($bodyText)->replace('{{ publishers }}', $publishers)->
replace('{{ count }}', $entityCount);

$this->view->assign('processedText', $processedText);

return $this->htmlResponse();
}

private static function getPublisherName(Collection $publisher): string
{
return $publisher->get('name') . ' (' . $publisher->get('shorthand') . ')';
}

}
4 changes: 4 additions & 0 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
'mpdb_res_icon' => [
'provider' => SvgIconProvider::class,
'source' => 'EXT:mpdb_presentation/Resources/Public/Icons/mpdb_res_icon.svg'
],
'mpdb_wel_icon' => [
'provider' => SvgIconProvider::class,
'source' => 'EXT:mpdb_presentation/Resources/Public/Icons/mpdb_wel_icon.svg'
]
];
34 changes: 15 additions & 19 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') or die();
Expand All @@ -18,23 +17,20 @@
);
})();

(static function (): void {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
// extension name, matching the PHP namespaces (but without the vendor)
'MpdbPresentation',
// arbitrary, but unique plugin name (not visible in the backend)
'Mpdbwelcome',
// plugin title, as visible in the drop-down in the backend, use "LLL:" for localization
'Music publisher database welcome plugin'
);
})();

$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']['tx_mpdbpresentation_mpdbresearch'] = 'mpdb_res_icon';
$GLOBALS['TCA']['tt_content']['types']['tx_mpdbpresentation_mpdbresearch'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
header; Title,
bodytext;LLL:EXT:core/Resources/Private/Language/Form/locallang_ttc.xlf:bodytext_formlabel,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;acces,
',
'columnsOverrides' => [
'bodytext' => [
'config' => [
'enableRichtext' => true,
'richtextConfiguration' => 'default'
]
]
]
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']['tx_mpdbpresentation_mpdbwelcome'] = 'mpdb_wel_icon';

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'] = [
'mpdbpresentation_mpdbwelcome' => 'bodytext'
];
11 changes: 11 additions & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ plugin.tx_mpdbpresentation_mpdbapi {
}
}

plugin.tx_mpdbpresentation_mpdbwelcome {
view {
# cat=plugin.tx_mpdbpresentation_mpdbwelcome/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:mpdb_presentation/Resources/Private/Templates/
# cat=plugin.tx_mpdbpresentation_mpdbwelcome/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:mpdb_presentation/Resources/Private/Partials/
# cat=plugin.tx_mpdbpresentation_mpdbwelcome/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:mpdb_presentation/Resources/Private/Layouts/
}
}

plugin.tx_mpdbpresentation_mpdbresearch {
view {
# cat=plugin.tx_mpdbpresentation_mpdbresearch/file; type=string; label=Path to template root (FE)
Expand Down
33 changes: 33 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,39 @@ plugin.tx_mpdbpresentation_mpdbresearch {
teamPage {
pid = {$config.teamPage.pid}
}
guidelinePage {
pid = {$config.guidelinePage.pid}
}
abbrPage {
pid = {$config.abbrPage.pid}
}
}
}

plugin.tx_mpdbpresentation_mpdbwelcome {
view {
templateRootPaths.0 = EXT:tx_mpdb_presentation/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_mpdbpresentation_mpdbwelcome.view.templateRootPath}
partialRootPaths.0 = EXT:tx_mpdb_presentation/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_mpdbpresentation_mpdbwelcome.view.partialRootPath}
layoutRootPaths.0 = EXT:tx_mpdb_presentation/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_mpdbpresentation_mpdbwelcome.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_mpdbpresentation_mpdbwelcome.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
# Should be on by default, but can be disabled if all action in the plugin are uncached
requireCHashArgumentForActionArguments = 1
}
settings {
researchPage {
pid = {$config.researchPage.pid}
}
}
}

Expand Down
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Presentation Module of the Music Publisher Database
===================================================

[![TYPO3 11](https://img.shields.io/badge/TYPO3-11-orange.svg)](https://get.typo3.org/version/11)
[![CC-BY](https://img.shields.io/github/license/slub/mpdb_presentation)](https://github.com/slub/mpdb_presentation/blob/main/LICENSE)

This package provides a set of presentation tools for the music publisher database.

# Presentation plugin

After installing the extension, create a new content element of type "Insert Plugin" and choose "Music publisher database research plugin" in the Plugin tab.
To get your data into the elasticsearch indices, run the following commands:

```bash
$ typo3 mpdb_presentation:indexpublishers
$ typo3 mpdb_presentation:calculatetables
```

# Welcome plugin

The extension comes with a welcome plugin which displays a text that may be set in the "Plugin" tab of the plugin properties.
Inside that text, you can use `{{ count }}` to get the number of published items in your elasticsearch index and `{{ publishers }}` to get a localized list of the publishers in the index.
A sample text may look like

```txt
Willkommen auf der Homepage der mvdb.
Die Musikverlagsdatenbank enthält {{ count }} Datensätze zu Ausgaben der Musikverlage {{ publishers }}. Die Daten wurden anhand der Geschäftsbücher der Verlage erschlossen, und enthalten neben Angaben zu Verlagsnummern und Druckauflagen auch bibliograhischen Normdateninformationen der GND.
Nach welcher Ausgabe suchen Sie?
(Achtung: Bitte beachten Sie die Hinweise zu Verlässlichkeit, Umfang und Interpretation der Daten in den Datenerfassungsrichtlinien.)
```

# Plugin configuration

In order to get all links and redirects running, you need to provide your researchPage, teamPage, guidelinePage and abbrPage as constants in your Typoscript template as well as the storagePid.
An example configuration is here:

```txt
config {
researchPage {
pid =
}
teamPage {
pid =
}
guidelinePage {
pid =
}
abbrPage {
pid =
}
}
plugin.tx_mpdbpresentation_mpdbresearch.persistence.storagePid =
```

# Maintainer

If you have any questions or encounter any problems, please do not hesitate to contact me.
- [Matthias Richter](https://github.com/dikastes)
12 changes: 12 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
<source>The research plugin of the Music Publisher Database.</source>
<target>Das Rechercheplugin der Musikverlagsdatenbank.</target>
</trans-unit>
<trans-unit id="welcome_title" resname="welcome_title">
<source>Music Publisher Database Welcome</source>
<target>Musikverlagsdatenbank Willkommen</target>
</trans-unit>
<trans-unit id="welcome_description" resname="welcome_description">
<source>The welcome plugin of the Music Publisher Database.</source>
<target>Das Begrüßungsplugin der Musikverlagsdatenbank</target>
</trans-unit>
<trans-unit id="mpdbresearch.person">
<source>Person</source>
<target>Person</target>
Expand Down Expand Up @@ -152,6 +160,10 @@
<source>The type of the published item indicates, whether it is a simple work print, a collection print, a version or something else.</source>
<target>Der Typ des Verlagsartikels gibt an, ob es sich um einen einfachen Werkdruck, einen Sammeldruck, eine Bearbeitung oder etwas anderes handelt.</target>
</trans-unit>
<trans-unit id="and">
<source>and</source>
<target>und</target>
</trans-unit>
</body>
</file>
</xliff>
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<trans-unit id="start_description" resname="start_description">
<source>The research plugin of the Music Publisher Database.</source>
</trans-unit>
<trans-unit id="welcome_title" resname="welcome_title">
<source>Music Publisher Database Welcome</source>
</trans-unit>
<trans-unit id="welcome_description" resname="welcome_description">
<source>The welcome plugin of the Music Publisher Database.</source>
</trans-unit>
<trans-unit id="mpdbresearch.person">
<source>Person</source>
</trans-unit>
Expand Down Expand Up @@ -102,6 +108,9 @@
<trans-unit id="mpdbresearch.typeTooltip">
<source>The type of the published item indicates, whether it is a simple work print, a collection print, a version or something else.</source>
</trans-unit>
<trans-unit id="and">
<source>and</source>
</trans-unit>
</body>
</file>
</xliff>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Index/IndexPicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ul class="index-picker">
<f:for each="{indices}" as="index" key="key">
<f:variable name="searchconfig">{mpdbpres:setConfig(config:searchconfig,key:'index',value:key)}</f:variable>
<f:if condition="{index.translation}=={config.index}">
<f:if condition="{key}=={config.index}">
<f:then>
<li class="active">
<f:link.action action="search" arguments="{config:searchconfig}">
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Index/SearchSlot.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{namespace mpdbpres=Slub\MpdbPresentation\ViewHelpers}

<f:form action="search" controller="Index" class="form-inline">
<f:form action="search" controller="Index" class="form-inline" pluginName="mpdbresearch" pageUid="{settings.researchPage.pid}">
<div class="input-group">
<f:form.textfield name="config[searchTerm]" class="input-group-field" value="{config.searchTerm}" placeholder="{f:translate(key:'mpdbresearch.search')}" id="main-search" />
<div class="input-group-button">
Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Templates/PublishedItem/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ <h2>
</div>
</div>
<div class="graph-container">
<p> {publishedItem.publicComment} </p>
<f:if condition="{publisherActions.0}">
<f:then>
<div id="{graphTarget}"></div>
Expand Down
19 changes: 19 additions & 0 deletions Resources/Private/Templates/Welcome/Welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{namespace mpdbpres=Slub\MpdbPresentation\ViewHelpers}

<f:layout name="Research" />

<f:section name="wrap">
</f:section>

<f:section name="sidebar">
</f:section>

<f:section name="content">

<p class="welcome-text">
{processedText}
</p>

</f:section>
Loading

0 comments on commit 1242101

Please sign in to comment.