This repository has been archived by the owner. It is now read-only.

Some small improvements for JDocument: #697

Merged
merged 1 commit into from Jan 3, 2012
Jump to file or symbol
Failed to load files and symbols.
+19 −14
Split
@@ -968,6 +968,6 @@ public function render($cache = false, $params = array())
JResponse::setHeader('Last-Modified', $mdate /* gmdate('D, d M Y H:i:s', time() + 900) . ' GMT' */);
}
- JResponse::setHeader('Content-Type', $this->_mime . '; charset=' . $this->_charset);
+ JResponse::setHeader('Content-Type', $this->_mime . ($this->_charset ? '; charset=' . $this->_charset : ''));
}
}
@@ -108,7 +108,7 @@ public function __construct($options = array())
$this->_type = 'html';
// Set default mime type and document metadata (meta data syncs with mime type by default)
- $this->setMetaData('Content-Type', 'text/html', true);
+ $this->setMimeEncoding('text/html');
}
/**
@@ -121,16 +121,16 @@ public function __construct($options = array())
public function getHeadData()
{
$data = array();
- $data['title'] = $this->title;
+ $data['title'] = $this->title;
$data['description'] = $this->description;
- $data['link'] = $this->link;
- $data['metaTags'] = $this->_metaTags;
- $data['links'] = $this->_links;
+ $data['link'] = $this->link;
+ $data['metaTags'] = $this->_metaTags;
+ $data['links'] = $this->_links;
$data['styleSheets'] = $this->_styleSheets;
- $data['style'] = $this->_style;
- $data['scripts'] = $this->_scripts;
- $data['script'] = $this->_script;
- $data['custom'] = $this->_custom;
+ $data['style'] = $this->_style;
+ $data['scripts'] = $this->_scripts;
+ $data['script'] = $this->_script;
+ $data['custom'] = $this->_custom;
return $data;
}
@@ -298,7 +298,6 @@ public function addFavicon($href, $type = 'image/vnd.microsoft.icon', $relation
*
* @since 11.1
*/
-
public function addCustomTag($html)
{
$this->_custom[] = trim($html);
@@ -76,11 +76,11 @@ public function fetchHead(&$document)
if ($type == 'http-equiv')
{
$content .= '; charset=' . $document->getCharset();
- $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '"' . $tagEnd . $lnEnd;
+ $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd;
}
elseif ($type == 'standard' && !empty($content))
{
- $buffer .= $tab . '<meta name="' . $name . '" content="' . htmlspecialchars($content) . '"' . $tagEnd . $lnEnd;
+ $buffer .= $tab . '<meta name="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd;
}
}
}
@@ -92,7 +92,13 @@ public function fetchHead(&$document)
$buffer .= $tab . '<meta name="description" content="' . htmlspecialchars($documentDescription) . '" />' . $lnEnd;
}
- $buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($document->getGenerator()) . '" />' . $lnEnd;
+ // Don't add empty generators
+ $generator = $document->getGenerator();
+ if ($generator)
+ {
+ $buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator) . '" />' . $lnEnd;
+ }
+
$buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd;
// Generate link declarations