diff options
Diffstat (limited to 'mod/embed/views/default/embed/embed.php')
-rw-r--r-- | mod/embed/views/default/embed/embed.php | 93 |
1 files changed, 20 insertions, 73 deletions
diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php index f09d76a4b..9f0ac730f 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -29,8 +29,6 @@ if (!$sections) { $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; $params = array( - //'type' => $type, - //'subtype' => $subtype, 'offset' => $offset, 'limit' => $limit, 'section' => $active_section, @@ -43,10 +41,13 @@ if (!$sections) { if ($section_content = elgg_view("embed/$active_section/content", $params)) { // handles its own pagination $content .= $section_content; - } elseif ($embed_info = elgg_trigger_plugin_hook('embed_get_items', $active_section, $params, array('items' => array(), 'count' => 0))) { - // check if we have an override for this section type. - $view = "embed/$active_section/item/$layout"; + } else { + // see if anyone has any items to display for the active section + $result = array('items' => array(), 'count' => 0); + $embed_info = elgg_trigger_plugin_hook('embed_get_items', $active_section, $params, $result); + // do we use default view or has someone defined "embed/$active_section/item/$layout" + $view = "embed/$active_section/item/$layout"; if (!elgg_view_exists($view)) { $view = "embed/item/$layout"; } @@ -54,37 +55,16 @@ if (!$sections) { if (!isset($embed_info['items']) || !is_array($embed_info['items']) || !count($embed_info['items'])) { $content .= elgg_echo('embed:no_section_content'); } else { - // 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 = elgg_is_active_plugin('ecml')){ - $ecml_valid_keyword = ecml_is_valid_keyword($active_section); - } else { - $ecml_valid_keyword = FALSE; - } - - $items_content = '<ul class="elgg-list">'; - foreach ($embed_info['items'] as $item) { - $item_params = array( - 'section' => $active_section, - 'item' => $item, - 'ecml_enabled' => $ecml_enabled, - 'ecml_keyword' => ($ecml_valid_keyword) ? $active_section : 'entity', - 'icon_size' => elgg_extract('icon_size', $section_info, 'tiny'), - ); - - $items_content .= '<li class="elgg-list-item">' . elgg_view($view, $item_params) . '</li>'; - } - $items_content .= '</ul>'; - - $params['content'] = $items_content; - $params['count'] = $embed_info['count']; - - $content .= elgg_view('navigation/pagination', $params); - $content .= elgg_view("embed/layouts/$layout", $params); + elgg_push_context('widgets'); + $content .= elgg_view_entity_list($embed_info['items'], array( + 'full_view' => false, + )); + elgg_pop_context(); + + $js = elgg_view('js/embed/inline', array( + 'items' => $embed_info['items'], + )); } - } else { - $content .= elgg_echo('embed:no_section_content'); } } else { $content .= elgg_echo('embed:invalid_section'); @@ -92,42 +72,9 @@ if (!$sections) { } echo '<div class="embed-wrapper">' . $content . '</div>'; -?> - -<?php //@todo: JS 1.8: ugly ?> -<script type="text/javascript"> -$(function() { - var internal_id = '<?php echo addslashes($internal_id); ?>'; - - // Remove any existing "live" handlers - $('.embed_data').die('click'); - $('.embed_section').die('click'); - $('#facebox .elgg-pagination a').die('click'); - - // insert embed codes - $('.embed_data').live('click', function() { - var embed_code = $(this).data('embed_code'); - elggEmbedInsertContent(embed_code, internal_id); - - return false; - }); - // tabs - $('.embed_section').live('click', function() { - var section = $(this).attr('id'); - var url = elgg.config.wwwroot + 'embed/embed?active_section=' + section + '&internal_id=' + internal_id; - $('#facebox .body .content').load(url); - - return false; - }); - - // pagination - function elggPaginationClick() { - $('#facebox .body .content').load($(this).attr('href')); - return false; - } - - $('#facebox .elgg-pagination a').live('click', elggPaginationClick); -}); - -</script> +if (isset($js)) { + echo '<script type="text/javascript">'; + echo $js; + echo '</script>'; +} |