Skip to content

Commit

Permalink
MDL-26244 mod_date:added some logic show or hide the file picker butt…
Browse files Browse the repository at this point in the history
…on based on repository availability
  • Loading branch information
andyjdavis committed Oct 16, 2013
1 parent 945aa97 commit b154785
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 11 additions & 13 deletions lib/form/url.php
Expand Up @@ -79,7 +79,7 @@ function setHiddenLabel($hiddenLabel){
* @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'];
Expand All @@ -94,20 +94,9 @@ function toHtml(){
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;
Expand All @@ -117,6 +106,15 @@ function toHtml(){
$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);


Expand Down
4 changes: 3 additions & 1 deletion mod/data/field/url/field.class.php
Expand Up @@ -62,7 +62,9 @@ function display_add_field($recordid=0) {
// 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" />';
$str .= '<button id="filepicker-button-'.$options->client_id.'" style="display:none">'.$straddlink.'</button>'; if (count($options->repositories) > 0) {
$str .= '<button id="filepicker-button-'.$options->client_id.'" style="display:none">'.$straddlink.'</button>';
}
} }


// print out file picker // print out file picker
Expand Down
2 changes: 1 addition & 1 deletion repository/filepicker.js
Expand Up @@ -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
Expand Down

0 comments on commit b154785

Please sign in to comment.