[TASK] Sync CMS Fluid with Flow Fluid 1.1 (part1)
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Uri / ExternalViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * A view helper for creating URIs to external targets.
16 * Currently the specified URI is simply passed through.
17 *
18 * = Examples =
19 *
20 * <code>
21 * <f:uri.external uri="http://www.typo3.org" />
22 * </code>
23 * <output>
24 * http://www.typo3.org
25 * </output>
26 *
27 * <code title="custom default scheme">
28 * <f:uri.external uri="typo3.org" defaultScheme="ftp" />
29 * </code>
30 * <output>
31 * ftp://typo3.org
32 * </output>
33 *
34 * @api
35 */
36 class ExternalViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
37
38 /**
39 * @param string $uri target URI
40 * @param string $defaultScheme scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already
41 * @return string Rendered URI
42 * @api
43 */
44 public function render($uri, $defaultScheme = 'http') {
45 $scheme = parse_url($uri, PHP_URL_SCHEME);
46 if ($scheme === NULL && $defaultScheme !== '') {
47 $uri = $defaultScheme . '://' . $uri;
48 }
49 return $uri;
50 }
51 }
52
53 ?>