diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-23 00:34:36 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-23 00:34:36 +0000 |
commit | 64bbdaf4a13bd4beb252c95493e229291db91073 (patch) | |
tree | 74651714024577a2b9f897521915dcf3ba536b50 | |
parent | 05cd3a5f331d271a0a93d2bee69fdd70494f32d6 (diff) | |
download | elgg-64bbdaf4a13bd4beb252c95493e229291db91073.tar.gz elgg-64bbdaf4a13bd4beb252c95493e229291db91073.tar.bz2 |
Fixes #3180 adds ajax page handler
git-svn-id: http://code.elgg.org/elgg/trunk@8820 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/elgglib.php | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 5b0ff8365..7076ec12d 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1672,7 +1672,7 @@ function _elgg_shutdown_hook() { * @return void * @elgg_pagehandler js */ -function js_page_handler($page) { +function elgg_js_page_handler($page) { if (is_array($page) && sizeof($page)) { $js = implode('/', $page); $js = substr($js, 0, strpos($js, '.')); @@ -1691,6 +1691,38 @@ function js_page_handler($page) { } /** + * Serve individual views for Ajax. + * + * /ajax/view/<name of view>?<key/value params> + * + * @param array $page The page array + * + * @return void + * @elgg_pagehandler ajax + */ +function elgg_ajax_page_handler($page) { + if (is_array($page) && sizeof($page)) { + // throw away 'view' and form the view name + unset($page[0]); + $view = implode('/', $page); + + // pull out GET parameters through filter + $vars = array(); + foreach ($_GET as $name => $value) { + $vars[$name] = get_input($name); + } + + if (isset($vars['guid'])) { + $vars['entity'] = get_entity($vars['guid']); + } + + echo elgg_view($view, $vars); + } + + return true; +} + +/** * Serve CSS * * Serves CSS from the css views directory with headers for caching control @@ -1700,7 +1732,7 @@ function js_page_handler($page) { * @return void * @elgg_pagehandler css */ -function css_page_handler($page) { +function elgg_css_page_handler($page) { if (!isset($page[0])) { // default css $page[0] = 'elgg'; @@ -1896,8 +1928,9 @@ function elgg_init() { elgg_register_action('comments/add'); elgg_register_action('comments/delete'); - elgg_register_page_handler('js', 'js_page_handler'); - elgg_register_page_handler('css', 'css_page_handler'); + elgg_register_page_handler('js', 'elgg_js_page_handler'); + elgg_register_page_handler('css', 'elgg_css_page_handler'); + elgg_register_page_handler('ajax', 'elgg_ajax_page_handler'); elgg_register_js('elgg.autocomplete', 'js/lib/autocomplete.js'); elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js'); |