corrade-http-templates – Diff between revs 66 and 77
?pathlinks?
Rev 66 | Rev 77 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | <?php |
1 | <?php |
|
Line 2... | Line -... | |||
2 | |
- | ||
3 | ########################################################################### |
- | ||
4 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
5 | ########################################################################### |
- | ||
6 | function wasKeyValueGet($key, $data) { |
- | ||
7 | return array_reduce( |
- | ||
8 | explode( |
- | ||
9 | "&", |
- | ||
10 | $data |
- | ||
11 | ), |
- | ||
12 | function($o, $p) { |
- | ||
13 | $x = explode("=", $p); |
- | ||
14 | return array_shift($x) != $o ? $o : array_shift($x); |
- | ||
15 | }, |
- | ||
16 | $key |
- | ||
17 | ); |
- | ||
18 | } |
- | ||
19 | |
- | ||
20 | /////////////////////////////////////////////////////////////////////////// |
- | ||
21 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
- | ||
22 | /////////////////////////////////////////////////////////////////////////// |
- | ||
23 | function wasCSVToArray($csv) { |
- | ||
24 | $l = array(); |
- | ||
25 | $s = array(); |
- | ||
26 | $m = ""; |
- | ||
27 | for ($i = 0; $i < strlen($csv); ++$i) { |
- | ||
28 | switch ($csv[$i]) { |
- | ||
29 | case ',': |
- | ||
30 | if (sizeof($s) == 0 || !current($s) == '"') { |
- | ||
31 | array_push($l, $m); |
- | ||
32 | $m = ""; |
- | ||
33 | break; |
- | ||
34 | } |
- | ||
35 | $m .= $csv[$i]; |
- | ||
36 | continue; |
- | ||
37 | case '"': |
- | ||
38 | if ($i + 1 < strlen($csv) && $csv[$i] == $csv[$i + 1]) { |
- | ||
39 | $m .= $csv[$i]; |
- | ||
40 | ++$i; |
- | ||
41 | break; |
- | ||
42 | } |
- | ||
43 | if (sizeof($s) == 0|| !current($s) == $csv[$i]) { |
- | ||
44 | array_push($s, $csv[$i]); |
- | ||
45 | continue; |
- | ||
46 | } |
- | ||
47 | array_pop($s); |
- | ||
48 | break; |
- | ||
49 | default: |
- | ||
50 | $m .= $csv[$i]; |
- | ||
51 | break; |
- | ||
52 | } |
- | ||
53 | } |
- | ||
54 | array_push($l, $m); |
- | ||
55 | return $l; |
- | ||
56 | } |
- | ||
57 | |
- | ||
58 | /////////////////////////////////////////////////////////////////////////// |
- | ||
59 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
- | ||
60 | /////////////////////////////////////////////////////////////////////////// |
- | ||
61 | function wasArrayStride($a, $s) { |
- | ||
62 | return array_filter($a, |
- | ||
63 | function($e, $i) use($s) { |
- | ||
64 | return $i % $s == 0; |
- | ||
65 | }, |
- | ||
66 | ARRAY_FILTER_USE_BOTH |
- | ||
67 | ); |
- | ||
68 | } |
- | ||
69 | |
2 | |
|
70 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
71 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
4 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
|
72 | /////////////////////////////////////////////////////////////////////////// |
5 | /////////////////////////////////////////////////////////////////////////// |
|
73 | function wasColorHash($a) { |
6 | function wasColorHash($a) { |
|
Line 77... | Line 10... | |||
77 | return substr($hash, 0, 2). |
10 | return substr($hash, 0, 2). |
|
78 | substr($hash, $size/2, 2). |
11 | substr($hash, $size/2, 2). |
|
79 | substr($hash, $size-2, 2); |
12 | substr($hash, $size-2, 2); |
|
80 | } |
13 | } |
|
Line 81... | Line -... | |||
81 | |
- | ||
82 | ########################################################################### |
- | ||
83 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
84 | ########################################################################### |
- | ||
85 | function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) { |
- | ||
86 | return $yMin + ( |
- | ||
87 | ( |
- | ||
88 | $yMax - $yMin |
- | ||
89 | ) |
- | ||
90 | * |
- | ||
91 | ( |
- | ||
92 | $value - $xMin |
- | ||
93 | ) |
- | ||
94 | / |
- | ||
95 | ( |
- | ||
96 | $xMax - $xMin |
- | ||
97 | ) |
- | ||
98 | ); |
- | ||
99 | } |
- | ||
100 | |
14 | |
|
101 | function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') { |
15 | function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') { |
|
102 | $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); |
16 | $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); |
|
103 | $rgbArray = array(); |
17 | $rgbArray = array(); |
|
104 | switch(strlen($hexStr)) { |
18 | switch(strlen($hexStr)) { |