forked from NYCPlanning/edm-metadata-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_readme.php
More file actions
439 lines (376 loc) · 20.7 KB
/
edit_readme.php
File metadata and controls
439 lines (376 loc) · 20.7 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<?php
include ('navbar.php');
include ('readme_upload.php');
include ('dd_upload.php');
include ('readme_edit_submission.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])){
$id = $_POST['id'];
} else{
$id_query = "SELECT uid FROM readme WHERE sde_name = '$sde_name_underscore'";
$id_results = pg_query($id_query);
$id_row = pg_fetch_assoc($id_results);
$id = $id_row['uid'];
}
$readme_query = "SELECT * FROM readme WHERE uid = $id";
$readme_results = pg_query($readme_query);
$readme_row = pg_fetch_assoc($readme_results);
$uid = $readme_row['uid'];
$common_name = $readme_row['common_name'];
$sde_name = $readme_row['sde_name'];
$tags_guide = $readme_row['tags_guide'];
$tags_sde = $readme_row['tags_sde'];
$summary = $readme_row['summary'];
$summary_update_date = $readme_row['summary_update_date'];
$description = $readme_row['description'];
$description_data_loc = $readme_row['description_data_loc'];
$data_steward = $readme_row['data_steward'];
$data_engineer = $readme_row['data_engineer'];
$credits = $readme_row['credits'];
$genconst = $readme_row['genconst'];
$legconst = $readme_row['legconst'];
$update_freq = $readme_row['update_freq'];
$date_last_update = $readme_row['date_last_update'];
$date_underlying_data = $readme_row['date_underlying_data'];
$data_source = $readme_row['data_source'];
$version = $readme_row['version'];
$common_uses = $readme_row['common_uses'];
$data_quality = $readme_row['data_quality'];
$caveats = $readme_row['caveats'];
$future_plans = $readme_row['future_plans'];
$distribution = $readme_row['distribution'];
$contact = $readme_row['contact'];
$data_access = $readme_row['data_access'];
$sde_name_normalize = trim($sde_name);
$sde_name_underscore = str_replace(' ', '_', $sde_name_normalize);
// Checks if user is admin or super
$privilege = FALSE;
if (($_SESSION["type"] == 'superuser') || ($_SESSION["type"] == 'admin')) {
$privilege = TRUE;
}
// If $privilege is false then check if user has access from collaboration
if(!$privilege){
$user = $_SESSION["user"];
// Check if user have access to this dataset in the collaboration table
$query = "SELECT sdename FROM collaboration WHERE email = '$user'";
$result = pg_query($query);
$arr = pg_fetch_all($result);
foreach($arr as $v) {
if($v["sdename"] == $sde_name){
$privilege = TRUE;
}
}
}
// If dataset name doesn't exist in database send user back to Main.php
if (!isset($id) || !$privilege) {
echo '<script>';
echo 'window.location.href="Main.php"'; //not showing an alert box.
echo '</script>';
}
?>
<style>
li {
list-style: none;
}
.border-bottom {
border-bottom: 1px solid #DFE0E5;
box-shadow: 0 5px 5px -3px #DFE0E5;
}
.common-name-header{
margin: 0;
padding: 7px;
}
.common-name-header h3{
display: inline;
}
.fa-pen {
margin-left: 5px;
padding-bottom: 3px;
font-size: 18px;
}
.readme-header-container {
width: 100%;
padding: 15px 0 0 0;
}
.readme-header-container h4{
margin: -9px 0 0 0;
}
.readme-header-container button{
margin: -12px 10px 0 0;
}
.dd-header-container h4{
margin: 10px 0 0 0;
}
.dd-header-container a {
margin: 10px 10px 0 0;
}
.dd-header-container button{
margin: 9px 10px 0 0;
}
.left-container {
float: left;
width: 250px;
}
.right-container {
float: right;
width: 180px;
}
.common-name-header h3 {
margin: 0;
}
.dd-header-container {
width: 100%;
padding: 20px 0 0 0;
}
#wrapper {
width: 100%;
max-height: 100vh;
}
#top-div {
float: left;
width: 100%;
height: 45%;
overflow: auto;
padding: 0.4em;
}
#top-div textarea{
border-color: #D6D7DB;
border-width: 1.5px;
}
#bottom-div {
float: left;
width: 100%;
height: 30%;
overflow: auto;
padding: 0.4em;
}
/* code for creating a table structure using css */
table, td, th {
border: 0.5px solid #D6D7DB;
text-align: left;
}
th, td {
padding: 10px;
}
i {
color: black;
}
i:hover {
color: #D96B27;
}
/* Hide the UID of the table */
.uid0 {
display: none;
}
.text-right a{
margin-right: 10px;
}
.dd-header-container a {
margin: 10px 10px 0 0;
}
/* upload Overlay */
.upload-modal{
margin-top: 20%;
}
.dataset-delete {
margin-left: 5px;
font-size: 18px;
}
</style>
<div class="common-name-header border-bottom">
<h3 id="common-name-delete"><?php echo $common_name; ?></h3>
<input type="hidden" id="sde-name-delete" value="<?php echo $sde_name_underscore; ?>">
<input type="hidden" id="readme-id" value="<?php echo $id; ?>">
<a id="deleteData"><i class="far fa-trash-alt dataset-delete"></i></a>
</div>
<div class="readme-header-container">
<div class="container left-container">
<h4>Readme</h4>
</div>
<div class="upload-readme container right-container">
<div class="modal fade upload-modal" id="readme-upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header text-center">
<h4 class="modal-title w-100 font-weight-bold">Readme</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form action="display.php?id=<?php echo $id;?>" class="form-horizontal" method="post" name="upload_excel" enctype="multipart/form-data">
<fieldset>
<div class="form-group">
<label class="col-md-4 control-label" for="filebutton">Select File</label>
<div class="col-md-4">
<input type="file" name="file" id="readme-file" class="input-large" accept=".xml,.csv">
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-5">
<button type="submit" id="submit" name="readme_submit" data-loading-text="Loading...">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<div class="text-right">
<input type="submit" id="tableSubmit" value="Save" name="readme_save_button" form="readme-form" class="btn btn-default btn-rounded mb-4" style="padding-top:-15px;"/>
<a href="" class="btn btn-default btn-rounded mb-4" data-toggle="modal" data-target="#readme-upload">Upload From File</a>
</div>
</div>
</div>
<div id="wrapper">
<!-- Top Div -->
<div id="top-div" class="border-bottom">
<form name="readme" action="display.php?selection=<?php echo $selection;?>&id=<?php echo $id;?>" id="readme-form" method="POST" >
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="hidden" name="sde_old" value="<?php echo $sde_name; ?>">
<li>Common Name <a data-toggle="tooltip" data-placement="top" title="Descriptive name without underscores or abbreviations"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="common_name" style="width:500px;" value="<?php echo $common_name; ?>"/></li>
<br>
<li>SDE Name <a data-toggle="tooltip" data-placement="top" title="Name of the SDE data set"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="sde_name" style="width:500px;" value="<?php echo $sde_name; ?>" required/></li> <!-- this field is made mandatory by adding 'required' -->
<br>
<li>Tags for Guide <a data-toggle="tooltip" data-placement="top" title="Enter search terms for the data set. These will be used to find the data set on the Esri HUB. These tags would be used for the guide."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="tags_guide" style="width:500px;" value="<?php echo $tags_guide; ?>"/></li>
<br>
<li>Tags for SDE <a data-toggle="tooltip" data-placement="top" title="Enter search terms for the data set. These will be used to find the data set on the Esri HUB. These tags would be used for the SDE."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="tags_sde" style="width:500px;" value="<?php echo $tags_sde; ?>"/></li>
<br>
<li>Summary <a data-toggle="tooltip" data-placement="top" title="One or two line description of the data set"><i class="fas fa-info-circle"></i></a></li><li><textarea name="summary" style="height:90px;width:500px;" ><?php echo $summary; ?> </textarea></li>
<br>
<li>Summary - Update Date <a data-toggle="tooltip" data-placement="top" title="Date the summary was updated"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="summary_update_date" style="height:40px;width:500px;" value="<?php echo $summary_update_date; ?>"/></li>
<br>
<li>Description <a data-toggle="tooltip" data-placement="top" title="Concise, high level summary of the data set (no more than one or two paragraphs)."><i class="fas fa-info-circle"></i></a></li><li><textarea name="description" style="height:90px;width:500px;"> <?php echo $description; ?> </textarea></li>
<br>
<li>Description - Data Location <a data-toggle="tooltip" data-placement="top" title="Data location of the dataset"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="description_data_loc" style="width:500px;" value="<?php echo $description_data_loc; ?>"/></li>
<br>
<li>Data Steward <a data-toggle="tooltip" data-placement="top" title="The group or division in DCP that is the business owner for the data set."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="data_steward" style="width:500px;" value="<?php echo $data_steward; ?>"/></li>
<br>
<li>Data Engineer <a data-toggle="tooltip" data-placement="top" title="The group or division in DCP that is the technical owner for the data set. The data engineer cleans, prepares, and optimizes the data set under the guidance of the data steward."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="data_engineer" style="width:500px;" value="<?php echo $data_engineer; ?>"/></li>
<br>
<li>Credits <a data-toggle="tooltip" data-placement="top" title="For data sets received from an outside source and not modified by DCP, list the outside source. If DCP added value to the data, list both the outside source and DCP."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="credits" style="width:500px;" value="<?php echo $credits; ?>"/></li>
<br>
<li>General Constraints Use Limitations <a data-toggle="tooltip" data-placement="top" title="Dataset is being provided by the Department of City Planning (DCP) on DCP's website for informational purposes only. DCP does not warranty the completeness, accuracy, content, or fitness for any particular purpose or use of dataset, nor are any such warranties to be implied or inferred with respect to Dataset as furnished on the website."><i class="fas fa-info-circle"></i></a></li><li><textarea name="genconst" style="height:90px;width:500px;" ><?php echo $genconst; ?></textarea></li>
<br>
<li>Legal Constraints Use Limitations <a data-toggle="tooltip" data-placement="top" title="DCP and the City are not liable for any deficiencies in the completeness, accuracy, content, or fitness for any particular purpose or use of the dataset, or applications utilizing Dataset, provided by any third party."><i class="fas fa-info-circle"></i></a></li><li><textarea name="legconst" style="height:90px;width:500px;" ><?php echo $legconst; ?></textarea></li>
<br>
<!-- <li>Update Frequency:</li><li><input type="text" name="update_freq" /></li> -->
<li>Update Frequency <a data-toggle="tooltip" data-placement="top" title="How often will this data set be updated? For data sets with a regular update schedule, this may be Monthly, Quarterly, or Annually. For one-off data sets, such as those created for a particular study, this may be None planned or As needed."><i class="fas fa-info-circle"></i></a></li>
<select required name="update_freq" id="ddTables" style="font-size:12pt; height:45px; width:500px;">
<option value="<?php echo $update_freq; ?>" selected><?php echo $update_freq; ?></option>
<option value="monthly">Monthly</option>
<option value="biannually">Biannually</option>
<option value="annually">Annually</option>
<option value="quarterly">Quarterly</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="fortnightly">Fortnightly</option>
<option value="as-needed">As Needed</option>
</select>
<br>
<br><li>Date of Last Update <a data-toggle="tooltip" data-placement="top" title="When was the data set last updated? This should be the date that any processing and quality assurance was complete. It is the release date of the data set."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="date_last_update" style="width:500px;" value="<?php echo $date_last_update; ?>"/></li>
<br>
<li>Date of Underlying Data <a data-toggle="tooltip" data-placement="top" title="The “as of” date for the data. For a data set with multiple sources, like MapPLUTO, list each source and the date the data was extracted or received."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="date_underlying_data" style="width:500px;" value="<?php echo $date_underlying_data; ?>"/></li>
<br>
<li>Data Sources and Compilation Process <a data-toggle="tooltip" data-placement="top" title="If applicable, include a link to GitHub. Otherwise, describe how the data was sourced and processed."><i class="fas fa-info-circle"></i></a></li><li><textarea name="data_source" style="height:90px;width:500px;" ><?php echo $data_source; ?></textarea></li>
<br>
<li>Version <a data-toggle="tooltip" data-placement="top" title="If applicable, include the version number, e.g., 17V1 for MapPLUTO"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="version" style="width:500px;" value="<?php echo $version; ?>"/></li>
<br>
<li>Common Uses <a data-toggle="tooltip" data-placement="top" title="Describe any common applications for the dataset (i.e. soft site or CEQR analyses), including primary users of the dataset."><i class="fas fa-info-circle"></i></a></li><li><textarea name="common_uses" style="height:90px;width:500px;" ><?php echo $common_uses; ?></textarea></li>
<br>
<li>Data Quality <a data-toggle="tooltip" data-placement="top" title="If known, include information on the overall accuracy and completeness of the data set. (Information on specific fields should be documented in the data dictionary)."><i class="fas fa-info-circle"></i></a></li><li><textarea name="data_quality" style="height:90px;width:500px;"><?php echo $data_quality; ?></textarea></li>
<br>
<li>Caveats <a data-toggle="tooltip" data-placement="top" title="Outline any pitfalls, potential misconceptions, and/or misuses of the data. This will help users determine if the data set is applicable to their use case and help them avoid using the data incorrectly."><i class="fas fa-info-circle"></i></a></li><li><textarea name="caveats" style="height:90px;width:500px;"><?php echo $caveats; ?></textarea></li>
<br>
<li>Future Plans <a data-toggle="tooltip" data-placement="top" title="If applicable, describe any enhancements planned for the data set."><i class="fas fa-info-circle"></i></a></li><li><textarea name="future_plans" style="height:90px;width:500px;"><?php echo $future_plans; ?></textarea></li>
<br>
<li>Distribution <a data-toggle="tooltip" data-placement="top" title="Who is allowed to use this data set? Specific divisions within DCP, all DCP staff, other city agencies, the public?"><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="distribution" style="width:500px;" value="<?php echo $distribution; ?>"/></li>
<br>
<li>Contact <a data-toggle="tooltip" data-placement="top" title="If known, include contact information for the dataset."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="contact" style="width:500px;" value="<?php echo $contact; ?>"/></li>
<br>
<li>Data Access <a data-toggle="tooltip" data-placement="top" title="The Guide specific, path to layers."><i class="fas fa-info-circle"></i></a></li><li><input type="text" name="data_access" style="width:500px;" value="<?php echo $data_access; ?>"/></li>
<br>
<br>
</form>
</div><!-- /Top Div -->
<div class="dd-header-container">
<div class="container left-container">
<h4>Data Dictionary</h4>
</div>
<div class="text-right dd-header-container">
<a href= "edit.php?id=<?php echo $id; ?>" class="btn btn-default btn-rounded mb-4">Edit</a>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-default btn-rounded mb-4 export-file" data-toggle="modal" data-target="#exportDD">Export</button>
<!-- Modal -->
<div id="exportDD" class="modal fade" role="dialog" style="margin-top: 200px;">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title text-left" style="">Data Dictionary Export</h4>
</div>
<div class="modal-body text-center">
<form class="form-horizontal" action="expcsv_dict.php?sde_normalize=<?php echo $sde_name_normalize;?>&sde_underscore=<?php echo $sde_name_underscore;?>" method="post" name="upload_excel" enctype="multipart/form-data">
<input type="submit" name="Export" class="btn btn-default btn-rounded mb-4" value=".CSV"/>
</form>
<form class="form-horizontal" action="expxml_dict.php?sde_normalize=<?php echo $sde_name_normalize;?>&sde_underscore=<?php echo $sde_name_underscore;?>" method="post" name="upload_excel" enctype="multipart/form-data">
<input type="submit" name="Expor2xml" class="btn btn-default btn-rounded mb-4" value=".XML"/>
</form>
<form class="form-horizontal" action="expmd_dict.php?sde_normalize=<?php echo $sde_name_normalize;?>&sde_underscore=<?php echo $sde_name_underscore;?>" method="post" enctype="multipart/form-data">
<input type="submit" name="Expor2md" class="btn btn-default btn-rounded mb-4" value=".MD"/>
</form>
<form class="form-horizontal" action="exppdf_dict.php?sde_normalize=<?php echo $sde_name_normalize;?>&sde_underscore=<?php echo $sde_name_underscore;?>" method="post" enctype="multipart/form-data">
<input type="submit" name="Expor2pdf" class="btn btn-default btn-rounded mb-4" value=".PDF"/>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bottom Div -->
<div id="bottom-div">
<!-- Display Data Dictionary Table -->
<?php
$data_dict_query = "SELECT * FROM $sde_name_underscore ORDER BY uid";
$data_dict = pg_query($data_dict_query);
//fetching the column names of the dd table
echo '<table class="form-table"> <tr>';
$i = 0;
while ($i < pg_num_fields($data_dict))
{
$fieldName = pg_field_name($data_dict, $i);
$fieldName = ucwords(str_replace("_"," ",$fieldName));
if($fieldName == 'Orders') {
echo '<th class=uid' .$i . '> Order </th>';
} else {
echo '<th class=uid' .$i . '>' . $fieldName . '</th>';
}
$i = $i + 1;
}
echo '</tr>';
$i = 0;
//fetching and displaying the contents of the db table
while ($row = pg_fetch_row($data_dict))
{
echo "<form action=readme-p-update.php?id=".$row[0]." method='post'>";
echo "<tr>";
$count = count($row);
for ($y = 0; $y < $count; $y+=1)
{
$c_row = current($row);
echo "<td class=uid" . $y . ">" . $c_row . "</td>";
next($row);
}
$i = $i + 1;
}
pg_free_result($data_dict);
echo '</form></table>';
?>
</div> <!-- /Bottom Div -->
</div> <!-- /wrapper -->
</body>
</html>