Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Handles INPUT type="submit" boxes generation.
5
 */
6
class ButtonSubmitBox extends ButtonBox {
7
  /**
8
   * @var String URL to post the form to; may be null if this is not a 'submit' button
9
   * @access private
10
   */
11
  var $_action_url;
12
 
13
  /**
14
   * Note: required for interative forms only
15
   *
16
   * @var String textual name of the input field
17
   * @access private
18
   */
19
  var $_field_name;
20
 
21
  /**
22
   * Note: required for interactive forms only
23
   *
24
   * @var String button name to display
25
   * @access private
26
   */
27
  var $_value;
28
 
29
  /**
30
   * Constructs new (possibly interactive) button box
31
   *
32
   * @param String $text text to display
33
   * @param String $field field name (interactive forms)
34
   * @param String $value field value (interactive forms)
35
   */
36
  function ButtonSubmitBox($field, $value, $action) {
37
    $this->ButtonBox();
38
    $this->_action_url = $action;
39
    $this->_field_name = $field;
40
    $this->_value = $value;
41
  }
42
 
43
  /**
44
   * Create input box using DOM tree data
45
   *
46
   * @param Object $root DOM tree node corresponding to the box being created
47
   * @param Pipeline $pipeline reference to current pipeline object (unused)
48
   *
49
   * @return input box
50
   */
51
  function &create(&$root, &$pipeline) {
52
    /**
53
     * If no "value" attribute is specified, display the default button text.
54
     * Note the difference between displayed text and actual field value!
55
     */
56
    if ($root->has_attribute("value")) {
57
      $text = $root->get_attribute("value");
58
    } else {
59
      $text = DEFAULT_SUBMIT_TEXT;
60
    };
61
 
62
    $field = $root->get_attribute('name');
63
    $value = $root->get_attribute('value');
64
 
65
    $css_state =& $pipeline->get_current_css_state();
66
    $box =& new ButtonSubmitBox($field, $value, $css_state->get_property(CSS_HTML2PS_FORM_ACTION));
67
    $box->readCSS($css_state);
68
    $box->_setup($text, $pipeline);
69
 
70
    return $box;
71
  }
72
 
73
  /**
74
   * Render interactive field using the driver-specific capabilities;
75
   * button is rendered as a rectangle defined by margin and padding areas (note that unlike most other boxes,
76
   * borders are _outside_ the box, so we may treat
77
   *
78
   * @param OutputDriver $driver reference to current output driver object
79
   */
80
  function _render_field(&$driver) {
81
    $driver->field_pushbuttonsubmit($this->get_left_padding() - $this->get_margin_left(),
82
                                    $this->get_top_padding() + $this->get_margin_top(),
83
                                    $this->get_width() + $this->get_padding_left() + $this->get_padding_right() + $this->get_margin_left() + $this->get_margin_right(),
84
                                    $this->get_height() + $this->get_padding_top() + $this->get_padding_bottom() + $this->get_margin_top() + $this->get_margin_bottom(),
85
                                    $this->_field_name,
86
                                    $this->_value,
87
                                    $this->_action_url);
88
  }
89
}
90
 
91
?>