当前位置: 首页>>代码示例>>PHP>>正文


PHP tag_get_tags_array函数代码示例

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


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

示例1: file_area_contains_subdirs

    // Add context for editor.
    $editoroptions['context'] = $coursecontext;
    $editoroptions['subdirs'] = file_area_contains_subdirs($coursecontext, 'course', 'summary', 0);
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);
    if ($overviewfilesoptions) {
        file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, $coursecontext, 'course', 'overviewfiles', 0);
    }
    // Inject current aliases.
    $aliases = $DB->get_records('role_names', array('contextid' => $coursecontext->id));
    foreach ($aliases as $alias) {
        $course->{'role_' . $alias->roleid} = $alias->name;
    }
    // Populate course tags.
    if (!empty($CFG->usetags)) {
        include_once $CFG->dirroot . '/tag/lib.php';
        $course->tags = tag_get_tags_array('course', $course->id);
    }
} else {
    // Editor should respect category context if course context is not set.
    $editoroptions['context'] = $catcontext;
    $editoroptions['subdirs'] = 0;
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
    if ($overviewfilesoptions) {
        file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, null, 'course', 'overviewfiles', 0);
    }
}
// First create the form.
$args = array('course' => $course, 'category' => $category, 'editoroptions' => $editoroptions, 'returnto' => $returnto, 'returnurl' => $returnurl);
$editform = new course_edit_form(null, $args);
if ($editform->is_cancelled()) {
    // The form has been cancelled, take them back to what ever the return to is.
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:edit.php

示例2: get_tags

 /**
  * Get tags for this discussion.
  * @param $htmldecode bool Set true to decode html special chars (for form field)
  * @return array of sorted tags or false if no tags are found.
  */
 public function get_tags($htmldecode = false)
 {
     global $CFG;
     require_once $CFG->dirroot . '/tag/lib.php';
     $tags = null;
     $forum = $this->get_forum();
     if ($forum->get_tags_enabled()) {
         $tags = tag_get_tags_array('forumng_discussions', $this->get_id());
         $tags = array_map('strtolower', $tags);
         if ($htmldecode) {
             $tags = array_map('htmlspecialchars_decode', $tags);
         }
         // Sort tags keeping id.
         asort($tags);
         return $tags;
     } else {
         return false;
     }
 }
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:24,代码来源:mod_forumng_discussion.php

示例3: print_edit

    protected function print_edit($content = null) {
        global $CFG, $OUTPUT, $USER, $PAGE;

        if (!$this->check_locks()) {
            return;
        }

        //delete old locks (> 1 hour)
        wiki_delete_old_locks();

        $version = wiki_get_current_version($this->page->id);
        $format = $version->contentformat;

        if ($content == null) {
            if (empty($this->section)) {
                $content = $version->content;
            } else {
                $content = $this->sectioncontent;
            }
        }

        $versionnumber = $version->version;
        if ($this->versionnumber >= 0) {
            if ($version->version != $this->versionnumber) {
                print $OUTPUT->box(get_string('wrongversionlock', 'wiki'), 'errorbox');
                $versionnumber = $this->versionnumber;
            }
        }

        $url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
        if (!empty($this->section)) {
            $url .= "&section=" . urlencode($this->section);
        }

        $params = array(
            'attachmentoptions' => page_wiki_edit::$attachmentoptions,
            'format' => $version->contentformat,
            'version' => $versionnumber,
            'pagetitle' => $this->page->title,
            'contextid' => $this->modcontext->id
        );

        $data = new StdClass();
        $data->newcontent = $content;
        $data->version = $versionnumber;
        $data->format = $format;

        switch ($format) {
        case 'html':
            $data->newcontentformat = FORMAT_HTML;
            // Append editor context to editor options, giving preference to existing context.
            page_wiki_edit::$attachmentoptions = array_merge(array('context' => $this->modcontext), page_wiki_edit::$attachmentoptions);
            $data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
            break;
        default:
            break;
        }

        if ($version->contentformat != 'html') {
            $params['fileitemid'] = $this->subwiki->id;
            $params['component']  = 'mod_wiki';
            $params['filearea']   = 'attachments';
        }

        if (!empty($CFG->usetags)) {
            $params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
        }

        $form = new mod_wiki_edit_form($url, $params);

        if ($formdata = $form->get_data()) {
            if (!empty($CFG->usetags)) {
                $data->tags = $formdata->tags;
            }
        } else {
            if (!empty($CFG->usetags)) {
                $data->tags = tag_get_tags_array('wiki', $this->page->id);
            }
        }

        $form->set_data($data);
        $form->display();
    }
开发者ID:Burick,项目名称:moodle,代码行数:83,代码来源:pagelib.php

示例4: blog_rss_get_feed

/**
 * Generate any blog RSS feed via one function
 *
 * @param stdClass $context The context of the blog for which the feed it being generated
 * @param array    $args    An array of arguements needed to build the feed (contextid, token, componentname, type, id, tagid)
 */
function blog_rss_get_feed($context, $args)
{
    global $CFG, $SITE, $DB;
    if (empty($CFG->bloglevel)) {
        debugging('Blogging disabled on this site, RSS feeds are not available');
        return null;
    }
    if (empty($CFG->enablerssfeeds)) {
        debugging('Sorry, RSS feeds are disabled on this site');
        return '';
    }
    if ($CFG->bloglevel == BLOG_SITE_LEVEL) {
        if (isguestuser()) {
            debugging(get_string('nopermissiontoshow', 'error'));
            return '';
        }
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
    if (!has_capability('moodle/blog:view', $sitecontext)) {
        return null;
    }
    $type = clean_param($args[3], PARAM_ALPHA);
    $id = clean_param($args[4], PARAM_INT);
    // could be groupid / courseid  / userid  depending on $type
    $tagid = 0;
    if ($args[5] != 'rss.xml') {
        $tagid = clean_param($args[5], PARAM_INT);
    } else {
        $tagid = 0;
    }
    $filename = blog_rss_file_name($type, $id, $tagid);
    if (file_exists($filename)) {
        if (filemtime($filename) + 3600 > time()) {
            return $filename;
            // It's already done so we return cached version
        }
    }
    $courseid = $groupid = $userid = null;
    switch ($type) {
        case 'site':
            //$siteid = $id;
            break;
        case 'course':
            $courseid = $id;
            break;
        case 'group':
            $groupid = $id;
            break;
        case 'user':
            $userid = $id;
            break;
    }
    // Get all the entries from the database
    require_once $CFG->dirroot . '/blog/locallib.php';
    $blogheaders = blog_get_headers($courseid, $groupid, $userid, $tagid);
    $bloglisting = new blog_listing($blogheaders['filters']);
    $blogentries = $bloglisting->get_entries();
    // Now generate an array of RSS items
    if ($blogentries) {
        $items = array();
        foreach ($blogentries as $blog_entry) {
            $item = NULL;
            $item->author = fullname($DB->get_record('user', array('id' => $blog_entry->userid)));
            // TODO: this is slow
            $item->title = $blog_entry->subject;
            $item->pubdate = $blog_entry->lastmodified;
            $item->link = $CFG->wwwroot . '/blog/index.php?entryid=' . $blog_entry->id;
            $summary = file_rewrite_pluginfile_urls($blog_entry->summary, 'pluginfile.php', $sitecontext->id, 'blog', 'post', $blog_entry->id);
            $item->description = format_text($summary, $blog_entry->format);
            if (!empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id))) {
                if ($blogtags) {
                    $item->tags = $blogtags;
                }
                $item->tagscheme = $CFG->wwwroot . '/tag';
            }
            $items[] = $item;
        }
        $articles = rss_add_items($items);
        /// Change structure to XML
    } else {
        $articles = '';
    }
    /// Get header and footer information
    switch ($type) {
        case 'user':
            $info = fullname($DB->get_record('user', array('id' => $id), 'firstname,lastname'));
            break;
        case 'course':
            $info = $DB->get_field('course', 'fullname', array('id' => $id));
            $info = format_string($info, true, array('context' => get_context_instance(CONTEXT_COURSE, $id)));
            break;
        case 'site':
            $info = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
            break;
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:rsslib.php

示例5: blog_sync_external_entries

/**
 * Given a record in the {blog_external} table, checks the blog's URL
 * for new entries not yet copied into Moodle.
 * Also attempts to identify and remove deleted blog entries
 *
 * @param object $externalblog
 * @return boolean False if the Feed is invalid
 */
function blog_sync_external_entries($externalblog)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/simplepie/moodle_simplepie.php';
    $rssfile = new moodle_simplepie_file($externalblog->url);
    $filetest = new SimplePie_Locator($rssfile);
    if (!$filetest->is_feed($rssfile)) {
        $externalblog->failedlastsync = 1;
        $DB->update_record('blog_external', $externalblog);
        return false;
    } else {
        if (!empty($externalblog->failedlastsync)) {
            $externalblog->failedlastsync = 0;
            $DB->update_record('blog_external', $externalblog);
        }
    }
    $rss = new moodle_simplepie($externalblog->url);
    if (empty($rss->data)) {
        return null;
    }
    //used to identify blog posts that have been deleted from the source feed
    $oldesttimestamp = null;
    $uniquehashes = array();
    foreach ($rss->get_items() as $entry) {
        // If filtertags are defined, use them to filter the entries by RSS category
        if (!empty($externalblog->filtertags)) {
            $containsfiltertag = false;
            $categories = $entry->get_categories();
            $filtertags = explode(',', $externalblog->filtertags);
            $filtertags = array_map('trim', $filtertags);
            $filtertags = array_map('strtolower', $filtertags);
            foreach ($categories as $category) {
                if (in_array(trim(strtolower($category->term)), $filtertags)) {
                    $containsfiltertag = true;
                }
            }
            if (!$containsfiltertag) {
                continue;
            }
        }
        $uniquehashes[] = $entry->get_permalink();
        $newentry = new stdClass();
        $newentry->userid = $externalblog->userid;
        $newentry->module = 'blog_external';
        $newentry->content = $externalblog->id;
        $newentry->uniquehash = $entry->get_permalink();
        $newentry->publishstate = 'site';
        $newentry->format = FORMAT_HTML;
        // Clean subject of html, just in case
        $newentry->subject = clean_param($entry->get_title(), PARAM_TEXT);
        // Observe 128 max chars in DB
        // TODO: +1 to raise this to 255
        if (textlib::strlen($newentry->subject) > 128) {
            $newentry->subject = textlib::substr($newentry->subject, 0, 125) . '...';
        }
        $newentry->summary = $entry->get_description();
        //used to decide whether to insert or update
        //uses enty permalink plus creation date if available
        $existingpostconditions = array('uniquehash' => $entry->get_permalink());
        //our DB doesnt allow null creation or modified timestamps so check the external blog supplied one
        $entrydate = $entry->get_date('U');
        if (!empty($entrydate)) {
            $existingpostconditions['created'] = $entrydate;
        }
        //the post ID or false if post not found in DB
        $postid = $DB->get_field('post', 'id', $existingpostconditions);
        $timestamp = null;
        if (empty($entrydate)) {
            $timestamp = time();
        } else {
            $timestamp = $entrydate;
        }
        //only set created if its a new post so we retain the original creation timestamp if the post is edited
        if ($postid === false) {
            $newentry->created = $timestamp;
        }
        $newentry->lastmodified = $timestamp;
        if (empty($oldesttimestamp) || $timestamp < $oldesttimestamp) {
            //found an older post
            $oldesttimestamp = $timestamp;
        }
        if (textlib::strlen($newentry->uniquehash) > 255) {
            // The URL for this item is too long for the field. Rather than add
            // the entry without the link we will skip straight over it.
            // RSS spec says recommended length 500, we use 255.
            debugging('External blog entry skipped because of oversized URL', DEBUG_DEVELOPER);
            continue;
        }
        if ($postid === false) {
            $id = $DB->insert_record('post', $newentry);
            // Set tags
            if ($tags = tag_get_tags_array('blog_external', $externalblog->id)) {
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:lib.php

示例6: print_error

    print_error('guestnoeditprofileother');
}
if ($user->deleted) {
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string('userdeleted'));
    echo $OUTPUT->footer();
    die;
}
// Load user preferences.
useredit_load_preferences($user);
// Load custom profile fields data.
profile_load_data($user);
// User interests.
if (!empty($CFG->usetags)) {
    require_once $CFG->dirroot . '/tag/lib.php';
    $user->interests = tag_get_tags_array('user', $id);
}
if ($user->id !== -1) {
    $usercontext = context_user::instance($user->id);
    $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'forcehttps' => false, 'context' => $usercontext);
    $user = file_prepare_standard_editor($user, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
} else {
    $usercontext = null;
    // This is a new user, we don't want to add files here.
    $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false, 'context' => $coursecontext);
}
// Prepare filemanager draft area.
$draftitemid = 0;
$filemanagercontext = $editoroptions['context'];
$filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image');
file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions);
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:editadvanced.php

示例7: wiki_reset_userdata

function wiki_reset_userdata($data)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/wiki/pagelib.php';
    require_once $CFG->dirroot . '/tag/lib.php';
    require_once $CFG->dirroot . "/mod/wiki/locallib.php";
    $componentstr = get_string('modulenameplural', 'wiki');
    $status = array();
    //get the wiki(s) in this course.
    if (!($wikis = $DB->get_records('wiki', array('course' => $data->courseid)))) {
        return false;
    }
    $errors = false;
    foreach ($wikis as $wiki) {
        if (!($cm = get_coursemodule_from_instance('wiki', $wiki->id))) {
            continue;
        }
        $context = context_module::instance($cm->id);
        // Remove tags or all pages.
        if (!empty($data->reset_wiki_pages) || !empty($data->reset_wiki_tags)) {
            // Get subwiki information.
            $subwikis = wiki_get_subwikis($wiki->id);
            foreach ($subwikis as $subwiki) {
                // Get existing pages.
                if ($pages = wiki_get_page_list($subwiki->id)) {
                    // If the wiki page isn't selected then we are only removing tags.
                    if (empty($data->reset_wiki_pages)) {
                        // Go through each page and delete the tags.
                        foreach ($pages as $page) {
                            $tags = tag_get_tags_array('wiki_pages', $page->id);
                            foreach ($tags as $tagid => $tagname) {
                                // Delete the related tag_instances related to the wiki page.
                                $errors = tag_delete_instance('wiki_pages', $page->id, $tagid);
                                $status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'wiki'), 'error' => $errors);
                            }
                        }
                    } else {
                        // Otherwise we are removing pages and tags.
                        wiki_delete_pages($context, $pages, $subwiki->id);
                    }
                }
                if (!empty($data->reset_wiki_pages)) {
                    // Delete any subwikis.
                    $DB->delete_records('wiki_subwikis', array('id' => $subwiki->id), IGNORE_MISSING);
                    // Delete any attached files.
                    $fs = get_file_storage();
                    $fs->delete_area_files($context->id, 'mod_wiki', 'attachments');
                    $status[] = array('component' => $componentstr, 'item' => get_string('deleteallpages', 'wiki'), 'error' => $errors);
                }
            }
        }
        // Remove all comments.
        if (!empty($data->reset_wiki_comments) || !empty($data->reset_wiki_pages)) {
            $DB->delete_records_select('comments', "contextid = ? AND commentarea='wiki_page'", array($context->id));
            $status[] = array('component' => $componentstr, 'item' => get_string('deleteallcomments'), 'error' => false);
        }
    }
    return $status;
}
开发者ID:matiasma,项目名称:moodle,代码行数:59,代码来源:lib.php

