* @return text
*/
function format_module_intro($module, $activity, $cmid) {
- $options = (object)array('noclean'=>true);
+ global $CFG;
+ require_once("$CFG->libdir/filelib.php");
+ $options = (object)array('noclean'=>true, 'para'=>false);
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$intro = file_rewrite_pluginfile_urls($activity->intro, 'pluginfile.php', $context->id, $module.'_intro', 0);
- return format_text($intro, $activity->introformat, $options);
+ return trim(format_text($intro, $activity->introformat, $options));
}
/**
}
$currentsection = "";
- $options->para = false;
- $options->noclean = true;
foreach ($resources as $resource) {
if ($course->format == "weeks" or $course->format == "topics") {
$printsection = "";
if (!$resource->visible) { // Show dimmed if the mod is hidden
$table->data[] = array ($printsection,
"<a class=\"dimmed\" $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
- format_text($resource->intro, $resource->introformat, $options) );
+ format_module_intro('resource', $resource, $resource->coursemodule));
} else { //Show normal if the mod is visible
$table->data[] = array ($printsection,
"<a $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
- format_text($resource->intro, $resource->introformat, $options) );
+ format_module_intro('resource', $resource, $resource->coursemodule));
}
}
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
-// $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
-
$mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
}
$mform->addRule('name', null, 'required', null, 'client');
- $mform->addElement('htmleditor', 'intro', get_string('summary'));
- $mform->setType('intro', PARAM_RAW);
- $mform->setHelpButton('intro', array('summary', get_string('summary'), 'resource'));
- // summary should be optional again MDL-9485
- //$mform->addRule('summary', get_string('required'), 'required', null, 'client');
+ $this->add_intro_editor(false);
$mform->addElement('header', 'typedesc', resource_get_name($type));
$this->_resinstance->setup_elements($mform);
$subdir = optional_param('subdir','', PARAM_PATH);
$resource->reference = clean_param($resource->reference, PARAM_PATH);
- $formatoptions = new object();
- $formatoptions->noclean = true;
- $formatoptions->para = false; // MDL-12061, <p> in html editor breaks xhtml strict
-
add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
if ($resource->reference) {
if (trim(strip_tags($resource->intro))) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
print_spacer(10,10);
}
$mimetype = mimeinfo("type", $resource->reference);
$pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));
- $formatoptions = new object();
- $formatoptions->noclean = true;
-
if ($resource->options != "forcedownload") { // TODO nicolasconnault 14-03-07: This option should be renamed "embed"
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
$resourcetype = "image";
echo '</script>';
if (trim(strip_tags($resource->intro))) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
$link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" "
///print the intro
if (!empty($resource->intro)) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
echo "</body></html>";
exit;
print_header($pagetitle, $course->fullname, $navigation,
"", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
- $options = new object();
- $options->para = false;
- $options->noclean = true;
- echo '<div class="summary">'.format_text($resource->intro, $resource->introformat, $options).'</div>';
+ echo '<div class="summary">'.format_module_intro('resource', $resource, $cm->id).'</div>';
if (!empty($localpath)) { // Show some help
echo '<div class="mdl-right helplink">';
link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'),
}
if (trim($resource->intro)) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
if ($inpopup) {
echo '</script>';
if (trim(strip_tags($resource->intro))) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
$link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
$mimetype = mimeinfo("type", $resource->reference);
$pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));
- $formatoptions = new object();
- $formatoptions->noclean = true;
-
/// Cache this per request
static $items;
echo '</script>';
if (trim(strip_tags($resource->intro))) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
$link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
$mimetype = mimeinfo("type", $resource->reference);
$pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));
- $formatoptions = new object();
- $formatoptions->noclean = true;
-
if ($resource->options != "frame") {
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
$resourcetype = "image";
echo '</script>';
if (trim(strip_tags($resource->intro))) {
- $formatoptions->noclean = true;
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
$link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
print_header($pagetitle, $course->fullname, $navigation, "", "", true,
update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
- echo '<div class="summary">'.format_text($resource->intro, $resource->introformat, $formatoptions).'</div>';
+ echo '<div class="summary">'.format_module_intro('resource', $resource, $cm->id).'</div>';
if (!empty($localpath)) { // Show some help
echo '<div class="mdl-right helplink">';
link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
echo "</p></center>";
}
- if (trim($resource->summary)) {
- $formatoptions->noclean = true;
- print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
+ if (trim($resource->intro)) {
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
if ($inpopup) {
echo '</script>';
if (trim(strip_tags($resource->intro))) {
- print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center");
+ print_simple_box(format_module_intro('resource', $resource, $cm->id), "center");
}
$link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
- format_text($scorm->intro, $scorm->introformat, $options), $reportshow);
+ format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
- format_text($scorm->intro, $scorm->introformat, $options), $reportshow);
+ format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
}
}
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
- if ($filearea === 'scorm_intro') {
- // all users may access it
- $relativepath = '/'.implode('/', $args);
- $fullpath = $context->id.'scorm_intro0'.$relativepath;
-
- $fs = get_file_storage();
- if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
- return false;
- }
-
- } else if ($filearea === 'scorm_content') {
+ if ($filearea === 'scorm_content') {
$revision = (int)array_shift($args); // prevents caching problems - ignored here
$relativepath = '/'.implode('/', $args);
$fullpath = $context->id.'scorm_content0'.$relativepath;
$colspan = ' colspan="2"';
}
$options = (object)array('noclean'=>true);
- $headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_text($scorm->intro, $scorm->introformat, $options).'</td></tr></table>';
+ $headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_module_intro('scorm', $scorm, $scorm->coursemodule).'</td></tr></table>';
print_simple_box($headertext,'','100%');
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%');
} else {
$mform->addRule('name', null, 'required', null, 'client');
// Summary
- $mform->addElement('htmleditor', 'intro', get_string('summary'));
- $mform->setType('intro', PARAM_RAW);
- $mform->addRule('intro', get_string('required'), 'required', null, 'client');
- $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
+ $this->add_intro_editor(true);
// Scorm types
$options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
// Print the main part of the page
print_heading(format_string($scorm->name));
$attemptstatus = '';
- if($scorm->displayattemptstatus == 1) {
+ if ($scorm->displayattemptstatus == 1) {
$attemptstatus = scorm_get_attempt_status($USER,$scorm);
}
- $options = (object)array('noclean'=>true);
- print_simple_box(format_text($scorm->intro, $scorm->introformat, $options).$attemptstatus, 'center', '70%', '', 5, 'generalbox', 'intro');
+ print_simple_box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'center', '70%', '', 5, 'generalbox', 'intro');
$scormopen = true;
$timenow = time();
class mod_survey_mod_form extends moodleform_mod {
function definition() {
-
global $CFG, $DB;
+
$mform =& $this->_form;
$strrequired = get_string('required');
$mform->addRule('template', $strrequired, 'required', null, 'client');
$mform->setHelpButton('template', array('surveys', get_string('helpsurveys', 'survey')));
-
- $mform->addElement('textarea', 'intro', get_string('customintro', 'survey'), 'wrap="virtual" rows="20" cols="75"');
- $mform->setType('intro', PARAM_RAW);
+ $this->add_intro_editor(false, get_string('customintro', 'survey'));
$this->standard_coursemodule_elements();
} else {
- $options = (object)array('noclean'=>true);
- print_box(format_text($survey->intro, $survey->introformat, $options), 'generalbox', 'intro');
+ print_box(format_module_intro('survey', $survey, $cm->id), 'generalbox', 'intro');
print_spacer(30);
$questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions));
echo '<div>';
echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
- print_simple_box(format_text($survey->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
+ print_simple_box(format_module_intro('survey', $survey, $cm->id), 'center', '70%', '', 5, 'generalbox', 'intro');
// Get all the major questions and their proper order
if (! $questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions))) {
$timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
$options = (object)array('noclean'=>true);
- $summary = '<div class="smallinfo">'.format_text($wiki->intro, $wiki->introformat, $options).'</div>';
+ $summary = '<div class="smallinfo">'.format_module_intro('wiki', $wiki, $wiki->coursemodule).'</div>';
$site = get_site();
switch ($wiki->wtype) {
$mform->setType('name', PARAM_NOTAGS);
$mform->addRule('name', null, 'required', null, 'client');
- $mform->addElement('htmleditor', 'intro', get_string('summary'));
- $mform->setType('intro', PARAM_RAW);
- $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
- $mform->addRule('intro', get_string('required'), 'required', null, 'client');
+ $this->add_intro_editor(true);
if (!$wikihasentries){
asort($WIKI_TYPES);
if($wiki_entry && $ewiki_title==$wiki_entry->pagename && !empty($wiki->intro)) {
if (trim(strip_tags($wiki->intro))) {
- $options = (object)array('noclean'=>true);
- print_box(format_text($wiki->intro, $wiki->introformat, $options), 'generalbox', 'intro');
+ print_box(format_module_intro('wiki', $wiki, $cm->id), 'generalbox', 'intro');
}
}