function bp_swa_list_activities($per_page = 10, $page = 1, $scope = '', $max = 200, $show_avatar = "yes", $show_filters = "yes", $included = false, $excluded = false, $is_personal = "no", $is_blog_admin_activity = "no", $show_post_form = "no")
{
    //check for the scope of activity
    //is it the activity of logged in user/blog admin
    //logged in user over rides blog admin
    global $bp;
    $primary_id = '';
    if (bp_is_group()) {
        $primary_id = null;
    }
    $user_id = "";
    //for limiting to users
    if ($is_personal == "yes") {
        $user_id = $bp->loggedin_user->id;
    } else {
        if ($is_blog_admin_activity == "yes") {
            $user_id = swa_get_blog_admin_id();
        } else {
            if (bp_is_user()) {
                $user_id = null;
            }
        }
    }
    $components_scope = swa_get_base_component_scope($included, $excluded);
    $components_base_scope = "";
    if (!empty($components_scope)) {
        $components_base_scope = join(",", $components_scope);
    }
    ?>
      <div class='swa-wrap block1'>
          <?php 
    if (is_user_logged_in() && $show_post_form == "yes") {
        swa_show_post_form();
    }
    ?>
          <?php 
    if ($show_filters == "yes") {
        ?>
			<ul id="activity-filter-links">
				<?php 
        swa_activity_filter_links("scope=" . $scope . "&include=" . $included . "&exclude=" . $excluded);
        ?>
			</ul>
          <div class="clear"></div>
                    <?php 
    }
    ?>
        <?php 
    if (bp_has_activities('type=sitewide&max=' . $max . '&page=' . $page . '&per_page=' . $per_page . '&object=' . $scope . "&user_id=" . $user_id . "&primary_id=" . $primary_id)) {
        ?>

            <div class="swa-pagination ">
                    <div class="pag-count" id="activity-count">
                            <?php 
        bp_activity_pagination_count();
        ?>
                    </div>

                    <div class="pagination-links" id="activity-pag">
                            &nbsp; <?php 
        bp_activity_pagination_links();
        ?>
                    </div>
                <div class="clear" ></div>
            </div>


            <div class="clear" ></div>
                <ul  class="site-wide-stream swa-activity-list">
                    <?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
                        <?php 
            swa_activity_entry($show_avatar);
            ?>
                    <?php 
        }
        ?>
               </ul>

	<?php 
    } else {
        ?>

        <div class="widget-error">
            <?php 
        if ($is_personal == "yes") {
            $error = sprintf(__("You have no recent %s activity.", "swa"), $scope);
        } else {
            $error = __('There has been no recent site activity.', 'swa');
        }
        ?>
                <?php 
        echo $error;
        ?>
        </div>
	<?php 
    }
    ?>
     </div>
     
<?php 
}
function swa_get_activity_filter_links($args = false)
{
    global $activities_template, $bp;
    $link = '';
    $defaults = array('style' => 'list');
    //check scope, if not single entiry
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $components = swa_get_base_component_scope($include, $exclude);
    if (!$components) {
        return false;
    }
    foreach ((array) $components as $component) {
        /* Skip the activity comment filter */
        if ('activity' == $component) {
            continue;
        }
        if (isset($_GET['afilter']) && $component == $_GET['afilter']) {
            $selected = ' class="selected"';
        } else {
            $selected = '';
        }
        $component = esc_attr($component);
        if ($component == 'xprofile') {
            $component = 'profile';
        }
        switch ($style) {
            case 'list':
                $tag = 'li';
                $before = '<li id="afilter-' . $component . '"' . $selected . '>';
                $after = '</li>';
                break;
            case 'paragraph':
                $tag = 'p';
                $before = '<p id="afilter-' . $component . '"' . $selected . '>';
                $after = '</p>';
                break;
            case 'span':
                $tag = 'span';
                $before = '<span id="afilter-' . $component . '"' . $selected . '>';
                $after = '</span>';
                break;
        }
        $link = add_query_arg('afilter', $component);
        $link = remove_query_arg('acpage', $link);
        $link = apply_filters('bp_get_activity_filter_link_href', $link, $component);
        /* Make sure all core internal component names are translatable */
        $translatable_components = array(__('profile', 'swa'), __('friends', 'swa'), __('groups', 'swa'), __('status', 'swa'), __('blogs', 'swa'));
        $component_links[] = $before . '<a href="' . esc_attr($link) . '">' . ucwords(__($component, 'swa')) . '</a>' . $after;
    }
    $link = remove_query_arg('afilter', $link);
    if (!empty($_REQUEST['scope'])) {
        $link .= "?afilter=";
        $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr($link) . '"">' . __('Clear Filter', 'swa') . '</a></' . $tag . '>';
    }
    if (!empty($component_links)) {
        return apply_filters('swa_get_activity_filter_links', implode("\n", $component_links), $component_links);
    }
    return false;
}