Commit af94e42dfbfe423e4ec73e1061e3c816a376e5ad
1 parent
a8395497
Exists in
master
and in
52 other branches
Fix catalog upload
Showing
3 changed files
with
55 additions
and
22 deletions
Show diff stats
php/classes/CatalogCacheMgr.php
... | ... | @@ -24,7 +24,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
24 | 24 | $this->cache = new CatalogCacheObject(); |
25 | 25 | if (!empty($options['nparams'])) { |
26 | 26 | for ($i = 0; $i < (int)$options['nparams']; $i++) { |
27 | - $this->cache->addParameter(CatalogCacheMgr::DEFAULT_PARAM_ID_PREFIX.(string)($i+1), 'column_'.(string)($i+1), 1, 0); | |
27 | + $this->cache->addParameter(CatalogCacheMgr::DEFAULT_PARAM_ID_PREFIX.(string)($i+1), 'column_'.(string)($i+1), 1, 0, ""); | |
28 | 28 | } |
29 | 29 | } |
30 | 30 | else if (!empty($options['parameters'])) { |
... | ... | @@ -39,7 +39,11 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
39 | 39 | else { |
40 | 40 | $id = 'cat_param_id_'.$index; |
41 | 41 | } |
42 | - $this->cache->addParameter($id, $parameter['name'], intval($parameter['size']), intval($parameter['type'])); | |
42 | + $description = ""; | |
43 | + if (isset($parameter['description'])) { | |
44 | + $description = $parameter['description']; | |
45 | + } | |
46 | + $this->cache->addParameter($id, $parameter['name'], intval($parameter['size']), intval($parameter['type']), $description); | |
43 | 47 | ++$index; |
44 | 48 | } |
45 | 49 | } |
... | ... | @@ -64,7 +68,11 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
64 | 68 | |
65 | 69 | $info = $this->objectMgr->getUploadedObject($name, $format,TRUE); |
66 | 70 | foreach ($info['parameters'] as $parameter) { |
67 | - $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type'])); | |
71 | + $description = ""; | |
72 | + if (isset($parameter['description'])) { | |
73 | + $description = $parameter['description']; | |
74 | + } | |
75 | + $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type']), $parameter['description']); | |
68 | 76 | } |
69 | 77 | |
70 | 78 | return $result+ array('parameters' => $info['parameters']); |
... | ... |
php/classes/CatalogCacheObject.php
... | ... | @@ -26,13 +26,14 @@ class CatalogCacheObject extends TimeTableCacheObject |
26 | 26 | return $intervalObj; |
27 | 27 | } |
28 | 28 | |
29 | - public function addParameter($id, $name, $size, $type) | |
29 | + public function addParameter($id, $name, $size, $type, $description) | |
30 | 30 | { |
31 | 31 | $this->parameters[] = array( |
32 | 32 | 'id' => $id, |
33 | 33 | 'name' => $name, |
34 | 34 | 'size' => $size, |
35 | 35 | 'type' => $type, |
36 | + 'description' => $description, | |
36 | 37 | ); |
37 | 38 | } |
38 | 39 | |
... | ... | @@ -49,46 +50,56 @@ class CatalogCacheObject extends TimeTableCacheObject |
49 | 50 | fwrite($handle,pack('L',strlen($parameter['id']))); |
50 | 51 | //Param name length |
51 | 52 | fwrite($handle,pack('L',strlen($parameter['name']))); |
52 | - //Param Size | |
53 | + //Param Size | |
53 | 54 | fwrite($handle,pack('L',$parameter['size'])); |
54 | - //Param Type | |
55 | + //Param Type | |
55 | 56 | fwrite($handle,pack('L',$parameter['type'])); |
56 | - //Param Id | |
57 | + //Description Size | |
58 | + fwrite($handle,pack('L',strlen($parameter['description']))); | |
59 | + //Param Id | |
57 | 60 | for ($i = 0; $i < strlen($parameter['id']); ++$i) |
58 | - fwrite($handle,pack('C',ord($parameter['id'][$i]))); | |
59 | - //Param name: | |
61 | + fwrite($handle,pack('C',ord($parameter['id'][$i]))); | |
62 | + //Param name: | |
60 | 63 | for ($i = 0; $i < strlen($parameter['name']); ++$i) |
61 | - fwrite($handle,pack('C',ord($parameter['name'][$i]))); | |
64 | + fwrite($handle,pack('C',ord($parameter['name'][$i]))); | |
65 | + //Param description | |
66 | + for ($i = 0; $i < strlen($parameter['description']); ++$i) | |
67 | + fwrite($handle,pack('C',ord($parameter['description'][$i]))); | |
62 | 68 | } |
63 | 69 | } |
64 | 70 | |
65 | 71 | protected function loadAdditionalHeaderBin($handle) { |
66 | - //Params Number | |
72 | + //Params Number | |
67 | 73 | if (!$res = unpack('Lnumber',fread($handle,4))) |
68 | 74 | return false; |
69 | 75 | $nbParams = $res['number']; |
70 | 76 | |
71 | 77 | for ($i = 0; $i < $nbParams; ++$i) { |
72 | - //Param Id length | |
78 | + //Param Id length | |
73 | 79 | if (!$res = unpack('Lidlength',fread($handle,4))) |
74 | 80 | return false; |
75 | 81 | $idlength = $res['idlength']; |
76 | 82 | |
77 | - //Param Name length | |
78 | - if (!$res = unpack('Lnamelength',fread($handle,4))) | |
83 | + //Param Name length | |
84 | + if (!$res = unpack('Lnamelength',fread($handle,4))) | |
79 | 85 | return false; |
80 | 86 | $namelength = $res['namelength']; |
81 | 87 | |
82 | - //Param Size | |
83 | - if (!$res = unpack('Lsize',fread($handle,4))) | |
84 | - return false; | |
85 | - $size = $res['size']; | |
88 | + //Param Size | |
89 | + if (!$res = unpack('Lsize',fread($handle,4))) | |
90 | + return false; | |
91 | + $size = $res['size']; | |
86 | 92 | |
87 | 93 | //Param Type |
88 | 94 | if (!$res = unpack('Ltype',fread($handle,4))) |
89 | 95 | return false; |
90 | 96 | $type = $res['type']; |
91 | 97 | |
98 | + //Param Description lenfth | |
99 | + if (!$res = unpack('Ldescriptionlength',fread($handle,4))) | |
100 | + return false; | |
101 | + $descriptionlength = $res['descriptionlength']; | |
102 | + | |
92 | 103 | //Param Id |
93 | 104 | $id = ""; |
94 | 105 | for ($j = 0; $j < $idlength; ++$j) |
... | ... | @@ -98,7 +109,7 @@ class CatalogCacheObject extends TimeTableCacheObject |
98 | 109 | $id .= chr($res['id']); |
99 | 110 | } |
100 | 111 | |
101 | - //Param Name | |
112 | + //Param Name | |
102 | 113 | $name = ""; |
103 | 114 | for ($j = 0; $j < $namelength; ++$j) |
104 | 115 | { |
... | ... | @@ -107,7 +118,16 @@ class CatalogCacheObject extends TimeTableCacheObject |
107 | 118 | $name .= chr($res['name']); |
108 | 119 | } |
109 | 120 | |
110 | - $this->addParameter($id, $name, $size, $type); | |
121 | + //Param description | |
122 | + $description = ""; | |
123 | + for ($j = 0; $j < $descriptionlength; ++$j) | |
124 | + { | |
125 | + if (!$res = unpack('Cdescription',fread($handle,1))) | |
126 | + return false; | |
127 | + $description .= chr($res['description']); | |
128 | + } | |
129 | + | |
130 | + $this->addParameter($id, $name, $size, $type, $description); | |
111 | 131 | } |
112 | 132 | return true; |
113 | 133 | } |
... | ... | @@ -137,7 +157,7 @@ class CatalogCacheObject extends TimeTableCacheObject |
137 | 157 | |
138 | 158 | echo " => Parameters : ".PHP_EOL; |
139 | 159 | foreach ($this->parameters as $parameter) { |
140 | - echo " * id = ".$parameter['id'].", name = ".$parameter['name'].", size = ".$parameter['size'].", type = ".$parameter['type'].PHP_EOL; | |
160 | + echo " * id = ".$parameter['id'].", name = ".$parameter['name'].", size = ".$parameter['size'].", type = ".$parameter['type'].", description = ".$parameter['description'].PHP_EOL; | |
141 | 161 | } |
142 | 162 | echo PHP_EOL; |
143 | 163 | |
... | ... |
php/classes/TimeTableMgr.php
... | ... | @@ -84,7 +84,12 @@ class TimeTableMgr extends AmdaObjectMgr |
84 | 84 | else |
85 | 85 | $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;*/ |
86 | 86 | //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromObject' function |
87 | - if ($attribute->tagName != 'intervals') { | |
87 | + if ($attribute->tagName == 'parameters' && method_exists($this,'getCatalogParamDescription')) { | |
88 | + $parameters_desc = $this->getCatalogParamDescription(array('id' => $id, 'type' => $nodeType)); | |
89 | + if ($parameters_desc['success']) | |
90 | + $attributesToReturn[$attribute->tagName] = $parameters_desc['parameters']; | |
91 | + } | |
92 | + else if ($attribute->tagName != 'intervals') { | |
88 | 93 | $attributesToReturn[$attribute->tagName] = $attribute->nodeValue; |
89 | 94 | } else { |
90 | 95 | |
... | ... |