1 |
jonen |
1.1 |
<?php |
2 |
|
|
/** |
3 |
|
|
* This contains the TreeNav widget |
4 |
|
|
* |
5 |
jonen |
1.4 |
* $Id: TreeNav.inc,v 1.5 2002/09/27 23:37:50 hemna Exp $ |
6 |
jonen |
1.1 |
* |
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 |
jonen |
1.4 |
function push_text( $text, $selected=FALSE ) { |
52 |
|
|
array_push($this->data, array( "type"=>"text", "text"=>$text, |
53 |
jonen |
1.1 |
"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 |
jonen |
1.4 |
$img = html_img("/phphtmllib/widgets/images/arrow.gif", 9, 9); |
75 |
jonen |
1.1 |
$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 |
jonen |
1.4 |
$img = html_img("/phphtmllib/widgets/images/spacer.gif", 1, 1); |
110 |
jonen |
1.1 |
$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 |
jonen |
1.3 |
foreach( $this->data as $nav) { |
131 |
jonen |
1.1 |
$img_td = $this->build_img_td(); |
132 |
jonen |
1.4 |
$link_td = $this->build_link_td( $nav ); |
133 |
jonen |
1.1 |
|
134 |
|
|
$table->push_row( $img_td, $link_td, " "); |
135 |
|
|
|
136 |
|
|
$spacer_td = $this->build_spacer_td(); |
137 |
|
|
$table->push_row( $spacer_td ); |
138 |
jonen |
1.4 |
} |
139 |
|
|
|
140 |
jonen |
1.3 |
return $table; |
141 |
jonen |
1.1 |
} |
142 |
jonen |
1.4 |
|
143 |
jonen |
1.1 |
|
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 |
|
|
?> |