Skip to content

Commit

Permalink
Merge pull request #32 from madewild/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
madewild authored Jul 8, 2020
2 parents 9e91cbe + badf762 commit 67d2c1f
Show file tree
Hide file tree
Showing 41 changed files with 5,576 additions and 192 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
* linguist-vendored
*.php linguist-vendored=false
*.php linguist-language=PHP
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
static/secret.php
utils/sync.sh
sync.sh
xml/*test*
14 changes: 14 additions & 0 deletions admin/ajaxData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
include("../static/header.php");

if(!empty($_POST["domain_id"])){
$domainid = $_POST["domain_id"];
$conn = sqlsrv_connect($server, $conninfo);
if ($conn) {
$query = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE termlexid LIKE '$domainid%01-fr' ORDER BY termtext", array(), array("Scrollable" => 'static'));
while ($row = sqlsrv_fetch_array($query)) {
echo '<option value="'.$row["termlexid"].'">'.$row["termtext"].'</option>';
}
}
}
?>
11 changes: 11 additions & 0 deletions admin/delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
include("../static/header.php");

$termlexid = htmlspecialchars($_GET['delete']);
$path = $_SERVER['REQUEST_URI'];
$barepath = strtok($path, '?');
$fullpath = $barepath . "?fiche=" . $termlexid;

echo "<p><a href='" . $fullpath . "'>Retour à la fiche</a></p>";
echo "<p>La fiche " . $termlexid . " n'a heureusement PAS été supprimée !</p>";
?>
113 changes: 113 additions & 0 deletions admin/details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
include("../static/header.php");

$termlexid = htmlspecialchars($_GET['fiche']);
$conn = sqlsrv_connect($server, $conninfo);
if ($conn) {
$query = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE termlexid LIKE '$termlexid'", array(), array("Scrollable" => 'static'));
$row = sqlsrv_fetch_array($query);
}

$path = $_SERVER['REQUEST_URI'];
$barepath = strtok($path, '?');

echo "<p><a href='" . $barepath . "'>Retour à l'accueil de l'administration</a></p>";

echo "<h3>Fiche détaillée &nbsp;&nbsp;&nbsp;
<a href='" . $barepath . "?update=" . $termlexid . "'><img title='Modifier la fiche' src='icons/edit.png' style='width:24px;height:24px'></a>
<a href='" . $barepath . "?delete=" . $termlexid . "' onclick=\"return confirm('Voulez-vous vraiment supprimer cette fiche ?');\"><img title='Supprimer la fiche' src='icons/delete.png' style='width:24px;height:24px'></a>
</h3>";
echo "<table>";
echo "<tr><td><b>Terme principal en français</b></td><td>" . $row['termtext'] . "</td></tr>";
$variant = $row['variant'];
$mf = False;
if($variant != NULL) {
echo "<tr><td><b>Variante</b></td><td>" . $variant . "</td></tr>";
$mf = True;
}

$langroup_source = $row['langroup'];
$result = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE langroup=$langroup_source AND abbrev=1", array(), array("Scrollable" => 'static'));
$row2 = sqlsrv_fetch_array($result);
if($row2) {
$acro = $row2['termtext'];
echo "<tr><td><b>Abréviation</b></td><td>" . $acro . "</td></tr>";
}

$pos_id = $row['pos'];
if($pos_id == 1) {
$pos = "nom";
} else if($pos_id == 6) {
$pos = "adjectif"; // Also add Verbe
} else {
$pos = "locution";
}
echo "<tr><td><b>Catégorie grammaticale</b></td><td>" . $pos . "</td></tr>";

$gender_id = $row['gender'];
if($gender_id == 4 or $mf) {
$gender = "masculin ou féminin";
} else if($gender_id == 2) {
$gender = "masculin";
} else if($gender_id == 8) {
$gender = "féminin";
} else {
$gender = "";
}
echo "<tr><td><b>Genre</b></td><td>" . $gender . "</td></tr>";

$number_id = $row['number'];
if($number_id == 12) {
$number = "pluriel";
} else {
$number = "singulier";
}
echo "<tr><td><b>Nombre</b></td><td>" . $number . "</td></tr>";

$result = sqlsrv_query($conn, "SELECT termid FROM langroup WHERE id=$langroup_source", array(), array("Scrollable" => 'static'));
$termid = sqlsrv_fetch_array($result)['termid'];

$result = sqlsrv_query($conn, "SELECT definition FROM langroup WHERE termid=$termid AND lang LIKE 'fr%'", array(), array("Scrollable" => 'static'));
$definition = sqlsrv_fetch_array($result)['definition'];
if(!empty($definition)) {
$result = sqlsrv_query($conn, "SELECT * FROM source WHERE termid=$termid AND type='def'", array(), array("Scrollable" => 'static'));
$row = sqlsrv_fetch_array($result);
$bib_id = $row['biblio'];
$source_text_def = $row['text'];
$result = sqlsrv_query($conn, "SELECT title FROM biblio WHERE id=$bib_id", array(), array("Scrollable" => 'static'));
$bib_title_def = sqlsrv_fetch_array($result)['title'];
echo "<tr><td><b>Définition</b></td><td>" . $definition . "</td></tr>";
echo "<tr><td><b>Source de la définition</b></td><td>" . $bib_title_def . ", " . $source_text_def . "</td></tr>";
}

$result = sqlsrv_query($conn, "SELECT explanation FROM langroup WHERE termid=$termid AND lang LIKE 'fr%'", array(), array("Scrollable" => 'static'));
$explanation = sqlsrv_fetch_array($result)['explanation'];
if(!empty($explanation)) {
$result = sqlsrv_query($conn, "SELECT * FROM source WHERE termid=$termid AND type='exp'", array(), array("Scrollable" => 'static'));
$row = sqlsrv_fetch_array($result);
$bib_id = $row['biblio'];
$source_text_exp = $row['text'];
$result = sqlsrv_query($conn, "SELECT title FROM biblio WHERE id=$bib_id", array(), array("Scrollable" => 'static'));
$bib_title_exp = sqlsrv_fetch_array($result)['title'];
echo "<tr><td><b>Explication</b></td><td>" . $explanation . "</td></tr>";
echo "<tr><td><b>Source de l'explication</b></td><td>" . $bib_title_exp . ", " . $source_text_exp . "</td></tr>";
}
echo "</table>";

$result = sqlsrv_query($conn, "SELECT id FROM langroup WHERE termid=$termid AND lang LIKE 'en%'", array(), array("Scrollable" => 'static'));
$langroup_target = sqlsrv_fetch_array($result)['id'];
$results_pref = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE langroup=$langroup_target AND auth=7", array(), array("Scrollable" => 'static'));
if($results_pref === FALSE) {
print_r(sqlsrv_errors(), true);
print_r($langroup_target);
}
$results_admi = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE langroup=$langroup_target AND auth IN (0,9)", array(), array("Scrollable" => 'static'));
$results_depr = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE langroup=$langroup_target AND auth=10", array(), array("Scrollable" => 'static'));

$num_pref = sqlsrv_num_rows($results_pref);
show_trad_admin($conn, $results_pref, "privilégiée");
show_trad_admin($conn, $results_admi, "admise");
show_trad_admin($conn, $results_depr, "à éviter");

echo "</table>";
?>
37 changes: 37 additions & 0 deletions admin/home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php include("../static/header.php"); ?>
<h3>Espace d'administration</h3>
<form class="form" action="" method="get">
<fieldset>
<legend>
Sélectionnez une fiche à modifier &nbsp;&nbsp;&nbsp;
<a href="#" onclick="return confirm('Prochainement disponible...');"><img title='Créer une nouvelle fiche' src='icons/create.png' style='width:24px;height:24px'></a>
</legend>
<nav id="form">
<ul>
<li>
<label for="domain">Domaine</label>
<select id="domain" name="domain">
<option value="P01">Titres et fonctions</option>
<option value="P02">Enseignement supérieur</option>
</select>
</li>
<li>
<label for="fiche">Fiche</label>
<select id="fiche" name="fiche">
<?php
$conn = sqlsrv_connect($server, $conninfo);
if ($conn) {
$query = sqlsrv_query($conn, "SELECT * FROM termgroup WHERE termlexid LIKE 'P01%01-fr' ORDER BY termtext", array(), array("Scrollable" => 'static'));
while ($row = sqlsrv_fetch_array($query)) {
echo '<option value="'.$row["termlexid"].'">'.$row["termtext"].'</option>';
}
}
?>
</select>
</li>
<li><input type="submit" value="Afficher"></li>
</ul>
</nav>
<legend><a href="?import=xml">Importez un nouveau fichier XML</a></legend>
</fieldset>
</form><br>
Binary file added admin/icons/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions admin/icons/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php include('../../static/unauthorised.php'); ?>
17 changes: 17 additions & 0 deletions admin/import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
include("../static/header.php");

$conn = sqlsrv_connect($server, $conninfo);

$path = $_SERVER['REQUEST_URI'];
$barepath = strtok($path, '?');

echo "<p><a href='" . $barepath . "'>Retour à l'accueil de l'administration</a></p>";
?>

<h3>Import d'un fichier XML</h3>
<form action="<?php echo $barepath; ?>" method="post" enctype="multipart/form-data">
<p>Choisissez un fichier :
<input type="file" name="fileToUpload" id="fileToUpload">
<button type="submit" value="submit" name="submit">OK</button></p>
</form>
Loading

0 comments on commit 67d2c1f

Please sign in to comment.