Merge branch '138-toggle-free-look-with-hotkey' into 'main/atys-live'
[ryzomcore.git] / web / public_php / admin / functions_tool_event_entities.php
blob40d9522305083406c0fc02babe8a0dc499ba8b57
1 <?php
3 function tool_ee_parse_getview($data)
5 $entity_data = array();
7 reset($data);
8 foreach($data as $ais_data)
10 $service_name = 'n/a';
11 $answers = 0;
12 $values = 0;
13 $values_read = 0;
15 $entity = array();
17 reset($ais_data);
18 foreach($ais_data as $ais_line)
20 $ais_line = trim($ais_line);
21 if (ereg("^===\[ Service ([^\ ]+) returned \]===$", $ais_line, $eregs))
23 $service_name = $eregs[1];
25 elseif (ereg("^have ([[:digit:]]+) answer$", $ais_line, $eregs))
27 $answers = $eregs[1];
29 elseif (ereg("^have ([[:digit:]]+) value$", $ais_line, $eregs))
31 $values = $eregs[1];
33 elseif (ereg("^service ->(.*)$", $ais_line, $eregs))
35 $values_read++;
36 $entity['service_id'] = trim($eregs[1]);
38 elseif (ereg("^entity ->(.*)$", $ais_line, $eregs))
40 $values_read++;
41 $entity['entity'] = trim($eregs[1]);
42 $entity_string = str_replace(array('(',')','0x'), '', $entity['entity']);
43 $entity_string = str_replace(':','_', $entity_string);
44 $entity['entity_string'] = $entity_string;
46 elseif (ereg("^NamedEntityName ->(.*)$", $ais_line, $eregs))
48 $values_read++;
49 $entity['entity_name'] = trim($eregs[1]);
51 elseif (ereg("^NamedEntityState ->(.*)$", $ais_line, $eregs))
53 $values_read++;
54 $entity['entity_state'] = trim($eregs[1]);
56 elseif (ereg("^NamedEntityParam1 ->(.*)$", $ais_line, $eregs))
58 $values_read++;
59 $entity['entity_param1'] = trim($eregs[1]);
61 elseif (ereg("^NamedEntityParam2 ->(.*)$", $ais_line, $eregs))
63 $values_read++;
64 $entity['entity_param2'] = trim($eregs[1]);
67 if (sizeof($entity) && ($values_read == $values) && ($values > 0))
69 $entity['service'] = $service_name;
70 $entity['service_code'] = md5($service_name);
71 $entity_data[] = $entity;
72 $entity = array();
73 $values = 0;
74 $values_read = 0;
80 return $entity_data;
83 function tool_ee_get_entities($data)
85 $entities = array();
87 reset($data);
88 foreach($data as $dkey => $dval)
90 $dkey_bits = explode('_', $dkey);
91 $dkey_nums = sizeof($dkey_bits);
93 if ($dkey_nums > 4)
95 $_entity_bit_4 = array_pop($dkey_bits);
96 $_entity_bit_3 = array_pop($dkey_bits);
97 $_entity_bit_2 = array_pop($dkey_bits);
98 $_entity_bit_1 = array_pop($dkey_bits);
100 $dkey_bits = array_reverse($dkey_bits);
101 $_entity_service = array_pop($dkey_bits);
102 $dkey_bits = array_reverse($dkey_bits);
104 $dkey_entity = $_entity_bit_1 .'_'. $_entity_bit_2 .'_'. $_entity_bit_3 .'_'. $_entity_bit_4;
105 $dkey_name = implode('_', $dkey_bits);
107 if (!isset($entities[$_entity_service .'_'. $dkey_entity]))
109 $entities[$_entity_service .'_'. $dkey_entity] = array();
112 $entities[$_entity_service .'_'. $dkey_entity][$dkey_name] = trim($dval);
116 return $entities;