MDL-18910 full support for module intro editor with embedded images

This commit is contained in:
skodak 2009-04-22 04:46:04 +00:00
parent 50aa3fcc8b
commit 4ba2221a09
8 changed files with 29 additions and 54 deletions

View File

@ -153,9 +153,6 @@
/// First, let's process the general forums and build up a display
$introoptions = new object();
$introoptions->para = false;
if ($generalforums) {
foreach ($generalforums as $forum) {
$cm = $modinfo->instances['forum'][$forum->id];
@ -193,7 +190,7 @@
}
}
$forum->intro = shorten_text(trim(format_text($forum->intro, $forum->introformat, $introoptions)), $CFG->forum_shortpost);
$forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
$forumname = format_string($forum->name, true);;
if ($cm->visible) {
@ -315,8 +312,7 @@
}
}
$introoptions->para=false;
$forum->intro = shorten_text(trim(format_text($forum->intro, $forum->introformat, $introoptions)), $CFG->forum_shortpost);
$forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
if ($cm->sectionnum != $currentsection) {
$printsection = $cm->sectionnum;

View File

@ -27,12 +27,7 @@ class mod_forum_mod_form extends moodleform_mod {
$mform->setHelpButton('type', array('forumtype', get_string('forumtype', 'forum'), 'forum'));
$mform->setDefault('type', 'general');
$mform->addElement('htmleditor', 'intro', get_string('forumintro', 'forum'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
$mform->addElement('format', 'introformat', get_string('format'));
$this->add_intro_editor(true, get_string('forumintro', 'forum'));
$options = array();
$options[0] = get_string('no');
@ -148,7 +143,7 @@ class mod_forum_mod_form extends moodleform_mod {
}
function definition_after_data(){
function definition_after_data() {
parent::definition_after_data();
$mform =& $this->_form;
$type =& $mform->getElement('type');
@ -156,13 +151,13 @@ class mod_forum_mod_form extends moodleform_mod {
//we don't want to have these appear as possible selections in the form but
//we want the form to display them if they are set.
if ($typevalue[0]=='news'){
if ($typevalue[0]=='news') {
$type->addOption(get_string('namenews', 'forum'), 'news');
$type->setHelpButton(array('forumtypenews', get_string('forumtype', 'forum'), 'forum'));
$type->freeze();
$type->setPersistantFreeze(true);
}
if ($typevalue[0]=='social'){
if ($typevalue[0]=='social') {
$type->addOption(get_string('namesocial', 'forum'), 'social');
$type->freeze();
$type->setPersistantFreeze(true);
@ -170,12 +165,12 @@ class mod_forum_mod_form extends moodleform_mod {
}
function data_preprocessing(&$default_values){
if (empty($default_values['scale'])){
function data_preprocessing(&$default_values) {
if (empty($default_values['scale'])) {
$default_values['assessed'] = 0;
}
if (empty($default_values['assessed'])){
if (empty($default_values['assessed'])) {
$default_values['ratingtime'] = 0;
} else {
$default_values['ratingtime']=
@ -187,17 +182,17 @@ class mod_forum_mod_form extends moodleform_mod {
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completiondiscussionsenabled']=
!empty($default_values['completiondiscussions']) ? 1 : 0;
if(empty($default_values['completiondiscussions'])) {
if (empty($default_values['completiondiscussions'])) {
$default_values['completiondiscussions']=1;
}
$default_values['completionrepliesenabled']=
!empty($default_values['completionreplies']) ? 1 : 0;
if(empty($default_values['completionreplies'])) {
if (empty($default_values['completionreplies'])) {
$default_values['completionreplies']=1;
}
$default_values['completionpostsenabled']=
!empty($default_values['completionposts']) ? 1 : 0;
if(empty($default_values['completionposts'])) {
if (empty($default_values['completionposts'])) {
$default_values['completionposts']=1;
}
}
@ -239,20 +234,20 @@ class mod_forum_mod_form extends moodleform_mod {
}
function get_data() {
$data=parent::get_data();
if(!$data) {
$data = parent::get_data();
if (!$data) {
return false;
}
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion=!empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if(empty($data->completiondiscussionsenabled) || !$autocompletion) {
$data->completiondiscussions=0;
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
$data->completiondiscussions = 0;
}
if(empty($data->completionrepliesenabled) || !$autocompletion) {
$data->completionreplies=0;
if (empty($data->completionrepliesenabled) || !$autocompletion) {
$data->completionreplies = 0;
}
if(empty($data->completionpostsenabled) || !$autocompletion) {
$data->completionposts=0;
if (empty($data->completionpostsenabled) || !$autocompletion) {
$data->completionposts = 0;
}
return $data;
}

View File

@ -802,10 +802,8 @@
}
}
} else {
$forum->intro = trim($forum->intro);
if (!empty($forum->intro)) {
$options = (object)array('noclean'=>true);
print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
print_box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
}
}

View File

@ -122,7 +122,7 @@
//First all rss feeds common headers
$header = rss_standard_header(strip_tags(format_string($forum->name,true)),
$CFG->wwwroot."/mod/forum/view.php?f=".$forum->id,
format_string($forum->intro,true));
format_string($forum->intro,true)); // TODO: fix format
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);

View File

@ -203,8 +203,6 @@
notify(get_string('qandanotify','forum'));
}
$forum->intro = trim($forum->intro);
switch ($forum->type) {
case 'single':
if (! $discussion = $DB->get_record("forum_discussions", array("forum" => $forum->id))) {
@ -232,10 +230,7 @@
case 'eachuser':
if (!empty($forum->intro)) {
$options = new stdclass;
$options->para = false;
$options->noclean = true;
print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
print_box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
}
echo '<p class="mdl-align">';
if (forum_user_can_post_discussion($forum, null, -1, $cm)) {
@ -261,10 +256,7 @@
default:
if (!empty($forum->intro)) {
$options = new stdclass;
$options->para = false;
$options->noclean = true;
print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
print_box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
}
echo '<br />';
if (!empty($showall)) {

View File

@ -19,10 +19,7 @@ class mod_glossary_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'intro', get_string('description'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('intro', array('writing', 'questions', 'text2'), false, 'editorhelpbutton');
$this->add_intro_editor(true);
$mform->addElement('text', 'entbypage', get_string('entbypage', 'glossary'));
$mform->setDefault('entbypage', 10);

View File

@ -108,7 +108,7 @@
//First all rss feeds common headers
$header = rss_standard_header(format_string($glossary->name,true),
$CFG->wwwroot."/mod/glossary/view.php?g=".$glossary->id,
format_string($glossary->intro,true));
format_string($glossary->intro,true)); //TODO: fix format
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);

View File

@ -322,11 +322,8 @@
}
/// Info box
if ( $glossary->intro && $showcommonelements ) {
$options = new stdclass;
$options->para = false;
$options->noclean = true;
print_box(format_text($glossary->intro, $glossary->introformat, $options), 'generalbox', 'intro');
if ($glossary->intro && $showcommonelements) {
print_box(format_module_intro('glossary', $glossary, $cm->id), 'generalbox', 'intro');
}
/// Search box