• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP tag_create函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mc_tag_add

/**
 * Creates a tag 
 * 
 * @param string   $p_username        The user's username
 * @param string   $p_password        The user's password
 * @param array    $p_tag             The tag to create
 * @return soap_fault|integer
 */
function mc_tag_add($p_username, $p_password, $p_tag)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_create_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    $t_valid_matches = array();
    $t_tag_name = $p_tag['name'];
    $t_tag_description = array_key_exists('description', $p_tag) ? $p_tag['description'] : '';
    if (!tag_name_is_valid($t_tag_name, $t_valid_matches)) {
        return new soap_fault('client', '', 'Invalid tag name : "' . $t_tag_name . '"');
    }
    $t_matching_by_name = tag_get_by_name($t_tag_name);
    if ($t_matching_by_name != false) {
        return new soap_fault('client', '', 'A tag with the same name already exists , id: ' . $t_matching_by_name['id']);
    }
    return tag_create($t_tag_name, $t_user_id, $t_tag_description);
}
开发者ID:nextgens,项目名称:mantisbt,代码行数:29,代码来源:mc_tag_api.php


示例2: mc_tag_add

/**
 * Creates a tag
 *
 * @param string   $p_username        The user's username
 * @param string   $p_password        The user's password
 * @param array    $p_tag             The tag to create
 * @return soap_fault|integer
 */
function mc_tag_add($p_username, $p_password, $p_tag)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_create_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    $t_valid_matches = array();
    $p_tag = SoapObjectsFactory::unwrapObject($p_tag);
    $t_tag_name = $p_tag['name'];
    $t_tag_description = array_key_exists('description', $p_tag) ? $p_tag['description'] : '';
    if (!tag_name_is_valid($t_tag_name, $t_valid_matches)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Invalid tag name : "' . $t_tag_name . '"');
    }
    $t_matching_by_name = tag_get_by_name($t_tag_name);
    if ($t_matching_by_name != false) {
        return SoapObjectsFactory::newSoapFault('Client', 'A tag with the same name already exists , id: ' . $t_matching_by_name['id']);
    }
    log_event(LOG_WEBSERVICE, "creating tag '{$t_tag_name}' for user '{$t_user_id}'");
    return tag_create($t_tag_name, $t_user_id, $t_tag_description);
}
开发者ID:N0ctrnl,项目名称:mantisbt,代码行数:31,代码来源:mc_tag_api.php


示例3: add_tags_info

/**
 * function to attach tags into a post
 * @param int postid - id of the blog
 */
