TYPO3 CMS  TYPO3_8-7
ScalableVectorGraphicsContentObject.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
28  public function render($conf = [])
29  {
30  $width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
31  if (!$width) {
32  $width = 600;
33  }
34  $height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
35  if (!$height) {
36  $height = 400;
37  }
38  $src = isset($conf['src.']) ? $this->cObj->stdWrap($conf['src'], $conf['src.']) : $conf['src'];
39  if (!$src) {
40  $src = null;
41  }
42  $value = isset($conf['value.']) ? $this->cObj->stdWrap($conf['value'], $conf['value.']) : $conf['value'];
43  $noscript = isset($conf['noscript.']) ? $this->cObj->stdWrap($conf['noscript'], $conf['noscript.']) : $conf['noscript'];
44  if ($src) {
45  $content = '
46 
47  <!--[if IE]>
48  <object src="' . $src . '" classid="image/svg+xml" width="' . $width . '" height="' . $height . '">
49  <![endif]-->
50  <!--[if !IE]>-->
51  <object data="' . $src . '" type="image/svg+xml" width="' . $width . '" height="' . $height . '">
52  <!--<![endif]-->
53  ' . $noscript . '
54  </object>
55 
56  ';
57  } else {
58  $content = '
59  <script type="image/svg+xml">
60  <svg xmlns="http://www.w3.org/2000/svg"
61  xmlns:xlink="http://www.w3.org/1999/xlink"
62  width="' . $width . '"
63  height="' . $height . '">
64  ' . $value . '
65  </svg>
66  </script>
67  <noscript>
68  ' . $noscript . '
69  </noscript>
70  ';
71  }
72  if (isset($conf['stdWrap.'])) {
73  $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
74  }
75  return $content;
76  }
77 }