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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Mon Feb 3 15:59:58 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
CVS Tags: v2-1-3
Changes since 1.1: +2 -2 lines
+ resized font size from '8pt' to '10pt'

1 jonen 1.1 <?php
2    
3     /**
4     * This contains the TextNav widget
5     *
6 jonen 1.2 * $Id: TextCSSNav.inc,v 1.1.1.1 2003/01/30 03:29:44 jonen Exp $
7 jonen 1.1 *
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     }
108    
109     /**
110     * depricated version of add()
111     *
112     * @deprecated - use add() instead
113     */
114     function push($url, $text, $title="", $target="") {
115     $this->add($url, $text, $title);
116     }
117    
118     /**
119     * This lets you add a blank entry
120     * between 2 links
121     *
122     * @param int - the # of blank lines to insert
123     */
124     function add_blank( $num = 1 ) {
125     for ($x=1; $x<=$num; $x++)
126     array_push($this->data, array( "type"=>"blank" ));
127     }
128    
129     /**
130     * depricated version of add_blank()
131     *
132     * @deprecated - use add_blank() instead
133     */
134     function push_blank( $num = 1 ) {
135     $this->add_blank( $num );
136     }
137    
138     /**
139     * this adds a text item in the nav
140     *
141     * @param string - the text to display
142     */
143     function add_text( $text ) {
144     array_push($this->data, array( "type"=>"text", "text"=>$text ));
145     }
146    
147     /**
148     * depricated version of add_text()
149     *
150     * @deprecated - use add_text() instead
151     */
152     function push_text( $text ) {
153     $this->add_text( $text );
154     }
155    
156    
157     /**
158     * This function is used to build the links
159     * to click on
160     *
161     * @return Container
162     */
163     function _build_links() {
164     $container = container();
165     $container->set_collapse();
166    
167     $class = "first";
168     $cnt = 1;
169     foreach( $this->data as $nav ) {
170     switch ($nav["type"]) {
171     case 'url':
172     $url = $nav["url"];
173     if ($this->_highlight_selected) {
174     if (!strstr($url, "?")) {
175     $url .= "?";
176     }
177     $url .= "&".$this->_query_prefix."textcssnavselected=".$cnt;
178     }
179     $obj = html_a($url, $nav["text"], "", $nav["target"], $nav["title"]);
180     if ($class != NULL) {
181     if ($this->_highlight_selected && $this->_selected == $cnt) {
182     $class = "selected".$class;
183     }
184     $obj->set_class( $class );
185     $class = NULL;
186     } else {
187     if ($this->_highlight_selected && $this->_selected == $cnt) {
188     $obj->set_class( "selected" );
189     }
190     }
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", "div",
215     array("margin" => "0px 0px 0px 0px") );
216    
217     $this->add_entry(".textnav", "a",
218     array("font-family" => "sans-serif",
219 jonen 1.2 "font-size" => "10pt",
220 jonen 1.1 "font-weight" => "bold",
221     "text-decoration" => "none",
222     "color" => "#FFFFFF",
223     "background-color" => "#999999",
224     "padding" => "4px 4px 4px 4px",
225     "border-right" => "1px solid #828282",
226     "border-top" => "1px solid #828282",
227     "border-bottom" => "1px solid #828282") );
228    
229     $this->add_entry(".textnav", "a.first",
230     array("border-left" => "1px solid #828282") );
231    
232     $this->add_entry(".textnav", "a.selected",
233     array("color" => "#828282",
234     "background-color" => "#EEEEEE") );
235    
236     $this->add_entry(".textnav", "a.selectedfirst",
237     array("color" => "#828282",
238     "background-color" => "#EEEEEE",
239     "border-left" => "1px solid #828282") );
240    
241    
242     $this->add_entry(".textnav", "a:hover",
243     array("color" => "#000000",
244     "background-color" => "#EEEEEE"));
245    
246    
247     }
248     }
249     ?>

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