2013-10-09 23:18:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if(!defined('ONYX')) exit;
|
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
class Theme
|
|
|
|
{
|
2013-10-10 03:52:48 +00:00
|
|
|
var $id = null;
|
2013-10-10 02:47:02 +00:00
|
|
|
var $title;
|
2013-10-09 23:18:49 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
function Theme($id=null)
|
|
|
|
{
|
|
|
|
if (!empty($id))
|
|
|
|
{
|
|
|
|
$db = new BDD();
|
|
|
|
$res = $db->unique_query("SELECT id, title
|
|
|
|
FROM themes WHERE id=" . intval($id));
|
2013-10-09 23:18:49 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
if (!empty($res))
|
|
|
|
{
|
|
|
|
$this->title = $res['title'];
|
|
|
|
}
|
|
|
|
$db->deconnexion();
|
|
|
|
}
|
|
|
|
}
|
2013-10-09 23:18:49 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
function update()
|
|
|
|
{
|
|
|
|
$title = $this->title;
|
|
|
|
|
|
|
|
$db = new BDD();
|
|
|
|
$db->escape($title);
|
|
|
|
|
|
|
|
if (empty($this->id))
|
|
|
|
{
|
|
|
|
$db->query("INSERT INTO themes
|
|
|
|
VALUES (NULL, '".$title."');");
|
|
|
|
$this->id = $db->insert_id();
|
|
|
|
$aff = ($this->id > 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$db->query("UPDATE themes
|
2013-10-09 23:18:49 +00:00
|
|
|
SET title = '".$title."'
|
|
|
|
WHERE id = ".intval($this->id));
|
2013-10-10 02:47:02 +00:00
|
|
|
$aff = $db->affected();
|
|
|
|
}
|
|
|
|
$db->deconnexion();
|
|
|
|
|
|
|
|
return ($aff == 1);
|
|
|
|
}
|
2013-10-09 23:18:49 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
function get_title()
|
|
|
|
{
|
|
|
|
return $this->title;
|
|
|
|
}
|
2013-10-10 01:44:46 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
function get_id()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
2013-10-10 01:44:46 +00:00
|
|
|
|
2013-10-10 02:47:02 +00:00
|
|
|
function add_exercice($exercice)
|
|
|
|
{
|
|
|
|
if (isset($exercice))
|
|
|
|
{
|
|
|
|
$exercice->theme = $this;
|
|
|
|
return $exercice->update(true);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|