Commit c27de8d0 authored by Son Nguyen's avatar Son Nguyen Committed by Robert Lyon
Browse files

Support mobile media-capture feature for Image blocks. Bug 1385037



Currently only handle the 'image/*' mediatype

behatnotneeded

Change-Id: I496ebc8a4881d37a8162293fc23d3f47635a1fee
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 17ef60df
...@@ -667,6 +667,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype { ...@@ -667,6 +667,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default); $element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default);
$element['title'] = get_string('Images', 'artefact.file'); $element['title'] = get_string('Images', 'artefact.file');
$element['name'] = 'images'; $element['name'] = 'images';
$element['accept'] = 'image/*';
if ($class) { if ($class) {
$element['class'] = $class; $element['class'] = $class;
} }
......
...@@ -20,7 +20,7 @@ define('FILEBROWSERS', 1); ...@@ -20,7 +20,7 @@ define('FILEBROWSERS', 1);
*/ */
function pieform_element_filebrowser(Pieform $form, $element) { function pieform_element_filebrowser(Pieform $form, $element) {
require_once('license.php'); require_once('license.php');
global $USER, $_PIEFORM_FILEBROWSERS; global $USER, $_PIEFORM_FILEBROWSERS, $SESSION;
$smarty = smarty_core(); $smarty = smarty_core();
// See if the filebrowser has indicated it's a group element // See if the filebrowser has indicated it's a group element
...@@ -207,6 +207,23 @@ function pieform_element_filebrowser(Pieform $form, $element) { ...@@ -207,6 +207,23 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$smarty->assign('folderparams', $params); $smarty->assign('folderparams', $params);
// Add mobile media-capture form tags when users are on mobile or tablet
if ($SESSION->get('mobile') || $SESSION->get('tablet')) {
$supportedmediatypes = array('image/*');
if (isset($element['accept'])) {
$accepted = explode(',', $element['accept']);
foreach ($accepted as $type) {
if (in_array($type, $supportedmediatypes)) {
switch ($type) {
case 'image/*':
$smarty->assign('capturedevice', 'camera');
break;
}
}
}
}
}
return $smarty->fetch('artefact:file:form/filebrowser.tpl'); return $smarty->fetch('artefact:file:form/filebrowser.tpl');
} }
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</label> </label>
<span id="{$prefix}_userfile_container"> <span id="{$prefix}_userfile_container">
<input type="file" class="file" {$accepts|safe} id="{$prefix}_userfile" name="userfile[]" multiple size="20" /> <input type="file" class="file" {$accepts|safe} {if $capturedevice} capture="{$capturedevice}"{/if} id="{$prefix}_userfile" name="userfile[]" multiple size="20" />
</span> </span>
<span id="{$prefix}_userfile_maxuploadsize" class="file-description"> <span id="{$prefix}_userfile_maxuploadsize" class="file-description">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment