This commit is contained in:
Dan Poltawski 2013-10-21 11:24:51 +08:00
commit 2d0316d60d
3 changed files with 15 additions and 15 deletions

View file

@ -79,7 +79,7 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
* @return string * @return string
*/ */
function toHtml(){ function toHtml(){
global $CFG, $COURSE, $USER, $PAGE, $OUTPUT; global $PAGE, $OUTPUT;
$id = $this->_attributes['id']; $id = $this->_attributes['id'];
$elname = $this->_attributes['name']; $elname = $this->_attributes['name'];
@ -94,20 +94,9 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
if (empty($this->_options['usefilepicker'])) { if (empty($this->_options['usefilepicker'])) {
return $str; return $str;
} }
$strsaved = get_string('filesaved', 'repository');
$straddlink = get_string('choosealink', 'repository');
if ($COURSE->id == SITEID) {
$context = context_system::instance();
} else {
$context = context_course::instance($COURSE->id);
}
$client_id = uniqid(); $client_id = uniqid();
$str .= <<<EOD
<button id="filepicker-button-{$client_id}" style="display:none">
$straddlink
</button>
EOD;
$args = new stdClass(); $args = new stdClass();
$args->accepted_types = '*'; $args->accepted_types = '*';
$args->return_types = FILE_EXTERNAL; $args->return_types = FILE_EXTERNAL;
@ -117,6 +106,15 @@ EOD;
$fp = new file_picker($args); $fp = new file_picker($args);
$options = $fp->options; $options = $fp->options;
if (count($options->repositories) > 0) {
$straddlink = get_string('choosealink', 'repository');
$str .= <<<EOD
<button id="filepicker-button-{$client_id}" style="display:none">
$straddlink
</button>
EOD;
}
// print out file picker // print out file picker
$str .= $OUTPUT->render($fp); $str .= $OUTPUT->render($fp);

View file

@ -62,8 +62,10 @@ class data_field_url extends data_field_base {
// Just the URL field // Just the URL field
$str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>'; $str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>';
$str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.s($url).'" size="60" />'; $str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.s($url).'" size="60" />';
if (count($options->repositories) > 0) {
$str .= '<button id="filepicker-button-'.$options->client_id.'" style="display:none">'.$straddlink.'</button>'; $str .= '<button id="filepicker-button-'.$options->client_id.'" style="display:none">'.$straddlink.'</button>';
} }
}
// print out file picker // print out file picker
//$str .= $OUTPUT->render($fp); //$str .= $OUTPUT->render($fp);

View file

@ -23,7 +23,7 @@
* this.options.client_id, the instance id * this.options.client_id, the instance id
* this.options.contextid * this.options.contextid
* this.options.itemid * this.options.itemid
* this.options.repositories, stores all repositories displaied in file picker * this.options.repositories, stores all repositories displayed in file picker
* this.options.formcallback * this.options.formcallback
* *
* Active repository options * Active repository options