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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (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.4: +62 -35 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2
3 /**
4 * This contains the TextNav widget
5 *
6 * $Id: TextCSSNav.inc,v 1.17 2004/03/03 22:02:05 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 TextCSSNav extends BaseWidget {
25
26 /**
27 * Flag to tell us that we can
28 * highlight (css) the selected
29 * link.
30 *
31 * This is off by default
32 */
33 var $_highlight_selected = FALSE;
34
35 /**
36 * Holds which one is auto selected
37 *
38 */
39 var $_selected = 0;
40
41 /**
42 * the prefix for the query string var
43 * so we can have multiple widgets
44 * on the same page and have them
45 * operate independantly
46 */
47 var $_query_prefix = "";
48
49
50 /**
51 * Constructor for this class
52 * It just sets the width for the
53 * widget.
54 *
55 * @param int $width - the width of the widget
56 */
57 function TextCSSNav($highlight_selected=FALSE) {
58 $this->_highlight_selected = $highlight_selected;
59 }
60
61 /**
62 * function that will render the widget.
63 *
64 * @param int - the indentation level for
65 * the container.
66 * @param int - the output debug flag to
67 * maintain compatibility w/ the API.
68 *
69 * @return string the raw html output.
70 */
71 function render( $indent_level=1, $output_debug=0) {
72 $this->_selected = @$_REQUEST[$this->_query_prefix."textcssnavselected"];
73 $div = html_div("textnav", $this->_build_links());
74 return $div->render( $indent_level, $output_debug );
75 }
76
77
78 /**
79 * This method is used to set the prefix for
80 * the widget so someone can have multiple
81 * widgets on the same page and have them
82 * operate independantly
83 *
84 * @param string - the prefix for the query var
85 */
86 function set_prefix( $prefix ) {
87 $this->_query_prefix = $prefix;
88 }
89
90
91 //functions for adding/updating data
92
93 /**
94 * this function adds a clickable link.
95 * It automatically adds the link based on $url,
96 * with $text as the viewable text.
97 *
98 * @param string - the url for the link
99 * @param string - the link text
100 * @param string - the title text
101 * @param string - the link target
102 */
103 function add($url, $text, $title="", $target="", $selected=FALSE) {
104 array_push($this->data, array("type"=>"url", "url"=>$url,
105 "text"=>$text, "title"=>$title,
106 "target"=>$target,
107 "selected"=> $selected));
108 }
109
110 /**
111 * depricated version of add()
112 *
113 * @deprecated - use add() instead
114 */
115 function push($url, $text, $title="", $target="") {
116 $this->add($url, $text, $title);
117 }
118
119 /**
120 * This lets you add a blank entry
121 * between 2 links
122 *
123 * @param int - the # of blank lines to insert
124 */
125 function add_blank( $num = 1 ) {
126 for ($x=1; $x<=$num; $x++)
127 array_push($this->data, array( "type"=>"blank" ));
128 }
129
130 /**
131 * depricated version of add_blank()
132 *
133 * @deprecated - use add_blank() instead
134 */
135 function push_blank( $num = 1 ) {
136 $this->add_blank( $num );
137 }
138
139 /**
140 * this adds a text item in the nav
141 *
142 * @param string - the text to display
143 */
144 function add_text( $text ) {
145 array_push($this->data, array( "type"=>"text", "text"=>$text ));
146 }
147
148 /**
149 * depricated version of add_text()
150 *
151 * @deprecated - use add_text() instead
152 */
153 function push_text( $text ) {
154 $this->add_text( $text );
155 }
156
157
158 /**
159 * This function is used to build the links
160 * to click on
161 *
162 * @return Container
163 */
164 function _build_links() {
165 $container = container();
166 $container->set_collapse();
167
168 $is_first = TRUE;
169 $cnt = 1;
170 foreach( $this->data as $nav ) {
171 switch ($nav["type"]) {
172 case 'url':
173 $url = $nav["url"];
174 if ($this->_highlight_selected) {
175 if (!strstr($url, "?")) {
176 $url .= "?";
177 }
178 $url .= "&".$this->_query_prefix."textcssnavselected=".$cnt;
179 }
180 $obj = html_a(htmlentities($url), $nav["text"], "normal", $nav["target"], $nav["title"]);
181
182 $is_selected = $this->_highlight_selected && ($this->_selected == $cnt || $nav["selected"]);
183 $class = $is_selected ? "selected" : "";
184 if ($is_first) {
185 $class .= "first";
186 }
187 if ($is_selected || $is_first) {
188 $obj->set_class( $class );
189 }
190 $is_first = FALSE;
191 $cnt++;
192 break;
193 case "blank":
194 $obj = "&nbsp;";
195 break;
196 }
197 $container->push( $obj );
198 }
199
200 return $container;
201 }
202 }
203
204 /**
205 * This class defines the css used by the
206 * FooterNav Object.
207 *
208 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
209 * @package phpHtmlLib
210 */
211 class TextCSSNavCSS extends CSSBuilder {
212
213 function user_setup() {
214 $this->add_entry(".textnav", "",
215 array(
216 "margin" => "0px 0px 0px 0px",
217 "padding" => "3px 0px 0px 0px",
218 "height" => "16px",
219 "color" => "#FFFFFF",
220 "font-famiy" => "sans-serif",
221 "font-size" => "11px",
222 "font-weight" => "bold",
223 ) );
224
225 $this->add_entry(".textnav", "a.normal,a.normal:visited,a.normal:active",
226 array("font-family" => "sans-serif",
227 "text-decoration" => "none",
228 "color" => "#FFFFFF",
229 "background-color" => "#999999",
230 "padding" => "2px 4px 2px 4px",
231 "border-right" => "1px solid #828282",
232 "border-top" => "1px solid #828282",
233 "border-bottom" => "1px solid #828282"
234 ) );
235
236 $this->add_entry(".textnav", "a.first,a.first:visited",
237 array("font-family" => "sans-serif",
238 "text-decoration" => "none",
239 "color" => "#FFFFFF",
240 "background-color" => "#999999",
241 "padding" => "2px 4px 2px 4px",
242 "border-left" => "1px solid #828282",
243 "border-right" => "1px solid #828282",
244 "border-top" => "1px solid #828282",
245 "border-bottom" => "1px solid #828282") );
246
247 $this->add_entry(".textnav", "a.normal:hover,a.first:hover",
248 array("color" => "#000000",
249 "background-color" => "#EEEEEE",
250 "text-decoration" => "none"));
251
252 $this->add_entry(".textnav", "a.selected,a.selected:visited",
253 array("font-family" => "sans-serif",
254 "text-decoration" => "none",
255 "color" => "#828282",
256 "background-color" => "#EEEEEE",
257 "padding" => "2px 4px 2px 4px",
258 "border-right" => "1px solid #828282",
259 "border-top" => "1px solid #828282",
260 "border-bottom" => "1px solid #828282"
261 ) );
262
263 $this->add_entry(".textnav", "a.selectedfirst,a.selectedfirst:visited",
264 array("font-family" => "sans-serif",
265 //"font-size" => "12px",
266 "font-weight" => "bold",
267 "text-decoration" => "none",
268 "color" => "#828282",
269 "background-color" => "#EEEEEE",
270 "padding" => "2px 4px 2px 4px",
271 "border-left" => "1px solid #828282",
272 "border-top" => "1px solid #828282",
273 "border-bottom" => "1px solid #828282") );
274 }
275 }
276 ?>

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