forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data.php
58 lines (53 loc) · 1.69 KB
/
Data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
class Kwc_Basic_LinkTag_Mail_Data extends Kwf_Component_Data
{
private $_linkRow;
private function _getLinkRow()
{
if (!isset($this->_linkRow)) {
$m = Kwc_Abstract::createOwnModel($this->componentClass);
$this->_linkRow = $m->getRow($this->dbId);
}
return $this->_linkRow;
}
public static function createHref($row, $spamProtect = true)
{
$ret = 'mailto:';
if ($spamProtect) {
$helper = new Kwf_View_Helper_MailLink();
$ret .= $helper->encodeMail($row->mail);
} else {
$ret .= $row->mail;
}
if ($row->text || $row->subject) $ret .= '?';
if ($row->subject) $ret .= 'subject='.$row->subject;
if ($row->text && $row->subject) $ret .= '&';
if ($row->text) $ret .= 'body='.$row->text;
return $ret;
}
public function getAbsoluteUrl()
{
$row = $this->_getLinkRow();
if (!$row || !$row->mail) return '';
return self::createHref($row, false);
}
public function __get($var)
{
if ($var == 'url') {
$row = $this->_getLinkRow();
if (!$row || !$row->mail) return '';
return self::createHref($row);
} else if ($var == 'url_mail_html') {
$row = $this->_getLinkRow();
if (!$row || !$row->mail) return '';
return self::createHref($row, false);
} else if ($var == 'url_mail_txt') {
$row = $this->_getLinkRow();
return ((!$row || !$row->mail) ? '' : $row->mail);
} else if ($var == 'rel') {
return '';
} else {
return parent::__get($var);
}
}
}