Permalink
Browse files

MDL-26244 mod_date:added some logic show or hide the file picker butt…

…on based on repository availability
  • Loading branch information...
andyjdavis committed Oct 8, 2013
1 parent 945aa97 commit b15478526af10c0cbf54315d7cde86fd01849ad8
Showing with 15 additions and 15 deletions.
  1. +11 −13 lib/form/url.php
  2. +3 −1 mod/data/field/url/field.class.php
  3. +1 −1 repository/filepicker.js
View
@@ -79,7 +79,7 @@ function setHiddenLabel($hiddenLabel){
* @return string
*/
function toHtml(){
- global $CFG, $COURSE, $USER, $PAGE, $OUTPUT;
+ global $PAGE, $OUTPUT;
$id = $this->_attributes['id'];
$elname = $this->_attributes['name'];
@@ -94,20 +94,9 @@ function toHtml(){
if (empty($this->_options['usefilepicker'])) {
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();
- $str .= <<<EOD
-<button id="filepicker-button-{$client_id}" style="display:none">
-$straddlink
-</button>
-EOD;
$args = new stdClass();
$args->accepted_types = '*';
$args->return_types = FILE_EXTERNAL;
@@ -117,6 +106,15 @@ function toHtml(){
$fp = new file_picker($args);
$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
$str .= $OUTPUT->render($fp);
@@ -62,7 +62,9 @@ function display_add_field($recordid=0) {
// Just the URL field
$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 .= '<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
View
@@ -23,7 +23,7 @@
* this.options.client_id, the instance id
* this.options.contextid
* 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
*
* Active repository options

0 comments on commit b154785

Please sign in to comment.