-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttw_step2.php
92 lines (76 loc) · 2.71 KB
/
ttw_step2.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
<?php
session_start();
include_once "ttw_includes_var_func.php";
include_once "ttw_includes_head.php";
show_intro();
?>
<h3>Step 2: Select functions and output format</h3>
<?php
if(!isset($_POST["submit"])){
?>
<p>We strongly recommend to choose the following pre-selected options:</p>
<form method="post" action="">
<div class="infobox">
<ul>
<li><input type="checkbox" name="options[]" value="--bodyTags" checked>Set customized journal body tags</li>
<li><input type="checkbox" name="options[]" value="--figTags" checked>Set figure references tags</li>
<li><input type="checkbox" name="options[]" value="--litTags" checked>Set author year tags. *CAUTION*: Author Year List (.csv) *REQUIRED*"</li>
<li><input type="checkbox" name="options[]" value="--paragrNum" checked>Set paragraph numbers (recommended only if --bodyTags is chosen as well)</li>
<li><input type="checkbox" name="options[]" value="--illCred" checked>Insert tagged illustration credits section. *CAUTION*: Illustration Credit List (.csv) *REQUIRED*</li>
<li><input type="checkbox" name="options[]" value="--addSR" checked>Additional search and replace based on a value list. *CAUTION*: To Search And Replace List (.csv) *REQUIRED*.</li>
</ul>
</div>
<p>Choose output format:</p>
<select name="options[]">
<option value ="--toXML" selected>.xml</option>
<option value ="--toHTML">.html</option>
</select>
<h3>Submit and continue</h3>
<input type="submit" name="submit" value="Submit">
<?php
}
if(isset($_POST["submit"])){
$complete = true;
$options = $_POST['options'];
if(sizeof($options) < 2){
$complete = false;
}
if(!$complete){
?>
<script type="text/javascript" language="Javascript">
alert("Parameter(s) missing. \nCheck again and repeat submission.");
</script>
<?php
}
else {
//Extract output format
$outputFormat = null;
foreach($options as $option){
if($option == "--toHTML"){
$outputFormat = "html";
}
if($option == "--toXML"){
$outputFormat = "xml";
}
}
if($outputFormat!="") {
$_SESSION["outputFormat"] = $outputFormat;
}
//Start conversion and convert .docx to .html with pandoc...
$call_pandoc = "pandoc -s -o " . $sessionTempPath . "articleFile.html" . " " . $sessionTempPath . "articleFile.docx";
shell_exec($call_pandoc);
//.. and create a .zip archive
$fullPath = $sessionTempPath . "ttw_result.zip";
$zipArchive = new ZipArchive();
$zipArchive->open($fullPath, ZipArchive::CREATE);
$zipArchive->addFromString("InitialFile.txt", "Initial File\n");
$zipArchive->close();
//... finally run TagTool
call_ttw($options);
open_proceed_box("3", $_POST['options']);
}
}
?>
</form>
</body>
</html>