Skip to content

Commit

Permalink
MDL-33946 mod_label - create label from text dragged and dropped into…
Browse files Browse the repository at this point in the history
… the course
  • Loading branch information
davosmith committed Feb 28, 2013
1 parent cce0d9a commit 5efae68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions mod/label/lang/en/label.php
Expand Up @@ -31,6 +31,7 @@
$string['dndresizeheight'] = 'Resize drag and drop height'; $string['dndresizeheight'] = 'Resize drag and drop height';
$string['dndresizewidth'] = 'Resize drag and drop width'; $string['dndresizewidth'] = 'Resize drag and drop width';
$string['dnduploadlabel'] = 'Add image to course page'; $string['dnduploadlabel'] = 'Add image to course page';
$string['dnduploadlabeltext'] = 'Add text to course page';
$string['label:addinstance'] = 'Add a new label'; $string['label:addinstance'] = 'Add a new label';
$string['labeltext'] = 'Label text'; $string['labeltext'] = 'Label text';
$string['modulename'] = 'Label'; $string['modulename'] = 'Label';
Expand Down
16 changes: 12 additions & 4 deletions mod/label/lib.php
Expand Up @@ -207,18 +207,24 @@ function label_supports($feature) {
* @return array containing details of the files / types the mod can handle * @return array containing details of the files / types the mod can handle
*/ */
function label_dndupload_register() { function label_dndupload_register() {
$strdnd = get_string('dnduploadlabel', 'mod_label');
if (get_config('label', 'dndmedia')) { if (get_config('label', 'dndmedia')) {
$mediaextensions = file_get_typegroup('extension', 'web_image'); $mediaextensions = file_get_typegroup('extension', 'web_image');
$strdnd = get_string('dnduploadlabel', 'mod_label');
$files = array(); $files = array();
foreach ($mediaextensions as $extn) { foreach ($mediaextensions as $extn) {
$extn = trim($extn, '.'); $extn = trim($extn, '.');
$files[] = array('extension' => $extn, 'message' => $strdnd); $files[] = array('extension' => $extn, 'message' => $strdnd);
} }
return array('files' => $files); $ret = array('files' => $files);
} else { } 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)
)));
} }


/** /**
Expand Down Expand Up @@ -256,6 +262,8 @@ function label_dndupload_handle($uploadinfo) {
$data->intro = file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_label', 'intro', 0, $data->intro = file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_label', 'intro', 0,
null, $data->intro); null, $data->intro);
} }
} else if (!empty($uploadinfo->content)) {
$data->intro = $uploadinfo->content;
} }


return label_add_instance($data, null); return label_add_instance($data, null);
Expand Down Expand Up @@ -333,4 +341,4 @@ function label_generate_resized_image(stored_file $file, $maxwidth, $maxheight)
} else { } else {
return $img; return $img;
} }
} }

0 comments on commit 5efae68

Please sign in to comment.