Encontre este codigo pero no entiendo como funciona
function setup_elements(&$mform) {
global $CFG, $RESOURCE_WINDOW_OPTIONS;
$this->set_parameters(); // set the parameter array for the form
$mform->addElement('choosecoursefile', 'reference', get_string('location'));
$mform->setDefault('reference', $CFG->resource_defaulturl);
$mform->addRule('name', null, 'required', null, 'client');
if (!empty($CFG->resource_websearch)) {
/*echo "<form id='searchbox_007710969997475610228:wepmnvwg8p0' action='http://www.uamvirtual.edu.co/search.htm' target='_blank'>
<div align='right'>
<input type='hidden' name='cx' value='007710969997475610228:wepmnvwg8p0' >
<input type='hidden' name='cof' value='FORID:11' >
<input name='q' type='text' size='40' >
<input type='submit' name='sa' value='Buscar' >
<img src='http://www.google.com/coop/images/google_custom_search_smwide.gif' alt='Google Custom Search' > </div>
</form>";*/
//$searchbutton = $mform->addElement('button', 'searchbutton', get_string('searchweb', 'resource').'...'); //$buttonattributes = array('title'=>get_string('localfilechoose', 'resource'), 'onclick'=>"return window.open('$CFG->resource_websearch', 'websearch', 'menubar=1,location=1,directories=1,toolbar=1,scrollbars,resizable,width=800,height=600');");//$searchbutton->updateAttributes($buttonattributes);
$options = array('id'=>$course->id, 'wdir'=>'/'.$resource->reference.$subdir);
$editfiles = print_single_button("$CFG->wwwroot/files/index.php", $options, get_string("editfiles"), 'get', '', true);
$update = $editfiles.$update;
}
if (!empty($CFG->resource_allowlocalfiles)) {
$lfbutton = $mform->addElement('button', 'localfilesbutton', get_string('localfilechoose', 'resource').'...');
$options = 'menubar=0,location=0,scrollbars,resizable,width=600,height=400';
$url = '/mod/resource/type/file/localfile.php?choose=id_reference_value';
$buttonattributes = array('title'=>get_string('localfilechoose', 'resource'), 'onclick'=>"return openpopup('$url', '".$lfbutton->getName()."', '$options', 0);");
$lfbutton->updateAttributes($buttonattributes);
}