Forum MDL-25170 Discussion move feature should have button so you don't do it by...
authorSam Marshall <s.marshall@open.ac.uk>
Mon, 15 Nov 2010 10:41:26 +0000 (10:41 +0000)
committerSam Marshall <s.marshall@open.ac.uk>
Mon, 15 Nov 2010 10:41:26 +0000 (10:41 +0000)
lib/outputcomponents.php
lib/outputrenderers.php
mod/forum/discuss.php

index 1050632..fd0dfb3 100644 (file)
@@ -650,18 +650,26 @@ class url_select implements renderable {
      * @var array of component_action
      */
     var $helpicon = null;
+    /**
+     * @var string If set, makes button visible with given name for button
+     */
+    var $showbutton = null;
     /**
      * Constructor
      * @param array $urls list of options
      * @param string $selected selected element
      * @param array $nothing
      * @param string $formid
-     */
-    public function __construct(array $urls, $selected='', $nothing=array(''=>'choosedots'), $formid=null) {
-        $this->urls     = $urls;
-        $this->selected = $selected;
-        $this->nothing  = $nothing;
-        $this->formid   = $formid;
+     * @param string $showbutton Set to text of button if it should be visible
+     *   or null if it should be hidden (hidden version always has text 'go')
+     */
+    public function __construct(array $urls, $selected='', $nothing=array(''=>'choosedots'),
+            $formid=null, $showbutton=null) {
+        $this->urls       = $urls;
+        $this->selected   = $selected;
+        $this->nothing    = $nothing;
+        $this->formid     = $formid;
+        $this->showbutton = $showbutton;
     }
 
     /**
index 4948389..a188789 100644 (file)
@@ -1293,11 +1293,14 @@ class core_renderer extends renderer_base {
         $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
         $output .= html_writer::select($urls, 'jump', $selected, $select->nothing, $select->attributes);
 
-        $go = html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('go')));
-        $output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style'=>'inline'));
-
-        $nothing = empty($select->nothing) ? false : key($select->nothing);
-        $output .= $this->page->requires->js_init_call('M.util.init_url_select', array($select->formid, $select->attributes['id'], $nothing));
+        if (!$select->showbutton) {
+            $go = html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('go')));
+            $output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style'=>'inline'));
+            $nothing = empty($select->nothing) ? false : key($select->nothing);
+            $output .= $this->page->requires->js_init_call('M.util.init_url_select', array($select->formid, $select->attributes['id'], $nothing));
+        } else {
+            $output .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>$select->showbutton));
+        }
 
         // then div wrapper for xhtml strictness
         $output = html_writer::tag('div', $output);
index 147a081..b9b0ffd 100644 (file)
             }
             if (!empty($forummenu)) {
                 echo '<div class="movediscussionoption">';
-                $select = new url_select($forummenu, '', array(''=>get_string("movethisdiscussionto", "forum")), 'forummenu');
+                $select = new url_select($forummenu, '',
+                        array(''=>get_string("movethisdiscussionto", "forum")),
+                        'forummenu', get_string('move'));
                 echo $OUTPUT->render($select);
                 echo "</div>";
             }