示例8: blog_generate_rss_feed

function blog_generate_rss_feed($type, $id, $tagid = 0)
{
    global $CFG, $SITE;
    if (empty($CFG->enablerssfeeds)) {
        debugging('Sorry, RSS feeds are disabled on this site');
        return '';
    }
    $filename = blog_rss_file_name($type, $id, $tagid);
    if (file_exists($filename)) {
        if (filemtime($filename) + 3600 > time()) {
            return $filename;
            /// It's already done so we return cached version
        }
    }
    /// Get all the posts from the database
    $blogposts = blog_fetch_entries('', 20, '', $type, $id, $tagid);
    /// Now generate an array of RSS items
    if ($blogposts) {
        $items = array();
        foreach ($blogposts as $blogpost) {
            $item = NULL;
            $item->author = fullname(get_record('user', 'id', $blogpost->userid));
            $item->title = $blogpost->subject;
            $item->pubdate = $blogpost->lastmodified;
            $item->link = $CFG->wwwroot . '/blog/index.php?postid=' . $blogpost->id;
            $item->description = format_text($blogpost->summary, $blogpost->format);
            if (!empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blogpost->id))) {
                if ($blogtags) {
                    $item->tags = $blogtags;
                }
                $item->tagscheme = $CFG->wwwroot . '/tag';
            }
            $items[] = $item;
        }
        $articles = rss_add_items($items);
        /// Change structure to XML
    } else {
        $articles = '';
    }
    /// Get header and footer information
    switch ($type) {
        case 'user':
            $info = fullname(get_record('user', 'id', $id, '', '', '', '', 'firstname,lastname'));
            break;
        case 'course':
            $info = get_field('course', 'fullname', 'id', $id);
            break;
        case 'site':
            $info = $SITE->fullname;
            break;
        case 'group':
            $group = groups_get_group($id, false);
            $info = $group->name;
            //TODO: get_field('groups', 'name', 'id', $id)
            break;
        default:
            $info = '';
            break;
    }
    if ($tagid) {
        $info .= ': ' . get_field('tags', 'text', 'id', $tagid);
    }
    $header = rss_standard_header(get_string($type . 'blog', 'blog', $info), $CFG->wwwroot . '/blog/index.php', get_string('intro', 'blog'));
    $footer = rss_standard_footer();
    /// Save the XML contents to file.
    $rssdata = $header . $articles . $footer;
    if (blog_rss_save_file($type, $id, $tagid, $rssdata)) {
        return $filename;
    } else {
        return false;
        // Couldn't find it or make it
    }
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:73,代码来源:rsslib.php

