From 60fd7ad6ce1c2fbd140edf1a6185649e47735bbc Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 1 Jun 2010 22:33:58 +0000 Subject: First pass at a loosely couple embed plugin using ECML. git-svn-id: http://code.elgg.org/elgg/trunk@6315 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/embed/start.php | 75 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 29 deletions(-) (limited to 'mod/embed/start.php') diff --git a/mod/embed/start.php b/mod/embed/start.php index f98c21245..eb6f6d4a6 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -1,7 +1,7 @@ @@ -13,37 +13,54 @@ * Init function * */ - function embed_init() { - - // Extend useful views with stuff we need for our embed modal - elgg_extend_view('css','embed/css'); - elgg_extend_view('js/initialise_elgg','embed/js'); - elgg_extend_view('metatags','embed/metatags'); - elgg_extend_view('input/longtext','embed/link',1); - - // Page handler for the modal media embed - register_page_handler('embed','embed_page_handler'); - - } - +function embed_init() { + elgg_extend_view('css', 'embed/css'); + elgg_extend_view('js/initialise_elgg', 'embed/js'); + elgg_extend_view('metatags', 'embed/metatags'); + elgg_extend_view('input/longtext', 'embed/link', 1); + + // Page handler for the modal media embed + register_page_handler('embed', 'embed_page_handler'); +} + /** - * Runs the 'embed' script + * Serves pages for upload and embed. * + * @param $page */ - function embed_page_handler($page) { - - switch($page[0]) { - case 'upload': require_once(dirname(__FILE__) . '/upload.php'); - exit; - break; - default: require_once(dirname(__FILE__) . '/embed.php'); - exit; - break; - } - +function embed_page_handler($page) { + if (!isset($page[0])) { + $page[0] = 'embed'; + } + + switch($page[0]) { + case 'upload': + echo elgg_view('embed/upload'); + + break; + + case 'embed': + default: + // trigger hook to get section tabs + // use views for embed/section/ + // listing + // item + // default to embed/listing | item if not found. + // @todo trigger for all right now. If we categorize these later we can trigger + // for certain categories. + $sections = trigger_plugin_hook('embed_get_sections', 'all', NULL, array()); + asort($sections, SORT_LOCALE_STRING); + $active_section = get_input('active_section', NULL); + + echo elgg_view('embed/embed', array( + 'sections' => $sections, + 'active_section' => $active_section + )); + + break; } -// Register the init action - register_elgg_event_handler('init','system','embed_init',10); + exit; +} -?> +register_elgg_event_handler('init', 'system', 'embed_init'); \ No newline at end of file -- cgit v1.2.3