From d892f121e1b9a34edfa49288a20b99d4d4b65f6b Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 28 Nov 2010 18:06:35 +0000 Subject: Refs #2173 #2160 #2507 added a css page handler to support multiple css files git-svn-id: http://code.elgg.org/elgg/trunk@7463 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engine/lib/elgglib.php') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 8a8cecbfa..7bf23df5e 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2137,6 +2137,32 @@ function js_page_handler($page) { } } +/** + * Serve CSS + * + * Serves CSS from the css views directory with headers for caching control + * + * @param array $page The page array + * + * @return void + * @elgg_pagehandler css + */ +function css_page_handler($page) { + if (!isset($page[0])) { + // default css + } + + $css = str_replace('.css', '', $page[0]); + $return = elgg_view("css/$css"); + + header("Content-type: text/css", true); + header('Expires: ' . date('r', time() + 86400000), true); + header("Pragma: public", true); + header("Cache-Control: public", true); + + echo $return; +} + /** * Intercepts the index page when Walled Garden mode is enabled. * @@ -2192,6 +2218,7 @@ function elgg_init() { elgg_register_action('likes/delete'); register_page_handler('js', 'js_page_handler'); + register_page_handler('css', 'css_page_handler'); // Trigger the shutdown:system event upon PHP shutdown. register_shutdown_function('_elgg_shutdown_hook'); -- cgit v1.2.3