-
Notifications
You must be signed in to change notification settings - Fork 1
/
readFiles.php
116 lines (105 loc) · 3.24 KB
/
readFiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php include("parts_checkSession.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-US" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/frame.css" />
<title>Read Files</title>
<script src="js/function.js" type="text/javascript">
</script>
<style type="text/css">
.style1 {
border: 1px solid #000000;
background-color: #C0C0C0;
}
.style2 {
border: 2px solid #000000;
}
.style3 {
border: 1px solid #000000;
}
.style4 {
border: 1px solid #000000;
text-align: center;
}
.style5 {
text-align: center;
}
</style>
</head>
<body>
<div id="container">
<?php include("parts_header.php"); ?>
<?php include("function.php"); ?>
<?php
$fileNum = 1; //TODO
$files = array();
for($i = 0; $i < $fileNum; $i++) {
$line = "";
$flg[0] = "";
$flg[1] = "";
$flg[2] = "";
$lineNo = 0;
$ret = createExpArray();
$file = fopen($_FILES["FilePath"]["tmp_name"],"r") or exit("Unable to open file!");
while(!feof($file)) {
$lineNo++;
$line = fgets($file);
$flg = judgeContentType($line, $flg); // explode,splitStrToArray
//echo "[line".$lineNo."],[".$flg[0]."],[".$flg[1]."],[".$flg[2]."]<br>"; //debug
$ret = getSpliterResult($flg, $line, $ret);
}
fclose($file);
$ret = checkExpId($ret, $_FILES["FilePath"]["name"]);
$ret = checkCoordinate($ret);
$files[$i] = $ret;
//print_r($ret); //debug
}
?>
<div id="content">
<form id="form1" method="post" action="saveFiles.php">
<table class="style2" style="width: 600px" align="center">
<tr>
<td class="style1">Experiment ID</td>
<td class="style1">Treatment Num</td>
<td class="style1">Treatment Name</td>
<td class="style1" style="width: 81px">Select?</td>
</tr>
<?php
$jsCheck = "";
for($i = 0; $i < count($files); $i++) {
$exp = $files[$i];
$trs = $exp["treatments"];
$expId = $exp["exp.details:"]["exname"];
$isFstLine = true;
foreach ($trs as $tr) {
echo "<tr>";
if ($isFstLine) {
echo "<td rowspan='". count($trs) ."' class='style3'>" . $expId . "</td>";
$isFstLine = false;
}
$trNum = $tr["trtno"];
$trName = $tr["titlet"];
$checkBoxId = $expId . "_" . $trNum;
$jsCheck = $jsCheck . $checkBoxId . ",";
echo "<td class='style4'>" . $trNum . "</td>";
echo "<td class='style3'>" . $trName . "</td>";
echo "<td class='style4' style='width: 81px'><input id='" . $checkBoxId . "' name='" . $expId . "[]' type='checkbox' checked='checked' value='" . $trNum . "' /></td>";
echo "</tr>";
}
}
echo "<input name='files' type='hidden' value='" . json_encode($files) . "' />";
?>
</table>
<br />
<p class="style5">
<span><input name="Button1" type="button" value="Back" onclick="goBack()"/></span>
<span><input id="save" name="save" type="button" value="Save" onclick="checkChkbox('<?php echo $jsCheck; ?>')" /></span></form>
</p>
</form>
</div>
<?php include("parts_footer.php"); ?>
</div>
</body>
</html>