-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjsonTestValidator.php
150 lines (123 loc) · 6.57 KB
/
jsonTestValidator.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
require __DIR__."/../../config/bootstrap.php";
redirectToolDevOutside();
if(!isset($_REQUEST['id'])) {
$_SESSION['errorData']['Error'][] = "Please provide a tool id.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
$toolDevJSON = $GLOBALS['toolsDevMetaCol']->findOne(array('_id' => $_REQUEST['id']));
if(!isset($toolDevJSON)) {
$_SESSION['errorData']['Error'][] = "The tool id <strong>".$_REQUEST['toolid']."</strong> doesn't exist in our database.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
$toolDevMetaJSON = $GLOBALS['toolsDevMetaCol']->findOne(array('_id' => $_REQUEST['id'], 'user_id' => $_SESSION['User']['id']));
if(!isset($toolDevMetaJSON) && ($_SESSION['User']['Type'] != 0)) {
$_SESSION['errorData']['Error'][] = "The tool id <strong>".$_REQUEST['toolid']."</strong> you are trying to edit doesn't belong to you.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
?>
<?php require "../htmlib/header.inc.php"; ?>
<body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white page-container-bg-solid page-sidebar-fixed">
<div class="page-wrapper">
<?php require "../htmlib/top.inc.php"; ?>
<?php require "../htmlib/menu.inc.php"; ?>
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<!-- BEGIN CONTENT BODY -->
<div class="page-content">
<!-- BEGIN PAGE HEADER-->
<!-- BEGIN PAGE BAR -->
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<span>Admin</span>
<i class="fa fa-circle"></i>
</li>
<li>
<a href="admin/myNewTools.php">My new tools</a>
<i class="fa fa-circle"></i>
</li>
<li>
<span>Generate Test Files</span>
</li>
</ul>
</div>
<!-- END PAGE BAR -->
<!-- BEGIN PAGE TITLE-->
<h1 class="page-title"> Generate Test Files - define I/O</h1>
<!-- END PAGE TITLE-->
<!-- END PAGE HEADER-->
<div class="row">
<div class="col-md-12">
<?php
$error_data = false;
if ($_SESSION['errorData']){
$error_data = true;
?>
<?php if ($_SESSION['errorData']['Info']) { ?>
<div class="alert alert-info">
<?php } else { ?>
<div class="alert alert-danger">
<?php } ?>
<?php
foreach($_SESSION['errorData'] as $subTitle=>$txts){
print "<strong>$subTitle</strong><br/>";
foreach($txts as $txt){
print "<div>$txt</div>";
}
}
unset($_SESSION['errorData']);
?>
</div>
<?php } ?>
</div>
</div>
<form name="new-tool" id="new-tool" action="applib/updateToolDevIO.php" method="post" >
<div class="row">
<div class="col-md-12">
<p style="margin-top:0;">Paste or write your JSON code in the text area below. Once the JSON is correct,
you can validate it against our <a href="https://raw.githubusercontent.com/Multiscale-Genomics/VRE_tool_jsons/dev/tool_specification/tool_schema_io.json" target="_blank">JSON Schema</a>. Click the buttons below for further information:</p>
<p>
<a class="btn btn-xs green" href="http://multiscalegenomics.eu/MuGVRE/tool-specification-attributes/" target="_blank"><i class="fa fa-tag" aria-hidden="true"></i> Attribute's help</a>
<a class="btn btn-xs green" href="http://multiscalegenomics.eu/MuGVRE/file-types/" target="_blank"><i class="fa fa-list" aria-hidden="true"></i> Available File Types</a>
<a class="btn btn-xs green" href="http://multiscalegenomics.eu/MuGVRE/data-types/" target="_blank"><i class="fa fa-list" aria-hidden="true"></i> Available Data Type</a>
<a class="btn btn-xs green" href="javascript:;" target="_blank"><i class="fa fa-list" aria-hidden="true"></i> List of keywords</a>
</p>
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet light portlet-fit bordered">
<div class="portlet-body form" id="portlet-json">
<input type="hidden" name="toolid" value="<?php echo $_REQUEST['id']; ?>" />
<textarea id="code_editor" name="json_tool" placeholder="Please, paste or write your JSON code here..."><?php echo json_encode($toolDevJSON["step1"]["tool_io"], JSON_PRETTY_PRINT); ?></textarea>
</div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->
<input type="hidden" id="base-url" value="<?php echo $GLOBALS['BASEURL']; ?>" />
<div class="form-actions">
<a href="admin/myNewTools.php" class="btn btn-default">BACK</a>
<input type="submit" class="btn green " id="json-val-subm" value="SUBMIT" style="float:right;">
<input type="button" class="btn green snd-metadata-btn" id="json-val-but" value="VALIDATE JSON" style="float:right;margin-right:5px;">
</div>
</div>
</div>
</form>
<!-- END CONTENT BODY -->
</div>
<!-- END CONTENT -->
<div class="modal fade bs-modal" id="modalJSONSchema" tabindex="-1" role="basic" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">JSON Schema Validation</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn dark btn-outline" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
require "../htmlib/footer.inc.php";
require "../htmlib/js.inc.php";
?>