/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/SimpleGUIDataList.inc
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/SimpleGUIDataList.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Feb 22 21:08:37 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 jonen 1.1 <?php
2    
3     /**
4     * This file builds a VERY simple version of the DataList
5     * with no sortable columns, or searchablility.
6     *
7     *
8     * $Id: SimpleGUIDataList.inc,v 1.2 2003/02/18 23:02:04 hemna Exp $
9     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
10     * @package phpHtmlLib
11     */
12    
13     require_once($phphtmllib."/widgets/data_list/DataList.inc");
14    
15     class SimpleGUIDataList extends DataList {
16    
17     /**
18     * Initialize the gui layout
19     *
20     */
21     function gui_init() {
22     //disable searching
23     $this->search_disable();
24     $this->_data_table = html_table($this->get_width(),0,0,0,
25     $this->_align);
26     $this->_data_table->set_class("datalist_border");
27    
28     //add the header tr reference
29     //it will get populated later
30     $this->_header_tr = new TRtag;
31    
32     //initialize the first date row
33     $this->_data_row = new TRtag;
34    
35     $this->_data_table->add_reference( $this->_header_tr );
36     }
37    
38     function child_get_gui() {
39     return container( $this->_data_table );
40     }
41    
42     function child_build_column_header($name, $col, $cnt) {
43     $td = $this->build_column_header($name, $col, $cnt);
44     $this->_header_tr->add( $td );
45     }
46    
47    
48     function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) {
49     //show the normal data
50     $td = $this->wrap_column_item($obj, $col_name);
51     $this->_data_row->add( $td );
52    
53     if ($last_in_row_flag) {
54     $this->_data_table->add_row( $this->_data_row );
55     $this->_data_row = new TRtag;
56     }
57     }
58    
59     /**
60     * This function builds the object/text
61     * to be used for a column header. It can
62     * either be an href because its sortable,
63     * or it can just be text, because its not
64     * sortable.
65     *
66     * @param string $col_name - the column name
67     * to build from
68     * the headers.
69     * @param array $col_data - the column's data.
70     * @param int the column # we are working on.
71     * @return mixed - either an Atag object or
72     * raw text.
73     */
74     function build_column_header($col_name, $col_data, $col_num) {
75    
76     $td = new TDtag(array("class"=>"datalist_col_head",
77     "width" => $col_data["size"]));
78    
79     $td->push($col_name);
80     $td->set_tag_attribute("style", "padding-left:5px;padding-right:5px;white-space:nowrap;");
81    
82     return $td;
83     }
84    
85    
86     /**
87     * This function ensures that the data we place
88     * in a column is aligned according to what the
89     * user wants.
90     *
91     * @param mixed - $obj - the data for the td.
92     * @param string - $col_name - the name of the column header
93     * for this row to render.
94     * @param int - $odd_row - tells us if this cell lives in
95     * an odd # row (for alternating row colors)
96     * @param int - the column # we are working on.
97     * @return TDtag object
98     */
99     function wrap_column_item($obj, $col_name) {
100    
101     //make sure its set to something.
102     if ($obj == '') {
103     $obj = "&nbsp;";
104     }
105    
106     //make sure we don't put a right border on the last
107     //column we are working on.
108    
109     if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
110     $style = "background-color: #f4f4f4;";
111     } else {
112     $style = "background-color: #ffffff;";
113     }
114    
115     $align = $this->_columns[$col_name]["align"];
116     $td = new TDtag(array("align" => $align,
117     "style" => $style,
118     "class" => "datalist_data_cell"));
119    
120     if (is_object($obj) && $obj->_tag == "td") {
121     return $obj;
122     } else {
123     $td->add( $obj );
124     }
125     return $td;
126     }
127     }
128    
129     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed