1: <?php
2:
3: /**
4: * Document for class GeoLink
5: *
6: * PHP Version 5.6
7: *
8: * @category Class
9: * @package Geolib
10: * @author Peter Pitchford <peter@geotonics.com>
11: * @license GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
12: * @link http://geotonics.com/#geolib
13: */
14:
15: /**
16: * Geo - Class to create HTML a tags
17: *
18: * @category Html_Tag
19: * @package Geolib
20: * @author Peter Pitchford <peter@geotonics.com>
21: * @license GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
22: * @version Release: .1
23: * @link http://geotonics.com/#geolib
24: * @since Class available since Release .1
25: */
26: class GeoLink extends GeoTag
27: {
28: private $target;
29: private $onmouseover;
30: private $onmouseout;
31:
32: /**
33: * Set attributes of html a tag
34: *
35: * @param string $link href path of link
36: * @param string $text Text of link
37: * If text has html tags, then you need to add a (non html) text title so the the title does not have html
38: * @param string $title title of link
39: * @param string $target target of link
40: * @param string $class class of link
41: * @param string $id id of link
42: * @param string $atts any other atts of link
43: * @param string $style style of link
44: *
45: * title is later in the list because its usually the same as $text
46: */
47: public function __construct(
48: $link = null,
49: $text = null,
50: $title = null,
51: $target = null,
52: $class = null,
53: $id = null,
54: $atts = null,
55: $style = null
56: ) {
57:
58: $this->setLink($link);
59: $this->setAtt("target", $target);
60:
61: if ($atts && !is_array($atts)) {
62: $attsarr = explode("=", $atts);
63: $newatts[$attsarr[0]] = $attsarr[1];
64: $atts = $newatts;
65: }
66:
67: $this->init('a', $text, $class, $id, $style, $atts);
68: $this->setTitle($title);
69:
70: }
71:
72: /**
73: * Set href of link
74: *
75: * @param string $link href of link
76: *
77: * @return void
78: */
79: public function setLink($link)
80: {
81: $this->setAtt('href', $link);
82: }
83:
84: /**
85: * Set title of link
86: *
87: * @param string $title title of link
88: *
89: * @return void
90: */
91: public function setTitle($title)
92: {
93:
94: if (!$title) {
95: $title = $this->text;
96: } elseif ($title === true) {
97: $title = "";
98: }
99: $this->setAtt('title', htmlentities($title));
100:
101: }
102:
103: /**
104: * Set text of link
105: *
106: * @param string $text text of link
107: *
108: * @return void
109: */
110: public function setText($text)
111: {
112: if ($text) {
113: $this->text = $text;
114: } else {
115: $this->text = $this->atts['href'];
116: }
117: }
118:
119: /**
120: * HTML a tag
121: *
122: * @param string $link href of link
123: * @param string $text text of link
124: * @param string $title title of link
125: *
126: * @return html a tag
127: */
128: public function tag($link = null, $text = null, $title = null)
129: {
130: if ($title) {
131: $this->setTitle($title);
132: }
133:
134: if ($link) {
135: $this->setLink($link);
136: }
137:
138: if ($text) {
139: $this->setText($text);
140: }
141: //$this->setTitle();
142: return parent::baseTag();
143: }
144: }
145: