corrade-http-templates – Blame information for rev 7

Subversion Repositories:
Rev:
Rev Author Line No. Line
7 zed 1 <?php
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 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
21 ///////////////////////////////////////////////////////////////////////////
22 function wasCSVToArray($csv) {
23 $l = array();
24 $s = array();
25 $m = "";
26 for ($i = 0; $i < strlen($csv); ++$i) {
27 switch ($csv{$i}) {
28 case ',':
29 if (sizeof($s) == 0 || !current($s) == '"') {
30 array_push($l, $m);
31 $m = "";
32 break;
33 }
34 $m .= $csv{$i};
35 continue;
36 case '"':
37 if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) {
38 $m .= $csv{$i};
39 ++$i;
40 break;
41 }
42 if (sizeof($s) == 0|| !current($s) == $csv[$i]) {
43 array_push($s, $csv{$i});
44 continue;
45 }
46 array_pop($s);
47 break;
48 default:
49 $m .= $csv{$i};
50 break;
51 }
52 }
53 array_push($l, $m);
54 return $l;
55 }
56  
57 ##########################################################################
58 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
59 ###########################################################################
60 function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) {
61 return $yMin + (
62 (
63 $yMax - $yMin
64 )
65 *
66 (
67 $value - $xMin
68 )
69 /
70 (
71 $xMax - $xMin
72 )
73 );
74 }
75  
76 ###########################################################################
77 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
78 ###########################################################################
79 function wasLSLVectorToArray($vector) {
80 $components = array();
81 if(!preg_match(
82 "/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/",
83 $vector,
84 $components
85 )) return;
86 array_shift($components);
87 return $components;
88 }