public macroContentType ( |
||
$node | ||
$writer |
public function macroContentType(MacroNode $node, PhpWriter $writer)
{
if (!$this->getCompiler()->isInHead() && !($node->htmlNode && strtolower($node->htmlNode->name) === 'script' && strpos($node->args, 'html') !== FALSE)) {
throw new CompileException($node->getNotation() . ' is allowed only in template header.');
}
$compiler = $this->getCompiler();
if ($node->modifiers) {
throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
} elseif (strpos($node->args, 'xhtml') !== FALSE) {
$type = $compiler::CONTENT_XHTML;
} elseif (strpos($node->args, 'html') !== FALSE) {
$type = $compiler::CONTENT_HTML;
} elseif (strpos($node->args, 'xml') !== FALSE) {
$type = $compiler::CONTENT_XML;
} elseif (strpos($node->args, 'javascript') !== FALSE) {
$type = $compiler::CONTENT_JS;
} elseif (strpos($node->args, 'css') !== FALSE) {
$type = $compiler::CONTENT_CSS;
} elseif (strpos($node->args, 'calendar') !== FALSE) {
$type = $compiler::CONTENT_ICAL;
} else {
$type = $compiler::CONTENT_TEXT;
}
$compiler->setContentType($type);
if (strpos($node->args, '/') && !$node->htmlNode) {
return $writer->write('if (empty($this->global->coreCaptured) && in_array($this->getReferenceType(), ["extends", NULL], TRUE)) header(%var);', "Content-Type: {$node->args}");
}
}