10 defined(
'JPATH_PLATFORM') or die;
34 public function render($head, $params = array(), $content = null)
37 echo $this->fetchHead($this->_doc);
38 $buffer = ob_get_contents();
53 public function fetchHead($document)
56 if (isset($document->_metaTags[
'standard'][
'tags']))
58 $tagsHelper =
new JHelperTags;
59 $document->_metaTags[
'standard'][
'tags'] = implode(
', ', $tagsHelper->getTagNames($document->_metaTags[
'standard'][
'tags']));
64 $app->triggerEvent(
'onBeforeCompileHead');
67 $lnEnd = $document->_getLineEnd();
68 $tab = $document->_getTab();
73 if ($document->isHtml5())
75 $buffer .= $tab .
'<meta charset="' . $document->getCharset() .
'" />' . $lnEnd;
79 $base = $document->getBase();
82 $buffer .= $tab .
'<base href="' . $document->getBase() .
'" />' . $lnEnd;
86 foreach ($document->_metaTags as $type => $tag)
88 foreach ($tag as $name => $content)
90 if ($type ==
'http-equiv' && !($document->isHtml5() && $name ==
'content-type'))
92 $buffer .= $tab .
'<meta http-equiv="' . $name .
'" content="' . htmlspecialchars($content) .
'" />' . $lnEnd;
94 elseif ($type ==
'standard' && !empty($content))
96 $buffer .= $tab .
'<meta name="' . $name .
'" content="' . htmlspecialchars($content) .
'" />' . $lnEnd;
102 $documentDescription = $document->getDescription();
103 if ($documentDescription)
105 $buffer .= $tab .
'<meta name="description" content="' . htmlspecialchars($documentDescription) .
'" />' . $lnEnd;
109 $generator = $document->getGenerator();
112 $buffer .= $tab .
'<meta name="generator" content="' . htmlspecialchars($generator) .
'" />' . $lnEnd;
115 $buffer .= $tab .
'<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT,
'UTF-8') .
'</title>' . $lnEnd;
118 foreach ($document->_links as $link => $linkAtrr)
120 $buffer .= $tab .
'<link href="' . $link .
'" ' . $linkAtrr[
'relType'] .
'="' . $linkAtrr[
'relation'] .
'"';
123 $buffer .=
' ' . $temp;
125 $buffer .=
' />' . $lnEnd;
129 foreach ($document->_styleSheets as $strSrc => $strAttr)
131 $buffer .= $tab .
'<link rel="stylesheet" href="' . $strSrc .
'" type="' . $strAttr[
'mime'] .
'"';
132 if (!is_null($strAttr[
'media']))
134 $buffer .=
' media="' . $strAttr[
'media'] .
'" ';
138 $buffer .=
' ' . $temp;
140 $buffer .= $tagEnd . $lnEnd;
144 foreach ($document->_style as $type => $content)
146 $buffer .= $tab .
'<style type="' . $type .
'">' . $lnEnd;
149 if ($document->_mime !=
'text/html')
151 $buffer .= $tab . $tab .
'<![CDATA[' . $lnEnd;
154 $buffer .= $content . $lnEnd;
157 if ($document->_mime !=
'text/html')
159 $buffer .= $tab . $tab .
']]>' . $lnEnd;
161 $buffer .= $tab .
'</style>' . $lnEnd;
165 foreach ($document->_scripts as $strSrc => $strAttr)
167 $buffer .= $tab .
'<script src="' . $strSrc .
'"';
168 if (!is_null($strAttr[
'mime']))
170 $buffer .=
' type="' . $strAttr[
'mime'] .
'"';
172 if ($strAttr[
'defer'])
174 $buffer .=
' defer="defer"';
176 if ($strAttr[
'async'])
178 $buffer .=
' async="async"';
180 $buffer .=
'></script>' . $lnEnd;
184 foreach ($document->_script as $type => $content)
186 $buffer .= $tab .
'<script type="' . $type .
'">' . $lnEnd;
189 if ($document->_mime !=
'text/html')
191 $buffer .= $tab . $tab .
'<![CDATA[' . $lnEnd;
194 $buffer .= $content . $lnEnd;
197 if ($document->_mime !=
'text/html')
199 $buffer .= $tab . $tab .
']]>' . $lnEnd;
201 $buffer .= $tab .
'</script>' . $lnEnd;
207 $buffer .= $tab .
'<script type="text/javascript">' . $lnEnd;
208 $buffer .= $tab . $tab .
'(function() {' . $lnEnd;
209 $buffer .= $tab . $tab . $tab .
'var strings = ' . json_encode(
JText::script()) .
';' . $lnEnd;
210 $buffer .= $tab . $tab . $tab .
'if (typeof Joomla == \'undefined\') {' . $lnEnd;
211 $buffer .= $tab . $tab . $tab . $tab .
'Joomla = {};' . $lnEnd;
212 $buffer .= $tab . $tab . $tab . $tab .
'Joomla.JText = strings;' . $lnEnd;
213 $buffer .= $tab . $tab . $tab .
'}' . $lnEnd;
214 $buffer .= $tab . $tab . $tab .
'else {' . $lnEnd;
215 $buffer .= $tab . $tab . $tab . $tab .
'Joomla.JText.load(strings);' . $lnEnd;
216 $buffer .= $tab . $tab . $tab .
'}' . $lnEnd;
217 $buffer .= $tab . $tab .
'})();' . $lnEnd;
218 $buffer .= $tab .
'</script>' . $lnEnd;
221 foreach ($document->_custom as $custom)
223 $buffer .= $tab . $custom . $lnEnd;