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


PHP trusttext_pre_edit函数代码示例

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


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

示例1: prepare_message_for_edit

 public function prepare_message_for_edit($cm, $post)
 {
     $this->append_edited_by($post);
     $context = \context_module::instance($cm->id);
     $post = trusttext_pre_edit($post, 'message', $context);
     $itemid = file_get_submitted_draft_itemid('message');
     $message = file_prepare_draft_area($itemid, $context->id, 'mod_hsuforum', 'post', $post->id, \mod_hsuforum_post_form::editor_options($context, $post->id), $post->message);
     return array($message, $itemid);
 }
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:9,代码来源:form_service.php

示例2: print_error

     }
     $PAGE->set_cm($cm, $course, $forum);
     if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) {
         if (time() - $post->created > $CFG->maxeditingtime and !has_capability('mod/forum:editanypost', $modcontext)) {
             print_error('maxtimehaspassed', 'forum', '', format_time($CFG->maxeditingtime));
         }
     }
     if ($post->userid != $USER->id and !has_capability('mod/forum:editanypost', $modcontext)) {
         print_error('cannoteditposts', 'forum');
     }
     // Load up the $post variable.
     $post->edit = $edit;
     $post->course = $course->id;
     $post->forum = $forum->id;
     $post->groupid = $discussion->groupid == -1 ? 0 : $discussion->groupid;
     $post = trusttext_pre_edit($post, 'message', $modcontext);
     unset($SESSION->fromdiscussion);
 } else {
     if (!empty($delete)) {
         // User is deleting a post
         if (!($post = forum_get_post_full($delete))) {
             print_error('invalidpostid', 'forum');
         }
         if (!($discussion = $DB->get_record("forum_discussions", array("id" => $post->discussion)))) {
             print_error('notpartofdiscussion', 'forum');
         }
         if (!($forum = $DB->get_record("forum", array("id" => $discussion->forum)))) {
             print_error('invalidforumid', 'forum');
         }
         if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course))) {
             print_error('invalidcoursemodule');
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php

示例3: file_prepare_standard_editor

/**
 * Prepares 'editor' formslib element from data in database
 *
 * The passed $data record must contain field foobar, foobarformat and optionally foobartrust. This
 * function then copies the embedded files into draft area (assigning itemids automatically),
 * creates the form element foobar_editor and rewrites the URLs so the embedded images can be
 * displayed.
 * In your mform definition, you must have an 'editor' element called foobar_editor. Then you call
 * your mform's set_data() supplying the object returned by this function.
 *
 * @category files
 * @param stdClass $data database field that holds the html text with embedded media
 * @param string $field the name of the database field that holds the html text with embedded media
 * @param array $options editor options (like maxifiles, maxbytes etc.)
 * @param stdClass $context context of the editor
 * @param string $component
 * @param string $filearea file area name
 * @param int $itemid item id, required if item exists
 * @return stdClass modified data object
 */
function file_prepare_standard_editor($data, $field, array $options, $context = null, $component = null, $filearea = null, $itemid = null)
{
    $options = (array) $options;
    if (!isset($options['trusttext'])) {
        $options['trusttext'] = false;
    }
    if (!isset($options['forcehttps'])) {
        $options['forcehttps'] = false;
    }
    if (!isset($options['subdirs'])) {
        $options['subdirs'] = false;
    }
    if (!isset($options['maxfiles'])) {
        $options['maxfiles'] = 0;
        // no files by default
    }
    if (!isset($options['noclean'])) {
        $options['noclean'] = false;
    }
    //sanity check for passed context. This function doesn't expect $option['context'] to be set
    //But this function is called before creating editor hence, this is one of the best places to check
    //if context is used properly. This check notify developer that they missed passing context to editor.
    if (isset($context) && !isset($options['context'])) {
        //if $context is not null then make sure $option['context'] is also set.
        debugging('Context for editor is not set in editoroptions. Hence editor will not respect editor filters', DEBUG_DEVELOPER);
    } else {
        if (isset($options['context']) && isset($context)) {
            //If both are passed then they should be equal.
            if ($options['context']->id != $context->id) {
                $exceptionmsg = 'Editor context [' . $options['context']->id . '] is not equal to passed context [' . $context->id . ']';
                throw new coding_exception($exceptionmsg);
            }
        }
    }
    if (is_null($itemid) or is_null($context)) {
        $contextid = null;
        $itemid = null;
        if (!isset($data)) {
            $data = new stdClass();
        }
        if (!isset($data->{$field})) {
            $data->{$field} = '';
        }
        if (!isset($data->{$field . 'format'})) {
            $data->{$field . 'format'} = editors_get_preferred_format();
        }
        if (!$options['noclean']) {
            $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
        }
    } else {
        if ($options['trusttext']) {
            // noclean ignored if trusttext enabled
            if (!isset($data->{$field . 'trust'})) {
                $data->{$field . 'trust'} = 0;
            }
            $data = trusttext_pre_edit($data, $field, $context);
        } else {
            if (!$options['noclean']) {
                $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
            }
        }
        $contextid = $context->id;
    }
    if ($options['maxfiles'] != 0) {
        $draftid_editor = file_get_submitted_draft_itemid($field);
        $currenttext = file_prepare_draft_area($draftid_editor, $contextid, $component, $filearea, $itemid, $options, $data->{$field});
        $data->{$field . '_editor'} = array('text' => $currenttext, 'format' => $data->{$field . 'format'}, 'itemid' => $draftid_editor);
    } else {
        $data->{$field . '_editor'} = array('text' => $data->{$field}, 'format' => $data->{$field . 'format'}, 'itemid' => 0);
    }
    return $data;
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:92,代码来源:filelib.php

示例4: file_prepare_standard_editor

/**
 * Prepares 'editor' formslib element from data in database
 *
 * The passed $data record must contain field foobar, foobarformat and optionally foobartrust. This
 * function then copies the embedded files into draft area (assigning itemids automatically),
 * creates the form element foobar_editor and rewrites the URLs so the embedded images can be
 * displayed.
 * In your mform definition, you must have an 'editor' element called foobar_editor. Then you call
 * your mform's set_data() supplying the object returned by this function.
 *
 * @param object $data database field that holds the html text with embedded media
 * @param string $field the name of the database field that holds the html text with embedded media
 * @param array $options editor options (like maxifiles, maxbytes etc.)
 * @param object $context context of the editor
 * @param string $component
 * @param string $filearea file area name
 * @param int $itemid item id, required if item exists
 * @return object modified data object
 */
function file_prepare_standard_editor($data, $field, array $options, $context = null, $component = null, $filearea = null, $itemid = null)
{
    $options = (array) $options;
    if (!isset($options['trusttext'])) {
        $options['trusttext'] = false;
    }
    if (!isset($options['forcehttps'])) {
        $options['forcehttps'] = false;
    }
    if (!isset($options['subdirs'])) {
        $options['subdirs'] = false;
    }
    if (!isset($options['maxfiles'])) {
        $options['maxfiles'] = 0;
        // no files by default
    }
    if (!isset($options['noclean'])) {
        $options['noclean'] = false;
    }
    if (is_null($itemid) or is_null($context)) {
        $contextid = null;
        $itemid = null;
        if (!isset($data->{$field})) {
            $data->{$field} = '';
        }
        if (!isset($data->{$field . 'format'})) {
            $data->{$field . 'format'} = editors_get_preferred_format();
        }
        if (!$options['noclean']) {
            $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
        }
    } else {
        if ($options['trusttext']) {
            // noclean ignored if trusttext enabled
            if (!isset($data->{$field . 'trust'})) {
                $data->{$field . 'trust'} = 0;
            }
            $data = trusttext_pre_edit($data, $field, $context);
        } else {
            if (!$options['noclean']) {
                $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
            }
        }
        $contextid = $context->id;
    }
    if ($options['maxfiles'] != 0) {
        $draftid_editor = file_get_submitted_draft_itemid($field);
        $currenttext = file_prepare_draft_area($draftid_editor, $contextid, $component, $filearea, $itemid, $options, $data->{$field});
        $data->{$field . '_editor'} = array('text' => $currenttext, 'format' => $data->{$field . 'format'}, 'itemid' => $draftid_editor);
    } else {
        $data->{$field . '_editor'} = array('text' => $data->{$field}, 'format' => $data->{$field . 'format'}, 'itemid' => 0);
    }
    return $data;
}
开发者ID:richheath,项目名称:moodle,代码行数:73,代码来源:filelib.php

示例5: file_prepare_standard_editor

/**
 * Prepares standardised text field fro editing with Editor formslib element
 * @param object $data $database entry field
 * @param string $field name of data field
 * @param array $options various options
 * @param object $context context, required for existing data
 * @param string $filearea file area name
 * @param int $itemid item id, required if item exists
 * @return object modified data object
 */
function file_prepare_standard_editor($data, $field, array $options, $context = null, $filearea = null, $itemid = null)
{
    $options = (array) $options;
    if (!isset($options['trusttext'])) {
        $options['trusttext'] = false;
    }
    if (!isset($options['forcehttps'])) {
        $options['forcehttps'] = false;
    }
    if (!isset($options['subdirs'])) {
        $options['subdirs'] = false;
    }
    if (!isset($options['maxfiles'])) {
        $options['maxfiles'] = 0;
        // no files by default
    }
    if (!isset($options['noclean'])) {
        $options['noclean'] = false;
    }
    if (empty($data->id) or empty($context)) {
        $contextid = null;
        $data->id = null;
        if (!isset($data->{$field})) {
            $data->{$field} = '';
        }
        if (!isset($data->{$field . 'format'})) {
            $data->{$field . 'format'} = FORMAT_HTML;
            // TODO: use better default based on user preferences and browser capabilities
        }
        if (!$options['noclean']) {
            $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
        }
    } else {
        if ($options['trusttext']) {
            // noclean ignored if trusttext enabled
            if (!isset($data->{$field . 'trust'})) {
                $data->{$field . 'trust'} = 0;
            }
            $data = trusttext_pre_edit($data, $field, $context);
        } else {
            if (!$options['noclean']) {
                $data->{$field} = clean_text($data->{$field}, $data->{$field . 'format'});
            }
        }
        $contextid = $context->id;
    }
    if ($options['maxfiles'] != 0) {
        $draftid_editor = file_get_submitted_draft_itemid($field);
        $currenttext = file_prepare_draft_area($draftid_editor, $contextid, $filearea, $data->id, $options['subdirs'], $data->{$field}, $options['forcehttps']);
        $data->{$field . '_editor'} = array('text' => $currenttext, 'format' => $data->{$field . 'format'}, 'itemid' => $draftid_editor);
    } else {
        $data->{$field . '_editor'} = array('text' => $data->{$field}, 'format' => $data->{$field . 'format'}, 0);
    }
    return $data;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:65,代码来源:filelib.php


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