本文整理汇总了PHP中strip_pluginfile_content函数的典型用法代码示例。如果您正苦于以下问题:PHP strip_pluginfile_content函数的具体用法?PHP strip_pluginfile_content怎么用?PHP strip_pluginfile_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strip_pluginfile_content函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_strip_pluginfile_content
public function test_strip_pluginfile_content()
{
$source = <<<SOURCE
Hello!
I'm writing to you from the Moodle Majlis in Muscat, Oman, where we just had several days of Moodle community goodness.
URL outside a tag: https://moodle.org/logo/logo-240x60.gif
Plugin url outside a tag: @@PLUGINFILE@@/logo-240x60.gif
External link 1:<img src='https://moodle.org/logo/logo-240x60.gif' alt='Moodle'/>
External link 2:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif"/>
Internal link 1:<img src='@@PLUGINFILE@@/logo-240x60.gif' alt='Moodle'/>
Internal link 2:<img alt="Moodle" src="@@PLUGINFILE@@logo-240x60.gif"/>
Anchor link 1:<a href="@@PLUGINFILE@@logo-240x60.gif" alt="bananas">Link text</a>
Anchor link 2:<a title="bananas" href="../logo-240x60.gif">Link text</a>
Anchor + ext. img:<a title="bananas" href="../logo-240x60.gif"><img alt="Moodle" src="@@PLUGINFILE@@logo-240x60.gif"/></a>
Ext. anchor + img:<a href="@@PLUGINFILE@@logo-240x60.gif"><img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif"/></a>
SOURCE;
$expected = <<<EXPECTED
Hello!
I'm writing to you from the Moodle Majlis in Muscat, Oman, where we just had several days of Moodle community goodness.
URL outside a tag: https://moodle.org/logo/logo-240x60.gif
Plugin url outside a tag: @@PLUGINFILE@@/logo-240x60.gif
External link 1:<img src="https://moodle.org/logo/logo-240x60.gif" alt="Moodle" />
External link 2:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif" />
Internal link 1:
Internal link 2:
Anchor link 1:Link text
Anchor link 2:<a title="bananas" href="../logo-240x60.gif">Link text</a>
Anchor + ext. img:<a title="bananas" href="../logo-240x60.gif"></a>
Ext. anchor + img:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif" />
EXPECTED;
$this->assertSame($expected, strip_pluginfile_content($source));
}
示例2: convert_submission_text_to_feedback
/**
* Convert the text from any submission plugin that has an editor field to
* a format suitable for inserting in the feedback text field.
*
* @param stdClass $submission
* @param stdClass $data - Form data to be filled with the converted submission text and format.
* @return boolean - True if feedback text was set.
*/
protected function convert_submission_text_to_feedback($submission, $data) {
$format = false;
$text = '';
foreach ($this->assignment->get_submission_plugins() as $plugin) {
$fields = $plugin->get_editor_fields();
if ($plugin->is_enabled() && $plugin->is_visible() && !empty($fields)) {
foreach ($fields as $key => $description) {
$rawtext = strip_pluginfile_content($plugin->get_editor_text($key, $submission->id));
$newformat = $plugin->get_editor_format($key, $submission->id);
if ($format !== false && $newformat != $format) {
// There are 2 or more editor fields using different formats, set to plain as a fallback.
$format = FORMAT_PLAIN;
} else {
$format = $newformat;
}
$text .= $rawtext;
}
}
}
$data->assignfeedbackcomments_editor['text'] = $text;
$data->assignfeedbackcomments_editor['format'] = $format;
return true;
}
示例3: update_calendar
/**
* Update the calendar entries for this assignment.
*
* @param int $coursemoduleid - Required to pass this in because it might
* not exist in the database yet.
* @return bool
*/
public function update_calendar($coursemoduleid)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/calendar/lib.php';
// Special case for add_instance as the coursemodule has not been set yet.
$instance = $this->get_instance();
if ($instance->duedate) {
$event = new stdClass();
$params = array('modulename' => 'assign', 'instance' => $instance->id);
$event->id = $DB->get_field('event', 'id', $params);
$event->name = $instance->name;
$event->timestart = $instance->duedate;
// Convert the links to pluginfile. It is a bit hacky but at this stage the files
// might not have been saved in the module area yet.
$intro = $instance->intro;
if ($draftid = file_get_submitted_draft_itemid('introeditor')) {
$intro = file_rewrite_urls_to_pluginfile($intro, $draftid);
}
// We need to remove the links to files as the calendar is not ready
// to support module events with file areas.
$intro = strip_pluginfile_content($intro);
if ($this->show_intro()) {
$event->description = array('text' => $intro, 'format' => $instance->introformat);
} else {
$event->description = array('text' => '', 'format' => $instance->introformat);
}
if ($event->id) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
unset($event->id);
$event->courseid = $instance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assign';
$event->instance = $instance->id;
$event->eventtype = 'due';
$event->timeduration = 0;
calendar_event::create($event);
}
} else {
$DB->delete_records('event', array('modulename' => 'assign', 'instance' => $instance->id));
}
}
示例4: update_calendar
/**
* Update the calendar entries for this assignment.
*
* @param \stdClass $collaborate- collaborate record
*
* @return bool
*/
public static function update_calendar($collaborate)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/calendar/lib.php';
$event = new \stdClass();
$params = array('modulename' => 'collaborate', 'instance' => $collaborate->id);
$event->id = $DB->get_field('event', 'id', $params);
$event->name = $collaborate->name;
$event->timestart = $collaborate->timestart;
// Convert the links to pluginfile. It is a bit hacky but at this stage the files
// might not have been saved in the module area yet.
$intro = $collaborate->intro;
if ($draftid = file_get_submitted_draft_itemid('introeditor')) {
$intro = file_rewrite_urls_to_pluginfile($intro, $draftid);
}
// We need to remove the links to files as the calendar is not ready
// to support module events with file areas.
$intro = strip_pluginfile_content($intro);
$event->description = array('text' => $intro, 'format' => $collaborate->introformat);
if ($event->id) {
$calendarevent = \calendar_event::load($event->id);
$calendarevent->update($event);
} else {
unset($event->id);
$event->courseid = $collaborate->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'collaborate';
$event->instance = $collaborate->id;
$event->eventtype = 'due';
$event->timeend = self::timeend_from_duration($collaborate->timestart, $collaborate->duration);
if (!empty($event->timeend)) {
$event->timeduration = $event->timeend - $event->timestart;
} else {
$event->timeduration = 0;
}
\calendar_event::create($event);
}
}