From d8114dfde9a877126e061ba0cf88b64871955006 Mon Sep 17 00:00:00 2001 From: Pascal Rinker Date: Fri, 2 Feb 2018 16:33:22 +0100 Subject: [PATCH] initial commit --- .../Hooks/TypoScriptFrontendController.php | 59 ++++++++++++++++++ Documentation/Configuration/Index.rst | 27 ++++++++ Documentation/Includes.txt | 21 +++++++ Documentation/Index.rst | 58 +++++++++++++++++ Documentation/Links.rst | 21 +++++++ Documentation/Settings.yml | 32 ++++++++++ composer.json | 28 +++++++++ ext_emconf.php | 21 +++++++ ext_icon.gif | Bin 0 -> 369 bytes ext_localconf.php | 6 ++ 10 files changed, 273 insertions(+) create mode 100644 Classes/Hooks/TypoScriptFrontendController.php create mode 100644 Documentation/Configuration/Index.rst create mode 100644 Documentation/Includes.txt create mode 100644 Documentation/Index.rst create mode 100644 Documentation/Links.rst create mode 100644 Documentation/Settings.yml create mode 100644 composer.json create mode 100644 ext_emconf.php create mode 100644 ext_icon.gif create mode 100644 ext_localconf.php diff --git a/Classes/Hooks/TypoScriptFrontendController.php b/Classes/Hooks/TypoScriptFrontendController.php new file mode 100644 index 0000000..ace93c8 --- /dev/null +++ b/Classes/Hooks/TypoScriptFrontendController.php @@ -0,0 +1,59 @@ +content + * You must set the Search and Replace patterns via TypoScript. + * usage from TypoScript: + * config.tx_replacer { + * search { + * 1="/typo3temp/pics/ + * 2="/fileadmin/ + * } + * replace { + * 1="http://mycdn.com/i/ + * 2="http://mycdn.com/f/ + * } + * } + * + * @param array $params + * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $ref + * @return void + */ + public function contentPostProcOutput( + array &$params, + \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $ref + ) { + if ( + !empty($ref->config['config']['tx_replacer.']['search.']) + && !empty($ref->config['config']['tx_replacer.']['replace.']) + ) { + $ref->content = str_replace( + $ref->config['config']['tx_replacer.']['search.'], + $ref->config['config']['tx_replacer.']['replace.'], + $ref->content + ); + } + } +} diff --git a/Documentation/Configuration/Index.rst b/Documentation/Configuration/Index.rst new file mode 100644 index 0000000..c07ccda --- /dev/null +++ b/Documentation/Configuration/Index.rst @@ -0,0 +1,27 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: ../Includes.txt + + +.. _configuration: + +Configuration +======================= + +The configuration of ext:replacer is that easy. The whole configuration will be made inside your TypoScript Setup. + +**Example:** :: + + config.tx_replacer { + search { + 1="/typo3temp/pics/ + 2="/fileadmin/ + } + replace { + 1="http://cd/i/ + 2="http://mycdn.com/f/ + } + } diff --git a/Documentation/Includes.txt b/Documentation/Includes.txt new file mode 100644 index 0000000..a111144 --- /dev/null +++ b/Documentation/Includes.txt @@ -0,0 +1,21 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. This is 'Includes.txt'. It is included at the very top of each and + every ReST source file in this documentation project (= manual). + + +.. ================================================== +.. DEFINE SOME TEXT ROLES +.. -------------------------------------------------- + +.. role:: typoscript(code) + +.. role:: ts(typoscript) + :class: typoscript + +.. role:: php(code) + +.. highlight:: php diff --git a/Documentation/Index.rst b/Documentation/Index.rst new file mode 100644 index 0000000..f4a2f4e --- /dev/null +++ b/Documentation/Index.rst @@ -0,0 +1,58 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: Includes.txt + +.. _start: + +============================================================= +replacer +============================================================= + +.. only:: html + + :Classification: + replacer + + :Version: + |release| + + :Language: + en + + :Description: + Replaces string patterns from the page. You can use it to replace URLs for Content Delivery Network (CDN). + + :Keywords: + replacer,replacement,ja_replacer + + :Copyright: + 2018 + + :Author: + Pascal Rinker + + :Email: + projects@jweiland.net + + :License: + This document is published under the Open Content License + available from http://www.opencontent.org/opl.shtml + + :Rendered: + |today| + + The content of this document is related to TYPO3, + a GNU/GPL CMS/Framework available from `www.typo3.org `_. + + This extension is a fork of ja_replacer + + **Table of Contents** + +.. toctree:: + :maxdepth: 3 + :titlesonly: + + Configuration/Index diff --git a/Documentation/Links.rst b/Documentation/Links.rst new file mode 100644 index 0000000..46517cb --- /dev/null +++ b/Documentation/Links.rst @@ -0,0 +1,21 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: Includes.txt + + +.. _links: + +Links +----- + +:TER: + https://typo3.org/extensions/repository/view/replacer + +:Bug Tracker: + https://github.com/jweiland-net/replacer/issues + +:Git Repository: + https://github.com/jweiland-net/replacer diff --git a/Documentation/Settings.yml b/Documentation/Settings.yml new file mode 100644 index 0000000..aead930 --- /dev/null +++ b/Documentation/Settings.yml @@ -0,0 +1,32 @@ +# This is the project specific Settings.yml file. +# Place Sphinx specific build information here. +# Settings given here will replace the settings of 'conf.py'. + +# Below is an example of intersphinx mapping declaration +# Add more mappings depending on what manual you want to link to +# Remove entirely if you don't need cross-linking + +--- +conf.py: + copyright: 2018 + project: replacer + version: 1.0.0 + release: 1.0.0 + intersphinx_mapping: + t3tsref: + - http://docs.typo3.org/typo3cms/TyposcriptReference/ + - null + latex_documents: + - - Index + - replacer.tex + - replacer + - + - manual + latex_elements: + papersize: a4paper + pointsize: 10pt + preamble: \usepackage + html_theme_options: + github_repository: TYPO3-Documentation/TYPO3CMS-Example-ExtensionManual + github_branch: latest +... diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..743d7f7 --- /dev/null +++ b/composer.json @@ -0,0 +1,28 @@ +{ + "name": "jweiland/replacer", + "type": "typo3-cms-extension", + "description": "Replaces string patterns from the page. You can use it to replace URLs for Content Delivery Network (CDN).", + "license": "GPL-2.0-or-later", + "keywords": ["typo3", "TYPO3 CMS", "jw", "replacer"], + "homepage": "http://www.jweiland.net", + "authors": [ + { + "name": "Pascal Rinker", + "email": "projects@jweiland.net", + "role": "Developer" + } + ], + "support": { + "email": "projects@jweiland.net", + "issues": "https://github.com/jweiland-net/replacer/issues", + "source": "https://github.com/jweiland-net/replacer" + }, + "require": { + "typo3/cms-core": ">=7.6.0,<9.0" + }, + "autoload": { + "psr-4": { + "JWeiland\\Replacer\\": "Classes" + } + } +} diff --git a/ext_emconf.php b/ext_emconf.php new file mode 100644 index 0000000..65b8b0c --- /dev/null +++ b/ext_emconf.php @@ -0,0 +1,21 @@ + 'Content Replacer', + 'description' => 'Replaces string patterns from the page. You can use it to replace URLs for Content Delivery Network (CDN).', + 'category' => 'fe', + 'author' => 'Pascal Rinker', + 'author_email' => 'projects@jweiland.net', + 'author_company' => 'jweiland.net', + 'state' => 'stable', + 'uploadfolder' => 0, + 'createDirs' => '', + 'clearCacheOnLoad' => 0, + 'version' => '1.0.0', + 'constraints' => [ + 'depends' => [ + 'typo3' => '7.6.0-8.7.99', + ], + 'conflicts' => [], + 'suggests' => [], + ], +]; diff --git a/ext_icon.gif b/ext_icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..adffac4b06de3bba2cd360e11b34abb6534793ae GIT binary patch literal 369 zcmZ?wbhEHb6krfwxXJ(odJGJv3=Fmm46Y0e-V6-E3=Gi>45$~p!oz1pM9fJ{oSl-gI5Ts3ZtlvWqE!_Y z>uPE?b#&~UIdlK~`9~KnJh^JsnO(asA3b{a#EFNePTjkF`Q?=>Pww7*{rK^_uU~)u z`}ZH@7Se&@PZmy)A9O%kL4IOj>pRdKkf9+Xz}j@lz(sRkH|__0dL RxUM|lyPAdV+$u)~YXB*rZSnvB literal 0 HcmV?d00001 diff --git a/ext_localconf.php b/ext_localconf.php new file mode 100644 index 0000000..9f14ff1 --- /dev/null +++ b/ext_localconf.php @@ -0,0 +1,6 @@ +contentPostProcOutput';