mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
"MDL-17316, fix upload form in non-js file picker"
This commit is contained in:
parent
b556308033
commit
ab9cdbb976
6 changed files with 41 additions and 17 deletions
|
@ -173,7 +173,12 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
|||
$str .= $repo_info['js'];
|
||||
$str .= <<<EOD
|
||||
<input value="$draftitemid" name="{$this->_attributes['name']}" type="hidden" />
|
||||
<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
|
||||
<a href="###" id="btnadd-{$client_id}" style="display:none" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
document.getElementById('btnadd-{$client_id}').style.display="inline";
|
||||
//]]>
|
||||
</script>
|
||||
EOD;
|
||||
if (empty($CFG->filemanagerjsloaded)) {
|
||||
$str .= <<<EOD
|
||||
|
@ -224,7 +229,6 @@ function callpicker(el_id, client_id, itemid) {
|
|||
//]]>
|
||||
</script>
|
||||
<noscript>
|
||||
<a name="nonjsfp"></a>
|
||||
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="300" width="800" style="border:1px solid #000">Error</object>
|
||||
</noscript>
|
||||
EOD;
|
||||
|
|
|
@ -65,6 +65,8 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
|||
return $this->getFrozenHtml();
|
||||
}
|
||||
|
||||
$strsaved = get_string('filesaved', 'repository');
|
||||
$straddfile = get_string('openpicker', 'repository');
|
||||
$currentfile = '';
|
||||
$draftvalue = '';
|
||||
if ($draftid = (int)$this->getValue()) {
|
||||
|
@ -76,7 +78,6 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
|||
$draftvalue = 'value="'.$draftid.'"';
|
||||
}
|
||||
}
|
||||
$strsaved = get_string('filesaved', 'repository');
|
||||
if ($COURSE->id == SITEID) {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
} else {
|
||||
|
@ -90,8 +91,11 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
|||
|
||||
$str = $this->_getTabs();
|
||||
$str .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" '.$draftvalue.' />';
|
||||
$str .= $repository_info['css'].$repository_info['js'];
|
||||
|
||||
$str .= <<<EOD
|
||||
<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$client_id', '$id', '$draftvalue')">$straddfile</a>
|
||||
<span id="repo_info_{$client_id}" class="notifysuccess">$currentfile</span>
|
||||
<script type="text/javascript">
|
||||
function updatefile(client_id, obj) {
|
||||
document.getElementById('repo_info_'+client_id).innerHTML = obj['file'];
|
||||
|
@ -104,15 +108,20 @@ function callpicker(client_id, id) {
|
|||
var el=document.getElementById(id);
|
||||
var params = {};
|
||||
params.env = 'filepicker';
|
||||
params.itemid = itemid;
|
||||
params.maxbytes = $this->_options['maxbytes'];
|
||||
params.maxfiles = $this->_options['maxfiles'];
|
||||
params.target = el;
|
||||
params.callback = updatefile;
|
||||
open_filepicker(client_id, params);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<noscript>
|
||||
<a name="nonjsfp"></a>
|
||||
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="300" width="800" style="border:1px solid #000">Error</object>
|
||||
</noscript>
|
||||
EOD;
|
||||
$str .= '<input value="'.get_string('openpicker', 'repository').'" type="button" onclick="callpicker(\''.$client_id.'\', \''.$id.'\')" />'.'<span id="repo_info_'.$client_id.'" class="notifysuccess">'.$currentfile.'</span>'.$repository_info['css'].$repository_info['js'];
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue