1 | <?php |
||
5 | class Safeurl |
||
6 | { |
||
7 | public $decode; // Decode html entities in string? |
||
8 | public $decode_charset; // Charset to use if $decode is set to true |
||
9 | public $lowercase; // Turns string into all lowercase letters |
||
10 | public $strip; // Strip out html tags from string? |
||
11 | public $maxlength; // Maximum length of resulting title |
||
12 | public $whole_word; // If maxlength is reached, chop at nearest whole word? or hard chop? |
||
13 | public $blank; // What title to use if no alphanumeric characters can be found |
||
14 | public $separator; // Allow a differnt character to be used as the separator. |
||
15 | public $translation_table; // A table of UTF-8 characters and what to make them. |
||
16 | |||
17 | /** |
||
18 | * Class constructor. |
||
19 | */ |
||
20 | public function __construct() |
||
30 | |||
31 | /** |
||
32 | * the worker method. |
||
33 | * |
||
34 | * @param string $text |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | public function make($text, $options = null) |
||
77 | |||
78 | /** |
||
79 | * Set user defined options. |
||
80 | * |
||
81 | * @param array $options |
||
82 | */ |
||
83 | private function setUserOptions($options) |
||
91 | |||
92 | /** |
||
93 | * Helper method that uses the translation table to convert |
||
94 | * non-ascii characters to a resonalbe alternative. |
||
95 | * |
||
96 | * @param string $text |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function convertCharacters($text) |
||
107 | |||
108 | /** |
||
109 | * Decode HTML entities and UTF-8 characters. |
||
110 | * |
||
111 | * @param string $text |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | private function decode($text) |
||
119 | |||
120 | /** |
||
121 | * Convert string to lowercase. |
||
122 | * |
||
123 | * @param string $text |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | private function lower($text) |
||
131 | |||
132 | /** |
||
133 | * Strip HTML tages. |
||
134 | * |
||
135 | * @param string $text |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | private function strip($text) |
||
143 | |||
144 | /** |
||
145 | * Strip anything that isn't alphanumeric or an underscore. |
||
146 | * |
||
147 | * @param string $text |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | private function filter($text) |
||
159 | } |
||
160 | |||
165 |