diff options
Diffstat (limited to 'mod/embed/views/default/embed/embed.php')
-rw-r--r-- | mod/embed/views/default/embed/embed.php | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php index 09a15d7a0..4a14543d3 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -2,6 +2,9 @@ /** * Embed landing page * + * @todo Yes this is a lot of logic for a view. A good bit of it can be moved + * to the page handler + * * @uses string $vars['sections'] Array of section_id => Section Display Name * @uses string $vars['active_section'] Currently selected section_id */ @@ -38,12 +41,7 @@ if (!$sections) { $tabs_html = elgg_view('navigation/tabs', array('tabs' => $tabs)); $content .= $tabs_html; - $pagination_vars = array( - - ); - - $content .= elgg_view('navigation/pagination', $pagination_vars); - + // build the items and layout. if (array_key_exists($active_section, $sections)) { $section_info = $sections[$active_section]; $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; @@ -62,11 +60,39 @@ if (!$sections) { // handles its own pagination $content .= $section_content; } elseif ($embed_info = trigger_plugin_hook('embed_get_items', $active_section, $params, array('items' => array(), 'count' => 0))) { - $params['items'] = $embed_info['items']; + // check if we have an override for this section type. + $view = "embed/$section/item/$layout"; + + if (!elgg_view_exists($view)) { + $view = "embed/item/$layout"; + } + + // pull out some common tests + // embed requires ECML, but until we have plugin deps working + // we need to explicitly check and use a fallback. + if ($ecml_enabled = is_plugin_enabled('ecml')){ + $ecml_valid_keyword = ecml_is_valid_keyword($section); + } else { + $ecml_valid_keyword = FALSE; + } + + $items_content = ''; + foreach ($embed_info['items'] as $item) { + $item_params = array( + 'section' => $section, + 'item' => $item, + 'ecml_enabled' => $ecml_enabled, + 'ecml_keyword' => ($ecml_valid_keyword) ? $section : 'entity' + ); + + $items_content .= elgg_view($view, $item_params); + } + + $params['content'] = $items_content; $params['count'] = $embed_info['count']; - // pagination here. + $content .= elgg_view('navigation/pagination', $params); - $content .= elgg_view("embed/layouts/{$section_info['layout']}", $params); + $content .= elgg_view("embed/layouts/$layout", $params); } else { $content .= elgg_echo('embed:no_section_content'); } @@ -80,8 +106,13 @@ echo $content; <script type="text/javascript"> $(document).ready(function() { - // insert embed codes + $('.embed_data').click(function() { + var embed_code = $(this).data('embed_code'); + elggEmbedInsertContent(embed_code); + }); + + // tabs $('.embed_section').click(function() { var section = $(this).attr('id'); var url = '<?php echo $vars['url']; ?>pg/embed/embed?active_section=' + section; @@ -90,7 +121,7 @@ $(document).ready(function() { return false; }); - // handle pagination + // pagination function elggPaginationClick() { $('#facebox .body .content').load($(this).attr('href')); return false; @@ -101,5 +132,4 @@ $(document).ready(function() { $('.pagination_previous').click(elggPaginationClick); }); -</script> - +</script>
\ No newline at end of file |