1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Help class for handling links that could contain
4 * chars that would break Kohanas routing ('/')
9 * Encode a string so that it is possible to
10 * use it without risk in Kohana.
11 * The 'all' string has been given a special meaning
12 * and is therefore not encoded.
14 * @return str encoded string
16 public function encode($str)
19 if (strtolower($str) == 'all') {
22 return rawurlencode(base64_encode($str));
26 * Decode a string that has been encoded
27 * using the encode method.
28 * The 'all' string has been given a special meaning
29 * and is therefore not decoded.
31 * @return decoded string
33 public function decode($str)
36 if (strtolower($str) == 'all') {
39 return rawurldecode(base64_decode($str));
43 * Primitively 'detect' URI:s in a text and wrap
44 * in a html anchor element.
49 public static function linkify($text) {
50 return preg_replace('~((ftp|https?)://[^ ]+)~', '<a target="'.config
::get('nagdefault.notes_url_target', '*').'" href="$1">$1</a>', $text);