Commit 1ae990f0 authored by jlopez's avatar jlopez
Browse files

Add tags

parent 9c8ae216
Pipeline #203 failed with stages
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 01/02/19
* Time: 13:55
*/
class Tool
{
}
\ No newline at end of file
...@@ -38,6 +38,7 @@ $visibility = "public"; ...@@ -38,6 +38,7 @@ $visibility = "public";
$description = NULL; $description = NULL;
$author = 0; $author = 0;
$labels = array(); $labels = array();
$tags = "";
if(isset($_POST['containerid'])) { if(isset($_POST['containerid'])) {
$id = $_POST['containerid']; $id = $_POST['containerid'];
...@@ -75,7 +76,13 @@ if(isset($_POST['labels'])) { ...@@ -75,7 +76,13 @@ if(isset($_POST['labels'])) {
$labels = $_POST['labels']; $labels = $_POST['labels'];
} }
$container = new Container($id, $name, $value, $type, $visibility, $description, $author, $today); if(isset($_POST['tags'])) {
$tags = $_POST['tags'];
$tags = preg_replace("/[\n\r]/","",$tags);
$tags = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $tags);
}
$container = new Container($id, $name, $value, $type, $visibility, $description, $author, $today, $tags);
if($action == "create") { if($action == "create") {
$container->escape($db); $container->escape($db);
......
...@@ -9,70 +9,9 @@ $db = new DBquery(); ...@@ -9,70 +9,9 @@ $db = new DBquery();
$containers = $db->getContainers(); $containers = $db->getContainers();
?> require_once "./inc/php/buildHeader.php";
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->
<link rel="stylesheet" href="./inc/css/style.css">
<script src="./inc/js/jscolor.js"></script>
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
<?php
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link active" href="./container.php"> Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
{
echo ' <a class="nav-item nav-link" href="./manage.php"> Manage </a>';
}
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
?>
<div class="container-fluid"> <div class="container-fluid">
...@@ -89,6 +28,7 @@ $containers = $db->getContainers(); ...@@ -89,6 +28,7 @@ $containers = $db->getContainers();
<th>Name</th> <th>Name</th>
<th>Author</th> <th>Author</th>
<th>Labels</th> <th>Labels</th>
<th>Tags</th>
<th>Date</th> <th>Date</th>
<th>Description</th> <th>Description</th>
<th>Action</th> <th>Action</th>
...@@ -154,6 +94,24 @@ $containers = $db->getContainers(); ...@@ -154,6 +94,24 @@ $containers = $db->getContainers();
echo '</td>'; echo '</td>';
$tags = explode( ' ', $container->tags );
$index = 0;
echo '<td>';
foreach ($tags as $tag) {
echo '<span class="badge" style="background:#'."30336b".'; color:#FFFFFF">'.$tag.'</span>';
/*if($index == 3) {
echo '<br/>';
$index = 0;
} else {
$index++;
} */
}
echo '</td>';
echo '<td>' . $container->date . '</td>'; echo '<td>' . $container->date . '</td>';
echo '<td>' . $container->description . '</td>'; echo '<td>' . $container->description . '</td>';
......
...@@ -175,7 +175,7 @@ class DBquery ...@@ -175,7 +175,7 @@ class DBquery
$result = mysqli_query($this->dbh, $sql); $result = mysqli_query($this->dbh, $sql);
$results = array(); $results = array();
while($row = mysqli_fetch_assoc($result)){ while($row = mysqli_fetch_assoc($result)){
$cnt = new Container($row['ID'], $row['name'], $row['value'], $row['type'], $row['visibility'], $row['description'], $row['author'], $row['date']); $cnt = new Container($row['ID'], $row['name'], $row['value'], $row['type'], $row['visibility'], $row['description'], $row['author'], $row['date'], $row['tags']);
array_push($results, $cnt); array_push($results, $cnt);
} }
return $results; return $results;
......
<?php
echo '
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->
<link rel="stylesheet" href="./inc/css/style.css">
<script src="./inc/js/jscolor.js"></script>
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
';
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./container.php"> Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
{
echo ' <a class="nav-item nav-link" href="./manage.php"> Manage </a>';
// echo ' <a class="nav-item nav-link" href="./config.php"> Configs </a>';
}
}
echo '
</div>
<div class="navbar-nav">
';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
echo '</div>
</nav>
';
...@@ -43,70 +43,9 @@ foreach ($db->getAllActiveSectionParent() as $s){ ...@@ -43,70 +43,9 @@ foreach ($db->getAllActiveSectionParent() as $s){
} }
} }
?> require_once "./inc/php/buildHeader.php";
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css" crossorigin="anonymous"-->
<link rel="stylesheet" href="./inc/css/style.css">
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
<?php
echo ' <a class="nav-item nav-link active" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./container.php"> Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
{
echo ' <a class="nav-item nav-link" href="./manage.php"> Manage </a>';
}
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
?>
<div class="container-fluid"> <div class="container-fluid">
...@@ -428,6 +367,10 @@ foreach ($db->getAllActiveSectionParent() as $s){ ...@@ -428,6 +367,10 @@ foreach ($db->getAllActiveSectionParent() as $s){
</select> </select>
</div> </div>
<div class="form-group">
<label for="tagsContainer">Tags :</label>
<textarea class="form-control" rows="5" id="tagsContainer" maxlength="500" name ="tags"></textarea>
</div>
</div> </div>
......
...@@ -6,62 +6,10 @@ ...@@ -6,62 +6,10 @@
* Time: 10:10 * Time: 10:10
*/ */
//include('../include/buildHeader.php'); require_once "./inc/php/buildHeader.php";
?> ?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->
<link rel="stylesheet" href="./inc/css/style.css">
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-0">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav justify-content-center">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./gestion.php"> Gestion </a>';
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
<div class="container-fluid"> <div class="container-fluid">
......
...@@ -47,69 +47,9 @@ foreach ($grades as $grade) { ...@@ -47,69 +47,9 @@ foreach ($grades as $grade) {
} }
} }
?> require_once "./inc/php/buildHeader.php";
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->
<link rel="stylesheet" href="./inc/css/style.css">
<script src="./inc/js/jscolor.js"></script>
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
<?php
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./container.php"> Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
{
echo ' <a class="nav-item nav-link active" href="./manage.php"> Manage </a>';
}
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
?>
<div class="container-fluid"> <div class="container-fluid">
...@@ -737,10 +677,6 @@ foreach ($grades as $grade) { ...@@ -737,10 +677,6 @@ foreach ($grades as $grade) {
<!-- Latest compiled and minified JavaScript --> <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- local fallbaks -->
<!--script src="inc/js/jquery-latest.min.js" type="text/javascript"></script>
<script src="inc/js/bootstrap.min.js" type="text/javascript"></script-->
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -18,6 +18,7 @@ class Container ...@@ -18,6 +18,7 @@ class Container
var $description = ""; var $description = "";
var $author = 0; var $author = 0;
var $date = NULL; var $date = NULL;
var $tags = "";
/** /**
* Container constructor. * Container constructor.
...@@ -25,7 +26,7 @@ class Container ...@@ -25,7 +26,7 @@ class Container
* @param string $name * @param string $name
* @param int $type * @param int $type
*/ */
public function __construct($ID, $name, $value, $type, $visibility, $description, $author, $date) public function __construct($ID, $name, $value, $type, $visibility, $description, $author, $date, $tags)
{ {
$this->ID = $ID; $this->ID = $ID;
$this->name = $name; $this->name = $name;
...@@ -35,29 +36,32 @@ class Container ...@@ -35,29 +36,32 @@ class Container
$this->description = $description; $this->description = $description;
$this->author = $author; $this->author = $author;
$this->date = $date; $this->date = $date;
$this->tags = $tags;
} }
public function escape(DBquery $db) { public function escape(DBquery $db) {
$this->name = utf8_decode($db->escape($this->name)); $this->name = utf8_decode($db->escape($this->name));
$this->value = utf8_decode($db->escape($this->value)); $this->value = utf8_decode($db->escape($this->value));
$this->description = utf8_decode($db->escape($this->description)); $this->description = utf8_decode($db->escape($this->description));
$this->tags = utf8_decode($db->escape($this->tags));
} }
public function escape2(DBquery $db) { public function escape2(DBquery $db) {
$this->name = utf8_encode($db->escape($this->name)); $this->name = utf8_encode($db->escape($this->name));
$this->value = utf8_encode($db->escape($this->value)); $this->value = utf8_encode($db->escape($this->value));
$this->description = utf8_encode($db->escape($this->description)); $this->description = utf8_encode($db->escape($this->description));
$this->tags = utf8_encode($db->escape($this->tags));
} }
public function getInsert() { public function getInsert() {
return "INSERT INTO Container (name, value, type, visibility, description, author, date) return "INSERT INTO Container (name, value, type, visibility, description, author, date, tags)
VALUES ('$this->name', '$this->value', '$this->type', '$this->visibility', '$this->description', '$this->author', '$this->date');"; VALUES ('$this->name', '$this->value', '$this->type', '$this->visibility', '$this->description', '$this->author', '$this->date', '$this->tags');";
} }
public function getUpdate() { public function getUpdate() {
return "UPDATE Container return "UPDATE Container
SET name='$this->name', value='$this->value', type='$this->type', SET name='$this->name', value='$this->value', type='$this->type',
visiblity='$this->visibility', description='$this->description', author='$this->author', date='$this->date' visiblity='$this->visibility', description='$this->description', author='$this->author', date='$this->date', tags='$this->tags'
WHERE ID = '$this->ID';"; WHERE ID = '$this->ID';";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment