From 5efae6823dd48799a891f25c5ddabc79872add55 Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Fri, 4 Jan 2013 16:13:52 +0000 Subject: [PATCH] MDL-33946 mod_label - create label from text dragged and dropped into the course --- mod/label/lang/en/label.php | 1 + mod/label/lib.php | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mod/label/lang/en/label.php b/mod/label/lang/en/label.php index b8178f68be8..55787fcadb5 100644 --- a/mod/label/lang/en/label.php +++ b/mod/label/lang/en/label.php @@ -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'; diff --git a/mod/label/lib.php b/mod/label/lib.php index e2651291f07..64208d4bd94 100644 --- a/mod/label/lib.php +++ b/mod/label/lib.php @@ -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; } -} \ No newline at end of file +}