本文整理汇总了PHP中markdown_to_html函数的典型用法代码示例。如果您正苦于以下问题:PHP markdown_to_html函数的具体用法?PHP markdown_to_html怎么用?PHP markdown_to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了markdown_to_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: symbolicate
public function symbolicate()
{
$this->symbolicated_report = null;
$this->symbolicator_error_message = null;
if (is_post_request()) {
$symbolicator = new Symbolicator($this->params['report'], 'tower1');
try {
$this->symbolicated_report = $symbolicator->symbolicate();
} catch (Exception $e) {
$this->symbolicator_error_message = markdown_to_html($e->getMessage());
}
}
}
示例2: editable_section
/**
* Converts a markdown string into HTML, then returns it with the editable area.
*
* @package Reditype
* @subpackage helper
* @param string $string
* @param rtPage $object
* @param bool $summary
* @return string
*/
function editable_section($string, $object = null, $summary = false)
{
return editable_link($object) . markdown_to_html($string, $object, $summary);
}
示例3: format_text
//.........这里部分代码省略.........
if (count($croncache) > 150) {
reset($croncache);
$key = key($croncache);
unset($croncache[$key]);
}
$croncache[$md5key] = $oldcacheitem->formattedtext;
}
return $oldcacheitem->formattedtext;
}
}
}
switch ($format) {
case FORMAT_HTML:
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => FORMAT_HTML, 'noclean' => $options['noclean']));
break;
case FORMAT_PLAIN:
$text = s($text);
// cleans dangerous JS
$text = rebuildnolinktag($text);
$text = str_replace(' ', ' ', $text);
$text = nl2br($text);
break;
case FORMAT_WIKI:
// this format is deprecated
$text = '<p>NOTICE: Wiki-like formatting has been removed from Moodle. You should not be seeing
this message as all texts should have been converted to Markdown format instead.
Please post a bug report to http://moodle.org/bugs with information about where you
saw this message.</p>' . s($text);
break;
case FORMAT_MARKDOWN:
$text = markdown_to_html($text);
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => FORMAT_MARKDOWN, 'noclean' => $options['noclean']));
break;
default:
// FORMAT_MOODLE or anything else
$text = text_to_html($text, null, $options['para'], $options['newlines']);
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => $format, 'noclean' => $options['noclean']));
break;
}
if ($options['filter']) {
// at this point there should not be any draftfile links any more,
// this happens when developers forget to post process the text.
// The only potential problem is that somebody might try to format
// the text before storing into database which would be itself big bug.
$text = str_replace("\"{$CFG->httpswwwroot}/draftfile.php", "\"{$CFG->httpswwwroot}/brokenfile.php#", $text);
}
// Warn people that we have removed this old mechanism, just in case they
// were stupid enough to rely on it.
if (isset($CFG->currenttextiscacheable)) {
debugging('Once upon a time, Moodle had a truly evil use of global variables ' . 'called $CFG->currenttextiscacheable. The good news is that this no ' . 'longer exists. The bad news is that you seem to be using a filter that ' . 'relies on it. Please seek out and destroy that filter code.', DEBUG_DEVELOPER);
}
if (!empty($options['overflowdiv'])) {
$text = html_writer::tag('div', $text, array('class' => 'no-overflow'));
}
if (empty($options['nocache']) and !empty($CFG->cachetext)) {
if (CLI_SCRIPT) {
// special static cron cache - no need to store it in db if its not already there
示例4: get_grading_manager
$newareaid = $manager->create_shared_area($method);
$targetarea = get_grading_manager($newareaid);
$targetcontroller = $targetarea->get_controller($method);
$targetcontroller->update_definition($controller->get_definition_copy($targetcontroller));
$DB->set_field('grading_definitions', 'timecopied', time(), array('id' => $definition->id));
redirect(new moodle_url($PAGE->url, array('message' => get_string('manageactionsharedone', 'core_grading'))));
}
}
// delete the form definition
if (!empty($deleteform)) {
$controller = $manager->get_controller($method);
$definition = $controller->get_definition();
if (!$confirmed) {
// let the user confirm they understand the consequences (also known as WTF-effect)
echo $output->header();
echo $output->confirm(markdown_to_html(get_string('manageactiondeleteconfirm', 'core_grading', array('formname' => s($definition->name), 'component' => $manager->get_component_title(), 'area' => $manager->get_area_title()))), new moodle_url($PAGE->url, array('deleteform' => $deleteform, 'confirmed' => 1)), $PAGE->url);
echo $output->footer();
die;
} else {
require_sesskey();
$controller->delete_definition();
redirect(new moodle_url($PAGE->url, array('message' => get_string('manageactiondeletedone', 'core_grading'))));
}
}
echo $output->header();
if (!empty($message)) {
echo $output->management_message($message);
}
echo $output->heading(get_string('gradingmanagementtitle', 'core_grading', array('component' => $manager->get_component_title(), 'area' => $manager->get_area_title())));
// display the active grading method information and selector
echo $output->management_method_selector($manager, $PAGE->url);
示例5: redirect
$PAGE->set_pagelayout('admin');
// Check if we want to perform any actions.
if ($action) {
if ($action === 'delete') {
if ($ltiplugin->can_delete_instance($instance)) {
if ($confirm) {
$ltiplugin->delete_instance($instance);
redirect($PAGE->url);
}
$yesurl = new moodle_url('/enrol/lti/index.php', array('courseid' => $course->id, 'action' => 'delete', 'instanceid' => $instance->id, 'confirm' => 1, 'sesskey' => sesskey()));
$displayname = $ltiplugin->get_instance_name($instance);
$users = $DB->count_records('user_enrolments', array('enrolid' => $instance->id));
if ($users) {
$message = markdown_to_html(get_string('deleteinstanceconfirm', 'enrol', array('name' => $displayname, 'users' => $users)));
} else {
$message = markdown_to_html(get_string('deleteinstancenousersconfirm', 'enrol', array('name' => $displayname)));
}
echo $OUTPUT->header();
echo $OUTPUT->confirm($message, $yesurl, $PAGE->url);
echo $OUTPUT->footer();
die;
}
} else {
if ($action === 'disable') {
if ($ltiplugin->can_hide_show_instance($instance)) {
if ($instance->status != ENROL_INSTANCE_DISABLED) {
$ltiplugin->update_status($instance, ENROL_INSTANCE_DISABLED);
redirect($PAGE->url);
}
}
} else {
示例6: format_text
//.........这里部分代码省略.........
if (!isset($options['filter'])) {
$options['filter'] = true;
}
if (!isset($options['para'])) {
$options['para'] = true;
}
if (!isset($options['newlines'])) {
$options['newlines'] = true;
}
if (!isset($options['overflowdiv'])) {
$options['overflowdiv'] = false;
}
// Calculate best context.
if (empty($CFG->version) or $CFG->version < 2013051400 or during_initial_install()) {
// Do not filter anything during installation or before upgrade completes.
$context = null;
} else {
if (isset($options['context'])) {
// First by explicit passed context option.
if (is_object($options['context'])) {
$context = $options['context'];
} else {
$context = context::instance_by_id($options['context']);
}
} else {
if ($courseiddonotuse) {
// Legacy courseid.
$context = context_course::instance($courseiddonotuse);
} else {
// Fallback to $PAGE->context this may be problematic in CLI and other non-standard pages :-(.
$context = $PAGE->context;
}
}
}
if (!$context) {
// Either install/upgrade or something has gone really wrong because context does not exist (yet?).
$options['nocache'] = true;
$options['filter'] = false;
}
if ($options['filter']) {
$filtermanager = filter_manager::instance();
$filtermanager->setup_page_for_filters($PAGE, $context);
// Setup global stuff filters may have.
} else {
$filtermanager = new null_filter_manager();
}
switch ($format) {
case FORMAT_HTML:
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => FORMAT_HTML, 'noclean' => $options['noclean']));
break;
case FORMAT_PLAIN:
$text = s($text);
// Cleans dangerous JS.
$text = rebuildnolinktag($text);
$text = str_replace(' ', ' ', $text);
$text = nl2br($text);
break;
case FORMAT_WIKI:
// This format is deprecated.
$text = '<p>NOTICE: Wiki-like formatting has been removed from Moodle. You should not be seeing
this message as all texts should have been converted to Markdown format instead.
Please post a bug report to http://moodle.org/bugs with information about where you
saw this message.</p>' . s($text);
break;
case FORMAT_MARKDOWN:
$text = markdown_to_html($text);
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => FORMAT_MARKDOWN, 'noclean' => $options['noclean']));
break;
default:
// FORMAT_MOODLE or anything else.
$text = text_to_html($text, null, $options['para'], $options['newlines']);
if (!$options['noclean']) {
$text = clean_text($text, FORMAT_HTML, $options);
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => $format, 'noclean' => $options['noclean']));
break;
}
if ($options['filter']) {
// At this point there should not be any draftfile links any more,
// this happens when developers forget to post process the text.
// The only potential problem is that somebody might try to format
// the text before storing into database which would be itself big bug..
$text = str_replace("\"{$CFG->httpswwwroot}/draftfile.php", "\"{$CFG->httpswwwroot}/brokenfile.php#", $text);
if ($CFG->debugdeveloper) {
if (strpos($text, '@@PLUGINFILE@@/') !== false) {
debugging('Before calling format_text(), the content must be processed with file_rewrite_pluginfile_urls()', DEBUG_DEVELOPER);
}
}
}
if (!empty($options['overflowdiv'])) {
$text = html_writer::tag('div', $text, array('class' => 'no-overflow'));
}
return $text;
}
示例7: enrol_page_hook
/**
* Creates course enrol form, checks if form submitted
* and enrols user if necessary. It can also redirect.
*
* @param stdClass $instance
* @return string html text, usually a form in a text box
*/
public function enrol_page_hook(stdClass $instance)
{
global $CFG, $OUTPUT, $SESSION, $USER, $DB;
if (isguestuser()) {
// Can not enrol guest!!
return null;
}
if ($DB->record_exists('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) {
//TODO: maybe we should tell them they are already enrolled, but can not access the course
return null;
}
if ($instance->enrolstartdate != 0 and $instance->enrolstartdate > time()) {
//TODO: inform that we can not enrol yet
return null;
}
if ($instance->enrolenddate != 0 and $instance->enrolenddate < time()) {
//TODO: inform that enrolment is not possible any more
return null;
}
if ($instance->customint5) {
require_once "{$CFG->dirroot}/cohort/lib.php";
if (!cohort_is_member($instance->customint5, $USER->id)) {
$cohort = $DB->get_record('cohort', array('id' => $instance->customint5));
if (!$cohort) {
return null;
}
$a = format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid)));
return $OUTPUT->box(markdown_to_html(get_string('cohortnonmemberinfo', 'enrol_self', $a)));
}
}
require_once "{$CFG->dirroot}/enrol/self/locallib.php";
require_once "{$CFG->dirroot}/group/lib.php";
$form = new enrol_self_enrol_form(NULL, $instance);
$instanceid = optional_param('instance', 0, PARAM_INT);
if ($instance->id == $instanceid) {
if ($data = $form->get_data()) {
$enrol = enrol_get_plugin('self');
$timestart = time();
if ($instance->enrolperiod) {
$timeend = $timestart + $instance->enrolperiod;
} else {
$timeend = 0;
}
$this->enrol_user($instance, $USER->id, $instance->roleid, $timestart, $timeend);
add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id=' . $instance->courseid, $instance->courseid);
//TODO: There should be userid somewhere!
if ($instance->password and $instance->customint1 and $data->enrolpassword !== $instance->password) {
// it must be a group enrolment, let's assign group too
$groups = $DB->get_records('groups', array('courseid' => $instance->courseid), 'id', 'id, enrolmentkey');
foreach ($groups as $group) {
if (empty($group->enrolmentkey)) {
continue;
}
if ($group->enrolmentkey === $data->enrolpassword) {
groups_add_member($group->id, $USER->id);
break;
}
}
}
// Send welcome message.
if ($instance->customint4) {
$this->email_welcome_message($instance, $USER);
}
}
}
ob_start();
$form->display();
$output = ob_get_clean();
return $OUTPUT->box($output);
}
示例8: notify_expiry_enroller
/**
* Notify person responsible for enrolments that some user enrolments will be expired soon,
* it is called only if notification of enrollers (aka teachers) is enabled in course.
*
* This is called repeatedly every day for each course if there are any pending expiration
* in the expiration threshold.
*
* @param int $eid
* @param array $users
* @param bool $verbose
*/
protected function notify_expiry_enroller($eid, $users, $verbose)
{
global $DB, $SESSION;
$name = $this->get_name();
$instance = $DB->get_record('enrol', array('id' => $eid, 'enrol' => $name));
$context = context_course::instance($instance->courseid);
$course = $DB->get_record('course', array('id' => $instance->courseid));
$enroller = $this->get_enroller($instance->id);
$admin = get_admin();
// Some nasty hackery to get strings and dates localised for target user.
$sessionlang = isset($SESSION->lang) ? $SESSION->lang : null;
if (get_string_manager()->translation_exists($enroller->lang, false)) {
$SESSION->lang = $enroller->lang;
moodle_setlocale();
}
foreach ($users as $key => $info) {
$users[$key] = '* ' . $info['fullname'] . ' - ' . userdate($info['timeend'], '', $enroller->timezone);
}
$a = new stdClass();
$a->course = format_string($course->fullname, true, array('context' => $context));
$a->threshold = get_string('numdays', '', $instance->expirythreshold / (60 * 60 * 24));
$a->users = implode("\n", $users);
$a->extendurl = (string) new moodle_url('/enrol/users.php', array('id' => $instance->courseid));
$subject = get_string('expirymessageenrollersubject', 'enrol_' . $name, $a);
$body = get_string('expirymessageenrollerbody', 'enrol_' . $name, $a);
$message = new stdClass();
$message->notification = 1;
$message->component = 'enrol_' . $name;
$message->name = 'expiry_notification';
$message->userfrom = $admin;
$message->userto = $enroller;
$message->subject = $subject;
$message->fullmessage = $body;
$message->fullmessageformat = FORMAT_MARKDOWN;
$message->fullmessagehtml = markdown_to_html($body);
$message->smallmessage = $subject;
$message->contexturlname = $a->course;
$message->contexturl = $a->extendurl;
if (message_send($message)) {
if ($verbose) {
mtrace(" notifying user {$enroller->id} about all expiring {$name} enrolments in course {$instance->courseid}");
}
} else {
if ($verbose) {
mtrace(" error notifying user {$enroller->id} about all expiring {$name} enrolments in course {$instance->courseid}");
}
}
if ($SESSION->lang !== $sessionlang) {
$SESSION->lang = $sessionlang;
moodle_setlocale();
}
}
示例9: require_login
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with local_nagios. If not, see <http://www.gnu.org/licenses/>.
//
// Author: Michael Aherne
// Copyright 2014 University of Strathclyde
require_once '../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_login(SITEID);
require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup('local_nagios');
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/local/nagios/admin.php');
$PAGE->set_pagelayout('standard');
$PAGE->set_pagetype('admin');
$PAGE->set_heading("Nagios services");
$PAGE->navbar->add("Nagios services");
$action = optional_param('action', 'servicelist', PARAM_TEXT);
$out = $PAGE->get_renderer('local_nagios');
if ($action == 'servicelist') {
$servicelist = \local_nagios\service::service_list();
echo $OUTPUT->header();
echo $OUTPUT->heading("Nagios services");
echo $out->render_servicelist($servicelist);
echo $OUTPUT->box(markdown_to_html(get_string('servicelist_help', 'local_nagios')));
echo $OUTPUT->footer();
} else {
die("Unknown action");
}
示例10: use_helper
use_helper('I18N', 'Date', 'rtText');
?>
<div class="rt-section rt-wiki-page">
<div class="rt-section-tools-header rt-admin-tools">
<?php
echo link_to(__('Edit Page'), 'rtWikiPageAdmin/edit?id=' . $rt_wiki_page->getId(), array('class' => 'rt-admin-edit-tools-trigger'));
?>
</div>
<?php
if (sfConfig::get('app_rt_templates_headers_embedded', true)) {
?>
<div class="rt-section-header">
<h1><?php
echo $rt_wiki_page->getTitle();
?>
</h1>
</div>
<?php
}
?>
<div class="rt-section-content">
<?php
echo markdown_to_html($rt_wiki_page->getContent(), $rt_wiki_page);
?>
</div>
</div>
示例11: define
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* PHPUnit info
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_OUTPUT_BUFFERING', true);
require dirname(__FILE__) . '/../../../config.php';
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('toolphpunit');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'tool_phpunit'));
echo $OUTPUT->box_start();
$info = file_get_contents("{$CFG->libdir}/phpunit/readme.md");
echo markdown_to_html($info);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
示例12: markdown_to_html
* MS Excel Viewer 2003 (with Compatibility Pack), 2010
* LibreOffice 3.5, 3.6
* NeoOffice 3.3
* Apple Numbers \'09 (2.3) and Preview
* Google Drive spreadsheet import
* IBM Lotus Symphony 3.0.1
* Gnumeric 1.11
* Calligra Suite 2.4, 2.5
Known problems:
* Excel 2007 borders appear too thick in LibreOffice
* Excel 2007 can not be opened in Calligra Suite
';
echo markdown_to_html($notes);
echo $OUTPUT->box_end();
echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('type' => 'excel2007')), 'Test Excel 2007 format');
echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('type' => 'ods')), 'Test ODS format');
echo $OUTPUT->footer();
die;
}
if ($type === 'excel2007') {
$workbook = new MoodleExcelWorkbook('moodletest.xlsx', 'Excel2007');
} else {
if ($type === 'ods') {
$workbook = new MoodleODSWorkbook('moodletest.ods');
}
}
$worksheet = array();
$worksheet = $workbook->add_worksheet('Supported');
示例13: array
$PAGE->set_pagelayout('incourse');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('switchroleto'));
// Overall criteria aggregation.
$roles = array();
$assumedrole = -1;
if (is_role_switched($course->id)) {
$roles[0] = get_string('switchrolereturn');
$assumedrole = $USER->access['rsw'][$context->path];
}
$availableroles = get_switchable_roles($context);
if (is_array($availableroles)) {
foreach ($availableroles as $key => $role) {
if ($assumedrole == (int) $key) {
continue;
}
$roles[$key] = $role;
}
}
echo $OUTPUT->box(markdown_to_html(get_string('switchroleto_help')));
foreach ($roles as $key => $role) {
$url = new moodle_url('/course/switchrole.php', array('id' => $id, 'switchrole' => $key, 'returnurl' => $returnurl));
echo $OUTPUT->container($OUTPUT->single_button($url, $role), 'm-x-3 m-b-1');
}
$url = new moodle_url($returnurl);
echo $OUTPUT->container($OUTPUT->action_link($url, get_string('cancel')), 'm-x-3 m-b-1');
echo $OUTPUT->footer();
exit;
}
}
redirect($returnurl);
示例14: use_helper
}
div.shout p, div.shout li {
font-size: 150%;
font-weight: bold;
}
.row { *zoom: 1; }
.row:before, .row:after { content: ""; display: table; }
.row:after { clear: both; }
</style>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
<div class="rt-container">
<div class="rt-container-inner row">
<?php
use_helper('rtText');
echo markdown_to_html($sf_request->getParameter('data'), $object);
?>
<div class="clearfix"></div>
</div>
</div>
</body>
</html>
示例15: markdown_to_html
} else {
$message = markdown_to_html(get_string('deleteinstancenousersconfirm', 'enrol', array('name'=>$displayname)));
}
echo $OUTPUT->confirm($message, $yesurl, $PAGE->url);
echo $OUTPUT->footer();
die();
} else if ($action === 'disable') {
$instance = $instances[$instanceid];
$plugin = $plugins[$instance->enrol];
if ($instance->status != ENROL_INSTANCE_DISABLED) {
if (enrol_accessing_via_instance($instance)) {
if (!$confirm2) {
$yesurl = new moodle_url('/enrol/instances.php', array('id'=>$course->id, 'action'=>'disable', 'instance'=>$instance->id, 'confirm2'=>1, 'sesskey'=>sesskey()));
$displayname = $plugin->get_instance_name($instance);
$message = markdown_to_html(get_string('disableinstanceconfirmself', 'enrol', array('name'=>$displayname)));
echo $OUTPUT->header();
echo $OUTPUT->confirm($message, $yesurl, $PAGE->url);
echo $OUTPUT->footer();
die();
}
}
$plugin->update_status($instance, ENROL_INSTANCE_DISABLED);
redirect($PAGE->url);
}
} else if ($action === 'enable') {
$instance = $instances[$instanceid];
$plugin = $plugins[$instance->enrol];
if ($instance->status != ENROL_INSTANCE_ENABLED) {
$plugin->update_status($instance, ENROL_INSTANCE_ENABLED);