Commit f403a5bb authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

[FEATURE] Initial commit

parents
<?php
namespace SGalinski\SgContentlink\TCA;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\SingletonInterface;
/**
* This class contains methods for usage within the TCA forms.
*/
class TcaProvider implements SingletonInterface{
/**
* This are the values of the column CType of the table tt_content
*
* @var array
*/
protected static $allowedTypesForContentLink = [
'header' => 'header',
'text' => 'text',
'textpic' => 'textpic',
'image' => 'image',
'bullets' => 'bullets',
'table' => 'table',
'uploads' => 'uploads',
'media' => 'media',
'menu' => 'menu',
'shortcut' => 'shortcut',
'list' => 'list',
'fluidcontent_content' => 'fluidcontent_content',
];
public static function getAllowedTypesForTcaDisplayCond() {
$conditions = [];
foreach (self::$allowedTypesForContentLink as $allowedTypeForContentLink) {
$conditions[] = 'FIELD:CType:=:' . $allowedTypeForContentLink;
}
return [
'OR' => $conditions,
];
}
/**
* @return array
*/
public static function getAllowedTypesForContentLink() {
return self::$allowedTypesForContentLink;
}
/**
* @param array $allowedTypesForContentLink
*/
public static function setAllowedTypesForContentLink($allowedTypesForContentLink) {
self::$allowedTypesForContentLink = $allowedTypesForContentLink;
}
/**
* @param string $allowedTypeForContentLink
*/
public static function addAllowedTypeForContentLink($allowedTypeForContentLink) {
self::$allowedTypesForContentLink[$allowedTypeForContentLink] = $allowedTypeForContentLink;
}
/**
* @param string $allowedTypeForContentLink
*/
public static function removeAllowedTypeForContentLink($allowedTypeForContentLink) {
unset(self::$allowedTypesForContentLink[$allowedTypeForContentLink]);
}
}
?>
\ No newline at end of file
<?php
namespace SGalinski\SgContentlink\UserFunc;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Class for user functions that modifies the content element rendering.
*/
class ContentElementRendering {
/**
* @var ContentObjectRenderer
*/
public $cObj;
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
*/
protected $uriBuilder;
/**
* Construct for this user function
*/
public function __construct() {
$this->objectManager = $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->uriBuilder = $this->objectManager->get('TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder');
}
/**
* Adds parameters to the current content element.
*
* @param string $content
* @return string
*/
public function wrapContentLinkAroundContent($content) {
if (!$this->cObj->data || !$this->cObj->data['tx_sgcontentlink_contentlink']) {
return $content;
}
// Creation of the content link
$contentLink = $this->cObj->data['tx_sgcontentlink_contentlink'];
$contentLinkPageId = (int) $contentLink;
if ($contentLinkPageId > 0) {
$contentLink = $this->uriBuilder->reset()->setTargetPageUid($contentLinkPageId)->build();
} elseif ((stripos($contentLink, 'http://') === false) && (stripos($contentLink, 'https://') === false)) {
$contentLink = 'http://' . $contentLink;
}
if (!$contentLink) {
return $content;
}
// Removal of all links
$content = preg_replace('/<a.+?>/is', '', $content);
$content = str_replace('</a>', '', $content);
return $this->cObj->wrap($content, '<a href="' . $contentLink . '"> | </a>');
}
}
\ No newline at end of file
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content', [
'tx_sgcontentlink_contentlink' => [
'displayCond' => \SGalinski\SgContentlink\TCA\TcaProvider::getAllowedTypesForTcaDisplayCond(),
'exclude' => 1,
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:sg_contentlink/Resources/Private/Language/locallang_db.xlf:tt_content.tx_sgcontentlink_contentlink',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim',
'wizards' => [
'_PADDING' => 2,
'link' => [
'type' => 'popup',
'title' => 'LLL:EXT:cms/locallang_ttc.xlf:header_link_formlabel',
'icon' => 'link_popup.gif',
'module' => [
'name' => 'wizard_element_browser',
'urlParameters' => [
'mode' => 'wizard'
]
],
'params' => [
'blindLinkOptions' => 'folder, file, mail, spec',
'blindLinkFields' => 'target,title,class,params'
],
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
]
],
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content', '--linebreak--,tx_sgcontentlink_contentlink', '', 'after:sys_language_uid'
);
?>
\ No newline at end of file
# Change page rendering with user function
tt_content.stdWrap.postUserFunc = SGalinski\SgContentlink\UserFunc\ContentElementRendering->wrapContentLinkAroundContent
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2015-03-09T14:37:30Z">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'sg_contentlink'</description>
<generator>LFEditor</generator>
<authorName>Fabian Galinski</authorName>
<authorEmail>fabian@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="tt_content.tx_sgcontentlink_contentlink" approved="yes" xml:space="preserve">
<source>Contentelement link (Sets a link around this content. Could be a page uid)</source>
Please register or sign in to reply
<target>Inhaltselement-Link (Setzt einen Link um dieses Inhaltselement. Kann eine Seiten-Uid sein)</target>
Please register or sign in to reply
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2015-03-09T14:37:30Z">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'sg_contentlink'</description>
<generator>LFEditor</generator>
<authorName>Fabian Galinski</authorName>
<authorEmail>fabian@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="tt_content.tx_sgcontentlink_contentlink" xml:space="preserve">
<source>Contentelement link (Sets a link around this content. Could be a page uid)</source>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?php
$EM_CONF[$_EXTKEY] = array(
'title' => 'sgalinski Contentlink',
'description' => 'Possibility to set a link around a whole content element by sgalinski. Include static template.',
'category' => 'plugin',
'author' => 'Fabian Galinski',
'author_email' => 'fabian@sgalinski.de',
'author_company' => 'sgalinski Internet Services',
'shy' => '',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '1.0.0',
'constraints' => array(
'depends' => array(
'typo3' => '6.2.0-6.2.99',
'php' => '5.4.0-5.5.99',
),
'conflicts' => array(),
'suggests' => array(),
),
'suggests' => array(),
'_md5_values_when_last_written' => '',
);
?>
\ No newline at end of file
ext_icon.png

825 Bytes

<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
\ No newline at end of file
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'sg_contentlink', 'Configuration/TypoScript/Frontend', 'Contentlink'
);
\ No newline at end of file
CREATE TABLE tt_content (
tx_sgcontentlink_contentlink text NOT NULL,
);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment