public function render($data) { $type = $this->picnic()->router()->outputType(); if ($type == "xml") { PicnicBenchmark::instance()->mark("end"); header("Content-type: text/xml"); echo PicnicXMLParser::objects2XML($this->picnic()->controller()); exit; } else { if ($type == "json") { PicnicBenchmark::instance()->mark("end"); header("Content-type: text/x-javascript"); echo json_encode($this->picnic()->controller()); exit; } else { if ($this->_template == null) { throw new PicnicTemplateNotDefinedException("No template has been defined to use", 0, "PicnicView", "render"); } if (file_exists($this->templatePath())) { $contents = $this->getTemplateContents($this->templatePath()); if ($contents === false) { exit("TEMPLATE ERROR"); } PicnicBenchmark::instance()->mark("end"); if ($this->layoutTemplatePath() != "" && file_exists($this->layoutTemplatePath())) { // TODO: use getTemplateContents() include $this->layoutTemplatePath(); } else { echo $contents; } } else { throw new PicnicTemplateNotDefinedException("The template '{$this->_template}' does not exist in the template path '{$this->_templateFolder}'", 0, "PicnicView", "render"); } } } }