当前位置: 首页>>代码示例>>PHP>>正文


PHP bb_get_tag函数代码示例

本文整理汇总了PHP中bb_get_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP bb_get_tag函数的具体用法?PHP bb_get_tag怎么用?PHP bb_get_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bb_get_tag函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: em_do_linking

/**
 * Links the users & tags in posts
 *
 * @see bp_activity_at_name_filter() BuddyPress Function
 * 
 * @param $content The content to be parsed
 */
function em_do_linking($content)
{
    global $em_plugopts;
    if ($em_plugopts['link-tags'] == 1) {
        preg_match_all('/[#]+([A-Za-z0-9-_]+)/', $content, $tags);
        $tags = $tags[1];
        foreach ((array) $tags as $tag) {
            if (!($t = bb_get_tag($tag))) {
                continue;
            }
            if ($link = bb_get_tag_link($t)) {
                $content = str_replace("#{$tag}", "#<a href='" . $link . "'>{$tag}</a>", $content);
            }
            //should we add rel='nofollow'?
        }
    }
    if ($em_plugopts['link-users'] == 1) {
        preg_match_all('/[@]+([A-Za-z0-9-_]+)/', $content, $usernames);
        $usernames = $usernames[1];
        foreach ((array) $usernames as $username) {
            if (!($user = bb_get_user($username, array('by' => 'login')))) {
                //check #1, by username
                if (!($user = bb_get_user($username, array('by' => 'nicename')))) {
                    //check #2, by nicename
                    continue;
                }
            }
            /* Increase the number of new @ mentions for the user - maybe later */
            /*$new_mention_count = (int)bb_get_usermeta( $user_id, 'em_mention_count' );
            		bb_update_usermeta( $user_id, 'em_mention_count', $new_mention_count + 1 );*/
            if ('website' == $em_plugopts['link-user-to']) {
                if (!($link = $user->user_url)) {
                    $link = get_user_profile_link($user->ID);
                }
            } else {
                $link = get_user_profile_link($user->ID);
            }
            if ($link) {
                $content = str_replace("@{$username}", "@<a href='" . $link . "'>{$username}</a>", $content);
            }
            //should we add rel='nofollow'?
        }
    }
    return $content;
}
开发者ID:achorg,项目名称:DH-Answers,代码行数:52,代码来源:public.php

示例2: bb_die

<?php

require 'admin.php';
if (!bb_current_user_can('manage_tags')) {
    bb_die(__('You are not allowed to manage tags.'));
}
$tag_id = (int) $_POST['id'];
$tag = stripslashes($_POST['tag']);
bb_check_admin_referer('rename-tag_' . $tag_id);
if (!($old_tag = bb_get_tag($tag_id))) {
    bb_die(__('Tag not found.'));
}
if ($tag = bb_rename_tag($tag_id, $tag)) {
    wp_redirect(bb_get_tag_link());
} else {
    bb_die(printf(__('There already exists a tag by that name or the name is invalid. <a href="%s">Try Again</a>'), wp_get_referer()));
}
exit;
开发者ID:danielcoats,项目名称:schoolpress,代码行数:18,代码来源:tag-rename.php

