-
Notifications
You must be signed in to change notification settings - Fork 2
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 2516ef2
Showing
13 changed files
with
426 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,78 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
charset = utf-8 | ||
|
||
# Get rid of whitespace to avoid diffs with a bunch of EOL changes | ||
trim_trailing_whitespace = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# CSS-Files | ||
[*.css] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# HTML-Files | ||
[*.html] | ||
indent_style = tab | ||
indent_size = 2 | ||
|
||
# TMPL-Files | ||
[*.tmpl] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# LESS-Files | ||
[*.less] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# JS-Files | ||
[*.js] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# JSON-Files | ||
[*.json] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# PHP-Files | ||
[*.php] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# ReST-Files | ||
[*.rst] | ||
indent_style = space | ||
indent_size = 3 | ||
|
||
# MD-Files | ||
[*.md] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# package.json or .travis.yml | ||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# TypoScript | ||
[*.ts] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# XLF-Files | ||
[*.xlf] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# SQL-Files | ||
[*.sql] | ||
indent_style = tab | ||
indent_size = 2 |
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,35 @@ | ||
<?php | ||
|
||
namespace Monosize\LinkHandler\Plus\Hooks; | ||
|
||
use TYPO3\CMS\Core\SingletonInterface; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; | ||
use TYPO3\CMS\Frontend\Service\TypoLinkCodecService; | ||
|
||
class TypoLinkHandler implements SingletonInterface | ||
{ | ||
/** | ||
* @return array | ||
* | ||
* @param string $linkText | ||
* @param array $configuration | ||
* @param string $linkHandlerKeyword | ||
* @param string $linkHandlerValue | ||
* @param string $mixedLinkParameter | ||
* @param $cObj ContentObjectRenderer | ||
*/ | ||
public function main($linkText, $configuration, $linkHandlerKeyword, $linkHandlerValue, $mixedLinkParameter, $cObj) | ||
{ | ||
|
||
$linkParameterParts = GeneralUtility::makeInstance(TypoLinkCodecService::class)->decode($mixedLinkParameter); | ||
|
||
return [ | ||
'href' => 'unknown:' . $linkHandlerKeyword . ':' . $linkHandlerValue, | ||
'target' => $linkParameterParts['target'], | ||
'class' => $linkParameterParts['class'], | ||
'title' => $linkParameterParts['title'] | ||
]; | ||
} | ||
|
||
} |
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,30 @@ | ||
<?php | ||
namespace Monosize\LinkHandler\Plus\LinkHandling; | ||
|
||
use TYPO3\CMS\Core\LinkHandling\LinkHandlingInterface; | ||
|
||
class TelLinkHandler implements LinkHandlingInterface | ||
{ | ||
|
||
/** | ||
* Returns the link to an tel as a string | ||
* | ||
* @param array $parameters | ||
* @return string | ||
*/ | ||
public function asString(array $parameters): string | ||
{ | ||
return 'tel:' . $parameters['tel']; | ||
} | ||
|
||
/** | ||
* Returns the email address without the "tel:" prefix | ||
* in the 'tel' property of the array. | ||
* | ||
* @param array $data | ||
* @return array | ||
*/ | ||
public function resolveHandlerData(array $data): array | ||
{ | ||
return ['tel' => substr($data['tel'], 4)]; | ||
}} |
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,133 @@ | ||
<?php | ||
namespace Monosize\LinkHandler\Plus\Recordlist\LinkHandler; | ||
|
||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use TYPO3\CMS\Core\Page\PageRenderer; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\PathUtility; | ||
use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController; | ||
use TYPO3\CMS\Recordlist\LinkHandler\AbstractLinkHandler; | ||
use TYPO3\CMS\Recordlist\LinkHandler\LinkHandlerInterface; | ||
|
||
/** | ||
* Link handler for email links | ||
*/ | ||
class TelLinkHandler extends AbstractLinkHandler implements LinkHandlerInterface | ||
{ | ||
/** | ||
* Parts of the current link | ||
* | ||
* @var array | ||
*/ | ||
protected $linkParts = []; | ||
|
||
/** | ||
* We don't support updates since there is no difference to simply set the link again. | ||
* | ||
* @var bool | ||
*/ | ||
protected $updateSupported = false; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
// remove unsupported link attributes | ||
foreach (['target', 'rel'] as $attribute) { | ||
$position = array_search($attribute, $this->linkAttributes, true); | ||
if ($position !== false) { | ||
unset($this->linkAttributes[$position]); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Initialize the handler | ||
* | ||
* @param AbstractLinkBrowserController $linkBrowser | ||
* @param string $identifier | ||
* @param array $configuration Page TSconfig | ||
* | ||
* @return void | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function initialize(AbstractLinkBrowserController $linkBrowser, $identifier, array $configuration) | ||
{ | ||
parent::initialize($linkBrowser, $identifier, $configuration); | ||
$this->view->setTemplateRootPaths([ | ||
GeneralUtility::getFileAbsFileName('EXT:recordlist/Resources/Private/Templates/LinkBrowser'), | ||
GeneralUtility::getFileAbsFileName('EXT:linkhandler_plus/Resources/Private/Templates/LinkBrowser') | ||
]); | ||
|
||
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); | ||
$fullJsPath = PathUtility::getRelativePath( | ||
PATH_typo3, | ||
GeneralUtility::getFileAbsFileName('EXT:linkhandler_plus/Resources/Public/JavaScript/') | ||
); | ||
|
||
// requirejs | ||
$pageRenderer->addRequireJsConfiguration([ | ||
'paths' => [ | ||
'LinkhandlerPlus/RecordList/TelLinkHandler' => $fullJsPath . 'RecordList/TelLinkHandler', | ||
], | ||
]); | ||
|
||
} | ||
|
||
/** | ||
* Checks if this is the handler for the given link | ||
* | ||
* The handler may store this information locally for later usage. | ||
* | ||
* @param array $linkParts Link parts as returned from TypoLinkCodecService | ||
* | ||
* @return bool | ||
*/ | ||
public function canHandleLink(array $linkParts) | ||
{ | ||
if ($linkParts['type'] === 'tel' && isset($linkParts['url']['url'])) { | ||
$this->linkParts = $linkParts; | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Format the current link for HTML output | ||
* | ||
* @return string | ||
*/ | ||
public function formatCurrentUrl() | ||
{ | ||
return $this->linkParts['url']['url']; | ||
} | ||
|
||
/** | ||
* Render the link handler | ||
* | ||
* @param ServerRequestInterface $request | ||
* | ||
* @return string | ||
*/ | ||
public function render(ServerRequestInterface $request) | ||
{ | ||
GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule('TYPO3/CMS/LinkhandlerPlus/RecordList/TelLinkHandler'); | ||
|
||
$this->view->assign('tel', !empty($this->linkParts) ? $this->linkParts['url']['url'] : ''); | ||
|
||
return $this->view->render('Tel'); | ||
} | ||
|
||
/** | ||
* @return string[] Array of body-tag attributes | ||
*/ | ||
public function getBodyTagAttributes() | ||
{ | ||
return []; | ||
} | ||
} |
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 @@ | ||
TCEMAIN.linkHandler { | ||
tel { | ||
handler = Monosize\LinkHandler\Plus\Recordlist\LinkHandler\TelLinkHandler | ||
label = LLL:EXT:linkhandler_plus/Resources/Private/Language/locallang_browse_links.xlf:tel | ||
displayBefore = url | ||
scanBefore = url | ||
} | ||
} |
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,16 @@ | ||
# TYPO3 CMS LinkHandler Plus | ||
|
||
A LinkHandler extension to link to **tel:** urls. | ||
## Installation | ||
|
||
``` | ||
composer require monosize/linkhandler-plus | ||
``` | ||
|
||
## Configuration | ||
|
||
Nothing to do. | ||
|
||
## License | ||
|
||
GPLv2+ |
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 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | ||
<xliff version="1.0"> | ||
<file source-language="en" datatype="plaintext" original="messages" product-name="linkhandler_plus" date="2017-02-27T20:24:41+01:00"> | ||
<header/> | ||
<body> | ||
<trans-unit id="tel"> | ||
<source>Telephone</source> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
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,13 @@ | ||
<div class="link-browser-section link-browser-tab-content-tel"> | ||
<form action="" id="ltelform" class="form-horizontal"> | ||
<div class="form-group form-group-sm"> | ||
<label class="col-xs-4 control-label"><f:translate key="LLL:EXT:linkhandler_plus/Resources/Private/Language/locallang_browse_links.xlf:tel" /></label> | ||
<div class="col-xs-6"> | ||
<input type="text" name="ltel" size="20" class="form-control" value="{tel}" /> | ||
</div> | ||
<div class="col-xs-2"> | ||
<input class="btn btn-default" type="submit" value="{f:translate(key: 'LLL:EXT:lang/Resources/Private/Language/locallang_browse_links.xlf:setLink')}" /> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |
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,34 @@ | ||
|
||
/** | ||
* Module: LinkhandlerPlus/RecordList/TelLinkHandler | ||
* Tel link interaction | ||
*/ | ||
define(['jquery', 'TYPO3/CMS/Recordlist/LinkBrowser'], function($, LinkBrowser) { | ||
'use strict'; | ||
|
||
/** | ||
* | ||
* @type {{}} | ||
* @exports LinkhandlerPlus/RecordList/TelLinkHandler | ||
*/ | ||
var TelLinkHandler = {}; | ||
|
||
$(function() { | ||
$('#ltelform').on('submit', function(event) { | ||
event.preventDefault(); | ||
|
||
var value = $(this).find('[name="ltel"]').val(); | ||
if (value === 'tel:') { | ||
return; | ||
} | ||
|
||
while (value.substr(0, 4) === 'tel:') { | ||
value = value.substr(4); | ||
} | ||
|
||
LinkBrowser.finalizeFunction('tel:' + value); | ||
}); | ||
}); | ||
|
||
return TelLinkHandler; | ||
}); |
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 @@ | ||
{ | ||
"name": "monosize/linkhandler-plus", | ||
"description": "Extended the Linkhandler to handle tel: url's", | ||
"keywords": ["typo3", "linkhandler", "telephone"], | ||
"homepage": "https://typo3.org/", | ||
"type": "typo3-cms-extension", | ||
"version": "0.1.0", | ||
"license": "GPL-2.0+", | ||
"authors": [ | ||
{ | ||
"name": "Frank Rakow", | ||
"email": "frank.rakow@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"typo3/cms": "^8.6" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Monosize\\LinkHandler\\Plus": "Classes/" | ||
} | ||
}, | ||
"extra": { | ||
"installer-name": "linkhandler_plus", | ||
"typo3/cms": { | ||
"extensionKey": "linkhandler_plus" | ||
} | ||
} | ||
} |
Oops, something went wrong.