/[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.2 - (show annotations)
Fri Jan 31 08:48:45 2003 UTC (21 years, 7 months ago) by jonen
Branch: MAIN
Changes since 1.1: +24 -7 lines
+ tried building deep tree from given deep hash

1 <?php
2 /**
3 * This contains the TreeNav widget
4 *
5 * $Id: TreeNav.inc,v 1.1.1.1 2003/01/30 03:29:44 jonen 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 if (is_array($text)) {
53 foreach($text as $value) {
54 $this->push_text($value);
55 }
56 }
57 else {
58 array_push($this->data, array( "type"=>"text", "text"=>$text,
59 "selected" => $selected ));
60 }
61 }
62
63 /**
64 * Set this text as the selected
65 * item
66 *
67 * @param string $text - the text item selected.
68 */
69 function set_selected( $text ) {
70 //ok find the
71 }
72
73 /**
74 * build the image seperator td
75 *
76 */
77 function build_img_td() {
78
79 $td = new TDtag;
80 $td->newline_after_opentag = FALSE;
81 $img = html_img("img/widgets/arrow.gif", 9, 9);
82 $img->set_tag_attributes( array("vspace"=>5, "hspace"=>3));
83 $img->indent_flag = FALSE;
84 $img->newline_after_opentag = FALSE;
85 $td->push( $img );
86 return $td;
87 }
88
89 /**
90 * build the link td.
91 *
92 */
93 function build_link_td( $nav ) {
94 $span = html_span();
95 $span->indent_flag = FALSE;
96 $span->newline_after_opentag = FALSE;
97 $span->newline_after_closetag = FALSE;
98
99 $a = html_a($nav["url"], $nav["text"], "treenavnormal");
100
101 $td = new TDtag( array("width" => "100%"), $a );
102
103 return $td;
104 }
105
106 /**
107 * build a spacer td.
108 *
109 */
110 function build_spacer_td() {
111
112 $attributes = array("colspan" => 3,
113 "class" => "treenavspacer");
114 $td = new TDtag( $attributes );
115 $td->newline_after_opentag = FALSE;
116 $img = html_img("img/widgets/spacer.gif", 1, 1);
117 $img->indent_flag = FALSE;
118 $img->newline_after_opentag = FALSE;
119 $td->push( $img );
120 return $td;
121 }
122
123
124 /**
125 * build all of the idividual nav elements.
126 *
127 */
128 function build_innertable() {
129
130 $attributes = array( "width" => $this->width,
131 "cellspacing" => 0,
132 "cellpadding" => 0,
133 "border"=>0,
134 "class" => "treenavinnertable");
135 $table = new TABLEtag( $attributes );
136
137 $this->build_entries($this->data, $table);
138
139 return $table;
140 }
141
142 function build_entries($entries = '', &$table) {
143 if(!is_array($entries)) { $entries = $this->data; }
144 foreach( $entries as $nav) {
145 if(is_array($nav)) {
146 $this->build_entries($nav, $table);
147 }
148 else {
149 print $nav;
150 $img_td = $this->build_img_td();
151 $link_td = $this->build_link_td( $nav );
152
153 $table->push_row( $img_td, $link_td, "&nbsp;");
154
155 $spacer_td = $this->build_spacer_td();
156 $table->push_row( $spacer_td );
157 }
158 }
159 }
160
161
162 /**
163 * function that will render the widget.
164 *
165 * @param int - the indentation level for
166 * the container.
167 * @param int - the output debug flag to
168 * maintain compatibility w/ the API.
169 *
170 * @return string the raw html output.
171 *
172 */
173 function render( $indent_level=1, $output_debug=0) {
174 $attributes = array( "border" => 0, "width" => $this->width,
175 "cellpadding" => 0, "cellspacing" => 1,
176 "class" => "treenavwrapper" );
177 $table = new TABLEtag( $attributes );
178 $tr = new TRtag;
179
180 //Ok now build the content.
181
182 $tr->push( $this->build_innertable() );
183
184 $table->push( $tr );
185
186 return $table->render( $indent_level, $output_debug );
187 }
188 }
189 ?>

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