1 | <?php |
||
10 | trait Strings |
||
11 | { |
||
12 | /** |
||
13 | * Encrypt string |
||
14 | * |
||
15 | * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is |
||
16 | * important for you, then use a purpose built package. https://github.com/defuse/php-encryption seems like |
||
17 | * a good candidate. |
||
18 | * @deprecated Do not trust a two-line encryption-method. |
||
19 | * |
||
20 | * @throws Exception if extension mcrypt is not loaded. |
||
21 | * |
||
22 | * @param string $string String to encrypt |
||
23 | * @param string $key Key to encrypt/decrypt. |
||
24 | * @return string Encrypted string |
||
25 | */ |
||
26 | public static function encrypt($string, $key) |
||
50 | |||
51 | /** |
||
52 | * Decrypt string |
||
53 | * |
||
54 | * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is |
||
55 | * important for you, then use a purpose built package. https://github.com/defuse/php-encryption seems like |
||
56 | * a good candidate. |
||
57 | * @deprecated Do not trust a two-line decryption-method. |
||
58 | * |
||
59 | * @param string $string String to decrypt |
||
60 | * @param string $key Key to encrypt/decrypt. |
||
61 | * @return string Decrypted string |
||
62 | */ |
||
63 | public static function decrypt($string, $key) |
||
95 | |||
96 | /** |
||
97 | * Obfuscate string (url-safe and somewhat hard to guess). |
||
98 | * |
||
99 | * @param string $input The text that should be obfuscated |
||
100 | * @return string Obfuscated string |
||
101 | */ |
||
102 | public static function obfuscateString($input) |
||
106 | |||
107 | /** |
||
108 | * Deobfuscate string |
||
109 | * |
||
110 | * @param string $input Obfuscated string |
||
111 | * @return string Deobfuscated string |
||
112 | */ |
||
113 | public static function deobfuscateString($input) |
||
117 | |||
118 | /** |
||
119 | * Convert <textarea> to [textarea]. |
||
120 | * |
||
121 | * @param string $html |
||
122 | * @return string |
||
123 | */ |
||
124 | public static function textareaEncode($html) |
||
128 | |||
129 | /** |
||
130 | * Convert [textarea] to <textarea>. |
||
131 | * |
||
132 | * @param string $html |
||
133 | * @return string |
||
134 | */ |
||
135 | public static function textareaDecode($html) |
||
139 | |||
140 | /** |
||
141 | * To replace "Hallo [@var] world" with $value. |
||
142 | * |
||
143 | * Example: |
||
144 | * ```php |
||
145 | * replace_string($string, array("val1" => "foo", "val2" => "bar")) |
||
146 | * ``` |
||
147 | * |
||
148 | * @param string $langString String containing placeholder. |
||
149 | * @param array $dynamicContent key->value array. |
||
150 | * @return string String with placeholder replaced. |
||
151 | */ |
||
152 | public static function replaceString($langString, $dynamicContent = array()) |
||
159 | |||
160 | /** |
||
161 | * Creates rainbow-colored text. |
||
162 | * |
||
163 | * @uses Holt45::colorBlend() |
||
164 | * @uses Holt45::rgbhex() |
||
165 | * |
||
166 | * @param string $text Text wanted coloured. |
||
167 | * @return string String with span-tags with color. |
||
168 | */ |
||
169 | public static function rainbowText($text) |
||
216 | |||
217 | /** |
||
218 | * Get the symbol from a list of keyboard-keys... |
||
219 | * |
||
220 | * @used-by Holt45::kbdShortcut() |
||
221 | * |
||
222 | * @param string $inputKey Text |
||
223 | * @param string $inputOperatingSystem default|auto|win|mac|linux |
||
224 | * @return null|string HTML Entity (decimal) |
||
225 | */ |
||
226 | public static function kbdSymbol($inputKey, $inputOperatingSystem = "default") |
||
294 | |||
295 | /** |
||
296 | * Show fancy buttons for keyboard-shortcuts. |
||
297 | * |
||
298 | * @uses Holt45::kbdSymbol() |
||
299 | * |
||
300 | * @param array $inputArrayKeys |
||
301 | * @param string $inputOperatingSystem |
||
302 | * @param string $inputKbdClass |
||
303 | * @param string $inputKbdSymbolClass |
||
304 | * @param string $inputJoinGlue Glue |
||
305 | * @return string String of html |
||
306 | */ |
||
307 | public static function kbdShortcut( |
||
330 | |||
331 | /** |
||
332 | * Attempting to keep CSS on one line with scoped style. |
||
333 | * |
||
334 | * NOTICE: This is a rough estimate, font type, design, etc affects the results. |
||
335 | * |
||
336 | * @param string $text |
||
337 | * @param string $cssSelector |
||
338 | * @param int $fontSizePx |
||
339 | * @param int $minPageWidthPx |
||
340 | * @return null|string Scoped style |
||
341 | */ |
||
342 | public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) |
||
367 | } |
||
368 |