Пример #1
0
 /**
  * 
  * @param Scripter $scripter
  * @param Response $response
  * @param Request $request
  */
 public static function register_shutdown(Scripter $scripter, Response $response, Request $request)
 {
     register_shutdown_function(function () use($scripter, $response, $request) {
         $page = ob_get_contents();
         ob_end_clean();
         $header_type = $response->getHeader("Content-Type");
         if ($header_type && strpos($header_type, "text/html") === 0 && !$request->isAjax()) {
             $scripter->cache->removeNotUseFile();
             preg_match('/(?:<head[^>]*>)(.*?)<\\/head>/s', $page, $matches);
             if (isset($matches[1])) {
                 $replace = $matches[1];
                 $matches[1] .= '<script type="text/javascript" src="' . '/' . $scripter->config->url_path_name . '/' . $scripter->getPageName() . '/js' . '"></script>';
                 $matches[1] .= '<link rel="stylesheet" href="' . '/' . $scripter->config->url_path_name . '/' . $scripter->getPageName() . '/css' . '">';
                 $page = str_replace($replace, $matches[1], $page);
             }
         }
         echo $page;
     });
 }