configured
[bMailZu.git] / lib / Link.class.php
blob049f62fc0487e4c97d2962346fad9ea27ac6638f
1 <?php
2 /**
3 * XHTML link class
4 * Creates or prints an XHTML valid link
5 * @author Nick Korbel <lqqkout13@users.sourceforge.net>
6 * @version 01-20-05
7 * @package Link
9 * Copyright (C) 2003 - 2005 phpScheduleIt
10 * License: GPL, see LICENSE
13 class Link {
14 var $url;
15 var $text;
16 var $_class;
17 var $style;
18 var $text_on_over;
19 var $img_src;
20 var $img_alt;
22 /**
23 * Link Constructor
24 * Creates a new XHTML valid link
25 * @param string $url url to link to
26 * @param string $text text of link
27 * @param string $class link class
28 * @param string $style inline style of link (overrides class)
29 * @param string $text_on_over text to display in status bar onmouseover
30 * @param string $on_over javascript to call onmouseover
32 function Link($url=null, $text=null, $class=null, $style=null, $text_on_over=null) {
33 $this->url = $url;
34 $this->text = $text;
35 $this->_class = $class;
36 $this->style = $style;
37 $this->text_on_over = addslashes($text_on_over);
40 //---------------------------------------------
41 // Setter functions
42 //---------------------------------------------
43 /**
44 * Set the url of the link
45 * @param string $url url to link to
47 function setUrl($url) {
48 $this->url = $url;
51 /**
52 * Set the text of the link
53 * @param string $text text of link
55 function setText($text) {
56 $this->text = $text;
59 /**
60 * Set the class of the link
61 * @param string $class link class
63 function setClass($class) {
64 $this->_class = $class;
67 /**
68 * Set the inline style of the link
69 * @param string $style inline style of link (overrides class)
71 function setStyle($style) {
72 $this->style = $style;
75 /**
76 * Set the text onmouseover
77 * @param string $text_on_over text to display in status bar onmouseover
79 function setTextOnOver($text_on_over) {
80 $this->text_on_over = addslashes($text_on_over);
83 /**
84 * Set the image source "src" property
85 * @param string $img_src image source property
87 function setImgSrc($img_src) {
88 $this->img_src = $img_src;
91 /**
92 * Set the image alt property
93 * @param string $img_alt image alt property
95 function setImgAlt($img_alt) {
96 $this->img_alt = $img_alt;
99 //=============================================
102 //---------------------------------------------
103 // Getter functions
104 //---------------------------------------------
106 * Return the url of the link
107 * @return string $url url to link to
109 function getUrl() {
110 return $this->url;
114 * Return the text of the link
115 * @return string $text text of link
117 function getText() {
118 return $this->text;
122 * Return the class of the link
123 * @return string $class link class
125 function getClass() {
126 return $this->_class;
130 * Return the inline style of the link
131 * @return string $style inline style of link (overrides class)
133 function getStyle() {
134 return $this->style;
138 * Return the text onmouseover
139 * @return string $text_on_over text to display in status bar onmouseover
141 function getTextOnOver() {
142 return stripslashes($this->text_on_over);
146 * Return the image source "src" property
147 * @return string
149 function getImgSrc() {
150 return $img_src;
154 * Return the image alt property
155 * @return string
157 function getImgAlt() {
158 return $img_alt;
161 //=============================================
165 * Print out a link without creating a new Link object
166 * @param string $url url to link to
167 * @param string $text text of link
168 * @param string $class link class
169 * @param string $style inline style of link (overrides class)
170 * @param string $text_on_over text to display in status bar onmouseover
172 function doLink($url=null, $text=null, $class=null, $style=null, $text_on_over=null, $boldtext=null) {
173 echo $this->getLink($url, $text, $class, $style, $text_on_over, $boldtext);
177 * Print out an image link without creating a new Link obejct
178 * @param string $url url to link to
179 * @param string $img_src image source "src" property
180 * @param string $alt image alt property
181 * @param string $text_on_over text to display in status bar onmouseover
183 function doImageLink($url = null, $img_src = null, $alt = null, $text_on_over = null) {
184 echo $this->getImageLink($url, $img_src, $alt, $text_on_over);
188 * Prints out the link using the class values
189 * @param none
190 * @see doLink()
192 function printLink() {
193 $this->doLink($this->url, $this->text, $this->_class, $this->style, $this->text_on_over);
197 * Returns the HTML for the link with given parameters
198 * @param string $url url to link to
199 * @param string $text text of link
200 * @param string $class link class
201 * @param string $style inline style of link (overrides class)
202 * @param string $text_on_over text to display in status bar onmouseover
203 * @return string of HTML for link
205 function getLink($url=null, $text=null, $class=null, $style=null, $text_on_over=null, $boldtext=null) {
206 $text_on_over = (!is_null($text_on_over)) ? $text_on_over : $text; // Use passed in text on mouse over, else just use link text
207 //return "<a href=\"$url\" class=\"$class\" style=\"$style\" onmouseover=\"javascript: window.status='" . addslashes($text_on_over) . "'; return true;\" onmouseout=\"javascript: window.status=''; return true;\">$text</a>";
208 return "<a href=\"$url\" class=\"$class\" style=\"$style\" onmouseover=\"javascript: window.status='" . addslashes($text_on_over) . "'; return true;\" onmouseout=\"javascript: window.status=''; return true;\">" . ($boldtext ? "<b>$text</b>" : $text) . "</a>";
212 * Returns the HTML for the link with given parameters
213 * @param string $url url to link to
214 * @param string $img_src image source "src" property
215 * @param string $alt image alt property
216 * @param string $text_on_over text to display in status bar onmouseover
218 function getImageLink($url = null, $img_src = null, $alt = null, $text_on_over = null) {
219 $text_on_over = (!is_null($text_on_over)) ? $text_on_over : $alt; // Use passed in text on mouse over, else just use link text
220 return "<a href=\"$url\" onmouseover=\"javascript: window.status='" . addslashes($text_on_over) . "'; return true;\" onmouseout=\"javascript: window.status=''; return true;\"><img src=\"$img_src\" alt=\"$alt\" title=\"$alt\" border=\"0\"/></a>\n";