本文整理汇总了PHP中get_topic函数的典型用法代码示例。如果您正苦于以下问题:PHP get_topic函数的具体用法?PHP get_topic怎么用?PHP get_topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_topic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSendRepost
public function beforeSendRepost($param)
{
//检测话题的存在性
$topic = get_topic($param['content']);
if (isset($topic) && !is_null($topic)) {
foreach ($topic as $e) {
$tik = D('Weibo/Topic')->where(array('name' => $e))->find();
//没有这个话题的时候创建这个话题
if (!$tik) {
D('Weibo/Topic')->add(array('name' => $e));
}
}
}
}
示例2: addTopic
public function addTopic(&$content)
{
//检测话题的存在性
$topic = get_topic($content);
if (isset($topic) && !is_null($topic)) {
foreach ($topic as $e) {
$tik = $this->where(array('name' => $e))->find();
//没有这个话题的时候创建这个话题
if (!$tik) {
$this->add(array('name' => $e));
}
}
}
}
示例3: parse_topic
function parse_topic($content)
{
//找出话题
$topic = get_topic($content);
//将##替换成链接
foreach ($topic as $e) {
$tik = D('Weibo/Topic')->where(array('name' => $e))->find();
//没有这个话题的时候创建这个话题
if ($tik) {
//D('Weibo/Topic')->add(array('name'=> $e));
$space_url = U('Weibo/Topic/index', array('topk' => urlencode($e)));
$content = str_replace("#{$e}#", "<a href=\"{$space_url}\" target=\"_blank\">#{$e}# </a>", $content);
}
}
//返回替换的文本
return $content;
}
示例4: mod_notification_new_post
function mod_notification_new_post()
{
global $bbdb, $topic_id, $bb_current_user;
$all_moderators = notification_select_all_mods();
$topic = get_topic($topic_id);
$header = 'From: ' . bb_get_option('name') . ' <' . bb_get_option('from_email') . '>';
$header .= 'MIME-Version: 1.0' . "\n";
$header .= 'Content-Type: text/plain; charset="' . BBDB_CHARSET . '"' . "\n";
$header .= 'Content-Transfer-Encoding: 7bit' . "\n";
$subject = '[DHAnswers] New Post';
foreach ($all_moderators as $userdata) {
if (mod_notification_is_activated($userdata->ID)) {
$msg = "Hello,\n\nA new post has been added to \"" . $topic->topic_title . "\" at DHAnswers. \n\n" . get_topic_link($topic_id);
mail($userdata->user_email, $subject, $msg, $header);
}
}
}
示例5: bb_auth
<?php
require './bb-load.php';
bb_auth('logged_in');
if (!bb_is_user_logged_in()) {
bb_die(__('You need to be logged in to add a tag.'));
}
$topic_id = (int) @$_POST['id'];
$page = (int) @$_POST['page'];
$tag = @$_POST['tag'];
$tag = stripslashes($tag);
bb_check_admin_referer('add-tag_' . $topic_id);
if (!($topic = get_topic($topic_id))) {
bb_die(__('Topic not found.'));
}
if (bb_add_topic_tags($topic_id, $tag)) {
nxt_redirect(get_topic_link($topic_id, $page));
} else {
bb_die(__('The tag was not added. Either the tag name was invalid or the topic is closed.'));
}
exit;
示例6: ass_group_notification_forum_posts
/**
* When a new forum topic or post is posted in bbPress, either:
* 1) Send emails to all group subscribers
* 2) Prepares to record it for digest purposes - see {@link ass_group_forum_record_digest()}.
*
* Hooks into the bbPress action - 'bb_new_post' - to easily identify new forum posts vs edits.
*/
function ass_group_notification_forum_posts($post_id)
{
global $bp, $wpdb;
$post = bb_get_post($post_id);
// Check to see if user has been registered long enough
if (!ass_registered_long_enough($post->poster_id)) {
return;
}
$topic = get_topic($post->topic_id);
$group = groups_get_current_group();
// if the current group isn't available, grab it
if (empty($group)) {
// get the group ID by looking up the forum ID in the groupmeta table
$group_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT group_id\n\t\t\t\tFROM {$bp->groups->table_name_groupmeta}\n\t\t\t\tWHERE meta_key = %s\n\t\t\t\tAND meta_value = %d\n\t\t\t", 'forum_id', $topic->forum_id));
// now get the group
$group = groups_get_group(array('group_id' => $group_id));
}
$primary_link = trailingslashit(bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug);
$blogname = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . ']';
$is_topic = false;
// initialize faux activity object for backpat filter reasons
//
// due to r-a-y being an idiot here:
// https://github.com/boonebgorges/buddypress-group-email-subscription/commit/526b80c617fe9058a859ac4eb4cfb1d42d333aa0
//
// because we moved the email recording process to 'bb_new_post' from the BP activity save hook,
// we need to ensure that 3rd-party code will continue to work as-is
//
// we can't add the 'id' because we're firing the filters before the activity item is created :(
$activity = new stdClass();
$activity->user_id = $post->poster_id;
$activity->component = 'groups';
$activity->item_id = $group->id;
$activity->content = $post->post_text;
// this is a new topic
if ($post->post_position == 1) {
$is_topic = true;
// more faux activity items!
$activity->type = 'new_forum_topic';
$activity->secondary_item_id = $topic->topic_id;
$activity->primary_link = $primary_link;
$action = $activity->action = sprintf(__('%s started the forum topic "%s" in the group "%s"', 'bp-ass'), bp_core_get_user_displayname($post->poster_id), $topic->topic_title, $group->name);
$subject = apply_filters('bp_ass_new_topic_subject', $action . ' ' . $blogname, $action, $blogname);
$the_content = apply_filters('bp_ass_new_topic_content', $post->post_text, $activity, $topic, $group);
} else {
// more faux activity items!
$activity->type = 'new_forum_post';
$activity->secondary_item_id = $post_id;
$action = $activity->action = sprintf(__('%s replied to the forum topic "%s" in the group "%s"', 'bp-ass'), bp_core_get_user_displayname($post->poster_id), $topic->topic_title, $group->name);
// calculate the topic page for pagination purposes
$pag_num = apply_filters('bp_ass_topic_pag_num', 15);
$page = ceil($topic->topic_posts / $pag_num);
if ($page > 1) {
$primary_link .= '?topic_page=' . $page;
}
$primary_link .= "#post-" . $post_id;
$activity->primary_link = $primary_link;
$subject = apply_filters('bp_ass_forum_reply_subject', $action . ' ' . $blogname, $action, $blogname);
$the_content = apply_filters('bp_ass_forum_reply_content', $post->post_text, $activity, $topic, $group);
}
// Convert entities and do other cleanup
$the_content = ass_clean_content($the_content);
// if group is not public, change primary link to login URL to verify
// authentication and for easier redirection after logging in
if ($group->status != 'public') {
$primary_link = ass_get_login_redirect_url($primary_link, 'legacy_forums_view');
$text_before_primary = __('To view or reply to this topic, go to:', 'bp-ass');
// if public, show standard text
} else {
$text_before_primary = __('To view or reply to this topic, log in and go to:', 'bp-ass');
}
// setup the email meessage
$message = sprintf(__('%s
"%s"
%s
%s
---------------------
', 'bp-ass'), $action . ':', $the_content, $text_before_primary, $primary_link);
// get subscribed users
$subscribed_users = groups_get_groupmeta($group->id, 'ass_subscribed_users');
// do this for forum replies only
if (!$is_topic) {
// pre-load these arrays to reduce db calls in the loop
$ass_replies_to_my_topic = ass_user_settings_array('ass_replies_to_my_topic');
$ass_replies_after_me_topic = ass_user_settings_array('ass_replies_after_me_topic');
$previous_posters = ass_get_previous_posters($post->topic_id);
// make sure manually-subscribed topic users and regular group subscribed users are combined
$user_topic_status = groups_get_groupmeta($group->id, 'ass_user_topic_status_' . $topic->topic_id);
if (!empty($subscribed_users) && !empty($user_topic_status)) {
$subscribed_users = $subscribed_users + $user_topic_status;
//.........这里部分代码省略.........
示例7: _e
<h3 id="useractivity"><?php
_e('User Activity');
?>
</h3>
<div id="user-replies" class="user-recent"><h4><?php
_e('Recent Replies');
?>
</h4>
<?php
if ($posts) {
?>
<ol>
<?php
foreach ($posts as $bb_post) {
$topic = get_topic($bb_post->topic_id);
?>
<li<?php
alt_class('replies');
?>
>
<a href="<?php
topic_link();
?>
"><?php
topic_title();
?>
</a> -
<?php
if ($user->ID == bb_get_current_user_info('id')) {
printf(__('You last replied: %s ago'), bb_get_post_time());
示例8: get_topic
<?php
require 'admin-action.php';
$topic_id = (int) $_GET['id'];
$topic = get_topic($topic_id);
if (!$topic) {
bb_die(__('There is a problem with that topic, pardner.'));
}
if (!bb_current_user_can('close_topic', $topic_id)) {
nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
exit;
}
bb_check_admin_referer('close-topic_' . $topic_id);
if (topic_is_open($topic_id)) {
bb_close_topic($topic_id);
$message = 'closed';
} else {
bb_open_topic($topic_id);
$message = 'opened';
}
if ($sendto = nxt_get_referer()) {
$sendto = remove_query_arg('message', $sendto);
$sendto = add_query_arg('message', $message, $sendto);
} else {
$sendto = get_topic_link($topic_id);
}
bb_safe_redirect($sendto);
exit;
示例9: bb_ksd_new_post
function bb_ksd_new_post($post_id)
{
global $bb_ksd_pre_post_status;
if ('2' != $bb_ksd_pre_post_status) {
return;
}
$bb_post = bb_get_post($post_id);
$topic = get_topic($bb_post->topic_id);
if (0 == $topic->topic_posts) {
bb_delete_topic($topic->topic_id, 2);
}
}
示例10: parse_topic
function parse_topic($content)
{
//找出话题
$topic = get_topic($content);
//将##替换成链接
foreach ($topic as $e) {
$tik = D('Weibo/Topic')->where(array('name' => $e))->find();
//没有这个话题的时候创建这个话题
if ($tik) {
//D('Weibo/Topic')->add(array('name'=> $e));
$space_url = U('Weibo/Topic/index', array('topk' => urlencode($e)));
if (modC('HIGH_LIGHT_TOPIC', 1, 'Weibo')) {
$content = str_replace("#{$e}#", " <a class='label label-badge label-info' href=\"{$space_url}\" target=\"_blank\">#{$e}# </a> ", $content);
} else {
$content = str_replace("#{$e}#", " <a href=\"{$space_url}\" target=\"_blank\">#{$e}# </a> ", $content);
}
}
}
//返回替换的文本
return $content;
}
示例11: bb_get_topic_tags
/**
* bb_get_topic_tags() - Returns all of the bb_topic_tags associated with the specified topic.
*
* @param int $topic_id
* @param mixed $args
* @return array|false Term objects (back-compat), false on failure
*/
function bb_get_topic_tags($topic_id = 0, $args = null)
{
global $wp_taxonomy_object;
if (!($topic = get_topic(get_topic_id($topic_id)))) {
return false;
}
$topic_id = (int) $topic->topic_id;
$cache_id = $topic_id . serialize($args);
$terms = wp_cache_get($cache_id, 'bb_topic_tag_terms');
if (false === $terms) {
$terms = $wp_taxonomy_object->get_object_terms((int) $topic->topic_id, 'bb_topic_tag', $args);
wp_cache_set($cache_id, $terms, 'bb_topic_tag_terms');
}
if (is_wp_error($terms)) {
return false;
}
for ($i = 0; isset($terms[$i]); $i++) {
_bb_make_tag_compat($terms[$i]);
}
return $terms;
}
示例12: bb_add_user_favorite
function bb_add_user_favorite($user_id, $topic_id)
{
global $bbdb;
$user_id = (int) $user_id;
$topic_id = (int) $topic_id;
$user = bb_get_user($user_id);
$topic = get_topic($topic_id);
if (!$user || !$topic) {
return false;
}
$favorites_key = $bbdb->prefix . 'favorites';
$fav = $user->{$favorites_key} ? explode(',', $user->{$favorites_key}) : array();
if (!in_array($topic_id, $fav)) {
$fav[] = $topic_id;
$fav = implode(',', $fav);
bb_update_usermeta($user->ID, $favorites_key, $fav);
}
do_action('bb_add_user_favorite', $user_id, $topic_id);
return true;
}
示例13: view_increment
$page_no_var = $var;
//get the current Page from URL
}
}
//--increment views of poem--//
$update_poem = view_increment($database, $poem_id);
//--get poem information--//
$get_poem = get_poem($database, $poem_id);
//--get topic information--//
if ($get_poem['topic_id']) {
$poem_topics_array = array();
//get topic ids as array
$poem_topics = unserialize($get_poem['topic_id']);
foreach ($poem_topics as $poem_topic_id) {
if (!array_key_exists($poem_topic_id, $poem_topics_array)) {
$poem_topic_array[$poem_topic_id] = get_topic($database, $poem_topic_id);
}
}
$get_poem['topic_id'] = $poem_topic_array;
}
//--get author information--//
// $author_id = $get_poem['author_id'];
// if($get_poem['author_id']){
// $get_poem['author_id'] = get_author($database, $get_poem['author_id']);
// $tpl->author_info = $get_poem['author_id'];
// //get_user_info
// // submitter_id
// }
$submitter_id = $get_poem['submitter_id'];
if ($get_poem['submitter_id']) {
$data = get_user_info($database, $get_poem['submitter_id']);
示例14: bb_export_topic_posts
function bb_export_topic_posts($r, $topic_id)
{
if (!get_topic($topic_id)) {
return;
}
$r .= "\n";
$page = 1;
while ($posts = get_thread($topic_id, array('post_status' => 'all', 'page' => $page++))) {
foreach ($posts as $post) {
$r .= bb_export_post($post->post_id);
}
}
return $r;
}
示例15: blocklist_check
function blocklist_check($post_id = 0, $wall = false)
{
if (bb_current_user_can('moderate') || bb_current_user_can('throttle')) {
return;
}
if ($wall) {
$bb_post = user_wall_get_post($post_id);
} else {
$bb_post = bb_get_post($post_id);
}
if (empty($post_id) || empty($bb_post) || !empty($bb_post->post_status)) {
return;
}
global $blocklist, $bbdb;
blocklist_initialize();
if (empty($blocklist['data'])) {
return;
}
(array) ($data = explode("\r\n", $blocklist['data']));
$user = bb_get_user($bb_post->poster_id);
foreach ($data as $item) {
if (empty($item) || strlen($item) < 4 || ord($item) == 35) {
continue;
}
if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $item)) {
// is IP
if (strpos($bb_post->poster_ip, $item) === 0) {
$found = "IP address";
$bad = $item;
break;
}
} else {
// is word
$qitem = preg_quote($item);
if (preg_match('/\\b' . $qitem . '/simU', $user->user_email)) {
$found = "email";
$bad = $item;
break;
}
if (preg_match('/\\b' . $qitem . '/simU', $user->user_login)) {
$found = "username";
$bad = $item;
break;
}
if (preg_match('/\\b' . $qitem . '/simU', $bb_post->post_text)) {
$found = "post text";
$bad = $item;
break;
} elseif (!$wall && $bb_post->post_position == 1) {
if (empty($topic)) {
$topic = get_topic($bb_post->topic_id);
}
if (!empty($topic->topic_title) && preg_match('/\\b' . $qitem . '/simU', $topic->topic_title)) {
$found = "topic title";
$bad = $item;
break;
}
}
}
if (!empty($bad)) {
break;
}
}
if (!empty($bad)) {
if ($wall) {
user_wall_delete_post($post_id, 2);
$uri = bb_get_option('uri') . "bb-admin/admin-base.php?post_status=2&plugin=user_wall_admin&user-wall-recent=1";
} else {
bb_delete_post($post_id, 2);
if (empty($topic)) {
$topic = get_topic($bb_post->topic_id);
}
if (empty($topic->topic_posts)) {
bb_delete_topic($topic->topic_id, 2);
}
// if no posts in topic, also set topic to spam
$uri = bb_get_option('uri') . 'bb-admin/' . (defined('BACKPRESS_PATH') ? '' : 'content-') . 'posts.php?post_status=2';
}
if (empty($blocklist['email'])) {
return;
}
(array) ($email = explode("\r\n", $blocklist['email']));
$message = "The blocklist has been triggered... \r\n\r\n";
$message .= "Matching entry " . '"' . $bad . '"' . " found in {$found}.\r\n";
$message .= "{$uri}\r\n\r\n";
$message .= sprintf(__('Username: %s'), stripslashes($user->user_login)) . "\r\n";
$message .= sprintf(__('Profile: %s'), get_user_profile_link($user->ID)) . "\r\n";
$message .= sprintf(__('Email: %s'), stripslashes($user->user_email)) . "\r\n";
$message .= sprintf(__('IP address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n";
$message .= sprintf(__('Agent: %s'), substr(stripslashes($_SERVER["HTTP_USER_AGENT"]), 0, 255)) . "\r\n\r\n";
foreach ($email as $to) {
if (empty($to) || strlen($to) < 8) {
continue;
}
@bb_mail($to, "[" . bb_get_option('name') . "] blocklist triggered", $message);
}
}
}