예제 #1
0
function topic_icons_label($label)
{
    global $topic;
    if (bb_is_front() || bb_is_forum() || bb_is_view() || bb_is_tag()) {
        $icon_set_name = topic_icons_get_active_icon_set();
        $icon_set_url = ICON_SET_URL_BASE . $icon_set_name;
        $status = get_active_status_interpreter()->getStatus(bb_get_location(), $topic);
        $renderer = get_active_status_renderer();
        $image = $renderer->renderStatus($status);
        $tooltip = $renderer->renderStatusTooltip($status);
        $exists = file_exists(dirname(__FILE__) . '/icon-sets/' . $icon_set_name . '/' . $image);
        if (!$exists) {
            return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), ICON_SET_URL_BASE . '/empty.png', ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
        } else {
            if (strlen($tooltip) > 0) {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"><span>%s</span></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $tooltip, $label);
            } else {
                return sprintf(__('<div class="topic-icon-image"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s" border="0"></a></div> %s'), get_topic_link($topic->topic_id), $icon_set_url . '/' . $image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $label);
            }
        }
    }
    return $label;
}
function get_latest_topics($args = null)
{
    $defaults = array('forum' => false, 'page' => 1, 'exclude' => false, 'number' => false);
    if (is_numeric($args)) {
        $args = array('forum' => $args);
    } else {
        $args = wp_parse_args($args);
    }
    // Make sure it's an array
    if (1 < func_num_args()) {
        $args['page'] = func_get_arg(1);
    }
    if (2 < func_num_args()) {
        $args['exclude'] = func_get_arg(2);
    }
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if ($exclude) {
        $exclude = '-' . str_replace(',', ',-', $exclude);
        $exclude = str_replace('--', '-', $exclude);
        if ($forum) {
            $forum = (string) $forum . ",{$exclude}";
        } else {
            $forum = $exclude;
        }
    }
    $q = array('forum_id' => $forum, 'page' => $page, 'per_page' => $number, 'index_hint' => 'USE INDEX (`forum_time`)');
    if (bb_is_front()) {
        $q['sticky'] = '-2';
    } elseif (bb_is_forum() || bb_is_view()) {
        $q['sticky'] = 0;
    }
    // Last param makes filters back compat
    $query = new BB_Query('topic', $q, 'get_latest_topics');
    return $query->results;
}
예제 #3
0
function is_forum()
{
    bb_log_deprecated('function', __FUNCTION__, 'bb_is_forum');
    return bb_is_forum();
}
/**
 * bb_get_new_topic_link() - Get the link to the form for a new topic
 *
 * @since 1.0
 * @param mixed The arguments for this function.
 * @return string The link to the new topic form
 */
function bb_get_new_topic_link($args = null)
{
    $defaults = array('text' => __('Add New &raquo;'), 'forum' => 0, 'tag' => '');
    if ($args && is_string($args) && false === strpos($args, '=')) {
        $args = array('text' => $args);
    }
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if ($forum && ($forum = bb_get_forum($forum))) {
        $url = get_forum_link($forum->forum_id) . '#postform';
    } elseif ($tag && ($tag = bb_get_tag($tag))) {
        $url = bb_get_tag_link($tag->tag) . '#postform';
    } elseif (bb_is_forum()) {
        global $forum;
        $url = get_forum_link($forum->forum_id) . '#postform';
    } elseif (bb_is_tag()) {
        global $tag;
        $url = bb_get_tag_link($tag) . '#postform';
    } elseif (bb_is_topic()) {
        $url = get_forum_link() . '#postform';
    } elseif (bb_is_front()) {
        $url = bb_get_uri(null, array('new' => 1));
    }
    if (!bb_is_user_logged_in()) {
        $url = bb_get_uri('bb-login.php', array('re' => $url), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS);
    } elseif (bb_is_forum() || bb_is_topic()) {
        if (!bb_current_user_can('write_topic', get_forum_id())) {
            return;
        }
    } else {
        if (!bb_current_user_can('write_topics')) {
            return;
        }
    }
    if ($url = esc_attr(apply_filters('new_topic_url', $url, $args))) {
        return '<a href="' . $url . '" class="new-topic">' . $text . '</a>' . "\n";
    }
}