]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15405: A first form (partly) converted to the new filepicker element.
authorscyrma <scyrma>
Wed, 27 Aug 2008 07:57:54 +0000 (07:57 +0000)
committerscyrma <scyrma>
Wed, 27 Aug 2008 07:57:54 +0000 (07:57 +0000)
lib/form/filepicker.php
mod/forum/post_form.php

index 99993a327dfb8a96f5da38f27406a4ebaa9be6b0..4c3064e9661eac93d9ddb9dea310223f99b85644 100644 (file)
@@ -14,7 +14,13 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/repository/lib.php');
  */
 class MoodleQuickForm_filepicker extends HTML_QuickForm_button
 {
+    var $_filearea;
     var $_helpbutton='';
+    
+    function MoodleQuickForm_filepicker($elementName=null, $value=null, $filearea=null, $attributes=null) {
+        parent::HTML_QuickForm_button($elementName, $value, $attributes);
+        $this->_filearea = $filearea;
+    }
     function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
@@ -55,6 +61,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_button
             $str = $this->_getTabs();
             $str .= '<input type="hidden" value="" name="'.$this->_attributes['name'].'" id="'.$this->_attributes['id'].'_'.$suffix.'" />';
             $id = $this->_attributes['id'];
+            $filearea = $this->_filearea;
             $str .= <<<EOD
 <script type="text/javascript">
 function updatefile_$suffix(){
@@ -66,11 +73,12 @@ function callpicker_$suffix(){
     picker.id = 'file-picker-$suffix';
     document.body.appendChild(picker);
     var el=document.getElementById('${id}_${suffix}');
-    openpicker_$suffix({"env":"form", 'target':el, 'callback':updatefile_$suffix})
+    openpicker_$suffix({"env":"form", 'target':el, 'callback':updatefile_$suffix, 'filearea':${filearea}})
 }
 </script>
 EOD;
             // $this->_getAttrString($this->_attributes);
+            $str .= "<input name=\"filearea\" value=\"$filearea\" type=\"hidden\">\n";
             $str .= '<input value ="'.get_string('openpicker', 'repository').'" type="button" onclick=\'callpicker_'.$suffix.'()\' />'.'<span id="repo_info_'.$suffix.'" style="color:green"></span>'.$ret['css'].$ret['js'];
             return $str;
         }
index ceebe57114fa7b93273fca5ff4933afe25be700f..60d16672726a5f12354b6517f3f487595f173917 100644 (file)
@@ -16,7 +16,6 @@ class mod_forum_post_form extends moodleform {
         $forum         = $this->_customdata['forum'];
         $post          = $this->_customdata['post']; // hack alert
 
-
         $mform->addElement('header', 'general', '');//fill in the data depending on page params
                                                     //later using set_data
         $mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
@@ -54,9 +53,8 @@ class mod_forum_post_form extends moodleform {
         }
 
         if ($forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext))  {  //  1 = No attachments at all
-            $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
+            $mform->addElement('filepicker', 'attachment', get_string('attachment', 'forum'), 'forum_submission');
             $mform->setHelpButton('attachment', array('attachment', get_string('attachment', 'forum'), 'forum'));
-
         }
 
         if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) { // hack alert