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

PHP tag_set_add函数代码示例

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

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



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

示例1: test_tag_set_delete

 /**
  * Test the tag_set_delete function.
  * This function was deprecated in 3.1
  */
 public function test_tag_set_delete()
 {
     global $DB;
     // Create a course to tag.
     $course = $this->getDataGenerator()->create_course();
     // Create the tag and tag instance we are going to delete.
     tag_set_add('course', $course->id, 'A random tag', 'core', context_course::instance($course->id)->id);
     $this->assertDebuggingCalled();
     // Call the tag_set_delete function.
     tag_set_delete('course', $course->id, 'a random tag', 'core', context_course::instance($course->id)->id);
     $this->assertDebuggingCalled();
     // Now check that there are no tags or tag instances.
     $this->assertEquals(0, $DB->count_records('tag'));
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     // Add tag again, add and remove related tag.
     tag_set_add('course', $course->id, 'A random tag', 'core', context_course::instance($course->id)->id);
     $this->assertDebuggingCalled();
     $taginstance = $DB->get_record('tag_instance', array('itemtype' => 'course', 'itemid' => $course->id), '*', MUST_EXIST);
     $tagid = $taginstance->tagid;
     tag_set_add('tag', $tagid, 'Some related tag');
     $this->assertDebuggingCalled();
     tag_set_delete('tag', $tagid, 'Some related tag');
     $this->assertDebuggingCalled();
     $relatedtags = tag_get_related_tags($tagid);
     $this->assertDebuggingCalled();
     $this->assertCount(0, $relatedtags);
 }
开发者ID:bewanyk,项目名称:moodle,代码行数:31,代码来源:taglib_test.php


示例2: 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);
            }
        }
    }
    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:r007,项目名称:PMoodle,代码行数:61,代码来源:lib.php


示例3: process_wiki_tag

 protected function process_wiki_tag($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $oldid = $data->id;
     if (empty($CFG->usetags)) {
         // tags disabled in server, nothing to process
         return;
     }
     $tag = $data->rawname;
     $itemid = $this->get_new_parentid('wiki_page');
     tag_set_add('wiki_pages', $itemid, $tag);
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:13,代码来源:restore_wiki_stepslib.php


示例4: print_error

if (empty($CFG->usetags)) {
    print_error('tagdisabled');
}
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:
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:user.php


示例5: test_tag_set_delete

 /**
  * Test the tag_set_delete function.
  */
 public function test_tag_set_delete()
 {
     global $DB;
     // Create a course to tag.
     $course = $this->getDataGenerator()->create_course();
     // Create the tag and tag instance we are going to delete.
     tag_set_add('course', $course->id, 'A random tag', 'core', context_course::instance($course->id)->id);
     // Call the tag_set_delete function.
     tag_set_delete('course', $course->id, 'a random tag', 'core', context_course::instance($course->id)->id);
     // Now check that there are no tags or tag instances.
     $this->assertEquals(0, $DB->count_records('tag'));
     $this->assertEquals(0, $DB->count_records('tag_instance'));
     // Recreate the tag and tag instance.
     tag_set_add('course', $course->id, 'A random tag', 'core', context_course::instance($course->id)->id);
     // Now call the tag_set_delete function without specifying the component or
     // contextid and ensure the function debugging is called.
     tag_set_delete('course', $course->id, 'A random tag');
     $this->assertDebuggingCalled();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:22,代码来源:taglib_test.php


示例6: process_wiki_tag

 protected function process_wiki_tag($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $oldid = $data->id;
     if (empty($CFG->usetags)) {
         // tags disabled in server, nothing to process
         return;
     }
     $tag = $data->rawname;
     $itemid = $this->get_new_parentid('wiki_page');
     $wikiid = $this->get_new_parentid('wiki');
     $cm = get_coursemodule_from_instance('wiki', $wikiid);
     tag_set_add('wiki_pages', $itemid, $tag, 'mod_wiki', context_module::instance($cm->id)->id);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:15,代码来源:restore_wiki_stepslib.php


示例7: process_forumng_forumtaginstance

 protected function process_forumng_forumtaginstance($data)
 {
     global $CFG;
     $data = (object) $data;
     $oldid = $data->id;
     if (empty($CFG->usetags)) {
         // Tags disabled in server, nothing to process.
         return;
     }
     $tag = $data->rawname;
     $forumid = $this->get_new_parentid('forumng');
     $cm = get_coursemodule_from_instance('forumng', $forumid);
     tag_set_add('forumng', $forumid, $tag, 'mod_forumng', context_module::instance($cm->id)->id);
 }
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:14,代码来源:restore_forumng_stepslib.php


示例8: print_error

    print_error('tagdisabled');
}
if (isguestuser()) {
    print_error('noguest');
}
if (!confirm_sesskey()) {
    print_error('sesskey');
}
$usercontext = context_user::instance($USER->id);
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, 'core', $usercontext->id);
        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, 'core', $usercontext->id);
        redirect($CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag));
        break;
    case 'flaginappropriate':
        $tagid = tag_get_id($tag);
        tag_set_flag($tagid);
        redirect($CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
        break;
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:user.php


示例9: get_record

             $existingmethod = get_record('classification_value', 'value', $method2);
             if (empty($existingmethod)) {
                 //create new classification if needed.
                 $newmeth = new stdclass();
                 $newmeth->type = get_field('classification_type', 'id', 'name', 'Subject');
                 $newmeth->value = $method2;
                 insert_record('classification_value', $newmeth);
                 $existingmethod = get_record('classification_value', 'value', $method2);
             }
             if (!empty($existingmethod)) {
                 //this is a valid method.
                 //now check to see if classification already set for this LP
                 if (!record_exists('course_classification', 'course', $courseid, 'value', $existingmethod->id)) {
                     //need to insert a classification and a tag.
                     insert_record('course_classification', (object) array('course' => $courseid, 'value' => $existingmethod->id));
                     tag_set_add('courseclassification', $courseid, strtolower($method));
                 }
             }
         }
     }
 }
 $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
 //now do stuff with contributors
 if (!empty($lp['contributors'])) {
     $useridarray = array();
     $contribroleid = get_field('role', 'id', 'shortname', ROLE_LPCONTRIBUTOR);
     foreach ($lp['contributors'] as $conid) {
         $user = get_record('user', 'username', $conid);
         if (!empty($user)) {
             role_assign($contribroleid, $user->id, 0, $coursecontext->id);
             $useridarray[] = $user->id;
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:db_lp.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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