| 1 |
jonen |
1.1 |
<?php |
| 2 |
|
|
|
| 3 |
|
|
/** |
| 4 |
|
|
* This contains the VerticalCSSNavTable widget |
| 5 |
|
|
* |
| 6 |
jonen |
1.3 |
* $Id: VerticalCSSNavTable.inc,v 1.10 2003/01/14 22:44:07 hemna 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 nice table |
| 20 |
|
|
* that conains clickable cells. |
| 21 |
|
|
* |
| 22 |
|
|
* --------------------- |
| 23 |
|
|
* | TITLE | |
| 24 |
|
|
* --------------------- |
| 25 |
|
|
* | SUBTITLE | |
| 26 |
|
|
* --------------------- |
| 27 |
|
|
* | link 1 | |
| 28 |
|
|
* --------------------- |
| 29 |
|
|
* | link 2 | |
| 30 |
|
|
* --------------------- |
| 31 |
|
|
* |
| 32 |
|
|
* |
| 33 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
| 34 |
|
|
* @package phpHtmlLib |
| 35 |
|
|
*/ |
| 36 |
|
|
class VerticalCSSNavTable extends BaseWidget { |
| 37 |
|
|
|
| 38 |
|
|
/** |
| 39 |
|
|
* the subtitle if any |
| 40 |
|
|
* |
| 41 |
|
|
* @var string |
| 42 |
|
|
*/ |
| 43 |
|
|
var $_subtitle = ""; |
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
/** |
| 47 |
|
|
* Holds the outer table object |
| 48 |
|
|
* |
| 49 |
|
|
* @var TABLEtag object |
| 50 |
|
|
*/ |
| 51 |
|
|
var $_table = NULL; |
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
/** |
| 55 |
|
|
* Constructor for this class |
| 56 |
|
|
* It just sets the width for the |
| 57 |
|
|
* widget. |
| 58 |
|
|
* |
| 59 |
|
|
* @param int $width - the width of the widget |
| 60 |
|
|
*/ |
| 61 |
|
|
function VerticalCSSNavTable($title, $subtitle="", $width="100%" ) { |
| 62 |
|
|
$this->set_title( $title ); |
| 63 |
|
|
$this->set_subtitle( $subtitle ); |
| 64 |
|
|
$this->set_width( $width ); |
| 65 |
|
|
} |
| 66 |
|
|
|
| 67 |
|
|
/** |
| 68 |
|
|
* function that will render the widget. |
| 69 |
|
|
* |
| 70 |
|
|
* @param int - the indentation level for |
| 71 |
|
|
* the container. |
| 72 |
|
|
* @param int - the output debug flag to |
| 73 |
|
|
* maintain compatibility w/ the API. |
| 74 |
|
|
* |
| 75 |
|
|
* @return string the raw html output. |
| 76 |
|
|
*/ |
| 77 |
|
|
function render( $indent_level=1, $output_debug=0) { |
| 78 |
|
|
|
| 79 |
|
|
$this->_table = html_table( $this->get_width() ); |
| 80 |
|
|
$this->_table->set_class("verticalcssnav"); |
| 81 |
|
|
|
| 82 |
|
|
$this->_build_title(); |
| 83 |
|
|
|
| 84 |
|
|
$this->_build_links(); |
| 85 |
|
|
|
| 86 |
|
|
return $this->_table->render( $indent_level, $output_debug ); |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
/** |
| 91 |
|
|
* This sets the subtitle |
| 92 |
|
|
* |
| 93 |
|
|
* @param string - the subtitle |
| 94 |
|
|
*/ |
| 95 |
|
|
function set_subtitle( $subtitle ) { |
| 96 |
|
|
$this->_subtitle = $subtitle; |
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
|
|
/** |
| 100 |
|
|
* This function returns the current |
| 101 |
|
|
* subtitle. |
| 102 |
|
|
* |
| 103 |
|
|
* @return string - the subtitle |
| 104 |
|
|
*/ |
| 105 |
|
|
function get_subtitle() { |
| 106 |
|
|
return $this->_subtitle; |
| 107 |
|
|
} |
| 108 |
|
|
|
| 109 |
|
|
|
| 110 |
|
|
//functions for adding/updating data |
| 111 |
|
|
|
| 112 |
|
|
/** |
| 113 |
|
|
* this function adds a clickable link. |
| 114 |
|
|
* It automatically adds the link based on $url, |
| 115 |
|
|
* with $text as the viewable text. |
| 116 |
|
|
* |
| 117 |
|
|
* @param string - the url for the link |
| 118 |
|
|
* @param string - the link text |
| 119 |
|
|
* @param string - the title text |
| 120 |
|
|
* @param string - the link target |
| 121 |
|
|
*/ |
| 122 |
|
|
function add($url, $text, $title="", $target="") { |
| 123 |
|
|
array_push($this->data, array("type"=>"url", "url"=>$url, |
| 124 |
|
|
"text"=>$text, "title"=>$title, |
| 125 |
|
|
"target"=>$target)); |
| 126 |
|
|
} |
| 127 |
|
|
|
| 128 |
|
|
/** |
| 129 |
|
|
* this adds a text item in the nav |
| 130 |
|
|
* |
| 131 |
|
|
* @param string - the text to display |
| 132 |
|
|
*/ |
| 133 |
|
|
function add_text( $text ) { |
| 134 |
|
|
array_push($this->data, array( "type"=>"text", "text"=>$text )); |
| 135 |
|
|
} |
| 136 |
|
|
|
| 137 |
|
|
|
| 138 |
|
|
/** |
| 139 |
|
|
* This function builds the title tr |
| 140 |
|
|
* |
| 141 |
|
|
*/ |
| 142 |
|
|
function _build_title() { |
| 143 |
|
|
$caption = html_caption( $this->get_title() ); |
| 144 |
|
|
$this->_table->add( $caption ); |
| 145 |
|
|
} |
| 146 |
|
|
|
| 147 |
|
|
/** |
| 148 |
|
|
* This function builds the subtitle |
| 149 |
|
|
* if needed. |
| 150 |
|
|
*/ |
| 151 |
|
|
function _build_subtitle() { |
| 152 |
|
|
|
| 153 |
|
|
$subtitle = $this->get_subtitle(); |
| 154 |
|
|
if ($subtitle != "") { |
| 155 |
|
|
$div = html_div(); |
| 156 |
|
|
$div->set_class( "subtitle" ); |
| 157 |
|
|
$div->add( $this->get_subtitle() ); |
| 158 |
|
|
return $div; |
| 159 |
|
|
} else { |
| 160 |
|
|
return NULL; |
| 161 |
|
|
} |
| 162 |
|
|
} |
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
/** |
| 166 |
|
|
* This function is used to build the links |
| 167 |
|
|
* to click on |
| 168 |
|
|
* |
| 169 |
|
|
* @return Container |
| 170 |
|
|
*/ |
| 171 |
|
|
function _build_links() { |
| 172 |
|
|
$container = container(); |
| 173 |
|
|
|
| 174 |
|
|
$container->push( $this->_build_subtitle() ); |
| 175 |
|
|
|
| 176 |
|
|
foreach( $this->data as $nav ) { |
| 177 |
|
|
switch ($nav["type"]) { |
| 178 |
|
|
case 'url': |
| 179 |
|
|
$a = html_a($nav["url"], $nav["text"], "", $nav["target"], $nav["title"]); |
| 180 |
|
|
$a->set_class("navurl"); |
| 181 |
|
|
$container->add( $a ); |
| 182 |
|
|
break; |
| 183 |
|
|
case "text": |
| 184 |
|
|
$div = html_div("",$nav["text"]); |
| 185 |
|
|
|
| 186 |
|
|
$container->add($div); |
| 187 |
|
|
break; |
| 188 |
|
|
} |
| 189 |
|
|
|
| 190 |
|
|
} |
| 191 |
|
|
|
| 192 |
|
|
$this->_table->add_row( $container ); |
| 193 |
|
|
|
| 194 |
|
|
return $container; |
| 195 |
|
|
} |
| 196 |
|
|
|
| 197 |
|
|
} |
| 198 |
|
|
|
| 199 |
|
|
/** |
| 200 |
|
|
* This class defines the css used by the |
| 201 |
|
|
* VerticalCSSNavTable Object. |
| 202 |
|
|
* |
| 203 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
| 204 |
|
|
* @package phpHtmlLib |
| 205 |
|
|
*/ |
| 206 |
|
|
class VerticalCSSNavTableCSS extends CSSBuilder { |
| 207 |
|
|
|
| 208 |
|
|
function user_setup() { |
| 209 |
|
|
$this->add_entry(".verticalcssnav", NULL, |
| 210 |
|
|
array("vertical-align" => "top", |
| 211 |
|
|
"font-family" => "arial, helvetica, sans-serif") ); |
| 212 |
|
|
|
| 213 |
|
|
$this->add_entry(".verticalcssnav", "caption", |
| 214 |
|
|
array("font-size" => "10pt", |
| 215 |
|
|
"font-weight" => "bold", |
| 216 |
|
|
"color" => "#FFFFFF", |
| 217 |
|
|
"background-color" => "#999999", |
| 218 |
|
|
"border" => "1px solid #999999")); |
| 219 |
|
|
|
| 220 |
|
|
$this->add_entry(".verticalcssnav", "div", |
| 221 |
|
|
array("font-size" => "8pt", |
| 222 |
|
|
"color" => "#000000", |
| 223 |
|
|
"padding" => "2px 4px 2px 4px", |
| 224 |
|
|
"border-right" => "1px solid #999999", |
| 225 |
|
|
"border-left" => "1px solid #999999", |
| 226 |
|
|
"border-bottom" => "1px solid #999999")); |
| 227 |
|
|
|
| 228 |
|
|
$this->add_entry(".verticalcssnav", "div.subtitle", |
| 229 |
|
|
array("font-size" => "10pt", |
| 230 |
|
|
"font-weight" => "bold", |
| 231 |
|
|
"color" => "#777777", |
| 232 |
|
|
"background-color" => "#eeeeee", |
| 233 |
|
|
"text-align" => "center")); |
| 234 |
|
|
|
| 235 |
|
|
$this->add_entry(".verticalcssnav", "a.navurl:active,a.navurl:link,a.navurl:visited", |
| 236 |
|
|
array("display" => "block", |
| 237 |
jonen |
1.3 |
"font-family" => "arial, verdana, helvetica, sans-serif", |
| 238 |
jonen |
1.2 |
"font-size" => "10pt", |
| 239 |
jonen |
1.1 |
"padding" => "2px 4px 2px 4px", |
| 240 |
|
|
"text-decoration" => "none", |
| 241 |
|
|
"color" => "#000000", |
| 242 |
|
|
"background-color" => "#FFFFFF", |
| 243 |
|
|
"border-bottom" => "1px solid #999999", |
| 244 |
|
|
"border-right" => "1px solid #999999", |
| 245 |
|
|
"border-left" => "1px solid #999999")); |
| 246 |
|
|
|
| 247 |
|
|
$this->add_entry(".verticalcssnav", "a.navurl:hover", |
| 248 |
|
|
array("color" => "#000000", |
| 249 |
|
|
"background-color" => "#eeeeee")); |
| 250 |
|
|
|
| 251 |
|
|
|
| 252 |
|
|
} |
| 253 |
|
|
} |
| 254 |
|
|
?> |