[Phphtmllib-devel] SF.net SVN: phphtmllib:[3128] branches/BRANCH_2_X/phphtmllib/form/ form_elements
Status: Beta
Brought to you by:
hemna
From: <mpw...@us...> - 2008-08-02 01:19:21
|
Revision: 3128 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3128&view=rev Author: mpwalsh8 Date: 2008-08-02 01:19:30 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Added FEComboListVertical widget to build a ComboListBox with a vertical arrangement. Modified Paths: -------------- branches/BRANCH_2_X/phphtmllib/form/form_elements/FEListBox.inc Modified: branches/BRANCH_2_X/phphtmllib/form/form_elements/FEListBox.inc =================================================================== --- branches/BRANCH_2_X/phphtmllib/form/form_elements/FEListBox.inc 2008-08-02 01:15:40 UTC (rev 3127) +++ branches/BRANCH_2_X/phphtmllib/form/form_elements/FEListBox.inc 2008-08-02 01:19:30 UTC (rev 3128) @@ -1085,6 +1085,133 @@ } /** + * This builds a complex dual select box + * with buttons to move entries from one + * select box to another. The boxes are + * stacked vertically instead of horizontally. + * + * From + * ------------------------ + * |----------------------| + * |----------------------| + * |----------------------| + * |----------------------| Add >> + * |----------------------| Add All + * |----------------------| + * |----------------------| + * |----------------------| + * ------------------------ + * To + * ------------------------ + * |----------------------| + * |----------------------| + * |----------------------| + * |----------------------| << Remove + * |----------------------| Remove All + * |----------------------| + * |----------------------| + * |----------------------| + * ------------------------ + * + * @author Mike Walsh <mik...@mi...> + * @see FEComboListBox + */ +class FEComboListBoxVertical extends FEComboListBox +{ + /** + * This function builds and returns the + * form element object + * + * @return object + */ + function get_element() { + $table = html_table(); + + $from_select = form_select($this->_element_name.'_available', + $this->_data_list,'', TRUE); + + if ($this->onChangeJS != null) { + $from_select->set_tag_attribute("onChange", $this->onChangeJS); + } + + $from_select->set_tag_attribute('id', $this->build_id_name().'_from'); + + $style = ''; + if ($this->_height) { + $style .= "height: ".$this->_height.";"; + } + if ($this->_width) { + $style .= "width: ".$this->_width.";"; + } + + //build the buttons + $button_style = 'width: 90px;'; + $f_name = $this->_element_name."_move_around"; + $add = form_button($this->_element_name.'_add', 'Add >>', array('style' => $button_style, + 'onclick' => $f_name."('right',false);")); + $add_all = form_button($this->_element_name.'_add_all', 'Add All', array('style' => $button_style, + "onclick" => $f_name."('right', true);")); + + $remove = form_button($this->_element_name.'_remove', '<< Remove', array('style' => $button_style, + 'onclick' => $f_name."('left', false);")); + $remove_all = form_button($this->_element_name.'_remove_all', 'Remove All', array('style' => $button_style, + 'onclick' => $f_name."('left', true);")); + + $to_select = form_select($this->_element_name.'[]', + $this->_data_list_to, '', TRUE); + + if (strlen($style) > 0) { + $from_select->set_style($style); + $to_select->set_style($style); + } + + //check to see if we are disabled + if ($this->is_disabled()) { + $from_select->set_tag_attribute('disabled'); + $add->set_tag_attribute('disabled'); + $add_all->set_tag_attribute('disabled'); + $remove->set_tag_attribute('disabled'); + $remove_all->set_tag_attribute('disabled'); + $to_select->set_tag_attribute('disabled'); + } + + $to_select->set_tag_attribute('id', $this->build_id_name().'_to'); + + + $button_td = new TDtag(array('align' => 'left'), + $add, html_br(), $add_all, html_br(2), + $remove, html_br(), $remove_all); + + $f_name = $this->_element_name."_order"; + + $move_up = form_button('Move Up', 'Move Up', array('onclick' => "javascript: ".$f_name."(0)")); + $move_down = form_button('Move Down', 'Move Down', array('onclick' => "javascript: ".$f_name."(1)")); + + //IE sucks. + + $add_button_td = new TDtag(array('align' => 'left'), + $add, html_br(), $add_all); + $add_button_td->set_collapse(); + + $remove_button_td = new TDtag(array('align' => 'left'), + $remove, html_br(), $remove_all); + $remove_button_td->set_collapse(); + + + $table->add_row($this->_from_label) ; + $table->add_row($from_select, $add_button_td) ; + $table->add_row($this->_to_label) ; + $table->add_row($to_select, $remove_button_td) ; + + if ($this->_ordering) { + $table->add_row(container($move_up, $move_down)); + } + + return $table; + } +} + +/** * This class builds a FEDataList that shows a select box for Months of the year * * You should use the built in php {@link http://www.php.net/manual/en/function.setlocale.php setlocale} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |