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

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/TreeNav.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Thu May 6 16:27:42 2004 UTC (20 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This contains the TreeNav widget
4 *
5 * $Id: TreeNav.inc,v 1.5 2002/09/27 23:37:50 hemna Exp $
6 *
7 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8 * @package phpHtmlLib
9 *
10 */
11
12 /**
13 * must have the BaseWidget
14 */
15 require_once( $phphtmllib."/widgets/BaseWidget.inc");
16
17 /**
18 * This class tries to build a tree
19 * navigational widget.
20 * definetly not done.
21 *
22 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
23 * @package phpHtmlLib
24 */
25 class TreeNav extends BaseWidget {
26
27 /**
28 * Constructor for this class
29 * It just sets the width for the
30 * widget.
31 *
32 * @param int $width - the width of the widget
33 */
34 function TreeNav( $width = 760 ) {
35 $this->set_width( $width );
36 }
37
38
39 //functions for adding/updating data
40
41 function push($url, $text, $selected=FALSE) {
42 array_push($this->data, array("type"=>"url", "url"=>$url,
43 "text"=>$text, "selected" => $selected));
44 }
45
46 function push_blank( $num=1 ) {
47 for ($x=1; $x<=$num; $x++)
48 array_push($this->data, array( "type"=>"blank" ));
49 }
50
51 function push_text( $text, $selected=FALSE ) {
52 array_push($this->data, array( "type"=>"text", "text"=>$text,
53 "selected" => $selected ));
54 }
55
56 /**
57 * Set this text as the selected
58 * item
59 *
60 * @param string $text - the text item selected.
61 */
62 function set_selected( $text ) {
63 //ok find the
64 }
65
66 /**
67 * build the image seperator td
68 *
69 */
70 function build_img_td() {
71
72 $td = new TDtag;
73 $td->newline_after_opentag = FALSE;
74 $img = html_img("/phphtmllib/widgets/images/arrow.gif", 9, 9);
75 $img->set_tag_attributes( array("vspace"=>5, "hspace"=>3));
76 $img->indent_flag = FALSE;
77 $img->newline_after_opentag = FALSE;
78 $td->push( $img );
79 return $td;
80 }
81
82 /**
83 * build the link td.
84 *
85 */
86 function build_link_td( $nav ) {
87 $span = html_span();
88 $span->indent_flag = FALSE;
89 $span->newline_after_opentag = FALSE;
90 $span->newline_after_closetag = FALSE;
91
92 $a = html_a($nav["url"], $nav["text"], "treenavnormal");
93
94 $td = new TDtag( array("width" => "100%"), $a );
95
96 return $td;
97 }
98
99 /**
100 * build a spacer td.
101 *
102 */
103 function build_spacer_td() {
104
105 $attributes = array("colspan" => 3,
106 "class" => "treenavspacer");
107 $td = new TDtag( $attributes );
108 $td->newline_after_opentag = FALSE;
109 $img = html_img("/phphtmllib/widgets/images/spacer.gif", 1, 1);
110 $img->indent_flag = FALSE;
111 $img->newline_after_opentag = FALSE;
112 $td->push( $img );
113 return $td;
114 }
115
116
117 /**
118 * build all of the idividual nav elements.
119 *
120 */
121 function build_innertable() {
122
123 $attributes = array( "width" => $this->width,
124 "cellspacing" => 0,
125 "cellpadding" => 0,
126 "border"=>0,
127 "class" => "treenavinnertable");
128 $table = new TABLEtag( $attributes );
129
130 foreach( $this->data as $nav) {
131 $img_td = $this->build_img_td();
132 $link_td = $this->build_link_td( $nav );
133
134 $table->push_row( $img_td, $link_td, "&nbsp;");
135
136 $spacer_td = $this->build_spacer_td();
137 $table->push_row( $spacer_td );
138 }
139
140 return $table;
141 }
142
143
144
145 /**
146 * function that will render the widget.
147 *
148 * @param int - the indentation level for
149 * the container.
150 * @param int - the output debug flag to
151 * maintain compatibility w/ the API.
152 *
153 * @return string the raw html output.
154 *
155 */
156 function render( $indent_level=1, $output_debug=0) {
157 $attributes = array( "border" => 0, "width" => $this->width,
158 "cellpadding" => 0, "cellspacing" => 1,
159 "class" => "treenavwrapper" );
160 $table = new TABLEtag( $attributes );
161 $tr = new TRtag;
162
163 //Ok now build the content.
164
165 $tr->push( $this->build_innertable() );
166
167 $table->push( $tr );
168
169 return $table->render( $indent_level, $output_debug );
170 }
171 }
172 ?>

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