Commit 1bd64e144c4c42bf996cee5160408f7bb777d0c5

Authored by Erdogan Furkan
1 parent c0008d6e

Integration part to treate a TT/Cat like a parameter

src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
... ... @@ -46,6 +46,8 @@ class IHMParamManagerClass
46 46 return $this->addUploadedParam($param,$paramsData);
47 47 else if ($this->isImpexParam($param))
48 48 return $this->addImpexParam($param,$paramsData,$templateArgs);
  49 + else if($this->isTTCatParam($param))
  50 + return $this->addTTCatParam($param,$paramsData);
49 51 else
50 52 return $this->addLocalParam($param,$paramsData,$templateArgs, $tableLink);
51 53 return "";
... ... @@ -84,7 +86,17 @@ class IHMParamManagerClass
84 86 $info = $this->ttCatMgr->getTTCatInfoFromId($paramId);
85 87  
86 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 102 $status = array();
... ... @@ -93,9 +105,9 @@ class IHMParamManagerClass
93 105 $flag = "";
94 106  
95 107 if ($info["info"]["isCatalog"]) {
96   - $parameters = $this->ttCatMgr->getCatalogParameters($paramId);
  108 + $parameters = $this->ttCatMgr->getCatalogParameters($info["info"]["id"]);
97 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 112 //For the moment, use the first parameter
101 113 $parameter = $parameters["parameters"][0];
... ... @@ -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 197 * @brief Detect if it's a uploaded parameter
177 198 */
178 199 public function isUploadedParam($param)
... ...
src/InputOutput/IHMImpl/Tools/IHMTTCatLoaderClass.php
... ... @@ -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 79 * @brief Get parameters from id (empty for a TT)
65 80 */
66 81 public function getCatalogParameters($id)
... ...