corrade-http-templates – Diff between revs 7 and 69

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 7 Rev 69
1 <?php 1 <?php
2   2  
3 ########################################################################### 3 ###########################################################################
4 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## 4 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
5 ########################################################################### 5 ###########################################################################
6 function wasKeyValueGet($key, $data) { 6 function wasKeyValueGet($key, $data) {
7 return array_reduce( 7 return array_reduce(
8 explode( 8 explode(
9 "&", 9 "&",
10 $data 10 $data
11 ), 11 ),
12 function($o, $p) { 12 function($o, $p) {
13 $x = explode("=", $p); 13 $x = explode("=", $p);
14 return array_shift($x) != $o ? $o : array_shift($x); 14 return array_shift($x) != $o ? $o : array_shift($x);
15 }, 15 },
16 $key 16 $key
17 ); 17 );
18 } 18 }
19 /////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////
20 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // 20 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
21 /////////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////////
22 function wasCSVToArray($csv) { 22 function wasCSVToArray($csv) {
23 $l = array(); 23 $l = array();
24 $s = array(); 24 $s = array();
25 $m = ""; 25 $m = "";
26 for ($i = 0; $i < strlen($csv); ++$i) { 26 for ($i = 0; $i < strlen($csv); ++$i) {
27 switch ($csv{$i}) { 27 switch ($csv[$i]) {
28 case ',': 28 case ',':
29 if (sizeof($s) == 0 || !current($s) == '"') { 29 if (sizeof($s) == 0 || !current($s) == '"') {
30 array_push($l, $m); 30 array_push($l, $m);
31 $m = ""; 31 $m = "";
32 break; 32 break;
33 } 33 }
34 $m .= $csv{$i}; 34 $m .= $csv[$i];
35 continue; 35 continue;
36 case '"': 36 case '"':
37 if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) { 37 if ($i + 1 < strlen($csv) && $csv[$i] == $csv[$i + 1]) {
38 $m .= $csv{$i}; 38 $m .= $csv[$i];
39 ++$i; 39 ++$i;
40 break; 40 break;
41 } 41 }
42 if (sizeof($s) == 0|| !current($s) == $csv[$i]) { 42 if (sizeof($s) == 0|| !current($s) == $csv[$i]) {
43 array_push($s, $csv{$i}); 43 array_push($s, $csv[$i]);
44 continue; 44 continue;
45 } 45 }
46 array_pop($s); 46 array_pop($s);
47 break; 47 break;
48 default: 48 default:
49 $m .= $csv{$i}; 49 $m .= $csv[$i];
50 break; 50 break;
51 } 51 }
52 } 52 }
53 array_push($l, $m); 53 array_push($l, $m);
54 return $l; 54 return $l;
55 } 55 }
56   56  
57 ########################################################################## 57 ##########################################################################
58 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## 58 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
59 ########################################################################### 59 ###########################################################################
60 function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) { 60 function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) {
61 return $yMin + ( 61 return $yMin + (
62 ( 62 (
63 $yMax - $yMin 63 $yMax - $yMin
64 ) 64 )
65 * 65 *
66 ( 66 (
67 $value - $xMin 67 $value - $xMin
68 ) 68 )
69 / 69 /
70 ( 70 (
71 $xMax - $xMin 71 $xMax - $xMin
72 ) 72 )
73 ); 73 );
74 } 74 }
75   75  
76 ########################################################################### 76 ###########################################################################
77 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## 77 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
78 ########################################################################### 78 ###########################################################################
79 function wasLSLVectorToArray($vector) { 79 function wasLSLVectorToArray($vector) {
80 $components = array(); 80 $components = array();
81 if(!preg_match( 81 if(!preg_match(
82 "/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/", 82 "/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/",
83 $vector, 83 $vector,
84 $components 84 $components
85 )) return; 85 )) return;
86 array_shift($components); 86 array_shift($components);
87 return $components; 87 return $components;
88 } 88 }
89   89  
90
Generated by GNU Enscript 1.6.5.90.
90
Generated by GNU Enscript 1.6.5.90.
91   91  
92   92  
93   93