1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Document
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Abstract class for a renderer
14 *
15 * @since 11.1
16 */
17 class JDocumentRenderer
18 {
19 /**
20 * Reference to the JDocument object that instantiated the renderer
21 *
22 * @var JDocument
23 * @since 11.1
24 */
25 protected $_doc = null;
26
27 /**
28 * Renderer mime type
29 *
30 * @var string
31 * @since 11.1
32 */
33 protected $_mime = 'text/html';
34
35 /**
36 * Class constructor
37 *
38 * @param JDocument $doc A reference to the JDocument object that instantiated the renderer
39 *
40 * @since 11.1
41 */
42 public function __construct(JDocument $doc)
43 {
44 $this->_doc = $doc;
45 }
46
47 /**
48 * Renders a script and returns the results as a string
49 *
50 * @param string $name The name of the element to render
51 * @param array $params Array of values
52 * @param string $content Override the output of the renderer
53 *
54 * @return string The output of the script
55 *
56 * @since 11.1
57 */
58 public function render($name, $params = null, $content = null)
59 {
60 }
61
62 /**
63 * Return the content type of the renderer
64 *
65 * @return string The contentType
66 *
67 * @since 11.1
68 */
69 public function getContentType()
70 {
71 return $this->_mime;
72 }
73
74 /**
75 * Convert links in a text from relative to absolute
76 *
77 * @param string $text The text processed
78 *
79 * @return string Text with converted links
80 *
81 * @since 11.1
82 */
83 protected function _relToAbs($text)
84 {
85 $base = JUri::base();
86 $text = preg_replace("/(href|src)=\"(?!http|ftp|https|mailto|data|\/\/)([^\"]*)\"/", "$1=\"$base\$2\"", $text);
87
88 return $text;
89 }
90 }
91