1 |
<?php |
2 |
|
3 |
/** |
4 |
* This contains the FooterNav widget and |
5 |
* the FooterNavCSS widget. |
6 |
* |
7 |
* $Id: FooterNav.inc,v 1.10 2002/09/24 23:19:55 hemna Exp $ |
8 |
* |
9 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
10 |
* @package phpHtmlLib |
11 |
* |
12 |
*/ |
13 |
|
14 |
/** |
15 |
* must have the BaseWidget |
16 |
*/ |
17 |
require_once( $phphtmllib."/widgets/BaseWidget.inc"); |
18 |
|
19 |
/** |
20 |
* Use this class to render footer navigation that |
21 |
* is displayed at the bottom of a page. |
22 |
* |
23 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
24 |
* @package phpHtmlLib |
25 |
*/ |
26 |
class FooterNav extends BaseWidget { |
27 |
|
28 |
/** |
29 |
* the company name for the copyright |
30 |
* statement. |
31 |
* |
32 |
* @access private |
33 |
* @var string |
34 |
*/ |
35 |
var $_company_name = ""; |
36 |
|
37 |
/** |
38 |
* The date string for the copyright |
39 |
* statement. In form of |
40 |
* "2001-1997", or "2001" |
41 |
* |
42 |
* @access private |
43 |
* @var string |
44 |
*/ |
45 |
var $_date_string = ""; |
46 |
|
47 |
/** |
48 |
* flag to tell us to render the |
49 |
* copyright string or not. |
50 |
* defaults to TRUE (or on) |
51 |
* |
52 |
* @access private |
53 |
* @var boolean |
54 |
*/ |
55 |
var $_render_copyright = TRUE; |
56 |
|
57 |
/** |
58 |
* url for the Legal statement. |
59 |
* if this is non-null, we will |
60 |
* render the "Legal Notice" link |
61 |
* in the copyright header. |
62 |
* |
63 |
* @access private |
64 |
* @var string |
65 |
*/ |
66 |
var $_legalnotice_url = NULL; |
67 |
|
68 |
/** |
69 |
* url for the privacy policy. |
70 |
* If this is non-null, we will |
71 |
* render the "Privacy Policy" link |
72 |
* in the copyright header. |
73 |
* |
74 |
* @access private |
75 |
* @var string |
76 |
*/ |
77 |
var $_privacypolicy_url = NULL; |
78 |
|
79 |
/** |
80 |
* email address to contact web site |
81 |
* maintainer. |
82 |
* |
83 |
* @access private |
84 |
* @var string |
85 |
*/ |
86 |
var $_webmaster_email = NULL; |
87 |
|
88 |
/** |
89 |
* Constructore for this class. |
90 |
* |
91 |
* @param string $company_name - used in the |
92 |
* - copyright |
93 |
* @param string $date_str - a date string to be used |
94 |
* for the copyright. |
95 |
*/ |
96 |
function FooterNav( $company_name="", $date_str=NULL ) { |
97 |
$this->set_company_name( $company_name ); |
98 |
if ($date_str==NULL) { |
99 |
$year = date("Y"); |
100 |
$this->set_date_string($year); |
101 |
} |
102 |
} |
103 |
|
104 |
|
105 |
|
106 |
/** |
107 |
* set the company name for the copyright |
108 |
* statement. |
109 |
* |
110 |
* @param string - $name |
111 |
*/ |
112 |
function set_company_name( $name ) { |
113 |
$this->_company_name = $name; |
114 |
} |
115 |
|
116 |
/** |
117 |
* set the date string for the copyright. |
118 |
* in the form of "2001-1997", or |
119 |
* "2001". |
120 |
* |
121 |
* @param string - $date_str |
122 |
*/ |
123 |
function set_date_string( $date_str ) { |
124 |
$this->_date_string = $date_str; |
125 |
} |
126 |
|
127 |
/** |
128 |
* set/unset the flag to tell us to |
129 |
* render the copyright string |
130 |
* |
131 |
* @param boolean - $flag |
132 |
*/ |
133 |
function set_copyright_flag( $flag ) { |
134 |
$this->_render_copyright = $flag; |
135 |
} |
136 |
|
137 |
/** |
138 |
* set the legal notice url. |
139 |
* if this is set we show the |
140 |
* legal notice link that points to $url. |
141 |
* |
142 |
* @param string - $url |
143 |
*/ |
144 |
function set_legalnotice_url( $url ) { |
145 |
$this->_legalnotice_url = $url; |
146 |
} |
147 |
|
148 |
/** |
149 |
* sets the Privacy policy url. |
150 |
* if this is set we show the |
151 |
* privacy policy link that points to $url |
152 |
* |
153 |
* @param string - $url |
154 |
*/ |
155 |
function set_privacypolicy_url( $url ) { |
156 |
$this->_privacypolicy_url = $url; |
157 |
} |
158 |
|
159 |
/** |
160 |
* sets the Webmaster email address |
161 |
* if this is set we show the |
162 |
* mailto for this email |
163 |
* |
164 |
* @param string - $email |
165 |
*/ |
166 |
function set_webmaster_email( $email ) { |
167 |
$this->_webmaster_email = $email; |
168 |
} |
169 |
|
170 |
|
171 |
/** |
172 |
* add an entry to the footer nav |
173 |
* |
174 |
* @param string - $url - url to go to |
175 |
* @param text - $text - url text to click on. |
176 |
*/ |
177 |
function add( $url, $text ) { |
178 |
$this->data[] = array( "type" => "url", "url" => $url, |
179 |
"text" => $text ); |
180 |
} |
181 |
|
182 |
|
183 |
/** |
184 |
* add an entry to the footer nav. |
185 |
* @deprecated |
186 |
* |
187 |
* @param string - $url - url to go to |
188 |
* @param text - $text - url text to click on. |
189 |
*/ |
190 |
function push( $url, $text ) { |
191 |
$this->add($url, $text); |
192 |
} |
193 |
|
194 |
|
195 |
|
196 |
//****************************************** |
197 |
//* rendering area |
198 |
//****************************************** |
199 |
|
200 |
|
201 |
/** |
202 |
* render the code for this widget. |
203 |
* |
204 |
* @param int - the indentation level for |
205 |
* the container. |
206 |
* @param int - the output debug flag to |
207 |
* maintain compatibility w/ the API. |
208 |
* |
209 |
* @return string the raw html output. |
210 |
*/ |
211 |
function render( $indent_level=1, $output_debug=0) { |
212 |
|
213 |
//build the wrapper table first. |
214 |
$table = $this->build_wrapper_table(); |
215 |
$div = html_div("links"); |
216 |
$count = count($this->data); |
217 |
if ($count) { |
218 |
$x=0; |
219 |
//now walk thru each item and render it. |
220 |
foreach( $this->data as $item ) { |
221 |
$a = html_a($item['url'], $item['text'], 'foot'); |
222 |
$x++; |
223 |
if ($x == $count) { |
224 |
$div->add($a, " "); |
225 |
} else { |
226 |
$div->add( $a, " | "); |
227 |
} |
228 |
} |
229 |
$table->add_row( $div ); |
230 |
} |
231 |
|
232 |
if ($this->_render_copyright) { |
233 |
$table->add_row( $this->build_copyright_header() ); |
234 |
|
235 |
} |
236 |
|
237 |
//add the Webmaster email link if Any |
238 |
if ($this->_webmaster_email) { |
239 |
$mailto = mailto($this->_webmaster_email); |
240 |
$mailto->set_class("notice"); |
241 |
$table->add_row( html_span("trademark", $mailto)); |
242 |
} |
243 |
|
244 |
return $table->render( $indent_level, $output_debug ); |
245 |
} |
246 |
|
247 |
/** |
248 |
* render the copyright string |
249 |
* |
250 |
* @return SPANtag object that |
251 |
* contains the copyright |
252 |
* header. |
253 |
*/ |
254 |
function build_copyright_header() { |
255 |
|
256 |
$span = html_span("trademark"); |
257 |
$string = "Copyright @"; |
258 |
$string .= $this->_date_string . ", "; |
259 |
$string .= $this->_company_name. ". All Rights Reserved. "; |
260 |
$span->add( $string ); |
261 |
|
262 |
//add the Legal notice if any |
263 |
if ($this->_legalnotice_url) { |
264 |
$span->add( html_a($this->_legalnotice_url, "Legal Notice", "notice"), |
265 |
" " ); |
266 |
} |
267 |
|
268 |
//add the Privacy notice if any |
269 |
if ($this->_privacypolicy_url) { |
270 |
$span->push( html_a($this->_privacypolicy_url, "Privacy Policy", "notice"), |
271 |
" " ); |
272 |
} |
273 |
|
274 |
return $span; |
275 |
} |
276 |
|
277 |
|
278 |
/** |
279 |
* builds the wrapper table |
280 |
* |
281 |
* @return TABLEtag object. |
282 |
*/ |
283 |
function build_wrapper_table() { |
284 |
$table = html_table($this->width, 0, 2, 0); |
285 |
$table->set_id("footernav"); |
286 |
$table->set_default_col_attributes( array("align" => "center") ); |
287 |
return $table; |
288 |
} |
289 |
} |
290 |
|
291 |
|
292 |
|
293 |
/** |
294 |
* This class defines the css used by the |
295 |
* FooterNav Object. |
296 |
* |
297 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
298 |
* @package phpHtmlLib |
299 |
*/ |
300 |
class FooterNavCSS extends CSSBuilder { |
301 |
|
302 |
function user_setup() { |
303 |
$this->add_entry("#footernav", NULL, |
304 |
array("font-family" => "arial,verdana,helvetica", |
305 |
"color" => "#4141FF") ); |
306 |
|
307 |
$this->add_entry("#footernav", "div.links", |
308 |
array("font-size" => "10px", |
309 |
"line-height" => "10px", |
310 |
"margin" => "15px 0px 10px 0px") ); |
311 |
|
312 |
$this->add_entry("#footernav","A.foot:active, A.foot:link, A.foot:visited", |
313 |
array("font-size" => "12px", |
314 |
"color" => "#4141FF") ); |
315 |
|
316 |
$this->add_entry("#footernav", "A.foot:hover", |
317 |
array("color" => "#FFFFFF", |
318 |
"background-color" => "#4141FF", |
319 |
"text-decoration" => "none") ); |
320 |
|
321 |
$this->add_entry("#footernav", "A.notice:active,A.notice:link,A.notice:visited", |
322 |
array("font-size" => "11px", |
323 |
"color" => "#4141FF") ); |
324 |
|
325 |
$this->add_entry("#footernav", "A.notice:hover", |
326 |
array("color" => "#FFFFFF", |
327 |
"background-color" => "#4141FF", |
328 |
"text-decoration" => "none") ); |
329 |
|
330 |
$this->add_entry("#footernav", "SPAN.trademark", |
331 |
array("font-size" => "11px", |
332 |
"color" => "#000000")); |
333 |
|
334 |
} |
335 |
} |
336 |
?> |