function add_tags_info($postid)
{
    global $USER;
    $post = get_record('post', 'id', $postid);
    /// Attach official tags
    if ($otags = optional_param('otags', '', PARAM_INT)) {
        foreach ($otags as $otag) {
            $tag->tagid = $otag;
            //insert_record('blog_tag_instance', $tag);
            tag_an_item('blog', $postid, $otag, 'official');
        }
    }
    /// Attach Personal Tags
    if ($ptags = optional_param('ptags', '', PARAM_NOTAGS)) {
        $ptags = explode(',', $ptags);
        foreach ($ptags as $ptag) {
            $ptag = trim($ptag);
            // check for existance
            // it does not matter whether it is an offical tag or personal tag
            // we do not want to have 1 copy of offical tag and 1 copy of personal tag (for the same tag)
            if ($ctag = tag_by_id($ptag)) {
                tag_an_item('blog', $postid, $ctag);
            } else {
                // create a personal tag
                if ($tagid = tag_create($ptag)) {
                    if ($tagid = array_shift($tagid)) {
                        tag_an_item('blog', $postid, $tagid);
                    }
                }
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:37,代码来源:edit.php


示例4: action_attach_tags_process

/**
 * Attaches all the tags to each bug in the group action.
 * @param integer Bug ID
 * @return boolean True if all tags attach properly
 */
function action_attach_tags_process($p_bug_id)
{
    global $g_action_attach_tags_attach, $g_action_attach_tags_create;
    $t_user_id = auth_get_current_user_id();
    foreach ($g_action_attach_tags_create as $t_tag_row) {
        $t_tag_row['id'] = tag_create($t_tag_row['name'], $t_user_id);
        $g_action_attach_tags_attach[] = $t_tag_row;
    }
    $g_action_attach_tags_create = array();
    foreach ($g_action_attach_tags_attach as $t_tag_row) {
        if (!tag_bug_is_attached($t_tag_row['id'], $p_bug_id)) {
            tag_bug_attach($t_tag_row['id'], $p_bug_id, $t_user_id);
        }
    }
    return true;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:21,代码来源:bug_actiongroup_attach_tags_inc.php


示例5: require_api

 * @package MantisBT
 * @copyright Copyright 2002  MantisBT Team - [email protected]
 * @link http://www.mantisbt.org
 *
 * @uses core.php
 * @uses authentication_api.php
 * @uses form_api.php
 * @uses gpc_api.php
 * @uses print_api.php
 * @uses tag_api.php
 */
require_once 'core.php';
require_api('authentication_api.php');
require_api('form_api.php');
require_api('gpc_api.php');
require_api('print_api.php');
require_api('tag_api.php');
form_security_validate('tag_create');
$f_tag_name = gpc_get_string('name');
$f_tag_description = gpc_get_string('description');
$t_tag_user = auth_get_current_user_id();
if (!is_null($f_tag_name)) {
    $t_tags = tag_parse_string($f_tag_name);
    foreach ($t_tags as $t_tag_row) {
        if (-1 == $t_tag_row['id']) {
            tag_create($t_tag_row['name'], $t_tag_user, $f_tag_description);
        }
    }
}
form_security_purge('tag_create');
print_successful_redirect('manage_tags_page.php');
开发者ID:gtn,项目名称:mantisbt,代码行数:31,代码来源:tag_create.php


示例6: tag_get_by_item

<?php

require '../include/core/common.php';
require PATHS_INCLUDE . 'libraries/forum.php';
// NOTE: if(false)! (This file is deprecated)
if (false) {
    if ($_GET['action'] == 'update_tags') {
        /* Remove all old tags */
        $tags = tag_get_by_item('discussion', $_GET['discussion_id']);
        foreach ($tags as $tag) {
            $tag_ids[] = $tag['tag_id'];
        }
        tag_remove($_GET['discussion_id'], 'discussion', $tag_ids);
        /* Set the new tags */
        $tags = explode(' ', str_replace(',', ' ', $_GET['tags']));
        foreach ($tags as $key => $tag) {
            $tags[$key] = trim($tag);
        }
        $tags = array_unique($tags);
        foreach ($tags as $tag_label) {
            $return = tag_exists($tag_label);
            if ($return['status'] == 'exists') {
                $set_tag_ids[] = array('tag_id' => $return['tag_id']);
            } else {
                $set_tag_ids[] = array('tag_id' => tag_create($taglabel));
            }
        }
        tag_set($_GET['discussion_id'], 'discussion', $set_tag_ids);
        // Äntligen kan vi börja sätta de nya taggarna
    }
}
开发者ID:Razze,项目名称:hamsterpaj,代码行数:31,代码来源:discussions.php


示例7: lang_get

    ?>
	<tr class="spacer"><td colspan="2"></td></tr>
	<tr>
	<th class="category"><?php 
    echo lang_get('tag_attach_long');
    ?>
</th>
	<td>
<?php 
    print_tag_attach_form($f_bug_id, $t_tag_string);
    ?>
	</td>
	</tr>
</table>
<?php 
    html_page_bottom();
    // end failed to attach tag
} else {
    foreach ($t_tags_create as $t_tag_row) {
        $t_tag_row['id'] = tag_create($t_tag_row['name'], $t_user_id);
        $t_tags_attach[] = $t_tag_row;
    }
    foreach ($t_tags_attach as $t_tag_row) {
        if (!tag_bug_is_attached($t_tag_row['id'], $f_bug_id)) {
            tag_bug_attach($t_tag_row['id'], $f_bug_id, $t_user_id);
        }
    }
    event_signal('EVENT_TAG_ATTACHED', array($f_bug_id, $t_tags_attach));
    form_security_purge('tag_attach');
    print_successful_redirect_to_bug($f_bug_id);
}
开发者ID:N0ctrnl,项目名称:mantisbt,代码行数:31,代码来源:tag_attach.php


示例8: tag_attach_many

/**
 * Attaches a bunch of tags to the specified issue.
 *
 * @param int    $p_bug_id     The bug id.
 * @param string $p_tag_string String of tags separated by configured separator.
 * @param int    $p_tag_id     Tag id to add or 0 to skip.
 * @return array|bool true for success, otherwise array of failures.  The array elements follow the tag_parse_string()
 *                    format.
 */
function tag_attach_many($p_bug_id, $p_tag_string, $p_tag_id = 0)
{
    # If no work, then there is no need to do access check.
    if ($p_tag_id === 0 && is_blank($p_tag_string)) {
        return true;
    }
    access_ensure_bug_level(config_get('tag_attach_threshold'), $p_bug_id);
    $t_tags = tag_parse_string($p_tag_string);
    $t_can_create = access_has_global_level(config_get('tag_create_threshold'));
    $t_tags_create = array();
    $t_tags_attach = array();
    $t_tags_failed = array();
    foreach ($t_tags as $t_tag_row) {
        if (-1 == $t_tag_row['id']) {
            if ($t_can_create) {
                $t_tags_create[] = $t_tag_row;
            } else {
                $t_tags_failed[] = $t_tag_row;
            }
        } else {
            if (-2 == $t_tag_row['id']) {
                $t_tags_failed[] = $t_tag_row;
            } else {
                $t_tags_attach[] = $t_tag_row;
            }
        }
    }
    if (0 < $p_tag_id && tag_exists($p_tag_id)) {
        $t_tags_attach[] = tag_get($p_tag_id);
    }
    # failed to attach at least one tag
    if (count($t_tags_failed) > 0) {
        return $t_tags_failed;
    }
    foreach ($t_tags_create as $t_tag_row) {
        $t_tag_row['id'] = tag_create($t_tag_row['name']);
        $t_tags_attach[] = $t_tag_row;
    }
    foreach ($t_tags_attach as $t_tag_row) {
        if (!tag_bug_is_attached($t_tag_row['id'], $p_bug_id)) {
            tag_bug_attach($t_tag_row['id'], $p_bug_id);
        }
    }
    event_signal('EVENT_TAG_ATTACHED', array($p_bug_id, $t_tags_attach));
    return true;
}
开发者ID:spring,项目名称:spring-website,代码行数:55,代码来源:tag_api.php


示例9: tag_an_item

/**
 * Associates a tag with an item
 *
 * Ex 1: tag_an_item('user', '1', 'hisTOrY, RELIGIONS, roman' )
 *  This will tag an user whose id is 1 with "history", "religions", "roman"
 *   If the tag names passed do not exist, they will get created.
 *
 * Ex 2: tag_an_item('user', '1', 'hisTory, 12, 11, roman')
 *   This will tag an user whose id is 1 with 'history', 'roman' and with tags of ids 12 and 11
 *
 * @param string $item_type name of the table where the item is stored. Ex: 'user'
 * @param string $item_id id of the item to be tagged
 * @param string $tag_names_or_ids_csv comma separated tag names (can be unormalized) or ids of existing tags
 * @param string $tag_type type of the tags that are beeing added (optional, default value is "default")
 */
function tag_an_item($item_type, $item_id, $tag_names_or_ids_csv, $tag_type = "default")
{
    global $CFG;
    //convert any tag ids passed to their corresponding tag names
    $tag_names_csv = tag_name_from_string($tag_names_or_ids_csv);
    //create the tags
    $tags_created_ids = tag_create($tag_names_csv, $tag_type);
    //tag instances of an item are ordered, get the last one
    $query = "\n        SELECT\n            MAX(ordering) max_order\n        FROM\n            {$CFG->prefix}tag_instance ti\n        WHERE\n            ti.itemtype = '{$item_type}'\n        AND\n            ti.itemid = '{$item_id}'\n        ";
    $max_order = get_field_sql($query);
    $tag_names = explode(',', tag_normalize($tag_names_csv));
    $ordering = array();
    foreach ($tag_names as $tag_name) {
        $ordering[$tag_name] = ++$max_order;
    }
    //setup tag_instance object
    $tag_instance = new StdClass();
    $tag_instance->itemtype = $item_type;
    $tag_instance->itemid = $item_id;
    //create tag instances
    foreach ($tags_created_ids as $tag_normalized_name => $tag_id) {
        $tag_instance->tagid = $tag_id;
        $tag_instance->ordering = $ordering[$tag_normalized_name];
        $tag_instance->timemodified = time();
        $tag_instance_exists = get_record('tag_instance', 'tagid', $tag_id, 'itemtype', $item_type, 'itemid', $item_id);
        if (!$tag_instance_exists) {
            insert_record('tag_instance', $tag_instance);
        } else {
            $tag_instance_exists->timemodified = time();
            $tag_instance_exists->ordering = $ordering[$tag_normalized_name];
            update_record('tag_instance', $tag_instance_exists);
        }
    }
    // update_tag_correlations($item_type, $item_id);
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:50,代码来源:lib.php


示例10: tag_set_wrap

function tag_set_wrap($options)
{
    /*
    Obs! Removes all old tags
    
    options			array support		possible values
    item_id			no
    object_type		no					'discussion', 'post', 'wallpaper', 'article', 'survey', 'game', 'clip', 'a1'
    tag_handle		yes					handle_type_values
    tag_label		yes					Free text values
    tag_id			yes					1, 2, 3..
    add				no					set to true if tags should be added to old tags
    */
    if (644314 == $_SESSION['login']['id']) {
        preint_r($options);
    }
    $keys = array('tag_handle', 'tag_label', 'tag_id');
    foreach ($keys as $key) {
        if (isset($options[$key])) {
            $options[$key] = is_array($options[$key]) ? $options[$key] : array($options[$key]);
            $keytype = $key;
        }
    }
    if ($keytype == 'tag_label') {
        foreach ($options['tag_label'] as $label) {
            if (!($tag = tag_get_by_handle(url_secure_string($label)))) {
                $tag_id = tag_create($label);
            } else {
                $tag_id = $tag['id'];
            }
            $tag_ids[] = $tag_id;
        }
    } elseif ($keytype == 'tag_handle') {
        $tags = tag_get_by_handle($options['tag_handle']);
        unset($tag_ids);
        foreach ($tags as $tag) {
            $tag_ids[] = $tag['id'];
        }
    }
    if (!isset($options['add'])) {
        $query = 'DELETE FROM object_tags WHERE object_type = "' . $options['object_type'] . '" AND reference_id = "' . $options['item_id'] . '"';
        mysql_query($query);
    }
    foreach ($tag_ids as $tag_id) {
        $query = 'INSERT INTO object_tags (tag_id, object_type, reference_id)';
        $query .= ' VALUES ("' . $tag_id . '", "' . $options['object_type'] . '", "' . $options['item_id'] . '")';
        mysql_query($query);
        //todo! annan felhantering här då det kan hända att man försöker sätta redan satta taggar, or die(report_sql_error($query, __FILE__, __LINE__));
    }
}
开发者ID:Razze,项目名称:hamsterpaj,代码行数:50,代码来源:tags.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP tag_cron函数代码示例发布时间:2022-05-23
下一篇:
PHP tag_cloud函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap