Commit 1bd64e144c4c42bf996cee5160408f7bb777d0c5
1 parent
c0008d6e
Exists in
master
and in
25 other branches
Integration part to treate a TT/Cat like a parameter
Showing
2 changed files
with
39 additions
and
3 deletions
Show diff stats
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -46,6 +46,8 @@ class IHMParamManagerClass | @@ -46,6 +46,8 @@ class IHMParamManagerClass | ||
46 | return $this->addUploadedParam($param,$paramsData); | 46 | return $this->addUploadedParam($param,$paramsData); |
47 | else if ($this->isImpexParam($param)) | 47 | else if ($this->isImpexParam($param)) |
48 | return $this->addImpexParam($param,$paramsData,$templateArgs); | 48 | return $this->addImpexParam($param,$paramsData,$templateArgs); |
49 | + else if($this->isTTCatParam($param)) | ||
50 | + return $this->addTTCatParam($param,$paramsData); | ||
49 | else | 51 | else |
50 | return $this->addLocalParam($param,$paramsData,$templateArgs, $tableLink); | 52 | return $this->addLocalParam($param,$paramsData,$templateArgs, $tableLink); |
51 | return ""; | 53 | return ""; |
@@ -84,7 +86,17 @@ class IHMParamManagerClass | @@ -84,7 +86,17 @@ class IHMParamManagerClass | ||
84 | $info = $this->ttCatMgr->getTTCatInfoFromId($paramId); | 86 | $info = $this->ttCatMgr->getTTCatInfoFromId($paramId); |
85 | 87 | ||
86 | if (!$info["success"]) { | 88 | if (!$info["success"]) { |
87 | - throw new Exception($info["message"]); | 89 | + $paramName = $paramId; |
90 | + foreach(array("tt_","cat_","sharedtimeTable_","sharedcartalog_") as $prefix){ | ||
91 | + if(strpos($paramName, $prefix) === 0){ | ||
92 | + $paramName = substr($paramName, strlen($prefix)); | ||
93 | + break; | ||
94 | + } | ||
95 | + } | ||
96 | + $info = $this->ttCatMgr->getTTCatInfoFromName($paramName); | ||
97 | + if (!$info["success"]) { | ||
98 | + throw new Exception($info["message"]); | ||
99 | + } | ||
88 | } | 100 | } |
89 | 101 | ||
90 | $status = array(); | 102 | $status = array(); |
@@ -93,9 +105,9 @@ class IHMParamManagerClass | @@ -93,9 +105,9 @@ class IHMParamManagerClass | ||
93 | $flag = ""; | 105 | $flag = ""; |
94 | 106 | ||
95 | if ($info["info"]["isCatalog"]) { | 107 | if ($info["info"]["isCatalog"]) { |
96 | - $parameters = $this->ttCatMgr->getCatalogParameters($paramId); | 108 | + $parameters = $this->ttCatMgr->getCatalogParameters($info["info"]["id"]); |
97 | if (!$parameters["success"] || empty($parameters["parameters"])) { | 109 | if (!$parameters["success"] || empty($parameters["parameters"])) { |
98 | - throw new Exception("Error to extract first parameter of ".$paramId); | 110 | + throw new Exception("Error to extract first parameter of ".$info["info"]["id"]); |
99 | } | 111 | } |
100 | //For the moment, use the first parameter | 112 | //For the moment, use the first parameter |
101 | $parameter = $parameters["parameters"][0]; | 113 | $parameter = $parameters["parameters"][0]; |
@@ -173,6 +185,15 @@ class IHMParamManagerClass | @@ -173,6 +185,15 @@ class IHMParamManagerClass | ||
173 | } | 185 | } |
174 | 186 | ||
175 | /* | 187 | /* |
188 | + * @brief Detect if it's a TT/Cat parameter | ||
189 | + */ | ||
190 | + private function isTTCatParam($param) | ||
191 | + { | ||
192 | + return preg_match("#^tt_#",$param) || preg_match("#^cat_#",$param) || | ||
193 | + preg_match("#^sharedtimeTable_#",$param) || preg_match("#^sharedcatalog_#",$param); | ||
194 | + } | ||
195 | + | ||
196 | + /* | ||
176 | * @brief Detect if it's a uploaded parameter | 197 | * @brief Detect if it's a uploaded parameter |
177 | */ | 198 | */ |
178 | public function isUploadedParam($param) | 199 | public function isUploadedParam($param) |
src/InputOutput/IHMImpl/Tools/IHMTTCatLoaderClass.php
@@ -61,6 +61,21 @@ class IHMTTCatLoaderClass | @@ -61,6 +61,21 @@ class IHMTTCatLoaderClass | ||
61 | } | 61 | } |
62 | 62 | ||
63 | /* | 63 | /* |
64 | + * @brief Get info about a TT or a catalog from name | ||
65 | + */ | ||
66 | + public function getTTCatInfoFromName($name) | ||
67 | + { | ||
68 | + if (!isset($this->ttCatList)) { | ||
69 | + $this->ttCatList = $this->loadTTCatManagerFiles(); | ||
70 | + } | ||
71 | + foreach($this->ttCatList as $value){ | ||
72 | + if($value['name'] == $name) | ||
73 | + return array("success" => true, "info" => $value); | ||
74 | + } | ||
75 | + return array("success" => false, "message" => "Cannot retrieve TT or catalog"); | ||
76 | + } | ||
77 | + | ||
78 | + /* | ||
64 | * @brief Get parameters from id (empty for a TT) | 79 | * @brief Get parameters from id (empty for a TT) |
65 | */ | 80 | */ |
66 | public function getCatalogParameters($id) | 81 | public function getCatalogParameters($id) |