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

PHP tag_get_name函数代码示例

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

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



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

示例1: tag_set

/**
 * Set the tags assigned to a record.  This overwrites the current tags.
 *
 * This function is meant to be fed the string coming up from the user
 * interface, which contains all tags assigned to a record.
 *
 * @param string $record_type the type of record to tag ('post' for blogs,
 *     'user' for users, 'tag' for tags, etc.
 * @param int $record_id the id of the record to tag
 * @param array $tags the array of tags to set on the record. If
 *     given an empty array, all tags will be removed.
 * @return void
 */
function tag_set($record_type, $record_id, $tags)
{
    static $in_recursion_semaphore = false;
    // this is to prevent loops when tagging a tag
    if ($record_type == 'tag' && !$in_recursion_semaphore) {
        $current_tagged_tag_name = tag_get_name($record_id);
    }
    $tags_ids = tag_get_id($tags, TAG_RETURN_ARRAY);
    // force an array, even if we only have one tag.
    $cleaned_tags = tag_normalize($tags);
    //echo 'tags-in-tag_set'; var_dump($tags); var_dump($tags_ids); var_dump($cleaned_tags);
    $current_ids = tag_get_tags_ids($record_type, $record_id);
    //var_dump($current_ids);
    // for data coherence reasons, it's better to remove deleted tags
    // before adding new data: ordering could be duplicated.
    foreach ($current_ids as $current_id) {
        if (!in_array($current_id, $tags_ids)) {
            tag_delete_instance($record_type, $record_id, $current_id);
            if ($record_type == 'tag' && !$in_recursion_semaphore) {
                // if we are removing a tag-on-a-tag (manually related tag),
                // we need to remove the opposite relationship as well.
                tag_delete_instance('tag', $current_id, $record_id);
            }
        }
    }
    if (empty($tags)) {
        return true;
    }
    foreach ($tags as $ordering => $tag) {
        $tag = trim($tag);
        if (!$tag) {
            continue;
        }
        $clean_tag = $cleaned_tags[$tag];
        $tag_current_id = $tags_ids[$clean_tag];
        if (is_null($tag_current_id)) {
            // create new tags
            //echo "call to add tag $tag\n";
            $new_tag = tag_add($tag);
            $tag_current_id = $new_tag[$clean_tag];
        }
        tag_assign($record_type, $record_id, $tag_current_id, $ordering);
        // if we are tagging a tag (adding a manually-assigned related tag), we
        // need to create the opposite relationship as well.
        if ($record_type == 'tag' && !$in_recursion_semaphore) {
            $in_recursion_semaphore = true;
            tag_set_add('tag', $tag_current_id, $current_tagged_tag_name);
            $in_recursion_semaphore = false;
        }
    }
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:64,代码来源:lib.php


示例2: array

     if (!data_submitted() or !confirm_sesskey()) {
         break;
     }
     $changed = array();
     foreach ($tagschecked as $tag_id) {
         if (!array_key_exists($tagtypes[$tag_id], $existing_tagtypes)) {
             //can not add new types here!!
             continue;
         }
         // update tag type;
         if (tag_type_set($tag_id, $tagtypes[$tag_id])) {
             $changed[] = $tag_id;
         }
     }
     if (!empty($changed)) {
         $str_changed = implode(', ', tag_get_name($changed));
         $notice = $str_changed . ' --  ' . get_string('typechanged', 'tag');
     }
     break;
 case 'changename':
     if (!data_submitted() or !confirm_sesskey()) {
         break;
     }
     $tags_names_changed = array();
     foreach ($tagschecked as $tag_id) {
         if ($newnames[$tag_id] != '') {
             if (!($tags_names_updated[] = tag_rename($tag_id, $newnames[$tag_id]))) {
                 // if tag already exists, or is not a valid tag name, etc.
                 $err_notice .= $newnames[$tag_id] . '-- ' . get_string('namesalreadybeeingused', 'tag') . '<br />';
             } else {
                 $tags_names_changed[$tag_id] = $newnames[$tag_id];
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:manage.php


示例3: tagged_courses

 /**
  * Renders html to print list of courses tagged with particular tag
  *
  * @param int $tagid id of the tag
  * @return string empty string if no courses are marked with this tag or rendered list of courses
  */
 public function tagged_courses($tagid)
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $displayoptions = array('limit' => $CFG->coursesperpage);
     $displayoptions['viewmoreurl'] = new moodle_url('/course/search.php', array('tagid' => $tagid, 'page' => 1, 'perpage' => $CFG->coursesperpage));
     $displayoptions['viewmoretext'] = new lang_string('findmorecourses');
     $chelper = new coursecat_helper();
     $searchcriteria = array('tagid' => $tagid);
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT)->set_search_criteria(array('tagid' => $tagid))->set_courses_display_options($displayoptions)->set_attributes(array('class' => 'course-search-result course-search-result-tagid'));
     // (we set the same css class as in search results by tagid)
     $courses = coursecat::search_courses($searchcriteria, $chelper->get_courses_display_options());
     $totalcount = coursecat::search_courses_count($searchcriteria);
     $content = $this->coursecat_courses($chelper, $courses, $totalcount);
     if ($totalcount) {
         require_once $CFG->dirroot . '/tag/lib.php';
         $heading = get_string('courses') . ' ' . get_string('taggedwith', 'tag', tag_get_name($tagid)) . ': ' . $totalcount;
         return $this->heading($heading, 3) . $content;
     }
     return '';
 }
开发者ID:helenagarcia90,项目名称:moodle,代码行数:27,代码来源:renderer.php


示例4: print_error

if (isguestuser()) {
    print_error('noguest');
}
if (!confirm_sesskey()) {
    print_error('sesskey');
}
switch ($action) {
    case 'addinterest':
        if (empty($tag) && $id) {
            // for backward-compatibility (people saving bookmarks, mostly..)
            $tag = tag_get_name($id);
        }
        tag_set_add('user', $USER->id, $tag);
        redirect($CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag));
        break;
    case 'removeinterest':
        if (empty($tag) && $id) {
            // for backward-compatibility (people saving bookmarks, mostly..)
            $tag = tag_get_name($id);
        }
        tag_set_delete('user', $USER->id, $tag);
        redirect($CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag));
        break;
    case 'flaginappropriate':
        tag_set_flag(tag_get_id($tag));
        redirect($CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
        break;
    default:
        print_error('unknowaction');
        break;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:user.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP tag_get_related_tags函数代码示例发布时间:2022-05-23
下一篇:
PHP tag_get_id函数代码示例发布时间: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