mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-40493 User preference: Allow users to set their preferred text editor.
This changes the setting htmleditor in the user table from a 0 or 1 column to a user preference for the name of their preferred html editor.
This commit is contained in:
parent
0af463d413
commit
3d27180e94
@ -10,10 +10,10 @@ Feature: Forms manipulation
|
||||
And I follow "Admin User"
|
||||
And I follow "Edit profile"
|
||||
When I fill in "First name" with "Field value"
|
||||
And I select "Use standard web forms" from "When editing text"
|
||||
And I select "Plain text area" from "Text editor"
|
||||
And I check "Unmask"
|
||||
Then the "First name" field should match "Field value" value
|
||||
And the "When editing text" select box should contain "Use standard web forms"
|
||||
And the "Text editor" select box should contain "Plain text area"
|
||||
And the "Unmask" checkbox should be checked
|
||||
And I uncheck "Unmask"
|
||||
And the "Unmask" checkbox should not be checked
|
||||
|
@ -237,19 +237,6 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
|
||||
$mform->setDefault('autosubscribe', 1);
|
||||
|
||||
$editors = editors_get_enabled();
|
||||
if (count($editors) > 1) {
|
||||
$choices = array();
|
||||
$choices['0'] = get_string('texteditor');
|
||||
$choices['1'] = get_string('htmleditor');
|
||||
$mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
|
||||
$mform->setDefault('htmleditor', 1);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'htmleditor');
|
||||
$mform->setDefault('htmleditor', 1);
|
||||
$mform->setType('htmleditor', PARAM_INT);
|
||||
}
|
||||
|
||||
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
|
||||
$mform->setType('city', PARAM_TEXT);
|
||||
if (empty($CFG->defaultcity)) {
|
||||
|
@ -1191,7 +1191,7 @@ class backup_users_structure_step extends backup_structure_step {
|
||||
'confirmed', 'policyagreed', 'deleted',
|
||||
'lang', 'theme', 'timezone', 'firstaccess',
|
||||
'lastaccess', 'lastlogin', 'currentlogin',
|
||||
'mailformat', 'maildigest', 'maildisplay', 'htmleditor',
|
||||
'mailformat', 'maildigest', 'maildisplay',
|
||||
'autosubscribe', 'trackforums', 'timecreated',
|
||||
'timemodified', 'trustbitmask');
|
||||
|
||||
|
@ -1180,6 +1180,16 @@ abstract class restore_dbops {
|
||||
$status = $DB->insert_record('user_preferences', $preference);
|
||||
}
|
||||
}
|
||||
// Special handling for htmleditor which was converted to a preference.
|
||||
if (isset($user->htmleditor)) {
|
||||
if ($user->htmleditor == 0) {
|
||||
$preference = new stdClass();
|
||||
$preference->userid = $newuserid;
|
||||
$preference->name = 'htmleditor';
|
||||
$preference->value = 'textarea';
|
||||
$status = $DB->insert_record('user_preferences', $preference);
|
||||
}
|
||||
}
|
||||
|
||||
// Create user files in pool (profile, icon, private) by context
|
||||
restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
|
||||
|
@ -107,21 +107,17 @@ $mform = new edit_grade_form(null, array('grade_item'=>$grade_item, 'gpr'=>$gpr)
|
||||
if ($grade = $DB->get_record('grade_grades', array('itemid' => $grade_item->id, 'userid' => $userid))) {
|
||||
|
||||
// always clean existing feedback - grading should not have XSS risk
|
||||
if (can_use_html_editor()) {
|
||||
if (empty($grade->feedback)) {
|
||||
$grade->feedback = '';
|
||||
} else {
|
||||
$options = new stdClass();
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
$options->noclean = false;
|
||||
$options->para = false;
|
||||
$grade->feedback = format_text($grade->feedback, $grade->feedbackformat, $options);
|
||||
}
|
||||
$grade->feedbackformat = FORMAT_HTML;
|
||||
if (empty($grade->feedback)) {
|
||||
$grade->feedback = '';
|
||||
} else {
|
||||
$grade->feedback = clean_text($grade->feedback, $grade->feedbackformat);
|
||||
$options = new stdClass();
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
$options->noclean = false;
|
||||
$options->para = false;
|
||||
$grade->feedback = format_text($grade->feedback, $grade->feedbackformat, $options);
|
||||
}
|
||||
$grade->feedbackformat = FORMAT_HTML;
|
||||
|
||||
$grade->locked = $grade->locked > 0 ? 1:0;
|
||||
$grade->overridden = $grade->overridden > 0 ? 1:0;
|
||||
|
@ -1102,7 +1102,6 @@ $string['upgradingversion'] = 'Upgrading to new version';
|
||||
$string['upwards'] = 'upwards';
|
||||
$string['useblogassociations'] = 'Enable associations';
|
||||
$string['useexternalyui'] = 'Use online YUI libraries';
|
||||
$string['usehtmleditor'] = 'Use HTML editor';
|
||||
$string['user'] = 'User';
|
||||
$string['userbulk'] = 'Bulk user actions';
|
||||
$string['userlist'] = 'Browse list of users';
|
||||
|
@ -421,6 +421,7 @@ $string['day'] = 'day';
|
||||
$string['days'] = 'days';
|
||||
$string['decodinginternallinks'] = 'Decoding internal links';
|
||||
$string['default'] = 'Default';
|
||||
$string['defaulteditor'] = 'Default editor';
|
||||
$string['defaultcoursestudent'] = 'Student';
|
||||
$string['defaultcoursestudentdescription'] = 'Students generally have fewer privileges within a course.';
|
||||
$string['defaultcoursestudents'] = 'Students';
|
||||
@ -1679,7 +1680,7 @@ $string['targetrole'] = 'Target role';
|
||||
$string['teacheronly'] = 'for the {$a} only';
|
||||
$string['teacherroles'] = '{$a} roles';
|
||||
$string['teachers'] = 'Teachers';
|
||||
$string['textediting'] = 'When editing text';
|
||||
$string['textediting'] = 'Text editor';
|
||||
$string['texteditor'] = 'Use standard web forms';
|
||||
$string['textformat'] = 'Plain text format';
|
||||
$string['thanks'] = 'Thanks';
|
||||
|
@ -3842,8 +3842,7 @@ class admin_setting_special_frontpagedesc extends admin_setting {
|
||||
public function output_html($data, $query='') {
|
||||
global $CFG;
|
||||
|
||||
$CFG->adminusehtmleditor = can_use_html_editor();
|
||||
$return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary') .'</div>';
|
||||
$return = '<div class="form-htmlarea">'.print_textarea(true, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary') .'</div>';
|
||||
|
||||
return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query);
|
||||
}
|
||||
|
3
lib/db/install.xml
Normal file → Executable file
3
lib/db/install.xml
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20130927" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20131001" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -786,7 +786,6 @@
|
||||
<FIELD NAME="mailformat" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
|
||||
<FIELD NAME="maildigest" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="maildisplay" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="2" SEQUENCE="false"/>
|
||||
<FIELD NAME="htmleditor" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
|
||||
<FIELD NAME="autosubscribe" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
|
||||
<FIELD NAME="trackforums" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
|
@ -2579,5 +2579,23 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2013092700.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2013100100.00) {
|
||||
$sql = "INSERT INTO {user_preferences}(userid, name, value)
|
||||
SELECT id, 'htmleditor', 'textarea' FROM {user} u where u.htmleditor = 0";
|
||||
$DB->execute($sql);
|
||||
|
||||
// Define field htmleditor to be dropped from user
|
||||
$table = new xmldb_table('user');
|
||||
$field = new xmldb_field('htmleditor');
|
||||
|
||||
// Conditionally launch drop field requested
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2013100100.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1483,7 +1483,7 @@ function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=fa
|
||||
* When using this function, you should
|
||||
*
|
||||
* @global object
|
||||
* @param bool $usehtmleditor Enables the use of the htmleditor for this field.
|
||||
* @param bool $unused No longer used.
|
||||
* @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
|
||||
* @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
|
||||
* @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
|
||||
@ -1495,7 +1495,7 @@ function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=fa
|
||||
* @param string $id CSS ID to add to the textarea element.
|
||||
* @return string|void depending on the value of $return
|
||||
*/
|
||||
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
|
||||
function print_textarea($unused, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
|
||||
/// $width and height are legacy fields and no longer used as pixels like they used to be.
|
||||
/// However, you can set them to zero to override the mincols and minrows values below.
|
||||
|
||||
@ -1512,29 +1512,19 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
|
||||
$id = 'edit-'.$name;
|
||||
}
|
||||
|
||||
if ($usehtmleditor) {
|
||||
if ($height && ($rows < $minrows)) {
|
||||
$rows = $minrows;
|
||||
}
|
||||
if ($width && ($cols < $mincols)) {
|
||||
$cols = $mincols;
|
||||
}
|
||||
if ($height && ($rows < $minrows)) {
|
||||
$rows = $minrows;
|
||||
}
|
||||
if ($width && ($cols < $mincols)) {
|
||||
$cols = $mincols;
|
||||
}
|
||||
|
||||
if ($usehtmleditor) {
|
||||
editors_head_setup();
|
||||
$editor = editors_get_preferred_editor(FORMAT_HTML);
|
||||
$editor->use_editor($id, array('legacy'=>true));
|
||||
} else {
|
||||
$editorclass = '';
|
||||
}
|
||||
editors_head_setup();
|
||||
$editor = editors_get_preferred_editor(FORMAT_HTML);
|
||||
$editor->use_editor($id, array('legacy'=>true));
|
||||
|
||||
$str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'" spellcheck="true">'."\n";
|
||||
if ($usehtmleditor) {
|
||||
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
|
||||
} else {
|
||||
$str .= s($value);
|
||||
}
|
||||
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
|
||||
$str .= '</textarea>'."\n";
|
||||
|
||||
if ($return) {
|
||||
@ -4692,3 +4682,15 @@ function badges_get_issued_badge_info($hash) {
|
||||
$assertion = new core_badges_assertion($hash);
|
||||
return $assertion->get_badge_assertion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the user want and can edit using rich text html editor?
|
||||
* This function does not make sense anymore because a user can directly choose their preferred editor.
|
||||
*
|
||||
* @deprecated since 2.6
|
||||
* @return bool
|
||||
*/
|
||||
function can_use_html_editor() {
|
||||
debugging('can_use_html_editor has been deprecated please update your code to assume it returns true.', DEBUG_DEVELOPER);
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,14 @@ function editors_get_preferred_editor($format = NULL) {
|
||||
|
||||
$enabled = editors_get_enabled();
|
||||
|
||||
$preventhtml = (count($enabled) > 1 and empty($USER->htmleditor));
|
||||
$preference = get_user_preferences('htmleditor', '', $USER);
|
||||
|
||||
if (isset($enabled[$preference])) {
|
||||
// Edit the list of editors so the users preferred editor is first in the list.
|
||||
$editor = $enabled[$preference];
|
||||
unset($enabled[$preference]);
|
||||
array_unshift($enabled, $editor);
|
||||
}
|
||||
|
||||
// now find some plugin that supports format and is available
|
||||
$editor = false;
|
||||
@ -46,27 +53,11 @@ function editors_get_preferred_editor($format = NULL) {
|
||||
// bad luck, this editor is not compatible
|
||||
continue;
|
||||
}
|
||||
if ($preventhtml and $format == FORMAT_HTML and $e->get_preferred_format() == FORMAT_HTML) {
|
||||
// this is really not what we want but we could use it if nothing better found
|
||||
$editor = $e;
|
||||
continue;
|
||||
}
|
||||
if (!$supports = $e->get_supported_formats()) {
|
||||
// buggy editor!
|
||||
continue;
|
||||
}
|
||||
if (is_null($format)) {
|
||||
// format does not matter
|
||||
if ($preventhtml and $e->get_preferred_format() == FORMAT_HTML) {
|
||||
// this is really not what we want but we could use it if nothing better found
|
||||
$editor = $e;
|
||||
continue;
|
||||
} else {
|
||||
$editor = $e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_array($format, $supports)) {
|
||||
if (is_null($format) || in_array($format, $supports)) {
|
||||
// editor supports this format, yay!
|
||||
$editor = $e;
|
||||
break;
|
||||
@ -87,22 +78,7 @@ function editors_get_preferred_editor($format = NULL) {
|
||||
function editors_get_preferred_format() {
|
||||
global $USER;
|
||||
|
||||
$editors = editors_get_enabled();
|
||||
if (count($editors) == 1) {
|
||||
$editor = reset($editors);
|
||||
return $editor->get_preferred_format();
|
||||
}
|
||||
|
||||
foreach ($editors as $editor) {
|
||||
if (empty($USER->htmleditor) and $editor->get_preferred_format() == FORMAT_HTML) {
|
||||
// we do not prefer this one
|
||||
continue;
|
||||
}
|
||||
return $editor->get_preferred_format();
|
||||
}
|
||||
|
||||
// user did not want html editor, but there is no other choice, sorry
|
||||
$editor = reset($editors);
|
||||
$editor = editors_get_preferred_editor();
|
||||
return $editor->get_preferred_format();
|
||||
}
|
||||
|
||||
@ -172,7 +148,7 @@ function editors_head_setup() {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->texteditors)) {
|
||||
$CFG->texteditors = 'tinymce,textarea';
|
||||
$CFG->texteditors = 'tinymce,atto,textarea';
|
||||
}
|
||||
$active = explode(',', $CFG->texteditors);
|
||||
|
||||
@ -236,29 +212,3 @@ abstract class texteditor {
|
||||
public function head_setup() {
|
||||
}
|
||||
}
|
||||
|
||||
//=== TO BE DEPRECATED in 2.1 =====================
|
||||
|
||||
/**
|
||||
* Does the user want and can edit using rich text html editor?
|
||||
* @todo Deprecate: eradicate completely, replace with something else in the future
|
||||
* @return bool
|
||||
*/
|
||||
function can_use_html_editor() {
|
||||
global $USER;
|
||||
|
||||
$editors = editors_get_enabled();
|
||||
if (count($editors) > 1) {
|
||||
if (empty($USER->htmleditor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($editors as $editor) {
|
||||
if ($editor->get_preferred_format() == FORMAT_HTML) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -42,11 +42,8 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
|
||||
/** @var string defines the type of editor */
|
||||
var $_type;
|
||||
|
||||
/** @var bool Does the user want and can edit using rich text html editor */
|
||||
var $_canUseHtmlEditor;
|
||||
|
||||
/** @var array default options for html editor, which can be overridden */
|
||||
var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>45, 'width'=>0,'height'=>0);
|
||||
var $_options=array('rows'=>10, 'cols'=>45, 'width'=>0,'height'=>0);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -71,16 +68,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_options['canUseHtmlEditor']=='detect'){
|
||||
$this->_options['canUseHtmlEditor']=can_use_html_editor();
|
||||
}
|
||||
if ($this->_options['canUseHtmlEditor']){
|
||||
$this->_type='htmleditor';
|
||||
//$this->_elementTemplateType='wide';
|
||||
}else{
|
||||
$this->_type='textarea';
|
||||
}
|
||||
$this->_canUseHtmlEditor = $this->_options['canUseHtmlEditor'];
|
||||
$this->_type='htmleditor';
|
||||
|
||||
editors_head_setup();
|
||||
}
|
||||
@ -91,16 +79,11 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
|
||||
* @return string
|
||||
*/
|
||||
function toHtml(){
|
||||
//if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
|
||||
// $script = '';
|
||||
//} else {
|
||||
// $script='';
|
||||
//}
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
} else {
|
||||
return $this->_getTabs() .
|
||||
print_textarea($this->_canUseHtmlEditor,
|
||||
print_textarea(true,
|
||||
$this->_options['rows'],
|
||||
$this->_options['cols'],
|
||||
$this->_options['width'],
|
||||
|
60
lib/tests/editorlib_test.php
Normal file
60
lib/tests/editorlib_test.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Tests editors subsystem.
|
||||
*
|
||||
* @package core_editors
|
||||
* @subpackage phpunit
|
||||
* @copyright 2013 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @author Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
class core_editorslib_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Tests the installation of event handlers from file
|
||||
*/
|
||||
public function test_get_preferred_editor() {
|
||||
|
||||
// Fake a user agent.
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.21 5 Safari/534.10';
|
||||
|
||||
$enabled = editors_get_enabled();
|
||||
// Array assignment is always a clone.
|
||||
$editors = $enabled;
|
||||
|
||||
$first = array_shift($enabled);
|
||||
|
||||
// Get the default editor which should be the first in the list.
|
||||
set_user_preference('htmleditor', '');
|
||||
$preferred = editors_get_preferred_editor();
|
||||
$this->assertEquals($first, $preferred);
|
||||
|
||||
foreach ($editors as $key => $editor) {
|
||||
// User has set a preference for a specific editor.
|
||||
set_user_preference('htmleditor', $key);
|
||||
$preferred = editors_get_preferred_editor();
|
||||
$this->assertEquals($editor, $preferred);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,8 +68,6 @@ class assignment_base {
|
||||
var $strlastmodified;
|
||||
/** @var string */
|
||||
var $pagetitle;
|
||||
/** @var bool */
|
||||
var $usehtmleditor;
|
||||
/**
|
||||
* @todo document this var
|
||||
*/
|
||||
|
@ -281,15 +281,9 @@ class assignment_online extends assignment_base {
|
||||
|
||||
function preprocess_submission(&$submission) {
|
||||
if ($this->assignment->var1 && empty($submission->submissioncomment)) { // comment inline
|
||||
if ($this->usehtmleditor) {
|
||||
// Convert to html, clean & copy student data to teacher
|
||||
$submission->submissioncomment = format_text($submission->data1, $submission->data2);
|
||||
$submission->format = FORMAT_HTML;
|
||||
} else {
|
||||
// Copy student data to teacher
|
||||
$submission->submissioncomment = $submission->data1;
|
||||
$submission->format = $submission->data2;
|
||||
}
|
||||
// Convert to html, clean & copy student data to teacher
|
||||
$submission->submissioncomment = format_text($submission->data1, $submission->data2);
|
||||
$submission->format = FORMAT_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,7 @@ class data_field_textarea extends data_field_base {
|
||||
$text = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_data', 'content', $content->id, $options, $text);
|
||||
} else {
|
||||
$draftitemid = file_get_unused_draft_itemid();
|
||||
if (can_use_html_editor()) {
|
||||
$format = FORMAT_HTML;
|
||||
} else {
|
||||
$format = FORMAT_PLAIN;
|
||||
}
|
||||
$format = FORMAT_HTML;
|
||||
}
|
||||
|
||||
// get filepicker info
|
||||
|
@ -192,7 +192,7 @@ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo '<table cellpadding="4" cellspacing="0" border="0">';
|
||||
|
||||
/// Add the HTML editor(s).
|
||||
$usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate') && !$disableeditor;
|
||||
$usehtmleditor = ($mode != 'csstemplate') && ($mode != 'jstemplate') && !$disableeditor;
|
||||
if ($mode == 'listtemplate'){
|
||||
// Print the list template header.
|
||||
echo '<tr>';
|
||||
@ -275,15 +275,13 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') {
|
||||
|
||||
echo '</select>';
|
||||
echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />';
|
||||
if (can_use_html_editor()) {
|
||||
echo '<br /><br />';
|
||||
if ($usehtmleditor) {
|
||||
$switcheditor = get_string('editordisable', 'data');
|
||||
echo '<input type="submit" name="switcheditor" value="'.s($switcheditor).'" />';
|
||||
} else {
|
||||
$switcheditor = get_string('editorenable', 'data');
|
||||
echo '<input type="submit" name="useeditor" value="'.s($switcheditor).'" />';
|
||||
}
|
||||
echo '<br /><br />';
|
||||
if ($usehtmleditor) {
|
||||
$switcheditor = get_string('editordisable', 'data');
|
||||
echo '<input type="submit" name="switcheditor" value="'.s($switcheditor).'" />';
|
||||
} else {
|
||||
$switcheditor = get_string('editorenable', 'data');
|
||||
echo '<input type="submit" name="useeditor" value="'.s($switcheditor).'" />';
|
||||
}
|
||||
} else {
|
||||
echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />';
|
||||
|
@ -48,7 +48,6 @@ if ($id !== false) {
|
||||
$PAGE->set_url($url);
|
||||
|
||||
// set up some general variables
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
|
@ -268,7 +268,6 @@ if (!$students) {
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
||||
}
|
||||
if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
echo '<div class="buttons"><br />';
|
||||
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
|
||||
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
|
||||
@ -279,14 +278,9 @@ if (!$students) {
|
||||
echo '<label for="feedback_subject">'.get_string('subject', 'feedback').' </label>';
|
||||
echo '<input type="text" id="feedback_subject" size="50" maxlength="255" name="subject" value="'.$subject.'" />';
|
||||
echo '</div>';
|
||||
print_textarea($usehtmleditor, 15, 25, 30, 10, "message", $message);
|
||||
if ($usehtmleditor) {
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
} else {
|
||||
echo '<label for="menuformat" class="accesshide">'. get_string('format') .'</label>';
|
||||
choose_from_menu(format_text_menu(), "format", $format, "");
|
||||
}
|
||||
print_textarea(true, 15, 25, 30, 10, "message", $message);
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
echo '<br /><div class="buttons">';
|
||||
echo '<input type="submit" name="send_message" value="'.get_string('send', 'feedback').'" />';
|
||||
echo '</div>';
|
||||
|
@ -393,7 +393,6 @@ class quiz_grading_report extends quiz_default_report {
|
||||
}
|
||||
|
||||
// Display the form with one section for each attempt.
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
$sesskey = sesskey();
|
||||
$qubaidlist = implode(',', $qubaids);
|
||||
echo html_writer::start_tag('form', array('method' => 'post',
|
||||
|
14
tag/edit.php
14
tag/edit.php
@ -60,15 +60,13 @@ $tagname = tag_display_name($tag);
|
||||
// set the relatedtags field of the $tag object that will be passed to the form
|
||||
$tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
|
||||
|
||||
if (can_use_html_editor()) {
|
||||
$options = new stdClass();
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
$options = new stdClass();
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
|
||||
// convert and remove any XSS
|
||||
$tag->description = format_text($tag->description, $tag->descriptionformat, $options);
|
||||
$tag->descriptionformat = FORMAT_HTML;
|
||||
}
|
||||
// convert and remove any XSS
|
||||
$tag->description = format_text($tag->description, $tag->descriptionformat, $options);
|
||||
$tag->descriptionformat = FORMAT_HTML;
|
||||
|
||||
$errorstring = '';
|
||||
|
||||
|
@ -226,15 +226,21 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
|
||||
|
||||
$editors = editors_get_enabled();
|
||||
if (count($editors) > 1) {
|
||||
$choices = array();
|
||||
$choices['0'] = get_string('texteditor');
|
||||
$choices['1'] = get_string('htmleditor');
|
||||
$mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
|
||||
$mform->setDefault('htmleditor', 1);
|
||||
$choices = array('' => get_string('defaulteditor'));
|
||||
$firsteditor = '';
|
||||
foreach (array_keys($editors) as $editor) {
|
||||
if (!$firsteditor) {
|
||||
$firsteditor = $editor;
|
||||
}
|
||||
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
|
||||
}
|
||||
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
|
||||
$mform->setDefault('preference_htmleditor', '');
|
||||
} else {
|
||||
$mform->addElement('hidden', 'htmleditor');
|
||||
$mform->setDefault('htmleditor', 1);
|
||||
$mform->setType('htmleditor', PARAM_INT);
|
||||
// Empty string means use the first chosen text editor.
|
||||
$mform->addElement('hidden', 'preference_htmleditor');
|
||||
$mform->setDefault('preference_htmleditor', '');
|
||||
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
|
||||
}
|
||||
|
||||
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
|
||||
|
@ -10,7 +10,7 @@
|
||||
<?php print_string("messagebody"); ?>:
|
||||
</b></td>
|
||||
<td align="left" rowspan="2">
|
||||
<?php print_textarea($usehtmleditor, 25, 65, 630, 400, "messagebody", $messagebody); ?>
|
||||
<?php print_textarea(true, 25, 65, 630, 400, "messagebody", $messagebody); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -18,12 +18,8 @@
|
||||
<td align="right"><label for="menuformat"><b><?php print_string("formattexttype"); ?>:</b></label></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($usehtmleditor) { /// Trying this out for a while
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
} else {
|
||||
choose_from_menu(format_text_menu(), "format", $format, "");
|
||||
}
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -174,7 +174,6 @@ if ((!empty($send) || !empty($preview) || !empty($edit)) && (empty($messagebody)
|
||||
|
||||
if (count($SESSION->emailto[$id])) {
|
||||
require_sesskey();
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
require("message.html");
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013092700.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2013100100.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user