1 |
<?php |
2 |
|
3 |
/** |
4 |
* This contains the TextNav widget |
5 |
* |
6 |
* $Id: TextNav.inc,v 1.11 2002/10/15 15:04:44 hemna Exp $ |
7 |
* |
8 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
9 |
* @package phpHtmlLib |
10 |
* |
11 |
*/ |
12 |
|
13 |
/** |
14 |
* must have the BaseWidget |
15 |
*/ |
16 |
require_once( $phphtmllib."/widgets/BaseWidget.inc"); |
17 |
|
18 |
/** |
19 |
* This class builds a simple text navigational |
20 |
* widget. |
21 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
22 |
* @package phpHtmlLib |
23 |
*/ |
24 |
class TextNav extends BaseWidget { |
25 |
|
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 TextNav( $width = 760 ) { |
35 |
$this->set_width( $width ); |
36 |
} |
37 |
|
38 |
|
39 |
/** |
40 |
* function that will render the widget. |
41 |
* |
42 |
* @param int - the indentation level for |
43 |
* the container. |
44 |
* @param int - the output debug flag to |
45 |
* maintain compatibility w/ the API. |
46 |
* |
47 |
* @return string the raw html output. |
48 |
* |
49 |
*/ |
50 |
function render( $indent_level=1, $output_debug=0) { |
51 |
|
52 |
$table = html_table($this->width, 0, 0, 2); |
53 |
$table->set_style("border-top-color: #eeeeee;border-width: 1px;". |
54 |
"border-left-color: #eeeeee;". |
55 |
"border-right-color: #eeeeee;". |
56 |
"border-bottom-color: #eeeeee;"); |
57 |
$tr = new TRtag; |
58 |
|
59 |
$this->count = count($this->data); |
60 |
|
61 |
$cnt=1; |
62 |
foreach( $this->data as $nav) { |
63 |
$nav_td = $this->build_nav_td( $nav, $cnt ); |
64 |
$cnt++; |
65 |
//$img_td = $this->build_img_td(); |
66 |
$tr->add( $nav_td ); |
67 |
} |
68 |
$table->add( $tr ); |
69 |
|
70 |
return $table->render( $indent_level, $output_debug ); |
71 |
} |
72 |
|
73 |
|
74 |
//functions for adding/updating data |
75 |
|
76 |
/** |
77 |
* this function adds a clickable link. |
78 |
* It automatically adds the link based on $url, |
79 |
* with $text as the viewable text. |
80 |
* |
81 |
* @param string - the url for the link |
82 |
* @param string - the link text |
83 |
* @param string - the width of the cell |
84 |
* @param string - the target for the url |
85 |
*/ |
86 |
function add($url, $text, $width = 100, $target=NULL) { |
87 |
array_push($this->data, array("type"=>"url", "url"=>$url, |
88 |
"text"=>$text, "width" => $width, |
89 |
"target" => $target)); |
90 |
} |
91 |
|
92 |
/** |
93 |
* depricated version of add() |
94 |
* |
95 |
* @deprecated - use add() instead |
96 |
*/ |
97 |
function push($url, $text, $width = 100) { |
98 |
$this->add($url, $text, $width); |
99 |
} |
100 |
|
101 |
/** |
102 |
* This lets you add a blank entry |
103 |
* between 2 links |
104 |
* |
105 |
* @param int - the # of blank lines to insert |
106 |
*/ |
107 |
function add_blank( $num = 1 ) { |
108 |
for ($x=1; $x<=$num; $x++) |
109 |
array_push($this->data, array( "type"=>"blank" )); |
110 |
} |
111 |
|
112 |
/** |
113 |
* depricated version of add_blank() |
114 |
* |
115 |
* @deprecated - use add_blank() instead |
116 |
*/ |
117 |
function push_blank( $num = 1 ) { |
118 |
$this->add_blank( $num ); |
119 |
} |
120 |
|
121 |
/** |
122 |
* this adds a text item in the nav |
123 |
* |
124 |
* @param string - the text to display |
125 |
*/ |
126 |
function add_text( $text ) { |
127 |
array_push($this->data, array( "type"=>"text", "text"=>$text )); |
128 |
} |
129 |
|
130 |
/** |
131 |
* depricated version of add_text() |
132 |
* |
133 |
* @deprecated - use add_text() instead |
134 |
*/ |
135 |
function push_text( $text ) { |
136 |
$this->add_text( $text ); |
137 |
} |
138 |
|
139 |
|
140 |
/** |
141 |
* build a td for the link. |
142 |
* |
143 |
* @param array - the nav array entry |
144 |
* @param int - the column # this entry is |
145 |
* |
146 |
*/ |
147 |
function build_nav_td( $nav, $count ) { |
148 |
$td = html_td("textnavtd", "center"); |
149 |
$style = "width: ".$nav["width"].";"; |
150 |
|
151 |
if ($count != $this->count) { |
152 |
$style .= "border-right-color:#eeeeee;border-width:2px;"; |
153 |
} |
154 |
$td->set_style( $style ); |
155 |
$td->set_collapse(); |
156 |
|
157 |
switch ($nav['type']) { |
158 |
case 'url': |
159 |
$text = str_replace(' ', " ", $nav['text'] ); |
160 |
$content = html_a( $nav['url'], ' ' . $text . ' ', |
161 |
"textnavlist", $nav['target']); |
162 |
break; |
163 |
case 'blank': |
164 |
$content = " "; |
165 |
} |
166 |
$td->add( $content ); |
167 |
return $td; |
168 |
} |
169 |
|
170 |
/** |
171 |
* build the image seperator td |
172 |
* |
173 |
*/ |
174 |
function build_img_td() { |
175 |
|
176 |
$td = html_td("textnavdivider"); |
177 |
$td->set_style("width: 1px;"); |
178 |
$td->set_collapse(); |
179 |
|
180 |
$img = html_img("/phphtmllib/widgets/images/dot_clear.gif", 1, 1, 0); |
181 |
$td->add( $img ); |
182 |
return $td; |
183 |
} |
184 |
} |
185 |
|
186 |
|
187 |
/** |
188 |
* This class defines the css used by the |
189 |
* TextNav Object. |
190 |
* |
191 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
192 |
* @package phpHtmlLib |
193 |
*/ |
194 |
class TextNavCSS extends CSSBuilder { |
195 |
|
196 |
function user_setup() { |
197 |
|
198 |
$this->add_entry("A.textnavlist:hover", "", |
199 |
array("color" => "#FF0000") ); |
200 |
|
201 |
$this->add_entry("A.textnavlist", "", |
202 |
array("font-family" => "Arial, Helvetica, sans-serif", |
203 |
"font-size" => "10pt", |
204 |
"font-weight" => "bold", |
205 |
"color" => "#000000", |
206 |
"text-decoration" => "none")); |
207 |
|
208 |
$this->add_entry("TD.textnavdivider", "", |
209 |
array("background-image" => |
210 |
"url('/phphtmllib/widgets/images/dot_div_vert.gif')")); |
211 |
|
212 |
$this->add_entry("TD.textnavtd", "", |
213 |
array("background-color" => "#FFCC00")); |
214 |
|
215 |
} |
216 |
} |
217 |
?> |