/** * draw * * Try draw output layout * * @return null */ public static function draw() { $renderTries = 2; while ($renderTries--) { try { ob_start(); // txt context if (self::$_outputContext == 'txt') { Request::addHeader('Content-Type: text/plain'); $raw = TextPlainOutput::getContent(self::$_data); // json context } else { if (self::$_outputContext == 'json') { Request::addHeader('Content-Type: application/json'); $raw = json_encode(self::$_data ? self::$_data : new StdClass()); // xml context } else { if (self::$_outputContext == 'xml') { Request::addHeader('Content-Type: application/xml'); $raw = XmlOutput::getContent(self::$_data, self::$_XSDSchema, self::$_docType); // html context error } else { if (!self::$_layout) { throw new SystemErrorException(array('title' => 'View error', 'description' => 'Layout is not set')); // html context } else { Request::addHeader('Content-Type: text/html; charset=utf-8'); self::_normalizeHtmlContext(); extract(self::$_protectedData); extract(self::$_data); } } } } // set non-html context raw layout if (self::$_outputContext != 'html') { self::$_layout = 'raw.phtml'; } require self::$_layout; } catch (Exception $e) { ob_clean(); self::assignException($e); continue; } $layoutContent = ob_get_clean(); break; } if (!isset($layoutContent) && isset($e)) { UnexpectedException::take($e, true); } Request::sendHeaders(); echo $layoutContent; }
function setLayout($layout = '') { self::$_layout = $layout; }
public static function setLayout($layout) { self::$_layout = $layout; }