diff --git a/classes/Resources.php b/classes/Resources.php index 569991d..da742f2 100644 --- a/classes/Resources.php +++ b/classes/Resources.php @@ -27,7 +27,7 @@ class Resources { // outputs the specified resource, if defined in this class. // the main script should do no further output after calling this function. - public static function output($resource) + public static function output($resource, $echo=true) { if (isset(self::$_resources[$resource])) { $res =& self::$_resources[$resource]; @@ -41,6 +41,7 @@ public static function output($resource) // use last-modified time as etag; etag must be quoted $etag = '"' . filemtime($filename) . '"'; + if ($echo) { // check headers for matching etag; if etag hasn't changed, use the cached version if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header('HTTP/1.0 304 Not Modified'); @@ -54,17 +55,25 @@ public static function output($resource) // output resource header('Content-type: ' . $res['mime']); + } + $result = ''; if (isset($data)) { if (isset($res['base64'])) { - echo base64_decode($data); + $result = base64_decode($data); } else { - echo $data; + $result = $data; } } else { - readfile($filename); + $result = file_get_contents($filename); } + + if ($echo) + echo $result; + else + return $result; } } } + diff --git a/index.php b/index.php index 6837650..e520362 100644 --- a/index.php +++ b/index.php @@ -51,6 +51,9 @@ function pla_autoload($classname) // up here, we don't output anything. debug output might appear here which is catched by ob and thrown later ob_start(); +// if inline_resources set +$inline_resources = isset($inline_resources) ? $inline_resources : false; + // Resource output (css and javascript files) // we get out of the main code as soon as possible, without inizializing the session if (isset($_GET['resource'])) @@ -1460,7 +1463,7 @@ function parseSize($size) - + <?php echo PROJECT ?> ", PHP_EOL; + echo ($inline_resources ? '' : "". PHP_EOL); else // only use the default stylesheet if an external one does not exist - echo "", PHP_EOL; + echo ($inline_resources ? '' : "". PHP_EOL); // HTML: output help text, then exit if(isset($_GET['help'])) @@ -1519,8 +1522,12 @@ function parseSize($size) { //- Javascript include ?> - + + + + +