本文整理汇总了PHP中filter_get_active_in_context函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_get_active_in_context函数的具体用法?PHP filter_get_active_in_context怎么用?PHP filter_get_active_in_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_get_active_in_context函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update_init_params
protected function update_init_params(array &$params, context $context, array $options = null)
{
global $OUTPUT;
if ($this->get_config('requireemoticon', 1)) {
// If emoticon filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/emoticon', $filters)) {
return;
}
}
// Add button after 'image' in advancedbuttons3.
$this->add_button_after($params, 3, 'moodleemoticon', 'image');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
// Extra params specifically for emoticon plugin.
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$imgs = array();
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
$index = 0;
foreach ($emoticons as $emoticon) {
$imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
}
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:25,代码来源:lib.php
示例2: update_init_params
protected function update_init_params(array &$params, context $context, array $options = null)
{
// If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/tex', $filters)) {
return;
}
// Add button before 'nonbreaking' in advancedbuttons3.
$this->add_button_before($params, 3, 'dragmath', 'nonbreaking');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
开发者ID:nigeli,项目名称:moodle,代码行数:12,代码来源:lib.php
示例3: load_filters
/** Load all the filters required by this context. */
protected function load_filters($context, $courseid)
{
$filters = filter_get_active_in_context($context);
$this->textfilters[$context->id] = array();
$this->stringfilters[$context->id] = array();
foreach ($filters as $filtername => $localconfig) {
$filter = $this->make_filter_object($filtername, $context, $courseid, $localconfig);
if (is_null($filter)) {
continue;
}
$this->textfilters[$context->id][] = $filter;
if (in_array($filtername, $this->stringfilternames)) {
$this->stringfilters[$context->id][] = $filter;
}
}
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:17,代码来源:filterlib.php
示例4: update_init_params
protected function update_init_params(array &$params, context $context, array $options = null)
{
// 'binumi' is the key used in Moodle >= 2.5
$filters = filter_get_active_in_context($context);
$enabled = array_key_exists('binumi', $filters);
// If binumi filter is disabled, do not add button.
if (!$enabled) {
return;
}
$binumi_client = new binumi_client();
$params = $params + $binumi_client->get_texteditor_params();
$numrows = $this->count_button_rows($params);
$this->add_button_after($params, $numrows, '|,binumi');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
开发者ID:Binumi,项目名称:binumi-moodle,代码行数:16,代码来源:lib.php
示例5: update_init_params
protected function update_init_params(array &$params, context $context, array $options = null)
{
if ($this->get_config('requiretex', 1)) {
// If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('tex', $filters)) {
return;
}
}
if ($row = $this->find_button($params, 'nonbreaking')) {
// Add button before 'nonbreaking'.
$this->add_button_before($params, $row, 'dragmath', 'nonbreaking');
} else {
// If 'nonbreaking' is not found, add button in the end of the last row:
$this->add_button_after($params, $this->count_button_rows($params), 'dragmath');
}
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:19,代码来源:lib.php
示例6: update_init_params
protected function update_init_params(array &$params, context $context, array $options = null)
{
if ($this->get_config('requiremultilang2', 1)) {
// If multi-language content filter (v2) is disabled, do not add drop down menu.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('multilang2', $filters)) {
return;
}
}
if (!has_capability('tinymce/moodlelang2:viewlanguagemenu', $context)) {
return;
}
if ($row = $this->find_button($params, 'formatselect')) {
// Add button after 'formatselect'.
$this->add_button_after($params, $row, 'moodlelang2', 'formatselect');
} else {
// Add this button in the end of the first row (by default 'formatselect' button should be in the first row).
$this->add_button_after($params, 1, 'moodlelang2');
}
// We need to pass the list of languages to tinymce.
if ($this->get_config('showalllangs')) {
$langs = get_string_manager()->get_list_of_languages();
} else {
$langs = get_string_manager()->get_list_of_translations();
}
asort($langs);
$params['moodlelang2_langs'] = json_encode($langs);
if ($highlight = $this->get_config('highlight', 1)) {
$params['moodlelang2_highlight'] = json_encode($highlight);
}
require dirname(__FILE__) . '/default-css.php';
if ($highlight_css = $this->get_config('highlight_css', $moodlelang2_default_css)) {
$params['moodlelang2_css'] = json_encode($highlight_css);
}
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
开发者ID:alexferrergrau,项目名称:moodle-tinymce_moodlelang2,代码行数:37,代码来源:lib.php
示例7: save_post
/**
* Save a post using the submitted data
*
* @param type $data
* @return type
*/
public function save_post($data, $course)
{
global $USER, $DB, $CFG, $PAGE;
require_once $CFG->dirroot . '/mod/url/locallib.php';
$context = \context_course::instance($data->courseid);
// ... create post.
$post = new \stdClass();
$update = false;
// If id is not empty, ensure that post is existing and test whether user is updating the post.
if (!empty($data->id)) {
if ($exists = $DB->get_record('format_socialwall_posts', array('id' => $data->id))) {
$post = $exists;
// Check, whether user is allowed to update the post.
$caneditpost = ($post->fromuserid == $USER->id and has_capability('format/socialwall:updateownpost', $context));
$caneditpost = ($caneditpost or has_capability('format/socialwall:updateanypost', $context));
if (!$caneditpost) {
print_error('missingcapupdatepost', 'format_socialwall');
}
$update = true;
} else {
print_error('noposttoupdate', 'format_socialwall');
}
}
// ...save when even a posttext or a externalurl or a file or a actvitiy is given.
$cmsequence = $data->cmsequence;
// ... are there added activities?
if (!empty($cmsequence)) {
$cmsequence = $this->check_and_move_module($data->courseid, $cmsequence);
}
// If user may not add any activity but may add a file or a link, replace existing files with new file.
if (!$PAGE->user_allowed_editing()) {
// ... add a resource.
if (!empty($data->files)) {
$canpostfile = has_capability('format/socialwall:postfile', $context) && !empty($course->enablestudentupload);
if (!$canpostfile) {
print_error('missingcappostfile', 'format_socialwall');
}
$cmsequence = $this->create_mod_files($data);
} else {
// ... check externalurl and create a activity in section 1, if necessary.
if (!empty($data->externalurl)) {
$canposturl = has_capability('format/socialwall:posturl', $context) && !empty($course->enablestudentupload);
if (!$canposturl) {
print_error('missingcapposturl', 'format_socialwall');
}
$cmsequence = $this->create_mod_url($data->externalurl);
// ... set filter Plugin here.
$filters = filter_get_active_in_context($context);
if (isset($filters['urlresource'])) {
require_once $CFG->dirroot . '/filter/urlresource/lib.php';
\filter_url_resource_helper::save_externalurl($data, $cmsequence);
}
}
}
}
if (empty($data->posttext) and empty($cmsequence)) {
print_error('attachmentorpostrequired', 'format_socialwall');
}
$post->courseid = $data->courseid;
$post->fromuserid = $USER->id;
$post->togroupid = $data->togroupid;
if (is_array($data->posttext)) {
$posttext = $data->posttext['text'];
} else {
$posttext = $data->posttext;
}
if (has_capability('format/socialwall:posthtml', $context)) {
$post->posttext = clean_text($posttext);
} else {
$post->posttext = clean_param($posttext, PARAM_NOTAGS);
}
if (isset($data->poststatus)) {
$post->sticky = $data->poststatus == 1;
$post->private = $data->poststatus == 2;
$post->alert = $data->poststatus == 4;
} else {
$post->sticky = 0;
$post->private = 0;
$post->alert = 0;
}
if ($update) {
$post->timemodified = time();
$DB->update_record('format_socialwall_posts', $post);
// ...reset postid if post was updated.
$cache = \cache::make('format_socialwall', 'timelinefilter');
$cache->purge_current_user();
} else {
$post->timecreated = time();
$post->timemodified = $post->timecreated;
$post->id = $DB->insert_record('format_socialwall_posts', $post);
}
attaches::save_attaches($post->id, $cmsequence);
// We use a instant enqueueing, if needed you might use events here.
notification::enqueue_post_created($post);
//.........这里部分代码省略.........
开发者ID:HarcourtsAcademy,项目名称:moodle-format_socialwall,代码行数:101,代码来源:posts.php
示例8: definition
//.........这里部分代码省略.........
if (isset($formparams['togroupid'])) {
$mform->setDefault('togroupid', $formparams['togroupid']);
}
}
// ... options group.
$poststatusmenu = array(0 => get_string('poststatus', 'format_socialwall'));
if (has_capability('format/socialwall:makesticky', $context)) {
$poststatusmenu[1] = get_string('makesticky', 'format_socialwall');
}
if (has_capability('format/socialwall:postprivate', $context)) {
$poststatusmenu[2] = get_string('privatepost', 'format_socialwall');
}
if ($PAGE->user_allowed_editing()) {
$poststatusmenu[4] = get_string('makealert', 'format_socialwall');
}
if (count($poststatusmenu) > 1) {
$postoptions[] = $mform->createElement('select', 'poststatus', '', $poststatusmenu);
if (isset($formparams['poststatus'])) {
$mform->setDefault('poststatus', $formparams['poststatus']);
}
}
// ...switch htmleditor on/off.
if ($canposthtml) {
$key = !empty($formparams['loadposteditor']) ? 'turneditoroff' : 'turneditoron';
$postoptions[] = $mform->createElement('submit', $key, get_string($key, 'format_socialwall'));
}
if (count($postoptions) > 0) {
$mform->addGroup($postoptions);
}
// ... display the activites prepared for the next post only by a teacher.
if ($PAGE->user_allowed_editing()) {
if (!isset($USER->editing) or !$USER->editing) {
$addstr = get_string('addactivityresource', 'format_socialwall');
$mform->addElement('submit', 'turneditingon', $addstr, array('id' => 'sw-addactivitylink'));
}
} else {
$o = html_writer::tag('div', '', array('class' => 'clearfix'));
$mform->addElement('html', $o);
// ...upload options for all users, which cannot edit page.
$attachgroup = array();
$course = course_get_format($COURSE)->get_course();
$canpostfile = has_capability('format/socialwall:postfile', $context) && !empty($course->enablestudentupload);
if ($canpostfile) {
$uploadfileicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('icon', 'resource')));
$linktext = $uploadfileicon . get_string('uploadafile', 'format_socialwall');
$url = new moodle_url('/course/view.php', array('id' => $courseid, 'loadfilemanager' => 1));
$link = html_writer::link($url, $linktext, array('id' => 'uploadfile'));
$attachgroup[] = $mform->createElement('static', 'uploadfile', '', $link);
}
$canposturl = has_capability('format/socialwall:posturl', $context) && !empty($course->enablestudentupload);
if ($canposturl) {
$addlinkicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('icon', 'url')));
$at = html_writer::link('#', $addlinkicon . get_string('addalink', 'format_socialwall'), array('id' => 'addalink'));
$attachgroup[] = $mform->createElement('static', 'addalink', '', $at);
}
if (!empty($attachgroup)) {
$mform->addGroup($attachgroup);
}
$loadfilemanager = optional_param('loadfilemanager', 0, PARAM_INT);
if ($canpostfile and $loadfilemanager == 1) {
$mform->addElement('html', html_writer::start_div('', array('id' => 'fileswrapper')));
// ... filemanager.
$filemanageroptions = array();
$filemanageroptions['accepted_types'] = '*';
$filemanageroptions['maxbytes'] = 0;
$filemanageroptions['maxfiles'] = 1;
$filemanageroptions['mainfile'] = true;
$mform->addElement('filemanager', 'files', get_string('selectfiles'), array(), $filemanageroptions);
$mform->addElement('html', html_writer::end_div());
$mform->addElement('hidden', 'loadfilemanager', '1', array('id' => 'loadfilemanager'));
$mform->setType('loadfilemanager', PARAM_INT);
}
// ...external url.
$style = isset($errors['externalurl']) ? 'display:auto' : 'display:none';
$mform->addElement('html', html_writer::start_div('', array('id' => 'externalurlwrapper', 'style' => $style)));
$mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size' => '60'), array('usefilepicker' => true));
$mform->setType('externalurl', PARAM_URL);
if (isset($errors['externalurl'])) {
$mform->setDefault('externalurl', $errors['externalurl']['value']);
}
// ... get urlresource filter a try.
$filters = filter_get_active_in_context($context);
if (isset($filters['urlresource'])) {
require_once $CFG->dirroot . '/filter/urlresource/lib.php';
filter_url_resource_helper::add_postformfields($mform, $courseid);
}
$mform->addElement('html', html_writer::end_div());
}
// Id of post to remember the update option for further pageloads.
$mform->addElement('hidden', 'id', 0, array('id' => 'id'));
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $postid);
// Id of course we are in.
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$mform->setDefault('courseid', $courseid);
$mform->addElement('hidden', 'action', $action);
$mform->setType('action', PARAM_TEXT);
$mform->disable_form_change_checker();
}
开发者ID:HarcourtsAcademy,项目名称:moodle-format_socialwall,代码行数:101,代码来源:post_form.php
示例9: assert_matches
private function assert_matches($modinfo)
{
global $FILTERLIB_PRIVATE;
// Use preload cache...
$FILTERLIB_PRIVATE = new stdClass();
filter_preload_activities($modinfo);
// Get data and check no queries are made
$before = $this->testdb->perf_get_reads();
$plfilters1 = filter_get_active_in_context($this->activity1context);
$plfilters2 = filter_get_active_in_context($this->activity2context);
$after = $this->testdb->perf_get_reads();
$this->assertEqual($before, $after);
// Repeat without cache and check it makes queries now
$FILTERLIB_PRIVATE = new stdClass();
$before = $this->testdb->perf_get_reads();
$filters1 = filter_get_active_in_context($this->activity1context);
$filters2 = filter_get_active_in_context($this->activity2context);
$after = $this->testdb->perf_get_reads();
$this->assertTrue($after > $before);
// Check they match
$this->assertEqual($plfilters1, $filters1);
$this->assertEqual($plfilters2, $filters2);
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:23,代码来源:testfilterconfig.php
示例10: fix_filters
/**
* fix_filters
*
* @return xxx
*/
function fix_filters()
{
global $CFG;
if (isset($CFG->textfilters)) {
$textfilters = $CFG->textfilters;
} else {
$textfilters = '';
}
if ($this->hotpot->usefilters) {
$filters = filter_get_active_in_context($this->hotpot->context);
$filters = array_keys($filters);
} else {
$filters = array();
}
if ($this->hotpot->useglossary && !in_array('mod/glossary', $filters)) {
$filters[] = 'mod/glossary';
}
if ($this->hotpot->usemediafilter) {
// exclude certain unnecessary or miscreant $filters
// - "mediaplugins" because it duplicates work done by "usemediafilter" setting
// - "asciimath" because it does not behave like a filter is supposed to behave
$filters = preg_grep('/^filter\\/(mediaplugin|asciimath)$/', $filters, PREG_GREP_INVERT);
}
$CFG->textfilters = implode(',', $filters);
$this->filter_text_headcontent();
$this->filter_text_bodycontent();
$CFG->textfilters = $textfilters;
// fix unwanted conversions by the Moodle's Tex filter
// http://moodle.org/mod/forum/discuss.php?d=68435
// http://tracker.moodle.org/browse/MDL-7849
if (preg_match('/jcross|jmix/', get_class($this))) {
$search = '/(?<=replace\\(\\/)' . '<a[^>]*><img[^>]*class="texrender"[^>]*title="(.*?)"[^>]*><\\/a>' . '(?=\\/g)/is';
$replace = '\\[' . '$1' . '\\]';
$this->headcontent = preg_replace($search, $replace, $this->headcontent);
}
// make sure openpopup() function is available if needed (for glossary entries)
// Note: this could also be done using filter_add_javascript($this->htmlcontent)
// but that function expects entire htmlcontent, where we would prefer just the headcontent
if ($this->hotpot->navigation == hotpot::NAVIGATION_ORIGINAL && in_array('mod/glossary', $filters)) {
// add openwindow() function (from lib/javascript.php)
$this->headcontent .= "\n" . '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . 'function openpopup(url, name, options, fullscreen) {' . "\n" . ' var fullurl = "' . $CFG->httpswwwroot . '" + url;' . "\n" . ' var windowobj = window.open(fullurl, name, options);' . "\n" . ' if (!windowobj) {' . "\n" . ' return true;' . "\n" . ' }' . "\n" . ' if (fullscreen) {' . "\n" . ' windowobj.moveTo(0, 0);' . "\n" . ' windowobj.resizeTo(screen.availWidth, screen.availHeight);' . "\n" . ' }' . "\n" . ' windowobj.focus();' . "\n" . ' return false;' . "\n" . '}' . "\n" . '//]]>' . "\n" . '</script>';
}
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:48,代码来源:renderer.php
示例11: test_config_from_other_filter_not_returned
public function test_config_from_other_filter_not_returned()
{
// Setup fixture.
filter_set_global_state('filter/name', TEXTFILTER_ON);
filter_set_local_config('filter/name', $this->childcontext->id, 'settingname', 'A value');
filter_set_local_config('filter/other', $this->childcontext->id, 'anothersettingname', 'Another value');
// Exercise SUT.
$filters = filter_get_active_in_context($this->childcontext);
// Validate.
$this->assertEqual(array('settingname' => 'A value'), $filters['filter/name']);
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:11,代码来源:testfilterconfig.php
示例12: configure_tinymce_lib_params
/**
* Method for hooking into the Moodle 2.3 Tinymce plugin lib.php
* file
*
* Moodle 2.4+ uses different logic -- see Binumi plugin
* installation instructions for details.
*
* @param array $filters
* @param array $params
* @return array
*/
public function configure_tinymce_lib_params($filters, $params)
{
if (!function_exists('filter_get_active_in_context')) {
throw new Zend_Exception('This class can only be called ' . 'from within the tinymce/lib.php file');
}
if (!isset($filters)) {
$filters = filter_get_active_in_context($context);
}
if (array_key_exists('filter/binumi', $filters)) {
$params = $params + $this->get_texteditor_params();
$params['plugins'] .= ',binumi';
if (isset($params['theme_advanced_buttons3_add'])) {
$params['theme_advanced_buttons3_add'] .= ",|,binumi";
} else {
$params['theme_advanced_buttons3_add'] = ",|,binumi";
}
}
return $params;
}
开发者ID:Binumi,项目名称:binumi-moodle,代码行数:30,代码来源:binumi_client.class.php
示例13: offlinequiz_print_question_preview
/**
* Prints a preview for a question in an offlinequiz to Stdout.
*
* @param object $question
* @param array $choiceorder
* @param int $number
* @param object $context
*/
function offlinequiz_print_question_preview($question, $choiceorder, $number, $context, $page)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/filter/mathjaxloader/filter.php';
$letterstr = 'abcdefghijklmnopqrstuvwxyz';
echo '<div id="q' . $question->id . '" class="preview">
<div class="question">
<span class="number">';
if ($question->qtype != 'description') {
echo $number . ') ';
}
echo ' </span>';
$text = question_rewrite_question_preview_urls($question->questiontext, $question->id, $question->contextid, 'question', 'questiontext', $question->id, $context->id, 'offlinequiz');
// Remove leading paragraph tags because the cause a line break after the question number.
$text = preg_replace('!^<p>!i', '', $text);
// Filter only for tex formulas.
$texfilter = null;
$mathjaxfilter = null;
$filters = filter_get_active_in_context($context);
if (array_key_exists('mathjaxloader', $filters)) {
$mathjaxfilter = new filter_mathjaxloader($context, array());
$mathjaxfilter->setup($page, $context);
}
if (array_key_exists('tex', $filters)) {
$texfilter = new filter_tex($context, array());
}
if ($mathjaxfilter) {
$text = $mathjaxfilter->filter($text);
if ($question->qtype != 'description') {
foreach ($choiceorder as $key => $answer) {
$question->options->answers[$answer]->answer = $mathjaxfilter->filter($question->options->answers[$answer]->answer);
}
}
} else {
if ($texfilter) {
$text = $texfilter->filter($text);
if ($question->qtype != 'description') {
foreach ($choiceorder as $key => $answer) {
$question->options->answers[$answer]->answer = $texfilter->filter($question->options->answers[$answer]->answer);
}
}
}
}
echo $text;
echo ' </div>';
if ($question->qtype != 'description') {
echo ' <div class="grade">';
echo '(' . get_string('marks', 'quiz') . ': ' . ($question->maxmark + 0) . ')';
echo ' </div>';
foreach ($choiceorder as $key => $answer) {
$answertext = $question->options->answers[$answer]->answer;
// Remove all HTML comments (typically from MS Office).
$answertext = preg_replace("/<!--.*?--\\s*>/ms", "", $answertext);
// Remove all paragraph tags because they mess up the layout.
$answertext = preg_replace("/<p[^>]*>/ms", "", $answertext);
$answertext = preg_replace("/<\\/p[^>]*>/ms", "", $answertext);
echo "<div class=\"answer\">{$letterstr[$key]}) ";
echo $answertext;
echo "</div>";
}
}
echo "</div>";
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:71,代码来源:locallib.php
示例14: get_init_params
protected function get_init_params($elementid, array $options = null)
{
global $CFG, $PAGE;
//TODO: we need to implement user preferences that affec tthe editor setup too
//TODO: reimplement rulesets, maybe it would be better to implement it some other way
//$xmlruleset = file_get_contents('extra/xhtml_ruleset.txt');
$directionality = get_string('thisdirection');
$strtime = get_string('strftimetime');
$strdate = get_string('strftimedaydate');
$lang = str_replace('_utf8', '', current_language());
// use more standard language codes
$contentcss = $CFG->themewww . '/' . current_theme() . '/styles.php';
// should be customizable
$context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
if (!empty($options['legacy'])) {
$xmedia = '';
} else {
if (!empty($options['noclean']) or !empty($options['trusted'])) {
$xmedia = 'media,';
} else {
$xmedia = '';
}
}
$filters = filter_get_active_in_context($context);
if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}
$params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,{$xmedia}searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect,styleselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym", 'theme_advanced_buttons2_add' => "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,emotions,image,{$xmedia}{$xdragmath}advhr,nonbreaking,charmap", 'theme_advanced_buttons3_add' => "|,table,insertlayer,styleprops,visualchars,|,code,preview", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom");
if (empty($options['legacy'])) {
if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
$params['file_browser_callback'] = "mce_moodlefilemanager";
}
}
return $params;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:37,代码来源:lib.php
示例15: get_init_params
protected function get_init_params($elementid, array $options = null)
{
global $CFG, $PAGE, $OUTPUT;
//TODO: we need to implement user preferences that affect the editor setup too
$directionality = get_string('thisdirection', 'langconfig');
$strtime = get_string('strftimetime');
$strdate = get_string('strftimedaydate');
$lang = current_language();
$contentcss = $PAGE->theme->editor_css_url()->out(false);
$context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
$xmedia = 'moodlemedia,';
// HQ thinks it should be always on, so it is no matter if it will actually work or not
/*
if (!empty($options['legacy'])) {
$xmedia = 'moodlemedia,';
} else {
if (!empty($options['noclean']) or !empty($options['trusted'])) {
}
}*/
$filters = filter_get_active_in_context($context);
if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}
if (array_key_exists('filter/emoticon', $filters)) {
$xemoticon = 'moodleemoticon,';
} else {
$xemoticon = '';
}
$params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright", 'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap", 'theme_advanced_buttons3_add' => "table,|,code,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_resizing_min_height' => 30, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", 'spellchecker_rpc_url' => $CFG->wwwroot . "/lib/editor/tinymce/tiny_mce/{$this->version}/plugins/spellchecker/rpc.php", 'spellchecker_languages' => get_config('editor_tinymce', 'spelllanguagelist'));
if ($xemoticon) {
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$imgs = array();
// see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
$index = 0;
foreach ($emoticons as $emoticon) {
$imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
}
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
// but they scream even more when we strip all tags that are not strict :-(
$params['valid_elements'] = 'script[src|type],*[*]';
// for some reason the *[*] does not inlcude javascript src attribute MDL-25836
$params['invalid_elements'] = '';
}
if (empty($options['legacy'])) {
if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
$params['file_browser_callback'] = "M.editor_tinymce.filepicker";
}
}
//Add onblur event for client side text validation
if (!empty($options['required'])) {
$params['init_instance_callback'] = 'M.editor_tinymce.onblur_event';
}
return $params;
}
开发者ID:nickread,项目名称:moodle,代码行数:60,代码来源:lib.php
示例16: save_post
/** save a post using the submitted data
*
* @global type $USER
* @global obejct $DB
* @param type $data
* @return type
*/
public function save_post($data, $course)
{
global $USER, $DB, $CFG;
require_once $CFG->dirroot . '/mod/url/locallib.php';
$context = \context_course::instance($data->id);
// ...save when even a posttext or a externalurl or a file or a actvitiy is given.
$cmsequence = $data->cmsequence;
// ... added activity?
if (!empty($cmsequence)) {
$cmsequence = $this->check_and_move_module($data->id, $cmsequence);
} else {
// ... add a resource.
if (!empty($data->files)) {
$canpostfile = has_capability('format/socialwall:postfile', $context) && !empty($course->enablestudentupload);
if (!$canpostfile) {
print_error('missingcappostfile', 'format_socialwall');
}
$cmsequence = $this->create_mod_files($data);
} else {
// ... check externalurl and create a activity in section 1, if necessary.
if (!empty($data->externalurl)) {
$canposturl = has_capability('format/socialwall:posturl', $context) && !empty($course->enablestudentupload);
if (!$canposturl) {
print_error('missingcapposturl', 'format_socialwall');
}
$cmsequence = $this->create_mod_url($data->externalurl);
// ... set filter Plugin here.
$filters = filter_get_active_in_context($context);
if (isset($filters['urlresource'])) {
require_once $CFG->dirroot . '/filter/urlresource/lib.php';
\filter_url_resource_helper::save_externalurl($data, $cmsequence);
}
}
}
}
if (empty($data->posttext) and empty($cmsequence)) {
print_error('attachmentorpostrequired', 'format_socialwall');
}
// ... create post.
$post = new \stdClass();
$post->courseid = $data->id;
$post->fromuserid = $USER->id;
$post->togroupid = $data->togroupid;
if (is_array($data->posttext)) {
$posttext = $data->posttext['text'];
} else {
$posttext = $data->posttext;
}
if (has_capability('format/socialwall:posthtml', $context)) {
$post->posttext = clean_text($posttext);
} else {
$post->posttext = clean_param($posttext, PARAM_NOTAGS);
}
if (isset($data->poststatus)) {
$post->sticky = $data->poststatus == 1;
$post->private = $data->poststatus == 2;
$post->alert = $data->poststatus == 4;
} else {
$post->sticky = 0;
$post->private = 0;
$post->alert = 0;
}
$post->timecreated = time();
$post->timemodified = $post->timecreated;
$post->id = $DB->insert_record('format_socialwall_posts', $post);
if (!empty($cmsequence)) {
attaches::save_attaches($post->id, $cmsequence);
}
// We use a instant enqueueing, if needed you might use events here.
notification::enqueue_post_created($post);
// ...clear the inputed values.
$cache = \cache::make('format_socialwall', 'postformparams');
$cache->purge();
return array('error' => '0', 'message' => 'postsaved');
}
开发者ID:nadavkav,项目名称:moodle-format_socialwall,代码行数:82,代码来源:posts.php
示例17: filter
function filter($text, array $options = array())
{
global $CFG, $DB, $PAGE;
$texfilterenabled = array_key_exists("tex", filter_get_active_in_context($PAGE->context));
if ($texfilterenabled) {
print_error("disable regular TeX notation filter!");
}
$mathjaxenabled = array_key_exists("mathjaxloader", filter_get_active_in_context($PAGE->context));
/// Do a quick check using stripos to avoid unnecessary work
if (!preg_match('/<tex/i', $text) && strpos($text, '$$') === false && strpos($text, '\\[') === false && strpos($text, '\\(') === false && !preg_match('/\\[tex/i', $text)) {
return $text;
}
$text .= ' ';
preg_match_all('/\\$(\\$\\$+?)([^\\$])/s', $text, $matches);
for ($i = 0; $i < count($matches[0]); $i++) {
$replacement = str_replace('$', '$', $matches[1][$i]) . $matches[2][$i];
$text = str_replace($matches[0][$i], $replacement, $text);
}
// <tex> TeX expression </tex>
// or <tex alt="My alternative text to be used instead of the TeX form"> TeX expression </tex>
// or $$ TeX expression $$
// or \[ TeX expression \] // original tag of MathType and TeXaide (dlnsk)
// or [tex] TeX expression [/tex] // somtime it's more comfortable than <tex> (dlnsk)
$rules = array('<tex(?:\\s+alt=["\'](.*?)["\'])?>(.+?)<\\/tex>', '\\$\\$(.+?)\\$\\$', '\\\\\\[(.+?)\\\\\\]', '\\\\\\((.+?)\\\\\\)', '\\[tex\\](.+?)\\[\\/tex\\]');
if ($mathjaxenabled == true) {
$rules = array('<tex(?:\\s+alt=["\'](.*?)["\'])?>(.+?)<\\/tex>', '\\$\\$(.+?)\\$\\$', '\\[tex\\](.+?)\\[\\/tex\\]');
}
$megarule = '/' . implode($rules, '|') . '/is';
preg_match_all($megarule, $text, $matches);
for ($i = 0; $i < count($matches[0]); $i++) {
$texexp = '';
for ($j = 0; $j < count($rules); $j++) {
$texexp .= $matches[$j + 2][$i];
}
$alt = $matches[1][$i];
$texexp = str_replace('<nolink>', '', $texexp);
$texexp = str_replace('</nolink>', '', $texexp);
$texexp = str_replace('<span class="nolink">', '', $texexp);
$texexp = str_replace('</span>', '', $texexp);
$texexp = preg_replace("/<br[[:space:]]*\\/?>/i", '', $texexp);
//dlnsk
$align = "middle";
if (preg_match('/^align=bottom /', $texexp)) {
$align = "text-bottom";
$texexp = preg_replace('/^align=bottom /', '', $texexp
|
请发表评论