mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
mod-data MDL-19806 Converted remaining print_textarea's to 2.0 editors.
This commit is contained in:
parent
f81a82477d
commit
4e03354235
@ -21,44 +21,61 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once($CFG->dirroot.'/lib/filelib.php');
|
||||
require_once($CFG->dirroot.'/repository/lib.php');
|
||||
|
||||
class data_field_textarea extends data_field_base {
|
||||
|
||||
var $type = 'textarea';
|
||||
|
||||
function display_add_field($recordid=0) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB, $OUTPUT, $PAGE;
|
||||
|
||||
$text = '';
|
||||
$format = 0;
|
||||
|
||||
if ($recordid){
|
||||
if ($content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) {
|
||||
$text = $content->content;
|
||||
$format = $content->content1;
|
||||
}
|
||||
}
|
||||
|
||||
$str = '<div title="'.$this->field->description.'">';
|
||||
|
||||
if (can_use_html_editor()) {
|
||||
// Show a rich text html editor.
|
||||
$str .= $this->gen_textarea(true, $text);
|
||||
$str .= $OUTPUT->help_icon(moodle_help_icon::make("richtext2", get_string("helprichtext"), 'moodle', true));
|
||||
$str .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
|
||||
editors_head_setup();
|
||||
|
||||
$options = array();
|
||||
$options['trusttext'] = false;
|
||||
$options['forcehttps'] = false;
|
||||
$options['subdirs'] = false;
|
||||
$options['maxfiles'] = 0;
|
||||
$options['maxbytes'] = 0;
|
||||
$options['changeformat'] = 0;
|
||||
$options['noclean'] = false;
|
||||
|
||||
$itemid = $this->field->id;
|
||||
$field = 'field_'.$itemid;
|
||||
|
||||
if ($recordid && $content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))){
|
||||
$text = $content->content;
|
||||
$format = $content->content1;
|
||||
} else if (can_use_html_editor()) {
|
||||
$format = FORMAT_HTML;
|
||||
} else {
|
||||
// Show a normal textarea. Also let the user specify the format to be used.
|
||||
$str .= $this->gen_textarea(false, $text);
|
||||
|
||||
// Get the available text formats for this field.
|
||||
$formatsForField = format_text_menu();
|
||||
$str .= '<br />';
|
||||
$select = html_select( $formatsForField, 'field_' . $this->field->id . '_content1', $format);
|
||||
$select->nothingvalue = '';
|
||||
$str .= $OUTPUT->select($select);
|
||||
|
||||
$str .= $OUTPUT->help_icon(moodle_help_icon::make('textformat', get_string('helpformatting'), 'moodle'));
|
||||
$format = FORMAT_PLAIN;
|
||||
}
|
||||
|
||||
$editor = get_preferred_texteditor($format);
|
||||
$strformats = format_text_menu();
|
||||
$formats = $editor->get_supported_formats();
|
||||
foreach ($formats as $fid) {
|
||||
$formats[$fid] = $strformats[$fid];
|
||||
}
|
||||
$editor->use_editor($field, $options);
|
||||
$str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="15" cols="80">'.s($text).'</textarea></div>';
|
||||
$str .= '<div><select name="'.$field.'_content1">';
|
||||
foreach ($formats as $key=>$desc) {
|
||||
$selected = ($format == $key) ? 'selected="selected"' : '';
|
||||
$str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
|
||||
}
|
||||
$str .= '</select>';
|
||||
$str .= $OUTPUT->help_icon(moodle_help_icon::make('textformat', get_string('helpformatting'), 'moodle'));
|
||||
$str .= '</div>';
|
||||
|
||||
$str .= '</div>';
|
||||
return $str;
|
||||
}
|
||||
@ -83,12 +100,6 @@ class data_field_textarea extends data_field_base {
|
||||
return array(" ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content $ILIKE :$name) ", array($name=>"%$value%"));
|
||||
}
|
||||
|
||||
function gen_textarea($usehtmleditor, $text='') {
|
||||
return print_textarea($usehtmleditor, $this->field->param3, $this->field->param2,
|
||||
'', '', 'field_'.$this->field->id, $text, '', true, 'field_' . $this->field->id);
|
||||
}
|
||||
|
||||
|
||||
function print_after_form() {
|
||||
}
|
||||
|
||||
|
@ -39,3 +39,4 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="param4" id="param4" value="<?php echo FORMAT_HTML; ?>" />
|
||||
|
@ -151,6 +151,22 @@ if (empty($data->addtemplate) and empty($data->singletemplate) and
|
||||
data_generate_default_template($data, 'rsstemplate');
|
||||
}
|
||||
|
||||
editors_head_setup();
|
||||
$format = FORMAT_HTML;
|
||||
$editor = get_preferred_texteditor($format);
|
||||
$strformats = format_text_menu();
|
||||
$formats = $editor->get_supported_formats();
|
||||
foreach ($formats as $fid) {
|
||||
$formats[$fid] = $strformats[$fid];
|
||||
}
|
||||
$options = array();
|
||||
$options['trusttext'] = false;
|
||||
$options['forcehttps'] = false;
|
||||
$options['subdirs'] = false;
|
||||
$options['maxfiles'] = 0;
|
||||
$options['maxbytes'] = 0;
|
||||
$options['changeformat'] = 0;
|
||||
$options['noclean'] = false;
|
||||
|
||||
echo '<form id="tempform" action="templates.php?d='.$data->id.'&mode='.$mode.'" method="post">';
|
||||
echo '<div>';
|
||||
@ -172,7 +188,11 @@ if ($mode == 'listtemplate'){
|
||||
echo '<td> </td>';
|
||||
echo '<td>';
|
||||
echo '<div style="text-align:center"><label for="edit-listtemplateheader">'.get_string('header','data').'</label></div>';
|
||||
print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplateheader', $data->listtemplateheader);
|
||||
|
||||
$field = 'listtemplateheader';
|
||||
$editor->use_editor($field, $options);
|
||||
echo '<div><textarea id="'.$field.'" name="'.$field.'" rows="15" cols="80">'.s($data->listtemplateheader).'</textarea></div>';
|
||||
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
@ -263,7 +283,9 @@ if ($mode == 'listtemplate'){
|
||||
echo '<div style="text-align:center"><label for="edit-template">'.get_string($mode,'data').'</label></div>';
|
||||
}
|
||||
|
||||
print_textarea($usehtmleditor, 20, 72, 0, 0, 'template', $data->{$mode});
|
||||
$field = 'template';
|
||||
$editor->use_editor($field, $options);
|
||||
echo '<div><textarea id="'.$field.'" name="'.$field.'" rows="15" cols="80">'.s($data->{$mode}).'</textarea></div>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
@ -272,7 +294,10 @@ if ($mode == 'listtemplate'){
|
||||
echo '<td> </td>';
|
||||
echo '<td>';
|
||||
echo '<div style="text-align:center"><label for="edit-listtemplatefooter">'.get_string('footer','data').'</label></div>';
|
||||
print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplatefooter', $data->listtemplatefooter);
|
||||
|
||||
$field = 'listtemplatefooter';
|
||||
$editor->use_editor($field, $options);
|
||||
echo '<div><textarea id="'.$field.'" name="'.$field.'" rows="15" cols="80">'.s($data->listtemplatefooter).'</textarea></div>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
} else if ($mode == 'rsstemplate') {
|
||||
@ -280,7 +305,10 @@ if ($mode == 'listtemplate'){
|
||||
echo '<td> </td>';
|
||||
echo '<td>';
|
||||
echo '<div style="text-align:center"><label for="edit-rsstitletemplate">'.get_string('rsstitletemplate','data').'</label></div>';
|
||||
print_textarea($usehtmleditor, 10, 72, 0, 0, 'rsstitletemplate', $data->rsstitletemplate);
|
||||
|
||||
$field = 'rsstitletemplate';
|
||||
$editor->use_editor($field, $options);
|
||||
echo '<div><textarea id="'.$field.'" name="'.$field.'" rows="15" cols="80">'.s($data->rsstitletemplate).'</textarea></div>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user