示例9: get_string

    case 'add':
        // prepare new empty form
        $post->publishstate = 'site';
        $strformheading = get_string('addnewentry', 'blog');
        $post->action = $action;
        break;
    case 'edit':
        if (!$existing) {
            print_error('wrongpostid', 'blog');
        }
        $post->id = $existing->id;
        $post->subject = $existing->subject;
        $post->summary = $existing->summary;
        $post->publishstate = $existing->publishstate;
        $post->format = $existing->format;
        $post->tags = tag_get_tags_array('post', $post->id);
        $post->action = $action;
        $strformheading = get_string('updateentrywithid', 'blog');
        break;
    default:
        print_error('unknowaction');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = $DB->get_record('user', array('id' => $userid)))) {
    print_error('invaliduserid');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strblogs, 'link' => "{$CFG->wwwroot}/blog/index.php?userid={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strformheading, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:edit.php

示例10: wiki_print_page_content

function wiki_print_page_content($page, $context, $subwikiid)
{
    global $OUTPUT, $CFG;
    if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
        $content = wiki_refresh_cachedcontent($page);
        $page = $content['page'];
    }
    if (isset($content)) {
        $box = '';
        foreach ($content['sections'] as $s) {
            $box .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>';
        }
        if (!empty($box)) {
            echo $OUTPUT->box($box);
        }
    }
    $html = file_rewrite_pluginfile_urls($page->cachedcontent, 'pluginfile.php', $context->id, 'mod_wiki', 'attachments', $subwikiid);
    $html = format_text($html, FORMAT_MOODLE, array('overflowdiv' => true));
    echo $OUTPUT->box($html);
    if (!empty($CFG->usetags)) {
        $tags = tag_get_tags_array('wiki_pages', $page->id);
        echo '<p class="wiki-tags"><span>Tags: </span>' . join($tags, ", ") . '</p>';
    }
    wiki_increment_pageviews($page);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:25,代码来源:locallib.php

示例11: print_edit

    protected function print_edit($content = null) {
        global $CFG, $OUTPUT, $USER, $PAGE;

        if (!$this->check_locks()) {
            return;
        }

        //delete old locks (> 1 hour)
        wiki_delete_old_locks();

        $version = wiki_get_current_version($this->page->id);
        $format = $version->contentformat;

        if ($content == null) {
            if (empty($this->section)) {
                $content = $version->content;
            } else {
                $content = $this->sectioncontent;
            }
        }

        $versionnumber = $version->version;
        if ($this->versionnumber >= 0) {
            if ($version->version != $this->versionnumber) {
                print $OUTPUT->box(get_string('wrongversionlock', 'wiki'), 'errorbox');
                $versionnumber = $this->versionnumber;
            }
        }

        $url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
        if (!empty($this->section)) {
            $url .= "&section=" . $this->section;
        }

        $params = array('attachmentoptions' => page_wiki_edit::$attachmentoptions, 'format' => $version->contentformat, 'version' => $versionnumber, 'pagetitle'=>$this->page->title);

        $data = new StdClass();
        $data->newcontent = $content;
        $data->version = $versionnumber;
        $data->format = $format;

        switch ($format) {
        case 'html':
            $data->newcontentformat = FORMAT_HTML;
            $data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
            break;
        default:
            //$draftitemid = file_get_submitted_draft_itemid('attachments');
            //file_prepare_draft_area($draftitemid, $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
            //$data->attachments = $draftitemid;
            }

        if ($version->contentformat != 'html') {
            $params['contextid'] = $this->modcontext->id;
            $params['component'] = 'mod_wiki';
            $params['filearea'] = 'attachments';
            $params['fileitemid'] = $this->subwiki->id;
        }

        if (!empty($CFG->usetags)) {
            $params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
        }

        $form = new mod_wiki_edit_form($url, $params);

        if ($formdata = $form->get_data()) {
            if ($format != 'html') {
                $errors = $this->process_uploads($this->modcontext);
                if (!empty($errors)) {
                    $contenterror = "";
                    foreach ($errors as $e) {
                        $contenterror .= "<p>" . get_string('filenotuploadederror', 'wiki', $e->get_filename()) . "</p>";
                    }
                    print $OUTPUT->box($contenterror, 'errorbox');
                }
            }
            if (!empty($CFG->usetags)) {
                $data->tags = $formdata->tags;
            }
        } else {
            if (!empty($CFG->usetags)) {
                $data->tags = tag_get_tags_array('wiki', $this->page->id);
            }
        }

        $form->set_data($data);
        $form->display();
    }
开发者ID:nfreear,项目名称:moodle,代码行数:88,代码来源:pagelib.php

示例12: require_login

require_login();
// Check capabilities but do not call require_login($course) - the user does not have to be enrolled.
$context = context_course::instance($course->id);
if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
    print_error('coursehidden', '', $CFG->wwwroot . '/');
}
require_capability('moodle/course:tag', $context);
if (empty($CFG->usetags)) {
    print_error('tagsaredisabled', 'tag');
}
$PAGE->set_course($course);
$PAGE->set_pagelayout('incourse');
$PAGE->set_url('/course/tags.php', array('id' => $course->id));
$PAGE->set_title(get_string('coursetags', 'tag'));
$PAGE->set_heading($course->fullname);
$form = new coursetags_form();
$data = array('id' => $course->id, 'tags' => tag_get_tags_array('course', $course->id));
$form->set_data($data);
$redirecturl = $returnurl ? new moodle_url($returnurl) : course_get_url($course);
if ($form->is_cancelled()) {
    redirect($redirecturl);
} else {
    if ($data = $form->get_data()) {
        tag_set('course', $course->id, $data->tags, 'core', context_course::instance($course->id)->id);
        redirect($redirecturl);
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('coursetags', 'tag'));
$form->display();
echo $OUTPUT->footer();
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:tags.php

示例13: writequestion


//.........这里部分代码省略.........
                 $expout .= "    <correctanswerlength>{$correctanswerlength}</correctanswerlength>\n";
                 $feedbackformat = $this->get_format($answer->feedbackformat);
                 $expout .= "    <feedback format=\"{$feedbackformat}\">\n";
                 $expout .= $this->writetext($answer->feedback);
                 $expout .= $this->write_files($answer->feedbackfiles);
                 $expout .= "    </feedback>\n";
                 $expout .= "</answer>\n";
             }
             if (isset($question->options->unitgradingtype)) {
                 $expout .= "    <unitgradingtype>{$question->options->unitgradingtype}</unitgradingtype>\n";
             }
             if (isset($question->options->unitpenalty)) {
                 $expout .= "    <unitpenalty>{$question->options->unitpenalty}</unitpenalty>\n";
             }
             if (isset($question->options->showunits)) {
                 $expout .= "    <showunits>{$question->options->showunits}</showunits>\n";
             }
             if (isset($question->options->unitsleft)) {
                 $expout .= "    <unitsleft>{$question->options->unitsleft}</unitsleft>\n";
             }
             if (isset($question->options->instructionsformat)) {
                 $textformat = $this->get_format($question->options->instructionsformat);
                 $files = $fs->get_area_files($contextid, $component, 'instruction', $question->id);
                 $expout .= "    <instructions format=\"{$textformat}\">\n";
                 $expout .= $this->writetext($question->options->instructions, 3);
                 $expout .= $this->write_files($files);
                 $expout .= "    </instructions>\n";
             }
             if (isset($question->options->units)) {
                 $units = $question->options->units;
                 if (count($units)) {
                     $expout .= "<units>\n";
                     foreach ($units as $unit) {
                         $expout .= "  <unit>\n";
                         $expout .= "    <multiplier>{$unit->multiplier}</multiplier>\n";
                         $expout .= "    <unit_name>{$unit->unit}</unit_name>\n";
                         $expout .= "  </unit>\n";
                     }
                     $expout .= "</units>\n";
                 }
             }
             //The tag $question->export_process has been set so we get all the data items in the database
             //   from the function $QTYPES['calculated']->get_question_options(&$question);
             //  calculatedsimple defaults to calculated
             if (isset($question->options->datasets) && count($question->options->datasets)) {
                 // there should be
                 $expout .= "<dataset_definitions>\n";
                 foreach ($question->options->datasets as $def) {
                     $expout .= "<dataset_definition>\n";
                     $expout .= "    <status>" . $this->writetext($def->status) . "</status>\n";
                     $expout .= "    <name>" . $this->writetext($def->name) . "</name>\n";
                     if ($question->qtype == CALCULATED) {
                         $expout .= "    <type>calculated</type>\n";
                     } else {
                         $expout .= "    <type>calculatedsimple</type>\n";
                     }
                     $expout .= "    <distribution>" . $this->writetext($def->distribution) . "</distribution>\n";
                     $expout .= "    <minimum>" . $this->writetext($def->minimum) . "</minimum>\n";
                     $expout .= "    <maximum>" . $this->writetext($def->maximum) . "</maximum>\n";
                     $expout .= "    <decimals>" . $this->writetext($def->decimals) . "</decimals>\n";
                     $expout .= "    <itemcount>{$def->itemcount}</itemcount>\n";
                     if ($def->itemcount > 0) {
                         $expout .= "    <dataset_items>\n";
                         foreach ($def->items as $item) {
                             $expout .= "        <dataset_item>\n";
                             $expout .= "           <number>" . $item->itemnumber . "</number>\n";
                             $expout .= "           <value>" . $item->value . "</value>\n";
                             $expout .= "        </dataset_item>\n";
                         }
                         $expout .= "    </dataset_items>\n";
                         $expout .= "    <number_of_items>" . $def->number_of_items . "</number_of_items>\n";
                     }
                     $expout .= "</dataset_definition>\n";
                 }
                 $expout .= "</dataset_definitions>\n";
             }
             break;
         default:
             // try support by optional plugin
             if (!($data = $this->try_exporting_using_qtypes($question->qtype, $question))) {
                 echo $OUTPUT->notification(get_string('unsupportedexport', 'qformat_xml', $QTYPES[$question->qtype]->local_name()));
             }
             $expout .= $data;
     }
     // Write the question tags.
     if (!empty($CFG->usetags)) {
         require_once $CFG->dirroot . '/tag/lib.php';
         $tags = tag_get_tags_array('question', $question->id);
         if (!empty($tags)) {
             $expout .= "    <tags>\n";
             foreach ($tags as $tag) {
                 $expout .= "      <tag>" . $this->writetext($tag, 0, true) . "</tag>\n";
             }
             $expout .= "    </tags>\n";
         }
     }
     // close the question tag
     $expout .= "</question>\n";
     return $expout;
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:101,代码来源:format.php

