4 * Creates or prints an XHTML valid link
5 * @author Nick Korbel <lqqkout13@users.sourceforge.net>
9 * Copyright (C) 2003 - 2005 phpScheduleIt
10 * License: GPL, see LICENSE
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) {
35 $this->_class
= $class;
36 $this->style
= $style;
37 $this->text_on_over
= addslashes($text_on_over);
40 //---------------------------------------------
42 //---------------------------------------------
44 * Set the url of the link
45 * @param string $url url to link to
47 function setUrl($url) {
52 * Set the text of the link
53 * @param string $text text of link
55 function setText($text) {
60 * Set the class of the link
61 * @param string $class link class
63 function setClass($class) {
64 $this->_class
= $class;
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;
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);
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;
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 //---------------------------------------------
104 //---------------------------------------------
106 * Return the url of the link
107 * @return string $url url to link to
114 * Return the text of the link
115 * @return string $text text of link
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() {
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
149 function getImgSrc() {
154 * Return the image alt property
157 function getImgAlt() {
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
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";