Compare View
Commits (9)
Showing
14 changed files
Show diff stats
src/FunctionTypeEnumClass.php
@@ -18,6 +18,7 @@ abstract class FunctionTypeEnumClass | @@ -18,6 +18,7 @@ abstract class FunctionTypeEnumClass | ||
18 | const TTMERGE = "tt_merge"; | 18 | const TTMERGE = "tt_merge"; |
19 | const TTUNION = "tt_union"; | 19 | const TTUNION = "tt_union"; |
20 | const TTCONVERT = "tt_convert"; | 20 | const TTCONVERT = "tt_convert"; |
21 | + const DLOBJECT = "download_object"; | ||
21 | const PARAMINFO = "param_info"; | 22 | const PARAMINFO = "param_info"; |
22 | const USERWSINIT = "user_init"; | 23 | const USERWSINIT = "user_init"; |
23 | } | 24 | } |
src/InputOutput/IHMImpl/DownloadObject/IHMInputOutputDownloadObjectClass.php
0 → 100644
@@ -0,0 +1,90 @@ | @@ -0,0 +1,90 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * @class IHMInputOutputDownloadObjectClass | ||
5 | + * @brief Class that's implement an InputOutputInterface used to treat a get download object request | ||
6 | + * @details | ||
7 | + */ | ||
8 | +class IHMInputOutputDownloadObjectClass implements InputOutputInterface | ||
9 | +{ | ||
10 | + /* | ||
11 | + * @brief Get working dir name | ||
12 | + */ | ||
13 | + protected function getWorkingDirName() | ||
14 | + { | ||
15 | + return $this->requestDirPrefix."DownloadData_"; | ||
16 | + } | ||
17 | + | ||
18 | + /* | ||
19 | + * @brief Get full working dir path | ||
20 | + */ | ||
21 | + protected function getWorkingPath() | ||
22 | + { | ||
23 | + return IHMConfigClass::getRequestPath().$this->getWorkingDirName().'/'; | ||
24 | + } | ||
25 | + | ||
26 | + public function getInputData($input, $function, $requestId = ""){ | ||
27 | + if (is_dir(IHMConfigClass::getDownloadTmpPath())) { | ||
28 | + foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.zip') as $filename) unlink($filename); | ||
29 | + foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.tar.gz') as $filename) unlink($filename); | ||
30 | + } | ||
31 | + else { | ||
32 | + mkdir(IHMConfigClass::getDownloadTmpPath()); | ||
33 | + } | ||
34 | + | ||
35 | + $this->downloadObjectData = new DownloadObjectRequestDataClass(); | ||
36 | + | ||
37 | + if($input->nodeType == "download" && $input->downloadSrc == "2") | ||
38 | + { | ||
39 | + // Set type | ||
40 | + $this->downloadObjectData->setType(DownloadObjectTypeEnumClass::ASTROIMG); | ||
41 | + | ||
42 | + | ||
43 | + // Set list of links to download | ||
44 | + if(sizeof($input->list) > 0){ | ||
45 | + foreach ($input->list as $file) { | ||
46 | + $this->downloadObjectData->addFile($file->name, $file->url); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + } | ||
51 | + else { | ||
52 | + throw new Exception('Unknown download data type.'); | ||
53 | + } | ||
54 | + | ||
55 | + $outputFileName = "".$this->downloadObjectData->getType()."_".time(); | ||
56 | + | ||
57 | + // Set working dir | ||
58 | + $this->downloadObjectData->setWorkingPath($this->getWorkingPath()); | ||
59 | + | ||
60 | + // Set compression format | ||
61 | + switch ($input->compression) { | ||
62 | + case DownloadObjectFormatEnumClass::ZIP: | ||
63 | + $this->downloadObjectData->setCompressionFormat(DownloadObjectFormatEnumClass::ZIP); | ||
64 | + $extension = ".zip"; | ||
65 | + break; | ||
66 | + default: | ||
67 | + throw new Exception('Unknown compression format type.'); | ||
68 | + } | ||
69 | + | ||
70 | + | ||
71 | + // Set output | ||
72 | + $outputPath = IHMConfigClass::getDownloadTmpPath() . $outputFileName . $extension; | ||
73 | + $this->downloadObjectData->setOutputPath($outputPath); | ||
74 | + | ||
75 | + return $this->downloadObjectData; | ||
76 | + | ||
77 | + } | ||
78 | + public function getOutput($data) | ||
79 | + { | ||
80 | + if (!$data->getSuccess()) | ||
81 | + return array( | ||
82 | + 'success' => false, | ||
83 | + 'message' => $data->getLastErrorMessage()); | ||
84 | + | ||
85 | + return array( | ||
86 | + 'success' => true, | ||
87 | + 'download' => str_replace(IHM_SRC_DIR, '', $data->getOutputPath()), | ||
88 | + ); | ||
89 | + } | ||
90 | +} | ||
0 | \ No newline at end of file | 91 | \ No newline at end of file |
src/InputOutput/IHMImpl/IHMInputOutputClass.php
@@ -71,10 +71,10 @@ class IHMInputOutputClass implements InputOutputInterface | @@ -71,10 +71,10 @@ class IHMInputOutputClass implements InputOutputInterface | ||
71 | $this->inputOutput = new IHMInputOutputParamsGeneratorClass(); | 71 | $this->inputOutput = new IHMInputOutputParamsGeneratorClass(); |
72 | $requestId = "ParamGen"; | 72 | $requestId = "ParamGen"; |
73 | break; | 73 | break; |
74 | - case FunctionTypeEnumClass::PARAMSINFOGEN : | ||
75 | - $this->inputOutput = new IHMInputOutputParamsInfoGeneratorClass(); | ||
76 | - $requestId = "ParamInfoGen"; | ||
77 | - break; | 74 | + case FunctionTypeEnumClass::PARAMSINFOGEN : |
75 | + $this->inputOutput = new IHMInputOutputParamsInfoGeneratorClass(); | ||
76 | + $requestId = "ParamInfoGen"; | ||
77 | + break; | ||
78 | case FunctionTypeEnumClass::ACTION : | 78 | case FunctionTypeEnumClass::ACTION : |
79 | if (!$input->action->multiplot) { | 79 | if (!$input->action->multiplot) { |
80 | $this->inputOutput = new IHMInputOutputParamsPlotClass(); | 80 | $this->inputOutput = new IHMInputOutputParamsPlotClass(); |
@@ -111,6 +111,9 @@ class IHMInputOutputClass implements InputOutputInterface | @@ -111,6 +111,9 @@ class IHMInputOutputClass implements InputOutputInterface | ||
111 | case FunctionTypeEnumClass::PARAMINFO : | 111 | case FunctionTypeEnumClass::PARAMINFO : |
112 | $this->inputOutput = new IHMInputOutputParamInfoClass(); | 112 | $this->inputOutput = new IHMInputOutputParamInfoClass(); |
113 | break; | 113 | break; |
114 | + case FunctionTypeEnumClass::DLOBJECT : | ||
115 | + $this->inputOutput = new IHMInputOutputDownloadObjectClass(); | ||
116 | + break; | ||
114 | case FunctionTypeEnumClass::USERWSINIT : | 117 | case FunctionTypeEnumClass::USERWSINIT : |
115 | return $this->userWSMgr->init(); | 118 | return $this->userWSMgr->init(); |
116 | default : | 119 | default : |
src/InputOutput/IHMImpl/ParamInfo/IHMInputOutputParamInfoClass.php
@@ -565,6 +565,11 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -565,6 +565,11 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
565 | $this->unmarshallSymbolData($drawNode->getTimeTicks()->getFirstSymbol(), "serie-timetick-firstsymbols-", $result_array); | 565 | $this->unmarshallSymbolData($drawNode->getTimeTicks()->getFirstSymbol(), "serie-timetick-firstsymbols-", $result_array); |
566 | } | 566 | } |
567 | 567 | ||
568 | + if ($drawNode->getTimeTicks()->isLastSymbolDefined()) { | ||
569 | + $result_array['serie-timetick-lastsymbols-activated'] = true; | ||
570 | + $this->unmarshallSymbolData($drawNode->getTimeTicks()->getLastSymbol(), "serie-timetick-lastsymbols-", $result_array); | ||
571 | + } | ||
572 | + | ||
568 | if ($drawNode->getTimeTicks()->isFontDefined()) { | 573 | if ($drawNode->getTimeTicks()->isFontDefined()) { |
569 | $result_array['serie-timetick-font-activated'] = true; | 574 | $result_array['serie-timetick-font-activated'] = true; |
570 | $this->unmarshallFontData($drawNode->getTimeTicks()->getFont(), "serie-timetick-font-", $result_array); | 575 | $this->unmarshallFontData($drawNode->getTimeTicks()->getFont(), "serie-timetick-font-", $result_array); |
@@ -581,6 +586,11 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -581,6 +586,11 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
581 | $this->unmarshallSymbolData($drawNode->getIntervalTicks()->getSymbol(), "serie-intervaltick-", $result_array); | 586 | $this->unmarshallSymbolData($drawNode->getIntervalTicks()->getSymbol(), "serie-intervaltick-", $result_array); |
582 | } | 587 | } |
583 | 588 | ||
589 | + if ($drawNode->getIntervalTicks()->isLastSymbolDefined()) { | ||
590 | + $result_array['serie-intervaltick-lastsymbols-activated'] = true; | ||
591 | + $this->unmarshallSymbolData($drawNode->getIntervalTicks()->getLastSymbol(), "serie-intervaltick-lastsymbols-", $result_array); | ||
592 | + } | ||
593 | + | ||
584 | if ($drawNode->getIntervalTicks()->isFontDefined()) { | 594 | if ($drawNode->getIntervalTicks()->isFontDefined()) { |
585 | $result_array['serie-intervaltick-font-activated'] = true; | 595 | $result_array['serie-intervaltick-font-activated'] = true; |
586 | $this->unmarshallFontData($drawNode->getIntervalTicks()->getFont(), "serie-intervaltick-font-", $result_array); | 596 | $this->unmarshallFontData($drawNode->getIntervalTicks()->getFont(), "serie-intervaltick-font-", $result_array); |
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -946,6 +946,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -946,6 +946,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
946 | //First Symbol | 946 | //First Symbol |
947 | if ($serieData->{'serie-timetick-firstsymbols-activated'}) | 947 | if ($serieData->{'serie-timetick-firstsymbols-activated'}) |
948 | $this->unmarshallSymbol($serieData, 'serie-timetick-firstsymbols', $timeTickNode->getFirstSymbol()); | 948 | $this->unmarshallSymbol($serieData, 'serie-timetick-firstsymbols', $timeTickNode->getFirstSymbol()); |
949 | + //Last Symbol | ||
950 | + if ($serieData->{'serie-timetick-lastsymbols-activated'}) | ||
951 | + $this->unmarshallSymbol($serieData, 'serie-timetick-lastsymbols', $timeTickNode->getLastSymbol()); | ||
949 | //Symbol | 952 | //Symbol |
950 | $this->unmarshallSymbol($serieData, 'serie-timetick-symbols', $timeTickNode->getSymbol()); | 953 | $this->unmarshallSymbol($serieData, 'serie-timetick-symbols', $timeTickNode->getSymbol()); |
951 | //Set options by type | 954 | //Set options by type |
@@ -993,6 +996,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -993,6 +996,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
993 | //Symbol | 996 | //Symbol |
994 | $this->unmarshallSymbol($serieData, 'serie-intervaltick-symbols', $intervalTickNode->getSymbol()); | 997 | $this->unmarshallSymbol($serieData, 'serie-intervaltick-symbols', $intervalTickNode->getSymbol()); |
995 | 998 | ||
999 | + //Last Symbol | ||
1000 | + if ($serieData->{'serie-intervaltick-lastsymbols-activated'}) | ||
1001 | + $this->unmarshallSymbol($serieData, 'serie-intervaltick-lastsymbols', $intervalTickNode->getLastSymbol()); | ||
1002 | + | ||
996 | //Font | 1003 | //Font |
997 | if ($serieData->{'serie-intervaltick-font-activated'}) | 1004 | if ($serieData->{'serie-intervaltick-font-activated'}) |
998 | $this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont()); | 1005 | $this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont()); |
@@ -1129,6 +1136,12 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -1129,6 +1136,12 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
1129 | 1136 | ||
1130 | $intervalsNode = $paramNode->addIntervals($color); | 1137 | $intervalsNode = $paramNode->addIntervals($color); |
1131 | 1138 | ||
1139 | + if ($paramDrawingData->{'intervals-column-show'}){ | ||
1140 | + $columnId = $paramDrawingData->{'intervals-param-show'}; | ||
1141 | + if ($columnId !== "" ) | ||
1142 | + $intervalsNode->setColumnId($columnId); | ||
1143 | + } | ||
1144 | + | ||
1132 | if ($paramDrawingData->{'legend-text-activated'}) { | 1145 | if ($paramDrawingData->{'legend-text-activated'}) { |
1133 | $textLegendNode = $intervalsNode->addTextLegend(); | 1146 | $textLegendNode = $intervalsNode->addTextLegend(); |
1134 | 1147 |
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
@@ -291,7 +291,19 @@ class IHMParamManagerClass | @@ -291,7 +291,19 @@ class IHMParamManagerClass | ||
291 | throw new Exception('Cannot generate parameter template file '.$paramId); | 291 | throw new Exception('Cannot generate parameter template file '.$paramId); |
292 | } | 292 | } |
293 | else { | 293 | else { |
294 | - $paramPath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml"; | 294 | + $template_args = array(); |
295 | + | ||
296 | + $templated_ref_param = $this->templateParamsManager->parseTemplatedParam($paramId); | ||
297 | + | ||
298 | + if ($templated_ref_param !== FALSE) { | ||
299 | + foreach ($templated_ref_param['template_args'] as $key => $val) { | ||
300 | + $template_args[$key] = $val; | ||
301 | + } | ||
302 | + $paramPath = $this->templateParamsManager->generateTemplatedParamFile($templated_ref_param['paramid'], $templateArgs, $tableLink); | ||
303 | + } | ||
304 | + else { | ||
305 | + $paramPath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml"; | ||
306 | + } | ||
295 | if (!file_exists($paramPath)) | 307 | if (!file_exists($paramPath)) |
296 | throw new Exception('Cannot find parameter local file '.$paramId); | 308 | throw new Exception('Cannot find parameter local file '.$paramId); |
297 | } | 309 | } |
@@ -319,7 +331,20 @@ class IHMParamManagerClass | @@ -319,7 +331,20 @@ class IHMParamManagerClass | ||
319 | throw new Exception('Cannot find parameter template file '.$paramId); | 331 | throw new Exception('Cannot find parameter template file '.$paramId); |
320 | } | 332 | } |
321 | else { | 333 | else { |
322 | - $paramPath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml"; | 334 | + $template_args = array(); |
335 | + | ||
336 | + $templated_ref_param = $this->templateParamsManager->parseTemplatedParam($paramId); | ||
337 | + | ||
338 | + if ($templated_ref_param !== FALSE) { | ||
339 | + foreach ($templated_ref_param['template_args'] as $key => $val) { | ||
340 | + $template_args[$key] = $val; | ||
341 | + } | ||
342 | + $paramPath = $this->templateParamsManager->generateTemplatedParamFile($templated_ref_param['paramid'], $templateArgs, $tableLink); | ||
343 | + } | ||
344 | + else { | ||
345 | + $paramPath = IHMConfigClass::getLocalParamDBPath().$paramId.".xml"; | ||
346 | + } | ||
347 | + | ||
323 | if (empty($paramPath) || !@$doc->load($paramPath)) | 348 | if (empty($paramPath) || !@$doc->load($paramPath)) |
324 | throw new Exception('Cannot find parameter local file '.$paramId); | 349 | throw new Exception('Cannot find parameter local file '.$paramId); |
325 | } | 350 | } |
src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php
@@ -72,26 +72,64 @@ class IHMPlotContextFileClass | @@ -72,26 +72,64 @@ class IHMPlotContextFileClass | ||
72 | 'MinSampling' => $item->getAttribute('MinSampling') | 72 | 'MinSampling' => $item->getAttribute('MinSampling') |
73 | ); | 73 | ); |
74 | 74 | ||
75 | - $panelContext[$PARAMETERS_TAG][] = $pContext; | ||
76 | - } | ||
77 | - } | ||
78 | - | ||
79 | - | ||
80 | - //<intervals> | ||
81 | - $intervalsNodes = $panelNode->getElementsByTagName('intervals'); | ||
82 | - if ($intervalsNodes->length > 0) { | ||
83 | - $panelContext['intervals'] = array(); | ||
84 | - | ||
85 | - foreach ($intervalsNodes as $intervalsNode) { | ||
86 | - $intervalsContext = array( | ||
87 | - 'name' => $intervalsNode->getAttribute('name'), | ||
88 | - 'id' => $intervalsNode->getAttribute('id'), | ||
89 | - 'startTime' => $intervalsNode->getAttribute('startTime'), | ||
90 | - 'stopTime' => $intervalsNode->getAttribute('stopTime'), | ||
91 | - 'params' => $intervalsNode->getAttribute('params') | ||
92 | - ); | ||
93 | - | ||
94 | - $panelContext['intervals'][] = $intervalsContext; | 75 | + //<catalog> or <timetable> |
76 | + $catalogNodes = $item->getElementsByTagName('catalog'); | ||
77 | + $timetableNodes = $item->getElementsByTagName('timetable'); | ||
78 | + if (($catalogNodes->length > 0) || ($timetableNodes->length > 0)) { | ||
79 | + $isCatalog = FALSE; | ||
80 | + if ($catalogNodes->length > 0) { | ||
81 | + $isCatalog = TRUE; | ||
82 | + $ttorcatNode = $catalogNodes->item(0); | ||
83 | + } | ||
84 | + else { | ||
85 | + $ttorcatNode = $timetableNodes->item(0); | ||
86 | + } | ||
87 | + | ||
88 | + $ttOrCatContext = array( | ||
89 | + 'name' => $ttorcatNode->getAttribute('name'), | ||
90 | + 'columnToShow' => $ttorcatNode->getAttribute('columnToShow'), | ||
91 | + ); | ||
92 | + | ||
93 | + if ($isCatalog) { | ||
94 | + //<columns> | ||
95 | + $columnsNodes = $ttorcatNode->getElementsByTagName('columns'); | ||
96 | + if ($columnsNodes->length > 0) { | ||
97 | + $ttOrCatContext['columns'] = []; | ||
98 | + $columnNodes = $columnsNodes->item(0)->getElementsByTagName('column'); | ||
99 | + foreach ($columnNodes as $columnNode) { | ||
100 | + $ttOrCatContext['columns'][$columnNode->getAttribute('id')] = array( | ||
101 | + 'name' => $columnNode->getAttribute('name') | ||
102 | + ); | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + } | ||
107 | + | ||
108 | + //<intervals> | ||
109 | + $intervalsNodes = $ttorcatNode->getElementsByTagName('intervals'); | ||
110 | + if ($intervalsNodes->length > 0) { | ||
111 | + $ttOrCatContext['intervals'] = []; | ||
112 | + $intervalNodes = $intervalsNodes->item(0)->getElementsByTagName('interval'); | ||
113 | + foreach ($intervalNodes as $intervalNode) { | ||
114 | + $intervalContext = array( | ||
115 | + 'start' => $intervalNode->getAttribute('startTime'), | ||
116 | + 'stop' => $intervalNode->getAttribute('stopTime'), | ||
117 | + ); | ||
118 | + if ($isCatalog) { | ||
119 | + $intervalContext['params'] = array(); | ||
120 | + $paramNodes = $intervalNode->getElementsByTagName('param'); | ||
121 | + if ($paramNodes->length > 0) { | ||
122 | + foreach ($paramNodes as $paramNode) { | ||
123 | + $intervalContext['params'][$paramNode->getAttribute('id')] = $paramNode->getAttribute('val'); | ||
124 | + } | ||
125 | + } | ||
126 | + } | ||
127 | + $ttOrCatContext['intervals'][$intervalNode->getAttribute('id')] = $intervalContext; | ||
128 | + } | ||
129 | + } | ||
130 | + $pContext['ttorcat'] = $ttOrCatContext; | ||
131 | + } | ||
132 | + $panelContext[$PARAMETERS_TAG][] = $pContext; | ||
95 | } | 133 | } |
96 | } | 134 | } |
97 | 135 |
@@ -0,0 +1,122 @@ | @@ -0,0 +1,122 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * @class DownloadObjectRequestClass | ||
5 | + * @brief Class used for a download request | ||
6 | + * @details | ||
7 | + */ | ||
8 | +class DownloadObjectRequestClass extends RequestAbstractClass | ||
9 | +{ | ||
10 | + | ||
11 | + /* | ||
12 | + * @brief Init a donwload object request | ||
13 | + */ | ||
14 | + public function init(){ | ||
15 | + if (!isset($this->requestData)) | ||
16 | + return false; | ||
17 | + if (!is_dir($this->requestData->getWorkingPath())) { | ||
18 | + mkdir($this->requestData->getWorkingPath()); | ||
19 | + } | ||
20 | + return true; | ||
21 | + } | ||
22 | + | ||
23 | + public function run(){ | ||
24 | + // Array to hold the paths of the downloaded files | ||
25 | + $filePaths = array(); | ||
26 | + | ||
27 | + $files = $this->requestData->getFiles(); | ||
28 | + foreach($files as $fileName => $fileUrl){ | ||
29 | + $result = $this->downloadFile($fileName, $fileUrl, $this->requestData->getWorkingPath()); | ||
30 | + if (!$result['success']) { | ||
31 | + $this->cleanup($filePaths); | ||
32 | + $this->requestData->setLastErrorMessage($result['message']); | ||
33 | + $this->requestData->setSuccess(false); | ||
34 | + return false; | ||
35 | + } | ||
36 | + $filePaths[] = $result['filePath']; | ||
37 | + } | ||
38 | + | ||
39 | + | ||
40 | + $result = $this->zipFiles($filePaths, $this->requestData->getOutputPath()); | ||
41 | + if (!$result['success']) { | ||
42 | + $this->cleanup($filePaths); | ||
43 | + $this->requestData->setLastErrorMessage($result['message']); | ||
44 | + $this->requestData->setSuccess(false); | ||
45 | + | ||
46 | + return false; | ||
47 | + } | ||
48 | + | ||
49 | + $this->cleanup($filePaths); | ||
50 | + | ||
51 | + $this->requestData->setSuccess(true); | ||
52 | + | ||
53 | + return true; | ||
54 | + } | ||
55 | + | ||
56 | + public function downloadFile($fileName, $fileUrl, $workingDir){ | ||
57 | + // Initialize cURL session | ||
58 | + $ch = curl_init($fileUrl); | ||
59 | + // Set cURL options | ||
60 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
61 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
62 | + | ||
63 | + // Execute cURL request | ||
64 | + $content = curl_exec($ch); | ||
65 | + | ||
66 | + // Check for cURL errors | ||
67 | + if (curl_errno($ch)) { | ||
68 | + curl_close($ch); | ||
69 | + return array( | ||
70 | + "success" => FALSE, | ||
71 | + "message" => "Cannot download $fileUrl", | ||
72 | + ); | ||
73 | + } | ||
74 | + | ||
75 | + // Close cURL session | ||
76 | + curl_close($ch); | ||
77 | + | ||
78 | + // Write file in working dir | ||
79 | + $filePath = $workingDir . '/' . $fileName; | ||
80 | + file_put_contents($filePath, $content); | ||
81 | + | ||
82 | + return array( | ||
83 | + "success" => TRUE, | ||
84 | + "filePath" => $filePath, | ||
85 | + ); | ||
86 | + } | ||
87 | + | ||
88 | + public function zipFiles($filePaths, $outputPath){ | ||
89 | + | ||
90 | + // Create a zip file | ||
91 | + $zip = new ZipArchive(); | ||
92 | + | ||
93 | + if ($zip->open($outputPath, ZipArchive::CREATE) !== TRUE) { | ||
94 | + return array( | ||
95 | + "success" => FALSE, | ||
96 | + "message" => "Cannot create output archive", | ||
97 | + ); | ||
98 | + } | ||
99 | + | ||
100 | + // Add files to the zip archive | ||
101 | + foreach ($filePaths as $filePath) { | ||
102 | + $zip->addFile($filePath, basename($filePath)); | ||
103 | + } | ||
104 | + | ||
105 | + // Close the zip archive | ||
106 | + $zip->close(); | ||
107 | + | ||
108 | + // Return the path of the zip file | ||
109 | + return array( | ||
110 | + "success" => TRUE, | ||
111 | + "zipfilepath" => $outputPath, | ||
112 | + ); | ||
113 | + } | ||
114 | + | ||
115 | + public function cleanup($filePaths) { | ||
116 | + // Clean up the temporary files | ||
117 | + foreach ($filePaths as $filePath) { | ||
118 | + if (file_exists($filePath)) | ||
119 | + unlink($filePath); | ||
120 | + } | ||
121 | + } | ||
122 | +} | ||
0 | \ No newline at end of file | 123 | \ No newline at end of file |
@@ -0,0 +1,90 @@ | @@ -0,0 +1,90 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * @class DownloadObjectTypeEnumClass | ||
5 | + * @brief Enumerate for download request type | ||
6 | + * @details | ||
7 | + */ | ||
8 | +abstract class DownloadObjectTypeEnumClass | ||
9 | +{ | ||
10 | + const UNKNOWN = ""; | ||
11 | + const ASTROIMG = "astro_image"; | ||
12 | +} | ||
13 | + | ||
14 | +/** | ||
15 | + * @class DownloadObjectFormatEnumClass | ||
16 | + * @brief Enumerate for download extention request type | ||
17 | + * @details | ||
18 | + */ | ||
19 | +abstract class DownloadObjectFormatEnumClass | ||
20 | +{ | ||
21 | + const UNKNOWN = ""; | ||
22 | + const ZIP = "zip"; | ||
23 | +} | ||
24 | + | ||
25 | + | ||
26 | +/** | ||
27 | + * @class DownloadObjectRequestDataClass | ||
28 | + * @brief Data for a download request | ||
29 | + * @details | ||
30 | + */ | ||
31 | +class DownloadObjectRequestDataClass extends RequestDataClass | ||
32 | +{ | ||
33 | + private $type = DownloadObjectTypeEnumClass::UNKNOWN; | ||
34 | + private $files = array(); | ||
35 | + private $compression = DownloadObjectFormatEnumClass::ZIP; | ||
36 | + private $workingPath = ""; | ||
37 | + private $outputPath = ""; | ||
38 | + | ||
39 | + | ||
40 | + public function getType() | ||
41 | + { | ||
42 | + return $this->type; | ||
43 | + } | ||
44 | + | ||
45 | + public function setType($type) | ||
46 | + { | ||
47 | + $this->type = $type; | ||
48 | + } | ||
49 | + | ||
50 | + public function getFiles() | ||
51 | + { | ||
52 | + return $this->files; | ||
53 | + } | ||
54 | + | ||
55 | + public function addFile($name, $url) | ||
56 | + { | ||
57 | + $this->files[$name] = $url; | ||
58 | + } | ||
59 | + | ||
60 | + public function getWorkingPath() | ||
61 | + { | ||
62 | + return $this->workingPath; | ||
63 | + } | ||
64 | + | ||
65 | + public function setWorkingPath($workingPath) | ||
66 | + { | ||
67 | + $this->workingPath = $workingPath; | ||
68 | + } | ||
69 | + | ||
70 | + public function getOutputPath() | ||
71 | + { | ||
72 | + return $this->outputPath; | ||
73 | + } | ||
74 | + | ||
75 | + public function setOutputPath($outputPath) | ||
76 | + { | ||
77 | + $this->outputPath = $outputPath; | ||
78 | + } | ||
79 | + | ||
80 | + public function getCompressionFormat() | ||
81 | + { | ||
82 | + return $this->compression; | ||
83 | + } | ||
84 | + | ||
85 | + public function setCompressionFormat($compression) | ||
86 | + { | ||
87 | + $this->compression = $compression; | ||
88 | + } | ||
89 | + | ||
90 | +} | ||
0 | \ No newline at end of file | 91 | \ No newline at end of file |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotIntervalsNodeClass.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | define("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals"); | 3 | define("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals"); |
4 | define("REQUESTOUTPUTPLOTINTERVALS_COLOR", "color"); | 4 | define("REQUESTOUTPUTPLOTINTERVALS_COLOR", "color"); |
5 | +define("REQUESTOUTPUTPLOTINTERVALS_COLUMNID", "columnId"); | ||
5 | 6 | ||
6 | 7 | ||
7 | /** | 8 | /** |
@@ -26,6 +27,14 @@ class RequestOutputPlotIntervalsNodeClass extends NodeClass | @@ -26,6 +27,14 @@ class RequestOutputPlotIntervalsNodeClass extends NodeClass | ||
26 | { | 27 | { |
27 | return $this->getAttribute(REQUESTOUTPUTPLOTINTERVALS_COLOR); | 28 | return $this->getAttribute(REQUESTOUTPUTPLOTINTERVALS_COLOR); |
28 | } | 29 | } |
30 | + | ||
31 | + public function setColumnId($columnId){ | ||
32 | + $this->setAttribute(REQUESTOUTPUTPLOTINTERVALS_COLUMNID, $columnId); | ||
33 | + } | ||
34 | + | ||
35 | + public function getColumnId(){ | ||
36 | + return $this->getAttribute(REQUESTOUTPUTPLOTINTERVALS_COLUMNID); | ||
37 | + } | ||
29 | 38 | ||
30 | public function addTextLegend() | 39 | public function addTextLegend() |
31 | { | 40 | { |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotSerieIntervalTicksNodeClass.php
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_MODE", "mode"); | 3 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_MODE", "mode"); |
4 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_COLOR", "color"); | 4 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_COLOR", "color"); |
5 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_SYMBOL", "symbol"); | 5 | define ("REQUESTOUTPUTPLOTSERIEINTERVALTICKS_SYMBOL", "symbol"); |
6 | +define ("REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL", "lastSymbol"); | ||
6 | 7 | ||
7 | abstract class RequestOutputPlotSerieIntervalTicksModeEnum | 8 | abstract class RequestOutputPlotSerieIntervalTicksModeEnum |
8 | { | 9 | { |
@@ -62,6 +63,25 @@ class RequestOutputPlotSerieIntervalTicksNodeClass extends NodeClass | @@ -62,6 +63,25 @@ class RequestOutputPlotSerieIntervalTicksNodeClass extends NodeClass | ||
62 | 63 | ||
63 | return $node; | 64 | return $node; |
64 | } | 65 | } |
66 | + | ||
67 | + public function isLastSymbolDefined() | ||
68 | + { | ||
69 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
70 | + return isset($node); | ||
71 | + } | ||
72 | + | ||
73 | + public function getLastSymbol() | ||
74 | + { | ||
75 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
76 | + | ||
77 | + if (!isset($node)) | ||
78 | + { | ||
79 | + $node = new RequestOutputPlotSymbolNodeClass(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
80 | + $this->addChild($node); | ||
81 | + } | ||
82 | + | ||
83 | + return $node; | ||
84 | + } | ||
65 | 85 | ||
66 | public function isFontDefined() | 86 | public function isFontDefined() |
67 | { | 87 | { |
@@ -90,6 +110,10 @@ class RequestOutputPlotSerieIntervalTicksNodeClass extends NodeClass | @@ -90,6 +110,10 @@ class RequestOutputPlotSerieIntervalTicksNodeClass extends NodeClass | ||
90 | $symbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIEINTERVALTICKS_SYMBOL); | 110 | $symbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIEINTERVALTICKS_SYMBOL); |
91 | if (isset($symbolXmlNode)) | 111 | if (isset($symbolXmlNode)) |
92 | $this->getSymbol()->loadFromNode($symbolXmlNode); | 112 | $this->getSymbol()->loadFromNode($symbolXmlNode); |
113 | + | ||
114 | + $lastsymbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
115 | + if (isset($lastsymbolXmlNode)) | ||
116 | + $this->getLastSymbol()->loadFromNode($lastsymbolXmlNode); | ||
93 | 117 | ||
94 | $fontXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTFONT_NODENAME); | 118 | $fontXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTFONT_NODENAME); |
95 | if (isset($fontXmlNode)) | 119 | if (isset($fontXmlNode)) |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotSerieTimeTicksNodeClass.php
@@ -6,6 +6,7 @@ define ("REQUESTOUTPUTPLOTSERIETIMETICKS_MINOR", "minor"); | @@ -6,6 +6,7 @@ define ("REQUESTOUTPUTPLOTSERIETIMETICKS_MINOR", "minor"); | ||
6 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_COLOR", "color"); | 6 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_COLOR", "color"); |
7 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_SYMBOL", "symbol"); | 7 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_SYMBOL", "symbol"); |
8 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_FIRSTSYMBOL", "firstSymbol"); | 8 | define ("REQUESTOUTPUTPLOTSERIETIMETICKS_FIRSTSYMBOL", "firstSymbol"); |
9 | +define ("REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL", "lastSymbol"); | ||
9 | 10 | ||
10 | /** | 11 | /** |
11 | * @class RequestOutputPlotSerieTimeTicksNodeClass | 12 | * @class RequestOutputPlotSerieTimeTicksNodeClass |
@@ -56,6 +57,26 @@ class RequestOutputPlotSerieTimeTicksNodeClass extends NodeClass | @@ -56,6 +57,26 @@ class RequestOutputPlotSerieTimeTicksNodeClass extends NodeClass | ||
56 | 57 | ||
57 | return $node; | 58 | return $node; |
58 | } | 59 | } |
60 | + | ||
61 | + public function isLastSymbolDefined() | ||
62 | + { | ||
63 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
64 | + return isset($node); | ||
65 | + } | ||
66 | + | ||
67 | + public function getLastSymbol() | ||
68 | + { | ||
69 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
70 | + | ||
71 | + if (!isset($node)) | ||
72 | + { | ||
73 | + $node = new RequestOutputPlotSymbolNodeClass(REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
74 | + $this->addChild($node); | ||
75 | + } | ||
76 | + | ||
77 | + return $node; | ||
78 | + } | ||
79 | + | ||
59 | 80 | ||
60 | public function isFontDefined() | 81 | public function isFontDefined() |
61 | { | 82 | { |
@@ -125,6 +146,10 @@ class RequestOutputPlotSerieTimeTicksNodeClass extends NodeClass | @@ -125,6 +146,10 @@ class RequestOutputPlotSerieTimeTicksNodeClass extends NodeClass | ||
125 | $firstsymbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIETIMETICKS_FIRSTSYMBOL); | 146 | $firstsymbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIETIMETICKS_FIRSTSYMBOL); |
126 | if (isset($firstsymbolXmlNode)) | 147 | if (isset($firstsymbolXmlNode)) |
127 | $this->getFirstSymbol()->loadFromNode($firstsymbolXmlNode); | 148 | $this->getFirstSymbol()->loadFromNode($firstsymbolXmlNode); |
149 | + | ||
150 | + $lastsymbolXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTSERIETIMETICKS_LASTSYMBOL); | ||
151 | + if (isset($lastsymbolXmlNode)) | ||
152 | + $this->getLastSymbol()->loadFromNode($lastsymbolXmlNode); | ||
128 | 153 | ||
129 | $fontXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTFONT_NODENAME); | 154 | $fontXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTFONT_NODENAME); |
130 | if (isset($fontXmlNode)) | 155 | if (isset($fontXmlNode)) |
src/RequestManagerClass.php
@@ -84,6 +84,8 @@ Class RequestManagerClass | @@ -84,6 +84,8 @@ Class RequestManagerClass | ||
84 | return new ParamInfoRequestClass($user, $userHost); | 84 | return new ParamInfoRequestClass($user, $userHost); |
85 | case FunctionTypeEnumClass::USERWSINIT : | 85 | case FunctionTypeEnumClass::USERWSINIT : |
86 | return new UserRequestClass($user, $userHost); | 86 | return new UserRequestClass($user, $userHost); |
87 | + case FunctionTypeEnumClass::DLOBJECT : | ||
88 | + return new DownloadObjectRequestClass($user, $userHost); | ||
87 | default : | 89 | default : |
88 | throw new Exception('Request '.$function.' not implemented.'); | 90 | throw new Exception('Request '.$function.' not implemented.'); |
89 | } | 91 | } |
src/amdaintegration_autoload.php
@@ -23,6 +23,7 @@ class AutoloadData { | @@ -23,6 +23,7 @@ class AutoloadData { | ||
23 | 'InputOutput/IHMImpl/Params/GenInfoParamImpl', | 23 | 'InputOutput/IHMImpl/Params/GenInfoParamImpl', |
24 | 'InputOutput/IHMImpl/Process', | 24 | 'InputOutput/IHMImpl/Process', |
25 | 'InputOutput/IHMImpl/ParamInfo', | 25 | 'InputOutput/IHMImpl/ParamInfo', |
26 | + 'InputOutput/IHMImpl/DownloadObject', | ||
26 | 'InputOutput/IHMImpl/Tools', | 27 | 'InputOutput/IHMImpl/Tools', |
27 | 'InputOutput/IHMImpl/TimeTables', | 28 | 'InputOutput/IHMImpl/TimeTables', |
28 | 'InputOutput/TestImpl', | 29 | 'InputOutput/TestImpl', |