diff --git a/web_service/ws/Workspace.class.inc b/web_service/ws/Workspace.class.inc index d85b36b486e6988fa8762daa698ff695a0f7b6ac..229163284fef843c8cfc6d14a1abf9152c0ef1fc 100755 --- a/web_service/ws/Workspace.class.inc +++ b/web_service/ws/Workspace.class.inc @@ -170,60 +170,42 @@ class Workspace extends GTF { */ function GET() { if (!empty($this->aValues["form"])) { - $sDirName = $this->aProperties['workspace_dir'] . "/" . (string) $this->aValues["my_vitis_id"]; require $this->sRessourcesFile; $this->aFields = $this->getFields($this->aProperties['schema_gtf'], "v_workspace", "workspace_id"); + // Groupes rattachés au projet FME. $this->getGroups(); - - if ($this->aValues["form"] == "Default") { - $sFile = $sDirName . "/form/DSubform.json"; - } else if ($this->aValues["form"] == "Perso") { - $sFile = $sDirName . "/form/WSubform.json"; - } else if ($this->aValues["form"] == "Published") { - $sFile = $sDirName . "/form/Subform.json"; - } else { + // Fichier de formulaire. + if ($this->aValues["form"] == 'Default') + $sFile = 'DSubform.json'; + else if ($this->aValues["form"] == 'Perso') + $sFile = 'WSubform.json'; + else if ($this->aValues["form"] == 'Published') + $sFile = 'Subform.json'; + else { writeToErrorLog("Error parameter is not a known mode user :" . $_SESSION["user_id"]); - $this->oError = new VitisError(1, "Error parameter is not a known mode"); } - if (is_file($sFile)) { - $pFile = fopen($sFile, "r"); - $iSize = filesize($sFile); - $sJson = fread($pFile, $iSize); - fclose($pFile); - $aJson = json_decode($sJson, true); + // Contenu du fichier de formulaire. + $sFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'form', $sFile); + if ($sFileContent !== false) { + $aJson = json_decode($sFileContent, true); $this->aFields["json_form"] = array($aJson); $sJs = ""; $sCss = ""; - if (is_dir($sDirName . "/form")) { - if ($dh = opendir($sDirName . "/form/ressources")) { - while (($file = readdir($dh)) !== false) { - $sName = explode(".", $file); - if ($sName[1] == "js") { - // $pFileJS = fopen($sDirName . "/form/ressources/Subform.js", "r"); - // $iSize = filesize($sDirName . "/form/ressources/Subform.js"); - // $sJs = fread($pFileJS, $iSize); - // fclose($pFileJS); - - $sJs = $this->aProperties['web_server_name'] . '/' . $this->aProperties['ws_data_alias'] . "/gtf/workspace/" . (string) $this->aValues["my_vitis_id"] . "/form/ressources/Subform.js"; - } - if ($sName[1] == "css") { - /* $pFileCSS = fopen($sDirName . "/form/ressources/Subform.css", "r"); - $iSize = filesize($sDirName . "/form/ressources/Subform.css"); - $sCss = fread($pFileCSS, $iSize); - fclose($pFileCSS); */ - $sCss = $this->aProperties['web_server_name'] . '/' . $this->aProperties['ws_data_alias'] . "/gtf/workspace/" . (string) $this->aValues["my_vitis_id"] . "/form/ressources/Subform.css"; - } - } - closedir($dh); - } - } + // Url du fichier js du formulaire. + $sFileUrl = getFileUrlInWsDataDir('gtf', 'workspace', $this->aValues['my_vitis_id'], 'form/ressources', 'Subform.js'); + if ($sFileUrl !== false) + $sJs = $sFileUrl; + // Url du fichier css du formulaire. + $sFileUrl = getFileUrlInWsDataDir('gtf', 'workspace', $this->aValues['my_vitis_id'], 'form/ressources', 'Subform.css'); + if ($sFileUrl !== false) + $sCss = $sFileUrl; + // array_push($this->aFields["json_form"], $sJs); array_push($this->aFields["json_form"], $sCss); - } else { - - $this->oError = new VitisError(1, "File not found"); } + else + $this->oError = new VitisError(1, "File not found"); } else { require $this->sRessourcesFile; $this->aFields = $this->getFields($this->aProperties['schema_gtf'], "v_workspace", "workspace_id"); @@ -236,8 +218,7 @@ class Workspace extends GTF { } } // Formatage de la colonne "form_type". - $sFile = $this->aProperties['workspace_dir'] . "/" . $this->aValues["my_vitis_id"] . '/form/Subform.json'; - if (!file_exists($sFile)) + if (!fileExistsInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form', 'Subform.json')) $this->aFields['form_type'] = ''; else { if ($this->aFields['form_type'] != "custom") diff --git a/web_service/ws/Workspaces.class.inc b/web_service/ws/Workspaces.class.inc index 25df9f3208b56314499b2c1e23724764a11aab75..e0b3ac58621b1e540356b232e8db0bddeff98c98 100755 --- a/web_service/ws/Workspaces.class.inc +++ b/web_service/ws/Workspaces.class.inc @@ -403,7 +403,7 @@ class Workspaces extends GTF { putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form/ressources', 'Subform.js', ''); putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form/ressources', 'Subform.css', ''); // Lit le contenu du fichier .fmw du projet. - $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $_FILES['fmw_file']['name'][$i]); + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $_FILES['fmw_file']['name'][$i]); // Sauve le .fmw sans les visualizers. $oFmwParser = new GtfFmwParser($_FILES['fmw_file']['name'][$i], $sFmwFileContent, $this->aProperties); $oFmwParser->save($oFmwParser->sFmwFileName); @@ -532,7 +532,7 @@ class Workspaces extends GTF { */ } // Lit le contenu du fichier .fmw du projet. - $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $_FILES['fmw_file']['name']); + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $_FILES['fmw_file']['name']); // Sauve le .fmw sans les visualizers. $oFmwParser = new GtfFmwParser($_FILES['fmw_file']['name'], $sFmwFileContent, $this->aProperties); $oFmwParser->save($oFmwParser->sFmwFileName); @@ -896,7 +896,7 @@ class Workspaces extends GTF { putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form/ressources', 'Subform.js', ''); putFileContentInWsDataDir('gtf', 'workspace', $this->aValues["my_vitis_id"], 'form/ressources', 'Subform.css', ''); // Lit le contenu du fichier .fmw du projet. - $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $this->aValues['fmw_file_name']); + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $this->aValues['fmw_file_name']); // Sauve le .fmw sans les visualizers. $oFmwParser = new GtfFmwParser($this->aValues['fmw_file_name'], $sFmwFileContent, $this->aProperties); $oFmwParser->save($oFmwParser->sFmwFileName); @@ -1195,7 +1195,7 @@ class Workspaces extends GTF { */ function getWorkspaceFile() { // Chargement du contenu du fichier. - $sFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $this->aValues['file_name']); + $sFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $this->aValues['file_name']); if ($sFileContent !== false) { // Copie du fichier dans un répertoire temporaire. $sFilePath = $this->aProperties['extract_dir'] . '/' . getUniqRandomId() . '/' . $this->aValues['file_name']; @@ -1250,7 +1250,7 @@ class Workspaces extends GTF { require $this->sRessourcesFile; $aFields = $this->getFields($this->aProperties['schema_gtf'], "workspace", "workspace_id"); // Lit le contenu du fichier .fmw du projet. - $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $aFields['fmw_file']); + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $aFields['fmw_file']); // Remplace les métas données. if ($sFmwFileContent !== false) { $oFmwParser = new GtfFmwParser($aFields['fmw_file'], $sFmwFileContent, $this->aProperties); @@ -1279,7 +1279,7 @@ class Workspaces extends GTF { function reintegrateMetadata() { $aFields = $this->getFields($this->aProperties['schema_gtf'], "workspace", "workspace_id"); // Lit le contenu du fichier .fmw du projet. - $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], $sField = 'fme', $aFields['fmw_file']); + $sFmwFileContent = getFileContentInWsDataDir("gtf", "workspace", $this->aValues["my_vitis_id"], 'fme', $aFields['fmw_file']); // Remplace les métas données. if ($sFmwFileContent !== false) { $oFmwParser = new GtfFmwParser($aFields['fmw_file'], $sFmwFileContent, $this->aProperties);