Commit ee3dc835 authored by GROSS-AMBLARD David's avatar GROSS-AMBLARD David
Browse files

Removes show-pages.php, dispatches its functions in respective /pages

parent 37b37074
......@@ -27,7 +27,6 @@ require_once("lib/artifacts.php");
require_once("pages/skills/skills.php");
require_once("tasks.php");
require_once("connection.php");
require_once("show-pages.php");
require_once("pages/workflowdesign/workflowdesign.php");
require_once("pages/showCredit/showCredit.php");
require_once("pages/showState/showState.php");
......
......@@ -584,5 +584,137 @@ function insertJsonAnswer($conn, $id, $activity_id,$answer,$mass){
}
/**
* showQueryAnswer
*
* Display the result of a query in a table titled $title
*
* @param $conn :
* A valid database PDO connection
* @param $title :
* A title
* @param $query :
* A valid query
*/
function showQueryAnswer($conn, $title, $query, $exception = null)
{
global $VIEW;
if ($exception == null) :
$exception = array();
endif;
$VIEW['MAIN'] .= "\n<div><table class='table table-striped'><caption>$title</caption>";
try {
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$first = true;
while ($line = ($stmt->fetch())) {
if ($first) {
$VIEW['MAIN'] .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$VIEW['MAIN'] .= "<th>$k</th>";
endif;
}
$VIEW['MAIN'] .= "</tr>";
$first = false;
}
$VIEW['MAIN'] .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$VIEW['MAIN'] .= "<td>" . showValue($v) . "</td>";
endif;
}
$VIEW['MAIN'] .= "</tr>";
}
} catch (PDOException $e) {
$VIEW['MAIN'] .= "Error: " . $e->getMessage();
}
$conn = null;
$VIEW['MAIN'] .= "</table></div>";
// debug($query);
}
/**
* showQueryAnswerAsString
*
* return the result of a query in a table titled $title as a string
*
* @param $conn :
* A valid database PDO connection
* @param $title :
* A title
* @param $query :
* A valid query
*/
function showQueryAnswerAsString($conn, $title, $query, $exception = null)
{
if ($exception == null) :
$exception = array();
endif;
if(!$query) return;
$res = "\n<div><table class='table table-striped'><caption>$title</caption>";
try {
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$first = true;
while ($line = ($stmt->fetch())) {
if ($first) {
$res .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$res .= "<th>$k</th>";
endif;
}
$res .= "</tr>";
$first = false;
}
$res .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$res .= "<td>" . showValue($v) . "</td>";
endif;
}
$res .= "</tr>";
}
} catch (PDOException $e) {
$res .= "Error: " . $e->getMessage();
}
$res .= "</table></div>";
return $res;
}
/**
* showValue : return an image if it is an image and a text otherwise
*/
function showValue($v)
{
if (is_string($v)) :
if (substr($v, - 3) === 'jpg') :
return '<img src=' . $v . ' alt=' . $v . ' width=200></img>';
endif;
endif;
return $v;
}
function showHome()
{
global $VIEW;
$VIEW['MAIN'] = file_get_contents("home.html");
}
?>
<?php
/*
* showAwaitingActivities
*
* Show startable artifacts, registered with the broadcast user
*
* @param $conn : A valid database PDO connection
*
*/
function showAwaitingActivites($conn)
{
global $VIEW;
startAllArtifact($conn, $_SESSION['id']);
return;
// Showing startable artifacts, registered with the broadcast user
$table = $conn->query("select description, Artifact.id,concat('index.php?mode=startArtifact&artifactid=',min(Artifact.id)),'details' from Artifact,ArtifactClass where project='" . $_SESSION['project'] . "' and Artifact.classid=ArtifactClass.id and Artifact.ownerid=0 group by Artifact.classid");
$mylist = $table->fetchAll(PDO::FETCH_NUM);
if (empty($mylist))
$mylist = array(
array(
"<div class=\"alert alert-success\" role=\"alert\">Everything is active !</div>",
"",
""
)
);
$VIEW["MAIN"] .=
HTMLh1("Waiting activities in ".
$_SESSION['project']).
BSMakeListGroup($mylist, $_SESSION['activity_id']).
HTMLbr();
}
/**
* showQueryAnswer
*
* Display the result of a query in a table titled $title
*
* @param $conn :
* A valid database PDO connection
* @param $title :
* A title
* @param $query :
* A valid query
*/
function showQueryAnswer($conn, $title, $query, $exception = null)
{
global $VIEW;
if ($exception == null) :
$exception = array();
endif;
$VIEW['MAIN'] .= "\n<div><table class='table table-striped'><caption>$title</caption>";
try {
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$first = true;
while ($line = ($stmt->fetch())) {
if ($first) {
$VIEW['MAIN'] .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$VIEW['MAIN'] .= "<th>$k</th>";
endif;
}
$VIEW['MAIN'] .= "</tr>";
$first = false;
}
$VIEW['MAIN'] .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$VIEW['MAIN'] .= "<td>" . showValue($v) . "</td>";
endif;
}
$VIEW['MAIN'] .= "</tr>";
}
} catch (PDOException $e) {
$VIEW['MAIN'] .= "Error: " . $e->getMessage();
}
$conn = null;
$VIEW['MAIN'] .= "</table></div>";
// debug($query);
}
/**
* showQueryAnswerAsString
*
* return the result of a query in a table titled $title as a string
*
* @param $conn :
* A valid database PDO connection
* @param $title :
* A title
* @param $query :
* A valid query
*/
function showQueryAnswerAsString($conn, $title, $query, $exception = null)
{
if ($exception == null) :
$exception = array();
endif;
if(!$query) return;
$res = "\n<div><table class='table table-striped'><caption>$title</caption>";
try {
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$first = true;
while ($line = ($stmt->fetch())) {
if ($first) {
$res .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$res .= "<th>$k</th>";
endif;
}
$res .= "</tr>";
$first = false;
}
$res .= "\n<tr>";
foreach ($line as $k => $v) {
if (! in_array($k, $exception)) :
$res .= "<td>" . showValue($v) . "</td>";
endif;
}
$res .= "</tr>";
}
} catch (PDOException $e) {
$res .= "Error: " . $e->getMessage();
}
$res .= "</table></div>";
return $res;
}
/**
* showValue : return an image if it is an image and a text otherwise
*/
function showValue($v)
{
if (is_string($v)) :
if (substr($v, - 3) === 'jpg') :
return '<img src=' . $v . ' alt=' . $v . ' width=200></img>';
endif;
endif;
return $v;
}
function showHome()
{
global $VIEW;
$VIEW['MAIN'] = file_get_contents("home.html");
}
......@@ -7,7 +7,6 @@ require("pages/skills/skills.php");
require("tasks.php");
require("actions.php");
require("connection.php");
require("show-pages.php");
require("lib/artifacts.php");
require("show-artifact.php");
require("drawArtifact.php");
......
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