]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13766, fix bugs in formlib
authordongsheng <dongsheng>
Wed, 6 Aug 2008 03:26:57 +0000 (03:26 +0000)
committerdongsheng <dongsheng>
Wed, 6 Aug 2008 03:26:57 +0000 (03:26 +0000)
lang/en_utf8/repository.php
lib/form/filepicker.php
repository/lib.php

index a36844cad5ed874b5df8038e0022624e69e2e077..af0dd13e701035db8760172b0a44a6100822981d 100644 (file)
@@ -4,6 +4,7 @@ $string['back'] = '&lt; Back';
 $string['download'] = 'Download';
 $string['close'] = 'Close';
 $string['filename'] = 'Filename';
+$string['filesaved'] = 'File Saved!';
 $string['invalidrepositoryid'] = 'Invalid Repository ID';
 $string['invalidplugin'] = 'Invalid Repository Plug-in';
 $string['manageuserrepository'] = 'Manage individual repository';
index 8ffa04ddc6e74a8323e8817fbd32b975ff32c418..8e8097a120d43f6e1f0676413cf637a259bcf699 100644 (file)
@@ -45,11 +45,15 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_button
             return $this->getFrozenHtml();
         } else {
             $strsaved = get_string('filesaved', 'repository');
+            // TODO
+            // Use a better itemid value to identify a repository
+            // file
             $itemid = time();
             $ret = get_repository_client();
             $suffix = $ret['suffix'];
             $str = $this->_getTabs();
-            $str .= '<input type="hidden" value="'.$itemid.'" name="repo_attachment" id="repo_value_'.$suffix.'" />';
+            $str .= '<input type="hidden" value="'.$itemid.'" name="'.$this->_attributes['name'].'" id="'.$this->_attributes['id'].'_'.$suffix.'" />';
+            $id = $this->_attributes['id'];
             $str .= <<<EOD
 <script type="text/javascript">
 function updatefile(){
@@ -57,12 +61,13 @@ function updatefile(){
     document.getElementById('repo_info_$suffix').innerHTML = '$strsaved';
 }
 function callpicker_$suffix(){
-    var el=document.getElementById('repo_value_$suffix');
+    var el=document.getElementById('${id}_${suffix}');
     openpicker_$suffix({"env":"form", 'itemid': $itemid, 'target':el, 'callback':updatefile})
 }
 </script>
 EOD;
-            $str .= '<input' . $this->_getAttrString($this->_attributes) . ' onclick=\'callpicker_'.$suffix.'()\' />'.'<span id="repo_info_'.$suffix.'" style="color:green"></span>'.$ret['html'].$ret['js'];
+            // $this->_getAttrString($this->_attributes);
+            $str .= '<input value ="'.get_string('openpicker', 'repository').'" type="button" onclick=\'callpicker_'.$suffix.'()\' />'.'<span id="repo_info_'.$suffix.'" style="color:green"></span>'.$ret['html'].$ret['js'];
             return $str;
         }
     }
index 83e9d264075fbb36037c667f0c4464926e1d0e63..8735f04b978d1cec1207209a977dc5f7abbd50b1 100644 (file)
@@ -494,6 +494,9 @@ function get_repository_client(){
             this.show = function(){
                 panel.show();
             }
+            this.hide = function(){
+                panel.hide();
+            }
             this.create_picker = function(){
                 // display UI
                 panel.render();
@@ -694,6 +697,7 @@ function get_repository_client(){
         _client.end = function(str){
             _client.target.value = str;
             _client.formcallback();
+            _client.instance.hide();
             _client.viewfiles();
         }
         _client.callback = {