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 important for you, then |
||
|
|||
16 | * use a purpose built package. https://github.com/defuse/php-encryption seems like a good candidate. |
||
17 | * @deprecated Do not trust a two-line encryption-method. |
||
18 | * |
||
19 | * @param string $string String to encrypt |
||
20 | * @param string $key Key to encrypt/decrypt. |
||
21 | * @return string Encrypted string |
||
22 | */ |
||
23 | public static function encrypt($string, $key) { |
||
35 | |||
36 | /** |
||
37 | * Decrypt string |
||
38 | * |
||
39 | * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is important for you, then |
||
40 | * use a purpose built package. https://github.com/defuse/php-encryption seems like a good candidate. |
||
41 | * @deprecated Do not trust a two-line decryption-method. |
||
42 | * |
||
43 | * @param string $string String to decrypt |
||
44 | * @param string $key Key to encrypt/decrypt. |
||
45 | * @return string Decrypted string |
||
46 | */ |
||
47 | public static function decrypt($string, $key) { |
||
56 | |||
57 | /** |
||
58 | * Obfuscate string (url-safe and somewhat hard to guess). |
||
59 | * |
||
60 | * @param string $input The text that should be obfuscated |
||
61 | * @return string Obfuscated string |
||
62 | */ |
||
63 | public static function obfuscateString($input) |
||
67 | |||
68 | /** |
||
69 | * Deobfuscate string |
||
70 | * |
||
71 | * @param string $input Obfuscated string |
||
72 | * @return string Deobfuscated string |
||
73 | */ |
||
74 | public static function deobfuscateString($input) |
||
78 | |||
79 | /** |
||
80 | * Convert <textarea> to [textarea]. |
||
81 | * |
||
82 | * @param string $html |
||
83 | * @return string |
||
84 | */ |
||
85 | public static function textareaEncode($html) |
||
89 | |||
90 | /** |
||
91 | * Convert [textarea] to <textarea>. |
||
92 | * |
||
93 | * @param string $html |
||
94 | * @return string |
||
95 | */ |
||
96 | public static function textareaDecode($html) |
||
100 | |||
101 | /** |
||
102 | * To replace "Hallo [@var] world" with $value. |
||
103 | * |
||
104 | * Example: |
||
105 | * ```php |
||
106 | * replace_string($string, array("val1" => "foo", "val2" => "bar")) |
||
107 | * ``` |
||
108 | * |
||
109 | * @param string $langString String containing placeholder. |
||
110 | * @param array $dynamicContent key->value array. |
||
111 | * @return string String with placeholder replaced. |
||
112 | */ |
||
113 | public static function replaceString($langString, $dynamicContent = array()) |
||
120 | |||
121 | /** |
||
122 | * Creates rainbow-colored text. |
||
123 | * |
||
124 | * @uses Holt45::colorBlend() |
||
125 | * @uses Holt45::rgbhex() |
||
126 | * |
||
127 | * @param string $text Text wanted coloured. |
||
128 | * @return string String with span-tags with color. |
||
129 | */ |
||
130 | public static function rainbowText($text) |
||
179 | |||
180 | /** |
||
181 | * Get the symbol from a list of keyboard-keys... |
||
182 | * |
||
183 | * @used-by Holt45::kbdShortcut() |
||
184 | * |
||
185 | * @param string $inputKey Text |
||
186 | * @param string $inputOperatingSystem default|auto|win|mac|linux |
||
187 | * @return null|string HTML Entity (decimal) |
||
188 | */ |
||
189 | public static function kbdSymbol($inputKey, $inputOperatingSystem = "default") |
||
259 | |||
260 | /** |
||
261 | * Show fancy buttons for keyboard-shortcuts. |
||
262 | * |
||
263 | * @uses Holt45::kbdSymbol() |
||
264 | * |
||
265 | * @param array $inputArrayKeys |
||
266 | * @param string $inputOperatingSystem |
||
267 | * @param string $inputKbdClass |
||
268 | * @param string $inputKbdSymbolClass |
||
269 | * @param string $inputJoinGlue Glue |
||
270 | * @return string String of html |
||
271 | */ |
||
272 | public static function kbdShortcut( |
||
297 | |||
298 | /** |
||
299 | * Attempting to keep CSS on one line with scoped style. |
||
300 | * |
||
301 | * NOTICE: This is a rough estimate, font type, design, etc affects the results. |
||
302 | * |
||
303 | * @param string $text |
||
304 | * @param string $cssSelector |
||
305 | * @param int $fontSizePx |
||
306 | * @param int $minPageWidthPx |
||
307 | * @return null|string Scoped style |
||
308 | */ |
||
309 | public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) |
||
329 | } |
||
330 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.