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

PHP tag_type_set函数代码示例

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

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



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

示例1: test_tag_updated

 /**
  * Test the tag updated event.
  */
 public function test_tag_updated()
 {
     $this->setAdminUser();
     // Save the system context.
     $systemcontext = context_system::instance();
     // Create a tag we are going to update.
     $tag = $this->getDataGenerator()->create_tag();
     // Store the name before we change it.
     $oldname = $tag->name;
     // Trigger and capture the event when renaming a tag.
     $sink = $this->redirectEvents();
     tag_rename($tag->id, 'newname');
     $this->assertDebuggingCalled();
     // Update the tag's name since we have renamed it.
     $tag->name = 'newname';
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\tag_updated', $event);
     $this->assertEquals($systemcontext, $event->get_context());
     $expected = array(SITEID, 'tag', 'update', 'index.php?id=' . $tag->id, $oldname . '->' . $tag->name);
     $this->assertEventLegacyLogData($expected, $event);
     // Trigger and capture the event when setting the type of a tag.
     $sink = $this->redirectEvents();
     tag_type_set($tag->id, 'official');
     $this->assertDebuggingCalled();
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\tag_updated', $event);
     $this->assertEquals($systemcontext, $event->get_context());
     $expected = array(0, 'tag', 'update', 'index.php?id=' . $tag->id, $tag->name);
     $this->assertEventLegacyLogData($expected, $event);
     // Trigger and capture the event for setting the description of a tag.
     $sink = $this->redirectEvents();
     tag_description_set($tag->id, 'description', FORMAT_MOODLE);
     $this->assertDebuggingCalled();
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\tag_updated', $event);
     $this->assertEquals($systemcontext, $event->get_context());
     $expected = array(0, 'tag', 'update', 'index.php?id=' . $tag->id, $tag->name);
     $this->assertEventLegacyLogData($expected, $event);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:48,代码来源:events_test.php


示例2: coursetag_store_keywords

/**
 * Stores a tag for a course for a user
 *
 * @uses $CFG
 * @param array $tags simple array of keywords to be stored
 * @param integer $courseid
 * @param integer $userid
 * @param string $tagtype official or default only
 * @param string $myurl optional for logging creation of course tags
 */
function coursetag_store_keywords($tags, $courseid, $userid=0, $tagtype='official', $myurl='') {

    global $CFG;

    if (is_array($tags) and !empty($tags)) {
        foreach($tags as $tag) {
            $tag = trim($tag);
            if (strlen($tag) > 0) {
                //tag_set_add('course', $courseid, $tag, $userid); //deletes official tags

                //add tag if does not exist
                if (!$tagid = tag_get_id($tag)) {
                    $tag_id_array = tag_add(array($tag), $tagtype);
                    $tagid = $tag_id_array[moodle_strtolower($tag)];
                }
                //ordering
                $ordering = 0;
                if ($current_ids = tag_get_tags_ids('course', $courseid)) {
                    end($current_ids);
                    $ordering = key($current_ids) + 1;
                }
                //set type
                tag_type_set($tagid, $tagtype);

                //tag_instance entry
                tag_assign('course', $courseid, $tagid, $ordering, $userid);

                //logging - note only for user added tags
                if ($tagtype == 'default' and $myurl != '') {
                    $url = $myurl.'?query='.urlencode($tag);
                    add_to_log($courseid, 'coursetags', 'add', $url, 'Course tagged');
                }
            }
        }
    }

}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:47,代码来源:coursetagslib.php


示例3: array

$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id));
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
$tagform = new tag_edit_form(null, compact('editoroptions'));
if ($tag->tagtype == 'official') {
    $tag->tagtype = '1';
} else {
    $tag->tagtype = '0';
}
$tagform->set_data($tag);
// If new data has been sent, update the tag record
if ($tagnew = $tagform->get_data()) {
    if (has_capability('moodle/tag:manage', $systemcontext)) {
        if ($tag->tagtype != 'default' && (!isset($tagnew->tagtype) || $tagnew->tagtype != '1')) {
            tag_type_set($tag->id, 'default');
        } elseif ($tag->tagtype != 'official' && $tagnew->tagtype == '1') {
            tag_type_set($tag->id, 'official');
        }
    }
    if (!has_capability('moodle/tag:manage', $systemcontext)) {
        unset($tagnew->name);
        unset($tagnew->rawname);
    } else {
        // They might be trying to change the rawname, make sure it's a change that doesn't affect name
        $norm = tag_normalize($tagnew->rawname, TAG_CASE_LOWER);
        $tagnew->name = array_shift($norm);
        if ($tag->name != $tagnew->name) {
            // The name has changed, let's make sure it's not another existing tag
            if (tag_get_id($tagnew->name)) {
                // Something exists already, so flag an error
                $errorstring = s($tagnew->rawname) . ': ' . get_string('namesalreadybeeingused', 'tag');
            }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:edit.php


示例4: implode

        //notice to inform what tags had their names effectively updated
        if ($tags_names_changed) {
            $notice = implode($tags_names_changed, ', ');
            $notice .= ' -- ' . get_string('updated', 'tag');
        }
        break;
    case 'addofficialtag':
        if (!data_submitted() or !confirm_sesskey()) {
            break;
        }
        $new_otags = explode(',', optional_param('otagsadd', '', PARAM_TAG));
        $notice = '';
        foreach ($new_otags as $new_otag) {
            if ($new_otag_id = tag_get_id($new_otag)) {
                // tag exists, change the type
                tag_type_set($new_otag_id, 'official');
            } else {
                require_capability('moodle/tag:create', get_context_instance(CONTEXT_SYSTEM));
                tag_add($new_otag, 'official');
            }
            $notice .= get_string('addedotag', 'tag', $new_otag) . ' ';
        }
        break;
}
if ($err_notice) {
    echo $OUTPUT->notification($err_notice, 'red');
}
if ($notice) {
    echo $OUTPUT->notification($notice, 'green');
}
// small form to add an official tag
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:manage.php


示例5: coursetag_store_keywords

/**
 * Stores a tag for a course for a user
 *
 * @package  core_tag
 * @category tag
 * @param    array  $tags     simple array of keywords to be stored
 * @param    int    $courseid the id of the course we wish to store a tag for
 * @param    int    $userid   the id of the user we wish to store a tag for
 * @param    string $tagtype  official or default only
 * @param    string $myurl    (optional) for logging creation of course tags
 */
function coursetag_store_keywords($tags, $courseid, $userid = 0, $tagtype = 'official', $myurl = '')
{
    global $CFG;
    if (is_array($tags) and !empty($tags)) {
        foreach ($tags as $tag) {
            $tag = trim($tag);
            if (strlen($tag) > 0) {
                //tag_set_add('course', $courseid, $tag, $userid); //deletes official tags
                //add tag if does not exist
                if (!($tagid = tag_get_id($tag))) {
                    $tag_id_array = tag_add(array($tag), $tagtype);
                    $tagid = $tag_id_array[core_text::strtolower($tag)];
                }
                //ordering
                $ordering = 0;
                if ($current_ids = tag_get_tags_ids('course', $courseid)) {
                    end($current_ids);
                    $ordering = key($current_ids) + 1;
                }
                //set type
                tag_type_set($tagid, $tagtype);
                //tag_instance entry
                tag_assign('course', $courseid, $tagid, $ordering, $userid, 'core', context_course::instance($courseid)->id);
            }
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:coursetagslib.php


示例6: coursetag_store_keywords

/**
 * Stores a tag for a course for a user
 *
 * @deprecated since 3.0
 * @package  core_tag
 * @category tag
 * @param    array  $tags     simple array of keywords to be stored
 * @param    int    $courseid the id of the course we wish to store a tag for
 * @param    int    $userid   the id of the user we wish to store a tag for
 * @param    string $tagtype  official or default only
 * @param    string $myurl    (optional) for logging creation of course tags
 */
function coursetag_store_keywords($tags, $courseid, $userid = 0, $tagtype = 'official', $myurl = '')
{
    debugging('Function coursetag_store_keywords() is deprecated. Userid is no longer used for tagging courses.', DEBUG_DEVELOPER);
    global $CFG;
    require_once $CFG->dirroot . '/tag/lib.php';
    if (is_array($tags) and !empty($tags)) {
        foreach ($tags as $tag) {
            $tag = trim($tag);
            if (strlen($tag) > 0) {
                //tag_set_add('course', $courseid, $tag, $userid); //deletes official tags
                //add tag if does not exist
                if (!($tagid = tag_get_id($tag))) {
                    $tag_id_array = tag_add(array($tag), $tagtype);
                    $tagid = $tag_id_array[core_text::strtolower($tag)];
                }
                //ordering
                $ordering = 0;
                if ($current_ids = tag_get_tags_ids('course', $courseid)) {
                    end($current_ids);
                    $ordering = key($current_ids) + 1;
                }
                //set type
                tag_type_set($tagid, $tagtype);
                //tag_instance entry
                tag_assign('course', $courseid, $tagid, $ordering, $userid, 'core', context_course::instance($courseid)->id);
            }
        }
    }
}
开发者ID:nickbert77,项目名称:moodle,代码行数:41,代码来源:deprecatedlib.php


示例7: test_cleanup

 /**
  * Test for function tag_cleanup() that is part of tag cron
  */
 public function test_cleanup()
 {
     global $DB;
     $user = $this->getDataGenerator()->create_user();
     // Setting tags will create non-official tags 'cat', 'dog' and 'fish'.
     tag_set('user', $user->id, array('cat', 'dog', 'fish'), 'core', context_user::instance($user->id)->id);
     $this->assertTrue($DB->record_exists('tag', array('name' => 'cat')));
     $this->assertTrue($DB->record_exists('tag', array('name' => 'dog')));
     $this->assertTrue($DB->record_exists('tag', array('name' => 'fish')));
     // Make tag 'dog' official.
     $dogtag = tag_get('name', 'dog');
     $fishtag = tag_get('name', 'fish');
     tag_type_set($dogtag->id, 'official');
     // Manually remove the instances pointing on tags 'dog' and 'fish'.
     $DB->execute('DELETE FROM {tag_instance} WHERE tagid in (?,?)', array($dogtag->id, $fishtag->id));
     // Call tag_cleanup().
     tag_cleanup();
     // Tag 'cat' is still present because it's used. Tag 'dog' is present because it's official.
     // Tag 'fish' was removed because it is not official and it is no longer used by anybody.
     $this->assertTrue($DB->record_exists('tag', array('name' => 'cat')));
     $this->assertTrue($DB->record_exists('tag', array('name' => 'dog')));
     $this->assertFalse($DB->record_exists('tag', array('name' => 'fish')));
     // Delete user without using API function.
     $DB->update_record('user', array('id' => $user->id, 'deleted' => 1));
     // Call tag_cleanup().
     tag_cleanup();
     // Tag 'cat' was now deleted too.
     $this->assertFalse($DB->record_exists('tag', array('name' => 'cat')));
     // Assign tag to non-existing record. Make sure tag was created in the DB.
     tag_set('course', 1231231, array('bird'), 'core', context_system::instance()->id);
     $this->assertTrue($DB->record_exists('tag', array('name' => 'bird')));
     // Call tag_cleanup().
     tag_cleanup();
     // Tag 'bird' was now deleted because the related record does not exist in the DB.
     $this->assertFalse($DB->record_exists('tag', array('name' => 'bird')));
     // Now we have a tag instance pointing on 'sometag' tag.
     $user = $this->getDataGenerator()->create_user();
     tag_set('user', $user->id, array('sometag'), 'core', context_user::instance($user->id)->id);
     $sometag = tag_get('name', 'sometag');
     $this->assertTrue($DB->record_exists('tag_instance', array('tagid' => $sometag->id)));
     // Some hacker removes the tag without using API.
     $DB->delete_records('tag', array('id' => $sometag->id));
     // Call tag_cleanup().
     tag_cleanup();
     // The tag instances were also removed.
     $this->assertFalse($DB->record_exists('tag_instance', array('tagid' => $sometag->id)));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:50,代码来源:taglib_test.php


示例8: redirect

            }
        }
        redirect($PAGE->url);
        break;
    case 'addofficialtag':
        require_sesskey();
        $otagsadd = optional_param('otagsadd', '', PARAM_RAW);
        $newtags = preg_split('/\\s*,\\s*/', trim($otagsadd), -1, PREG_SPLIT_NO_EMPTY);
        $newtags = array_filter(tag_normalize($newtags, TAG_CASE_ORIGINAL));
        if (!$newtags) {
            redirect($PAGE->url);
        }
        foreach ($newtags as $newotag) {
            if ($newotagid = tag_get_id($newotag)) {
                // Tag exists, change the type.
                tag_type_set($newotagid, 'official');
            } else {
                tag_add($newotag, 'official');
            }
        }
        redirect(new moodle_url($PAGE->url, array('notice' => 'added')));
        break;
}
echo $OUTPUT->header();
if ($notice && get_string_manager()->string_exists($notice, 'tag')) {
    echo $OUTPUT->notification(get_string($notice, 'tag'), 'notifysuccess');
}
// Small form to add an official tag.
print '<form class="tag-addtags-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php">';
print '<input type="hidden" name="action" value="addofficialtag" />';
print '<input type="hidden" name="perpage" value="' . $perpage . '" />';
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:manage.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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