Skip to content
Browse files

MDL-33946 mod_label - create label from text dragged and dropped into…

… the course
  • Loading branch information...
1 parent cce0d9a commit 5efae6823dd48799a891f25c5ddabc79872add55 @davosmith davosmith committed Jan 4, 2013
Showing with 13 additions and 4 deletions.
  1. +1 −0 mod/label/lang/en/label.php
  2. +12 −4 mod/label/lib.php
View
1 mod/label/lang/en/label.php
@@ -31,6 +31,7 @@
$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';
View
16 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;
}
-}
+}

0 comments on commit 5efae68

Please sign in to comment.
Something went wrong with that request. Please try again.