本文整理汇总了PHP中text_to_html函数的典型用法代码示例。如果您正苦于以下问题:PHP text_to_html函数的具体用法?PHP text_to_html怎么用?PHP text_to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text_to_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_qtype_match_upgrade
function xmldb_qtype_match_upgrade($oldversion)
{
global $CFG, $DB, $QTYPES;
$dbman = $DB->get_manager();
if ($oldversion < 2009072100) {
// Define field questiontextformat to be added to question_match_sub
$table = new xmldb_table('question_match_sub');
$field = new xmldb_field('questiontextformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'questiontext');
// Conditionally launch add field questiontextformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// In the past, question_match_sub.questiontext assumed to contain
// content of the same form as question.questiontextformat. If we are
// using the HTML editor, then convert FORMAT_MOODLE content to FORMAT_HTML.
$rs = $DB->get_recordset_sql('
SELECT qms.*, q.oldquestiontextformat
FROM {question_match_sub} qms
JOIN {question} q ON qms.question = q.id');
foreach ($rs as $record) {
if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) {
$record->questiontext = text_to_html($record->questiontext, false, false, true);
$record->questiontextformat = FORMAT_HTML;
} else {
$record->questiontextformat = $record->oldquestiontextformat;
}
$DB->update_record('question_match_sub', $record);
}
$rs->close();
// match savepoint reached
upgrade_plugin_savepoint(true, 2009072100, 'qtype', 'match');
}
return true;
}
示例2: process_forum
/**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM data
*/
public function process_forum($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_forum');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// Convert the introformat if necessary.
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// start writing forum.xml
$this->open_xml_writer("activities/forum_{$this->moduleid}/forum.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'forum', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('forum', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('discussions');
return $data;
}
示例3: write_multichoice
/**
* Converts the multichoice info and writes it into the question.xml
*
* @param array $multichoices the grouped structure
* @param int $oldquestiontextformat - {@see moodle1_question_bank_handler::process_question()}
*/
protected function write_multichoice(array $multichoices, $oldquestiontextformat) {
global $CFG;
// the grouped array is supposed to have just one element - let us use foreach anyway
// just to be sure we do not loose anything
foreach ($multichoices as $multichoice) {
// append an artificial 'id' attribute (is not included in moodle.xml)
$multichoice['id'] = $this->converter->get_nextid();
// replay the upgrade step 2009021801
$multichoice['correctfeedbackformat'] = 0;
$multichoice['partiallycorrectfeedbackformat'] = 0;
$multichoice['incorrectfeedbackformat'] = 0;
if ($CFG->texteditors !== 'textarea' and $oldquestiontextformat == FORMAT_MOODLE) {
$multichoice['correctfeedback'] = text_to_html($multichoice['correctfeedback'], false, false, true);
$multichoice['correctfeedbackformat'] = FORMAT_HTML;
$multichoice['partiallycorrectfeedback'] = text_to_html($multichoice['partiallycorrectfeedback'], false, false, true);
$multichoice['partiallycorrectfeedbackformat'] = FORMAT_HTML;
$multichoice['incorrectfeedback'] = text_to_html($multichoice['incorrectfeedback'], false, false, true);
$multichoice['incorrectfeedbackformat'] = FORMAT_HTML;
} else {
$multichoice['correctfeedbackformat'] = $oldquestiontextformat;
$multichoice['partiallycorrectfeedbackformat'] = $oldquestiontextformat;
$multichoice['incorrectfeedbackformat'] = $oldquestiontextformat;
}
$this->write_xml('multichoice', $multichoice, array('/multichoice/id'));
}
}
示例4: xmldb_survey_upgrade
function xmldb_survey_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2009042002) {
/// Define field introformat to be added to survey
$table = new xmldb_table('survey');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
/// Conditionally launch add field introformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$rs = $DB->get_recordset('survey', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $s) {
$s->intro = text_to_html($s->intro, false, false, true);
$s->introformat = FORMAT_HTML;
$DB->update_record('survey', $s);
upgrade_set_timeout();
}
$rs->close();
}
/// survey savepoint reached
upgrade_mod_savepoint(true, 2009042002, 'survey');
}
return true;
}
示例5: process_rcontent
protected function process_rcontent($data)
{
global $DB;
$data = (object) $data;
$oldid = $data->id;
$data->levelid = $this->get_level($data->levelcode, $data->name);
$this->current_isbn = isset($data->isbn) ? $data->isbn : false;
$data->bookid = $this->get_book_id($this->current_isbn, $data->name);
$this->current_book_id = $data->bookid;
$data->unitid = $this->get_unit_id($data->unitcode);
$data->activityid = $this->get_activity_id($data->activitycode, $data->unitid);
if (!isset($data->intro) && isset($data->summary)) {
$data->intro = $data->summary;
if ($CFG->texteditors !== 'textarea') {
$data->intro = text_to_html($data->intro, false, false, true);
}
$data->introformat = FORMAT_HTML;
}
$data->course = $this->get_courseid();
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
// insert the scorm record
$newitemid = $DB->insert_record('rcontent', $data);
// immediately after inserting "activity" record, call this
$this->apply_activity_instance($newitemid);
}
示例6: process_question
/**
* Appends the match specific information to the question
*/
public function process_question(array $data, array $raw)
{
global $CFG;
// populate the list of matches first to get their ids
// note that the field is re-populated on restore anyway but let us
// do our best to produce valid backup files
$matchids = array();
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
$matchids[] = $match['id'];
}
}
// convert match options
$matchoptions = $data['matchoptions'][0];
$matchoptions['id'] = $this->converter->get_nextid();
$matchoptions['subquestions'] = implode(',', $matchids);
$this->write_xml('matchoptions', $matchoptions, array('/matchoptions/id'));
// convert matches
$this->xmlwriter->begin_tag('matches');
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
// replay the upgrade step 2009072100
$match['questiontextformat'] = 0;
if ($CFG->texteditors !== 'textarea' and $data['oldquestiontextformat'] == FORMAT_MOODLE) {
$match['questiontext'] = text_to_html($match['questiontext'], false, false, true);
$match['questiontextformat'] = FORMAT_HTML;
} else {
$match['questiontextformat'] = $data['oldquestiontextformat'];
}
$this->write_xml('match', $match, array('/match/id'));
}
}
$this->xmlwriter->end_tag('matches');
}
示例7: save_text_to_html
function save_text_to_html($string) {
//$string = strip_tags(trim($string));
//$string= htmlspecialchars(trim($string));
$string= text_to_html($string);
$string = preg_replace("/\r\n|\r|\n/", "\n<br />\n", $string);
return $string;
}
示例8: process_giportfolio
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/giportfolio
* data available
* @param array $data
*/
public function process_giportfolio($data)
{
global $CFG;
// Get the course module id and context id.
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// Replay the upgrade step 2009042006.
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// Get a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_giportfolio');
// Convert course files embedded into the intro.
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// Start writing giportfolio.xml.
$this->open_xml_writer("activities/giportfolio_{$this->moduleid}/giportfolio.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'giportfolio', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('giportfolio', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
}
示例9: process_assignment
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/ASSIGNMENT
* data available
*/
public function process_assignment($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
//store assignment type for possible subplugin conversions.
$this->currentsubpluginname = $data['assignmenttype'];
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_assignment');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// convert the introformat if necessary
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// start writing assignment.xml
$this->open_xml_writer("activities/assignment_{$this->moduleid}/assignment.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'assignment', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('assignment', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
//after writing the assignment type element, let the subplugin add on whatever it wants.
$this->handle_assignment_subplugin($data);
$this->xmlwriter->begin_tag('submissions');
return $data;
}
示例10: xmldb_qtype_numerical_upgrade
function xmldb_qtype_numerical_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2009100100) {
//New version in version.php
/// Define table question_numerical_options to be created
$table = new xmldb_table('question_numerical_options');
/// Adding fields to table question_numerical_options
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('instructions', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('showunits', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('unitsleft', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
$table->add_field('unitgradingtype', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('unitpenalty', XMLDB_TYPE_NUMBER, '12, 7', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0.1');
/// Adding keys to table question_numerical_options
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
/// Conditionally launch create table for question_calculated_options
if (!$dbman->table_exists($table)) {
// $dbman->create_table doesnt return a result, we just have to trust it
$dbman->create_table($table);
}
//else
upgrade_plugin_savepoint(true, 2009100100, 'qtype', 'numerical');
}
if ($oldversion < 2009100101) {
// Define field instructionsformat to be added to question_numerical_options
$table = new xmldb_table('question_numerical_options');
$field = new xmldb_field('instructionsformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'instructions');
// Conditionally launch add field instructionsformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// In the past, question_match_sub.questiontext assumed to contain
// content of the same form as question.questiontextformat. If we are
// using the HTML editor, then convert FORMAT_MOODLE content to FORMAT_HTML.
$rs = $DB->get_recordset_sql('
SELECT qno.*, q.oldquestiontextformat
FROM {question_numerical_options} qno
JOIN {question} q ON qno.question = q.id');
foreach ($rs as $record) {
if ($CFG->texteditors !== 'textarea' && $record->oldquestiontextformat == FORMAT_MOODLE) {
$record->instructions = text_to_html($record->questiontext, false, false, true);
$record->instructionsformat = FORMAT_HTML;
} else {
$record->instructionsformat = $record->oldquestiontextformat;
}
$DB->update_record('question_numerical_options', $record);
}
$rs->close();
// numerical savepoint reached
upgrade_plugin_savepoint(true, 2009100101, 'qtype', 'numerical');
}
return true;
}
示例11: links_summary_fill_smarty
function links_summary_fill_smarty(&$vars)
{
if (get_misc_data('links_stories')) {
$vars['smarty']->_vars['story_content'] = text_to_html($vars['smarty']->_vars['story_content']);
}
if (get_misc_data('links_nofollow')) {
$vars['smarty']->_vars['story_content'] = preg_replace('/<a ([^>]+)>/i', '<a rel="nofollow" $1>', $vars['smarty']->_vars['story_content']);
}
}
示例12: extract_useranswer
/**
* Unserialize attempt useranswer and add missing responseformat if needed
* for compatibility with old records.
*
* @param string $useranswer serialized object
* @return object
*/
public static function extract_useranswer($useranswer)
{
$essayinfo = unserialize($useranswer);
if (!isset($essayinfo->responseformat)) {
$essayinfo->response = text_to_html($essayinfo->response, false, false);
$essayinfo->responseformat = FORMAT_HTML;
}
return $essayinfo;
}
示例13: process_scorm
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/SCORM
* data available
*/
public function process_scorm($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$currentcminfo = $this->get_cminfo($instanceid);
$this->moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_scorm');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// check 1.9 version where backup was created
$backupinfo = $this->converter->get_stash('backup_info');
if ($backupinfo['moodle_version'] < 2007110503) {
// as we have no module version data, assume $currmodule->version <= $module->version
// - fix data as the source 1.9 build hadn't yet at time of backing up.
$data['grademethod'] = $data['grademethod'] % 10;
}
// update scormtype (logic is consistent as done in scorm/db/upgrade.php)
$ismanifest = preg_match('/imsmanifest\\.xml$/', $data['reference']);
$iszippif = preg_match('/.(zip|pif)$/', $data['reference']);
$isurl = preg_match('/^((http|https):\\/\\/|www\\.)/', $data['reference']);
if ($isurl) {
if ($ismanifest) {
$data['scormtype'] = 'external';
} else {
if ($iszippif) {
$data['scormtype'] = 'localtype';
}
}
}
// migrate scorm package file
$this->fileman->filearea = 'package';
$this->fileman->itemid = 0;
$this->fileman->migrate_file('course_files/' . $data['reference']);
// start writing scorm.xml
$this->open_xml_writer("activities/scorm_{$this->moduleid}/scorm.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'scorm', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('scorm', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('scoes');
return $data;
}
示例14: desc
public function desc($id)
{
if (!is_valid_id($id)) {
exit('Missing an ID');
}
$this->Product_model->set_id($id);
$info = $this->Product_model->get_product_info();
$data['name'] = $info['name'];
$data['desc'] = text_to_html($info['desc']);
$this->display_ajax('ajax_desc', $data);
}
示例15: xmldb_facetoface_install
function xmldb_facetoface_install() {
global $DB;
//Create default notification templates
$tpl_confirmation = new stdClass();
$tpl_confirmation->status = 1;
$tpl_confirmation->title = get_string('setting:defaultconfirmationsubjectdefault', 'facetoface');
$tpl_confirmation->body = text_to_html(get_string('setting:defaultconfirmationmessagedefault', 'facetoface'));
$tpl_confirmation->managerprefix = text_to_html(get_string('setting:defaultconfirmationinstrmngrdefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_confirmation);
$tpl_cancellation = new stdClass();
$tpl_cancellation->status = 1;
$tpl_cancellation->title = get_string('setting:defaultcancellationsubjectdefault', 'facetoface');
$tpl_cancellation->body = text_to_html(get_string('setting:defaultcancellationmessagedefault', 'facetoface'));
$tpl_cancellation->managerprefix = text_to_html(get_string('setting:defaultcancellationinstrmngrdefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_cancellation);
$tpl_waitlist = new stdClass();
$tpl_waitlist->status = 1;
$tpl_waitlist->title = get_string('setting:defaultwaitlistedsubjectdefault', 'facetoface');
$tpl_waitlist->body = text_to_html(get_string('setting:defaultwaitlistedmessagedefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_waitlist);
$tpl_reminder = new stdClass();
$tpl_reminder->status = 1;
$tpl_reminder->title = get_string('setting:defaultremindersubjectdefault', 'facetoface');
$tpl_reminder->body = text_to_html(get_string('setting:defaultremindermessagedefault', 'facetoface'));
$tpl_reminder->managerprefix = text_to_html(get_string('setting:defaultreminderinstrmngrdefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_reminder);
$tpl_request = new stdClass();
$tpl_request->status = 1;
$tpl_request->title = get_string('setting:defaultrequestsubjectdefault', 'facetoface');
$tpl_request->body = text_to_html(get_string('setting:defaultrequestmessagedefault', 'facetoface'));
$tpl_request->managerprefix = text_to_html(get_string('setting:defaultrequestinstrmngrdefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_request);
$tpl_decline = new stdClass();
$tpl_decline->status = 1;
$tpl_decline->title = get_string('setting:defaultdeclinesubjectdefault', 'facetoface');
$tpl_decline->body = text_to_html(get_string('setting:defaultdeclinemessagedefault', 'facetoface'));
$tpl_decline->managerprefix = text_to_html(get_string('setting:defaultdeclineinstrmngrdefault', 'facetoface'));
$DB->insert_record('facetoface_notification_tpl', $tpl_decline);
// Setting room, building, and address as default filters.
set_config('facetoface_calendarfilters', 'room,building,address');
}