Merge branch 'MDL-33946_label_dndupload_text' of git://github.com/davosmith/moodle

This commit is contained in:
Aparup Banerjee
2013-03-05 10:21:25 +08:00
2 changed files with 13 additions and 4 deletions
+1
View File
@@ -31,6 +31,7 @@ $string['dndmedia'] = 'Media drag and drop';
$string['dndresizeheight'] = 'Resize drag and drop height';
$string['dndresizewidth'] = 'Resize drag and drop width';
$string['dnduploadlabel'] = 'Add image to course page';
$string['dnduploadlabeltext'] = 'Add text to course page';
$string['label:addinstance'] = 'Add a new label';
$string['labeltext'] = 'Label text';
$string['modulename'] = 'Label';
+12 -4
View File
@@ -207,18 +207,24 @@ function label_supports($feature) {
* @return array containing details of the files / types the mod can handle
*/
function label_dndupload_register() {
$strdnd = get_string('dnduploadlabel', 'mod_label');
if (get_config('label', 'dndmedia')) {
$mediaextensions = file_get_typegroup('extension', 'web_image');
$strdnd = get_string('dnduploadlabel', 'mod_label');
$files = array();
foreach ($mediaextensions as $extn) {
$extn = trim($extn, '.');
$files[] = array('extension' => $extn, 'message' => $strdnd);
}
return array('files' => $files);
$ret = array('files' => $files);
} else {
return array();
$ret = array();
}
$strdndtext = get_string('dnduploadlabeltext', 'mod_label');
return array_merge($ret, array('types' => array(
array('identifier' => 'text/html', 'message' => $strdndtext),
array('identifier' => 'text', 'message' => $strdndtext)
)));
}
/**
@@ -256,6 +262,8 @@ function label_dndupload_handle($uploadinfo) {
$data->intro = file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_label', 'intro', 0,
null, $data->intro);
}
} else if (!empty($uploadinfo->content)) {
$data->intro = $uploadinfo->content;
}
return label_add_instance($data, null);
@@ -333,4 +341,4 @@ function label_generate_resized_image(stored_file $file, $maxwidth, $maxheight)
} else {
return $img;
}
}
}