diff options
Diffstat (limited to 'mod/embed/start.php')
-rw-r--r-- | mod/embed/start.php | 75 |
1 files changed, 46 insertions, 29 deletions
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 @@ <?php /** * Elgg media embed plugin - * + * * @package ElggEmbed * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd <info@elgg.com> @@ -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 |