217 lines
5.1 KiB
PHP
217 lines
5.1 KiB
PHP
<?php
|
|
require("header.php");
|
|
|
|
|
|
$choose_project = false;
|
|
|
|
if(!isset($_GET['id']) || $_GET['id'] == "")
|
|
{
|
|
|
|
$query = "SELECT `id`, `name` FROM `project`";
|
|
$result = ExecQuery($query);
|
|
|
|
$projects = "";
|
|
|
|
while($row = $result->fetch_assoc())
|
|
{
|
|
$projects .= "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
|
|
}
|
|
|
|
$choose_project = true;
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<!-- Portfolio Item Heading -->
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<h1 class="page-header">Projects</h1>
|
|
</div>
|
|
</div>
|
|
<!-- /.row -->
|
|
|
|
<?php if($choose_project) { ?>
|
|
|
|
<!-- New Project -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<h3>Select project</h3>
|
|
|
|
<form id="select-project" type="GET" action="edit.php">
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Project</span>
|
|
<select class="form-control" name="id">
|
|
<?php echo $projects; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php } else { ?>
|
|
|
|
<!-- New Project -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<h3>Add a new project</h3>
|
|
|
|
<form id="project-add" type="POST" action="php/project-add.php">
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Name</span>
|
|
<input type="text" class="form-control" id="project-name" name="name" maxlength="64" onchange="onProjectNameChange()" required>
|
|
<input type="hidden" id="project-uid" name="uid" maxlength="64" required>
|
|
<span class="input-group-addon" id="project-name-uid"></span>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Language</span>
|
|
<input type="text" class="form-control" name="language" maxlength="32" required>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Date</span>
|
|
<input type="text" class="form-control" name="date" maxlength="32" required>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Grade</span>
|
|
<input type="text" class="form-control" name="grade" maxlength="3" required>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<label for="body">Body</label>
|
|
<textarea class="form-control" name="body" required></textarea>
|
|
|
|
<br/>
|
|
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function onProjectNameChange()
|
|
{
|
|
var nameuid = $("#project-name").val().toLowerCase().trim().replace(/ /g, '-').replace(/[^a-zA-Z0-9-_]/g, '').substring(0,64);
|
|
$("#project-name-uid").html( nameuid );
|
|
$("#project-uid").val(nameuid);
|
|
}
|
|
</script>
|
|
|
|
<hr>
|
|
|
|
<!-- Add media -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<h3>Add media</h3>
|
|
|
|
<form id="project-media" type="POST" action="php/project-media.php" enctype="multipart/form-data">
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Name</span>
|
|
<input type="text" class="form-control" name="name" maxlength="64" required>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Project</span>
|
|
<select class="form-control" name="project">
|
|
<?php echo $projects; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">File type</span>
|
|
<select class="form-control" name="type">
|
|
<option value="image">Image</option>
|
|
<option value="video">Video</option>
|
|
<option value="audio">Audio</option>
|
|
</select>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="form-group">
|
|
<label for="mediafile">File input</label>
|
|
<input type="file" name="file" class="form-control" id="mediafile">
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add file -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<h3>Add file</h3>
|
|
|
|
<form id="project-file" type="POST" action="php/project-file.php" enctype="multipart/form-data">
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Name</span>
|
|
<input type="text" class="form-control" id="file-name" name="name" maxlength="64" onchange="onFileNameChange()" required>
|
|
<input type="hidden" id="file-uid" name="uid" maxlength="64" required>
|
|
<span class="input-group-addon" id="file-name-uid"></span>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="input-group">
|
|
<span class="input-group-addon">Project</span>
|
|
<select class="form-control" name="project">
|
|
<?php echo $projects; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="form-group">
|
|
<label for="filefile">File input</label>
|
|
<input type="file" name="file" class="form-control" id="filefile">
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function onMediaNameChange()
|
|
{
|
|
var nameuid = $("#file-name").val().toLowerCase().trim().replace(/ /g, '-').replace(/[^a-zA-Z0-9-_]/g, '').substring(0,64);
|
|
$("#file-name-uid").html( nameuid );
|
|
$("#file-uid").val(nameuid);
|
|
}
|
|
</script>
|
|
|
|
<?php
|
|
}
|
|
|
|
require("footer.php");
|
|
?>
|