-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f544e51
Showing
21 changed files
with
5,617 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"> | ||
<config name="installed_paths" value="../../slevomat/coding-standard" /> | ||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="PSR12"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="Generic.Files.LineLength"> | ||
<type>warning</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"> | ||
<type>warning</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"> | ||
<type>error</type> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"> | ||
<type>error</type> | ||
<properties> | ||
<property name="ignoreSpacesInComment" value="true" /> | ||
</properties> | ||
</rule> | ||
<rule ref="Squiz.Strings.DoubleQuoteUsage"> | ||
<type>error</type> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: remindgmbh/commitlint-action@v1.0.0 | ||
phpcs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.2 | ||
extensions: intl | ||
tools: composer:v2 | ||
- run: composer install | ||
- run: composer run-script phpcs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: remindgmbh/semantic-release-action@v2.2.0 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### IDE ### | ||
nbproject/ | ||
.idea/ | ||
|
||
### Composer ### | ||
composer.phar | ||
|
||
### Node ### | ||
node_modules/ | ||
|
||
### General ### | ||
*.log | ||
cache.properties | ||
|
||
### CI ### | ||
.build/bin/ | ||
.build/vendor/ | ||
.build/web/ | ||
.build/logs/ | ||
.build/coverage/ | ||
.build/pdepend/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"recommendations": [ | ||
"benjaminkott.typo3-typoscript", | ||
"devsense.phptools-vscode", | ||
"obliviousharmony.vscode-php-codesniffer" | ||
], | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"phpCodeSniffer.exec.linux": "./.build/bin/phpcs", | ||
"phpCodeSniffer.standard": "Custom", | ||
"phpCodeSniffer.standardCustom": "./.build/phpcs.xml", | ||
"phpCodeSniffer.exclude": [ | ||
"**/vendor/{,!(remind)/**}" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Remind\MatomoLinkHandler\LinkHandler; | ||
|
||
use TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder; | ||
use TYPO3\CMS\Frontend\Typolink\LinkResult; | ||
use TYPO3\CMS\Frontend\Typolink\LinkResultInterface; | ||
|
||
class LinkBuilder extends AbstractTypolinkBuilder | ||
{ | ||
private const TYPE_MATOMO = 'matomo'; | ||
|
||
public function build( | ||
array &$linkDetails, | ||
string $linkText, | ||
string $target, | ||
array $conf, | ||
): LinkResultInterface { | ||
$action = $linkDetails['action']; | ||
$url = 't3://matomo?action=' . $action; | ||
|
||
return (new LinkResult(self::TYPE_MATOMO, $url)) | ||
->withTarget($target) | ||
->withLinkConfiguration($conf) | ||
->withLinkText($linkText); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Remind\MatomoLinkHandler\LinkHandler; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use TYPO3\CMS\Backend\Controller\AbstractLinkBrowserController; | ||
use TYPO3\CMS\Backend\LinkHandler\LinkHandlerInterface; | ||
use TYPO3\CMS\Core\Page\PageRenderer; | ||
use TYPO3\CMS\Core\View\ViewInterface; | ||
|
||
class LinkHandler implements LinkHandlerInterface | ||
{ | ||
protected array $linkAttributes = ['title']; | ||
|
||
protected array $linkParts = []; | ||
|
||
protected ViewInterface $view; | ||
|
||
protected array $configuration; | ||
|
||
public function __construct( | ||
private readonly PageRenderer $pageRenderer | ||
) { | ||
} | ||
|
||
public function initialize(AbstractLinkBrowserController $linkBrowser, $identifier, array $configuration) | ||
{ | ||
$this->configuration = $configuration; | ||
} | ||
|
||
public function canHandleLink(array $linkParts): bool | ||
{ | ||
if ($linkParts['type'] !== 'matomo') { | ||
return false; | ||
} | ||
$this->linkParts = $linkParts['url'] ?? []; | ||
return true; | ||
} | ||
|
||
public function formatCurrentUrl(): string | ||
{ | ||
return 't3://matomo?action=' . $this->linkParts['action'] ?? ''; | ||
} | ||
|
||
public function render(ServerRequestInterface $request): string | ||
{ | ||
$this->pageRenderer->loadJavaScriptModule('@remind/matomo-link-handler/link_handler.js'); | ||
$this->view->assign('linkParts', $this->linkParts); | ||
$this->view->assign('action', $this->linkParts['action'] ?? ''); | ||
|
||
return $this->view->render('LinkBrowser/Matomo'); | ||
} | ||
|
||
public function getBodyTagAttributes(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function getLinkAttributes() | ||
{ | ||
return $this->linkAttributes; | ||
} | ||
|
||
public function modifyLinkAttributes(array $fieldDefinitions) | ||
{ | ||
return $fieldDefinitions; | ||
} | ||
|
||
public function isUpdateSupported() | ||
{ | ||
return false; | ||
} | ||
|
||
public function setView(ViewInterface $view): void | ||
{ | ||
$this->view = $view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Remind\MatomoLinkHandler\LinkHandler; | ||
|
||
use TYPO3\CMS\Core\LinkHandling\LinkHandlingInterface; | ||
|
||
class LinkHandling implements LinkHandlingInterface | ||
{ | ||
protected $baseUrn = 't3://matomo'; | ||
|
||
public function asString(array $parameters): string | ||
{ | ||
return $this->baseUrn . '?action=' . $parameters['action']; | ||
} | ||
|
||
public function resolveHandlerData(array $data): array | ||
{ | ||
return [ | ||
'action' => $data['action'] ?? '', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
'dependencies' => ['core', 'backend'], | ||
'tags' => [ | ||
'backend.contextmenu', | ||
], | ||
'imports' => [ | ||
'@remind/matomo-link-handler/' => 'EXT:rmnd_matomo_link_handler/Resources/Public/JavaScript/', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
Remind\MatomoLinkHandler\LinkHandler\LinkHandler: | ||
shared: false | ||
public: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
TCEMAIN.linkHandler { | ||
matomo { | ||
handler = Remind\MatomoLinkHandler\LinkHandler\LinkHandler | ||
label = LLL:EXT:rmnd_matomo_link_handler/Resources/Private/Language/locallang.xlf:title | ||
displayAfter = url | ||
scanBefore = url | ||
configuration { | ||
project = TYPO3-Documentation/TYPO3CMS-Reference-CoreApi | ||
action = issues | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
templates { | ||
typo3/cms-backend { | ||
1713438106 = remind/matomo-link-handler:Resources/Private | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'EXT:rmnd_matomo_link_handler/Configuration/TSConfig/Page/*.tsconfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> | ||
<xliff version="1.0"> | ||
<file source-language="en" datatype="plaintext"> | ||
<header/> | ||
<body> | ||
<trans-unit id="action"> | ||
<source>Action</source> | ||
</trans-unit> | ||
<trans-unit id="opt-in"> | ||
<source>Opt-In</source> | ||
</trans-unit> | ||
<trans-unit id="opt-out"> | ||
<source>Opt-Out</source> | ||
</trans-unit> | ||
<trans-unit id="title"> | ||
<source>Matomo</source> | ||
</trans-unit> | ||
<trans-unit id="toggle"> | ||
<source>Toggle</source> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
32 changes: 32 additions & 0 deletions
32
Resources/Private/Templates/Default/LinkBrowser/Matomo.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<html | ||
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
data-namespace-typo3-fluid="true" | ||
> | ||
|
||
<f:layout name="LinkBrowser" /> | ||
|
||
<f:section name="Content"> | ||
<form class="form" action="" id="lmatomoform"> | ||
<div class="element-browser-form-group"> | ||
<label for="lmatomo" class="form-label"> | ||
<f:translate key="LLL:EXT:rmnd_matomo_link_handler/Resources/Private/Language/locallang.xlf:action" /> | ||
</label> | ||
<div class="input-group"> | ||
<select name="lmatomo" class="form-select" id="lmatomo" reqiured> | ||
<option value="opt-out" {f:if(condition: '{action} === "opt-out"', then: 'selected')}> | ||
<f:translate key="LLL:EXT:rmnd_matomo_link_handler/Resources/Private/Language/locallang.xlf:opt-out" /> | ||
</option> | ||
<option value="opt-in" {f:if(condition: '{action} === "opt-in"', then: 'selected')}> | ||
<f:translate key="LLL:EXT:rmnd_matomo_link_handler/Resources/Private/Language/locallang.xlf:opt-in" /> | ||
</option> | ||
<option value="toggle" {f:if(condition: '{action} === "toggle"', then: 'selected')}> | ||
<f:translate key="LLL:EXT:rmnd_matomo_link_handler/Resources/Private/Language/locallang.xlf:toggle" /> | ||
</option> | ||
</select> | ||
<input class="btn btn-primary" type="submit" value="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_browse_links.xlf:setLink')}" /> | ||
</div> | ||
</div> | ||
</form> | ||
</f:section> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import LinkBrowser from "@typo3/backend/link-browser.js"; | ||
|
||
class LinkHandler { | ||
constructor() { | ||
var form_el = document.getElementById("lmatomoform"); | ||
form_el.addEventListener("submit", function(event) { | ||
event.preventDefault(); | ||
var value = document.getElementById('lmatomo').value; | ||
LinkBrowser.finalizeFunction('t3://matomo?action=' + value); | ||
}); | ||
} | ||
} | ||
|
||
export default new LinkHandler(); |
Oops, something went wrong.