_helpbutton=call_user_func_array($function, $helpbuttonargs); } function getHelpButton() { return $this->_helpbutton; } function getElementTemplateType() { if ($this->_flagFrozen){ return 'nodisplay'; } else { return 'default'; } } function toHtml() { global $CFG, $COURSE, $USER; if ($this->_flagFrozen) { return $this->getFrozenHtml(); } $currentfile = ''; $draftvalue = ''; if ($draftid = (int)$this->getValue()) { $fs = get_file_storage(); $usercontext = get_context_instance(CONTEXT_USER, $USER->id); if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftid, '', false)) { $file = reset($files); $currentfile = $file->get_filename(); $draftvalue = 'value="'.$draftid.'"'; } } $strsaved = get_string('filesaved', 'repository'); if ($COURSE->id == SITEID) { $context = get_context_instance(CONTEXT_SYSTEM); } else { $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); } $repository_info = repository_get_client($context); $suffix = $repository_info['suffix']; $id = $this->_attributes['id']; $elname = $this->_attributes['name']; $str = $this->_getTabs(); $str .= ''; $str .= << function updatefile_$suffix(str) { document.getElementById('repo_info_$suffix').innerHTML = str; } function callpicker_$suffix() { document.body.className += ' yui-skin-sam'; var picker = document.createElement('DIV'); picker.id = 'file-picker-$suffix'; picker.className = 'file-picker'; document.body.appendChild(picker); var el=document.getElementById('$id'); openpicker_$suffix({'env':'form', 'target':el, 'callback':updatefile_$suffix}) } EOD; $str .= ''.''.$currentfile.''.$repository_info['css'].$repository_info['js']; return $str; } function exportValue(&$submitValues, $assoc = false) { return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]); } }