protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true) { $_ctx =& $GLOBALS['_ctx']; $core =& $GLOBALS['core']; if ($_ctx->nb_entry_per_page === null) { $_ctx->nb_entry_per_page = $core->blog->settings->nb_post_per_page; } $tpl_file = $core->tpl->getFilePath($tpl); if (!$tpl_file) { throw new Exception('Unable to find template'); } if ($http_cache) { $GLOBALS['mod_files'][] = $tpl_file; http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']); } $result = new ArrayObject(); header('Content-Type: ' . $content_type . '; charset=UTF-8'); $_ctx->current_tpl = $tpl; $result['content'] = $core->tpl->getData($tpl); $result['content_type'] = $content_type; $result['tpl'] = $tpl; $result['blogupddt'] = $core->blog->upddt; # --BEHAVIOR-- urlHandlerServeDocument $core->callBehavior('urlHandlerServeDocument', $result); if ($http_cache && $http_etag) { http::etag($result['content'], http::getSelfURI()); } echo $result['content']; }
protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true) { $_ctx =& $GLOBALS['_ctx']; $core =& $GLOBALS['core']; if ($_ctx->nb_entry_per_page === null) { $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page; } if ($_ctx->nb_entry_first_page === null) { $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page; } $tpl_file = $core->tpl->getFilePath($tpl); if (!$tpl_file) { throw new Exception('Unable to find template '); } $result = new ArrayObject(); $_ctx->current_tpl = $tpl; $_ctx->content_type = $content_type; $_ctx->http_cache = $http_cache; $_ctx->http_etag = $http_etag; $core->callBehavior('urlHandlerBeforeGetData', $_ctx); if ($_ctx->http_cache) { $GLOBALS['mod_files'][] = $tpl_file; http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']); } header('Content-Type: ' . $_ctx->content_type . '; charset=UTF-8'); if ($core->blog->settings->system->prevents_clickjacking) { if ($_ctx->exists('xframeoption')) { $url = parse_url($_ctx->xframeoption); header(sprintf('X-Frame-Options: %s', is_array($url) ? "ALLOW-FROM " . $url['scheme'] . '://' . $url['host'] : 'SAMEORIGIN')); } else { // Prevents Clickjacking as far as possible header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ } } $result['content'] = $core->tpl->getData($_ctx->current_tpl); $result['content_type'] = $_ctx->content_type; $result['tpl'] = $_ctx->current_tpl; $result['blogupddt'] = $core->blog->upddt; # --BEHAVIOR-- urlHandlerServeDocument $core->callBehavior('urlHandlerServeDocument', $result); if ($_ctx->http_cache && $_ctx->http_etag) { http::etag($result['content'], http::getSelfURI()); } echo $result['content']; }