function sp_render_topic_tools($topic, $forum, $page)
{
    global $spThisUser;
    $out = '';
    $topicname = urlencode(sp_filter_title_display($topic['topic_name']));
    $out .= '<div id="spMainContainer" class="spForumToolsPopup">';
    $out .= '<div class="spForumToolsHeader">';
    $out .= '<div class="spForumToolsHeaderTitle">' . sp_filter_title_display($topic['topic_name']) . '</div>';
    $out .= '</div>';
    $out .= sp_render_common_tools($forum, $topic, '', $page);
    if ($spThisUser->admin) {
        $out .= '<div class="spForumToolsOrder">';
        $out .= '<img class="spIcon" src="' . sp_find_icon(SPTHEMEICONSURL, 'sp_ToolsSort.png') . '" alt="" title="" />';
        $site = SFHOMEURL . 'index.php?sp_ahah=admintools&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;action=sort-forum&amp;forumid=' . $forum['forum_id'];
        $out .= '<a href="javascript:void(null)" onclick="spjLoadTool(\'' . $site . '\', \'spMainContainer\', \'\');">' . sp_text('Reverse sort this forum') . '</a>';
        $out .= '</div>';
    }
    if ($spThisUser->admin || $spThisUser->moderator) {
        $out .= '<div class="spForumToolsProperties">';
        $out .= '<img class="spIcon" src="' . sp_find_icon(SPTHEMEICONSURL, 'sp_ToolsProperties.png') . '" alt="" title="" />';
        $title = sp_text('View properties');
        $site = SFHOMEURL . 'index.php?sp_ahah=admintools&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;action=properties&amp;group=' . $forum['group_id'] . '&amp;forum=' . $forum['forum_id'] . '&amp;topic=' . $topic['topic_id'];
        $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">' . $title . '</a>';
        $out .= '</div>';
    }
    $out = apply_filters('sph_add_topic_tool', $out, $topic, $forum, $page);
    $out .= '</div>';
    $out = apply_filters('sph_topic_tools', $out, $topic, $forum, $page);
    return $out;
}
function sp_render_topic_tools($topic, $forum, $page)
{
    global $spThisUser;
    $br = current_theme_supports('sp-theme-responsive') ? '<br />' : '';
    $topicname = urlencode(sp_filter_title_display($topic['topic_name']));
    $out = '';
    $out .= '<div id="spMainContainer" class="spForumToolsPopup">';
    $out .= '<div class="spAdminLinksPopup">';
    $out .= '<div class="spForumToolsHeader">';
    $out .= '<div class="spForumToolsHeaderTitle">' . sp_filter_title_display($topic['topic_name']) . '</div>';
    $out .= '</div>';
    $out .= sp_open_grid();
    $out .= sp_render_common_tools($forum, $topic, '', $page, $br);
    if ($spThisUser->admin) {
        $out .= sp_open_grid_cell();
        $out .= '<div class="spForumToolsOrder">';
        $site = SFHOMEURL . 'index.php?sp_ahah=admintools&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;action=sort-forum&amp;forumid=' . $forum['forum_id'];
        $out .= '<a href="javascript:void(null)" onclick="spjLoadTool(\'' . $site . '\', \'spMainContainer\', \'\');">';
        $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsSort.png') . $br;
        $out .= sp_text('Reverse sort this forum') . '</a>';
        $out .= '</div>';
        $out .= sp_close_grid_cell();
    }
    # add filter now so that propeties is always the bottom tool
    $out = apply_filters('sph_add_topic_tool', $out, $topic, $forum, $page, $br);
    if ($spThisUser->admin || $spThisUser->moderator) {
        $out .= sp_open_grid_cell();
        $title = sp_text('View properties');
        $site = SFHOMEURL . 'index.php?sp_ahah=admintools&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;action=properties&amp;group=' . $forum['group_id'] . '&amp;forum=' . $forum['forum_id'] . '&amp;topic=' . $topic['topic_id'];
        $out .= '<div class="spForumToolsProperties">';
        $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">';
        $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsProperties.png') . $br;
        $out .= $title . '</a>';
        $out .= '</div>';
        $out .= sp_close_grid_cell();
    }
    $out .= sp_close_grid();
    $out .= '</div></div>';
    $out = apply_filters('sph_topic_tools', $out, $topic, $forum, $page, $br);
    return $out;
}