Last active
August 29, 2015 14:03
-
-
Save webdesign2be/9cc36a085c59bc329573 to your computer and use it in GitHub Desktop.
Revisions
-
webdesign2be revised this gist
Jul 2, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public function evaluate() { /** @var \DOMDocument $dom */ $dom = new \DOMDocument(); $dom->loadHTML('<?xml encoding="UTF-8">' . $text); /** @var \DOMNode $node */ foreach ($dom->getElementsByTagName('a') as $node) { if (preg_match('~^(?:f|ht)tps?://~i', $node->getAttribute('href'))){ -
webdesign2be created this gist
Jul 2, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ <?php namespace Sms\Lsk\TypoScript; use TYPO3\Flow\Annotations as Flow; use TYPO3\Neos\Domain\Exception; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; use TYPO3\TypoScript\TypoScriptObjects\AbstractTypoScriptObject; class ConvertExternalUrisImplementation extends AbstractTypoScriptObject { /** * The string to be processed * * @return string */ public function getValue() { return $this->tsValue('value'); } /** * @return string * @throws Exception */ public function evaluate() { $text = $this->getValue(); if (!is_string($text)) { throw new Exception(sprintf('Only strings can be processed by this TypoScript object, given: "%s".', gettype($text)), 1382624080); } $currentContext = $this->tsRuntime->getCurrentContext(); $node = $currentContext['node']; if (!$node instanceof NodeInterface) { throw new Exception(sprintf('The current node must be an instance of NodeInterface, given: "%s".', gettype($text)), 1382624087); } if ($node->getContext()->getWorkspace()->getName() !== 'live') { return $text; } /** @var \DOMDocument $dom */ $dom = new \DOMDocument(); $dom->loadHTML($text); /** @var \DOMNode $node */ foreach ($dom->getElementsByTagName('a') as $node) { if (preg_match('~^(?:f|ht)tps?://~i', $node->getAttribute('href'))){ $node->setAttribute('target', '_blank'); } } return $dom->saveHTML(); } }