diff --git a/include/class.format.php b/include/class.format.php index e3f7b415a7553f6f77e6da85b31aff4d2c2f9ba5..ac9f94c3b42a9e5f1af87d196d0a2e24ac4fdacb 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -301,19 +301,19 @@ class Format { } //make urls clickable. Mainly for display - function clickableurls($text) { + function clickableurls($text, $trampoline=true) { global $ost; $token = $ost->getLinkToken(); // Find all text between tags $text = preg_replace_callback(':^[^<]+|>[^<]+:', - function($match) use ($token) { + function($match) use ($token, $trampoline) { // Scan for things that look like URLs return preg_replace_callback( '`(?<!>)(((f|ht)tp(s?)://|(?<!//)www\.)([-+~%/.\w]+)(?:[-?#+=&;%@.\w]*)?)' .'|(\b[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})`', - function ($match) use ($token) { + function ($match) use ($token, $trampoline) { if ($match[1]) { while (in_array(substr($match[1], -1), array('.','?','-',':',';'))) { @@ -323,9 +323,13 @@ class Format { if (strpos($match[2], '//') === false) { $match[1] = 'http://' . $match[1]; } - return '<a href="l.php?url='.urlencode($match[1]) - .sprintf('&auth=%s" target="_blank">', $token) - .$match[1].'</a>'.$match[9]; + if ($trampoline) + return '<a href="l.php?url='.urlencode($match[1]) + .sprintf('&auth=%s" target="_blank">', $token) + .$match[1].'</a>'.$match[9]; + else + return sprintf('<a href="%s">%s</a>%s', + $match[1], $match[1], $match[9]); } elseif ($match[6]) { return sprintf('<a href="mailto:%1$s" target="_blank">%1$s</a>', $match[6]); diff --git a/include/class.pdf.php b/include/class.pdf.php index 404e4dd7bd942ad0114a919fe0efec83d1c83a28..5e58a80a51e1a9125aeddaf89e86fb62792ec6eb 100644 --- a/include/class.pdf.php +++ b/include/class.pdf.php @@ -293,7 +293,7 @@ class Ticket2PDF extends mPDF $this->WriteCell($w, 7, Format::truncate($entry['title'], 50), 'TB', 0, 'L', true); $this->WriteCell($w/2, 7, $entry['name'] ?: $entry['poster'], 'TBR', 1, 'L', true); $this->SetFont(''); - $text= $entry['body']; + $text = $entry['body']->display('pdf'); if($entry['attachments'] && ($tentry=$ticket->getThreadEntry($entry['id'])) && ($attachments = $tentry->getAttachments())) { diff --git a/include/class.thread.php b/include/class.thread.php index f1eb94064f0697a841d969eb6770045eb6116184..367ed530bee7390d71e16dd2a2f77917c9cb9b33 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1272,15 +1272,20 @@ class ThreadBody /* extends SplString */ { return !$this->body || $this->body == '-'; } - function display() { + function display($output=false) { if ($this->isEmpty()) return '(empty)'; switch (strtolower($this->type)) { - case 'text': - return '<div style="white-space:pre-wrap">'.$this->body.'</div>'; - case 'html': + case 'text': + return '<div style="white-space:pre-wrap">'.$this->body.'</div>'; + case 'html': + switch ($output) { + case 'pdf': + return Format::clickableurls($this->body, false); + default: return Format::display($this->body); + } } }