Commit fca7be04 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

Displays card list (can't erase yet)

parent a6710de0
<?php
session_start();
error_reporting(E_ALL);//error_reporting(0); dsactiver
ini_set('display_errors', '1');
header('Content-Type: text/html; charset=UTF-8');
require('./sys/utils.func.php');
require('./sys/db.class.php');
require('./sys/constants.php');
require('./models/user.class.php');
require('./models/userlvl.class.php');
require('./languages/language.php');
//C'est pas beau mais sans mvc ici
$user = user::getInstance();
$userlogged = $user->logged_in();
if ( !$userlogged ){
header('Location: index.php');
}
else{
$title = 'Game of Words / Administration';
include('./views/page.header.html');
include('./controllersJS/menu_lang.js');
include('./sys/load_iso.php');
echo "<h1>".$lang['admin']."</h1>";
require_once('./models/item.factory.class.php');
$cardFactory = new ItemFactory($user->id,$user->langGame);
$card_ids = $cardFactory->get_card_ids(ItemFactory::ALL_CARDS);
require_once('./models/card.class.php');
foreach ($card_ids as $card_id){
$card = new Card($card_id);
$card->set_view("./views/card.inline.admin.display.php");
echo $card;
}
echo "<script>$('.close').click(function() {
$( this ).slideUp();
});</script>";
}
?>
......@@ -203,4 +203,7 @@ $lang['uploadProb'] = 'The file has not been uploaded yet...';
//
$lang['same_lang'] = ' You have chosen twice the same language in langues parlées';
//Administration cartes
$lang['admin'] = "Administration: Press cross to delete card";
?>
......@@ -196,3 +196,5 @@ $lang['uploadProb'] = 'Le fichier n\'a pas été uploadé...';
//
$lang['same_lang'] = 'Vous avez choisi deux fois la même langue dans langues parlées ';
//Administration cartes
$lang['admin'] = "Administration&nbsp;: Cliquer sur la croix pour supprimer la carte";
......@@ -5,6 +5,7 @@ require_once('./sys/db.class.php');//useless (called by Card)
class ItemFactory //a quick and dirty class…
{ //…to encapsulate some "complicated" frequent queries
const ANY = 1;
const ALL_CARDS = 6;
const CARD_NOT_ME = 2;
const CARD_FROM_LEXICON = 5;
const VALID_RECORDING_NOT_ME = 3;
......@@ -98,6 +99,11 @@ class ItemFactory //a quick and dirty class…
$res = false;
}
break;
case self::ALL_CARDS:
//partir sur cette piste ce serait peut être mieux : SELECT `cartes`.*, GROUP_CONCAT(`mots_interdits`.`mot` SEPARATOR '|') as `interdits` FROM `cartes`,`mots_interdits` WHERE `cartes`.`idCarte`=`mots_interdits`.`idCarte` GROUP BY `mots_interdits`.`idCarte` ORDER BY `cartes`.`langue`, `cartes`.`idCarte`
//mais c'est un peu fatiguant…
$this->query = "SELECT `idCarte` as `zeId` FROM `cartes` ORDER BY `langue`, `idCarte` $forOne";//le forOne servira pas, pour la cohérence
break;
default:
$res = false;
break;
......@@ -137,6 +143,23 @@ class ItemFactory //a quick and dirty class…
return $res;
}
public function get_card_ids($queryType, $parameter = NULL){
if($this->generate_query($queryType, $parameter, false)){
$this->db->query($this->query);
$res = $this->db->affected_rows();
if($res >= 1){
$res = array();
while($id = $this->db->fetch_object()){
array_push($res, $id->zeId);
}
}
}
else{
throw new Exception("Not a proper query type '$queryType'.");
}
return $res;
}
public function get_recording($queryType, $parameter = NULL){
if($this->generate_query($queryType,$parameter)){
$this->db->query($this->query);
......
<?php /* Global $card sent by Card class (models/card.class.php) → $res used then in Card class*/
include('./languages/language.php');
echo "<style>.lacarte{margin-left:0.5em; margin-right:0.5em;margin-bottom:1em;padding:3px; position:relative;background-color:lightgrey;display: flex;flex-direction: column;justify-content:space-between;width:250px;float:left}
.lacarte div{margin:0;padding-bottom:4px; padding-top:4px; padding-left:1em; padding-right:1em;}
.lacarte>div{padding:0;}
div.lalangue{font-weight:bold; background-color:grey;color:white;margin-right:16px}
.niveauMin{text-align: right; color:white; position:absolute;top:3px;right:16px; background-color:black;padding:0;}
.categoriecat{background-color:white; margin-bottom:3px}
.motCleCle{text-align:center;font-size:larger;}
.motVedette{font-weight:bold; background-color:#93CEDE}
.thethemes div{font-weight:bold}
.lacarte header{font-weight:normal;font-size:small;text-align:left;}
.auteur{background-color:white; text-align:left;}
.lacarte .close{position:absolute; top:3px; right:3px;padding:0;}</style>";
$res = "<div class='lacarte'>
<div>
<div class='niveauMin'>".$card->get_level()."</div>
<div class='lalangue'>ID&nbsp;: ".$card->get_id()." (".$card->get_lang().")</div>
<div class='close'>×</div>
<!--div class='categoriecat'>".$card->get_cat()."</div-->
<div class='thethemes'>
<header>".$lang['theme']."&nbsp;:</header>";
foreach($card->get_themes() as $theme){
$res .= "<div>$theme</div>";
}
$res.="</div>
</div>
<div>
<div class='motCleCle motVedette'>
<header>".$lang['word_to_find']."&nbsp;:</header>".$card->get_word().
"</div>
<div class='tabous'>
<header>".$lang["wordForbid"]."&nbsp;:</header>";
foreach($card->get_forbidden_words() as $word){
$res .= "<div class='motCleCle'>$word</div>\n";
}
$res .= "</div>
</div>
<!--div>TODO
<div class='auteur'>".$card->get_author()." (".$card->get_time().")</div>
</div-->
</div>";
?>
\ No newline at end of file
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