/** * * @param type $file * @param array $Variables * @param boolean $return * @param boolean $autoExtractHeaders * @return type */ function view_load($file, array $Variables = null, $return = false, $autoExtractHeaders = true) { ob_start(); # Incluindo arquivo $fileName = ABSPATH . '/' . APP::getCurrentModule(true) . "/views/{$file}.phtml"; if (!file_exists($fileName)) { throw new Exception("View `{$file}` não existe."); } file_include($fileName, $Variables); # Retornando HTML if ($return) { $Body = ob_get_clean(); if ($autoExtractHeaders) { # Script preg_match_all('/<script.*?<\\/script>/is', $Body, $result); foreach ($result[0] as $html) { Seo::addJs($html); } # Style preg_match_all('/<style.*?<\\/style>/is', $Body, $result); foreach ($result[0] as $html) { Seo::addCss($html); } return preg_replace(['/<style.*?<\\/style>/is', '/<script.*?<\\/script>/is'], null, $Body); } else { return $Body; } } else { ob_end_flush(); } }