示例14: definition_after_data

 public function definition_after_data()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     $name = trim($mform->getElementValue('name'));
     $description = trim($mform->getElementValue('description'));
     $url = $mform->getElementValue('url');
     if (empty($name) || empty($description)) {
         $rss = new moodle_simplepie($url);
         if (empty($name) && $rss->get_title()) {
             $mform->setDefault('name', $rss->get_title());
         }
         if (empty($description) && $rss->get_description()) {
             $mform->setDefault('description', $rss->get_description());
         }
     }
     if ($id = $mform->getElementValue('id')) {
         $mform->setDefault('autotags', implode(',', tag_get_tags_array('blog_external', $id)));
         $mform->freeze('url');
         if ($mform->elementExists('filtertags')) {
             $mform->freeze('filtertags');
         }
         // TODO change the filtertags element to a multiple select, using the tags of the external blog
         // Use $rss->get_channel_tags()
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:26,代码来源:external_blog_edit_form.php

示例15: definition

 public function definition()
 {
     $mform =& $this->_form;
     $this->user = $this->_customdata['user'];
     $mform->addElement('hidden', 'action', 'classify');
     $mform->addElement('hidden', 'id', $this->user->id);
     $selected = array();
     if ($itemptags = tag_get_tags_array('userclassify', $this->user->id)) {
         foreach ($itemptags as $itag) {
             $selected[strtolower($itag)] = 1;
         }
     }
     $types = get_records('classification_type');
     $allvalues = tao_get_classifications(false);
     $checkboxes = array();
     foreach ($allvalues as $value) {
         if (!array_key_exists($value->typeid, $checkboxes)) {
             $checkboxes[$value->typeid] = array();
         }
         $checkboxes[$value->typeid][] = $mform->createElement('checkbox', strtolower($value->value), $value->value, $value->value);
     }
     foreach ($types as $type) {
         $mform->addElement('header', $type->name);
         $mform->addGroup($checkboxes[$type->id], 'checkboxes' . $type->id, $type->name);
         $mform->setDefault('checkboxes' . $type->id, $selected);
     }
     $this->add_action_buttons(false);
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:28,代码来源:forms.php


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