示例3: __construct

 /**
  * Constructor method.
  *
  * @param string $type The 'type' is the sort order/kind. 'newest',
  *        'popular', 'unreplied', 'tags'.
  * @param int $forum_id The ID of the forum for which topics are being
  *        queried.
  * @param int $user_id The ID of the user to whom topics should be
  *        limited. Pass false to remove this filter.
  * @param int $page The number of the page being requested.
  * @param int $per_page The number of items being requested perpage.
  * @param string $no_stickies Requested sticky format.
  * @param string $search_terms Filter results by a string.
  * @param int $offset Optional. Offset results by a given numeric value.
  * @param int $number Optional. Total number of items to retrieve.
  */
 function __construct($type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false)
 {
     global $bp;
     $this->pag_page = $page;
     $this->pag_num = $per_page;
     $this->type = $type;
     $this->search_terms = $search_terms;
     $this->forum_id = $forum_id;
     $this->offset = $offset;
     $this->number = $number;
     switch ($type) {
         case 'newest':
         default:
             $this->topics = bp_forums_get_forum_topics(array('user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'offset' => $offset, 'number' => $number));
             break;
         case 'popular':
             $this->topics = bp_forums_get_forum_topics(array('user_id' => $user_id, 'type' => 'popular', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'offset' => $offset, 'number' => $number));
             break;
         case 'unreplied':
             $this->topics = bp_forums_get_forum_topics(array('user_id' => $user_id, 'type' => 'unreplied', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'offset' => $offset, 'number' => $number));
             break;
         case 'tags':
             $this->topics = bp_forums_get_forum_topics(array('user_id' => $user_id, 'type' => 'tags', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'offset' => $offset, 'number' => $number));
             break;
     }
     $this->topics = apply_filters('bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies);
     if (!(int) $this->topics) {
         $this->topic_count = 0;
         $this->total_topic_count = 0;
     } else {
         // Get a total topic count, for use in pagination. This value will differ
         // depending on scope
         if (!empty($forum_id)) {
             // Group forums
             $topic_count = bp_forums_get_forum($forum_id);
             $topic_count = (int) $topic_count->topics;
         } else {
             if (!empty($bp->groups->current_group)) {
                 $topic_count = (int) groups_total_public_forum_topic_count($type);
             } else {
                 if (bp_is_user_forums_started() || bp_is_directory() && $user_id) {
                     // This covers the case of Profile > Forums > Topics Started, as
                     // well as Forum Directory > My Topics
                     $topic_count = bp_forums_total_topic_count_for_user(bp_displayed_user_id(), $type);
                 } else {
                     if (bp_is_user_forums_replied_to()) {
                         // Profile > Forums > Replied To
                         $topic_count = bp_forums_total_replied_count_for_user(bp_displayed_user_id(), $type);
                     } else {
                         if ('tags' == $type) {
                             $tag = bb_get_tag($search_terms);
                             $topic_count = $tag->count;
                         } else {
                             // For forum directories (All Topics), get a true count
                             $status = bp_current_user_can('bp_moderate') ? 'all' : 'public';
                             // todo: member-of
                             $topic_count = (int) groups_total_forum_topic_count($status, $search_terms);
                         }
                     }
                 }
             }
         }
         if (!$max || $max >= $topic_count) {
             $this->total_topic_count = $topic_count;
         } else {
             $this->total_topic_count = (int) $max;
         }
         if ($max) {
             if ($max >= count($this->topics)) {
                 $this->topic_count = count($this->topics);
             } else {
                 $this->topic_count = (int) $max;
             }
         } else {
             $this->topic_count = count($this->topics);
         }
     }
     $this->topic_count = apply_filters_ref_array('bp_forums_template_topic_count', array($this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies));
     $this->total_topic_count = apply_filters_ref_array('bp_forums_template_total_topic_count', array($this->total_topic_count, $this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies));
     // Fetch extra information for topics, so we don't have to query inside the loop
     $this->topics = bp_forums_get_topic_extras($this->topics);
     if ((int) $this->total_topic_count && (int) $this->pag_num) {
         $this->pag_links = paginate_links(array('base' => add_query_arg(array('p' => '%#%', 'n' => $this->pag_num)), 'format' => '', 'total' => ceil((int) $this->total_topic_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('&larr;', 'Forum topic pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Forum topic pagination next text', 'buddypress'), 'mid_size' => 1));
     }
//.........这里部分代码省略.........
开发者ID:danielcoats,项目名称:schoolpress,代码行数:101,代码来源:bp-forums-template.php

示例4: bb_repermalink


//.........这里部分代码省略.........
                if (bb_get_option('mod_rewrite') === 'slugs') {
                    if (!($user = bb_get_user_by_nicename($id))) {
                        $user = bb_get_user($id);
                    }
                } else {
                    if (!($user = bb_get_user($id))) {
                        $user = bb_get_user_by_nicename($id);
                    }
                }
            }
            if (!$user || 1 == $user->user_status && !bb_current_user_can('moderate')) {
                bb_die(__('User not found.'), '', 404);
            }
            $user_id = $user->ID;
            bb_global_profile_menu_structure();
            $valid = false;
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                foreach ($profile_hooks as $valid_tab => $valid_file) {
                    if ($tab == $valid_tab) {
                        $valid = true;
                        $self = $valid_file;
                    }
                }
            }
            if ($valid) {
                $permalink = get_profile_tab_link($user->ID, $tab, $page);
            } else {
                $permalink = get_user_profile_link($user->ID, $page);
                unset($self, $tab);
            }
            break;
        case 'favorites-page':
            $permalink = get_favorites_link();
            break;
        case 'tag-page':
            // It's not an integer and tags.php pulls double duty.
            $id = isset($_GET['tag']) ? $_GET['tag'] : false;
            if (!$id || !bb_get_tag((string) $id)) {
                $permalink = bb_get_tag_page_link();
            } else {
                global $tag, $tag_name;
                $tag_name = $id;
                $tag = bb_get_tag((string) $id);
                $permalink = bb_get_tag_link(0, $page);
                // 0 => grabs $tag from global.
            }
            break;
        case 'view-page':
            // Not an integer
            if (isset($_GET['view'])) {
                $id = $_GET['view'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            global $view;
            $view = $id;
            $permalink = get_view_link($view, $page);
            break;
        default:
            return;
            break;
    }
    nxt_parse_str($_SERVER['QUERY_STRING'], $args);
    $args = urlencode_deep($args);
    if ($args) {
        $permalink = add_query_arg($args, $permalink);
        if (bb_get_option('mod_rewrite')) {
            $pretty_args = array('id', 'page', 'tag', 'tab', 'username');
            // these are already specified in the path
            if ($location == 'view-page') {
                $pretty_args[] = 'view';
            }
            foreach ($pretty_args as $pretty_arg) {
                $permalink = remove_query_arg($pretty_arg, $permalink);
            }
        }
    }
    $permalink = apply_filters('bb_repermalink_result', $permalink, $location);
    $domain = bb_get_option('domain');
    $domain = preg_replace('/^https?/', '', $domain);
    $check = preg_replace('|^.*' . trim($domain, ' /') . '|', '', $permalink, 1);
    $uri = rtrim($uri, " \t\n\r\v?");
    $uri = str_replace('/index.php', '/', $uri);
    global $bb_log;
    $bb_log->debug($uri, 'bb_repermalink() ' . __('REQUEST_URI'));
    $bb_log->debug($check, 'bb_repermalink() ' . __('should be'));
    $bb_log->debug($permalink, 'bb_repermalink() ' . __('full permalink'));
    $bb_log->debug(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null, 'bb_repermalink() ' . __('PATH_INFO'));
    if ($check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri)) {
        if ($issue_404 && rtrim($check, " \t\n\r\v/") !== rtrim($uri, " \t\n\r\v/")) {
            status_header(404);
            bb_load_template('404.php');
        } else {
            nxt_redirect($permalink);
        }
        exit;
    }
    do_action('post_permalink', $permalink);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:101,代码来源:functions.bb-core.php

示例5: bb_destroyTopicTag

 /**
  * Destroys the specified tag
  *
  * @since 1.0
  * @return integer|object 1 when successfully deleted or an IXR_Error object on failure
  * @param array $args Arguments passed by the XML-RPC call
  * @param string $args[0] The username for authentication
  * @param string $args[1] The password for authentication
  * @param string $args[2] The tag name or slug to be destroyed
  *
  * XML-RPC request to destroy the tag "banana"
  * <methodCall>
  *     <methodName>bb.destroyTopicTag</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><string>banana</string></value></param>
  *     </params>
  * </methodCall>
  */
 function bb_destroyTopicTag($args)
 {
     do_action('bb_xmlrpc_call', 'bb.destroyTopicTag');
     // Escape args
     $this->escape($args);
     // Get the login credentials
     $username = $args[0];
     $password = (string) $args[1];
     // Check the user is valid
     $user = $this->authenticate($username, $password, 'manage_tags', __('You do not have permission to manage tags.'));
     do_action('bb_xmlrpc_call_authenticated', 'bb.destroyTopicTag');
     // If an error was raised by authentication or by an action then return it
     if ($this->error) {
         return $this->error;
     }
     // Can only be a string
     $tag_id = isset($args[2]) ? (string) $args[2] : false;
     // Check for bad data
     if (!$tag_id) {
         $this->error = new IXR_Error(400, __('The tag id is invalid.'));
         return $this->error;
     }
     // Check the requested tag exists
     if (!($tag = bb_get_tag($tag_id))) {
         $this->error = new IXR_Error(400, __('No tag found.'));
         return $this->error;
     }
     // Get the numeric tag id
     $tag_id = (int) $tag->tag_id;
     // Destroy the tag
     if (!($result = bb_destroy_tag($tag_id))) {
         $this->error = new IXR_Error(500, __('The tag could not be destroyed.'));
         return $this->error;
     }
     $result = 1;
     do_action('bb_xmlrpc_call_return', 'bb.destroyTopicTag');
     // Return the tag
     return $result;
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:59,代码来源:xmlrpc.php

示例6: bb_merge_tags

function bb_merge_tags($old_id, $new_id)
{
    if (!bb_current_user_can('manage_tags')) {
        return false;
    }
    $old_id = (int) $old_id;
    $new_id = (int) $new_id;
    if ($old_id == $new_id) {
        return false;
    }
    do_action('bb_pre_merge_tags', $old_id, $new_id);
    // Get all topics tagged with old tag
    $old_topics = bb_get_tagged_topic_ids($old_id);
    // Get all toics tagged with new tag
    $new_topics = bb_get_tagged_topic_ids($new_id);
    // Get intersection of those topics
    $both_topics = array_intersect($old_topics, $new_topics);
    // Discard the intersection from the old tags topics
    $old_topics = array_diff($old_topics, $both_topics);
    // Add the remainder of the old tag topics to the new tag
    if (count($old_topics)) {
        $new_tag = bb_get_tag($new_id);
        foreach ($old_topics as $old_topic) {
            bb_add_topic_tag($old_topic, $new_tag->slug);
        }
    }
    // Destroy the old tag
    $old_tag = bb_destroy_tag($old_id);
    return array('destroyed' => $old_tag, 'old_count' => count($old_topics), 'diff_count' => count($both_topics));
}
开发者ID:hscale,项目名称:webento,代码行数:30,代码来源:functions.bb-topic-tags.php

示例7: bb_get_tag_by_name

function bb_get_tag_by_name($tag)
{
    bb_log_deprecated('function', __FUNCTION__, 'bb_get_tag');
    return bb_get_tag($tag);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:5,代码来源:functions.bb-deprecated.php

示例8: bb_get_tag_remove_link

function bb_get_tag_remove_link($args = null)
{
    if (is_scalar($args) || is_object($args)) {
        $args = array('tag' => $args);
    }
    $defaults = array('tag' => 0, 'topic' => 0, 'list_id' => 'tags-list');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if (is_object($tag) && isset($tag->tag_id)) {
    } elseif (!($tag = bb_get_tag(bb_get_tag_id($tag)))) {
        return false;
    }
    if (!($topic = get_topic(get_topic_id($topic)))) {
        return false;
    }
    if (!bb_current_user_can('edit_tag_by_on', $tag->user_id, $topic->topic_id)) {
        return false;
    }
    $url = bb_get_uri('tag-remove.php', array('tag' => $tag->tag_id, 'user' => $tag->user_id, 'topic' => $topic->topic_id));
    $url = esc_url(bb_nonce_url($url, 'remove-tag_' . $tag->tag_id . '|' . $topic->topic_id));
    $title = esc_attr__('Remove this tag');
    $list_id = esc_attr($list_id);
    return "[<a href='{$url}' class='delete:{$list_id}:tag-{$tag->tag_id}_{$tag->user_id}' title='{$title}'>&times;</a>]";
}
开发者ID:abc2mit,项目名称:abc2mit.github.io,代码行数:24,代码来源:functions.bb-template.php

示例9: array

     if (!($tag = bb_get_tag($feed_id))) {
         die;
     }
     if (!($topics = get_tagged_topics(array('tag_id' => $tag->tag_id, 'page' => 0)))) {
         die;
     }
     $posts = array();
     foreach ($topics as $topic) {
         $posts[] = bb_get_first_post($topic->topic_id);
     }
     $title = esc_html(sprintf(__('%1$s &raquo; Tag: %2$s - Recent Topics'), bb_get_option('name'), bb_get_tag_name()));
     $link = bb_get_tag_link($feed_id);
     $link_self = bb_get_tag_topics_rss_link($feed_id);
     break;
 case 'tag-posts':
     if (!($tag = bb_get_tag($feed_id))) {
         die;
     }
     if (!($posts = get_tagged_topic_posts(array('tag_id' => $tag->tag_id, 'page' => 0)))) {
         die;
     }
     $title = esc_html(sprintf(__('%1$s &raquo; Tag: %2$s - Recent Posts'), bb_get_option('name'), bb_get_tag_name()));
     $link = bb_get_tag_link($feed_id);
     $link_self = bb_get_tag_posts_rss_link($feed_id);
     break;
 case 'forum-topics':
     if (!($topics = get_latest_topics($feed_id))) {
         die;
     }
     $posts = array();
     foreach ($topics as $topic) {
开发者ID:abc2mit,项目名称:abc2mit.github.io,代码行数:31,代码来源:rss.php

示例10: esc_attr

         $tag->raw_tag = esc_attr($tag->raw_tag);
         $x->add(array('what' => 'tag', 'id' => $tag_id_val, 'data' => _bb_list_tag_item($tag, array('list_id' => 'tags-list', 'format' => 'list'))));
     }
     $x->send();
     break;
 case 'delete-tag':
     list($tag_id, $user_id) = explode('_', $_POST['id']);
     $tag_id = (int) $tag_id;
     $user_id = (int) $user_id;
     $topic_id = (int) $_POST['topic_id'];
     if (!bb_current_user_can('edit_tag_by_on', $user_id, $topic_id)) {
         die('-1');
     }
     bb_check_ajax_referer("remove-tag_{$tag_id}|{$topic_id}");
     add_action('bb_rpe_tag_removed', 'bb_grab_results', 10, 3);
     $tag = bb_get_tag($tag_id);
     $user = bb_get_user($user_id);
     $topic = get_topic($topic_id);
     if (!$tag || !$topic) {
         die('0');
     }
     if (false !== bb_remove_topic_tag($tag_id, $user_id, $topic_id)) {
         die('1');
     }
     break;
 case 'dim-favorite':
     $user_id = bb_get_current_user_info('id');
     if (!($topic = get_topic($id))) {
         die('0');
     }
     if (!bb_current_user_can('edit_favorites_of', $user_id)) {
开发者ID:laiello,项目名称:cartonbank,代码行数:31,代码来源:admin-ajax.php

示例11: bb_die

<?php

require 'admin.php';
if (!bb_current_user_can('manage_tags')) {
    bb_die(__('You are not allowed to manage tags.'));
}
$old_id = (int) $_POST['id'];
$tag = $_POST['tag'];
bb_check_admin_referer('merge-tag_' . $old_id);
if (!($tag = bb_get_tag($tag))) {
    bb_die(__('The destination tag you specified could not be found.'));
}
if (!bb_get_tag($old_id)) {
    bb_die(__('The original tag could not be found.'));
}
if ($merged = bb_merge_tags($old_id, $tag->tag_id)) {
    bb_die(sprintf(__("Number of topics from which the old tag was removed: %d <br />\n"), $merged['old_count']) . sprintf(__("Number of topics to which the new tag was added: %d <br />\n"), $merged['diff_count']) . sprintf(__("Number of rows deleted from tags table:%d <br />\n"), $merged['destroyed']['tags']) . sprintf(__('<a href="%s">View Results of Merge</a>'), bb_get_tag_link()));
} else {
    bb_die(printf(__("Something odd happened when attempting to merge those tags.<br />\n<a href=\"%s\">Try Again?</a>"), nxt_get_referer()));
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:20,代码来源:tag-merge.php


注:本文中的bb_get_tag函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。